fixed conditions where invalid state could be reached in card board

This commit is contained in:
betalars 2024-02-11 22:36:19 +01:00
parent 184fb82151
commit 2cddc8284c
2 changed files with 12 additions and 10 deletions

View File

@ -46,13 +46,13 @@ var base_sticky_note_panel: Panel
set(context): set(context):
if current_context == ASSIGN and !context == ASSIGN: if current_context == ASSIGN and !context == ASSIGN:
sticky_note_container.get_child(current_sticky_note_id).clear_if_empty() sticky_note_container.get_child(current_sticky_note_id).clear_if_empty()
match context: #match context:
NAVIGATE: # NAVIGATE:
_return_sticky_notes_to_panels() # _return_sticky_notes_to_panels()
DRAG: # DRAG:
pass # pass
ASSIGN: # ASSIGN:
pass # pass
current_context = context current_context = context
@onready var instructions = $instructions_panel/HBoxContainer/cards_remaining @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 to_handle is StickyNote:
if not to_handle.on_board: if not to_handle.on_board:
to_handle.reparent(dropzone) to_handle.reparent(dropzone)
to_handle.on_board = true
to_handle.owner = self to_handle.owner = self
current_context = DRAG current_context = DRAG
@ -187,6 +188,7 @@ func handle_mouse_button(to_handle: Area2D, input: InputEvent):
if area.has_sticky_note_attached(): if area.has_sticky_note_attached():
to_handle = area.exchange_sticky_note_with(to_handle) to_handle = area.exchange_sticky_note_with(to_handle)
to_handle.reparent(dropzone) to_handle.reparent(dropzone)
to_handle.on_board = true
sticky_note_container.get_child(current_sticky_note_id).attached_sticky_note = to_handle 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.attached_to = sticky_note_container.get_child(current_sticky_note_id)
to_handle.reset_drag() to_handle.reset_drag()
@ -235,6 +237,7 @@ func is_board_lore() -> bool:
# Mark area that was hovered over as currently selected # Mark area that was hovered over as currently selected
func handle_hover(to_handle: Area2D): func handle_hover(to_handle: Area2D):
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT): return
currently_active_node = to_handle currently_active_node = to_handle
if is_in_dropzone(to_handle) or to_handle is Card: 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(): if not node in parent.get_children():
node.reparent(parent) node.reparent(parent)
if node is StickyNote:
node.on_board = true
node.owner = self node.owner = self
if children.size() > 0: if children.size() > 0:

View File

@ -27,9 +27,6 @@ func attatch_sticky_note(attatchment: StickyNote, tween:bool = true):
attatchment.transform = ancor.transform attatchment.transform = ancor.transform
func reclaim_sticky_note(): func reclaim_sticky_note():
print("meep")
var is_emoty = is_empty()
print("meep")
if is_empty() and attached_sticky_note.on_board == true: if is_empty() and attached_sticky_note.on_board == true:
attached_sticky_note.on_board = false attached_sticky_note.on_board = false
attached_sticky_note.tween_transform_to(ancor.global_transform) attached_sticky_note.tween_transform_to(ancor.global_transform)