diff --git a/HumanReadableMissionName.cs b/HumanReadableMissionName.cs new file mode 100644 index 0000000..f315277 --- /dev/null +++ b/HumanReadableMissionName.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EDJournal { + public class HumanReadableMissionName { + /* TODO: make this a file at some point for easier editing. + */ + private static readonly Dictionary humanreadable = new Dictionary { + { "Mission_AltruismCredits_Bust_name", "Donate Credits (Bust)" }, + { "Mission_AltruismCredits_name", "Donate Credits" }, + { "Mission_Collect_Bust_name", "Provide (Bust)" }, + { "Mission_Collect_CivilLiberty_name", "Provide (Civil Liberty)" }, + { "Mission_Collect_CivilUnrest_name", "Provide (Civil Unrest)" }, + { "Mission_Collect_Famine_name", "Provide (Famine)" }, + { "Mission_Collect_name", "Provide" }, + { "Mission_Courier_Democracy_name", "Courier (Democracy)" }, + { "Mission_Courier_Elections_name", "Courier (Elections)" }, + { "Mission_Courier_Famine_name", "Courier (Famine)" }, + { "Mission_Courier_Lockdown_name", "Courier (Lockdown)" }, + { "Mission_Courier_name", "Courier" }, + { "Mission_Courier_RankEmp_name", "Courier (Empire)" }, + { "Mission_Delivery_Agriculture_name", "Delivery (Agriculture)" }, + { "Mission_Delivery_Boom_name", "Delivery (Boom)" }, + { "Mission_Delivery_Democracy_name", "Delivery (Democracy)" }, + { "Mission_Delivery_Investment_name", "Delivery (Investment)" }, + { "Mission_Delivery_name", "Delivery" }, + { "Mission_Delivery_RankEmp_name", "Delivery (Imperial Rank)" }, + { "Mission_Delivery_Retreat_name", "Delivery (Retreat)" }, + { "Mission_Hack_BLOPS_Boom_name", "Hack Megaship (Black Ops)" }, + { "Mission_HackMegaship_name", "Hack Megaship" }, + { "Mission_LongDistanceExpedition_name", "Long Distance Expedition" }, + { "Mission_Massacre_Conflict_CivilWar_name", "Massacre (Civil War)" }, + { "Mission_Massacre_name", "Massacre" }, + { "Mission_Massacre_RankEmp_name", "Massacre (Imperial Navy)" }, + { "Mission_MassacreWing_Legal_Bust_name", "Massacre (Wing) (Bust)" }, + { "Mission_MassacreWing_name", "Massacre (Wing)" }, + { "Mission_OnFoot_Collect_MB_name", "On Foot Collection" }, + { "Mission_OnFoot_Onslaught_MB_name", "On Foot Onslaught" }, + { "Mission_OnFoot_Onslaught_Offline_MB_name", "On Foot Onslaught (Offline)" }, + { "Mission_OnFoot_ProductionHeist_Covert_MB_name", "On Foot Production Heist (Covert)" }, + { "Mission_OnFoot_Reboot_MB_name", "On Foot Reboot" }, + { "Mission_OnFoot_RebootRestore_MB_name", "On Foot Reboot/Restore" }, + { "Mission_OnFoot_Sabotage_Production_Covert_MB_name", "On Foot Sabotage Production (Covert)" }, + { "Mission_OnFoot_Salvage_MB_name", "On Foot Salvage" }, + { "Mission_PassengerVIP_name", "Sightseeing (VIP)" }, + { "Mission_Rescue_Planet_name", "Planet Rescue" }, + { "MISSION_Salvage_CivilUnrest_name", "Salvage (Civil Unrest)" }, + { "MISSION_Salvage_Expansion_name", "Salvage (Expansion)" }, + { "MISSION_Salvage_Illegal_name", "Salvage (Illegal)" }, + { "Mission_Salvage_name", "Salvage" }, + { "Mission_Salvage_RankEmp_name", "Salvage (Imperial Navy)" }, + { "MISSION_Salvage_Retreat_name", "Salvage (Retreat)" }, + { "MISSION_Scan_name", "Scan" }, + { "Mission_Sightseeing_name", "Sightseeing" }, + }; + + public static string MakeHumanReadableName(string name) { + if (name == null) { + return null; + } + + if (humanreadable.ContainsKey(name)) { + return humanreadable[name]; + } + + return null; + } + } +} diff --git a/MissionCompletedEntry.cs b/MissionCompletedEntry.cs index d593e32..6f9473f 100644 --- a/MissionCompletedEntry.cs +++ b/MissionCompletedEntry.cs @@ -13,54 +13,6 @@ namespace EDJournal { private int donated = 0; private int id = 0; - /* TODO: make this a file at some point for easier editing. - */ - private static readonly Dictionary humanreadable = new Dictionary { - { "Mission_AltruismCredits_Bust_name", "Donate Credits (Bust)" }, - { "Mission_AltruismCredits_name", "Donate Credits" }, - { "Mission_Collect_Bust_name", "Provide (Bust)" }, - { "Mission_Collect_CivilLiberty_name", "Provide (Civil Liberty)" }, - { "Mission_Collect_CivilUnrest_name", "Provide (Civil Unrest)" }, - { "Mission_Collect_Famine_name", "Provide (Famine)" }, - { "Mission_Collect_name", "Provide" }, - { "Mission_Courier_Democracy_name", "Courier (Democracy)" }, - { "Mission_Courier_Elections_name", "Courier (Elections)" }, - { "Mission_Courier_Famine_name", "Courier (Famine)" }, - { "Mission_Courier_Lockdown_name", "Courier (Lockdown)" }, - { "Mission_Courier_name", "Courier" }, - { "Mission_Courier_RankEmp_name", "Courier (Empire)" }, - { "Mission_Delivery_Agriculture_name", "Delivery (Agriculture)" }, - { "Mission_Delivery_Boom_name", "Delivery (Boom)" }, - { "Mission_Delivery_Democracy_name", "Delivery (Democracy)" }, - { "Mission_Delivery_Investment_name", "Delivery (Investment)" }, - { "Mission_Delivery_name", "Delivery" }, - { "Mission_Delivery_RankEmp_name", "Delivery (Imperial Rank)" }, - { "Mission_Delivery_Retreat_name", "Delivery (Retreat)" }, - { "Mission_Hack_BLOPS_Boom_name", "Hack Megaship (Black Ops)" }, - { "Mission_HackMegaship_name", "Hack Megaship" }, - { "Mission_Massacre_Conflict_CivilWar_name", "Massacre (Civil War)" }, - { "Mission_Massacre_name", "Massacre" }, - { "Mission_Massacre_RankEmp_name", "Massacre (Imperial Navy)" }, - { "Mission_MassacreWing_Legal_Bust_name", "Massacre (Wing) (Bust)" }, - { "Mission_MassacreWing_name", "Massacre (Wing)" }, - { "Mission_OnFoot_Collect_MB_name", "On Foot Collection" }, - { "Mission_OnFoot_Onslaught_MB_name", "On Foot Onslaught" }, - { "Mission_OnFoot_Onslaught_Offline_MB_name", "On Foot Onslaught (Offline)" }, - { "Mission_OnFoot_ProductionHeist_Covert_MB_name", "On Foot Production Heist (Covert)" }, - { "Mission_OnFoot_Reboot_MB_name", "On Foot Reboot" }, - { "Mission_OnFoot_RebootRestore_MB_name", "On Foot Reboot/Restore" }, - { "Mission_OnFoot_Sabotage_Production_Covert_MB_name", "On Foot Sabotage Production (Covert)" }, - { "Mission_OnFoot_Salvage_MB_name", "On Foot Salvage" }, - { "Mission_Rescue_Planet_name", "Planet Rescue" }, - { "MISSION_Salvage_CivilUnrest_name", "Salvage (Civil Unrest)" }, - { "MISSION_Salvage_Expansion_name", "Salvage (Expansion)" }, - { "MISSION_Salvage_Illegal_name", "Salvage (Illegal)" }, - { "Mission_Salvage_name", "Salvage" }, - { "Mission_Salvage_RankEmp_name", "Salvage (Imperial Navy)" }, - { "MISSION_Salvage_Retreat_name", "Salvage (Retreat)" }, - { "MISSION_Scan_name", "Scan" }, - }; - protected override void Initialise() { MakeHumanReadableName(); id = JSON.Value("MissionID") ?? 0; @@ -82,20 +34,14 @@ namespace EDJournal { public int MissionID => id; private void MakeHumanReadableName() { - if (readable_name != null && readable_name.Length > 0) { + if (readable_name != null) { return; } - if (Name == null) { - return; - } + string readable = HumanReadableMissionName.MakeHumanReadableName(Name); + StringBuilder builder = new StringBuilder(); - StringBuilder builder; - - if (humanreadable.ContainsKey(Name)) { - builder = new StringBuilder(humanreadable[Name]); - readable_name_generated = false; - } else { + if (readable == null) { builder = new StringBuilder(Name); builder.Replace("Mission_", ""); builder.Replace("_name", ""); @@ -109,6 +55,8 @@ namespace EDJournal { builder.Replace("RebootRestore", "Reboot/Restore"); builder.Replace("CivilLiberty", ""); readable_name_generated = true; + } else { + builder.Append(readable); } if (count > 0 && commodity != null) { diff --git a/MissionFailedEntry.cs b/MissionFailedEntry.cs index 1f41d02..a7d4255 100644 --- a/MissionFailedEntry.cs +++ b/MissionFailedEntry.cs @@ -4,6 +4,12 @@ public int MissionID { get; set; } public int Fine { get; set; } + public string HumanReadableName { + get { + return HumanReadableMissionName.MakeHumanReadableName(Name); + } + } + protected override void Initialise() { Name = JSON.Value("Name") ?? ""; MissionID = JSON.Value("MissionID") ?? 0; diff --git a/edjournal.csproj b/edjournal.csproj index c20ddae..c111d3f 100644 --- a/edjournal.csproj +++ b/edjournal.csproj @@ -50,6 +50,7 @@ +