Skip to content

Commit c1a94ed

Browse files
committed
ModAPI.Common: refactor InstalledMods.cs
1 parent b0b11f0 commit c1a94ed

1 file changed

Lines changed: 9 additions & 17 deletions

File tree

ModAPI.Common/InstalledMods.cs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void Save(XmlDocument document, XmlElement parent)
120120
parent.AppendChild(element);
121121
}
122122

123-
public void Load(XmlDocument document, XmlNode node)
123+
public void Load(XmlNode node)
124124
{
125125
var nameAttribute = node.Attributes.GetNamedItem("name");
126126
if (nameAttribute != null)
@@ -206,8 +206,9 @@ public void RemoveMod(ModConfiguration mod)
206206

207207
}
208208

209-
public void Save(string path)
209+
public void Save()
210210
{
211+
string path = GetDefaultPath();
211212
var document = new XmlDocument();
212213

213214
var mainNode = document.CreateElement(InstalledMods.ElementName);
@@ -221,30 +222,26 @@ public void Save(string path)
221222
document.Save(path);
222223
}
223224

224-
public void Save()
225-
{
226-
Save(GetDefaultPath());
227-
}
228-
229-
public void Load(XmlDocument document, XmlNode node)
225+
public void Load(XmlNode node)
230226
{
231227
foreach (XmlNode child in node.ChildNodes)
232228
{
233229
if (child.Name == ModConfiguration.ElementName)
234230
{
235231
var mod = new ModConfiguration(null);
236-
mod.Load(document, child);
232+
mod.Load(child);
237233

238234
ModConfigurations.Add(mod);
239235
}
240236

241237
}
242238
}
243239

244-
public bool Load(string path)
240+
public bool Load()
245241
{
246242
ModConfigurations.Clear();
247243

244+
string path = GetDefaultPath();
248245
if (File.Exists(path))
249246
{
250247
string xmlIn = File.ReadAllText(path);
@@ -257,7 +254,7 @@ public bool Load(string path)
257254
{
258255
if (node.Name == InstalledMods.ElementName)
259256
{
260-
Load(document, node);
257+
Load(node);
261258
}
262259
}
263260
}
@@ -270,15 +267,10 @@ public bool Load(string path)
270267
}
271268
}
272269

273-
public bool Load()
274-
{
275-
return Load(GetDefaultPath());
276-
}
277-
278270
public static string GetDefaultPath()
279271
{
280272
var programPath = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
281-
return Path.Combine(new string[] {programPath, FileName});
273+
return Path.Combine(programPath, FileName);
282274
}
283275
}
284276
}

0 commit comments

Comments
 (0)