Refactor: unit double-click uses existing ctx_popup instead of CardDetailPopup
Removes the broken CardDetailPopup overlay machinery entirely. Double-clicking a battlefield unit now populates and shows the existing ContextPopup with name/type/affinity header, HP/DEF/ATK/MP stats row, and ability list (name + description bullets). 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:
@@ -64,7 +64,6 @@ enum Mode {
|
||||
var count : int = 0
|
||||
var _last_click_frame : int = -1
|
||||
var _last_click_iid : String = ""
|
||||
var _card_detail_popup : Control = null
|
||||
# ── Affinity colors ───────────────────────────────────────────────────────────
|
||||
|
||||
const AFFINITY_COLORS : Dictionary = {
|
||||
@@ -93,8 +92,7 @@ const AFFINITY_COLORS : Dictionary = {
|
||||
"GatewayField": Color(0.52, 0.60, 0.22),
|
||||
}
|
||||
|
||||
const _CARD_WIDGET_SCENE := preload("res://scenes/collection/components/CardWidget.tscn")
|
||||
const _CARD_DETAIL_POPUP_SCENE := preload("res://scenes/collection/components/CardDetailPopup.tscn")
|
||||
const _CARD_WIDGET_SCENE := preload("res://scenes/collection/components/CardWidget.tscn")
|
||||
|
||||
const HI_GREEN := Color(0.20, 0.90, 0.20, 0.40)
|
||||
const HI_RED := Color(1.00, 0.25, 0.25, 0.50)
|
||||
@@ -161,19 +159,6 @@ func _ready() -> void:
|
||||
get_tree().change_scene_to_file("res://scenes/main/MainScreen.tscn"))
|
||||
_hold_timer.timeout.connect(_on_hold_timer_fired)
|
||||
|
||||
# Card detail popup — needs a Control parent (not CanvasLayer directly) for
|
||||
# CenterContainer/ScrollContainer layout to work, and its own layer above HUD.
|
||||
var _popup_layer := CanvasLayer.new()
|
||||
_popup_layer.layer = 20
|
||||
add_child(_popup_layer)
|
||||
var _popup_anchor := Control.new()
|
||||
_popup_anchor.set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
_popup_anchor.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
_popup_layer.add_child(_popup_anchor)
|
||||
_card_detail_popup = _CARD_DETAIL_POPUP_SCENE.instantiate()
|
||||
_popup_anchor.add_child(_card_detail_popup)
|
||||
_card_detail_popup.hide()
|
||||
|
||||
Game.state_updated.connect(_on_state_updated)
|
||||
Game.game_over.connect(_on_game_over)
|
||||
|
||||
@@ -1066,13 +1051,28 @@ func _hide_ability_panel() -> void:
|
||||
func _show_unit_detail_popup(unit_id: String) -> void:
|
||||
var unit := Game.get_unit_by_id(unit_id)
|
||||
if unit.is_empty(): return
|
||||
# Build a dict with the aliases card_detail_popup expects.
|
||||
var data := unit.duplicate()
|
||||
data["movementPoints"] = unit.get("maxMp", null)
|
||||
# Null-safe abilitiesJson → abilities alias (popup reads "abilities" key).
|
||||
var _raw_abil_udp = unit.get("abilitiesJson")
|
||||
data["abilities"] = "" if _raw_abil_udp == null else str(_raw_abil_udp)
|
||||
_card_detail_popup.show_card(data, data)
|
||||
var name_ : String = unit.get("name", "?")
|
||||
var type_ : String = unit.get("cardType", "")
|
||||
var aff : String = unit.get("affinity", "")
|
||||
_ctx_tile_lbl.text = "%s — %s [%s]" % [name_, type_, aff]
|
||||
_ctx_unit_lbl.text = "HP %d/%d DEF %d/%d ATK %d MP %d/%d" % [
|
||||
int(unit.get("currentHealth", 0)), int(unit.get("maxHealth", 0)),
|
||||
int(unit.get("currentDefense", 0)), int(unit.get("maxDefense", 0)),
|
||||
int(unit.get("damage", 0)),
|
||||
int(unit.get("currentMp", 0)), int(unit.get("maxMp", 0))]
|
||||
var abil_str := ""
|
||||
var _raw = unit.get("abilitiesJson")
|
||||
var parsed = JSON.parse_string("[]" if _raw == null else str(_raw))
|
||||
if parsed is Array:
|
||||
for ab: Dictionary in parsed:
|
||||
var ab_name := str(ab.get("name", ab.get("Name", "")))
|
||||
var ab_desc := str(ab.get("description", ab.get("Description", "")))
|
||||
abil_str += "• %s" % ab_name
|
||||
if not ab_desc.is_empty():
|
||||
abil_str += ": %s" % ab_desc
|
||||
abil_str += "\n"
|
||||
_ctx_abil_lbl.text = abil_str.strip_edges()
|
||||
_ctx_popup.visible = true
|
||||
|
||||
# ── Hand card ArchSpirit routing ──────────────────────────────────────────────
|
||||
|
||||
|
||||
Reference in New Issue
Block a user