Skip to content

Commit

Permalink
Search for tutorial.ini from all file manager directories
Browse files Browse the repository at this point in the history
  • Loading branch information
Rampastring committed Jan 13, 2025
1 parent bc9b913 commit 258c8af
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/TSMapEditor/CCEngine/CCFileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,25 @@ public void LoadStringTable(string name)
CsfFiles.Add(file);
}

/// <summary>
/// Searches for a file from all search directories.
/// If found, returns the full path to the found file.
/// Otherwise returns null.
/// </summary>
/// <param name="fileName">The name of the file to look for.</param>
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)
Expand Down
7 changes: 6 additions & 1 deletion src/TSMapEditor/UI/Windows/MainMenuWindows/MapSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 258c8af

Please sign in to comment.