Skip to content

Commit

Permalink
CFW Settings for Commodore 64 Layout for Main Menu
Browse files Browse the repository at this point in the history
  • Loading branch information
RogueMaster committed Aug 10, 2023
1 parent d8b63da commit 5a47e7a
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions ReadMe.md
Expand Up @@ -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)]

<a name="release">

Expand Down
80 changes: 80 additions & 0 deletions applications/services/gui/modules/menu.c
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions lib/cfw/cfw.h
Expand Up @@ -23,6 +23,7 @@ typedef enum {
MenuStyleDsi,
MenuStylePs4,
MenuStyleVertical,
MenuStyleC64,
MenuStyleCount,
} MenuStyle;

Expand Down

0 comments on commit 5a47e7a

Please sign in to comment.