Add Alt+F to toggle fullscreen and window mode

New remappable action `toggle_fullscreen` (Alt+F) handled in main.gd::_input(),
so it works in the menu, during a match with the pointer captured and in the boss
sandbox; the event is marked handled so the key does not reach the rest of the game.

toggle_fullscreen() switches between WINDOW_MODE_FULLSCREEN and WINDOW_MODE_WINDOWED;
the state lives in main.fullscreen (initialised from the real window mode) instead of
querying the driver on every press, so the toggle is deterministic and testable. On
Web it is a no-op because fullscreen belongs to the page.

Desktop HUD hint updated. New tools/test_fullscreen_shortcut.gd: 8 checks (action and
key mapping, alternation, bare F inert, works mid-match without freeing the cursor).
Verified on a real display: window_get_mode 0 -> 3 -> 0.
This commit is contained in:
enne2
2026-10-24 12:55:15 +02:00
parent cb14fd5400
commit 4af402f8bf
6 changed files with 138 additions and 1 deletions
+20
View File
@@ -36,9 +36,13 @@ var simulation_finished := false
var simulation_restarting := false
var simulation_label: Label
var simulation_retry: Button
## Stato dello schermo intero, tenuto qui e non letto dal driver a ogni pressione:
## cosi' Alt+F alterna davvero e il comportamento e' verificabile anche in headless.
var fullscreen := false
func _ready() -> void:
smoke = "--smoke" in OS.get_cmdline_user_args()
fullscreen = DisplayServer.window_get_mode() != DisplayServer.WINDOW_MODE_WINDOWED
if not _configure_simulation():
return
# A simulation must never read/write the real player's profile or public scores.
@@ -412,11 +416,27 @@ func _setup_simulation_ui() -> void:
canvas.add_child(simulation_retry)
func _input(event: InputEvent) -> void:
# Alt+F: finestra <-> schermo intero. Vale sempre (menu, partita, simulazione),
# anche a cursore catturato, perche' _input arriva prima della UI.
if event.is_action_pressed("toggle_fullscreen"):
get_viewport().set_input_as_handled()
toggle_fullscreen()
return
# Only the completed native simulation has this shortcut. No menu click-to-start.
if boss_simulation and simulation_finished and event.is_action_pressed("reload"):
get_viewport().set_input_as_handled()
_restart_simulation()
## Alterna finestra e schermo intero. Restituisce il nuovo stato (true = schermo intero).
## Nel browser il fullscreen e' della pagina, non della finestra Godot: li' non si tocca.
func toggle_fullscreen() -> bool:
if OS.has_feature("web"):
return fullscreen
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED if fullscreen
else DisplayServer.WINDOW_MODE_FULLSCREEN)
fullscreen = not fullscreen
return fullscreen
func _restart_simulation() -> void:
if simulation_restarting:
return