From 195116fe1f9f6410c942d0deaa1b2044625ddcae Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Fri, 17 May 2024 01:47:23 +0200 Subject: [PATCH] Add input detection (fullscreen & navigation) --- src/classes/communication.gd | 13 +++++++++++++ src/userinterface.gd | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/classes/communication.gd b/src/classes/communication.gd index f6f9e5f..8198203 100644 --- a/src/classes/communication.gd +++ b/src/classes/communication.gd @@ -37,7 +37,20 @@ func _init(core_new: Core, presenloader_new: Node) -> void: sms = core.sms presenloader = presenloader_new + +func _process(_delta: float) -> void: + # Check for inputs + if Input.is_action_just_pressed("fullscreen"): + logger.diag("Toggling fullscreen mode") + + match(DisplayServer.window_get_mode()): + DisplayServer.WindowMode.WINDOW_MODE_WINDOWED: DisplayServer.window_set_mode(DisplayServer.WindowMode.WINDOW_MODE_FULLSCREEN) + _: DisplayServer.window_set_mode(DisplayServer.WindowMode.WINDOW_MODE_WINDOWED) + if Input.is_action_just_pressed("navigate_forwards"): + switch_slide(current_slide + 1) + if Input.is_action_just_pressed("navigate_backwards"): + switch_slide(current_slide - 1) entrypoint = presenloader.entrypoint_node manifest = presenloader.manifest diff --git a/src/userinterface.gd b/src/userinterface.gd index 4dbc23e..f22b34a 100644 --- a/src/userinterface.gd +++ b/src/userinterface.gd @@ -105,6 +105,16 @@ func load_high_quality_wallpaper() -> void: ) thread_wallpaper.wait_to_finish() +# +++ processing +++ +func _process(_delta: float) -> void: + # Check for inputs + if Input.is_action_just_pressed("fullscreen"): + logger.diag("Toggling fullscreen mode") + + match(DisplayServer.window_get_mode()): + DisplayServer.WindowMode.WINDOW_MODE_WINDOWED: DisplayServer.window_set_mode(DisplayServer.WindowMode.WINDOW_MODE_FULLSCREEN) + _: DisplayServer.window_set_mode(DisplayServer.WindowMode.WINDOW_MODE_WINDOWED) + # +++ unload & cleanup +++ func unload() -> void: logger.info("Unloading user interface")