diff --git a/src/logic-scenes/board/card-board.gd b/src/logic-scenes/board/card-board.gd index ee4aa32b..a55a2b23 100644 --- a/src/logic-scenes/board/card-board.gd +++ b/src/logic-scenes/board/card-board.gd @@ -25,12 +25,14 @@ func _ready(): area_dict["post_its_in_list"] = post_its # will be selected on the right side 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 if you stop clicking on them. + # 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 @@ -99,7 +101,24 @@ func handle_mouse_button(to_handle: Area2D, input: InputEvent, dragableType: int to_handle.position = panel.get_child(0).position break currently_dragged_area = null - +func handle_hover(to_handle: Area2D): + currently_selected_node = to_handle + pass +# Reorders the areas in any of the dictionaries entries +# Pass the entries key in order to reorder it +func reorder_areas(reorder: String): + var old_order = area_dict[reorder] + var new_order = Array() + + for obj in old_order: + var i = 0 + if !new_order.is_empty(): + for obj_2 in new_order: + if obj_2.position.y < obj.position.y: + i += 1 + new_order.insert(i, obj) + + print_debug(new_order)