added func to sort dict entries on y pos
This commit is contained in:
parent
4a0eddf3e9
commit
5c88414c48
|
|
@ -26,11 +26,13 @@ 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 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
|
||||
|
|
@ -100,6 +102,23 @@ func handle_mouse_button(to_handle: Area2D, input: InputEvent, dragableType: int
|
|||
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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue