feat(hand): draw card popup — show drawn card centre-screen, click to add
- New Settings.draw_card_popup bool (default true, persisted) - Toggle in InGameSettings under Gameplay: "Show drawn card popup" - _rebuild_hand detects brand-new cards and queues them in _pending_popup_cards instead of adding to hand immediately - _show_next_card_popup builds a CanvasLayer overlay (layer 20) with a dimmed background + full-size card widget; click card or background to dismiss - _dismiss_card_popup pops the queue, adds the card to hand via _apply_display_hand in server order, then shows the next queued popup 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,6 +64,14 @@ var click_to_focus_camera : bool = false :
|
||||
_save()
|
||||
settings_changed.emit()
|
||||
|
||||
## When true, newly drawn cards pop up in the centre of the screen and must be
|
||||
## clicked before they slide into the hand.
|
||||
var draw_card_popup : bool = true :
|
||||
set(v):
|
||||
draw_card_popup = 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.
|
||||
@@ -157,6 +165,7 @@ func _load() -> void:
|
||||
sfx_muted = bool(cfg.get_value(SECTION, "sfx_muted", false))
|
||||
camera_follow_unit = bool(cfg.get_value(SECTION_GAMEPLAY, "camera_follow_unit", true))
|
||||
click_to_focus_camera = bool(cfg.get_value(SECTION_GAMEPLAY, "click_to_focus_camera", false))
|
||||
draw_card_popup = bool(cfg.get_value(SECTION_GAMEPLAY, "draw_card_popup", true))
|
||||
touch_camera_mode = str(cfg.get_value(SECTION_CAMERA, "touch_camera_mode", "gesture"))
|
||||
skybox_mode = str(cfg.get_value(SECTION_VISUAL, "skybox_mode", "live"))
|
||||
var raw_overrides = cfg.get_value(SECTION_HIGHLIGHTS, "highlight_overrides", {})
|
||||
@@ -172,6 +181,7 @@ func _save() -> void:
|
||||
cfg.set_value(SECTION, "sfx_muted", sfx_muted)
|
||||
cfg.set_value(SECTION_GAMEPLAY, "camera_follow_unit", camera_follow_unit)
|
||||
cfg.set_value(SECTION_GAMEPLAY, "click_to_focus_camera", click_to_focus_camera)
|
||||
cfg.set_value(SECTION_GAMEPLAY, "draw_card_popup", draw_card_popup)
|
||||
cfg.set_value(SECTION_CAMERA, "touch_camera_mode", touch_camera_mode)
|
||||
cfg.set_value(SECTION_VISUAL, "skybox_mode", skybox_mode)
|
||||
cfg.set_value(SECTION_HIGHLIGHTS, "highlight_overrides", highlight_overrides)
|
||||
|
||||
@@ -113,6 +113,11 @@ unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Focus camera when clicking a tile"
|
||||
|
||||
[node name="DrawCardPopup" type="CheckButton" parent="MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Show drawn card popup"
|
||||
|
||||
[node name="HSeparatorCam" type="HSeparator" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
|
||||
@@ -83,6 +83,8 @@ var _is_spectating : bool = false
|
||||
var _hand_focus_index : int = 0
|
||||
var _hand_hover_iid : String = ""
|
||||
var _cached_hand_iids : Array[String] = []
|
||||
var _pending_popup_cards : Array[Dictionary] = []
|
||||
var _popup_layer : CanvasLayer = null
|
||||
# ── Affinity colors ───────────────────────────────────────────────────────────
|
||||
|
||||
const AFFINITY_COLORS : Dictionary = {
|
||||
@@ -4450,8 +4452,46 @@ func _rebuild_hand(hand: Array) -> void:
|
||||
if new_iids == _cached_hand_iids:
|
||||
_refresh_hand_selection()
|
||||
return
|
||||
|
||||
# Detect brand-new cards (not in previous server hand, not already queued).
|
||||
var pending_iids : Array[String] = []
|
||||
for c: Dictionary in _pending_popup_cards:
|
||||
pending_iids.append(c.get("instanceId", "") as String)
|
||||
|
||||
var brand_new : Array[Dictionary] = []
|
||||
if Settings.draw_card_popup:
|
||||
for card: Dictionary in hand:
|
||||
var iid : String = card.get("instanceId", "")
|
||||
if iid not in _cached_hand_iids and iid not in pending_iids:
|
||||
brand_new.append(card)
|
||||
|
||||
_cached_hand_iids = new_iids
|
||||
|
||||
# Drop pending popups for cards that left the hand.
|
||||
_pending_popup_cards = _pending_popup_cards.filter(
|
||||
func(c: Dictionary) -> bool: return c.get("instanceId", "") in new_iids)
|
||||
|
||||
# Queue brand-new cards for popup; exclude them from the live hand display.
|
||||
for card: Dictionary in brand_new:
|
||||
_pending_popup_cards.append(card)
|
||||
|
||||
var popup_iids : Array[String] = []
|
||||
for c: Dictionary in _pending_popup_cards:
|
||||
popup_iids.append(c.get("instanceId", "") as String)
|
||||
|
||||
# Build the display hand (everything except cards waiting in popup queue).
|
||||
var display_hand : Array = hand.filter(
|
||||
func(c: Variant) -> bool:
|
||||
return (c as Dictionary).get("instanceId", "") not in popup_iids)
|
||||
|
||||
_apply_display_hand(display_hand)
|
||||
|
||||
# Kick off popup for the first pending card if nothing is showing yet.
|
||||
if not _pending_popup_cards.is_empty() and (_popup_layer == null or not _popup_layer.visible):
|
||||
_show_next_card_popup()
|
||||
|
||||
|
||||
func _apply_display_hand(hand: Array) -> void:
|
||||
if hand.is_empty():
|
||||
for c in _hand_cards.get_children():
|
||||
_hand_cards.remove_child(c)
|
||||
@@ -4467,17 +4507,19 @@ func _rebuild_hand(hand: Array) -> void:
|
||||
if child.has_meta("card_instance_id"):
|
||||
existing[str(child.get_meta("card_instance_id"))] = child
|
||||
|
||||
# Remove widgets for cards that left the hand.
|
||||
# Use remove_child + queue_free so the node leaves the GUI tree immediately;
|
||||
# queue_free alone keeps it in get_children() until end-of-frame.
|
||||
var hand_iids : Array[String] = []
|
||||
for card: Dictionary in hand:
|
||||
hand_iids.append(card.get("instanceId", "") as String)
|
||||
|
||||
# Remove widgets for cards no longer in the display hand.
|
||||
for iid: String in existing.keys():
|
||||
if iid not in new_iids:
|
||||
if iid not in hand_iids:
|
||||
var w : Node = existing[iid]
|
||||
existing.erase(iid)
|
||||
_hand_cards.remove_child(w)
|
||||
w.queue_free()
|
||||
|
||||
# Add widgets for cards newly in the hand, update _fan_slot on all.
|
||||
# Add widgets for new cards, update _fan_slot on all.
|
||||
var slot := 0
|
||||
for card: Dictionary in hand:
|
||||
var iid : String = card.get("instanceId", "")
|
||||
@@ -4494,6 +4536,99 @@ func _rebuild_hand(hand: Array) -> void:
|
||||
_sync_hand_spin_buttons()
|
||||
|
||||
|
||||
func _show_next_card_popup() -> void:
|
||||
if _pending_popup_cards.is_empty():
|
||||
return
|
||||
var card : Dictionary = _pending_popup_cards[0]
|
||||
|
||||
# Create (or reuse) a dedicated CanvasLayer above the HUD.
|
||||
if _popup_layer == null or not is_instance_valid(_popup_layer):
|
||||
_popup_layer = CanvasLayer.new()
|
||||
_popup_layer.layer = 20
|
||||
add_child(_popup_layer)
|
||||
|
||||
# Clear any previous content.
|
||||
for c in _popup_layer.get_children():
|
||||
c.queue_free()
|
||||
_popup_layer.visible = true
|
||||
|
||||
# Dim background — catches clicks that miss the card.
|
||||
var bg := ColorRect.new()
|
||||
bg.color = Color(0.0, 0.0, 0.0, 0.65)
|
||||
bg.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
bg.mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
_popup_layer.add_child(bg)
|
||||
|
||||
# Centred column: label + card.
|
||||
var vbox := VBoxContainer.new()
|
||||
vbox.set_anchors_preset(Control.PRESET_CENTER)
|
||||
vbox.grow_horizontal = Control.GROW_DIRECTION_BOTH
|
||||
vbox.grow_vertical = Control.GROW_DIRECTION_BOTH
|
||||
vbox.theme_override_constants["separation"] = 16
|
||||
vbox.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
_popup_layer.add_child(vbox)
|
||||
|
||||
var lbl := Label.new()
|
||||
lbl.text = "Card Drawn — click to add to hand"
|
||||
lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
lbl.theme_override_font_sizes["font_size"] = 16
|
||||
vbox.add_child(lbl)
|
||||
|
||||
var widget : PanelContainer = _CARD_WIDGET_SCENE.instantiate()
|
||||
widget.custom_minimum_size = Vector2(200, 320)
|
||||
widget.mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
var def_id : String = str(card.get("cardDefinitionId", ""))
|
||||
var def : Dictionary = ContentCache.get_definition(def_id)
|
||||
if def.is_empty():
|
||||
def = card.duplicate()
|
||||
def["movementPoints"] = card.get("maxMp", def.get("movementPoints", null))
|
||||
widget.setup(card, def)
|
||||
vbox.add_child(widget)
|
||||
|
||||
# Either clicking the card or the background dismisses the popup.
|
||||
bg.gui_input.connect(func(ev: InputEvent) -> void:
|
||||
if ev is InputEventMouseButton and (ev as InputEventMouseButton).pressed:
|
||||
_dismiss_card_popup())
|
||||
widget.card_pressed.connect(func(_id: String) -> void: _dismiss_card_popup())
|
||||
|
||||
|
||||
func _dismiss_card_popup() -> void:
|
||||
if _pending_popup_cards.is_empty():
|
||||
return
|
||||
var card : Dictionary = _pending_popup_cards.pop_front()
|
||||
|
||||
# Hide the overlay.
|
||||
if is_instance_valid(_popup_layer):
|
||||
_popup_layer.visible = false
|
||||
|
||||
# Build the updated display hand: currently shown widgets + this newly added card.
|
||||
var display_iids : Array[String] = []
|
||||
for child in _hand_cards.get_children():
|
||||
if child.has_meta("card_instance_id"):
|
||||
display_iids.append(str(child.get_meta("card_instance_id")))
|
||||
display_iids.append(card.get("instanceId", "") as String)
|
||||
|
||||
# Reconstruct display hand in server order (from _cached_hand_iids).
|
||||
var display_hand : Array = []
|
||||
for iid: String in _cached_hand_iids:
|
||||
if iid in display_iids:
|
||||
# Find the card dict; use the drawn card if it matches.
|
||||
if iid == card.get("instanceId", ""):
|
||||
display_hand.append(card)
|
||||
else:
|
||||
# Pull from live Game hand for existing cards.
|
||||
for hc: Dictionary in Game.get_hand():
|
||||
if hc.get("instanceId", "") == iid:
|
||||
display_hand.append(hc)
|
||||
break
|
||||
|
||||
_apply_display_hand(display_hand)
|
||||
|
||||
# Show next queued popup if any.
|
||||
if not _pending_popup_cards.is_empty():
|
||||
_show_next_card_popup()
|
||||
|
||||
|
||||
func _make_hand_card(card: Dictionary) -> Control:
|
||||
var iid : String = card.get("instanceId", "")
|
||||
var def_id : String = str(card.get("cardDefinitionId", ""))
|
||||
|
||||
@@ -8,6 +8,7 @@ extends PanelContainer
|
||||
@onready var _sfx_mute : CheckButton = %SfxMute
|
||||
@onready var _cam_follow : CheckButton = %CameraFollowUnit
|
||||
@onready var _tile_focus_cam : CheckButton = %TileFocusCamera
|
||||
@onready var _draw_popup : CheckButton = %DrawCardPopup
|
||||
@onready var _skybox_opt : OptionButton = %SkyboxModeOption
|
||||
@onready var _touch_cam_mode_opt : OptionButton = %TouchCamModeOption
|
||||
@onready var _sync_btn : Button = %SyncBtn
|
||||
@@ -29,6 +30,7 @@ func _ready() -> void:
|
||||
_sfx_mute.toggled.connect(_on_sfx_mute_toggled)
|
||||
_cam_follow.toggled.connect(func(v: bool) -> void: Settings.camera_follow_unit = v)
|
||||
_tile_focus_cam.toggled.connect(func(v: bool) -> void: Settings.click_to_focus_camera = v)
|
||||
_draw_popup.toggled.connect(func(v: bool) -> void: Settings.draw_card_popup = v)
|
||||
_skybox_opt.item_selected.connect(_on_skybox_mode_changed)
|
||||
_touch_cam_mode_opt.item_selected.connect(func(idx: int) -> void:
|
||||
Settings.touch_camera_mode = (["gesture", "buttons"] as Array)[idx])
|
||||
@@ -61,6 +63,7 @@ func _sync_from_settings() -> void:
|
||||
_sfx_mute.set_pressed_no_signal(Settings.sfx_muted)
|
||||
_cam_follow.set_pressed_no_signal(Settings.camera_follow_unit)
|
||||
_tile_focus_cam.set_pressed_no_signal(Settings.click_to_focus_camera)
|
||||
_draw_popup.set_pressed_no_signal(Settings.draw_card_popup)
|
||||
_skybox_opt.selected = ["live", "cdn", "off"].find(Settings.skybox_mode)
|
||||
_touch_cam_mode_opt.selected = ["gesture", "buttons"].find(Settings.touch_camera_mode)
|
||||
_music_slider.modulate.a = 0.4 if Settings.music_muted else 1.0
|
||||
|
||||
Reference in New Issue
Block a user