Skip to content

Commit 25d6f80

Browse files
committed
Menu improvements
1 parent a80874b commit 25d6f80

File tree

4 files changed

+43
-41
lines changed

4 files changed

+43
-41
lines changed

src/bird.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,15 @@ void bird_tick(bird_t *bird, const joypad_buttons_t *const buttons)
321321
{
322322
bird->state = BIRD_STATE_PLAY;
323323
}
324+
else if (buttons->b)
325+
{
326+
bird->state = BIRD_STATE_TITLE;
327+
bird->is_dead_reset = true;
328+
bird->x = BIRD_TITLE_X;
329+
bird->y = 0.0;
330+
bird->dy = 0.0;
331+
sfx_play(SFX_SWOOSH);
332+
}
324333
break;
325334
case BIRD_STATE_DYING:
326335
if (bird->dy > 0 && !bird->played_die_sfx)

src/fps.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,14 @@ void fps_draw(void)
8282

8383
const ticks_t ticks = timer_ticks();
8484
const int font_id = gfx->highres ? FONT_AT01_2X : FONT_AT01;
85-
const int line_height = gfx->highres ? 26 : 13;
85+
const int margin_x = GFX_SCALE(10);
86+
const int line_height = GFX_SCALE(14);
8687

87-
rdpq_text_printf(NULL, font_id, 10, gfx->height - (line_height * 2 + 7),
88+
rdpq_text_printf(NULL, font_id, margin_x, gfx->height - (line_height * 2),
8889
"FPS: %05.2f, Frame: %u, Miss: %u",
8990
display_get_fps(), fps.total_frames, fps.total_misses);
9091

91-
rdpq_text_printf(NULL, font_id, 10, gfx->height - (line_height + 7),
92+
rdpq_text_printf(NULL, font_id, margin_x, gfx->height - (line_height * 1),
9293
"Milli: %llu, Tick: %llu",
9394
ticks / TICKS_PER_MS, ticks);
9495
}

src/ui.c

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#define UI_SPARKLE_CYCLE_TICKS ((int)500 * TICKS_PER_MS)
3636

3737
static color_t UI_DARK_COLOR = {0};
38+
static color_t UI_DIM_COLOR = {0};
3839
static color_t UI_LIGHT_COLOR = {0};
3940
static color_t UI_FLASH_COLOR = {0};
4041

@@ -46,6 +47,7 @@ static color_t UI_FLASH_COLOR = {0};
4647
static inline void ui_init_colors(void)
4748
{
4849
UI_DARK_COLOR = RGBA32(0x57, 0x37, 0x47, 0xFF);
50+
UI_DIM_COLOR = RGBA32(0x88, 0x68, 0x78, 0xFF);
4951
UI_LIGHT_COLOR = RGBA32(0xFF, 0xFF, 0xFF, 0xFF);
5052
UI_FLASH_COLOR = RGBA32(0xFF, 0xFF, 0xFF, 0xFF);
5153
}
@@ -215,13 +217,13 @@ static void ui_set_time_mode(ui_t *ui, bg_time_mode_t time_mode)
215217
{
216218
rdpq_font_style(font_1x, UI_STYLE_SHADOW, &(rdpq_fontstyle_t){ .color = ui->shadow_color });
217219
rdpq_font_style(font_1x, UI_STYLE_TEXT, &(rdpq_fontstyle_t){ .color = ui->text_color });
218-
rdpq_font_style(font_1x, UI_STYLE_DIM, &(rdpq_fontstyle_t){ .color = UI_DARK_COLOR });
220+
rdpq_font_style(font_1x, UI_STYLE_DIM, &(rdpq_fontstyle_t){ .color = UI_DIM_COLOR });
219221
}
220222
if (font_2x)
221223
{
222224
rdpq_font_style(font_2x, UI_STYLE_SHADOW, &(rdpq_fontstyle_t){ .color = ui->shadow_color });
223225
rdpq_font_style(font_2x, UI_STYLE_TEXT, &(rdpq_fontstyle_t){ .color = ui->text_color });
224-
rdpq_font_style(font_2x, UI_STYLE_DIM, &(rdpq_fontstyle_t){ .color = UI_DARK_COLOR });
226+
rdpq_font_style(font_2x, UI_STYLE_DIM, &(rdpq_fontstyle_t){ .color = UI_DIM_COLOR });
225227
}
226228
}
227229

@@ -436,42 +438,35 @@ static void ui_logo_draw(const ui_t *ui)
436438
.scale_y = gfx->scale,
437439
});
438440

439-
/* Select font and character width based on resolution */
441+
/* Select font based on resolution */
440442
const int font_id = gfx->highres ? FONT_AT01_2X : FONT_AT01;
441-
const int char_w = gfx->highres ? 10 : 5;
442-
const int shadow_offset = gfx->highres ? 2 : 1;
443+
const int shadow_offset = GFX_SCALE(1);
444+
const int line_h = GFX_SCALE(16);
443445

444-
const char *const credit1_str = "Game by .GEARS";
445-
const int credit1_w = strlen(credit1_str) * char_w;
446-
const int credit1_x = center_x - (credit1_w / 2);
447-
const int credit1_y = gfx->height - GFX_SCALE(80);
446+
/* Credits positioned at right side, right-aligned */
447+
const int credits_x = gfx->width / 2;
448+
const int credits_w = gfx->width / 2 - GFX_SCALE(32);
449+
const int credit1_y = gfx->height / 2 + GFX_SCALE(5) + line_h;
450+
const int credit2_y = credit1_y + line_h;
451+
const int version_y = credit2_y + line_h;
448452

453+
const char *const credit1_str = "Game by .GEARS";
449454
const char *const credit2_str = "N64 Port by Meeq";
450-
const int credit2_w = strlen(credit2_str) * char_w;
451-
const int credit2_x = center_x - (credit2_w / 2);
452-
const int credit2_y = gfx->height - GFX_SCALE(62);
453-
454455
const char *const version_str = ROM_VERSION;
455-
const int version_w = strlen(version_str) * char_w;
456-
const int version_x = gfx->width - GFX_SCALE(32) - version_w;
457-
const int version_y = gfx->height - GFX_SCALE(32);
458456

459-
/* Draw a shadow under the text */
460-
rdpq_textparms_t shadow_parms = { .style_id = UI_STYLE_SHADOW };
461-
rdpq_text_print(&shadow_parms, font_id, credit1_x + shadow_offset, credit1_y + shadow_offset, credit1_str);
462-
rdpq_text_print(&shadow_parms, font_id, credit2_x + shadow_offset, credit2_y + shadow_offset, credit2_str);
463-
if (version_w)
464-
{
465-
rdpq_text_print(&shadow_parms, font_id, version_x + shadow_offset, version_y + shadow_offset, version_str);
466-
}
457+
/* Draw shadows then text for credits (right-aligned) */
458+
rdpq_textparms_t shadow_parms = { .style_id = UI_STYLE_SHADOW, .width = credits_w, .align = ALIGN_RIGHT };
459+
rdpq_textparms_t text_parms = { .style_id = UI_STYLE_TEXT, .width = credits_w, .align = ALIGN_RIGHT };
467460

468-
/* Draw the same text on top of the shadow */
469-
rdpq_textparms_t text_parms = { .style_id = UI_STYLE_TEXT };
470-
rdpq_text_print(&text_parms, font_id, credit1_x, credit1_y, credit1_str);
471-
rdpq_text_print(&text_parms, font_id, credit2_x, credit2_y, credit2_str);
472-
if (version_w)
461+
rdpq_text_print(&shadow_parms, font_id, credits_x + shadow_offset, credit1_y + shadow_offset, credit1_str);
462+
rdpq_text_print(&shadow_parms, font_id, credits_x + shadow_offset, credit2_y + shadow_offset, credit2_str);
463+
rdpq_text_print(&text_parms, font_id, credits_x, credit1_y, credit1_str);
464+
rdpq_text_print(&text_parms, font_id, credits_x, credit2_y, credit2_str);
465+
466+
if (version_str[0])
473467
{
474-
rdpq_text_print(&text_parms, font_id, version_x, version_y, version_str);
468+
rdpq_text_print(&shadow_parms, font_id, credits_x + shadow_offset, version_y + shadow_offset, version_str);
469+
rdpq_text_print(&text_parms, font_id, credits_x, version_y, version_str);
475470
}
476471
}
477472

@@ -768,12 +763,10 @@ void ui_menu_tick(ui_t *ui, bird_t *bird, const joypad_buttons_t *buttons)
768763
static void ui_menu_draw(const ui_t *ui)
769764
{
770765
const int font_id = gfx->highres ? FONT_AT01_2X : FONT_AT01;
771-
const int char_w = gfx->highres ? 10 : 5;
772-
const int line_h = gfx->highres ? 16 : 8;
773-
const int shadow_offset = gfx->highres ? 2 : 1;
766+
const int line_h = GFX_SCALE(16);
767+
const int shadow_offset = GFX_SCALE(1);
774768

775-
const int center_x = gfx->width / 2;
776-
const int start_y = gfx->height / 2 - GFX_SCALE(10);
769+
const int start_y = gfx->height / 2 + GFX_SCALE(5);
777770

778771
/* Get current values */
779772
const char *color_str = MENU_COLOR_NAMES[ui->bird_color];
@@ -799,8 +792,7 @@ static void ui_menu_draw(const ui_t *ui)
799792
char line[40];
800793
snprintf(line, sizeof(line), "%s%s", prefix, rows[i]);
801794

802-
const int text_w = strlen(line) * char_w;
803-
const int x = center_x - (text_w / 2);
795+
const int x = GFX_SCALE(32);
804796
const int y = start_y + (i * line_h);
805797

806798
/* Draw shadow then text (dim if not focused) */

version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ fi
1919

2020
# Otherwise use short SHA with optional -dirty suffix
2121
sha=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
22-
echo "${sha}${dirty}"
22+
echo "Build ${sha}${dirty}"

0 commit comments

Comments
 (0)