From 2cddc8284cb0cc053f79fa02f64875c486e72013 Mon Sep 17 00:00:00 2001 From: betalars Date: Sun, 11 Feb 2024 22:36:19 +0100 Subject: [PATCH] fixed conditions where invalid state could be reached in card board --- src/logic-scenes/board/card-board.gd | 19 ++++++++++++------- .../board/empty_sticky_note_panel.gd | 3 --- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/logic-scenes/board/card-board.gd b/src/logic-scenes/board/card-board.gd index 8e6f0e1..3cf5c30 100644 --- a/src/logic-scenes/board/card-board.gd +++ b/src/logic-scenes/board/card-board.gd @@ -46,13 +46,13 @@ var base_sticky_note_panel: Panel set(context): if current_context == ASSIGN and !context == ASSIGN: sticky_note_container.get_child(current_sticky_note_id).clear_if_empty() - match context: - NAVIGATE: - _return_sticky_notes_to_panels() - DRAG: - pass - ASSIGN: - pass + #match context: + # NAVIGATE: + # _return_sticky_notes_to_panels() + # DRAG: + # pass + # ASSIGN: + # pass current_context = context @onready var instructions = $instructions_panel/HBoxContainer/cards_remaining @@ -172,6 +172,7 @@ func handle_mouse_button(to_handle: Area2D, input: InputEvent): if to_handle is StickyNote: if not to_handle.on_board: to_handle.reparent(dropzone) + to_handle.on_board = true to_handle.owner = self current_context = DRAG @@ -187,6 +188,7 @@ func handle_mouse_button(to_handle: Area2D, input: InputEvent): if area.has_sticky_note_attached(): to_handle = area.exchange_sticky_note_with(to_handle) to_handle.reparent(dropzone) + to_handle.on_board = true sticky_note_container.get_child(current_sticky_note_id).attached_sticky_note = to_handle to_handle.attached_to = sticky_note_container.get_child(current_sticky_note_id) to_handle.reset_drag() @@ -235,6 +237,7 @@ func is_board_lore() -> bool: # Mark area that was hovered over as currently selected func handle_hover(to_handle: Area2D): + if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT): return currently_active_node = to_handle if is_in_dropzone(to_handle) or to_handle is Card: @@ -252,6 +255,8 @@ func insert_area(parent: Control, node: Area2D): if not node in parent.get_children(): node.reparent(parent) + if node is StickyNote: + node.on_board = true node.owner = self if children.size() > 0: diff --git a/src/logic-scenes/board/empty_sticky_note_panel.gd b/src/logic-scenes/board/empty_sticky_note_panel.gd index 78b5be8..3563508 100644 --- a/src/logic-scenes/board/empty_sticky_note_panel.gd +++ b/src/logic-scenes/board/empty_sticky_note_panel.gd @@ -27,9 +27,6 @@ func attatch_sticky_note(attatchment: StickyNote, tween:bool = true): attatchment.transform = ancor.transform func reclaim_sticky_note(): - print("meep") - var is_emoty = is_empty() - print("meep") if is_empty() and attached_sticky_note.on_board == true: attached_sticky_note.on_board = false attached_sticky_note.tween_transform_to(ancor.global_transform)