From 010d401b756b29ae8c668b591f854df23082b479 Mon Sep 17 00:00:00 2001 From: Leonid Pershin Date: Tue, 16 Jun 2026 14:45:21 +0300 Subject: [PATCH] Enhance HUD with inspector and spawner hints - Added localization for inspector (F1) and spawner (F9) hints in both English and Russian. - Updated the WorldScene to display a new HUD card that includes date/time/season and control hints. - Refactored HudSystem to streamline the display of date/time/season information, removing seed and FPS from the HUD. This update improves user experience by providing clearer control hints and a more informative HUD layout. --- Mods/Core/Languages/en/ui.json | 2 ++ Mods/Core/Languages/ru/ui.json | 2 ++ src/LittleSim/Scenes/WorldScene.cs | 39 ++++++++++++++++++++---------- src/LittleSim/Sim/SimSystems.cs | 20 ++++++--------- 4 files changed, 37 insertions(+), 26 deletions(-) diff --git a/Mods/Core/Languages/en/ui.json b/Mods/Core/Languages/en/ui.json index 1931867..57d19a1 100644 --- a/Mods/Core/Languages/en/ui.json +++ b/Mods/Core/Languages/en/ui.json @@ -7,6 +7,8 @@ "season.autumn": "autumn", "season.winter": "winter", "hud.controls": "WASD — camera, wheel — zoom, LMB — select, ` — console, F1 — inspector", + "hud.inspector": "F1 — inspector", + "hud.spawner": "F9 — spawner", "inspect.tab.overview": "Overview", "inspect.tab.genes": "Genes", "inspect.tab.products": "Products", diff --git a/Mods/Core/Languages/ru/ui.json b/Mods/Core/Languages/ru/ui.json index 0d1902e..4c18e11 100644 --- a/Mods/Core/Languages/ru/ui.json +++ b/Mods/Core/Languages/ru/ui.json @@ -7,6 +7,8 @@ "season.autumn": "осень", "season.winter": "зима", "hud.controls": "WASD — камера, колесо — зум, ЛКМ — выбрать, ` — консоль, F1 — инспектор", + "hud.inspector": "F1 — инспектор", + "hud.spawner": "F9 — спавнер", "inspect.tab.overview": "Обзор", "inspect.tab.genes": "Гены", "inspect.tab.products": "Продукты", diff --git a/src/LittleSim/Scenes/WorldScene.cs b/src/LittleSim/Scenes/WorldScene.cs index 70c4693..038e043 100644 --- a/src/LittleSim/Scenes/WorldScene.cs +++ b/src/LittleSim/Scenes/WorldScene.cs @@ -20,6 +20,7 @@ using MrGameEng.Lighting; using MrGameEng.Tilemaps; using MrGameEng.UI; using Myra.Graphics2D; +using Myra.Graphics2D.Brushes; using Myra.Graphics2D.UI; namespace LittleSim.Scenes; @@ -163,7 +164,7 @@ public sealed class WorldScene : Scene // HUD, полоса скорости и меню-пауза в одной корневой панели. var desktop = this.UseScaledUI(); - var hudLabel = new Label { Left = 10, Top = 8 }; + var hudLabel = new Label { TextColor = Ui.Accent }; // дата/время/сезон — заполняет HudSystem var speedBar = BuildSpeedBar(content); _pause = new PauseMenu( Context, @@ -218,7 +219,29 @@ public sealed class WorldScene : Scene Margin = new Thickness(0, 8, 12, 0), }; - var hudChildren = new List { hudLabel, _inspect.Panel, speedBar, _pause.Root }; + // Карточка статуса (верх-слева): строка даты/времени/сезона + краткие подсказки клавиш. Спавнер + // (F9) — только в дев-режиме; инспектор (F1) доступен всегда. + var hint = content.Languages.Get("hud.inspector"); + if (spawner is not null) + { + hint += " · " + content.Languages.Get("hud.spawner"); + } + + var hudCard = new VerticalStackPanel + { + Spacing = 3, + Padding = new Thickness(12, 8), + HorizontalAlignment = HorizontalAlignment.Left, + VerticalAlignment = VerticalAlignment.Top, + Margin = new Thickness(10, 8, 0, 0), + Background = new SolidBrush(new Color(10, 13, 18, 210)), + Border = new SolidBrush(new Color(96, 134, 168)), + BorderThickness = new Thickness(1), + }; + hudCard.Widgets.Add(hudLabel); + hudCard.Widgets.Add(new Label { Text = hint, TextColor = Ui.Muted }); + + var hudChildren = new List { hudCard, _inspect.Panel, speedBar, _pause.Root }; if (spawner is not null) { hudChildren.Add(spawner.Panel); @@ -448,17 +471,7 @@ public sealed class WorldScene : Scene _perf?.Refresh(); }) ); - UpdateSystems.Add( - new HudSystem( - Context, - content.Languages, - hudLabel, - "hud.world", - _config.Seed, - calendar, - climate - ) - ); + UpdateSystems.Add(new HudSystem(Context, content.Languages, hudLabel, calendar, climate)); UpdateSystems.Add(new CallbackSystem(() => Hotkeys(input))); // Все системы добавлены — включаем per-system мониторинг (дев-режим), чтобы команда `perf` diff --git a/src/LittleSim/Sim/SimSystems.cs b/src/LittleSim/Sim/SimSystems.cs index b187c50..b62de67 100644 --- a/src/LittleSim/Sim/SimSystems.cs +++ b/src/LittleSim/Sim/SimSystems.cs @@ -180,15 +180,14 @@ public sealed class GodCameraSystem( } /// -/// Строка статуса в HUD: заголовок сцены (ключ локализации с сидом, датой/временем календаря и -/// FPS) и подсказка управления. Обновляется 4 раза в секунду; смена языка подхватывается сама. +/// Строка даты/времени/сезона в HUD (верх-слева). Обновляется ~4 раза в секунду; смена языка +/// подхватывается сама. Сид и FPS убраны (сид виден в меню, FPS — в окне производительности), +/// подсказки управления вынесены отдельной строкой сцены. /// public sealed class HudSystem( MrGameEng.Core.EngineContext context, MrGameEng.Mods.LanguageManager languages, Myra.Graphics2D.UI.Label label, - string titleKey, - int seed, MrGameEng.Core.Calendar? calendar = null, MrGameEng.Core.Climate? climate = null ) : BaseSystem @@ -198,7 +197,6 @@ public sealed class HudSystem( private static readonly string[] SeasonKeys = BuildSeasonKeys(); private float _accumulated; - private int _frames; private static string[] BuildSeasonKeys() { @@ -215,27 +213,23 @@ public sealed class HudSystem( protected override void OnUpdateGroup() { _accumulated += context.Clock.UnscaledDeltaTime; - _frames++; if (_accumulated < 0.25f) { return; } - var fps = (int)MathF.Round(_frames / _accumulated); _accumulated = 0f; - _frames = 0; - var when = calendar is null + var text = calendar is null ? "" : languages.Format("hud.datetime", calendar.Day, calendar.Hour, calendar.Minute); if (climate is not null) { var season = languages.Get(SeasonKeys[(int)climate.Season]); - when += - " | " + text += + " · " + languages.Format("hud.climate", season, (int)MathF.Round(climate.Temperature)); } - label.Text = - languages.Format(titleKey, seed, when, fps) + "\n" + languages.Get("hud.controls"); + label.Text = text; } }