added func to sort dict entries on y pos
This commit is contained in:
parent
4a0eddf3e9
commit
5c88414c48
|
|
@ -25,12 +25,14 @@ func _ready():
|
||||||
area_dict["post_its_in_list"] = post_its # will be selected on the right side
|
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
|
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.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
|
|
||||||
# Reset information about Areas being dragged, if the mouse is not longer pressed.
|
# 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:
|
if !Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT) and is_area_dragged:
|
||||||
currently_dragged_area.is_dragged = false
|
currently_dragged_area.is_dragged = false
|
||||||
is_area_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
|
to_handle.position = panel.get_child(0).position
|
||||||
break
|
break
|
||||||
currently_dragged_area = null
|
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)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue