Skip to content

Commit de574c5

Browse files
Merge pull request #369 from X-Hax/config-edit-modification
Config Editing Update
2 parents 9eecf9a + bad7d2a commit de574c5

1 file changed

Lines changed: 0 additions & 39 deletions

File tree

SA-Mod-Manager/ModsCommon/ModConfig.xaml.cs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Globalization;
44
using System.IO;
55
using System.Linq;
6-
using System.Security.Cryptography.X509Certificates;
76
using System.Threading.Tasks;
87
using System.Windows;
98
using System.Windows.Controls;
@@ -95,7 +94,6 @@ private async void ResetButton_Click(object sender, RoutedEventArgs e)
9594
Init();
9695
}
9796

98-
9997
private void CancelButton_Click(object sender, RoutedEventArgs e)
10098
{
10199
ModConfig.allGroupBoxes.Clear();
@@ -151,7 +149,6 @@ private void ToggleHeader_GroupBox(object sender, bool toggle)
151149
}
152150
}
153151

154-
155152
private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)
156153
{
157154

@@ -207,7 +204,6 @@ private void SearchBox_LostFocus(object sender, RoutedEventArgs e)
207204
}
208205
}
209206

210-
211207
private IEnumerable<FrameworkElement> FindAllControls(DependencyObject parent)
212208
{
213209
if (parent == null)
@@ -253,15 +249,11 @@ private void SearchAndFilter(string searchTerm)
253249

254250
}
255251

256-
257-
258252
public class ConfigSettings
259253
{
260254
public ConfigSchema schema;
261255
public Dictionary<string, Dictionary<string, string>> configINI;
262256
private string configfilename;
263-
public Dictionary<string, Dictionary<string, string>> modINI;
264-
private string modiniFilename;
265257
public string modPath;
266258
public bool modNeedRefresh = false;
267259

@@ -270,8 +262,6 @@ public ConfigSettings(string path)
270262
modPath = path;
271263
schema = ConfigSchema.Load(Path.Combine(path, "configschema.xml"));
272264
configfilename = Path.Combine(path, "config.ini");
273-
modiniFilename = Path.Combine(modPath, "mod.ini");
274-
modINI = Ini.IniFile.Load(modiniFilename);
275265

276266
if (File.Exists(configfilename))
277267
configINI = Ini.IniFile.Load(configfilename);
@@ -287,22 +277,6 @@ public ConfigSettings(string path)
287277
{
288278
if (!configINI[group.Name].ContainsKey(prop.Name))
289279
configINI[group.Name].Add(prop.Name, prop.DefaultValue);
290-
291-
//for basic mods config without code injection
292-
if (modINI is not null && prop.Name.ToLower().Contains("includedir"))
293-
{
294-
if (!modINI.ContainsKey("Config"))
295-
modINI.Add("Config", []);
296-
297-
var value = prop.DefaultValue;
298-
if (IsEnum(prop.Type) && int.TryParse(value, out int result))
299-
{
300-
var EnumProp = GetEnum(prop.Type).Members[result];
301-
value = string.IsNullOrEmpty(EnumProp.DisplayName) ? EnumProp.Name : EnumProp.DisplayName;
302-
}
303-
304-
modINI["Config"].TryAdd(prop.Name, value);
305-
}
306280
}
307281

308282

@@ -324,11 +298,6 @@ public void Save()
324298
}
325299

326300
Ini.IniFile.Save(configINI, configfilename);
327-
if (modINI != null)
328-
{
329-
Ini.IniFile.Save(modINI, modiniFilename);
330-
}
331-
332301

333302
FileInfo fileInfo = new(configfilename);
334303

@@ -355,9 +324,6 @@ public void ResetValues()
355324
var EnumProp = GetEnum(prop.Type).Members[result];
356325
value = string.IsNullOrEmpty(EnumProp.DisplayName) ? EnumProp.Name : EnumProp.DisplayName;
357326
}
358-
359-
if (IsEnum(prop.Type))
360-
modINI["Config"][prop.Name] = value;
361327
}
362328

363329
}
@@ -373,7 +339,6 @@ public ConfigSchemaEnum GetEnum(string name)
373339
return schema.Enums.SingleOrDefault(a => a.Name == name);
374340
}
375341

376-
377342
public bool IsEnum(string name)
378343
{
379344
string s = name.ToLower();
@@ -398,11 +363,8 @@ public void SetPropertyValue(string groupName, string propertyName, string value
398363
string enumName = GetEnum(type).Members[result].DisplayName;
399364
value = string.IsNullOrEmpty(enumName) ? value : enumName;
400365
}
401-
402-
modINI["Config"][propertyName] = value;
403366
}
404367
}
405-
406368
}
407369
}
408370

@@ -476,7 +438,6 @@ public int GetEnumIndex(string disp)
476438
return i;
477439
return 0;
478440
}
479-
480441
public void SetValue(object value)
481442
{
482443
switch (type)

0 commit comments

Comments
 (0)