This commit is contained in:
Willy-JL
2023-08-10 00:05:50 +02:00
3 changed files with 79 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ const char* const menu_style_names[MenuStyleCount] = {
"DSi",
"PS4",
"Vertical",
"C64",
};
static void xtreme_app_scene_interface_mainmenu_menu_style_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);

View File

@@ -270,6 +270,57 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {
canvas_set_orientation(canvas, CanvasOrientationHorizontal);
break;
}
case MenuStyleC64: {
FuriString* memstr = 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);
furi_string_free(item_str);
if(selected) {
canvas_set_color(canvas, ColorBlack);
}
}
}
furi_string_free(memstr);
break;
}
default:
break;
}
@@ -512,6 +563,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;
}
@@ -552,6 +610,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;
}
@@ -598,6 +663,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;
}
@@ -649,6 +720,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;
}

View File

@@ -31,6 +31,7 @@ typedef enum {
MenuStyleDsi,
MenuStylePs4,
MenuStyleVertical,
MenuStyleC64,
MenuStyleCount,
} MenuStyle;