Skip to content

Commit

Permalink
Added Alt+Enter fullscreen shortcut
Browse files Browse the repository at this point in the history
Closes #2525.
  • Loading branch information
Poobslag committed Aug 12, 2024
1 parent 3bbb726 commit ab8b0e2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
7 changes: 6 additions & 1 deletion project/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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]

Expand Down
9 changes: 9 additions & 0 deletions project/src/main/data/system-data.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 10 additions & 1 deletion project/src/main/ui/settings/settings-fullscreen.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit ab8b0e2

Please sign in to comment.