From 60697460cb16c1078964866963faaa223b525361 Mon Sep 17 00:00:00 2001 From: dingo Date: Mon, 9 Mar 2026 09:09:01 -0400 Subject: [PATCH] Feat: scroll block over hand, camera follow, chat overlay, admin cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Client (game_screen.gd): - Scroll wheel no longer zooms camera when mouse is over the hand panel - Clicking a friendly unit smoothly tweens camera pivot to that unit (EASE_OUT CUBIC, 0.4s) — respects Settings.camera_follow_unit toggle - Chat overlay instantiated from game screen and removed on exit Client (Settings.gd + SettingsScreen): - Added camera_follow_unit bool (default: on) to gameplay settings section - Persisted to user://settings.cfg under [gameplay] - Toggle visible in Settings screen under new GAMEPLAY section Server Admin (MatchmakingQueuePage): - "Clear History" button deletes all non-Searching matchmaking entries Server Admin (GameSessionsPage): - Per-row "Abandon" button for Active/Initializing sessions - "Abandon All Active" bulk button marks all live sessions as Abandoned with EndedAt=now and WinCondition="admin" Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- Client/origin-client/autoloads/Settings.gd | 30 ++++++++---- .../origin-client/scenes/game/game_screen.gd | 25 +++++++++- .../scenes/settings/SettingsScreen.tscn | 27 +++++++++++ .../scenes/settings/settings_screen.gd | 13 +++-- .../Pages/Game/GameSessionsPage.razor | 48 +++++++++++++++++-- .../Pages/Game/MatchmakingQueuePage.razor | 15 +++++- 6 files changed, 137 insertions(+), 21 deletions(-) diff --git a/Client/origin-client/autoloads/Settings.gd b/Client/origin-client/autoloads/Settings.gd index 366097b..422d268 100644 --- a/Client/origin-client/autoloads/Settings.gd +++ b/Client/origin-client/autoloads/Settings.gd @@ -9,8 +9,9 @@ extends Node ## ## Changing any property automatically applies it to the AudioServer and saves. -const SAVE_PATH := "user://settings.cfg" -const SECTION := "audio" +const SAVE_PATH := "user://settings.cfg" +const SECTION := "audio" +const SECTION_GAMEPLAY := "gameplay" ## Audio bus names as configured in the Godot project. const BUS_MUSIC := "Music" @@ -46,6 +47,13 @@ var sfx_muted : bool = false : _save() settings_changed.emit() +## When true, clicking a friendly unit slowly pans the camera to center on it. +var camera_follow_unit : bool = true : + set(v): + camera_follow_unit = v + _save() + settings_changed.emit() + # ── Lifecycle ───────────────────────────────────────────────────────────────── func _ready() -> void: @@ -75,16 +83,18 @@ func _load() -> void: var cfg := ConfigFile.new() if cfg.load(SAVE_PATH) != OK: return - music_volume = float(cfg.get_value(SECTION, "music_volume", 1.0)) - music_muted = bool(cfg.get_value(SECTION, "music_muted", false)) - sfx_volume = float(cfg.get_value(SECTION, "sfx_volume", 1.0)) - sfx_muted = bool(cfg.get_value(SECTION, "sfx_muted", false)) + music_volume = float(cfg.get_value(SECTION, "music_volume", 1.0)) + music_muted = bool(cfg.get_value(SECTION, "music_muted", false)) + sfx_volume = float(cfg.get_value(SECTION, "sfx_volume", 1.0)) + sfx_muted = bool(cfg.get_value(SECTION, "sfx_muted", false)) + camera_follow_unit = bool(cfg.get_value(SECTION_GAMEPLAY, "camera_follow_unit", true)) func _save() -> void: var cfg := ConfigFile.new() - cfg.set_value(SECTION, "music_volume", music_volume) - cfg.set_value(SECTION, "music_muted", music_muted) - cfg.set_value(SECTION, "sfx_volume", sfx_volume) - cfg.set_value(SECTION, "sfx_muted", sfx_muted) + cfg.set_value(SECTION, "music_volume", music_volume) + cfg.set_value(SECTION, "music_muted", music_muted) + cfg.set_value(SECTION, "sfx_volume", sfx_volume) + cfg.set_value(SECTION, "sfx_muted", sfx_muted) + cfg.set_value(SECTION_GAMEPLAY, "camera_follow_unit", camera_follow_unit) cfg.save(SAVE_PATH) diff --git a/Client/origin-client/scenes/game/game_screen.gd b/Client/origin-client/scenes/game/game_screen.gd index 88a2d37..b849f48 100644 --- a/Client/origin-client/scenes/game/game_screen.gd +++ b/Client/origin-client/scenes/game/game_screen.gd @@ -60,8 +60,10 @@ enum Mode { @onready var _go_rank_lbl : Label = %GORankLabel @onready var _go_menu_btn : Button = %GOMainMenuBtn @onready var _hud : CanvasLayer = $HUD +@onready var _hand_area : PanelContainer = $HUD/HandArea var count : int = 0 +var _cam_tween : Tween = null var _last_click_frame : int = -1 var _last_click_iid : String = "" # ── Affinity colors ─────────────────────────────────────────────────────────── @@ -92,7 +94,8 @@ const AFFINITY_COLORS : Dictionary = { "GatewayField": Color(0.52, 0.60, 0.22), } -const _CARD_WIDGET_SCENE := preload("res://scenes/collection/components/CardWidget.tscn") +const _CARD_WIDGET_SCENE := preload("res://scenes/collection/components/CardWidget.tscn") +const _CHAT_OVERLAY_SCENE := preload("res://scenes/chat/ChatOverlay.tscn") const HI_GREEN := Color(0.20, 0.90, 0.20, 0.40) const HI_RED := Color(1.00, 0.25, 0.25, 0.50) @@ -159,6 +162,10 @@ func _ready() -> void: get_tree().change_scene_to_file("res://scenes/main/MainScreen.tscn")) _hold_timer.timeout.connect(_on_hold_timer_fired) + # Chat overlay — add to viewport root so it renders above everything. + var _chat_overlay := _CHAT_OVERLAY_SCENE.instantiate() + get_tree().get_root().add_child(_chat_overlay) + Game.state_updated.connect(_on_state_updated) Game.game_over.connect(_on_game_over) @@ -173,6 +180,11 @@ func _exit_tree() -> void: Game.state_updated.disconnect(_on_state_updated) if Game.game_over.is_connected(_on_game_over): Game.game_over.disconnect(_on_game_over) + # Remove chat overlay added to the viewport root. + var root := get_tree().get_root() + for child in root.get_children(): + if child.name == "ChatOverlay": + child.queue_free() # ── Environment ─────────────────────────────────────────────────────────────── @@ -213,8 +225,10 @@ func _unhandled_input(event: InputEvent) -> void: if event is InputEventMouseButton: var mb := event as InputEventMouseButton if mb.button_index == MOUSE_BUTTON_WHEEL_UP: + if _hand_area.get_global_rect().has_point(mb.position): return _zoom(1.5); return elif mb.button_index == MOUSE_BUTTON_WHEEL_DOWN: + if _hand_area.get_global_rect().has_point(mb.position): return _zoom(-1.5); return elif mb.button_index == MOUSE_BUTTON_MIDDLE: _pan_active = mb.pressed @@ -816,6 +830,15 @@ func _select_unit(unit_id: String) -> void: var upos : Dictionary = unit.get("position", {}) if not upos.is_empty(): _add_highlight(upos.get("x", 0), upos.get("y", 0), HI_YELLOW) + # Smoothly pan camera to center on this unit if setting is enabled. + if Settings.camera_follow_unit: + var target := _coord_to_world(upos.get("x", 0), upos.get("y", 0)) + var from := _cam_pivot + if _cam_tween: _cam_tween.kill() + _cam_tween = create_tween().set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_CUBIC) + _cam_tween.tween_method( + func(v: Vector3) -> void: _cam_pivot = v; _apply_camera(), + from, target, 0.4) # Movement range (green). _highlight_tiles(_valid_move_tiles(unit), HI_GREEN) diff --git a/Client/origin-client/scenes/settings/SettingsScreen.tscn b/Client/origin-client/scenes/settings/SettingsScreen.tscn index 1e33c97..81906a1 100644 --- a/Client/origin-client/scenes/settings/SettingsScreen.tscn +++ b/Client/origin-client/scenes/settings/SettingsScreen.tscn @@ -141,3 +141,30 @@ unique_name_in_owner = true layout_mode = 2 text = "Mute" theme_override_font_sizes/font_size = 13 + +[node name="GameplaySection" type="VBoxContainer" parent="Layout/ScrollContainer/Content/ContentMargin/Sections"] +layout_mode = 2 +theme_override_constants/separation = 12 + +[node name="GameplayLabel" type="Label" parent="Layout/ScrollContainer/Content/ContentMargin/Sections/GameplaySection"] +layout_mode = 2 +text = "GAMEPLAY" +modulate = Color(0.6, 0.6, 0.65, 1.0) +theme_override_font_sizes/font_size = 11 + +[node name="CameraFollowRow" type="HBoxContainer" parent="Layout/ScrollContainer/Content/ContentMargin/Sections/GameplaySection"] +layout_mode = 2 +theme_override_constants/separation = 12 + +[node name="CameraFollowLabel" type="Label" parent="Layout/ScrollContainer/Content/ContentMargin/Sections/GameplaySection/CameraFollowRow"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "Center camera on selected unit" +vertical_alignment = 1 +theme_override_font_sizes/font_size = 14 + +[node name="CameraFollowBtn" type="CheckButton" parent="Layout/ScrollContainer/Content/ContentMargin/Sections/GameplaySection/CameraFollowRow"] +unique_name_in_owner = true +layout_mode = 2 +text = "On" +theme_override_font_sizes/font_size = 13 diff --git a/Client/origin-client/scenes/settings/settings_screen.gd b/Client/origin-client/scenes/settings/settings_screen.gd index 17ddbba..6bc7a10 100644 --- a/Client/origin-client/scenes/settings/settings_screen.gd +++ b/Client/origin-client/scenes/settings/settings_screen.gd @@ -2,11 +2,12 @@ extends Control ## Settings screen — audio volume and mute controls. ## Reads initial values from the Settings autoload and writes back on change. -@onready var back_btn : Button = %BackBtn -@onready var music_slider : HSlider = %MusicSlider -@onready var music_mute_btn : CheckButton = %MusicMuteBtn -@onready var sfx_slider : HSlider = %SfxSlider -@onready var sfx_mute_btn : CheckButton = %SfxMuteBtn +@onready var back_btn : Button = %BackBtn +@onready var music_slider : HSlider = %MusicSlider +@onready var music_mute_btn : CheckButton = %MusicMuteBtn +@onready var sfx_slider : HSlider = %SfxSlider +@onready var sfx_mute_btn : CheckButton = %SfxMuteBtn +@onready var camera_follow_btn : CheckButton = %CameraFollowBtn # ── Lifecycle ───────────────────────────────────────────────────────────────── @@ -16,6 +17,7 @@ func _ready() -> void: music_mute_btn.set_pressed_no_signal(Settings.music_muted) sfx_slider.set_value_no_signal(Settings.sfx_volume) sfx_mute_btn.set_pressed_no_signal(Settings.sfx_muted) + camera_follow_btn.set_pressed_no_signal(Settings.camera_follow_unit) _refresh_slider_states() @@ -28,6 +30,7 @@ func _ready() -> void: sfx_mute_btn.toggled.connect(func(on): Settings.sfx_muted = on _refresh_slider_states()) + camera_follow_btn.toggled.connect(func(on): Settings.camera_follow_unit = on) # ── Helpers ─────────────────────────────────────────────────────────────────── diff --git a/Server/src/SOR.Admin/Components/Pages/Game/GameSessionsPage.razor b/Server/src/SOR.Admin/Components/Pages/Game/GameSessionsPage.razor index 802c968..f9e6e69 100644 --- a/Server/src/SOR.Admin/Components/Pages/Game/GameSessionsPage.razor +++ b/Server/src/SOR.Admin/Components/Pages/Game/GameSessionsPage.razor @@ -9,9 +9,14 @@

Game Sessions

- +
+ + +
@@ -93,6 +98,7 @@ else Duration Winner Win Condition + @@ -109,12 +115,21 @@ else @(s.WinnerAccountId.HasValue ? s.WinnerAccountId.Value.ToString()[..8] + "…" : "—") @(s.WinCondition ?? "—") + + @if (s.Status is nameof(GameSessionStatus.Active) or nameof(GameSessionStatus.Initializing)) + { + + } + } @if (!_sessions.Any()) { - No sessions found. + No sessions found. } @@ -211,6 +226,31 @@ else await LoadAsync(); } + private async Task AbandonSessionAsync(Guid id) + { + var now = DateTimeOffset.UtcNow; + await Db.GameSessions + .Where(s => s.Id == id && + (s.Status == GameSessionStatus.Active || s.Status == GameSessionStatus.Initializing)) + .ExecuteUpdateAsync(s => s + .SetProperty(x => x.Status, GameSessionStatus.Abandoned) + .SetProperty(x => x.EndedAt, now) + .SetProperty(x => x.WinCondition, "admin")); + await LoadAsync(); + } + + private async Task AbandonAllActiveAsync() + { + var now = DateTimeOffset.UtcNow; + await Db.GameSessions + .Where(s => s.Status == GameSessionStatus.Active || s.Status == GameSessionStatus.Initializing) + .ExecuteUpdateAsync(s => s + .SetProperty(x => x.Status, GameSessionStatus.Abandoned) + .SetProperty(x => x.EndedAt, now) + .SetProperty(x => x.WinCondition, "admin")); + await LoadAsync(); + } + private static string FormatDurationEf(TimeSpan ts) { if (ts.TotalHours >= 1) return $"{(int)ts.TotalHours}h {ts.Minutes}m"; diff --git a/Server/src/SOR.Admin/Components/Pages/Game/MatchmakingQueuePage.razor b/Server/src/SOR.Admin/Components/Pages/Game/MatchmakingQueuePage.razor index d7de3cc..331a688 100644 --- a/Server/src/SOR.Admin/Components/Pages/Game/MatchmakingQueuePage.razor +++ b/Server/src/SOR.Admin/Components/Pages/Game/MatchmakingQueuePage.razor @@ -83,7 +83,12 @@ else
-
Recent Activity (last 100)
+
+ Recent Activity (last 100) + +
@@ -136,6 +141,14 @@ else protected override async Task OnInitializedAsync() => await LoadAsync(); + private async Task ClearRecentAsync() + { + await Db.MatchmakingEntries + .Where(e => e.Status != MatchmakingStatus.Searching) + .ExecuteDeleteAsync(); + await LoadAsync(); + } + private async Task LoadAsync() { _loading = true;