utils: add ToggleFullscreen and ToggleMute

This commit is contained in:
Sebastian Krzyszkowiak 2019-03-05 03:42:25 +01:00
parent c93c22cf04
commit 151e11d371
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF
2 changed files with 27 additions and 0 deletions

View file

@ -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;
}

View file

@ -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 */