diff --git a/project/code/LGS/ResourcePathManager.cs b/project/code/LGS/ResourcePathManager.cs index ec31c1c..50f0cdb 100644 --- a/project/code/LGS/ResourcePathManager.cs +++ b/project/code/LGS/ResourcePathManager.cs @@ -5,7 +5,7 @@ using System.Linq; namespace KeepersCompound.LGS; -// TODO: Support FMs resource paths! +// TODO: Merge the two versions of GetXXX and handle null campaign string as OM public class ResourcePathManager { private record CampaignResources @@ -84,6 +84,13 @@ public class ResourcePathManager return false; } + public string[] GetCampaignNames() + { + if (!_initialised) return null; + + return _fmResources.Keys.ToArray(); + } + public string GetMissionPath(string missionName) { if (!_initialised) return null; @@ -107,6 +114,24 @@ public class ResourcePathManager return null; } + public string[] GetMissionNames() + { + if (!_initialised) return null; + + return _omResources.missionPathMap.Keys.ToArray(); + } + + public string[] GetMissionNames(string campaignName) + { + if (!_initialised) return null; + + if (_fmResources.TryGetValue(campaignName, out var campaign)) + { + return campaign.missionPathMap.Keys.ToArray(); + } + return null; + } + public string GetTexturePath(string textureName) { if (!_initialised) return null; diff --git a/project/code/TMV/Mission.cs b/project/code/TMV/Mission.cs index cd3c9c9..918fbf6 100644 --- a/project/code/TMV/Mission.cs +++ b/project/code/TMV/Mission.cs @@ -48,11 +48,18 @@ public partial class Mission : Node3D var extractPath = ProjectSettings.GlobalizePath($"user://extracted/tmp"); _installPaths = new ResourcePathManager(extractPath); var missionSelector = GetNode("%MissionSelector") as MissionSelector; - missionSelector.LoadMission += (string rootPath, string missionPath) => + missionSelector.pathManager = _installPaths; + missionSelector.LoadMission += (string campaign, string mission) => { - var inited = _installPaths.Init(rootPath); - GD.Print($"Inited paths: {inited}"); - FileName = missionPath; + if (campaign == null) + { + FileName = _installPaths.GetMissionPath(mission); + } + else + { + FileName = _installPaths.GetMissionPath(campaign, mission); + } + Build = true; }; } diff --git a/project/code/TMV/UI/MissionSelector.cs b/project/code/TMV/UI/MissionSelector.cs index 338363c..712f945 100644 --- a/project/code/TMV/UI/MissionSelector.cs +++ b/project/code/TMV/UI/MissionSelector.cs @@ -1,15 +1,14 @@ -using System.IO; -using System.Linq; using Godot; +using KeepersCompound.LGS; namespace KeepersCompound.TMV.UI; public partial class MissionSelector : Control { [Signal] - public delegate void LoadMissionEventHandler(string rootPath, string missionPath); + public delegate void LoadMissionEventHandler(string campaign, string mission); - private InstallPaths _installPaths; + public ResourcePathManager pathManager; private FileDialog _FolderSelect; private LineEdit _FolderPath; @@ -22,7 +21,6 @@ public partial class MissionSelector : Control public override void _Ready() { // TODO: Load initial folderpath from config and prefil everything - _FolderSelect = GetNode("%FolderSelect"); _FolderPath = GetNode("%FolderPath"); _BrowseButton = GetNode