updates for cleaning functionality

This commit is contained in:
2026-01-24 19:15:04 -05:00
parent ea2028cf13
commit b1e99fa952
12 changed files with 700 additions and 22 deletions

View File

@@ -7,6 +7,7 @@ var table_setup: TableSetup
var game_ui: GameUI
var hand_display: HandDisplay
var hand_layer: CanvasLayer
var action_log: ActionLog
# Player damage displays
var damage_displays: Array[DamageDisplay] = []
@@ -35,6 +36,29 @@ func _setup_ui() -> void:
game_ui.layer = 10 # Base UI layer
add_child(game_ui)
# Action log (collapsible panel on right side)
var log_layer = CanvasLayer.new()
log_layer.layer = 12 # Above other UI
add_child(log_layer)
action_log = ActionLog.new()
log_layer.add_child(action_log)
# Position on right side of screen
action_log.set_anchors_preset(Control.PRESET_CENTER_RIGHT)
action_log.offset_left = -290
action_log.offset_right = -10
action_log.offset_top = -200
action_log.offset_bottom = 200
# Connect undo signal
action_log.undo_requested.connect(_on_undo_requested)
# Connect to GameManager undo signals
GameManager.undo_available_changed.connect(_on_undo_available_changed)
# Ensure ActionLog connects to GameManager after it's in the tree
action_log.call_deferred("_connect_game_manager_signals")
# Hand display needs its own CanvasLayer to render on top of 3D
hand_layer = CanvasLayer.new()
hand_layer.layer = 11 # Above the game UI
@@ -71,6 +95,18 @@ func _position_hand_display() -> void:
hand_display.position = Vector2(50, vp_size.y - 180)
hand_display.size = Vector2(vp_size.x - 100, 170)
# 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)
func _connect_signals() -> void:
# GameManager signals
GameManager.game_started.connect(_on_game_started)
@@ -157,12 +193,10 @@ func _update_playable_highlights() -> void:
hand_display.clear_highlights()
func _on_hand_card_selected(card: CardInstance) -> void:
print("Main: Card selected: ", card.card_data.name, " input_mode=", GameManager.input_mode)
var input_mode = GameManager.input_mode
match input_mode:
GameManager.InputMode.SELECT_CARD_TO_PLAY:
print("Main: Trying to play card")
GameManager.try_play_card(card)
_sync_visuals()
_update_hand_display()
@@ -170,12 +204,9 @@ func _on_hand_card_selected(card: CardInstance) -> void:
GameManager.InputMode.SELECT_CP_SOURCE:
# Discard for CP
print("Main: Discarding for CP")
GameManager.discard_card_for_cp(card)
_update_hand_display()
_update_cp_display()
_:
print("Main: Input mode not handled: ", input_mode)
func _on_hand_card_hovered(card: CardInstance) -> void:
game_ui.show_card_detail(card)
@@ -183,6 +214,19 @@ func _on_hand_card_hovered(card: CardInstance) -> void:
func _on_hand_card_unhovered() -> void:
game_ui.hide_card_detail()
func _on_undo_requested() -> void:
if GameManager.undo_last_action():
_sync_visuals()
_update_hand_display()
_update_cp_display()
_update_playable_highlights()
# Restore input mode based on current phase
GameManager.restore_input_mode_for_phase()
func _on_undo_available_changed(available: bool) -> void:
if action_log:
action_log.set_undo_available(available)
func _on_table_card_clicked(card: CardInstance, zone_type: Enums.ZoneType, player_index: int) -> void:
var input_mode = GameManager.input_mode
@@ -216,6 +260,17 @@ func _on_table_card_clicked(card: CardInstance, zone_type: Enums.ZoneType, playe
func _input(event: InputEvent) -> void:
# Keyboard shortcuts
if event is InputEventKey and event.pressed:
# Ctrl+Z for undo
if event.keycode == KEY_Z and event.ctrl_pressed:
_on_undo_requested()
return
# L key to toggle action log
if event.keycode == KEY_L and not event.ctrl_pressed:
if action_log:
action_log.toggle_panel()
return
match event.keycode:
KEY_SPACE:
# Pass priority / end phase