| 178 | } |
| 179 | |
| 180 | public static void AddLocalizationForTuningEntries() |
| 181 | { |
| 182 | try |
| 183 | { |
| 184 | string currentUIName, csvContents = File.ReadAllText(Constants.LocalizationCSV_CustomPath); |
| 185 | int newIndex = 37500; |
| 186 | |
| 187 | using (StreamWriter sw = new StreamWriter(Constants.LocalizationCSV_CustomPath, true)) |
| 188 | { |
| 189 | foreach (var tuningDefinition in TuningsCollection) |
| 190 | { |
| 191 | currentUIName = tuningDefinition.Value.UIName; |
| 192 | var tuning = SplitTuningUIName(currentUIName); |
| 193 | string index = tuning.Item1; |
| 194 | string onlyName = tuning.Item2; |
| 195 | |
| 196 | if (index == "0") // I.e. if it does not contain an index, give it one |
| 197 | { |
| 198 | while (csvContents.Contains(newIndex.ToString())) // Efficient ? Nope, but does the job |
| 199 | newIndex++; |
| 200 | |
| 201 | tuningDefinition.Value.UIName = String.Format("$[{0}]{1}", newIndex, onlyName); // Append its index in front |
| 202 | index = newIndex.ToString(); |
| 203 | } |
| 204 | |
| 205 | if (!csvContents.Contains(index)) // If the CSV already contains that index, don't add it to it |
| 206 | { |
| 207 | sw.Write(sw.NewLine); |
| 208 | sw.Write(index); |
| 209 | for (int i = 0; i < 7; i++) |
| 210 | { |
| 211 | sw.Write(','); |
| 212 | sw.Write(tuning.Item2); |
| 213 | } |
| 214 | |
| 215 | csvContents += index; |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | catch (IOException ioex) |
| 221 | { |
| 222 | MessageBox.Show("Error: " + ioex.Message.ToString(), "Error"); |
| 223 | } |
| 224 | |
| 225 | SaveTuningsJSON(); |
| 226 | } |
| 227 | |
| 228 | public static void SaveTuningsJSON() |
| 229 | { |