Implement FullScreen and FPS opts

This commit is contained in:
2024-01-29 16:41:13 +01:00
parent ed1815eddc
commit a633c9cbdf
7 changed files with 76 additions and 47 deletions

View File

@@ -278,17 +278,18 @@ void drawSettingsUI(Game *game, f32 dt) {
.type = BZ_UI_LAYOUT_FLEX_BOX,
.flags = BZ_UI_FLEX_DIR_COLUMN | BZ_UI_FLEX_JUSTIFY_CENTER | BZ_UI_FLEX_ALIGN_CENTER
});
static Options opts;
static GameData gameData = {};
if (game->screenPrevFrame != SCREEN_SETTINGS)
opts = game->options;
gameData = game->gameData;
uiSettingsLabel("Video");
uiSettingsCheckbox("Fullscreen", &opts.fullscreen);
uiSettingsCheckbox("V-Sync", &opts.vsync);
uiSettingsCheckbox("Fullscreen", &gameData.options.fullscreen);
uiSettingsCheckbox("Limit FPS", &gameData.options.limitFps);
//uiSettingsCheckbox("V-Sync", &opts.vsync);
uiSettingsLabel("Audio");
uiSettingsSlider("Master: ", &opts.master);
uiSettingsSlider("Music: ", &opts.music);
uiSettingsSlider("Sound: ", &opts.sound);
uiSettingsSlider("Master: ", &gameData.options.master);
uiSettingsSlider("Music: ", &gameData.options.music);
uiSettingsSlider("Sound: ", &gameData.options.sound);
bzUIPopParent(UI);
bzUIPushDiv(UI, (BzUISize) {BZ_UI_SIZE_REL_PARENT, 0.8f},
@@ -302,13 +303,12 @@ void drawSettingsUI(Game *game, f32 dt) {
setScreen(game, SCREEN_MAIN_MENU);
}
if (uiSettingsButton("Reset")) {
opts = game->options;
gameData = game->gameData;
}
if (uiSettingsButton("Apply")) {
serializeOptions(SETTINGS_PATH, &opts);
game->options = opts;
SoundState *sounds = ecs_singleton_get_mut(ECS, SoundState);
soundsApplyVolume(sounds, opts.master, opts.music, opts.sound);
serializeGameData(GAME_DATA_SAVE_PATH, &gameData);
game->gameData = gameData;
applyOptions(&game->gameData.options);
setScreen(game, SCREEN_MAIN_MENU);
}