From 5a47e7a4a8459a32f493b2f2f4c20137e98da1a1 Mon Sep 17 00:00:00 2001 From: RogueMaster Date: Thu, 10 Aug 2023 02:51:22 -0400 Subject: [PATCH] CFW Settings for Commodore 64 Layout for Main Menu --- ReadMe.md | 1 + applications/services/gui/modules/menu.c | 80 +++++++++++++++++++ .../scenes/cfw_app_scene_interface_mainmenu.c | 1 + lib/cfw/cfw.h | 1 + 4 files changed, 83 insertions(+) diff --git a/ReadMe.md b/ReadMe.md index c6ec131c8f6..5c2fbee8207 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -69,6 +69,7 @@ This software is for experimental purposes only and is not meant for any illegal - Updated: [Authenticator/TOTP v4 (By akopachov)](https://github.com/akopachov/flipper-zero_authenticator) - Updated: [Weather Station (By Skorpionm)-OFW](https://github.com/flipperdevices/flipperzero-good-faps/tree/dev/weather_station) [Added Support For Auriol AHFL 433B2 IPX4 sensor (By tomjschwanke)](https://github.com/flipperdevices/flipperzero-good-faps/pull/17) - Added: [Text Viewer 2 (By Willy-JL)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/commit/ae4fc4a54febccb44b010c4025a99c2edef9a7f0) Original by kowalski7cc & kyhwana, new has code borrowed from Archive-Show +- Settings: [CFW Settings for Commodore 64 Layout for Main Menu (By Willy-JL)] diff --git a/applications/services/gui/modules/menu.c b/applications/services/gui/modules/menu.c index c789ddc221d..62cb0a90f32 100644 --- a/applications/services/gui/modules/menu.c +++ b/applications/services/gui/modules/menu.c @@ -273,6 +273,60 @@ static void menu_draw_callback(Canvas* canvas, void* _model) { canvas_set_orientation(canvas, CanvasOrientationHorizontal); break; } + + case MenuStyleC64: { + FuriString* memstr = furi_string_alloc(); + FuriString* name = furi_string_alloc(); + + size_t index; + size_t y_off, x_off; + + canvas_set_font(canvas, FontSecondary); + canvas_draw_str_aligned( + canvas, 64, 0, AlignCenter, AlignTop, "* FLIPPADORE 64 BASIC *"); + + furi_string_printf(memstr, "%d BASIC BYTES FREE", memmgr_get_free_heap()); + + canvas_draw_str_aligned( + canvas, 64, 9, AlignCenter, AlignTop, furi_string_get_cstr(memstr)); + + canvas_set_font(canvas, FontKeyboard); + + for(size_t i = 0; i < 2; i++) { + for(size_t j = 0; j < 5; j++) { + index = i * 5 + j + (position - (position % 10)); + if(index >= items_count) continue; + y_off = (9 * j) + 13; + x_off = 64 * i; + bool selected = index == position; + size_t scroll_counter = menu_scroll_counter(model, selected); + if(selected) { + canvas_draw_box(canvas, x_off, y_off + 4, 64, 9); + canvas_set_color(canvas, ColorWhite); + } + item = MenuItemArray_get(model->items, index); + menu_short_name(item, name); + + FuriString* item_str = furi_string_alloc(); + + furi_string_printf(item_str, "%d.%s", index, furi_string_get_cstr(name)); + + elements_scrollable_text_line( + canvas, x_off + 2, y_off + 12, 64, item_str, scroll_counter, false, false); + + furi_string_free(item_str); + + if(selected) { + canvas_set_color(canvas, ColorBlack); + } + } + } + + furi_string_free(memstr); + furi_string_free(name); + + break; + } default: break; } @@ -517,6 +571,13 @@ static void menu_process_up(Menu* menu) { } vertical_offset = CLAMP(MAX((int)position - 4, 0), MAX((int)count - 8, 0), 0); break; + case MenuStyleC64: + if(position > 0) { + position--; + } else { + position = count - 1; + } + break; default: break; } @@ -557,6 +618,13 @@ static void menu_process_down(Menu* menu) { } vertical_offset = CLAMP(MAX((int)position - 4, 0), MAX((int)count - 8, 0), 0); break; + case MenuStyleC64: + if(position < count - 1) { + position++; + } else { + position = 0; + } + break; default: break; } @@ -603,6 +671,12 @@ static void menu_process_left(Menu* menu) { vertical_offset = count - 8; } break; + case MenuStyleC64: + if((position % 10) < 5) { + position = position + 5; + } else if((position % 10) >= 5) { + position = position - 5; + } default: break; } @@ -654,6 +728,12 @@ static void menu_process_right(Menu* menu) { vertical_offset = 0; } break; + case MenuStyleC64: + if(position >= (count - count) && (position % 10) < 5) { + position = position + 5; + } else if((position % 10) >= 5 && position < count) { + position = position - 5; + } default: break; } diff --git a/applications/settings/cfw_app/scenes/cfw_app_scene_interface_mainmenu.c b/applications/settings/cfw_app/scenes/cfw_app_scene_interface_mainmenu.c index 4a9baadb743..72cfba09c5f 100644 --- a/applications/settings/cfw_app/scenes/cfw_app_scene_interface_mainmenu.c +++ b/applications/settings/cfw_app/scenes/cfw_app_scene_interface_mainmenu.c @@ -21,6 +21,7 @@ const char* const menu_style_names[MenuStyleCount] = { "DSi", "PS4", "Vertical", + "C64", }; static void cfw_app_scene_interface_mainmenu_menu_style_changed(VariableItem* item) { CfwApp* app = variable_item_get_context(item); diff --git a/lib/cfw/cfw.h b/lib/cfw/cfw.h index ed3cb9a8d3c..65cb9eebe01 100644 --- a/lib/cfw/cfw.h +++ b/lib/cfw/cfw.h @@ -23,6 +23,7 @@ typedef enum { MenuStyleDsi, MenuStylePs4, MenuStyleVertical, + MenuStyleC64, MenuStyleCount, } MenuStyle;