38 lines
1.2 KiB
GDScript
38 lines
1.2 KiB
GDScript
extends Node
|
|
|
|
|
|
@export var dragon_template: PackedScene
|
|
|
|
|
|
func _ready():
|
|
await get_tree().process_frame
|
|
move_window_to_bottom_right()
|
|
|
|
|
|
func move_window_to_bottom_right():
|
|
var display_index: int = DisplayServer.window_get_current_screen()
|
|
|
|
var work_area_position: Vector2i = DisplayServer.screen_get_usable_rect(display_index).position
|
|
var work_area_size: Vector2i = DisplayServer.screen_get_usable_rect(display_index).size
|
|
|
|
var window_size: Vector2i = DisplayServer.window_get_size()
|
|
|
|
var new_position: Vector2i = work_area_position + Vector2i(work_area_size.x - window_size.x, work_area_size.y - window_size.y)
|
|
|
|
DisplayServer.window_set_position(new_position)
|
|
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
if event.is_action_pressed("ui_accept"):
|
|
_instantiate_dragon(Vector2i(0, 0))
|
|
|
|
|
|
func _instantiate_dragon(relative_position: Vector2i) -> void:
|
|
var dragon = dragon_template.instantiate()
|
|
add_child(dragon)
|
|
if dragon is Window:
|
|
var window_position: Vector2i = DisplayServer.window_get_position()
|
|
var window_size: Vector2i = DisplayServer.window_get_size()
|
|
dragon.position = window_position + relative_position
|
|
dragon.main_window_rect = Rect2i(window_position, window_size)
|
|
dragon.show()
|