From adee13944998daf9bef3b6b668092d065eb09145 Mon Sep 17 00:00:00 2001 From: Adrian Schmid Date: Sat, 15 Jul 2023 15:26:14 +0200 Subject: [PATCH 1/3] post its now float beneath the card they are going to be attached to --- src/logic-scenes/board/card-board.gd | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/logic-scenes/board/card-board.gd b/src/logic-scenes/board/card-board.gd index 36257f64..7bd6f8af 100644 --- a/src/logic-scenes/board/card-board.gd +++ b/src/logic-scenes/board/card-board.gd @@ -131,6 +131,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 +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 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 +277,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 +315,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 +336,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.global_position = 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 From ccad0811a8418da96ce51e82d203cc447399b0d5 Mon Sep 17 00:00:00 2001 From: Adrian Schmid Date: Sat, 15 Jul 2023 15:59:22 +0200 Subject: [PATCH 2/3] added quick tween to post its which are attached to cards or returned to the panels --- src/logic-scenes/board/card-board.gd | 18 +++++++++--------- src/logic-scenes/board/post-it.gd | 3 +++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/logic-scenes/board/card-board.gd b/src/logic-scenes/board/card-board.gd index 7bd6f8af..78662431 100644 --- a/src/logic-scenes/board/card-board.gd +++ b/src/logic-scenes/board/card-board.gd @@ -345,7 +345,7 @@ func _enter_assignment_context(): # 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) + 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(): @@ -354,16 +354,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 diff --git a/src/logic-scenes/board/post-it.gd b/src/logic-scenes/board/post-it.gd index 108c00e5..65520df8 100644 --- a/src/logic-scenes/board/post-it.gd +++ b/src/logic-scenes/board/post-it.gd @@ -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) From 391e026e72e6a30c48f4b27095d336bf29b8603a Mon Sep 17 00:00:00 2001 From: Adrian Schmid Date: Sat, 15 Jul 2023 16:04:41 +0200 Subject: [PATCH 3/3] add label to display if the board is empty --- src/logic-scenes/board/card-board.gd | 3 +++ src/logic-scenes/board/physics-board.tscn | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/logic-scenes/board/card-board.gd b/src/logic-scenes/board/card-board.gd index 78662431..3e1a7982 100644 --- a/src/logic-scenes/board/card-board.gd +++ b/src/logic-scenes/board/card-board.gd @@ -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() diff --git a/src/logic-scenes/board/physics-board.tscn b/src/logic-scenes/board/physics-board.tscn index dd47a1dd..3d89e771 100644 --- a/src/logic-scenes/board/physics-board.tscn +++ b/src/logic-scenes/board/physics-board.tscn @@ -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