wip: drag and drop fixes
This commit is contained in:
parent
46f7463267
commit
a992ef476d
|
|
@ -321,11 +321,16 @@ func give_lore_feedback():
|
||||||
complete = true
|
complete = true
|
||||||
|
|
||||||
# Mark area that was hovered over as currently selected
|
# Mark area that was hovered over as currently selected
|
||||||
func handle_hover(draggable: Draggable) -> void:
|
func handle_hover(_draggable: Draggable) -> void:
|
||||||
|
|
||||||
# If we're hovering with the mouse without clicking, that updates our selection
|
# If we're hovering with the mouse without clicking, that updates our selection
|
||||||
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT): return
|
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT): return
|
||||||
|
|
||||||
|
var candidate := _nearest_hovered(_sort_by_proximity_and_depth(notes))
|
||||||
|
if not candidate:
|
||||||
|
candidate = _nearest_hovered(_sort_by_proximity_and_depth(cards))
|
||||||
|
selection = candidate
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _sort_by_proximity_and_depth(draggables: Array) -> Array[Draggable]:
|
func _sort_by_proximity_and_depth(draggables: Array) -> Array[Draggable]:
|
||||||
var result : Array[Draggable] = []
|
var result : Array[Draggable] = []
|
||||||
|
|
@ -334,7 +339,7 @@ func _sort_by_proximity_and_depth(draggables: Array) -> Array[Draggable]:
|
||||||
var depth := len(result) * 2
|
var depth := len(result) * 2
|
||||||
for item in result:
|
for item in result:
|
||||||
depth -= 1
|
depth -= 1
|
||||||
item.z_index = depth
|
item.z_index = depth if item.mouse_over else 0 # only care about the ones we are currently touching
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -382,7 +387,7 @@ func _input(event) -> void:
|
||||||
get_viewport().set_input_as_handled()
|
get_viewport().set_input_as_handled()
|
||||||
|
|
||||||
|
|
||||||
if event is InputEventMouseMotion and not event.is_action_pressed("mouse_left"):
|
if selection and event is InputEventMouseMotion and not event.is_action_pressed("mouse_left"):
|
||||||
var candidate := _nearest_hovered(_sort_by_proximity_and_depth(notes))
|
var candidate := _nearest_hovered(_sort_by_proximity_and_depth(notes))
|
||||||
if not candidate:
|
if not candidate:
|
||||||
candidate = _nearest_hovered(_sort_by_proximity_and_depth(cards))
|
candidate = _nearest_hovered(_sort_by_proximity_and_depth(cards))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue