From cef4a004f74fecca7556ea7aeb947897a1f392b5 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 30 Jul 2023 01:29:14 +0200 Subject: [PATCH] Add PS4 menu style --- .../xtreme_app_scene_interface_mainmenu.c | 1 + applications/services/gui/modules/menu.c | 52 +++++++++++++++++++ lib/xtreme/xtreme.h | 1 + 3 files changed, 54 insertions(+) diff --git a/applications/main/xtreme_app/scenes/xtreme_app_scene_interface_mainmenu.c b/applications/main/xtreme_app/scenes/xtreme_app_scene_interface_mainmenu.c index 8e2ae38dd..099d8b6ed 100644 --- a/applications/main/xtreme_app/scenes/xtreme_app_scene_interface_mainmenu.c +++ b/applications/main/xtreme_app/scenes/xtreme_app_scene_interface_mainmenu.c @@ -18,6 +18,7 @@ const char* const menu_style_names[MenuStyleCount] = { "List", "Wii", "DSi", + "PS4", "Vertical", }; static void xtreme_app_scene_interface_mainmenu_menu_style_changed(VariableItem* item) { diff --git a/applications/services/gui/modules/menu.c b/applications/services/gui/modules/menu.c index 2a19af825..5929e6055 100644 --- a/applications/services/gui/modules/menu.c +++ b/applications/services/gui/modules/menu.c @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include #include #include @@ -191,6 +193,54 @@ static void menu_draw_callback(Canvas* canvas, void* _model) { elements_scrollbar_horizontal(canvas, 0, 64, 128, position, items_count); break; } + case MenuStylePs4: { + canvas_set_font(canvas, FontSecondary); + canvas_draw_str_aligned( + canvas, 1, 1, AlignLeft, AlignTop, furi_hal_version_get_name_ptr()); + char str[10]; + Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN); + snprintf(str, 10, "Level %i", dolphin_get_level(dolphin->state->data.icounter)); + furi_record_close(RECORD_DOLPHIN); + canvas_draw_str_aligned(canvas, 127, 1, AlignRight, AlignTop, str); + for(int8_t i = -1; i <= 4; i++) { + shift_position = position + i; + if(shift_position >= items_count) continue; + item = MenuItemArray_get(model->items, shift_position); + size_t width = 20; + size_t height = 20; + size_t pos_x = 36; + size_t pos_y = 27; + if(i == 0) { + width += 10; + height += 10; + pos_y += 2; + canvas_draw_box(canvas, pos_x - width / 2, pos_y + height / 2, width, 9); + canvas_set_color(canvas, ColorWhite); + canvas_set_font(canvas, FontBatteryPercent); + canvas_draw_str_aligned( + canvas, pos_x, pos_y + height / 2 + 1, AlignCenter, AlignTop, "Start"); + + canvas_set_color(canvas, ColorBlack); + canvas_set_font(canvas, FontSecondary); + size_t scroll_counter = menu_scroll_counter(model, true); + elements_scrollable_text_line_str( + canvas, + pos_x + width / 2 + 2, + pos_y + height / 2 + 7, + 74, + item->label, + scroll_counter, + false, + false); + } else { + pos_x += (width + 1) * i + (i < 0 ? -6 : 6); + } + canvas_draw_frame(canvas, pos_x - width / 2, pos_y - height / 2, width, height); + menu_centered_icon(canvas, item, pos_x - 7, pos_y - 7, 14, 14); + } + elements_scrollbar_horizontal(canvas, 0, 64, 128, position, items_count); + break; + } case MenuStyleVertical: { canvas_set_orientation(canvas, CanvasOrientationVertical); FuriString* name = furi_string_alloc(); @@ -533,6 +583,7 @@ static void menu_process_left(Menu* menu) { vertical_offset = CLAMP(MAX((int)position - 4, 0), MAX((int)count - 8, 0), 0); break; case MenuStyleDsi: + case MenuStylePs4: case MenuStyleVertical: if(position > 0) { position--; @@ -583,6 +634,7 @@ static void menu_process_right(Menu* menu) { vertical_offset = CLAMP(MAX((int)position - 4, 0), MAX((int)count - 8, 0), 0); break; case MenuStyleDsi: + case MenuStylePs4: case MenuStyleVertical: if(position < count - 1) { position++; diff --git a/lib/xtreme/xtreme.h b/lib/xtreme/xtreme.h index 0c8b41f78..c60c4364f 100644 --- a/lib/xtreme/xtreme.h +++ b/lib/xtreme/xtreme.h @@ -29,6 +29,7 @@ typedef enum { MenuStyleList, MenuStyleWii, MenuStyleDsi, + MenuStylePs4, MenuStyleVertical, MenuStyleCount, } MenuStyle;