Merge commit '56ab26d1d6253d2385c47fa914e692124512bf65'

This commit is contained in:
betalars 2023-07-16 01:13:13 +02:00
commit 47e4fe4a92
3 changed files with 36 additions and 10 deletions

View File

@ -27,6 +27,7 @@ var has_stage = false:
@onready var postit_container = $HBoxContainer/ScrollContainer/VBoxContainer
@onready var board_of_devs = $"board of devs"
@onready var base_postit_panel = $HBoxContainer/ScrollContainer/VBoxContainer/Panel
@onready var empty_text = $emptyText
@onready var active_context = ui_context.DROPZONE # 0 = dropzone, 1 = post it list
var currently_selected_node: Area2D = null
@ -66,6 +67,8 @@ func _process(delta):
# Will be used later to spawn Cards and Post-Its and remember them in the dictionary
func populate_board(card_names: Array):
empty_text.visible = false
var all_cards = Array()
var all_postits = Array()
@ -131,6 +134,7 @@ func _find_area_by_string(area_arr: Array, name: String) -> Area2D:
return area
return null
# Checks if a Node is currently inside the dropzone
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):
@ -190,7 +194,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
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.set_owner(self)
@ -272,7 +280,7 @@ func _input(event):
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
attach_postit_to_card(currently_selected_node,
currently_selected_card_for_assigning, true)
currently_selected_card_for_assigning, false)
_leave_assignment_context()
else:
_enter_assignment_context()
@ -310,6 +318,7 @@ func _input(event):
currently_selected_card_for_assigning.highlighted = false
currently_selected_card_for_assigning = area_dict["cards"][selected_card_for_assignment]
currently_selected_card_for_assigning.highlighted = true
_select_card_for_assigning(currently_selected_node, currently_selected_card_for_assigning)
# update dictiornary orders
reorder_areas("dropzone_content")
@ -330,9 +339,17 @@ func _enter_assignment_context():
# adjust everything for the post it to select its attach-target
active_context = ui_context.ASSIGN_POST_IT
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.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.tween_transform_to(card.get_child(3).global_position + Vector2(0, 50))
# leaves the context for assigning postit via button controls
func _leave_assignment_context():
currently_selected_node.highlighted = false
@ -340,16 +357,16 @@ func _leave_assignment_context():
currently_selected_node = currently_selected_card_for_assigning
# handles everything to return a post it to the panels
func _return_postit_to_panels(postit: Area2D):
func _return_postit_to_panels(post_it: Area2D):
for panel in area_dict["post_it_panels"]:
if panel.get_child_count() == 1:
postit.reparent(panel)
postit.set_owner(self)
area_dict["dropzone_content"].erase(postit)
area_dict["post_its_in_list"].push_back(postit)
postit.position = panel.get_child(0).position
postit.rotation = postit.base_rotation
postit.scale = postit.base_scale
area_dict["dropzone_content"].erase(post_it)
area_dict["post_its_in_list"].push_back(post_it)
post_it.tween_transform_to(panel.get_child(0).position)
post_it.rotation = post_it.base_rotation
post_it.scale = post_it.base_scale
post_it.reparent(panel)
post_it.set_owner(self)
reorder_areas("dropzone_content")
reorder_areas("post_its_in_list")
break

View File

@ -137,3 +137,9 @@ direction = Vector2(-100, 0)
position = Vector2(12, 13)
rotation = 1.5708
shape = SubResource("RectangleShape2D_ivo5o")
[node name="emptyText" type="Label" parent="."]
layout_mode = 2
text = "Bitte nicht wundern!"
horizontal_alignment = 1
vertical_alignment = 1

View File

@ -104,3 +104,6 @@ func is_postit_attached() -> bool:
return true
return false
func tween_transform_to(target: Vector2):
var transform_tween = create_tween()
transform_tween.tween_property(self, "position", target, 0.25)