From 9dad33dcfe495fcf07f3290b2eb77d44153fd033 Mon Sep 17 00:00:00 2001 From: Vincent-FK Date: Sun, 13 Dec 2020 15:28:45 +0100 Subject: [PATCH] added screen to change launcher in Menu --- RetroFE/Source/Menu/MenuMode.cpp | 53 ++++++++++++++++++++++++++++++++ RetroFE/Source/Menu/MenuMode.h | 23 ++++++++------ 2 files changed, 66 insertions(+), 10 deletions(-) diff --git a/RetroFE/Source/Menu/MenuMode.cpp b/RetroFE/Source/Menu/MenuMode.cpp index 72552b3..2198f98 100755 --- a/RetroFE/Source/Menu/MenuMode.cpp +++ b/RetroFE/Source/Menu/MenuMode.cpp @@ -334,6 +334,19 @@ void MenuMode::add_menu_zone(ENUM_MENU_TYPE menu_type){ text_pos.y = surface->h - MENU_ZONE_HEIGHT/2 - text_surface->h/2 - padding_y_from_center_menu_zone*2; SDL_BlitSurface(text_surface, NULL, surface, &text_pos); break; + case MENU_TYPE_LAUNCHER: + MENU_DEBUG_PRINTF("Init MENU_TYPE_LAUNCHER\n"); + /// ------ Text ------ + text_surface = TTF_RenderText_Blended(menu_title_font, "SET LAUNCHER", text_color); + text_pos.x = (surface->w - MENU_ZONE_WIDTH)/2 + (MENU_ZONE_WIDTH - text_surface->w)/2; + text_pos.y = surface->h - MENU_ZONE_HEIGHT/2 - text_surface->h/2 - padding_y_from_center_menu_zone*2; + SDL_BlitSurface(text_surface, NULL, surface, &text_pos); + /// ------ Text ------ + text_surface = TTF_RenderText_Blended(menu_title_font, "GMENU2X", text_color); + text_pos.x = (surface->w - MENU_ZONE_WIDTH)/2 + (MENU_ZONE_WIDTH - text_surface->w)/2; + text_pos.y = surface->h - MENU_ZONE_HEIGHT/2 - text_surface->h/2; + SDL_BlitSurface(text_surface, NULL, surface, &text_pos); + break; case MENU_TYPE_POWERDOWN: MENU_DEBUG_PRINTF("Init MENU_TYPE_POWERDOWN\n"); /// ------ Text ------ @@ -368,6 +381,8 @@ void MenuMode::init_menu_zones(){ add_menu_zone(MENU_TYPE_USB); /// Init Theme Menu add_menu_zone(MENU_TYPE_THEME); + /// Init Launcher Menu + add_menu_zone(MENU_TYPE_LAUNCHER); /// Init Powerdown Menu add_menu_zone(MENU_TYPE_POWERDOWN); } @@ -622,6 +637,23 @@ void MenuMode::menu_screen_refresh(int menuItem, int prevItem, int scroll, uint8 } break; + case MENU_TYPE_LAUNCHER: + if(menu_action){ + sprintf(text_tmp, "In progress..."); + text_surface = TTF_RenderText_Blended(menu_info_font, text_tmp, text_color); + text_pos.x = (virtual_hw_screen->w - MENU_ZONE_WIDTH)/2 + (MENU_ZONE_WIDTH - text_surface->w)/2; + text_pos.y = virtual_hw_screen->h - MENU_ZONE_HEIGHT/2 - text_surface->h/2 + 2*padding_y_from_center_menu_zone; + SDL_BlitSurface(text_surface, NULL, virtual_hw_screen, &text_pos); + } + else if(menu_confirmation){ + sprintf(text_tmp, "Are you sure ?"); + text_surface = TTF_RenderText_Blended(menu_info_font, text_tmp, text_color); + text_pos.x = (virtual_hw_screen->w - MENU_ZONE_WIDTH)/2 + (MENU_ZONE_WIDTH - text_surface->w)/2; + text_pos.y = virtual_hw_screen->h - MENU_ZONE_HEIGHT/2 - text_surface->h/2 + 2*padding_y_from_center_menu_zone; + SDL_BlitSurface(text_surface, NULL, virtual_hw_screen, &text_pos); + } + break; + case MENU_TYPE_EXIT: case MENU_TYPE_POWERDOWN: if(menu_action){ @@ -1009,6 +1041,27 @@ int MenuMode::launch( ) screen_refresh = 1; } } + else if(idx_menus[menuItem] == MENU_TYPE_LAUNCHER){ + if(menu_confirmation){ + MENU_DEBUG_PRINTF("Lancher change - confirmed\n"); + + /// ------ Refresh Screen ------- + menu_screen_refresh(menuItem, prevItem, scroll, menu_confirmation, 1); + + /// ----- Shell cmd ---- + MENU_DEBUG_PRINTF("Running command: %s\n", SHELL_CMD_SET_LAUNCHER_GMENU2X); + Utils::executeRawPath(SHELL_CMD_SET_LAUNCHER_GMENU2X); + + stop_menu_loop = 1; + returnCode = MENU_RETURN_EXIT; + } + else{ + MENU_DEBUG_PRINTF("Launcher change - asking confirmation\n"); + menu_confirmation = 1; + /// ------ Refresh screen ------ + screen_refresh = 1; + } + } else if(idx_menus[menuItem] == MENU_TYPE_EXIT){ MENU_DEBUG_PRINTF("Exit game\n"); if(menu_confirmation){ diff --git a/RetroFE/Source/Menu/MenuMode.h b/RetroFE/Source/Menu/MenuMode.h index 5c905cf..ca20408 100755 --- a/RetroFE/Source/Menu/MenuMode.h +++ b/RetroFE/Source/Menu/MenuMode.h @@ -13,6 +13,7 @@ typedef enum{ MENU_TYPE_ASPECT_RATIO, MENU_TYPE_USB, MENU_TYPE_THEME, + MENU_TYPE_LAUNCHER, MENU_TYPE_EXIT, MENU_TYPE_POWERDOWN, NB_MENU_TYPES, @@ -43,16 +44,18 @@ typedef enum {ASPECT_RATIOS} ENUM_ASPECT_RATIOS_TYPES; #define STEP_CHANGE_BRIGHTNESS 10 ////------ Menu commands ------- -#define SHELL_CMD_VOLUME_GET "volume_get" -#define SHELL_CMD_VOLUME_SET "volume_set" -#define SHELL_CMD_BRIGHTNESS_GET "brightness_get" -#define SHELL_CMD_BRIGHTNESS_SET "brightness_set" -#define SHELL_CMD_USB_DATA_CONNECTED "is_usb_data_connected" -#define SHELL_CMD_USB_MOUNT "share start" -#define SHELL_CMD_USB_UNMOUNT "share stop" -#define SHELL_CMD_USB_CHECK_IS_SHARING "share is_sharing" -#define SHELL_CMD_POWERDOWN "shutdown_funkey" -#define SHELL_CMD_SCHEDULE_POWERDOWN "sched_shutdown" +#define SHELL_CMD_VOLUME_GET "volume_get" +#define SHELL_CMD_VOLUME_SET "volume_set" +#define SHELL_CMD_BRIGHTNESS_GET "brightness_get" +#define SHELL_CMD_BRIGHTNESS_SET "brightness_set" +#define SHELL_CMD_USB_DATA_CONNECTED "is_usb_data_connected" +#define SHELL_CMD_USB_MOUNT "share start" +#define SHELL_CMD_USB_UNMOUNT "share stop" +#define SHELL_CMD_USB_CHECK_IS_SHARING "share is_sharing" +#define SHELL_CMD_POWERDOWN "shutdown_funkey" +#define SHELL_CMD_SCHEDULE_POWERDOWN "sched_shutdown" +#define SHELL_CMD_SET_LAUNCHER_GMENU2X "set_launcher gmenu2x" +#define SHELL_CMD_SET_LAUNCHER_RETROFE "set_launcher retrofe" class MenuMode {