refactor: some events turned into gui_input
This commit is contained in:
parent
69cec724f5
commit
9990a80845
|
|
@ -390,7 +390,7 @@ func handle_drop(draggable: Draggable) -> int:
|
|||
|
||||
|
||||
# Takes the inputs for control inputs
|
||||
func _input(event : InputEvent) -> void:
|
||||
func _gui_input(event : InputEvent) -> void:
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
closed.emit()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
|
|
|||
|
|
@ -56,11 +56,11 @@ func _get_hover_handler() -> Node:
|
|||
|
||||
|
||||
## Walks up the scene tree to find the CardBoard
|
||||
func _get_board() -> Node:
|
||||
func _get_board() -> CardBoard:
|
||||
var node := get_parent()
|
||||
while node:
|
||||
if node.has_method("handle_mouse_button"):
|
||||
return node
|
||||
return node as CardBoard
|
||||
node = node.get_parent()
|
||||
return null
|
||||
|
||||
|
|
@ -91,23 +91,16 @@ func _on_mouse_exited() -> void:
|
|||
|
||||
## Handles global input events (used to catch mouse release during drag)
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_LEFT and not event.pressed:
|
||||
if is_dragged:
|
||||
is_dragged = false
|
||||
# Trigger the drop logic
|
||||
var board := _get_board()
|
||||
if board and board.has_method("_end_drag"):
|
||||
board._end_drag(self)
|
||||
if is_dragged and event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.is_released():
|
||||
is_dragged = false
|
||||
# Trigger the drop logic
|
||||
_get_board().handle_mouse_button(event, self)
|
||||
|
||||
|
||||
## Handles input events on this Area2D (used to start drag)
|
||||
func _on_input_event(_viewport, event, _shape_idx):
|
||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
|
||||
if highlighted:
|
||||
var board := _get_board()
|
||||
if board and board.has_method("handle_mouse_button"):
|
||||
board.handle_mouse_button(event, self)
|
||||
if highlighted and event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
|
||||
_get_board().handle_mouse_button(event, self)
|
||||
|
||||
|
||||
## Starts a drag operation
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ func _process(delta: float) -> void:
|
|||
offset.y -= scroll_speed * delta
|
||||
Handle.position = offset
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
func _gui_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("ui_menu") or event.is_action_pressed("ui_cancel") or event.is_action_pressed("ui_accept"):
|
||||
stop()
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,6 @@ func _on_exit_button_pressed() -> void:
|
|||
leave_stage.emit()
|
||||
State.save_settings()
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
func _gui_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("ui_cancel") and focused:
|
||||
leave_stage.emit()
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ func _on_exit_button_pressed() -> void:
|
|||
leave_stage.emit()
|
||||
State.save_settings()
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
func _gui_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("ui_cancel") and focused:
|
||||
leave_stage.emit()
|
||||
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ func has_more_saves() -> bool:
|
|||
return true
|
||||
return false
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
func _gui_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
cancel()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue