From c585960c61ece0bc080be30ec582c983688ba9cb Mon Sep 17 00:00:00 2001 From: iisaev Date: Tue, 27 Oct 2026 01:07:33 +0100 Subject: [PATCH] Expose map atmosphere and event move routes --- locale/ui_en.properties | 9 +++++++++ locale/ui_ru.properties | 9 +++++++++ src/RpgEventPropertiesPanel.cs | 17 +++++++++++++++++ src/RpgMapPropertiesPanel.cs | 12 ++++++++++++ 4 files changed, 47 insertions(+) diff --git a/locale/ui_en.properties b/locale/ui_en.properties index 6e3ea51..c8717e0 100644 --- a/locale/ui_en.properties +++ b/locale/ui_en.properties @@ -110,3 +110,12 @@ tools/rpg_editor/light_color_tip = #rrggbb or #rrggbbaa (alpha is the strength); tools/rpg_editor/ambient = Fixed ambient tools/rpg_editor/ambient_tip = #rrggbb: the map is always lit like this (a room with a lamp); empty: by the time of day tools/rpg_editor/autotile = autotile + +tools/rpg_editor/atmosphere = Atmosphere +tools/rpg_editor/atmosphere_none = Still / indoors +tools/rpg_editor/atmosphere_woodland = Woodland: leaves, fireflies, ripples +tools/rpg_editor/section_route = Movement route +tools/rpg_editor/route_steps = Steps +tools/rpg_editor/route_steps_tip = up, down, left, right, wait, random, toward, away, face_up/down/left/right. Separate with commas. Empty = stand still. +tools/rpg_editor/route_every = Pause between steps (s) +tools/rpg_editor/route_repeat = Repeat route diff --git a/locale/ui_ru.properties b/locale/ui_ru.properties index 894f610..20bb433 100644 --- a/locale/ui_ru.properties +++ b/locale/ui_ru.properties @@ -110,3 +110,12 @@ tools/rpg_editor/light_color_tip = #rrggbb или #rrggbbaa (альфа — си tools/rpg_editor/ambient = Своё освещение tools/rpg_editor/ambient_tip = #rrggbb: карта всегда освещена так (комната с лампой); пусто — по времени суток tools/rpg_editor/autotile = автотайл + +tools/rpg_editor/atmosphere = Атмосфера +tools/rpg_editor/atmosphere_none = Без движения / помещение +tools/rpg_editor/atmosphere_woodland = Лес: листья, светляки, рябь +tools/rpg_editor/section_route = Маршрут движения +tools/rpg_editor/route_steps = Шаги +tools/rpg_editor/route_steps_tip = up, down, left, right, wait, random, toward, away, face_up/down/left/right. Через запятую. Пусто — стоять на месте. +tools/rpg_editor/route_every = Пауза между шагами (с) +tools/rpg_editor/route_repeat = Повторять маршрут diff --git a/src/RpgEventPropertiesPanel.cs b/src/RpgEventPropertiesPanel.cs index abf5140..9d6a688 100644 --- a/src/RpgEventPropertiesPanel.cs +++ b/src/RpgEventPropertiesPanel.cs @@ -44,6 +44,9 @@ namespace Cthangover.Tools.RpgEditor private readonly OptionButton teleportDir; private readonly SpinBox lightRadius; private readonly LineEdit lightColor; + private readonly LineEdit routeSteps; + private readonly SpinBox routeEvery; + private readonly CheckBox routeRepeat; private RpgMapEvent mapEvent; private bool suppress; private bool editing; @@ -87,6 +90,12 @@ namespace Cthangover.Tools.RpgEditor commandsEdit.TextChanged += OnCommandsChanged; body.AddChild(commandsEdit); + body.AddChild(ToolUi.Section("tools/rpg_editor/section_route")); + routeSteps = ToolUi.Field(body, "tools/rpg_editor/route_steps", ToolUi.Text("left, wait, right", OnTextChanged), "tools/rpg_editor/route_steps_tip"); + routeEvery = ToolUi.Field(body, "tools/rpg_editor/route_every", ToolUi.Number(0.1, 30, 0.1, OnNumberChanged)); + routeRepeat = ToolUi.Field(body, "tools/rpg_editor/route_repeat", new CheckBox()); + routeRepeat.Toggled += OnRouteRepeat; + body.AddChild(ToolUi.Section("tools/rpg_editor/section_light")); lightRadius = ToolUi.Field(body, "tools/rpg_editor/light_radius", ToolUi.Number(0, 16, 0.5, OnNumberChanged), "tools/rpg_editor/light_radius_tip"); lightColor = ToolUi.Field(body, "tools/rpg_editor/light_color", ToolUi.Text("#ffd8a0", OnTextChanged), "tools/rpg_editor/light_color_tip"); @@ -128,6 +137,9 @@ namespace Cthangover.Tools.RpgEditor teleportX.Value = value.Teleport?.X ?? -1; teleportY.Value = value.Teleport?.Y ?? -1; teleportDir.Select((int)(value.Teleport?.Dir ?? RpgDirection.Down)); + routeSteps.Text = string.Join(", ", value.Route?.Steps ?? new List()); + routeEvery.Value = value.Route?.Every ?? 0.9; + routeRepeat.ButtonPressed = value.Route?.Repeat ?? true; lightRadius.Value = value.Light?.Radius ?? 0; lightColor.Text = value.Light?.Color ?? string.Empty; suppress = false; @@ -154,6 +166,8 @@ namespace Cthangover.Tools.RpgEditor private void OnCommandsChanged() => Write(); + private void OnRouteRepeat(bool value) => Write(); + private void OnDeletePressed() { if (mapEvent != null) @@ -195,6 +209,9 @@ namespace Cthangover.Tools.RpgEditor } : null; + var steps = routeSteps.Text.Split(new[] { ',', ';', ' ' }, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).ToList(); + mapEvent.Route = steps.Count == 0 ? null : new RpgMoveRoute { Steps = steps, Every = routeEvery.Value, Repeat = routeRepeat.ButtonPressed }; + // A radius of 0 means no light; an empty colour keeps the warm default. mapEvent.Light = lightRadius.Value > 0 ? new RpgLight { Radius = (float)lightRadius.Value, Color = NullIfEmpty(lightColor.Text) ?? new RpgLight().Color } diff --git a/src/RpgMapPropertiesPanel.cs b/src/RpgMapPropertiesPanel.cs index 9d9cebd..96b6309 100644 --- a/src/RpgMapPropertiesPanel.cs +++ b/src/RpgMapPropertiesPanel.cs @@ -29,6 +29,7 @@ namespace Cthangover.Tools.RpgEditor private readonly SpinBox heightSpin; private readonly SpinBox zoomSpin; private readonly LineEdit ambientEdit; + private readonly OptionButton atmospherePicker; private readonly SpinBox spawnX; private readonly SpinBox spawnY; private readonly OptionButton spawnDir; @@ -65,6 +66,8 @@ namespace Cthangover.Tools.RpgEditor zoomSpin = ToolUi.Field(this, "tools/rpg_editor/zoom", ToolUi.Number(1, 4, 1, OnZoomChanged), "tools/rpg_editor/zoom_tip"); ambientEdit = ToolUi.Field(this, "tools/rpg_editor/ambient", ToolUi.Text("#e0d2b8", OnAmbientChanged), "tools/rpg_editor/ambient_tip"); + atmospherePicker = ToolUi.Field(this, "tools/rpg_editor/atmosphere", RpgEditorFields.Choice(new[] { "tools/rpg_editor/atmosphere_none", "tools/rpg_editor/atmosphere_woodland" }, OnAtmospherePicked)); + AddChild(ToolUi.Section("tools/rpg_editor/section_spawn")); spawnX = ToolUi.Field(this, "tools/rpg_editor/x", ToolUi.Number(0, 255, 1, OnSpawnChanged)); spawnY = ToolUi.Field(this, "tools/rpg_editor/y", ToolUi.Number(0, 255, 1, OnSpawnChanged)); @@ -98,6 +101,7 @@ namespace Cthangover.Tools.RpgEditor heightSpin.Value = value.Grid.Height; zoomSpin.Value = map.Zoom; ambientEdit.Text = map.Ambient ?? string.Empty; + atmospherePicker.Select(map.Atmosphere == "woodland" ? 1 : 0); spawnX.Value = map.Spawn.X; spawnY.Value = map.Spawn.Y; spawnDir.Select((int)map.Spawn.Dir); @@ -127,6 +131,14 @@ namespace Cthangover.Tools.RpgEditor Changed?.Invoke(); } + private void OnAtmospherePicked(int index) + { + if (!Begin()) + return; + document.Map.Atmosphere = index == 1 ? "woodland" : null; + Changed?.Invoke(); + } + private void OnAmbientChanged(string text) { if (!Begin())