diff --git a/project/code/TMV/InstallPaths.cs b/project/code/TMV/InstallPaths.cs new file mode 100644 index 0000000..44da648 --- /dev/null +++ b/project/code/TMV/InstallPaths.cs @@ -0,0 +1,50 @@ +using System.IO; +using Godot; + +namespace KeepersCompound.TMV; + +// TODO: Error handling lol +public class InstallPaths +{ + public string rootPath; + public string famPath; + public string omsPath; + public string fmsPath; + + public InstallPaths(string root) + { + var searchOptions = new EnumerationOptions + { + MatchCasing = MatchCasing.CaseInsensitive, + RecurseSubdirectories = true + }; + + rootPath = root; + famPath = Directory.GetFiles(rootPath, "fam.crf", searchOptions)[0]; + var installCfgPath = Directory.GetFiles(rootPath, "install.cfg", searchOptions)[0]; + GD.Print($"Install.cfg: {installCfgPath}"); + foreach (var line in File.ReadLines(installCfgPath)) + { + if (line.StartsWith("load_path")) + { + var path = line.Split(" ")[1].Replace("\\", "/"); + omsPath = Path.GetFullPath(rootPath + path); + break; + } + } + + var camModPath = Directory.GetFiles(rootPath, "cam_mod.ini", searchOptions)[0]; + fmsPath = rootPath + "/FMs"; + foreach (var line in File.ReadLines(camModPath)) + { + if (line.StartsWith("fm_path")) + { + var path = line.Split(" ")[1].Replace("\\", "/"); + fmsPath = Path.GetFullPath(rootPath + path); + break; + } + } + + GD.Print($"OMs Path: {omsPath}"); + } +} \ No newline at end of file diff --git a/project/code/TMV/TextureLoader.cs b/project/code/TMV/TextureLoader.cs index 54a081e..b7f9a60 100644 --- a/project/code/TMV/TextureLoader.cs +++ b/project/code/TMV/TextureLoader.cs @@ -60,6 +60,7 @@ public partial class TextureLoader public bool Load(int id, string path) { + // TODO: Handle lowercase .pcx :) var userTexturesPath = ProjectSettings.GlobalizePath($"user://textures{path}.PCX"); var loaded = false; diff --git a/project/code/TMV/UI/MissionSelector.cs b/project/code/TMV/UI/MissionSelector.cs index f0bdffa..6076ee9 100644 --- a/project/code/TMV/UI/MissionSelector.cs +++ b/project/code/TMV/UI/MissionSelector.cs @@ -1,4 +1,5 @@ using System.IO; +using System.Linq; using Godot; namespace KeepersCompound.TMV.UI; @@ -8,26 +9,33 @@ public partial class MissionSelector : Control [Signal] public delegate void LoadMissionEventHandler(string path); + private InstallPaths _installPaths; + private FileDialog _FolderSelect; private LineEdit _FolderPath; private Button _BrowseButton; + private ItemList _Campaigns; private ItemList _Missions; private Button _LoadButton; private Button _CancelButton; public override void _Ready() { + // TODO: Load initial folderpath from config and prefil everything + _FolderSelect = GetNode("%FolderSelect"); _FolderPath = GetNode("%FolderPath"); _BrowseButton = GetNode