godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

By default, bind Alt + Enter to switch between fullscreen and windowed mode #1983

Open iwanPlays opened 3 years ago

iwanPlays commented 3 years ago

Describe the project you are working on

None. I am a YouTuber representing players from a convenience/usability perspective.

Describe the problem or limitation you are having in your project

Godot games usually start at 1280x720 windowed mode

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Unreal and Unity by default allow switching between windowed (multitasking) and fullscreen (immersion) using ALT+ENTER Most other games do too. It allows for fast necessary window management, because there are screens/drivers that just have issues with fullscreen but playing fullscreen is important for immersion.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

if alt-enter pressed and fullscreen then
  windowed
else
  fullscreen
end

A project settings switch could be used to disable this a la https://answers.unity.com/questions/544183/block-or-override-alt-enter-fullscreen.html but it needs to be default.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Of course, yes. But it will be used by every game unless the game is supposed to be a troll/subversive kind of game. The purpose of this is to provide usability/immersion to projects made by beginners. It is to help beginner game devs who are already overwhelmed by making a game and not have them think about window management.

Is there a reason why this should be core and not an add-on in the asset library?

It's basic functionality of nearly every game on the market. Just like ALT+F4 needs to kill applications unless there's a really good reason against or ALT+TAB should always switch applications unless there's a REALLY REALLY REALLY good reason against that.

Calinou commented 3 years ago

This will be implemented by https://github.com/godotengine/godot/pull/39708 once it's merged.

It's basic functionality of nearly every game on the market. Just like ALT+F4 needs to kill applications unless there's a really good reason against or ALT+TAB should always switch applications unless there's a REALLY REALLY REALLY good reason against that.

Note that these are handled differently to Alt + Enter though, since the OS will handle those by default. Alt + Enter needs to be implemented by the application as the OS doesn't implement it by default.

elvisish commented 8 months ago

For Godot 4.x, if anyone wants a quick solution, just add this to InputMap: image

And throw this in an Autorun:

func _input(event):
    if Input.is_action_pressed("toggle_fullscreen"):
        if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_WINDOWED:
            DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
        elif DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
            DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
Calinou commented 5 months ago

For Godot 4.x, if anyone wants a quick solution, just add this to InputMap:

As an aside, note that WINDOW_MODE_EXCLUSIVE_FULLSCREEN should be used for games instead of WINDOW_MODE_FULLSCREEN, which is intended to be used for non-game applications. WINDOW_MODE_FULLSCREEN intentionally adds a border around the borderless fullscreen window, so that other windows can be overlaid on top (for multi-window support). This border is needed so that the graphics driver doesn't automatically convert it to exclusive fullscreen, which has various limitations that can be problematic for non-game applications (such as overlaying other windows on top).

In contrast, WINDOW_MODE_EXCLUSIVE_FULLSCREEN provides lower latency and no visible border, but no ability to overlay other windows on top. See discussion in https://github.com/godotengine/godot/issues/63500 for details.