diff --git a/Client/origin-client/autoloads/HighlightConfig.gd b/Client/origin-client/autoloads/HighlightConfig.gd new file mode 100644 index 0000000..b44d641 --- /dev/null +++ b/Client/origin-client/autoloads/HighlightConfig.gd @@ -0,0 +1,209 @@ +extends Node +## HighlightConfig autoload — fetches and caches tile highlight texture configuration. +## +## Usage: +## HighlightConfig.get_texture("movement") → Texture2D or null +## HighlightConfig.get_color("movement") → Color (parsed from fallbackHex) +## HighlightConfig.is_ready → bool +## +## Cosmetic overrides (via Settings.highlight_overrides or equipped HighlightPack): +## HighlightConfig.set_override("movement", { cdnPath=…, isAnimated=false, … }) +## HighlightConfig.clear_override("movement") +## HighlightConfig.clear_all_overrides() +## +## Texture loading is async. Callers should handle null gracefully and fall back to +## get_color() when get_texture() returns null. + +signal loaded + +const CACHE_PATH := "user://highlight_config.json" +const REQUEST_TYPE := "content.get_highlight_config" + +## Default fallback colours used when no server config exists. +const DEFAULT_HEX : Dictionary = { + "movement": "#33FF3366", + "attack": "#FF404080", + "ability": "#3380FF66", + "terramorpha": "#FF990073", + "selector": "#FFFFFF40", +} + +## Whether the server config has been loaded (or the cache has been used). +var is_ready : bool = false + +# ── Internal state ───────────────────────────────────────────────────────────── + +# Server-provided configs keyed by lowercase type name. +# Each entry: { cdnPath, isAnimated, frameCount, fps, fallbackHex } +var _server_configs : Dictionary = {} + +# Admin/cosmetic overrides — same structure, keyed by lowercase type name. +var _overrides : Dictionary = {} + +# Loaded textures: type → Texture2D (null while loading or if failed). +var _textures : Dictionary = {} + +# HTTP fetch nodes keyed by type (to avoid duplicate requests). +var _pending_fetches : Dictionary = {} + +# ── Lifecycle ────────────────────────────────────────────────────────────────── + +func _ready() -> void: + _load_cache() + _fetch_from_server() + + +# ── Public API ───────────────────────────────────────────────────────────────── + +## Returns the loaded Texture2D for this highlight type, or null if not yet loaded. +## Starts loading the texture on first call if not already in progress. +func get_texture(type: String) -> Texture2D: + var key := type.to_lower() + if _textures.has(key): + return _textures[key] + # Start loading if we have a config for this type. + var cfg := _effective_config(key) + if not cfg.is_empty() and not cfg.get("cdnPath", "").is_empty(): + _start_texture_load(key, cfg) + return null + + +## Returns the fallback Color for this highlight type. +func get_color(type: String) -> Color: + var key := type.to_lower() + var cfg := _effective_config(key) + var hex : String = cfg.get("fallbackHex", DEFAULT_HEX.get(key, "#FFFFFF66")) + return _parse_hex(hex) + + +## Override a highlight type with a custom config dict. +## Config keys: cdnPath (String), isAnimated (bool), frameCount (int), fps (float), fallbackHex (String). +func set_override(type: String, config: Dictionary) -> void: + var key := type.to_lower() + _overrides[key] = config + _textures.erase(key) # Invalidate cached texture so next get_texture() reloads. + _pending_fetches.erase(key) + + +## Remove override for one type. +func clear_override(type: String) -> void: + var key := type.to_lower() + _overrides.erase(key) + _textures.erase(key) + _pending_fetches.erase(key) + + +## Remove all cosmetic/settings overrides. +func clear_all_overrides() -> void: + _overrides.clear() + _textures.clear() + _pending_fetches.clear() + + +## Apply an equipped HighlightPack cosmetic (parsed from AssetCdnUrl JSON). +## pack_data: Dictionary keyed by lowercase type name, each value is a config dict. +func apply_cosmetic_pack(pack_data: Dictionary) -> void: + for key in pack_data: + set_override(str(key).to_lower(), pack_data[key] as Dictionary) + + +# ── Internal ─────────────────────────────────────────────────────────────────── + +func _effective_config(key: String) -> Dictionary: + if _overrides.has(key): + return _overrides[key] as Dictionary + if _server_configs.has(key): + return _server_configs[key] as Dictionary + return {} + + +func _fetch_from_server() -> void: + Network.request( + REQUEST_TYPE, + {}, + func(_type: String, resp: Variant) -> void: + _on_server_response(resp), + func(_code: String, _msg: String) -> void: + # Use cached config if available; set is_ready anyway. + is_ready = true + loaded.emit() + ) + + +func _on_server_response(resp: Variant) -> void: + var configs : Array = (resp as Dictionary).get("configs", []) + for entry : Dictionary in configs: + var key : String = str(entry.get("highlightType", "")).to_lower() + if key.is_empty(): + continue + _server_configs[key] = { + "cdnPath": str(entry.get("cdnPath", "")), + "isAnimated": bool(entry.get("isAnimated", false)), + "frameCount": int(entry.get("frameCount", 1)), + "fps": float(entry.get("fps", 12.0)), + "fallbackHex": str(entry.get("fallbackHex", DEFAULT_HEX.get(key, "#FFFFFF66"))), + } + _save_cache() + is_ready = true + loaded.emit() + + +func _start_texture_load(key: String, cfg: Dictionary) -> void: + if _pending_fetches.has(key): + return + _pending_fetches[key] = true + var url : String = cfg.get("cdnPath", "") + if url.is_empty(): + return + + var http := HTTPRequest.new() + add_child(http) + http.request_completed.connect( + func(result: int, _code: int, _headers: PackedStringArray, body: PackedByteArray) -> void: + http.queue_free() + _pending_fetches.erase(key) + if result != HTTPRequest.RESULT_SUCCESS or body.is_empty(): + return + var img := Image.new() + if img.load_png_from_buffer(body) != OK: + if img.load_webp_from_buffer(body) != OK: + return + var tex := ImageTexture.create_from_image(img) + _textures[key] = tex + ) + http.request(url) + + +func _parse_hex(hex: String) -> Color: + var s := hex.strip_edges() + if s.begins_with("#"): + s = s.substr(1) + match s.length(): + 6: return Color(s.hex_to_int() << 8 | 0xFF) / float(0xFFFFFFFF) + 8: + var v := s.hex_to_int() + var r := ((v >> 24) & 0xFF) / 255.0 + var g := ((v >> 16) & 0xFF) / 255.0 + var b := ((v >> 8) & 0xFF) / 255.0 + var a := ( v & 0xFF) / 255.0 + return Color(r, g, b, a) + return Color.WHITE + + +func _load_cache() -> void: + var f := FileAccess.open(CACHE_PATH, FileAccess.READ) + if f == null: + return + var text := f.get_as_text() + f.close() + var parsed := JSON.parse_string(text) + if parsed is Dictionary: + _server_configs = parsed as Dictionary + + +func _save_cache() -> void: + var f := FileAccess.open(CACHE_PATH, FileAccess.WRITE) + if f == null: + return + f.store_string(JSON.stringify(_server_configs)) + f.close() diff --git a/Client/origin-client/autoloads/Settings.gd b/Client/origin-client/autoloads/Settings.gd index 5a75707..2caec32 100644 --- a/Client/origin-client/autoloads/Settings.gd +++ b/Client/origin-client/autoloads/Settings.gd @@ -9,10 +9,11 @@ extends Node ## ## 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 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" @@ -65,6 +66,31 @@ var skybox_mode : String = "live" : _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: @@ -82,6 +108,20 @@ func _apply_music() -> void: 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: @@ -98,8 +138,11 @@ func _load() -> void: 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")) + 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: @@ -108,6 +151,7 @@ func _save() -> void: 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_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) diff --git a/Client/origin-client/project.godot b/Client/origin-client/project.godot index 622ea2c..337d344 100644 --- a/Client/origin-client/project.godot +++ b/Client/origin-client/project.godot @@ -28,6 +28,7 @@ CustomLobby="*res://autoloads/CustomLobby.gd" ModelCache="*res://autoloads/ModelCache.gd" Music="*res://autoloads/Music.gd" SFX="*res://autoloads/SFX.gd" +HighlightConfig="*res://autoloads/HighlightConfig.gd" [display] diff --git a/Client/origin-client/scenes/game/game_screen.gd b/Client/origin-client/scenes/game/game_screen.gd index 93e59f0..4137c35 100644 --- a/Client/origin-client/scenes/game/game_screen.gd +++ b/Client/origin-client/scenes/game/game_screen.gd @@ -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 _: diff --git a/Client/origin-client/scenes/settings/settings_screen.gd b/Client/origin-client/scenes/settings/settings_screen.gd index 6bc7a10..27d9a73 100644 --- a/Client/origin-client/scenes/settings/settings_screen.gd +++ b/Client/origin-client/scenes/settings/settings_screen.gd @@ -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 diff --git a/Server/src/SOR.Admin/Components/Layout/NavMenu.razor b/Server/src/SOR.Admin/Components/Layout/NavMenu.razor index 9525470..4823143 100644 --- a/Server/src/SOR.Admin/Components/Layout/NavMenu.razor +++ b/Server/src/SOR.Admin/Components/Layout/NavMenu.razor @@ -127,6 +127,11 @@ Skyboxes +