From b36a644f56878e2a122ca0418c8da575a31cebf0 Mon Sep 17 00:00:00 2001 From: dingo Date: Sun, 8 Mar 2026 12:40:48 -0400 Subject: [PATCH] =?UTF-8?q?Fix:=20Spirit=20card=20highlights=20=E2=80=94?= =?UTF-8?q?=20emissive=20material,=20preserve=20selection=20through=20stat?= =?UTF-8?q?e=20updates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - _add_highlight: use emission (emission_energy_multiplier=2) + 75% opaque base so tiles glow visibly regardless of depth-sort/transparency ordering; raised Y to 0.58 (clear of tile top at 0.50); thicker mesh (0.06 vs 0.02) - Remove Godot-3-only flags_transparent property (no-op in Godot 4) - _on_state_updated: preserve CARD_FROM_HAND / TERRAMORPHA_SELECT through server state pushes if selected card is still in hand (re-apply highlights after _rebuild_hand); only clear UNIT_SELECTED and other transient modes - Add diagnostic prints to _add_highlight and _on_state_updated to trace when state updates arrive relative to card selection Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- .../components/card_detail_popup.gd | 4 +- .../origin-client/scenes/game/GameScreen.tscn | 62 ++++++++----------- .../origin-client/scenes/game/game_screen.gd | 57 +++++++++++++---- 3 files changed, 73 insertions(+), 50 deletions(-) diff --git a/Client/origin-client/scenes/collection/components/card_detail_popup.gd b/Client/origin-client/scenes/collection/components/card_detail_popup.gd index 08ab926..21c97b2 100644 --- a/Client/origin-client/scenes/collection/components/card_detail_popup.gd +++ b/Client/origin-client/scenes/collection/components/card_detail_popup.gd @@ -96,11 +96,11 @@ func _add_stat(label_text: String, value_text: String) -> void: var lbl := Label.new() lbl.text = label_text lbl.modulate = Color(0.65, 0.65, 0.72) - lbl.theme_override_font_sizes["font_size"] = 12 + #lbl.theme_override_font_sizes["font_size"] = 12 var val := Label.new() val.text = value_text - val.theme_override_font_sizes["font_size"] = 13 + #val.theme_override_font_sizes["font_size"] = 13 stats_grid.add_child(lbl) stats_grid.add_child(val) diff --git a/Client/origin-client/scenes/game/GameScreen.tscn b/Client/origin-client/scenes/game/GameScreen.tscn index 862b304..e914132 100644 --- a/Client/origin-client/scenes/game/GameScreen.tscn +++ b/Client/origin-client/scenes/game/GameScreen.tscn @@ -1,6 +1,6 @@ -[gd_scene load_steps=2 format=3 uid="uid://game_screen"] +[gd_scene load_steps=2 format=3 uid="uid://b17evi1hw4dqu"] -[ext_resource type="Script" path="res://scenes/game/game_screen.gd" id="1_gscr"] +[ext_resource type="Script" uid="uid://b8x84lb58h6gx" path="res://scenes/game/game_screen.gd" id="1_gscr"] [node name="GameScreen" type="Node3D"] script = ExtResource("1_gscr") @@ -29,19 +29,15 @@ transform = Transform3D(1, 0, 0, 0, 0.766044, 0.642788, 0, -0.642788, 0.766044, layer = 10 [node name="TopBar" type="HBoxContainer" parent="HUD"] -layout_mode = 1 anchors_preset = -1 -anchor_left = 0.0 -anchor_top = 0.0 anchor_right = 1.0 -anchor_bottom = 0.0 offset_bottom = 48.0 theme_override_constants/separation = 0 [node name="PhaseLabel" type="Label" parent="HUD/TopBar"] unique_name_in_owner = true -layout_mode = 2 custom_minimum_size = Vector2(140, 48) +layout_mode = 2 theme_override_font_sizes/font_size = 13 text = "Phase: —" vertical_alignment = 1 @@ -57,17 +53,17 @@ vertical_alignment = 1 [node name="OpponentPanel" type="HBoxContainer" parent="HUD/TopBar"] unique_name_in_owner = true -layout_mode = 2 custom_minimum_size = Vector2(240, 48) +layout_mode = 2 theme_override_constants/separation = 8 [node name="OppNameLabel" type="Label" parent="HUD/TopBar/OpponentPanel"] unique_name_in_owner = true +modulate = Color(1, 0.5, 0.5, 1) layout_mode = 2 theme_override_font_sizes/font_size = 12 text = "Opponent" vertical_alignment = 1 -modulate = Color(1, 0.5, 0.5, 1) [node name="OppHandLabel" type="Label" parent="HUD/TopBar/OpponentPanel"] unique_name_in_owner = true @@ -90,14 +86,11 @@ theme_override_font_sizes/font_size = 11 text = "Discard" [node name="HandArea" type="PanelContainer" parent="HUD"] -layout_mode = 1 anchors_preset = -1 -anchor_left = 0.0 anchor_top = 1.0 anchor_right = 0.75 anchor_bottom = 1.0 -offset_top = -220.0 -offset_right = 0.0 +offset_top = -250.0 [node name="HandScroll" type="ScrollContainer" parent="HUD/HandArea"] unique_name_in_owner = true @@ -113,19 +106,22 @@ size_flags_vertical = 4 theme_override_constants/separation = 6 [node name="RightPanel" type="PanelContainer" parent="HUD"] -layout_mode = 1 anchors_preset = -1 anchor_left = 0.75 anchor_top = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 -offset_top = -220.0 +offset_left = -1.0 +offset_top = -241.0 +offset_right = -1.0 +offset_bottom = 9.0 +scale = Vector2(1, 0.96000004) [node name="RightMargin" type="MarginContainer" parent="HUD/RightPanel"] layout_mode = 2 theme_override_constants/margin_left = 10 -theme_override_constants/margin_right = 10 theme_override_constants/margin_top = 8 +theme_override_constants/margin_right = 10 theme_override_constants/margin_bottom = 8 [node name="RightVBox" type="VBoxContainer" parent="HUD/RightPanel/RightMargin"] @@ -156,21 +152,17 @@ layout_mode = 2 theme_override_font_sizes/font_size = 12 text = "View Discard" -[node name="Spacer" type="Control" parent="HUD/RightPanel/RightMargin/RightVBox"] -layout_mode = 2 -size_flags_vertical = 3 - [node name="DrawBtn" type="Button" parent="HUD/RightPanel/RightMargin/RightVBox"] unique_name_in_owner = true -layout_mode = 2 custom_minimum_size = Vector2(0, 36) +layout_mode = 2 theme_override_font_sizes/font_size = 13 text = "Draw Card" [node name="EndTurnBtn" type="Button" parent="HUD/RightPanel/RightMargin/RightVBox"] unique_name_in_owner = true -layout_mode = 2 custom_minimum_size = Vector2(0, 36) +layout_mode = 2 theme_override_font_sizes/font_size = 13 text = "End Turn" @@ -182,7 +174,7 @@ text = "Concede" [node name="ContextPopup" type="PanelContainer" parent="HUD"] unique_name_in_owner = true -layout_mode = 1 +visible = false anchors_preset = -1 anchor_left = 0.5 anchor_top = 0.5 @@ -192,13 +184,12 @@ offset_left = -160.0 offset_top = -120.0 offset_right = 160.0 offset_bottom = 120.0 -visible = false [node name="ContextMargin" type="MarginContainer" parent="HUD/ContextPopup"] layout_mode = 2 theme_override_constants/margin_left = 12 -theme_override_constants/margin_right = 12 theme_override_constants/margin_top = 8 +theme_override_constants/margin_right = 12 theme_override_constants/margin_bottom = 8 [node name="ContextVBox" type="VBoxContainer" parent="HUD/ContextPopup/ContextMargin"] @@ -215,16 +206,14 @@ text = "Tile (0,0) — Void" unique_name_in_owner = true layout_mode = 2 theme_override_font_sizes/font_size = 12 -text = "" autowrap_mode = 3 [node name="ContextAbilitiesLabel" type="Label" parent="HUD/ContextPopup/ContextMargin/ContextVBox"] unique_name_in_owner = true +modulate = Color(0.7, 0.7, 0.85, 1) layout_mode = 2 theme_override_font_sizes/font_size = 11 -text = "" autowrap_mode = 3 -modulate = Color(0.7, 0.7, 0.85, 1) [node name="ContextClose" type="Button" parent="HUD/ContextPopup/ContextMargin/ContextVBox"] unique_name_in_owner = true @@ -234,18 +223,18 @@ text = "Close" [node name="DiscardViewer" type="PanelContainer" parent="HUD"] unique_name_in_owner = true -layout_mode = 1 +visible = false +anchors_preset = -1 anchor_left = 0.1 anchor_top = 0.05 anchor_right = 0.9 anchor_bottom = 0.95 -visible = false [node name="DVMargin" type="MarginContainer" parent="HUD/DiscardViewer"] layout_mode = 2 theme_override_constants/margin_left = 16 -theme_override_constants/margin_right = 16 theme_override_constants/margin_top = 12 +theme_override_constants/margin_right = 16 theme_override_constants/margin_bottom = 12 [node name="DVVBox" type="VBoxContainer" parent="HUD/DiscardViewer/DVMargin"] @@ -271,25 +260,25 @@ theme_override_constants/separation = 4 [node name="DVCloseBtn" type="Button" parent="HUD/DiscardViewer/DVMargin/DVVBox"] unique_name_in_owner = true -layout_mode = 2 custom_minimum_size = Vector2(0, 36) +layout_mode = 2 theme_override_font_sizes/font_size = 13 text = "Close" [node name="GameOverOverlay" type="PanelContainer" parent="HUD"] unique_name_in_owner = true -layout_mode = 1 +visible = false +anchors_preset = -1 anchor_left = 0.25 anchor_top = 0.25 anchor_right = 0.75 anchor_bottom = 0.75 -visible = false [node name="GOMargin" type="MarginContainer" parent="HUD/GameOverOverlay"] layout_mode = 2 theme_override_constants/margin_left = 24 -theme_override_constants/margin_right = 24 theme_override_constants/margin_top = 24 +theme_override_constants/margin_right = 24 theme_override_constants/margin_bottom = 24 [node name="GOVBox" type="VBoxContainer" parent="HUD/GameOverOverlay/GOMargin"] @@ -307,13 +296,12 @@ horizontal_alignment = 1 unique_name_in_owner = true layout_mode = 2 theme_override_font_sizes/font_size = 15 -text = "" horizontal_alignment = 1 [node name="GOMainMenuBtn" type="Button" parent="HUD/GameOverOverlay/GOMargin/GOVBox"] unique_name_in_owner = true -layout_mode = 2 custom_minimum_size = Vector2(0, 44) +layout_mode = 2 theme_override_font_sizes/font_size = 15 text = "Return to Main Menu" diff --git a/Client/origin-client/scenes/game/game_screen.gd b/Client/origin-client/scenes/game/game_screen.gd index d3997f7..8246add 100644 --- a/Client/origin-client/scenes/game/game_screen.gd +++ b/Client/origin-client/scenes/game/game_screen.gd @@ -493,15 +493,23 @@ func _clear_highlights() -> void: func _add_highlight(x: int, y: int, color: Color) -> void: var mi := MeshInstance3D.new() var bm := BoxMesh.new() - bm.size = Vector3(0.98, 0.02, 0.98) + bm.size = Vector3(0.96, 0.06, 0.96) mi.mesh = bm var mat := StandardMaterial3D.new() - mat.albedo_color = color - mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA - mat.flags_transparent = true - mi.material_override = mat - mi.position = _coord_to_world(x, y) + Vector3(0, 0.52, 0) + # 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 clearly above the tile top (tile top = Y 0.50). + mi.position = _coord_to_world(x, y) + Vector3(0, 0.58, 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: @@ -536,13 +544,15 @@ func _valid_play_tiles(card: Dictionary) -> Array: var raw_min = arch.get("minChannelRange") var raw_max = arch.get("maxChannelRange") var min_r : int = 1 if raw_min == null else int(raw_min) - var max_r : int = 2 if raw_max == null else int(raw_max) + var max_r : int = 1 if raw_max == null else int(raw_max) for tx in range(bw): for ty in range(bh): var dist : int = abs(tx - ax) + abs(ty - ay) if dist < min_r or dist > max_r: continue if Game.get_tile(tx, ty).get("occupantId"): continue + print("Adding tiles") results.append(Vector2i(tx, ty)) + print("results: ", results) "Terramorpha": for tx in range(bw): @@ -718,9 +728,10 @@ func _handle_board_click(mouse_pos: Vector2) -> void: if abs(coord.x - last.x) + abs(coord.y - last.y) != 1: return # must be adjacent # Avoid duplicates. + print("Handle Board Click: terra targets: ", _terra_targets) if _terra_targets.has(coord): return _terra_targets.append(coord) - + print("Added Target") if _terra_targets.size() >= _terra_count: # All tiles selected — send play. var targets := _terra_targets.map(func(v: Vector2i) -> Dictionary: @@ -1265,6 +1276,9 @@ func _on_game_over(winner_id: String, win_condition: String, # ── State → scene ───────────────────────────────────────────────────────────── func _on_state_updated(state: Dictionary) -> void: + print("[StateUpdate] phase=", state.get("phase","?"), + " mode=", _mode, " sel_card=", + _sel_card_id.substr(0, 8) if not _sel_card_id.is_empty() else "none") _rebuild_ownership(state) # Orient camera behind the local player's row on the first state with playerOneAccountId. @@ -1305,9 +1319,30 @@ func _on_state_updated(state: Dictionary) -> void: _rebuild_hand(hand) _update_hud(state) - # Clear non-PLACEMENT selection after state change. - if _mode not in [Mode.NONE, Mode.PLACEMENT]: - _set_mode(Mode.NONE) + # After a state update, preserve hand-card and unit selections where possible. + # A state push from the server (e.g. opponent action, draw echo) must not + # silently clear tile highlights that the player just set up. + match _mode: + Mode.NONE, Mode.PLACEMENT: + pass # placement highlights are managed in _update_hud above + + Mode.CARD_FROM_HAND, Mode.TERRAMORPHA_SELECT: + # Keep selection only if the card is still in our hand. + var sel_card := _find_hand_card(_sel_card_id) + if sel_card.is_empty(): + print("[StateUpdate] selected card gone — clearing mode") + _set_mode(Mode.NONE) + else: + # 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) + _refresh_hand_selection() # mark the (new) widget as selected + + _: + # Unit selected, sacrifice, ability — clear these on any state change + # because unit positions / health / eligibility may have changed. + _set_mode(Mode.NONE) # Auto-draw. if state.get("phase", "") == "Draw" and Game.is_my_turn():