New map written through SceneFileEntry, re-read through SceneManager.ReloadContent

This commit is contained in:
cthangover committed 2026-10-22 19:14:57 +02:00
1 parent d50af2e910
commit fcdd2a041b
2 files changed
+7 -9

No files matched your search

+6 -8
View File
@@ -28,7 +28,7 @@ namespace Cthangover.Tools.RpgEditor
/// first tile of the first tileset, and the first save also writes /// first tile of the first tileset, and the first save also writes
/// <c>scenes/&lt;id&gt;.json</c> when the mod has no such scene, because the /// <c>scenes/&lt;id&gt;.json</c> when the mod has no such scene, because the
/// map id is the scene name; the game re-reads its scenes right away /// map id is the scene name; the game re-reads its scenes right away
/// (<see cref="SceneFileService.RefreshGame"/>), so "Play" works on a new map /// (<see cref="SceneManager.ReloadContent"/>), so "Play" works on a new map
/// without a mod reload. /// without a mod reload.
/// <para/> /// <para/>
/// After a save the map is put into the running game's map cache, and a /// After a save the map is put into the running game's map cache, and a
@@ -38,7 +38,6 @@ namespace Cthangover.Tools.RpgEditor
public partial class RpgMapEditorWindow : ToolWindow public partial class RpgMapEditorWindow : ToolWindow
{ {
private const string MapDir = "maps"; private const string MapDir = "maps";
private const string SceneDir = "scenes";
private readonly RpgTextures textures = new(); private readonly RpgTextures textures = new();
private readonly Dictionary<RpgEditLayer, Button> layerButtons = new(); private readonly Dictionary<RpgEditLayer, Button> layerButtons = new();
@@ -257,7 +256,7 @@ namespace Cthangover.Tools.RpgEditor
var sceneNote = isNew ? EnsureScene() : null; var sceneNote = isNew ? EnsureScene() : null;
if (sceneNote != null) if (sceneNote != null)
SceneFileService.RefreshGame(); SceneManager.ReloadContent();
isNew = false; isNew = false;
MarkClean(); MarkClean();
PublishToGame(json); PublishToGame(json);
@@ -268,12 +267,11 @@ namespace Cthangover.Tools.RpgEditor
/// <summary>Writes <c>scenes/&lt;id&gt;.json</c> for a new map when the mod has none; returns a status suffix.</summary> /// <summary>Writes <c>scenes/&lt;id&gt;.json</c> for a new map when the mod has none; returns a status suffix.</summary>
private string EnsureScene() private string EnsureScene()
{ {
var scenePath = SceneDir + "/" + document.Map.ID + ".json"; var scene = new SceneFileEntry { ModId = modId, Name = document.Map.ID, RelativePath = SceneFileEntry.PathFor(document.Map.ID) };
if (!string.IsNullOrEmpty(ModFileService.ReadText(modId, scenePath))) if (!string.IsNullOrEmpty(ModFileService.ReadText(modId, scene.RelativePath)))
return null; return null;
var json = "{\n \"name\": \"" + document.Map.ID + "\",\n \"defaultAmbient\": \"\"\n}\n"; return SceneFileService.Write(scene)
return ModFileService.WriteText(modId, scenePath, json) ? " · " + string.Format(ToolUi.Tr("tools/rpg_editor/scene_created"), scene.RelativePath)
? " · " + string.Format(ToolUi.Tr("tools/rpg_editor/scene_created"), scenePath)
: null; : null;
} }
+1 -1
View File
@@ -156,7 +156,7 @@ namespace Cthangover.Tools.RpgEditor.Tests
{ {
window.QueueFree(); window.QueueFree();
DeleteNewMapFiles(); DeleteNewMapFiles();
SceneFileService.RefreshGame(); SceneManager.ReloadContent();
} }
Finish(); Finish();
return; return;