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>
101 lines
3.1 KiB
GDScript
101 lines
3.1 KiB
GDScript
extends Node
|
||
## Settings autoload — persists audio volume/mute preferences.
|
||
##
|
||
## Usage from any scene:
|
||
## Settings.music_volume → float 0.0–1.0
|
||
## Settings.music_muted → bool
|
||
## Settings.sfx_volume → float 0.0–1.0
|
||
## Settings.sfx_muted → bool
|
||
##
|
||
## Changing any property automatically applies it to the AudioServer and saves.
|
||
|
||
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"
|
||
const BUS_SFX := "SFX"
|
||
|
||
signal settings_changed
|
||
|
||
var music_volume : float = 1.0 :
|
||
set(v):
|
||
music_volume = clampf(v, 0.0, 1.0)
|
||
_apply_music()
|
||
_save()
|
||
settings_changed.emit()
|
||
|
||
var music_muted : bool = false :
|
||
set(v):
|
||
music_muted = v
|
||
_apply_music()
|
||
_save()
|
||
settings_changed.emit()
|
||
|
||
var sfx_volume : float = 1.0 :
|
||
set(v):
|
||
sfx_volume = clampf(v, 0.0, 1.0)
|
||
_apply_sfx()
|
||
_save()
|
||
settings_changed.emit()
|
||
|
||
var sfx_muted : bool = false :
|
||
set(v):
|
||
sfx_muted = v
|
||
_apply_sfx()
|
||
_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:
|
||
_load()
|
||
_apply_music()
|
||
_apply_sfx()
|
||
|
||
# ── Internal ──────────────────────────────────────────────────────────────────
|
||
|
||
func _apply_music() -> void:
|
||
var idx := AudioServer.get_bus_index(BUS_MUSIC)
|
||
if idx < 0:
|
||
return
|
||
AudioServer.set_bus_volume_db(idx, linear_to_db(music_volume) if not music_muted else -80.0)
|
||
AudioServer.set_bus_mute(idx, music_muted)
|
||
|
||
|
||
func _apply_sfx() -> void:
|
||
var idx := AudioServer.get_bus_index(BUS_SFX)
|
||
if idx < 0:
|
||
return
|
||
AudioServer.set_bus_volume_db(idx, linear_to_db(sfx_volume) if not sfx_muted else -80.0)
|
||
AudioServer.set_bus_mute(idx, sfx_muted)
|
||
|
||
|
||
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))
|
||
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_GAMEPLAY, "camera_follow_unit", camera_follow_unit)
|
||
cfg.save(SAVE_PATH)
|