diff --git a/locale/ui_en.properties b/locale/ui_en.properties index ffcdeef..d9ee13d 100644 --- a/locale/ui_en.properties +++ b/locale/ui_en.properties @@ -19,7 +19,7 @@ tools/rpg_editor/redo = Redo tools/rpg_editor/redo_tip = Redo (Ctrl+Y) tools/rpg_editor/play = Play tools/rpg_editor/play_tip = Save and walk the map from its spawn in the running game -tools/rpg_editor/play_no_scene = Scene "{0}" is not loaded yet: reload the mods (Ctrl+Shift+R) after creating a map. +tools/rpg_editor/play_no_scene = The game does not know scene "{0}": check scenes/{0}.json in the map's mod. tools/rpg_editor/scene_created = scene {0} created tools/rpg_editor/section_palette = Palette tools/rpg_editor/section_map = Map diff --git a/locale/ui_ru.properties b/locale/ui_ru.properties index 9e62197..ab3799a 100644 --- a/locale/ui_ru.properties +++ b/locale/ui_ru.properties @@ -19,7 +19,7 @@ tools/rpg_editor/redo = Вернуть tools/rpg_editor/redo_tip = Вернуть отменённое (Ctrl+Y) tools/rpg_editor/play = Играть tools/rpg_editor/play_tip = Сохранить и пройтись по карте от точки появления в запущенной игре -tools/rpg_editor/play_no_scene = Сцена «{0}» ещё не загружена: после создания карты перезагрузите моды (Ctrl+Shift+R). +tools/rpg_editor/play_no_scene = Игра не знает сцену «{0}»: проверьте файл scenes/{0}.json в моде карты. tools/rpg_editor/scene_created = создана сцена {0} tools/rpg_editor/section_palette = Палитра tools/rpg_editor/section_map = Карта diff --git a/mod.jpg b/mod.jpg new file mode 100644 index 0000000..1b2aa24 Binary files /dev/null and b/mod.jpg differ diff --git a/src/RpgMapEditorWindow.cs b/src/RpgMapEditorWindow.cs index ff7d8c1..032d260 100644 --- a/src/RpgMapEditorWindow.cs +++ b/src/RpgMapEditorWindow.cs @@ -27,7 +27,9 @@ namespace Cthangover.Tools.RpgEditor /// (Ctrl+Z / Ctrl+Y); Ctrl+S saves. A new file becomes a map filled with the /// first tile of the first tileset, and the first save also writes /// scenes/<id>.json when the mod has no such scene, because the - /// map id is the scene name. + /// map id is the scene name; the game re-reads its scenes right away + /// (), so "Play" works on a new map + /// without a mod reload. /// /// After a save the map is put into the running game's map cache, and a /// world showing it is remounted, so the edit is visible at once; "Play" @@ -254,6 +256,8 @@ namespace Cthangover.Tools.RpgEditor } var sceneNote = isNew ? EnsureScene() : null; + if (sceneNote != null) + SceneFileService.RefreshGame(); isNew = false; MarkClean(); PublishToGame(json); diff --git a/test_suites/edit/src/RpgEditorTestDriver.cs b/test_suites/edit/src/RpgEditorTestDriver.cs index d947ca4..6b6eb17 100644 --- a/test_suites/edit/src/RpgEditorTestDriver.cs +++ b/test_suites/edit/src/RpgEditorTestDriver.cs @@ -1,9 +1,13 @@ using System.Collections.Generic; +using System.IO; using System.Linq; using Cthangover.Core.Bootstrap; +using Cthangover.Core.Scenes; using Cthangover.Core.Utils; using Cthangover.Mods.Interface.Tool; using Cthangover.Mods.Rpg; +using Cthangover.Tools.Common; +using Cthangover.Tools.Services; using Godot; namespace Cthangover.Tools.RpgEditor.Tests @@ -11,8 +15,10 @@ namespace Cthangover.Tools.RpgEditor.Tests /// /// Drives the RPG map editor through its controls like an author: layer /// buttons are pressed, the palette and the canvas get mouse events through - /// their gui_input signal, Ctrl+Z goes into the window. The window is - /// freed at the end without saving, so the demo maps never change. + /// their gui_input signal, Ctrl+Z goes into the window. That window is + /// freed without saving, so the demo maps never change. A second window then + /// creates a new map through the file selector's "+" and saves it: the game must + /// know the map's scene at once (no mod reload); its files are deleted again. /// Result line: [TEST_RESULT] name=rpg_editor_edit passed=N failed=M. /// public partial class RpgEditorTestDriver : Node @@ -20,6 +26,7 @@ namespace Cthangover.Tools.RpgEditor.Tests private const float TickSeconds = 0.15f; private const float TimeoutSeconds = 60f; private const int RockTile = 11; + private const string NewMap = "zz_editor_test_map"; private static readonly Vector2I PaintCell = new(3, 5); private static readonly Vector2I EventCell = new(2, 6); @@ -32,6 +39,7 @@ namespace Cthangover.Tools.RpgEditor.Tests private RpgMapEditorWindow window; private RpgMapEditorCanvas canvas; private int eventsBefore; + private string newMapMod; /// Creates the driver; null disables screenshots. public RpgEditorTestDriver(string shotsDir) @@ -115,11 +123,58 @@ namespace Cthangover.Tools.RpgEditor.Tests case 4: Shot("collision"); window.QueueFree(); + window = ToolWindow.Open(); + step++; + return; + case 5: + canvas = window.FindChildren("*", "", true, false).OfType().FirstOrDefault(); + if (canvas?.Document == null) + return; + newMapMod = Selector().CurrentMod; + DeleteNewMapFiles(); + Selector().FindChildren("*", "", true, false).OfType