Server / DB:
- New HighlightConfig entity (catalog.highlight_configs): one row per
highlight type (Movement/Attack/Ability/Terramorpha/Selector). Supports
static texture URL or animated (base folder + frame count + FPS) with a
FallbackHex RGBA colour for when no texture is configured.
- EF migration AddHighlightConfig.
- CosmeticType.HighlightPack added; AssetCdnUrl stores serialised JSON with
per-type texture config so players can buy full highlight packs in the Bazaar.
- content.get_highlight_config handler in SOR.Content; response DTOs added to
ContentMessages.cs; handler registered in ServiceRegistration.
Admin:
- /content/highlights page: inline editor for all five highlight types
(CDN path, animated toggle, frame count, FPS, fallback hex with swatch).
Upserts rows — no delete needed since there is always exactly one row per type.
- Highlights nav link added to Content section in NavMenu.
- CosmeticEditor: HighlightPack type renders a per-type table (Movement/
Attack/Ability/Terramorpha/Selector), serialising to JSON in AssetCdnUrl.
Client (Godot):
- HighlightConfig autoload: fetches content.get_highlight_config on startup,
caches to user://highlight_config.json. Provides get_texture(type) and
get_color(type). Supports set_override/clear_override/apply_cosmetic_pack
for cosmetic and settings overrides.
- Settings autoload: highlight_overrides Dictionary persisted in settings.cfg.
set_highlight_override/clear_highlight_override push into HighlightConfig.
- settings_screen.gd: programmatic "Highlight Texture Overrides" section added
with a LineEdit + Reset button per type; appended to Sections VBoxContainer.
- game_screen.gd:
• _add_highlight() rewritten to use flat PlaneMesh quads with textured
StandardMaterial3D. Accepts a string type key ("movement", "attack",
"ability", "terramorpha", "selector") instead of a Color constant.
• _cursor_highlight + _hover_team_overlay: two permanently-allocated quads
that are never freed. The selector highlights the tile under the mouse at
all times; the team overlay shows a coloured tint when hovering an occupied
tile. Both are preserved across _clear_highlights() and _build_board().
• _update_hover(): called on every InputEventMouseMotion event. Moves the
selector quad, shows the team-colour overlay when hovering an occupied tile,
and boosts MeshInstance3D emission on the hovered unit via
set_surface_override_material (reset when hover leaves).
• All existing _highlight_tiles() / _add_highlight() callers updated from
HI_* Color constants to type key strings.
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>
158 lines
5.1 KiB
GDScript
158 lines
5.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"
|
||
const SECTION_VISUAL := "visual"
|
||
const SECTION_HIGHLIGHTS := "highlights"
|
||
|
||
## 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()
|
||
|
||
## Skybox display mode in gameplay scenes.
|
||
## "live" — near-black sky with emissive stars; each star = an active game session.
|
||
## "cdn" — server-configured panoramic or animated skybox image.
|
||
## "off" — default procedural sky (dark blue gradient).
|
||
var skybox_mode : String = "live" :
|
||
set(v):
|
||
skybox_mode = v
|
||
_save()
|
||
settings_changed.emit()
|
||
|
||
## Per-type highlight texture URL overrides entered by the player.
|
||
## Keys: "movement", "attack", "ability", "terramorpha", "selector"
|
||
## Value: URL string, or "" to use the server default.
|
||
var highlight_overrides : Dictionary = {} :
|
||
set(v):
|
||
highlight_overrides = v
|
||
_apply_highlight_overrides()
|
||
_save()
|
||
settings_changed.emit()
|
||
|
||
|
||
func set_highlight_override(type: String, url: String) -> void:
|
||
var key := type.to_lower()
|
||
if url.is_empty():
|
||
highlight_overrides.erase(key)
|
||
else:
|
||
highlight_overrides[key] = url
|
||
_apply_highlight_overrides()
|
||
_save()
|
||
settings_changed.emit()
|
||
|
||
|
||
func clear_highlight_override(type: String) -> void:
|
||
set_highlight_override(type.to_lower(), "")
|
||
|
||
# ── 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_highlight_overrides() -> void:
|
||
if not is_node_ready():
|
||
return
|
||
# Wait until HighlightConfig has initialised (it's an autoload, loaded after Settings).
|
||
if not Engine.has_singleton("HighlightConfig"):
|
||
return
|
||
HighlightConfig.clear_all_overrides()
|
||
for key in highlight_overrides:
|
||
var url : String = str(highlight_overrides[key])
|
||
if not url.is_empty():
|
||
HighlightConfig.set_override(key, { "cdnPath": url, "isAnimated": false,
|
||
"frameCount": 1, "fps": 12.0, "fallbackHex": "" })
|
||
|
||
|
||
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))
|
||
skybox_mode = str(cfg.get_value(SECTION_VISUAL, "skybox_mode", "live"))
|
||
var raw_overrides = cfg.get_value(SECTION_HIGHLIGHTS, "highlight_overrides", {})
|
||
if raw_overrides is Dictionary:
|
||
highlight_overrides = raw_overrides as Dictionary
|
||
|
||
|
||
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.set_value(SECTION_VISUAL, "skybox_mode", skybox_mode)
|
||
cfg.set_value(SECTION_HIGHLIGHTS, "highlight_overrides", highlight_overrides)
|
||
cfg.save(SAVE_PATH)
|