remove legacy code for XML loading
This commit is contained in:
parent
091c443440
commit
27cfdce912
@ -1,63 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Xml;
|
|
||||||
|
|
||||||
namespace EDPlayerJournal;
|
|
||||||
|
|
||||||
public class HumanReadableMissionName {
|
|
||||||
private static Dictionary<string, string>? humanreadable = null;
|
|
||||||
|
|
||||||
private static void LoadMissions() {
|
|
||||||
try {
|
|
||||||
string dir = AppDomain.CurrentDomain.BaseDirectory;
|
|
||||||
string file = Path.Combine(dir, "MissionNames.xml");
|
|
||||||
|
|
||||||
XmlDocument document = new XmlDocument();
|
|
||||||
|
|
||||||
using (FileStream stream = new FileStream(file, FileMode.Open)) {
|
|
||||||
document.Load(stream);
|
|
||||||
XmlNode? missions = document.DocumentElement;
|
|
||||||
|
|
||||||
if (missions == null ||
|
|
||||||
missions.Name != "Missions" ||
|
|
||||||
missions.ChildNodes == null) {
|
|
||||||
throw new ApplicationException("Invalid XML");
|
|
||||||
}
|
|
||||||
|
|
||||||
humanreadable = new Dictionary<string, string>();
|
|
||||||
|
|
||||||
foreach (XmlNode mission in missions.ChildNodes) {
|
|
||||||
if (mission.Attributes == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
string? mission_key = mission.Attributes["Name"]?.Value;
|
|
||||||
string? mission_name = mission.InnerText;
|
|
||||||
|
|
||||||
if (mission_key == null || mission_name == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
humanreadable.Add(mission_key, mission_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception) {
|
|
||||||
humanreadable = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string? MakeHumanReadableName(string name) {
|
|
||||||
LoadMissions();
|
|
||||||
|
|
||||||
if (humanreadable == null || name == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (humanreadable.ContainsKey(name)) {
|
|
||||||
return humanreadable[name];
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user