From 164194ef50384f448dbc866316414549175f4522 Mon Sep 17 00:00:00 2001 From: iisaev Date: Thu, 22 Oct 2026 19:14:58 +0200 Subject: [PATCH] Content re-read through SceneManager.ReloadContent --- src/Runtime/StudioLayer.cs | 13 ++----------- src/Runtime/StudioLive.cs | 4 ++-- test_suites/live/src/StudioLiveDriverNode.cs | 2 +- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/Runtime/StudioLayer.cs b/src/Runtime/StudioLayer.cs index f33711a..1f70a45 100644 --- a/src/Runtime/StudioLayer.cs +++ b/src/Runtime/StudioLayer.cs @@ -62,7 +62,7 @@ namespace Cthangover.Mods.ScenarioStudio Directory.CreateDirectory(Path.Combine(RootPath, "scenes")); Directory.CreateDirectory(Path.Combine(RootPath, "backgrounds")); ModOverlays.Mount(Id, new FolderModFileProvider(RootPath, Id)); - RefreshContent(); + SceneManager.ReloadContent(); GameLogger.Log("UI", $"Scenario studio: layer '{Id}' mounted at {RootPath}"); } @@ -102,7 +102,7 @@ namespace Cthangover.Mods.ScenarioStudio name = $"{scene}_studio_{n}"; Write($"scenarios/{name}.scenario", $"scene: {scene}\npriority: 50\n---\n{firstLine}\nend\n"); - RefreshContent(); + SceneManager.ReloadContent(); return name; } @@ -141,15 +141,6 @@ namespace Cthangover.Mods.ScenarioStudio return target; } - /// Makes the next scene composition and the scene table see changed scenario and scene files. - public static void RefreshContent() - { - ScenarioDefs.Invalidate(); - ModManager.Instance.GetResolver()?.ClearCache(); - AppServices.Current.SceneDefs.Clear(); - SceneManager.RescanScenes(); - } - private string ScenarioFile(string name) => Path.Combine(RootPath, "scenarios", name + ".scenario"); private static void CopyTree(string from, string to) diff --git a/src/Runtime/StudioLive.cs b/src/Runtime/StudioLive.cs index 2caebfa..621343b 100644 --- a/src/Runtime/StudioLive.cs +++ b/src/Runtime/StudioLive.cs @@ -270,7 +270,7 @@ namespace Cthangover.Mods.ScenarioStudio File.WriteAllText(ModManager.Instance.GetFileSystemPath(evt.SourceModId, evt.SourcePath), copy.Text); _copies.Remove(evt.ID); - StudioLayer.RefreshContent(); + SceneManager.ReloadContent(); Journal.Add(StudioLogCategory.Edit, new StudioText("studio/log_text_applied", evt.ID, pending, target.ModId)); GameLogger.Log("UI", $"Scenario studio: applied {pending} change(s) of '{evt.ID}' to '{target.ModId}'"); Restart(StudioRestartMode.Rollback); @@ -484,7 +484,7 @@ namespace Cthangover.Mods.ScenarioStudio } var scenario = Layer.CreateScene(name, backgrounds, StudioScriptEdits.NewLine()); - StudioLayer.RefreshContent(); + SceneManager.ReloadContent(); Journal.Add(StudioLogCategory.Edit, new StudioText("studio/log_text_scene_created", name, scenario)); Touch(); return true; diff --git a/test_suites/live/src/StudioLiveDriverNode.cs b/test_suites/live/src/StudioLiveDriverNode.cs index d28790c..52d0ad2 100644 --- a/test_suites/live/src/StudioLiveDriverNode.cs +++ b/test_suites/live/src/StudioLiveDriverNode.cs @@ -582,7 +582,7 @@ namespace Cthangover.Mods.ScenarioStudio.Tests.Live if (string.IsNullOrEmpty(root) || !Directory.Exists(root)) return; ModOverlays.Unmount(StudioLayer.Id); - StudioLayer.RefreshContent(); + SceneManager.ReloadContent(); Directory.Delete(root, true); var parent = Path.GetDirectoryName(root); if (parent != null && Directory.GetFileSystemEntries(parent).Length == 0)