diff --git a/src/ScenarioEditor/ScenarioEditorWindow.cs b/src/ScenarioEditor/ScenarioEditorWindow.cs index a335df3..1ecb6a7 100644 --- a/src/ScenarioEditor/ScenarioEditorWindow.cs +++ b/src/ScenarioEditor/ScenarioEditorWindow.cs @@ -246,7 +246,7 @@ namespace Cthangover.Core.UI.Tool.ScenarioEditor _editTabs.SaveCurrentFile(); // The running game caches scenario headers and texts: drop them, so a new or // edited scenario plays on the next entry into its scene without a mod reload. - SceneFileService.RefreshGame(); + SceneManager.ReloadContent(); SetStatus(string.Format(ToolUi.Tr("tools/common/saved"), ScenarioFileService.GetDisplayPath(modId, relativePath)), ToolStatusKind.Ok); _infoPanel.Update(text); _thumbPanel.Load(text); diff --git a/src/SceneEditor/SceneEditorWindow.cs b/src/SceneEditor/SceneEditorWindow.cs index 989fdc0..237be88 100644 --- a/src/SceneEditor/SceneEditorWindow.cs +++ b/src/SceneEditor/SceneEditorWindow.cs @@ -29,7 +29,7 @@ namespace Cthangover.Tools.SceneEditor /// one of them — the file of the mod chosen in "Save to": the scene's own file when /// that mod defines it, otherwise a new file that adds to a foreign scene without /// touching the foreign mod. Backgrounds of the other files are shown locked, with - /// their mod. After saving the game re-reads scenes (), + /// their mod. After saving the game re-reads scenes (), /// so a new scene can be entered at once with "Go to scene". /// public partial class SceneEditorWindow : ToolWindow @@ -466,7 +466,7 @@ namespace Cthangover.Tools.SceneEditor } var created = _isNew; - SceneFileService.RefreshGame(); + SceneManager.ReloadContent(); var name = _sceneName; var mod = _target.ModId; LoadSources(); @@ -496,7 +496,7 @@ namespace Cthangover.Tools.SceneEditor } var path = _target.ModId + "/" + _target.RelativePath; - SceneFileService.RefreshGame(); + SceneManager.ReloadContent(); LoadSources(); if (FilesOf(_sceneName).Any()) { @@ -558,7 +558,7 @@ namespace Cthangover.Tools.SceneEditor SetStatus(ToolUi.Tr("tools/common/readonly"), ToolStatusKind.Error); return; } - SceneFileService.RefreshGame(); + SceneManager.ReloadContent(); RefreshAll(); OpenScenarioEditor(key); SetStatus(string.Format(ToolUi.Tr("tools/scene_editor/scenario_created"), key), ToolStatusKind.Ok); diff --git a/src/Services/SceneFileService.cs b/src/Services/SceneFileService.cs index 906a2b7..ebdb8b6 100644 --- a/src/Services/SceneFileService.cs +++ b/src/Services/SceneFileService.cs @@ -10,11 +10,9 @@ namespace Cthangover.Tools.Services { /// /// Scene files (scenes/**.json) of the loaded mods for the scene editor: reading - /// them per mod in load order (the order the game merges them in), writing one, and - /// making the running game see the change at once. The game caches scene definitions - /// and scenario headers; drops those caches and lets - /// rescan, the same steps the scenario studio takes after - /// creating a scene in its layer, so a new scene can be entered without a mod reload. + /// them per mod in load order (the order the game merges them in), writing and deleting + /// one. After a write the caller runs , so a new + /// scene can be entered without a mod reload. /// public static class SceneFileService { @@ -62,15 +60,6 @@ namespace Cthangover.Tools.Services return true; } - /// Makes the running game re-read scene files and scenario headers. - public static void RefreshGame() - { - ScenarioDefs.Invalidate(); - ModManager.Instance.GetResolver()?.ClearCache(); - AppServices.Current.SceneDefs.Clear(); - SceneManager.RescanScenes(); - } - private static void Collect(IModFileProvider provider, string modId, string directory, List result) { foreach (var entry in provider.ListFiles(directory)) diff --git a/test_suites/novel_flow/src/NovelFlowTestDriver.cs b/test_suites/novel_flow/src/NovelFlowTestDriver.cs index afae6b3..0dd19b8 100644 --- a/test_suites/novel_flow/src/NovelFlowTestDriver.cs +++ b/test_suites/novel_flow/src/NovelFlowTestDriver.cs @@ -107,7 +107,7 @@ namespace Cthangover.Tools.Tests.NovelFlow townOriginal = ModFileService.ReadText(Mod, TownScenario); File.WriteAllText(ProjectSettings.GlobalizePath(Backup), townOriginal ?? string.Empty); DeleteParkFiles(); - SceneFileService.RefreshGame(); + SceneManager.ReloadContent(); Check(townOriginal != null && !Scenes.HasScene(Park), "the novel runs in the town, no park yet"); OpenToolFromToolbar("tools/scene_editor/title"); Next(); @@ -351,7 +351,7 @@ namespace Cthangover.Tools.Tests.NovelFlow ModFileService.WriteText(Mod, TownScenario, townOriginal); File.Delete(ProjectSettings.GlobalizePath(Backup)); DeleteParkFiles(); - SceneFileService.RefreshGame(); + SceneManager.ReloadContent(); GameLogger.Log("TEST", $"[TEST_RESULT] name=novel_flow passed={passed} failed={failures.Count}"); GetTree().Quit(failures.Count == 0 ? 0 : 1); } diff --git a/test_suites/windows/src/ToolWindowsExercises.cs b/test_suites/windows/src/ToolWindowsExercises.cs index 31dd069..a2fe88b 100644 --- a/test_suites/windows/src/ToolWindowsExercises.cs +++ b/test_suites/windows/src/ToolWindowsExercises.cs @@ -155,7 +155,7 @@ namespace Cthangover.Tools.Tests.Windows finally { DeleteLeftovers(scenePath, scenarioPath); - SceneFileService.RefreshGame(); + SceneManager.ReloadContent(); } }