params: Add an option to not hide system cursor; toggle cursor with fullscreen

This commit is contained in:
Sebastian Krzyszkowiak 2022-07-21 06:42:07 +02:00
parent f68eab53f7
commit 6d7f6c6450
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF
3 changed files with 9 additions and 1 deletions

View file

@ -358,7 +358,7 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char*
al_destroy_bitmap(icon);
}
if (game->config.fullscreen || IS_POCKETCHIP) {
if (!game->_priv.params.show_cursor && (game->config.fullscreen || IS_POCKETCHIP)) {
al_hide_mouse_cursor(game->display);
}
al_inhibit_screensaver(true);

View file

@ -149,6 +149,7 @@ struct Params {
bool disable_bg_clear; /*!< If set to true, the gamestate framebuffer won't be cleared to background color before calling Gamestate_Draw. */
bool fixed_size; /*!< If set to true, the game's window will not be resizable. */
bool no_autopause; /*!< If set to true, engine autopause is forced to be disabled. */
bool show_cursor; /*!< If set to true, system cursor won't be hidden in fullscreen. */
int samples; /*!< How many samples should be used for multisampling; 0 to disable. */
int sample_rate; /*!< Default sample rate of audio output; 0 to use engine default. */
char* window_title; /*!< A title of the game's window. When NULL, al_get_app_name() is used. */

View file

@ -759,6 +759,13 @@ SYMBOL_EXPORT bool ToggleFullscreen(struct Game* game) {
al_set_display_flag(game->display, ALLEGRO_FULLSCREEN_WINDOW, game->config.fullscreen);
SetupViewport(game);
PrintConsole(game, "Fullscreen toggled: %s", game->config.fullscreen ? "on" : "off");
if (!game->_priv.params.show_cursor) {
if (game->config.fullscreen) {
al_hide_mouse_cursor(game->display);
} else {
al_show_mouse_cursor(game->display);
}
}
return game->config.fullscreen;
}