12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- @icon("res://common/graphics/icons/godot_icon_slide.svg")
- class_name Slide
- extends Node2D
- # Display slide content
- signal finished
- var center_offset: Vector2
- func _ready():
- center_offset = _compute_center_offset()
- set_visible(false)
- remove_focus()
- func remove_focus() -> void:
- set_process_unhandled_input(false)
- func focus() -> void:
- set_visible(true)
- set_process_unhandled_input(true)
- func get_center():
- return get_position() + center_offset
- func _unhandled_key_input(event: InputEvent):
- if not is_processing_unhandled_input():
- return # seems to be hacky, see if it's an engine bug
- if event.is_action("ui_accept") and event.is_pressed():
- finished.emit()
- get_viewport().set_input_as_handled()
- func _compute_center_offset() -> Vector2:
- var w: float = ProjectSettings.get("display/window/size/viewport_width")
- var h: float = ProjectSettings.get("display/window/size/viewport_height")
- return Vector2(w * scale.x / 2, h * scale.y / 2)
|