Add settings menu
This commit is contained in:
63
game/main.c
63
game/main.c
@@ -311,6 +311,8 @@ static void renderMainMenu(Game *game, float dt) {
|
||||
i32 width = GetScreenWidth();
|
||||
i32 height = GetScreenHeight();
|
||||
|
||||
game->camera.zoom = 3 * uiGetScale();
|
||||
|
||||
bzUIBegin(UI, width, height);
|
||||
bzUISetParentLayout(UI, (BzUILayout) {
|
||||
.type = BZ_UI_LAYOUT_FLEX_BOX,
|
||||
@@ -345,11 +347,66 @@ static void renderMainMenu(Game *game, float dt) {
|
||||
}
|
||||
|
||||
static void renderSettings(Game *game, float dt) {
|
||||
i32 width = GetScreenWidth();
|
||||
i32 height = GetScreenHeight();
|
||||
|
||||
game->camera.zoom = 3 * uiGetScale();
|
||||
|
||||
bzUIBegin(UI, width, height);
|
||||
bzUISetParentLayout(UI, (BzUILayout) {
|
||||
.type = BZ_UI_LAYOUT_FLEX_BOX,
|
||||
.flags = BZ_UI_FLEX_DIR_COLUMN | BZ_UI_FLEX_JUSTIFY_CENTER | BZ_UI_FLEX_ALIGN_CENTER
|
||||
});
|
||||
|
||||
bzUIPushDiv(UI, (BzUISize) { BZ_UI_SIZE_REL_PARENT, 0.8f},
|
||||
(BzUISize) { BZ_UI_SIZE_REL_PARENT, 0.8f});
|
||||
bzUISetParentLayout(UI, (BzUILayout) {
|
||||
.type = BZ_UI_LAYOUT_FLEX_BOX,
|
||||
.flags = BZ_UI_FLEX_DIR_COLUMN | BZ_UI_FLEX_JUSTIFY_CENTER | BZ_UI_FLEX_ALIGN_CENTER
|
||||
});
|
||||
static bool fullscreen = false;
|
||||
static bool vsync = false;
|
||||
uiSettingsLabel("Video");
|
||||
uiSettingsCheckbox("Fullscreen", &fullscreen);
|
||||
uiSettingsCheckbox("V-Sync", &vsync);
|
||||
|
||||
static f32 master = 50.0f;
|
||||
static f32 music = 50.0f;
|
||||
static f32 sound = 50.0f;
|
||||
uiSettingsLabel("Audio");
|
||||
uiSettingsSlider("Master: ", &master);
|
||||
uiSettingsSlider("Music: ", &music);
|
||||
uiSettingsSlider("Sound: ", &sound);
|
||||
|
||||
bzUIPopParent(UI);
|
||||
bzUIPushDiv(UI, (BzUISize) {BZ_UI_SIZE_REL_PARENT, 0.8f},
|
||||
(BzUISize) {BZ_UI_SIZE_REL_PARENT, 0.2f});
|
||||
bzUISetParentLayout(UI, (BzUILayout) {
|
||||
.type = BZ_UI_LAYOUT_FLEX_BOX,
|
||||
.flags = BZ_UI_FLEX_DIR_ROW | BZ_UI_FLEX_JUSTIFY_CENTER | BZ_UI_FLEX_ALIGN_CENTER
|
||||
});
|
||||
|
||||
if (uiSettingsButton("Back")) {
|
||||
game->screen = SCREEN_MAIN_MENU;
|
||||
}
|
||||
if (uiSettingsButton("Reset")) {
|
||||
|
||||
}
|
||||
if (uiSettingsButton("Apply")) {
|
||||
game->screen = SCREEN_MAIN_MENU;
|
||||
}
|
||||
|
||||
bzUIEnd(UI);
|
||||
}
|
||||
|
||||
void render(float dt, void *userData) {
|
||||
BZ_UNUSED(userData);
|
||||
Game *game = ecs_singleton_get_mut(ECS, Game);
|
||||
const InputState *input = ecs_singleton_get(ECS, InputState);;
|
||||
|
||||
if (IsKeyReleased(input->mapping.backBtn)) {
|
||||
game->screen = SCREEN_MAIN_MENU;
|
||||
}
|
||||
|
||||
Color shadow = BLACK;
|
||||
shadow.a = 35;
|
||||
@@ -378,14 +435,8 @@ void imguiRender(float dt, void *userData) {
|
||||
Game *game = ecs_singleton_get_mut(ECS, Game);
|
||||
InputState *input = ecs_singleton_get_mut(ECS, InputState);
|
||||
|
||||
if (game->screen != SCREEN_GAME) return;
|
||||
|
||||
igSetNextWindowSize((ImVec2){300, 400}, ImGuiCond_FirstUseEver);
|
||||
igBegin("Debug Menu", NULL, 0);
|
||||
if (igSmallButton("Recruit worker [50 food]")) {
|
||||
createWorker((Position) {1100, 400}, (Size) {10, 10}, game->entityGrid,
|
||||
&game->map.tilesets[2], 1322);
|
||||
}
|
||||
igText("PathData pool available: %llu", bzObjectPoolGetNumFree(game->pools.pathData));
|
||||
igText("Action pool available: %llu", bzObjectPoolGetNumFree(game->pools.actions));
|
||||
const char *inputState = "NONE";
|
||||
|
||||
Reference in New Issue
Block a user