Add continue button

This commit is contained in:
2024-01-28 20:18:31 +01:00
parent dfc20b6a96
commit 73082f9d1d
3 changed files with 19 additions and 16 deletions

View File

@@ -202,10 +202,10 @@ void drawPauseUI(Game *game, f32 dt) {
.type = BZ_UI_LAYOUT_FLEX_BOX, .type = BZ_UI_LAYOUT_FLEX_BOX,
.flags = BZ_UI_FLEX_DIR_COLUMN | BZ_UI_FLEX_ALIGN_CENTER .flags = BZ_UI_FLEX_DIR_COLUMN | BZ_UI_FLEX_ALIGN_CENTER
}); });
if (uiMainMenuButton("Resume")) { if (uiMainMenuButton("Resume", true)) {
setScreen(game, SCREEN_GAME); setScreen(game, SCREEN_GAME);
} }
if (uiMainMenuButton("Exit")) { if (uiMainMenuButton("Exit", true)) {
setScreen(game, SCREEN_MAIN_MENU); setScreen(game, SCREEN_MAIN_MENU);
unloadMap(game); unloadMap(game);
loadMap(game, "assets/maps/main_menu_01.tmj"); loadMap(game, "assets/maps/main_menu_01.tmj");
@@ -239,16 +239,19 @@ void drawMainMenuUI(Game *game, f32 dt) {
.type = BZ_UI_LAYOUT_FLEX_BOX, .type = BZ_UI_LAYOUT_FLEX_BOX,
.flags = BZ_UI_FLEX_DIR_COLUMN | BZ_UI_FLEX_ALIGN_CENTER .flags = BZ_UI_FLEX_DIR_COLUMN | BZ_UI_FLEX_ALIGN_CENTER
}); });
if (uiMainMenuButton("Play")) { if (uiMainMenuButton("Continue", false)) {
}
if (uiMainMenuButton("Play", true)) {
setScreen(game, SCREEN_GAME); setScreen(game, SCREEN_GAME);
unloadMap(game); unloadMap(game);
loadMap(game, "assets/maps/tree_test.tmj"); loadMap(game, "assets/maps/tree_test.tmj");
//loadMap(game, "assets/maps/map_01.tmj"); //loadMap(game, "assets/maps/map_01.tmj");
} }
if (uiMainMenuButton("Settings")) { if (uiMainMenuButton("Settings", true)) {
setScreen(game, SCREEN_SETTINGS); setScreen(game, SCREEN_SETTINGS);
} }
if (uiMainMenuButton("Exit")) { if (uiMainMenuButton("Exit", true)) {
bzGameExit(); bzGameExit();
} }
bzUIPopParent(UI); bzUIPopParent(UI);

View File

@@ -58,7 +58,7 @@ void uiBaseLabel(const char *txt, Font font, f32 scl, Color color) {
}); });
} }
bool uiBaseTextButton(const char *txt, Font font, f32 scl) { bool uiBaseTextButton(const char *txt, Font font, f32 scl, bool enabled) {
BzUINode *node = bzUINodeMake(UI, bzUIKeyFromString(txt), &(BzUINodeDesc) { BzUINode *node = bzUINodeMake(UI, bzUIKeyFromString(txt), &(BzUINodeDesc) {
.flags = BZ_UI_DRAW_TEXT | BZ_UI_DRAW_TEXT_SHADOW | BZ_UI_ALIGN_CENTER, .flags = BZ_UI_DRAW_TEXT | BZ_UI_DRAW_TEXT_SHADOW | BZ_UI_ALIGN_CENTER,
.semanticSize[BZ_UI_AXIS_X] = { .semanticSize[BZ_UI_AXIS_X] = {
@@ -75,9 +75,9 @@ bool uiBaseTextButton(const char *txt, Font font, f32 scl) {
.font = font, .font = font,
.fontSpacing = 2 * uiGetScale() * scl, .fontSpacing = 2 * uiGetScale() * scl,
.fontSize = 62 * uiGetScale() * scl, .fontSize = 62 * uiGetScale() * scl,
.normal = WHITE, .normal = enabled ? WHITE : GRAY,
.hover = GRAY, .hover = enabled ? GRAY : GRAY,
.active = YELLOW .active = enabled ? GRAY : LIGHTGRAY,
}); });
bzUISetTextShadowStyle(UI, node, (BzUITextShadowStyle) { bzUISetTextShadowStyle(UI, node, (BzUITextShadowStyle) {
.offset[BZ_UI_AXIS_X] = 2 * uiGetScale() * scl, .offset[BZ_UI_AXIS_X] = 2 * uiGetScale() * scl,
@@ -168,7 +168,7 @@ void uiBaseSlider(const char *txt, Font font, f32 scl, f32 *value, f32 min, f32
char buf[32]; char buf[32];
snprintf(buf, sizeof(buf), "-##%s", txt); snprintf(buf, sizeof(buf), "-##%s", txt);
if (uiBaseTextButton(buf, font, 0.6 * scl)) if (uiBaseTextButton(buf, font, 0.6 * scl, true))
(*value)--; (*value)--;
*value = BZ_MAX(*value, min); *value = BZ_MAX(*value, min);
@@ -176,7 +176,7 @@ void uiBaseSlider(const char *txt, Font font, f32 scl, f32 *value, f32 min, f32
uiBaseLabel(buf, font, 0.6 * scl, WHITE); uiBaseLabel(buf, font, 0.6 * scl, WHITE);
snprintf(buf, sizeof(buf), "+##%s", txt); snprintf(buf, sizeof(buf), "+##%s", txt);
if (uiBaseTextButton(buf, font, 0.6 * scl)) if (uiBaseTextButton(buf, font, 0.6 * scl, true))
(*value)++; (*value)++;
*value = BZ_MIN(*value, max); *value = BZ_MIN(*value, max);
bzUIPopParent(UI); bzUIPopParent(UI);
@@ -188,15 +188,15 @@ void uiMainMenuLabel(const char *txt) {
uiBaseLabel(txt, getFont(), 1.8f, WHITE); uiBaseLabel(txt, getFont(), 1.8f, WHITE);
} }
bool uiMainMenuButton(const char *txt) { bool uiMainMenuButton(const char *txt, bool enabled) {
return uiBaseTextButton(txt, getFont(), 0.8f); return uiBaseTextButton(txt, getFont(), 0.8f, enabled);
} }
void uiSettingsLabel(const char *txt) { void uiSettingsLabel(const char *txt) {
uiBaseLabel(txt, getFont(), 0.8f, WHITE); uiBaseLabel(txt, getFont(), 0.8f, WHITE);
} }
bool uiSettingsButton(const char *txt) { bool uiSettingsButton(const char *txt) {
return uiBaseTextButton(txt, getFont(), 0.7f); return uiBaseTextButton(txt, getFont(), 0.7f, true);
} }
void uiSettingsCheckbox(const char *txt, bool *check) { void uiSettingsCheckbox(const char *txt, bool *check) {
uiBaseCheckbox(txt, getFont(), 1.0f, check); uiBaseCheckbox(txt, getFont(), 1.0f, check);

View File

@@ -12,13 +12,13 @@ BzUINode *uiPushDivParentPercentage(f32 xPercent, f32 yPercent);
// Template stuff // Template stuff
void uiBaseLabel(const char *txt, Font font, f32 scl, Color color); void uiBaseLabel(const char *txt, Font font, f32 scl, Color color);
bool uiBaseTextButton(const char *txt, Font font, f32 scl); bool uiBaseTextButton(const char *txt, Font font, f32 scl, bool enabled);
void uiBaseCheckbox(const char *txt, Font font, f32 scl, bool *check); void uiBaseCheckbox(const char *txt, Font font, f32 scl, bool *check);
void uiBaseSlider(const char *txt, Font font, f32 scl, f32 *value, f32 min, f32 max); void uiBaseSlider(const char *txt, Font font, f32 scl, f32 *value, f32 min, f32 max);
// actual UI // actual UI
void uiMainMenuLabel(const char *txt); void uiMainMenuLabel(const char *txt);
bool uiMainMenuButton(const char *txt); bool uiMainMenuButton(const char *txt, bool enabled);
void uiSettingsLabel(const char *txt); void uiSettingsLabel(const char *txt);
bool uiSettingsButton(const char *txt); bool uiSettingsButton(const char *txt);