Merge GetMissionNames to handle null campaign

This commit is contained in:
Jarrod Doyle 2024-08-25 10:11:17 +01:00
parent 3270d89b05
commit be205897bb
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
2 changed files with 8 additions and 14 deletions

View File

@ -114,20 +114,17 @@ public class ResourcePathManager
return null;
}
public List<string> GetMissionNames()
{
if (!_initialised) return null;
var names = new List<string>(_omResources.missionPathMap.Keys);
names.Sort();
return names;
}
public List<string> GetMissionNames(string campaignName)
{
if (!_initialised) return null;
if (_fmResources.TryGetValue(campaignName, out var campaign))
if (campaignName == null || campaignName == "")
{
var names = new List<string>(_omResources.missionPathMap.Keys);
names.Sort();
return names;
}
else if (_fmResources.TryGetValue(campaignName, out var campaign))
{
var names = new List<string>(campaign.missionPathMap.Keys);
names.Sort();

View File

@ -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);