Merge GetMissionNames to handle null campaign
This commit is contained in:
parent
3270d89b05
commit
be205897bb
|
@ -114,20 +114,17 @@ public class ResourcePathManager
|
||||||
return null;
|
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)
|
public List<string> GetMissionNames(string campaignName)
|
||||||
{
|
{
|
||||||
if (!_initialised) return null;
|
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);
|
var names = new List<string>(campaign.missionPathMap.Keys);
|
||||||
names.Sort();
|
names.Sort();
|
||||||
|
|
|
@ -77,10 +77,7 @@ public partial class MissionSelector : Control
|
||||||
_LoadButton.Disabled = true;
|
_LoadButton.Disabled = true;
|
||||||
|
|
||||||
var campaignName = _Campaigns.GetItemText((int)idx);
|
var campaignName = _Campaigns.GetItemText((int)idx);
|
||||||
var missionNames = (idx == 0) ?
|
var missionNames = pathManager.GetMissionNames(idx == 0 ? null : campaignName);
|
||||||
pathManager.GetMissionNames() :
|
|
||||||
pathManager.GetMissionNames(campaignName);
|
|
||||||
|
|
||||||
foreach (var mission in missionNames)
|
foreach (var mission in missionNames)
|
||||||
{
|
{
|
||||||
_Missions.AddItem(mission);
|
_Missions.AddItem(mission);
|
||||||
|
|
Loading…
Reference in New Issue