diff --git a/locale/ui_en.properties b/locale/ui_en.properties index a573a0d..15db9a0 100644 --- a/locale/ui_en.properties +++ b/locale/ui_en.properties @@ -168,3 +168,9 @@ tools/map_editor/preview_tip = View the map as in game: hover, location card, ma tools/map_editor/preview_on = Preview mode: Esc or ✕ returns to the editor. tools/map_editor/preview_off = Edit mode. tools/map_editor/preview_missing = Failed to load the map widget scene (map_widget.tscn). +tools/map_editor/effective = In game: +tools/map_editor/effective_open = available +tools/map_editor/effective_locked = closed (flag) +tools/map_editor/effective_no_scene = closed (no scene) +tools/map_editor/effective_unknown_scene = closed (scene not found) +tools/map_editor/effective_hidden = hidden from map diff --git a/locale/ui_ru.properties b/locale/ui_ru.properties index 5f62134..32c7836 100644 --- a/locale/ui_ru.properties +++ b/locale/ui_ru.properties @@ -167,3 +167,9 @@ tools/map_editor/preview_tip = Посмотреть карту как в игр tools/map_editor/preview_on = Режим просмотра: Esc или ✕ — вернуться к редактору. tools/map_editor/preview_off = Режим редактирования. tools/map_editor/preview_missing = Не удалось загрузить сцену карты (map_widget.tscn). +tools/map_editor/effective = В игре: +tools/map_editor/effective_open = доступна +tools/map_editor/effective_locked = закрыта (флаг «Закрыта») +tools/map_editor/effective_no_scene = закрыта (сцена не задана) +tools/map_editor/effective_unknown_scene = закрыта (сцена не найдена) +tools/map_editor/effective_hidden = скрыта с карты diff --git a/src/MapEditor/MapEditorCanvas.cs b/src/MapEditor/MapEditorCanvas.cs index 8cfad31..d452e5f 100644 --- a/src/MapEditor/MapEditorCanvas.cs +++ b/src/MapEditor/MapEditorCanvas.cs @@ -272,7 +272,10 @@ namespace Cthangover.Tools.MapEditor private void DrawZone(MapZone zone, Rect2 rect, bool selected) { if (zone.Points != null && zone.Points.Count >= 2) - MapZoneStyle.Draw(this, ToPixels(zone.Points, rect), selected, false, zone.Locked); + { + var locked = MapZoneRules.IsLocked(zone, !zone.Locked); + MapZoneStyle.Draw(this, ToPixels(zone.Points, rect), selected, false, locked, zone.Hidden); + } if (HasMarker(zone)) DrawMarker(zone, ToPixel(zone.ImagePos, rect), selected); diff --git a/src/MapEditor/MapEditorWindow.cs b/src/MapEditor/MapEditorWindow.cs index 461c9c4..86fda3b 100644 --- a/src/MapEditor/MapEditorWindow.cs +++ b/src/MapEditor/MapEditorWindow.cs @@ -56,6 +56,7 @@ namespace Cthangover.Tools.MapEditor private ItemList _iconList; private CheckBox _lockedCheck; private CheckBox _hiddenCheck; + private Label _availabilityLabel; private CheckBox _labelCheck; private LineEdit _posX; private LineEdit _posY; @@ -256,6 +257,10 @@ namespace Cthangover.Tools.MapEditor _hiddenCheck.Toggled += _ => OnFieldsChanged(); sidebar.AddChild(_hiddenCheck); + _availabilityLabel = new Label { AutowrapMode = TextServer.AutowrapMode.WordSmart }; + _availabilityLabel.AddThemeColorOverride("font_color", UiTokens.Faint); + sidebar.AddChild(_availabilityLabel); + sidebar.AddChild(new Label { Text = Tr("tools/map_editor/vertices") }); var vertexButtons = new HBoxContainer(); @@ -722,6 +727,8 @@ namespace Cthangover.Tools.MapEditor SetDirty(); RefreshJson(); UpdateZoneListLabel(); + UpdateAvailability(zone); + _canvas.QueueRedraw(); } private void OnImageChanged() @@ -893,6 +900,7 @@ namespace Cthangover.Tools.MapEditor _labelX.Text = string.Empty; _labelY.Text = string.Empty; _labelCheck.ButtonPressed = false; + _availabilityLabel.Text = string.Empty; return; } @@ -913,6 +921,37 @@ namespace Cthangover.Tools.MapEditor WritePositionsToSidebar(zone); UpdateTitlePreview(); + UpdateAvailability(zone); + } + + /// + /// Shows the availability the current authoring data produces in the + /// game. The sidebar flags alone are not the whole truth: the player + /// also refuses to travel to a zone with an empty or unregistered + /// scene, so the hint goes through the shared + /// and the editor cannot disagree with the map the player sees. + /// + private void UpdateAvailability(MapZone zone) + { + if (zone == null) + { + _availabilityLabel.Text = string.Empty; + return; + } + + string state; + if (zone.Hidden) + state = Tr("tools/map_editor/effective_hidden"); + else if (zone.Locked) + state = Tr("tools/map_editor/effective_locked"); + else if (string.IsNullOrEmpty(zone.Scene)) + state = Tr("tools/map_editor/effective_no_scene"); + else if (MapZoneRules.IsLocked(zone, true)) + state = Tr("tools/map_editor/effective_unknown_scene"); + else + state = Tr("tools/map_editor/effective_open"); + + _availabilityLabel.Text = $"{Tr("tools/map_editor/effective")} {state}"; } private void WritePositionsToSidebar(MapZone zone)