From c2188316abcce6e2a2ea01c7b2f99ba6f97716ec Mon Sep 17 00:00:00 2001 From: Adrian Schmid Date: Sun, 2 Jul 2023 10:11:54 +0200 Subject: [PATCH] moved dictionary populating to its own function --- src/logic-scenes/board/card-board.gd | 33 +++++++++++++++------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/logic-scenes/board/card-board.gd b/src/logic-scenes/board/card-board.gd index a55a2b2..b5e3c53 100644 --- a/src/logic-scenes/board/card-board.gd +++ b/src/logic-scenes/board/card-board.gd @@ -10,6 +10,24 @@ var currently_dragged_area: Area2D # Called when the node enters the scene tree for the first time. func _ready(): + populate_board() + reorder_areas("dropzone_content") + + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + + # Reset information about Areas being dragged, if the mouse is not longer pressed. + # Needed because otherwise it can happen that the areas don't register it if you stop clicking on them. + if !Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT) and is_area_dragged: + currently_dragged_area.is_dragged = false + is_area_dragged = false + currently_dragged_area = null + +# Will be used later to spawn Cards and Post-Its and remember them in the dictionary +func populate_board(): + # TODO: Currently populating the dictionary with the Nodes currently in the scene # When opening the scene we need to pass some kind of collection to the Board # Then it can display the Card/PostIts and populate its dictionary at the same time @@ -26,21 +44,6 @@ func _ready(): currently_selected_node = area_dict["dropzone_content"][0] # set first Card as currently selected node by default - reorder_areas("dropzone_content") - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - - # Reset information about Areas being dragged, if the mouse is not longer pressed. - # Needed because otherwise it can happen that the areas don't register it if you stop clicking on them. - if !Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT) and is_area_dragged: - currently_dragged_area.is_dragged = false - is_area_dragged = false - currently_dragged_area = null - -# Will be used later to spawn Cards and Post-Its and remember them in the dictionary -func populate_board(): - pass # Checks if a Node is currently inside the dropzone func is_in_dropzone(to_check: Node) -> bool: