mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 05:48:35 -07:00
Add Commodore 64 style menu
This commit is contained in:
@@ -20,6 +20,7 @@ const char* const menu_style_names[MenuStyleCount] = {
|
|||||||
"DSi",
|
"DSi",
|
||||||
"PS4",
|
"PS4",
|
||||||
"Vertical",
|
"Vertical",
|
||||||
|
"C64",
|
||||||
};
|
};
|
||||||
static void xtreme_app_scene_interface_mainmenu_menu_style_changed(VariableItem* item) {
|
static void xtreme_app_scene_interface_mainmenu_menu_style_changed(VariableItem* item) {
|
||||||
XtremeApp* app = variable_item_get_context(item);
|
XtremeApp* app = variable_item_get_context(item);
|
||||||
|
|||||||
@@ -271,6 +271,59 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {
|
|||||||
canvas_set_orientation(canvas, CanvasOrientationHorizontal);
|
canvas_set_orientation(canvas, CanvasOrientationHorizontal);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case MenuStyleC64: {
|
||||||
|
FuriString* name = furi_string_alloc();
|
||||||
|
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);
|
||||||
|
furi_string_free(name);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -512,6 +565,13 @@ static void menu_process_up(Menu* menu) {
|
|||||||
}
|
}
|
||||||
vertical_offset = CLAMP(MAX((int)position - 4, 0), MAX((int)count - 8, 0), 0);
|
vertical_offset = CLAMP(MAX((int)position - 4, 0), MAX((int)count - 8, 0), 0);
|
||||||
break;
|
break;
|
||||||
|
case MenuStyleC64:
|
||||||
|
if(position > 0) {
|
||||||
|
position--;
|
||||||
|
} else {
|
||||||
|
position = count - 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -552,6 +612,13 @@ static void menu_process_down(Menu* menu) {
|
|||||||
}
|
}
|
||||||
vertical_offset = CLAMP(MAX((int)position - 4, 0), MAX((int)count - 8, 0), 0);
|
vertical_offset = CLAMP(MAX((int)position - 4, 0), MAX((int)count - 8, 0), 0);
|
||||||
break;
|
break;
|
||||||
|
case MenuStyleC64:
|
||||||
|
if(position < count - 1) {
|
||||||
|
position++;
|
||||||
|
} else {
|
||||||
|
position = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -598,6 +665,12 @@ static void menu_process_left(Menu* menu) {
|
|||||||
vertical_offset = count - 8;
|
vertical_offset = count - 8;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case MenuStyleC64:
|
||||||
|
if((position % 10) < 5) {
|
||||||
|
position = position + 5;
|
||||||
|
} else if((position % 10) >= 5) {
|
||||||
|
position = position - 5;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -649,6 +722,12 @@ static void menu_process_right(Menu* menu) {
|
|||||||
vertical_offset = 0;
|
vertical_offset = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case MenuStyleC64:
|
||||||
|
if(position >= (count - count) && (position % 10) < 5) {
|
||||||
|
position = position + 5;
|
||||||
|
} else if((position % 10) >= 5 && position < count) {
|
||||||
|
position = position - 5;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ typedef enum {
|
|||||||
MenuStyleDsi,
|
MenuStyleDsi,
|
||||||
MenuStylePs4,
|
MenuStylePs4,
|
||||||
MenuStyleVertical,
|
MenuStyleVertical,
|
||||||
|
MenuStyleC64,
|
||||||
MenuStyleCount,
|
MenuStyleCount,
|
||||||
} MenuStyle;
|
} MenuStyle;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user