working updates
This commit is contained in:
@@ -78,9 +78,10 @@ func _setup_ui() -> void:
|
||||
# We'll update position in _process or use a deferred call after container is sized
|
||||
call_deferred("_position_hand_display")
|
||||
|
||||
hand_display.card_selected.connect(_on_hand_card_selected)
|
||||
hand_display.card_action_requested.connect(_on_hand_card_action)
|
||||
hand_display.card_hovered.connect(_on_hand_card_hovered)
|
||||
hand_display.card_unhovered.connect(_on_hand_card_unhovered)
|
||||
hand_display.card_selected.connect(_on_hand_card_selected)
|
||||
|
||||
# Create damage displays (positioned by 3D camera overlay later)
|
||||
for i in range(2):
|
||||
@@ -92,20 +93,27 @@ func _position_hand_display() -> void:
|
||||
var viewport = get_viewport()
|
||||
if viewport:
|
||||
var vp_size = viewport.get_visible_rect().size
|
||||
hand_display.position = Vector2(50, vp_size.y - 180)
|
||||
hand_display.size = Vector2(vp_size.x - 100, 170)
|
||||
# Hand cards are 195x273px (triple original), positioned at y=0 in container
|
||||
var card_height = 273.0
|
||||
var hand_height = card_height + 25.0 # Extra space for hover lift
|
||||
|
||||
# Position so card bottom is 100px above viewport bottom
|
||||
var bottom_offset = 100.0
|
||||
hand_display.position = Vector2(10, vp_size.y - bottom_offset - card_height)
|
||||
hand_display.size = Vector2(vp_size.x - 20, hand_height)
|
||||
|
||||
# Connect to viewport size changed signal if not already connected
|
||||
if not viewport.size_changed.is_connected(_on_viewport_resized):
|
||||
viewport.size_changed.connect(_on_viewport_resized)
|
||||
|
||||
func _on_viewport_resized() -> void:
|
||||
# Reposition hand display when window resizes
|
||||
var viewport = get_viewport()
|
||||
if viewport and hand_display:
|
||||
var vp_size = viewport.get_visible_rect().size
|
||||
hand_display.position = Vector2(50, vp_size.y - 180)
|
||||
hand_display.size = Vector2(vp_size.x - 100, 170)
|
||||
var card_height = 273.0 # Triple size hand cards
|
||||
var hand_height = card_height + 25.0
|
||||
var bottom_offset = 100.0
|
||||
hand_display.position = Vector2(10, vp_size.y - bottom_offset - card_height)
|
||||
hand_display.size = Vector2(vp_size.x - 20, hand_height)
|
||||
|
||||
func _connect_signals() -> void:
|
||||
# GameManager signals
|
||||
@@ -192,28 +200,38 @@ func _update_playable_highlights() -> void:
|
||||
_:
|
||||
hand_display.clear_highlights()
|
||||
|
||||
func _on_hand_card_selected(card: CardInstance) -> void:
|
||||
var input_mode = GameManager.input_mode
|
||||
|
||||
match input_mode:
|
||||
GameManager.InputMode.SELECT_CARD_TO_PLAY:
|
||||
func _on_hand_card_action(card: CardInstance, action: String) -> void:
|
||||
match action:
|
||||
"play":
|
||||
# Try to play the card
|
||||
GameManager.try_play_card(card)
|
||||
_sync_visuals()
|
||||
_update_hand_display()
|
||||
_update_cp_display()
|
||||
|
||||
GameManager.InputMode.SELECT_CP_SOURCE:
|
||||
"discard_cp":
|
||||
# Discard for CP
|
||||
GameManager.discard_card_for_cp(card)
|
||||
_sync_visuals()
|
||||
_update_hand_display()
|
||||
_update_cp_display()
|
||||
|
||||
func _on_hand_card_hovered(card: CardInstance) -> void:
|
||||
game_ui.show_card_detail(card)
|
||||
"view":
|
||||
# Show detailed card view
|
||||
game_ui.show_card_detail(card)
|
||||
|
||||
func _on_hand_card_hovered(_card: CardInstance) -> void:
|
||||
# Hand cards use the selection panel for detail view, not the GameUI hover preview
|
||||
# So we intentionally do nothing here - no hover preview for hand cards
|
||||
pass
|
||||
|
||||
func _on_hand_card_unhovered() -> void:
|
||||
game_ui.hide_card_detail()
|
||||
|
||||
func _on_hand_card_selected(_card: CardInstance) -> void:
|
||||
# Selection panel is now visible - ensure any stale hover preview is hidden
|
||||
game_ui.hide_card_detail()
|
||||
|
||||
func _on_undo_requested() -> void:
|
||||
if GameManager.undo_last_action():
|
||||
_sync_visuals()
|
||||
|
||||
Reference in New Issue
Block a user