Merge GetMissionPath to one function

This commit is contained in:
Jarrod Doyle 2024-08-25 10:03:52 +01:00
parent 56a5aa6869
commit 659843c743
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
2 changed files with 13 additions and 23 deletions

View File

@ -93,26 +93,24 @@ public class ResourcePathManager
return names; return names;
} }
public string GetMissionPath(string missionName)
{
if (!_initialised) return null;
if (_omResources.missionPathMap.TryGetValue(missionName, out var path))
{
return path;
}
return null;
}
public string GetMissionPath(string campaignName, string missionName) public string GetMissionPath(string campaignName, string missionName)
{ {
if (!_initialised) return null; if (!_initialised) return null;
if (_fmResources.TryGetValue(campaignName, out var campaign) && if (campaignName == null || campaignName == "")
campaign.missionPathMap.TryGetValue(missionName, out var path))
{ {
return path; if (_omResources.missionPathMap.TryGetValue(missionName, out var omPath))
{
return omPath;
}
} }
else if (
_fmResources.TryGetValue(campaignName, out var campaign) &&
campaign.missionPathMap.TryGetValue(missionName, out var fmPath))
{
return fmPath;
}
return null; return null;
} }

View File

@ -51,15 +51,7 @@ public partial class Mission : Node3D
missionSelector.pathManager = _installPaths; missionSelector.pathManager = _installPaths;
missionSelector.MissionSelected += (string campaign, string mission) => missionSelector.MissionSelected += (string campaign, string mission) =>
{ {
if (campaign == null) FileName = _installPaths.GetMissionPath(campaign, mission);
{
FileName = _installPaths.GetMissionPath(mission);
}
else
{
FileName = _installPaths.GetMissionPath(campaign, mission);
}
Build = true; Build = true;
}; };
} }