YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
25 stars 8 forks source link

Implement `window_set_fullscreen` and `window_get_fullscreen` on the HTML5 target #6162

Open katsaii opened 5 months ago

katsaii commented 5 months ago

Is your feature request related to a problem?

The window_set_fullscreen and window_get_fullscreen functions are disabled in the HTML5 runner code: https://github.com/YoYoGames/GameMaker-HTML5/blob/bd3dbbf773948d0342859eadfac1bef8f141a260/scripts/functions/Function_Window.js#L91-L96

Most of the code exists but is commented out. But it looks like it uses some old windowing behaviour, instead of the new Fullscreen JavaScript API.

Describe the solution you'd like

Implement these two functions so they may be used on sites like Newgrounds and Itch.io to enter, exit, and detect fullscreen mode. (I am not the first person to encounter this problem, either: https://www.newgrounds.com/bbs/topic/1472969)

Describe alternatives you've considered

I have been getting around this by manually modifying my own local version of the runner source code:

function window_set_fullscreen(_full) {
    let full_curr = window_get_fullscreen();
    if (full_curr == _full) return;
    if (_full) {
        document.documentElement.requestFullscreen();
    } else {
        document.exitFullscreen();
    }
}

function window_get_fullscreen() {
    if (!document.fullscreenEnabled) {
        return false;
    }
    return document.fullscreenElement != null;
}

Additional context

Does this also need to be supported on the GX.games web export? I want to say no because it uses WASM, but you never know.

katsaii commented 5 months ago

Potentially related to #319.