From ab8b0e2eb40b935b5f7f6215181ea3ed4c2f859e Mon Sep 17 00:00:00 2001 From: Poobslag Date: Mon, 12 Aug 2024 10:38:52 -0400 Subject: [PATCH] Added Alt+Enter fullscreen shortcut Closes #2525. --- project/project.godot | 7 ++++++- project/src/main/data/system-data.gd | 9 +++++++++ project/src/main/ui/settings/settings-fullscreen.gd | 11 ++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/project/project.godot b/project/project.godot index d190d35e3..d513e77a4 100644 --- a/project/project.godot +++ b/project/project.godot @@ -1174,7 +1174,7 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://src/main/data/practice-data.gd" }, { -"base": "Reference", +"base": "VBoxContainer", "class": "PracticeSpeedSelector", "language": "GDScript", "path": "res://src/main/ui/menu/training-speed-selector.gd" @@ -2132,6 +2132,11 @@ prev_tab={ , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":90,"physical_scancode":0,"unicode":0,"echo":false,"script":null) ] } +fullscreen={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":true,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"physical_scancode":0,"unicode":0,"echo":false,"script":null) + ] +} [locale] diff --git a/project/src/main/data/system-data.gd b/project/src/main/data/system-data.gd index b9e6dae18..c895c9e99 100644 --- a/project/src/main/data/system-data.gd +++ b/project/src/main/data/system-data.gd @@ -29,6 +29,15 @@ func _ready() -> void: graphics_settings.connect("fullscreen_changed", self, "_on_GraphicsSettings_fullscreen_changed") graphics_settings.connect("use_vsync_changed", self, "_on_GraphicsSettings_use_vsync_changed") _schedule_refresh_graphics_settings() + + # allow the alt+enter shortcut to process even when gameplay is paused + pause_mode = Node.PAUSE_MODE_PROCESS + + +func _input(_event: InputEvent) -> void: + if Input.is_action_just_pressed("fullscreen"): + SystemData.graphics_settings.fullscreen = !SystemData.graphics_settings.fullscreen + get_tree().set_input_as_handled() ## Prevents the player's settings from triggering fullscreen mode or vsync. diff --git a/project/src/main/ui/settings/settings-fullscreen.gd b/project/src/main/ui/settings/settings-fullscreen.gd index 33628d6d8..c3a20d7e1 100644 --- a/project/src/main/ui/settings/settings-fullscreen.gd +++ b/project/src/main/ui/settings/settings-fullscreen.gd @@ -7,12 +7,21 @@ const WINDOWABLE_PLATFORMS := ["osx", "windows", "x11"] onready var _check_box: CheckBox = $CheckBox func _ready() -> void: - _check_box.pressed = SystemData.graphics_settings.fullscreen + _refresh_checkbox() + SystemData.graphics_settings.connect("fullscreen_changed", self, "_on_GraphicsSettings_fullscreen_changed") if not OS.get_name().to_lower() in WINDOWABLE_PLATFORMS: # hide component for web or mobile targets visible = false +func _refresh_checkbox() -> void: + _check_box.pressed = SystemData.graphics_settings.fullscreen + + func _on_CheckBox_pressed() -> void: SystemData.graphics_settings.fullscreen = _check_box.pressed + + +func _on_GraphicsSettings_fullscreen_changed(_value: bool) -> void: + _refresh_checkbox()