From 258c8af9a0166f2841c07cb71412a0a0936f8e32 Mon Sep 17 00:00:00 2001 From: Rampastring Date: Mon, 13 Jan 2025 17:11:22 +0200 Subject: [PATCH] Search for tutorial.ini from all file manager directories --- src/TSMapEditor/CCEngine/CCFileManager.cs | 19 +++++++++++++++++++ .../UI/Windows/MainMenuWindows/MapSetup.cs | 7 ++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/TSMapEditor/CCEngine/CCFileManager.cs b/src/TSMapEditor/CCEngine/CCFileManager.cs index f5430eb81..192c0f929 100644 --- a/src/TSMapEditor/CCEngine/CCFileManager.cs +++ b/src/TSMapEditor/CCEngine/CCFileManager.cs @@ -219,6 +219,25 @@ public void LoadStringTable(string name) CsfFiles.Add(file); } + /// + /// Searches for a file from all search directories. + /// If found, returns the full path to the found file. + /// Otherwise returns null. + /// + /// The name of the file to look for. + public string FindFileFromDirectories(string fileName) + { + foreach (string searchDirectory in searchDirectories) + { + string fullPath = Path.Combine(searchDirectory, fileName); + + if (File.Exists(fullPath)) + return fullPath; + } + + return null; + } + public byte[] LoadFile(string name) { foreach (string searchDirectory in searchDirectories) diff --git a/src/TSMapEditor/UI/Windows/MainMenuWindows/MapSetup.cs b/src/TSMapEditor/UI/Windows/MainMenuWindows/MapSetup.cs index 1cadbb298..ece4c1ba6 100644 --- a/src/TSMapEditor/UI/Windows/MainMenuWindows/MapSetup.cs +++ b/src/TSMapEditor/UI/Windows/MainMenuWindows/MapSetup.cs @@ -38,7 +38,12 @@ public static string InitializeMap(string gameDirectory, bool createNew, string var gameConfigIniFiles = new GameConfigINIFiles(gameDirectory, ccFileManager); - var tutorialLines = new TutorialLines(Path.Combine(gameDirectory, Constants.TutorialIniPath), a => windowManager.AddCallback(a, null)); + // Search for tutorial lines from all directories specified in the file manager configuration + string tutorialsPath = ccFileManager.FindFileFromDirectories(Constants.TutorialIniPath); + if (tutorialsPath == null) + tutorialsPath = Path.Combine(gameDirectory, Constants.TutorialIniPath); + + var tutorialLines = new TutorialLines(tutorialsPath, a => windowManager.AddCallback(a, null)); var themes = new Themes(IniFileEx.FromPathOrMix(Constants.ThemeIniPath, gameDirectory, ccFileManager)); var evaSpeeches = new EvaSpeeches(IniFileEx.FromPathOrMix(Constants.EvaIniPath, gameDirectory, ccFileManager)); var sounds = new Sounds(IniFileEx.FromPathOrMix(Constants.SoundIniPath, gameDirectory, ccFileManager));