Content re-read through SceneManager.ReloadContent
This commit is contained in:
1 parent
92d78d07cd
commit
164194ef50
3 files changed
+5
-14
No files matched your search
@@ -62,7 +62,7 @@ namespace Cthangover.Mods.ScenarioStudio
|
|||||||
Directory.CreateDirectory(Path.Combine(RootPath, "scenes"));
|
Directory.CreateDirectory(Path.Combine(RootPath, "scenes"));
|
||||||
Directory.CreateDirectory(Path.Combine(RootPath, "backgrounds"));
|
Directory.CreateDirectory(Path.Combine(RootPath, "backgrounds"));
|
||||||
ModOverlays.Mount(Id, new FolderModFileProvider(RootPath, Id));
|
ModOverlays.Mount(Id, new FolderModFileProvider(RootPath, Id));
|
||||||
RefreshContent();
|
SceneManager.ReloadContent();
|
||||||
GameLogger.Log("UI", $"Scenario studio: layer '{Id}' mounted at {RootPath}");
|
GameLogger.Log("UI", $"Scenario studio: layer '{Id}' mounted at {RootPath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ namespace Cthangover.Mods.ScenarioStudio
|
|||||||
name = $"{scene}_studio_{n}";
|
name = $"{scene}_studio_{n}";
|
||||||
|
|
||||||
Write($"scenarios/{name}.scenario", $"scene: {scene}\npriority: 50\n---\n{firstLine}\nend\n");
|
Write($"scenarios/{name}.scenario", $"scene: {scene}\npriority: 50\n---\n{firstLine}\nend\n");
|
||||||
RefreshContent();
|
SceneManager.ReloadContent();
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,15 +141,6 @@ namespace Cthangover.Mods.ScenarioStudio
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Makes the next scene composition and the scene table see changed scenario and scene files.</summary>
|
|
||||||
public static void RefreshContent()
|
|
||||||
{
|
|
||||||
ScenarioDefs.Invalidate();
|
|
||||||
ModManager.Instance.GetResolver<SceneDefinitionResolver>()?.ClearCache();
|
|
||||||
AppServices.Current.SceneDefs.Clear();
|
|
||||||
SceneManager.RescanScenes();
|
|
||||||
}
|
|
||||||
|
|
||||||
private string ScenarioFile(string name) => Path.Combine(RootPath, "scenarios", name + ".scenario");
|
private string ScenarioFile(string name) => Path.Combine(RootPath, "scenarios", name + ".scenario");
|
||||||
|
|
||||||
private static void CopyTree(string from, string to)
|
private static void CopyTree(string from, string to)
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ namespace Cthangover.Mods.ScenarioStudio
|
|||||||
File.WriteAllText(ModManager.Instance.GetFileSystemPath(evt.SourceModId, evt.SourcePath), copy.Text);
|
File.WriteAllText(ModManager.Instance.GetFileSystemPath(evt.SourceModId, evt.SourcePath), copy.Text);
|
||||||
|
|
||||||
_copies.Remove(evt.ID);
|
_copies.Remove(evt.ID);
|
||||||
StudioLayer.RefreshContent();
|
SceneManager.ReloadContent();
|
||||||
Journal.Add(StudioLogCategory.Edit, new StudioText("studio/log_text_applied", evt.ID, pending, target.ModId));
|
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}'");
|
GameLogger.Log("UI", $"Scenario studio: applied {pending} change(s) of '{evt.ID}' to '{target.ModId}'");
|
||||||
Restart(StudioRestartMode.Rollback);
|
Restart(StudioRestartMode.Rollback);
|
||||||
@@ -484,7 +484,7 @@ namespace Cthangover.Mods.ScenarioStudio
|
|||||||
}
|
}
|
||||||
|
|
||||||
var scenario = Layer.CreateScene(name, backgrounds, StudioScriptEdits.NewLine());
|
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));
|
Journal.Add(StudioLogCategory.Edit, new StudioText("studio/log_text_scene_created", name, scenario));
|
||||||
Touch();
|
Touch();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -582,7 +582,7 @@ namespace Cthangover.Mods.ScenarioStudio.Tests.Live
|
|||||||
if (string.IsNullOrEmpty(root) || !Directory.Exists(root))
|
if (string.IsNullOrEmpty(root) || !Directory.Exists(root))
|
||||||
return;
|
return;
|
||||||
ModOverlays.Unmount(StudioLayer.Id);
|
ModOverlays.Unmount(StudioLayer.Id);
|
||||||
StudioLayer.RefreshContent();
|
SceneManager.ReloadContent();
|
||||||
Directory.Delete(root, true);
|
Directory.Delete(root, true);
|
||||||
var parent = Path.GetDirectoryName(root);
|
var parent = Path.GetDirectoryName(root);
|
||||||
if (parent != null && Directory.GetFileSystemEntries(parent).Length == 0)
|
if (parent != null && Directory.GetFileSystemEntries(parent).Length == 0)
|
||||||
|
|||||||
Reference in new issue
Block a user