From 6894ea35fd4dabd3ff3d9f68a49bf8c124aa525b Mon Sep 17 00:00:00 2001 From: Alex Duchesne Date: Thu, 22 Apr 2021 15:32:26 -0400 Subject: [PATCH] Launcher: Truly fixed font selection scrolling now... --- components/retro-go/rg_gui.c | 11 +++++++---- components/retro-go/rg_gui.h | 2 +- launcher/main/main.c | 5 +++-- retro-go.code-workspace | 1 + 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/components/retro-go/rg_gui.c b/components/retro-go/rg_gui.c index 0832685d..717dc86f 100644 --- a/components/retro-go/rg_gui.c +++ b/components/retro-go/rg_gui.c @@ -119,12 +119,15 @@ static rg_glyph_t get_glyph(const rg_font_t *font, int points, int c) return out; } -bool rg_gui_set_font_type(uint8_t type) +bool rg_gui_set_font_type(int type) { - // if (type > fonts_count - 1) - // return false; + if (type < 0) + type += fonts_count; - font_info.type = type % fonts_count; + if (type < 0 || type > fonts_count - 1) + return false; + + font_info.type = type; font_info.font = fonts[font_info.type]; font_info.points = (font_info.type < 3) ? (8 + font_info.type * 4) : font_info.font->height; font_info.width = RG_MAX(font_info.font->width, 4); diff --git a/components/retro-go/rg_gui.h b/components/retro-go/rg_gui.h index 98f04eb1..f7ad1fad 100644 --- a/components/retro-go/rg_gui.h +++ b/components/retro-go/rg_gui.h @@ -101,7 +101,7 @@ struct dialog_option_s void rg_gui_init(void); bool rg_gui_set_theme(const dialog_theme_t *new_theme); -bool rg_gui_set_font_type(uint8_t type); +bool rg_gui_set_font_type(int type); font_info_t rg_gui_get_font_info(void); rg_rect_t rg_gui_calc_text_size(const char *text, uint32_t flags); rg_rect_t rg_gui_draw_text(int x_pos, int y_pos, int width, const char *text, uint16_t color_fg, uint16_t color_bg, uint32_t flags); diff --git a/launcher/main/main.c b/launcher/main/main.c index cfb5159f..1250e0b2 100644 --- a/launcher/main/main.c +++ b/launcher/main/main.c @@ -21,12 +21,13 @@ static dialog_return_t font_type_cb(dialog_option_t *option, dialog_event_t even font_info_t info = rg_gui_get_font_info(); if (event == RG_DIALOG_PREV) { - rg_gui_set_font_type(info.type > 0 ? info.type - 1 : 0xFF); + rg_gui_set_font_type((int)info.type - 1); info = rg_gui_get_font_info(); gui_redraw(); } if (event == RG_DIALOG_NEXT) { - rg_gui_set_font_type(rg_gui_get_font_info().type + 1); + if (!rg_gui_set_font_type((int)info.type + 1)) + rg_gui_set_font_type(0); info = rg_gui_get_font_info(); gui_redraw(); } diff --git a/retro-go.code-workspace b/retro-go.code-workspace index 84920f6d..b67baebc 100644 --- a/retro-go.code-workspace +++ b/retro-go.code-workspace @@ -61,6 +61,7 @@ "smsplusgx", "supergraphx" ], + "files.trimTrailingWhitespace": true, "files.exclude": { "**/build": true, "root": true