mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-05 00:38:00 +01:00
utils: add ToggleFullscreen and ToggleMute
This commit is contained in:
parent
c93c22cf04
commit
151e11d371
2 changed files with 27 additions and 0 deletions
24
src/utils.c
24
src/utils.c
|
@ -716,3 +716,27 @@ SYMBOL_EXPORT void QuitGame(struct Game* game, bool allow_pausing) {
|
|||
#endif
|
||||
UnloadAllGamestates(game);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT bool ToggleFullscreen(struct Game* game) {
|
||||
game->config.fullscreen = !game->config.fullscreen;
|
||||
if (game->config.fullscreen) {
|
||||
SetConfigOption(game, "SuperDerpy", "fullscreen", "1");
|
||||
} else {
|
||||
SetConfigOption(game, "SuperDerpy", "fullscreen", "0");
|
||||
}
|
||||
#ifdef ALLEGRO_ANDROID
|
||||
al_set_display_flag(game->display, ALLEGRO_FRAMELESS, game->config.fullscreen);
|
||||
#endif
|
||||
al_set_display_flag(game->display, ALLEGRO_FULLSCREEN_WINDOW, game->config.fullscreen);
|
||||
SetupViewport(game);
|
||||
PrintConsole(game, "Fullscreen toggled");
|
||||
return game->config.fullscreen;
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT bool ToggleMute(struct Game* game) {
|
||||
game->config.mute = !game->config.mute;
|
||||
al_set_mixer_gain(game->audio.mixer, game->config.mute ? 0.0 : 1.0);
|
||||
SetConfigOption(game, "SuperDerpy", "mute", game->config.mute ? "1" : "0");
|
||||
PrintConsole(game, "Mute: %d", game->config.mute);
|
||||
return game->config.mute;
|
||||
}
|
||||
|
|
|
@ -93,4 +93,7 @@ char* PunchNumber(struct Game* game, char* text, char ch, int number);
|
|||
/*! \brief Quits the game. On platforms that allow it, brings the game to the background without quiting if <allow_pausing> is true. */
|
||||
void QuitGame(struct Game* game, bool allow_pausing);
|
||||
|
||||
bool ToggleFullscreen(struct Game* game);
|
||||
bool ToggleMute(struct Game* game);
|
||||
|
||||
#endif /* LIBSUPERDERPY_UTILS_H */
|
||||
|
|
Loading…
Reference in a new issue