fix: avoid putting post-its on post-its + prevent putting post-its on card with post-its already attached
This commit is contained in:
parent
45b1fe3f14
commit
042fedd6a8
|
|
@ -2,6 +2,7 @@ extends PanelContainer
|
|||
|
||||
var area_dict = {
|
||||
"dropzone_content": [],
|
||||
"cards": [],
|
||||
"post_its_in_list": [],
|
||||
"post_it_panels": []
|
||||
}
|
||||
|
|
@ -102,6 +103,7 @@ func populate_board(card_names: Array):
|
|||
dropzone.add_child(new_card)
|
||||
new_card.set_owner(self)
|
||||
area_dict["dropzone_content"].push_back(new_card)
|
||||
area_dict["cards"].push_back(new_card)
|
||||
#new_card.position = Vector2(randf_range(new_card.diameter, dropzone.size.x), randf_range(new_card.diameter, dropzone.size.y)) - Vector2(new_card.diameter/2, new_card.diameter/2)
|
||||
new_card.is_dragable = true
|
||||
if "p_" in card_name: # spawning a post-it
|
||||
|
|
@ -118,6 +120,7 @@ func populate_board(card_names: Array):
|
|||
currently_selected_node = area_dict["dropzone_content"][0] # set first Card as currently selected node by default
|
||||
|
||||
reorder_areas("dropzone_content")
|
||||
reorder_areas("cards")
|
||||
reorder_areas("post_its_in_list")
|
||||
|
||||
|
||||
|
|
@ -158,6 +161,7 @@ func handle_mouse_button(to_handle: Area2D, input: InputEvent):
|
|||
active_context = ui_context.DROPZONE
|
||||
if input.is_pressed():
|
||||
reorder_areas("dropzone_content")
|
||||
reorder_areas("cards")
|
||||
else:
|
||||
dropzone.move_child(currently_dragged_area, -1)
|
||||
currently_dragged_area = null
|
||||
|
|
@ -186,6 +190,8 @@ func handle_mouse_button(to_handle: Area2D, input: InputEvent):
|
|||
|
||||
# Logic for attaching a postit to a card. Also reset postit positions if the card cannot be attached
|
||||
func attach_postit_to_card(postit: Area2D, card: Area2D, update_dict = false):
|
||||
if card.has_postit_attached(): return # don't attach if card has already a post-it attached
|
||||
|
||||
postit.reparent(card)
|
||||
postit.set_owner(self)
|
||||
postit.position = card.get_child(3).position
|
||||
|
|
@ -195,6 +201,7 @@ func attach_postit_to_card(postit: Area2D, card: Area2D, update_dict = false):
|
|||
area_dict["dropzone_content"].push_back(postit)
|
||||
|
||||
reorder_areas("dropzone_content")
|
||||
reorder_areas("cards")
|
||||
reorder_areas("post_its_in_list")
|
||||
|
||||
|
||||
|
|
@ -285,8 +292,8 @@ func _input(event):
|
|||
|
||||
if active_context == ui_context.ASSIGN_POST_IT: # skip this if we're not in assign post it context
|
||||
if selected_card_for_assignment < 0:
|
||||
selected_card_for_assignment = area_dict["dropzone_content"].size()-1
|
||||
elif selected_card_for_assignment > area_dict["dropzone_content"].size()-1:
|
||||
selected_card_for_assignment = area_dict["cards"].size()-1
|
||||
elif selected_card_for_assignment > area_dict["cards"].size()-1:
|
||||
selected_card_for_assignment = 0
|
||||
|
||||
# highlight the selected element
|
||||
|
|
@ -301,7 +308,7 @@ func _input(event):
|
|||
currently_selected_node.highlighted = true
|
||||
ui_context.ASSIGN_POST_IT:
|
||||
currently_selected_card_for_assigning.highlighted = false
|
||||
currently_selected_card_for_assigning = area_dict["dropzone_content"][selected_card_for_assignment]
|
||||
currently_selected_card_for_assigning = area_dict["cards"][selected_card_for_assignment]
|
||||
currently_selected_card_for_assigning.highlighted = true
|
||||
|
||||
# update dictiornary orders
|
||||
|
|
|
|||
Loading…
Reference in New Issue