Tile highlight texture system with cursor + hover glow
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>
This commit is contained in:
@@ -198,6 +198,16 @@ var _needs_face_rot : Dictionary = {} # iid → bool (team-based 180° f
|
||||
# Model retry tracking (when real GLB failed to download at placement time).
|
||||
var _unit_model_retries : Dictionary = {} # iid → attempt number (1-based, capped at 10)
|
||||
|
||||
# ── Cursor & hover state ───────────────────────────────────────────────────────
|
||||
## The selector highlight follows the mouse tile at all times.
|
||||
var _cursor_highlight : MeshInstance3D = null
|
||||
## Team-colour overlay shown when hovering an occupied tile or unit.
|
||||
var _hover_team_overlay : MeshInstance3D = null
|
||||
## Currently hovered tile coord (updated every mouse-motion event).
|
||||
var _hovered_coord : Vector2i = Vector2i(-1, -1)
|
||||
## The MeshInstance3D of the unit currently receiving a hover-glow override.
|
||||
var _hovered_unit_mesh : MeshInstance3D = null
|
||||
|
||||
## Animation name aliases: maps the canonical lower-case action to fallback track names.
|
||||
## The AnimationPlayer track list is matched case-insensitively against each entry.
|
||||
const ANIM_ALIASES : Dictionary = {
|
||||
@@ -213,6 +223,7 @@ const ANIM_ALIASES : Dictionary = {
|
||||
func _ready() -> void:
|
||||
_setup_environment()
|
||||
_apply_camera()
|
||||
_init_cursor_nodes()
|
||||
|
||||
_draw_btn.pressed.connect(_on_draw_pressed)
|
||||
_end_turn_btn.pressed.connect(_on_end_turn_pressed)
|
||||
@@ -269,6 +280,7 @@ func _exit_tree() -> void:
|
||||
Game.game_activity.disconnect(_on_game_activity)
|
||||
if Settings.settings_changed.is_connected(_on_skybox_setting_changed):
|
||||
Settings.settings_changed.disconnect(_on_skybox_setting_changed)
|
||||
_reset_unit_hover_glow()
|
||||
# Unsubscribe from activity feed and free star nodes.
|
||||
if _ambient_star_timer != null and is_instance_valid(_ambient_star_timer):
|
||||
_ambient_star_timer.queue_free()
|
||||
@@ -672,6 +684,8 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
_cam_yaw -= delta.x * 0.4
|
||||
_cam_pitch = clampf(_cam_pitch + delta.y * 0.3, 15.0, 75.0)
|
||||
_apply_camera()
|
||||
# Always update cursor/hover on mouse move (even while drag — hides during drag).
|
||||
_update_hover(mm.position)
|
||||
if _pan_active:
|
||||
var ps := _cam_distance * 0.0015
|
||||
var right := _camera_rig.global_basis.x * delta.x * ps
|
||||
@@ -791,7 +805,9 @@ func _rebuild_ownership(state: Dictionary) -> void:
|
||||
func _build_board(board: Dictionary) -> void:
|
||||
for c in _tiles_root.get_children(): c.queue_free()
|
||||
for c in _units_root.get_children(): c.queue_free()
|
||||
for c in _hi_root.get_children(): c.queue_free()
|
||||
for c : Node in _hi_root.get_children():
|
||||
if c != _cursor_highlight and c != _hover_team_overlay:
|
||||
c.queue_free()
|
||||
_tile_bodies.clear()
|
||||
_unit_meshes.clear()
|
||||
_unit_bodies.clear()
|
||||
@@ -1834,40 +1850,156 @@ func _schedule_rebuild(state: Dictionary, delay: float) -> void:
|
||||
# ── Highlights ────────────────────────────────────────────────────────────────
|
||||
|
||||
func _clear_highlights() -> void:
|
||||
print("Clearing")
|
||||
for c in _hi_root.get_children(): c.queue_free()
|
||||
# Preserve the two permanently-allocated hover quads (last two children).
|
||||
var children := _hi_root.get_children()
|
||||
for i in range(children.size()):
|
||||
var c : Node = children[i]
|
||||
if c != _cursor_highlight and c != _hover_team_overlay:
|
||||
c.queue_free()
|
||||
|
||||
|
||||
func _add_highlight(x: int, y: int, color: Color) -> void:
|
||||
## Update the always-visible cursor/hover state based on the current mouse position.
|
||||
## Called on every InputEventMouseMotion event.
|
||||
func _update_hover(mouse_pos: Vector2) -> void:
|
||||
if _cursor_highlight == null or _hover_team_overlay == null:
|
||||
return
|
||||
|
||||
# If dragging (camera rotation / pan), hide highlights.
|
||||
if _drag_active or _pan_active:
|
||||
_cursor_highlight.visible = false
|
||||
_hover_team_overlay.visible = false
|
||||
_reset_unit_hover_glow()
|
||||
_hovered_coord = Vector2i(-1, -1)
|
||||
return
|
||||
|
||||
var coord := _mouse_to_tile_coord(mouse_pos)
|
||||
if coord == _hovered_coord:
|
||||
return
|
||||
|
||||
# Reset previous unit glow.
|
||||
_reset_unit_hover_glow()
|
||||
|
||||
_hovered_coord = coord
|
||||
if coord.x < 0:
|
||||
_cursor_highlight.visible = false
|
||||
_hover_team_overlay.visible = false
|
||||
return
|
||||
|
||||
# Move selector cursor.
|
||||
var sel_tex : Texture2D = HighlightConfig.get_texture("selector")
|
||||
var sel_col : Color = HighlightConfig.get_color("selector")
|
||||
_place_highlight_quad(_cursor_highlight, coord.x, coord.y, sel_col, sel_tex)
|
||||
|
||||
# Check for an occupant on this tile and highlight with team colour.
|
||||
var tile : Dictionary = Game.get_tile(coord.x, coord.y)
|
||||
var occ_id : String = tile.get("occupantId", "")
|
||||
if occ_id.is_empty():
|
||||
_hover_team_overlay.visible = false
|
||||
return
|
||||
|
||||
var is_enemy : bool = _is_enemy_unit(occ_id)
|
||||
var team_col : Color = Color(1.0, 0.35, 0.35, 0.35) if is_enemy else Color(0.3, 0.5, 1.0, 0.35)
|
||||
|
||||
_place_highlight_quad(_hover_team_overlay, coord.x, coord.y, team_col)
|
||||
|
||||
# Boost emission on the unit mesh.
|
||||
if _unit_meshes.has(occ_id):
|
||||
var mesh : MeshInstance3D = _unit_meshes[occ_id] as MeshInstance3D
|
||||
if mesh != null:
|
||||
var orig_mat : Material = mesh.get_active_material(0)
|
||||
if orig_mat != null:
|
||||
var glow_mat : StandardMaterial3D = orig_mat.duplicate() as StandardMaterial3D
|
||||
glow_mat.emission_enabled = true
|
||||
glow_mat.emission = Color(team_col.r, team_col.g, team_col.b)
|
||||
glow_mat.emission_energy_multiplier = 2.5
|
||||
mesh.set_surface_override_material(0, glow_mat)
|
||||
_hovered_unit_mesh = mesh
|
||||
|
||||
|
||||
func _reset_unit_hover_glow() -> void:
|
||||
if _hovered_unit_mesh != null and is_instance_valid(_hovered_unit_mesh):
|
||||
_hovered_unit_mesh.set_surface_override_material(0, null)
|
||||
_hovered_unit_mesh = null
|
||||
|
||||
|
||||
## Create the two permanently-allocated hover/cursor quads.
|
||||
## Called once in _ready() after the scene is set up.
|
||||
func _init_cursor_nodes() -> void:
|
||||
_cursor_highlight = _make_highlight_quad(Color(1, 1, 1, 0.25))
|
||||
_hover_team_overlay = _make_highlight_quad(Color(0, 0, 0, 0))
|
||||
_hi_root.add_child(_cursor_highlight)
|
||||
_hi_root.add_child(_hover_team_overlay)
|
||||
_cursor_highlight.visible = false
|
||||
_hover_team_overlay.visible = false
|
||||
|
||||
|
||||
## Build a flat (PlaneMesh) highlight quad with the given fallback colour.
|
||||
## The caller positions it; the mesh is 0.96 × 0.96 lying flat (rotated -90° on X).
|
||||
func _make_highlight_quad(fallback: Color) -> MeshInstance3D:
|
||||
var mi := MeshInstance3D.new()
|
||||
var bm := BoxMesh.new()
|
||||
bm.size = Vector3(0.96, 0.06, 0.96)
|
||||
mi.mesh = bm
|
||||
var pm := PlaneMesh.new()
|
||||
pm.size = Vector2(0.96, 0.96)
|
||||
mi.mesh = pm
|
||||
var mat := StandardMaterial3D.new()
|
||||
# Use a solid opaque base + emission so the highlight is always visible
|
||||
# regardless of depth-sort or transparency ordering.
|
||||
mat.albedo_color = Color(color.r, color.g, color.b, 1.0)
|
||||
mat.emission_enabled = true
|
||||
mat.emission = Color(color.r, color.g, color.b)
|
||||
mat.emission_energy_multiplier = 2.0
|
||||
# Keep a mild transparency so the tile below is still readable.
|
||||
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
|
||||
mat.albedo_color.a = 0.75
|
||||
mi.material_override = mat
|
||||
# Position just above the tile top (varies per-tile, accounting for stagger).
|
||||
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
|
||||
mat.albedo_color = fallback
|
||||
mat.emission_enabled = true
|
||||
mat.emission = Color(fallback.r, fallback.g, fallback.b)
|
||||
mat.emission_energy_multiplier = 1.5
|
||||
mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
|
||||
mat.cull_mode = BaseMaterial3D.CULL_DISABLED
|
||||
mi.material_override = mat
|
||||
return mi
|
||||
|
||||
|
||||
## Add a textured highlight quad above tile (x, y) for the given game-action type.
|
||||
## type_key: "movement" | "attack" | "ability" | "terramorpha"
|
||||
## Falls back to HighlightConfig colours when no texture is loaded yet.
|
||||
func _add_highlight(x: int, y: int, type_key: String) -> void:
|
||||
var mi := MeshInstance3D.new()
|
||||
var pm := PlaneMesh.new()
|
||||
pm.size = Vector2(0.96, 0.96)
|
||||
mi.mesh = pm
|
||||
var mat := StandardMaterial3D.new()
|
||||
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
|
||||
mat.emission_enabled = true
|
||||
mat.emission_energy_multiplier = 1.5
|
||||
mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
|
||||
mat.cull_mode = BaseMaterial3D.CULL_DISABLED
|
||||
var tex : Texture2D = HighlightConfig.get_texture(type_key)
|
||||
var col : Color = HighlightConfig.get_color(type_key)
|
||||
if tex != null:
|
||||
mat.albedo_texture = tex
|
||||
mat.albedo_color = Color(col.r, col.g, col.b, col.a)
|
||||
else:
|
||||
mat.albedo_color = col
|
||||
mat.emission = Color(col.r, col.g, col.b)
|
||||
mi.material_override = mat
|
||||
var _hi_tile_h : float = _tile_heights.get("%d,%d" % [x, y], 1.0)
|
||||
var _hi_tile_base : float = _tile_y_bases.get("%d,%d" % [x, y], 0.0)
|
||||
mi.position = _coord_to_world(x, y) + Vector3(0, _hi_tile_base + _hi_tile_h + 0.08, 0)
|
||||
mi.position = _coord_to_world(x, y) + Vector3(0, _hi_tile_base + _hi_tile_h + 0.05, 0)
|
||||
_hi_root.add_child(mi)
|
||||
print("[Highlight] added (%d,%d) hi_root children=%d" % [x, y, _hi_root.get_child_count()])
|
||||
|
||||
|
||||
func _highlight_tiles(coords: Array, color: Color) -> void:
|
||||
func _highlight_tiles(coords: Array, type_key: String) -> void:
|
||||
for coord in coords:
|
||||
if coord is Vector2i:
|
||||
_add_highlight(coord.x, coord.y, color)
|
||||
_add_highlight(coord.x, coord.y, type_key)
|
||||
elif coord is Dictionary:
|
||||
_add_highlight(coord.get("x", 0), coord.get("y", 0), color)
|
||||
_add_highlight(coord.get("x", 0), coord.get("y", 0), type_key)
|
||||
|
||||
|
||||
## Position a permanently-allocated highlight quad above tile (x, y).
|
||||
func _place_highlight_quad(quad: MeshInstance3D, x: int, y: int, col: Color, texture: Texture2D = null) -> void:
|
||||
var tile_h : float = _tile_heights.get("%d,%d" % [x, y], 1.0)
|
||||
var tile_base : float = _tile_y_bases.get("%d,%d" % [x, y], 0.0)
|
||||
quad.position = _coord_to_world(x, y) + Vector3(0, tile_base + tile_h + 0.05, 0)
|
||||
var mat := quad.material_override as StandardMaterial3D
|
||||
mat.albedo_color = col
|
||||
mat.emission = Color(col.r, col.g, col.b)
|
||||
if texture != null:
|
||||
mat.albedo_texture = texture
|
||||
quad.visible = true
|
||||
|
||||
# ── Valid target computation ──────────────────────────────────────────────────
|
||||
|
||||
@@ -2098,7 +2230,7 @@ func _handle_board_click(mouse_pos: Vector2) -> void:
|
||||
# More tiles needed — re-highlight: orange for picked, green for valid next.
|
||||
_clear_highlights()
|
||||
for t: Vector2i in _terra_targets:
|
||||
_add_highlight(t.x, t.y, HI_ORANGE)
|
||||
_add_highlight(t.x, t.y, "terramorpha")
|
||||
var last2 : Vector2i = _terra_targets.back()
|
||||
var bw2 := Game.board_width()
|
||||
var bh2 := Game.board_height()
|
||||
@@ -2107,7 +2239,7 @@ func _handle_board_click(mouse_pos: Vector2) -> void:
|
||||
var ny := last2.y + d.y
|
||||
if nx < 0 or ny < 0 or nx >= bw2 or ny >= bh2: continue
|
||||
if _terra_targets.has(Vector2i(nx, ny)): continue
|
||||
_add_highlight(nx, ny, HI_GREEN)
|
||||
_add_highlight(nx, ny, "movement")
|
||||
|
||||
Mode.UNIT_SELECTED:
|
||||
if not unit_id.is_empty():
|
||||
@@ -2177,7 +2309,7 @@ func _select_unit(unit_id: String) -> void:
|
||||
# Highlight own tile.
|
||||
var upos : Dictionary = unit.get("position", {})
|
||||
if not upos.is_empty():
|
||||
_add_highlight(upos.get("x", 0), upos.get("y", 0), HI_YELLOW)
|
||||
_add_highlight(upos.get("x", 0), upos.get("y", 0), "selector")
|
||||
# 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))
|
||||
@@ -2188,13 +2320,13 @@ func _select_unit(unit_id: String) -> void:
|
||||
func(v: Vector3) -> void: _cam_pivot = v; _apply_camera(),
|
||||
from, target, 0.4)
|
||||
|
||||
# Movement range (green).
|
||||
_highlight_tiles(_valid_move_tiles(unit), HI_GREEN)
|
||||
# Movement range.
|
||||
_highlight_tiles(_valid_move_tiles(unit), "movement")
|
||||
|
||||
# Attack range area (orange) — visible reach even when no enemies are in range.
|
||||
_highlight_tiles(_attack_range_tiles(unit), HI_ORANGE)
|
||||
# Attackable enemies (red — drawn on top of orange).
|
||||
_highlight_tiles(_valid_attack_target_coords(unit), HI_RED)
|
||||
# Attack range area — visible reach even when no enemies are in range.
|
||||
_highlight_tiles(_attack_range_tiles(unit), "terramorpha")
|
||||
# Attackable enemies (drawn on top).
|
||||
_highlight_tiles(_valid_attack_target_coords(unit), "attack")
|
||||
|
||||
# Show ability panel if unit has active abilities.
|
||||
_show_ability_panel(unit_id, unit)
|
||||
@@ -2271,7 +2403,7 @@ func _start_sacrifice_mode() -> void:
|
||||
for spirit: Dictionary in _valid_sacrifice_spirits():
|
||||
var sp : Dictionary = spirit.get("position", {})
|
||||
if not sp.is_empty():
|
||||
_add_highlight(sp.get("x", 0), sp.get("y", 0), HI_GREEN)
|
||||
_add_highlight(sp.get("x", 0), sp.get("y", 0), "movement")
|
||||
|
||||
|
||||
func _confirm_sacrifice(unit_id: String, unit_name: String) -> void:
|
||||
@@ -2534,7 +2666,7 @@ func _highlight_ability_targets(action: Dictionary) -> void:
|
||||
for tx in range(bw):
|
||||
for ty in range(bh):
|
||||
if _tile_passes_filters(tx, ty, filters):
|
||||
_add_highlight(tx, ty, HI_BLUE)
|
||||
_add_highlight(tx, ty, "ability")
|
||||
return
|
||||
|
||||
# Unit-type target — highlight the board position of each matching unit.
|
||||
@@ -2572,7 +2704,7 @@ func _highlight_ability_targets(action: Dictionary) -> void:
|
||||
absi(int(pos.get("y", 0)) - int(src_pos_ab.get("y", 0))))
|
||||
if dist < int(_ability_range.get("min", 0)) or dist > int(_ability_range.get("max", 999)):
|
||||
continue
|
||||
_add_highlight(pos.get("x", 0), pos.get("y", 0), HI_BLUE)
|
||||
_add_highlight(pos.get("x", 0), pos.get("y", 0), "ability")
|
||||
|
||||
|
||||
## Returns true if the unit passes all client-evaluable filters.
|
||||
@@ -2791,7 +2923,7 @@ func _on_hand_card_clicked(iid: String, _panel: PanelContainer) -> void:
|
||||
_set_mode(Mode.TERRAMORPHA_SELECT)
|
||||
_terra_count = _terra_count_for_card(card)
|
||||
_clear_highlights()
|
||||
_highlight_tiles(_valid_play_tiles(card), HI_GREEN)
|
||||
_highlight_tiles(_valid_play_tiles(card), "movement")
|
||||
return
|
||||
|
||||
# Ruin — server auto-places it; channel immediately on click.
|
||||
@@ -2860,7 +2992,7 @@ func _on_hand_card_clicked(iid: String, _panel: PanelContainer) -> void:
|
||||
_sel_card_id = iid
|
||||
_set_mode(Mode.CARD_FROM_HAND)
|
||||
_clear_highlights()
|
||||
_highlight_tiles(_valid_play_tiles(card), HI_GREEN)
|
||||
_highlight_tiles(_valid_play_tiles(card), "movement")
|
||||
|
||||
# ── Hand display ──────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -2985,7 +3117,7 @@ func _update_hud(state: Dictionary) -> void:
|
||||
if _mode != Mode.PLACEMENT:
|
||||
_set_mode(Mode.PLACEMENT)
|
||||
_clear_highlights()
|
||||
_highlight_tiles(_valid_placement_tiles(), HI_GREEN)
|
||||
_highlight_tiles(_valid_placement_tiles(), "movement")
|
||||
else:
|
||||
_phase_lbl.text = "Phase: Placement — waiting for opponent…"
|
||||
if _mode == Mode.PLACEMENT:
|
||||
@@ -3216,7 +3348,7 @@ func _on_state_updated(state: Dictionary) -> void:
|
||||
# Re-apply highlights: board/units may have changed.
|
||||
print("[StateUpdate] preserving CARD_FROM_HAND, re-highlighting")
|
||||
_clear_highlights()
|
||||
_highlight_tiles(_valid_play_tiles(sel_card), HI_GREEN)
|
||||
_highlight_tiles(_valid_play_tiles(sel_card), "movement")
|
||||
_refresh_hand_selection() # mark the (new) widget as selected
|
||||
|
||||
_:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
extends Control
|
||||
## Settings screen — audio volume and mute controls.
|
||||
## Settings screen — audio volume, mute, gameplay, and highlight override controls.
|
||||
## Reads initial values from the Settings autoload and writes back on change.
|
||||
|
||||
@onready var back_btn : Button = %BackBtn
|
||||
@@ -9,6 +9,9 @@ extends Control
|
||||
@onready var sfx_mute_btn : CheckButton = %SfxMuteBtn
|
||||
@onready var camera_follow_btn : CheckButton = %CameraFollowBtn
|
||||
|
||||
const _HI_TYPES : Array = ["movement", "attack", "ability", "terramorpha", "selector"]
|
||||
const _HI_LABELS: Array = ["Movement", "Attack", "Ability", "Terramorpha", "Selector"]
|
||||
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -20,6 +23,7 @@ func _ready() -> void:
|
||||
camera_follow_btn.set_pressed_no_signal(Settings.camera_follow_unit)
|
||||
|
||||
_refresh_slider_states()
|
||||
_build_highlight_section()
|
||||
|
||||
back_btn.pressed.connect(_on_back)
|
||||
music_slider.value_changed.connect(func(v): Settings.music_volume = v)
|
||||
@@ -43,3 +47,68 @@ func _refresh_slider_states() -> void:
|
||||
|
||||
func _on_back() -> void:
|
||||
get_tree().change_scene_to_file("res://scenes/main/MainScreen.tscn")
|
||||
|
||||
|
||||
# ── Highlight override section (built programmatically) ───────────────────────
|
||||
|
||||
func _build_highlight_section() -> void:
|
||||
var sections : VBoxContainer = get_node_or_null(
|
||||
"Layout/ScrollContainer/Content/ContentMargin/Sections")
|
||||
if sections == null:
|
||||
return
|
||||
|
||||
var section := VBoxContainer.new()
|
||||
section.add_theme_constant_override("separation", 6)
|
||||
|
||||
var header := Label.new()
|
||||
header.text = "Highlight Texture Overrides"
|
||||
header.add_theme_font_size_override("font_size", 16)
|
||||
section.add_child(header)
|
||||
|
||||
var note := Label.new()
|
||||
note.text = "Enter a custom texture URL for each highlight type, or leave blank to use\nthe server default. Changes apply immediately."
|
||||
note.autowrap_mode = TextServer.AUTOWRAP_WORD
|
||||
note.modulate = Color(0.75, 0.75, 0.75)
|
||||
note.add_theme_font_size_override("font_size", 12)
|
||||
section.add_child(note)
|
||||
|
||||
for i in range(_HI_TYPES.size()):
|
||||
var key : String = _HI_TYPES[i]
|
||||
var label : String = _HI_LABELS[i]
|
||||
var row := _make_override_row(key, label)
|
||||
section.add_child(row)
|
||||
|
||||
sections.add_child(section)
|
||||
|
||||
|
||||
func _make_override_row(key: String, label: String) -> HBoxContainer:
|
||||
var row := HBoxContainer.new()
|
||||
row.add_theme_constant_override("separation", 8)
|
||||
|
||||
var lbl := Label.new()
|
||||
lbl.text = label
|
||||
lbl.custom_minimum_size = Vector2(90, 0)
|
||||
lbl.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
row.add_child(lbl)
|
||||
|
||||
var edit := LineEdit.new()
|
||||
edit.placeholder_text = "https://cdn.sor.gg/highlights/… (leave blank for default)"
|
||||
edit.text = str(Settings.highlight_overrides.get(key, ""))
|
||||
edit.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
row.add_child(edit)
|
||||
|
||||
var reset_btn := Button.new()
|
||||
reset_btn.text = "Reset"
|
||||
reset_btn.tooltip_text = "Remove override — use server default"
|
||||
row.add_child(reset_btn)
|
||||
|
||||
# Apply URL when the LineEdit loses focus or Enter is pressed.
|
||||
edit.text_submitted.connect(func(url: String) -> void:
|
||||
Settings.set_highlight_override(key, url.strip_edges()))
|
||||
edit.focus_exited.connect(func() -> void:
|
||||
Settings.set_highlight_override(key, edit.text.strip_edges()))
|
||||
reset_btn.pressed.connect(func() -> void:
|
||||
Settings.clear_highlight_override(key)
|
||||
edit.text = "")
|
||||
|
||||
return row
|
||||
|
||||
Reference in New Issue
Block a user