Feat: scroll block over hand, camera follow, chat overlay, admin cleanup
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 <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 ───────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
@@ -9,9 +9,14 @@
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="mb-0">Game Sessions</h1>
|
||||
<button class="btn btn-outline-secondary btn-sm" @onclick="LoadAsync">
|
||||
<i class="bi bi-arrow-clockwise me-1"></i>Refresh
|
||||
</button>
|
||||
<div class="d-flex gap-2">
|
||||
<button class="btn btn-outline-danger btn-sm" @onclick="AbandonAllActiveAsync">
|
||||
<i class="bi bi-x-circle me-1"></i>Abandon All Active
|
||||
</button>
|
||||
<button class="btn btn-outline-secondary btn-sm" @onclick="LoadAsync">
|
||||
<i class="bi bi-arrow-clockwise me-1"></i>Refresh
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Stats -->
|
||||
@@ -93,6 +98,7 @@ else
|
||||
<th>Duration</th>
|
||||
<th>Winner</th>
|
||||
<th>Win Condition</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -109,12 +115,21 @@ else
|
||||
@(s.WinnerAccountId.HasValue ? s.WinnerAccountId.Value.ToString()[..8] + "…" : "—")
|
||||
</td>
|
||||
<td class="text-muted small">@(s.WinCondition ?? "—")</td>
|
||||
<td>
|
||||
@if (s.Status is nameof(GameSessionStatus.Active) or nameof(GameSessionStatus.Initializing))
|
||||
{
|
||||
<button class="btn btn-outline-danger btn-sm py-0"
|
||||
@onclick="() => AbandonSessionAsync(s.Id)">
|
||||
Abandon
|
||||
</button>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
@if (!_sessions.Any())
|
||||
{
|
||||
<tr>
|
||||
<td colspan="8" class="text-muted text-center py-3">No sessions found.</td>
|
||||
<td colspan="9" class="text-muted text-center py-3">No sessions found.</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
@@ -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";
|
||||
|
||||
@@ -83,7 +83,12 @@ else
|
||||
|
||||
<!-- Recent Entries -->
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header fw-medium">Recent Activity (last 100)</div>
|
||||
<div class="card-header fw-medium d-flex justify-content-between align-items-center">
|
||||
<span>Recent Activity (last 100)</span>
|
||||
<button class="btn btn-outline-danger btn-sm" @onclick="ClearRecentAsync">
|
||||
<i class="bi bi-trash me-1"></i>Clear History
|
||||
</button>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<table class="table table-sm table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user