post its now float beneath the card they are going to be attached to
This commit is contained in:
parent
042fedd6a8
commit
d93858c122
|
|
@ -131,6 +131,7 @@ func _find_area_by_string(area_arr: Array, name: String) -> Area2D:
|
||||||
return area
|
return area
|
||||||
return null
|
return null
|
||||||
|
|
||||||
|
|
||||||
# Checks if a Node is currently inside the dropzone
|
# Checks if a Node is currently inside the dropzone
|
||||||
func is_in_dropzone(to_check: Node) -> bool:
|
func is_in_dropzone(to_check: Node) -> bool:
|
||||||
if (dropzone.size.x < to_check.global_position.x or dropzone.size.y < to_check.global_position.y):
|
if (dropzone.size.x < to_check.global_position.x or dropzone.size.y < to_check.global_position.y):
|
||||||
|
|
@ -190,7 +191,11 @@ 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
|
# 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):
|
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
|
|
||||||
|
if card.has_postit_attached():
|
||||||
|
if active_context == ui_context.ASSIGN_POST_IT:
|
||||||
|
_return_postit_to_panels(postit) # don't attach if card has already a post-it attached
|
||||||
|
return
|
||||||
|
|
||||||
postit.reparent(card)
|
postit.reparent(card)
|
||||||
postit.set_owner(self)
|
postit.set_owner(self)
|
||||||
|
|
@ -272,7 +277,7 @@ func _input(event):
|
||||||
elif event.is_action_pressed("ui_accept"): # select the selected post it
|
elif event.is_action_pressed("ui_accept"): # select the selected post it
|
||||||
if active_context == ui_context.ASSIGN_POST_IT: # to assign it to a card
|
if active_context == ui_context.ASSIGN_POST_IT: # to assign it to a card
|
||||||
attach_postit_to_card(currently_selected_node,
|
attach_postit_to_card(currently_selected_node,
|
||||||
currently_selected_card_for_assigning, true)
|
currently_selected_card_for_assigning, false)
|
||||||
_leave_assignment_context()
|
_leave_assignment_context()
|
||||||
else:
|
else:
|
||||||
_enter_assignment_context()
|
_enter_assignment_context()
|
||||||
|
|
@ -310,6 +315,7 @@ func _input(event):
|
||||||
currently_selected_card_for_assigning.highlighted = false
|
currently_selected_card_for_assigning.highlighted = false
|
||||||
currently_selected_card_for_assigning = area_dict["cards"][selected_card_for_assignment]
|
currently_selected_card_for_assigning = area_dict["cards"][selected_card_for_assignment]
|
||||||
currently_selected_card_for_assigning.highlighted = true
|
currently_selected_card_for_assigning.highlighted = true
|
||||||
|
_select_card_for_assigning(currently_selected_node, currently_selected_card_for_assigning)
|
||||||
|
|
||||||
# update dictiornary orders
|
# update dictiornary orders
|
||||||
reorder_areas("dropzone_content")
|
reorder_areas("dropzone_content")
|
||||||
|
|
@ -330,9 +336,17 @@ func _enter_assignment_context():
|
||||||
# adjust everything for the post it to select its attach-target
|
# adjust everything for the post it to select its attach-target
|
||||||
active_context = ui_context.ASSIGN_POST_IT
|
active_context = ui_context.ASSIGN_POST_IT
|
||||||
selected_card_for_assignment = 0
|
selected_card_for_assignment = 0
|
||||||
|
currently_selected_node.reparent(dropzone) # reparent to make it visible
|
||||||
|
currently_selected_node.set_owner(self)
|
||||||
|
area_dict["post_its_in_list"].erase(currently_selected_node)
|
||||||
|
area_dict["dropzone_content"].push_back(currently_selected_node)
|
||||||
currently_selected_card_for_assigning = area_dict["dropzone_content"][0]
|
currently_selected_card_for_assigning = area_dict["dropzone_content"][0]
|
||||||
currently_selected_card_for_assigning.highlighted = true
|
currently_selected_card_for_assigning.highlighted = true
|
||||||
|
|
||||||
|
# move the post it so it floats next to the card where it should be attached
|
||||||
|
func _select_card_for_assigning(post_it: Area2D, card: Area2D):
|
||||||
|
post_it.global_position = card.get_child(3).global_position + Vector2(0, 50)
|
||||||
|
|
||||||
# leaves the context for assigning postit via button controls
|
# leaves the context for assigning postit via button controls
|
||||||
func _leave_assignment_context():
|
func _leave_assignment_context():
|
||||||
currently_selected_node.highlighted = false
|
currently_selected_node.highlighted = false
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue