From be205897bbe4a04e10237dbeea4078028dbed1e0 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Sun, 25 Aug 2024 10:11:17 +0100 Subject: [PATCH] Merge GetMissionNames to handle null campaign --- project/code/LGS/ResourcePathManager.cs | 17 +++++++---------- project/code/TMV/UI/MissionSelector.cs | 5 +---- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/project/code/LGS/ResourcePathManager.cs b/project/code/LGS/ResourcePathManager.cs index c557553..eb7b248 100644 --- a/project/code/LGS/ResourcePathManager.cs +++ b/project/code/LGS/ResourcePathManager.cs @@ -114,20 +114,17 @@ public class ResourcePathManager return null; } - public List GetMissionNames() - { - if (!_initialised) return null; - - var names = new List(_omResources.missionPathMap.Keys); - names.Sort(); - return names; - } - public List GetMissionNames(string campaignName) { if (!_initialised) return null; - if (_fmResources.TryGetValue(campaignName, out var campaign)) + if (campaignName == null || campaignName == "") + { + var names = new List(_omResources.missionPathMap.Keys); + names.Sort(); + return names; + } + else if (_fmResources.TryGetValue(campaignName, out var campaign)) { var names = new List(campaign.missionPathMap.Keys); names.Sort(); diff --git a/project/code/TMV/UI/MissionSelector.cs b/project/code/TMV/UI/MissionSelector.cs index b84a15e..ddd4e83 100644 --- a/project/code/TMV/UI/MissionSelector.cs +++ b/project/code/TMV/UI/MissionSelector.cs @@ -77,10 +77,7 @@ public partial class MissionSelector : Control _LoadButton.Disabled = true; var campaignName = _Campaigns.GetItemText((int)idx); - var missionNames = (idx == 0) ? - pathManager.GetMissionNames() : - pathManager.GetMissionNames(campaignName); - + var missionNames = pathManager.GetMissionNames(idx == 0 ? null : campaignName); foreach (var mission in missionNames) { _Missions.AddItem(mission);