mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-19 01:12:33 +00:00
Revert "(RMenu) RMenu cleanups pt. 3"
This reverts commit bcc5f906b62005ab1d50b813a2eed0a73d2cb6d3.
This commit is contained in:
parent
bcc5f906b6
commit
d57484e6eb
@ -16,6 +16,7 @@
|
||||
|
||||
#include "rmenu.h"
|
||||
#include "utils/file_browser.h"
|
||||
#include "utils/menu_stack.h"
|
||||
|
||||
#if defined(__CELLOS_LV2__)
|
||||
#include <sdk_version.h>
|
||||
@ -65,6 +66,7 @@ enum {
|
||||
MENU_ITEM_LAST
|
||||
};
|
||||
|
||||
static rmenu_state_t rmenu_state;
|
||||
|
||||
static bool set_libretro_core_as_launch;
|
||||
|
||||
@ -244,50 +246,6 @@ static void menu_set_default_pos(rmenu_default_positions_t *position)
|
||||
#endif
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint64_t input;
|
||||
uint64_t old_state;
|
||||
#ifdef HAVE_OSKUTIL
|
||||
unsigned osk_param;
|
||||
bool (*osk_init)(void *data);
|
||||
bool (*osk_callback)(void *data);
|
||||
#endif
|
||||
} rmenu_state_t;
|
||||
|
||||
static rmenu_state_t rmenu_state;
|
||||
|
||||
/*============================================================
|
||||
MENU STACK
|
||||
============================================================ */
|
||||
|
||||
static uint8_t menu_stack_enum_array[10];
|
||||
static uint8_t stack_idx = 0;
|
||||
static bool need_refresh = false;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char enum_id;
|
||||
unsigned char category_id;
|
||||
int (*entry)(void *data, void *state);
|
||||
} menu;
|
||||
|
||||
|
||||
static void menu_stack_pop(void)
|
||||
{
|
||||
if(stack_idx > 1)
|
||||
{
|
||||
stack_idx--;
|
||||
need_refresh = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void menu_stack_push(unsigned menu_id)
|
||||
{
|
||||
menu_stack_enum_array[++stack_idx] = menu_id;
|
||||
need_refresh = true;
|
||||
}
|
||||
|
||||
/*============================================================
|
||||
EVENT CALLBACKS (AND RELATED)
|
||||
============================================================ */
|
||||
@ -997,7 +955,7 @@ static void browser_render(void *data)
|
||||
}
|
||||
}
|
||||
|
||||
static int select_file(void *data, void *state)
|
||||
int select_file(void *data, void *state)
|
||||
{
|
||||
char extensions[128];
|
||||
char comment[128];
|
||||
@ -1170,7 +1128,7 @@ static int select_file(void *data, void *state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int select_directory(void *data, void *state)
|
||||
int select_directory(void *data, void *state)
|
||||
{
|
||||
menu *current_menu = (menu*)data;
|
||||
rmenu_state_t *rstate = (rmenu_state_t*)state;
|
||||
@ -2526,7 +2484,7 @@ static int select_setting(void *data, void *state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int select_rom(void *data, void *state)
|
||||
int select_rom(void *data, void *state)
|
||||
{
|
||||
menu *current_menu = (menu*)data;
|
||||
rmenu_state_t *rstate = (rmenu_state_t*)state;
|
||||
@ -2635,7 +2593,7 @@ static int select_rom(void *data, void *state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ingame_menu_resize(void *data, void *state)
|
||||
int ingame_menu_resize(void *data, void *state)
|
||||
{
|
||||
menu *current_menu = (menu*)data;
|
||||
rmenu_state_t *rstate = (rmenu_state_t*)state;
|
||||
@ -2987,7 +2945,7 @@ static int ingame_menu_resize(void *data, void *state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ingame_menu_screenshot(void *data, void *state)
|
||||
int ingame_menu_screenshot(void *data, void *state)
|
||||
{
|
||||
rmenu_state_t *rstate = (rmenu_state_t*)state;
|
||||
|
||||
@ -3015,7 +2973,7 @@ static int ingame_menu_screenshot(void *data, void *state)
|
||||
|
||||
#define MENU_ITEM_SELECTED(index) (menuitem_colors[index])
|
||||
|
||||
static int ingame_menu(void *data, void *state)
|
||||
int ingame_menu(void *data, void *state)
|
||||
{
|
||||
menu *current_menu = (menu*)data;
|
||||
rmenu_state_t *rstate = (rmenu_state_t*)state;
|
||||
@ -3356,7 +3314,7 @@ static int ingame_menu(void *data, void *state)
|
||||
INPUT POLL CALLBACK
|
||||
============================================================ */
|
||||
|
||||
static void menu_input_poll(void *data, void *state)
|
||||
void menu_input_poll(void *data, void *state)
|
||||
{
|
||||
menu *current_menu = (menu*)data;
|
||||
|
||||
@ -3412,7 +3370,7 @@ static void menu_input_poll(void *data, void *state)
|
||||
INPUT PROCESS CALLBACK
|
||||
============================================================ */
|
||||
|
||||
static int menu_input_process(void *data, void *state)
|
||||
int menu_input_process(void *data, void *state)
|
||||
{
|
||||
(void)data;
|
||||
bool quit = false;
|
||||
@ -3467,10 +3425,35 @@ static int menu_input_process(void *data, void *state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*============================================================
|
||||
RESOURCE CALLBACKS
|
||||
============================================================ */
|
||||
|
||||
void init_filebrowser(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
browser = (filebrowser_t*)filebrowser_init(g_extern.console.main_wrap.default_rom_startup_dir, g_extern.system.valid_extensions);
|
||||
tmpBrowser = (filebrowser_t*)filebrowser_init(default_paths.filesystem_root_dir, "");
|
||||
|
||||
menu_stack_push(FILE_BROWSER_MENU);
|
||||
filebrowser_set_root_and_ext(browser, g_extern.system.valid_extensions, g_extern.console.main_wrap.default_rom_startup_dir);
|
||||
filebrowser_set_root_and_ext(tmpBrowser, NULL, default_paths.filesystem_root_dir);
|
||||
}
|
||||
|
||||
void free_filebrowser(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
filebrowser_free(browser);
|
||||
filebrowser_free(tmpBrowser);
|
||||
}
|
||||
|
||||
/*============================================================
|
||||
RMENU API
|
||||
============================================================ */
|
||||
|
||||
|
||||
void menu_init(void)
|
||||
{
|
||||
DEVICE_CAST device_ptr = (DEVICE_CAST)driver.video_data;
|
||||
@ -3478,20 +3461,14 @@ void menu_init(void)
|
||||
rmenu_state.input = 0;
|
||||
rmenu_state.old_state = 0;
|
||||
|
||||
browser = (filebrowser_t*)filebrowser_init(g_extern.console.main_wrap.default_rom_startup_dir, g_extern.system.valid_extensions);
|
||||
tmpBrowser = (filebrowser_t*)filebrowser_init(default_paths.filesystem_root_dir, "");
|
||||
|
||||
menu_stack_push(FILE_BROWSER_MENU);
|
||||
filebrowser_set_root_and_ext(browser, g_extern.system.valid_extensions, g_extern.console.main_wrap.default_rom_startup_dir);
|
||||
filebrowser_set_root_and_ext(tmpBrowser, NULL, default_paths.filesystem_root_dir);
|
||||
init_filebrowser(&rmenu_state);
|
||||
|
||||
device_ptr->ctx_driver->rmenu_init();
|
||||
}
|
||||
|
||||
void menu_free(void)
|
||||
{
|
||||
filebrowser_free(browser);
|
||||
filebrowser_free(tmpBrowser);
|
||||
free_filebrowser(&rmenu_state);
|
||||
}
|
||||
|
||||
bool menu_iterate(void)
|
||||
@ -3506,7 +3483,7 @@ bool menu_iterate(void)
|
||||
if (g_extern.lifecycle_mode_state & (1ULL << MODE_MENU_INGAME))
|
||||
menu_stack_push(INGAME_MENU);
|
||||
|
||||
need_refresh = true;
|
||||
menu_stack_force_refresh();
|
||||
g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU_DRAW);
|
||||
|
||||
#ifndef __CELLOS_LV2__
|
||||
@ -3518,108 +3495,7 @@ bool menu_iterate(void)
|
||||
|
||||
g_extern.frame_count++;
|
||||
|
||||
if(need_refresh)
|
||||
{
|
||||
unsigned menu_id = menu_stack_enum_array[stack_idx];
|
||||
|
||||
switch(menu_id)
|
||||
{
|
||||
case INGAME_MENU:
|
||||
current_menu.enum_id = menu_id;
|
||||
current_menu.category_id = CATEGORY_INGAME_MENU;
|
||||
current_menu.entry = ingame_menu;
|
||||
break;
|
||||
case INGAME_MENU_RESIZE:
|
||||
current_menu.enum_id = INGAME_MENU_RESIZE;
|
||||
current_menu.category_id = CATEGORY_INGAME_MENU;
|
||||
current_menu.entry = ingame_menu_resize;
|
||||
break;
|
||||
case INGAME_MENU_SCREENSHOT:
|
||||
current_menu.enum_id = menu_id;
|
||||
current_menu.category_id = CATEGORY_INGAME_MENU;
|
||||
current_menu.entry = ingame_menu_screenshot;
|
||||
break;
|
||||
case FILE_BROWSER_MENU:
|
||||
current_menu.enum_id = menu_id;
|
||||
current_menu.category_id = CATEGORY_FILEBROWSER;
|
||||
current_menu.entry = select_rom;
|
||||
break;
|
||||
case LIBRETRO_CHOICE:
|
||||
current_menu.enum_id = menu_id;
|
||||
current_menu.category_id = CATEGORY_FILEBROWSER;
|
||||
current_menu.entry = select_file;
|
||||
break;
|
||||
case PRESET_CHOICE:
|
||||
current_menu.enum_id = menu_id;
|
||||
current_menu.category_id = CATEGORY_FILEBROWSER;
|
||||
current_menu.entry = select_file;
|
||||
break;
|
||||
case INPUT_PRESET_CHOICE:
|
||||
current_menu.enum_id = menu_id;
|
||||
current_menu.category_id = CATEGORY_FILEBROWSER;
|
||||
current_menu.entry = select_file;
|
||||
break;
|
||||
case SHADER_CHOICE:
|
||||
current_menu.enum_id = menu_id;
|
||||
current_menu.category_id = CATEGORY_FILEBROWSER;
|
||||
current_menu.entry = select_file;
|
||||
break;
|
||||
case BORDER_CHOICE:
|
||||
current_menu.enum_id = menu_id;
|
||||
current_menu.category_id = CATEGORY_FILEBROWSER;
|
||||
current_menu.entry = select_file;
|
||||
break;
|
||||
case PATH_DEFAULT_ROM_DIR_CHOICE:
|
||||
case PATH_SAVESTATES_DIR_CHOICE:
|
||||
case PATH_SRAM_DIR_CHOICE:
|
||||
#ifdef HAVE_XML
|
||||
case PATH_CHEATS_DIR_CHOICE:
|
||||
#endif
|
||||
case PATH_SYSTEM_DIR_CHOICE:
|
||||
current_menu.enum_id = menu_id;
|
||||
current_menu.category_id = CATEGORY_FILEBROWSER;
|
||||
current_menu.entry = select_directory;
|
||||
break;
|
||||
case GENERAL_VIDEO_MENU:
|
||||
current_menu.enum_id = GENERAL_VIDEO_MENU;
|
||||
current_menu.category_id = CATEGORY_SETTINGS;
|
||||
current_menu.entry = select_setting;
|
||||
break;
|
||||
case GENERAL_AUDIO_MENU:
|
||||
current_menu.enum_id = GENERAL_AUDIO_MENU;
|
||||
current_menu.category_id = CATEGORY_SETTINGS;
|
||||
current_menu.entry = select_setting;
|
||||
break;
|
||||
case EMU_GENERAL_MENU:
|
||||
current_menu.enum_id = EMU_GENERAL_MENU;
|
||||
current_menu.category_id = CATEGORY_SETTINGS;
|
||||
current_menu.entry = select_setting;
|
||||
break;
|
||||
case EMU_VIDEO_MENU:
|
||||
current_menu.enum_id = EMU_VIDEO_MENU;
|
||||
current_menu.category_id = CATEGORY_SETTINGS;
|
||||
current_menu.entry = select_setting;
|
||||
break;
|
||||
case EMU_AUDIO_MENU:
|
||||
current_menu.enum_id = EMU_AUDIO_MENU;
|
||||
current_menu.category_id = CATEGORY_SETTINGS;
|
||||
current_menu.entry = select_setting;
|
||||
break;
|
||||
case PATH_MENU:
|
||||
current_menu.enum_id = PATH_MENU;
|
||||
current_menu.category_id = CATEGORY_SETTINGS;
|
||||
current_menu.entry = select_setting;
|
||||
break;
|
||||
case CONTROLS_MENU:
|
||||
current_menu.enum_id = CONTROLS_MENU;
|
||||
current_menu.category_id = CATEGORY_SETTINGS;
|
||||
current_menu.entry = select_setting;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
need_refresh = false;
|
||||
}
|
||||
menu_stack_get_current_ptr(¤t_menu);
|
||||
|
||||
rmenu_default_positions_t default_pos;
|
||||
menu_set_default_pos(&default_pos);
|
||||
|
152
frontend/menu/utils/menu_stack.c
Normal file
152
frontend/menu/utils/menu_stack.c
Normal file
@ -0,0 +1,152 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2013 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "menu_stack.h"
|
||||
|
||||
static unsigned char menu_stack_enum_array[10];
|
||||
static unsigned stack_idx = 0;
|
||||
static bool need_refresh = false;
|
||||
|
||||
static void menu_stack_pop(void)
|
||||
{
|
||||
if(stack_idx > 1)
|
||||
{
|
||||
stack_idx--;
|
||||
need_refresh = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void menu_stack_force_refresh(void)
|
||||
{
|
||||
need_refresh = true;
|
||||
}
|
||||
|
||||
static void menu_stack_push(unsigned menu_id)
|
||||
{
|
||||
menu_stack_enum_array[++stack_idx] = menu_id;
|
||||
need_refresh = true;
|
||||
}
|
||||
|
||||
static void menu_stack_get_current_ptr(menu *current_menu)
|
||||
{
|
||||
if(!need_refresh)
|
||||
return;
|
||||
|
||||
unsigned menu_id = menu_stack_enum_array[stack_idx];
|
||||
|
||||
switch(menu_id)
|
||||
{
|
||||
case INGAME_MENU:
|
||||
current_menu->enum_id = menu_id;
|
||||
current_menu->category_id = CATEGORY_INGAME_MENU;
|
||||
current_menu->entry = ingame_menu;
|
||||
break;
|
||||
case INGAME_MENU_RESIZE:
|
||||
current_menu->enum_id = INGAME_MENU_RESIZE;
|
||||
current_menu->category_id = CATEGORY_INGAME_MENU;
|
||||
current_menu->entry = ingame_menu_resize;
|
||||
break;
|
||||
case INGAME_MENU_SCREENSHOT:
|
||||
current_menu->enum_id = menu_id;
|
||||
current_menu->category_id = CATEGORY_INGAME_MENU;
|
||||
current_menu->entry = ingame_menu_screenshot;
|
||||
break;
|
||||
case FILE_BROWSER_MENU:
|
||||
current_menu->enum_id = menu_id;
|
||||
current_menu->category_id = CATEGORY_FILEBROWSER;
|
||||
current_menu->entry = select_rom;
|
||||
break;
|
||||
case LIBRETRO_CHOICE:
|
||||
current_menu->enum_id = menu_id;
|
||||
current_menu->category_id = CATEGORY_FILEBROWSER;
|
||||
current_menu->entry = select_file;
|
||||
break;
|
||||
case PRESET_CHOICE:
|
||||
current_menu->enum_id = menu_id;
|
||||
current_menu->category_id = CATEGORY_FILEBROWSER;
|
||||
current_menu->entry = select_file;
|
||||
break;
|
||||
case INPUT_PRESET_CHOICE:
|
||||
current_menu->enum_id = menu_id;
|
||||
current_menu->category_id = CATEGORY_FILEBROWSER;
|
||||
current_menu->entry = select_file;
|
||||
break;
|
||||
case SHADER_CHOICE:
|
||||
current_menu->enum_id = menu_id;
|
||||
current_menu->category_id = CATEGORY_FILEBROWSER;
|
||||
current_menu->entry = select_file;
|
||||
break;
|
||||
case BORDER_CHOICE:
|
||||
current_menu->enum_id = menu_id;
|
||||
current_menu->category_id = CATEGORY_FILEBROWSER;
|
||||
current_menu->entry = select_file;
|
||||
break;
|
||||
case PATH_DEFAULT_ROM_DIR_CHOICE:
|
||||
case PATH_SAVESTATES_DIR_CHOICE:
|
||||
case PATH_SRAM_DIR_CHOICE:
|
||||
#ifdef HAVE_XML
|
||||
case PATH_CHEATS_DIR_CHOICE:
|
||||
#endif
|
||||
case PATH_SYSTEM_DIR_CHOICE:
|
||||
current_menu->enum_id = menu_id;
|
||||
current_menu->category_id = CATEGORY_FILEBROWSER;
|
||||
current_menu->entry = select_directory;
|
||||
break;
|
||||
case GENERAL_VIDEO_MENU:
|
||||
current_menu->enum_id = GENERAL_VIDEO_MENU;
|
||||
current_menu->category_id = CATEGORY_SETTINGS;
|
||||
current_menu->entry = select_setting;
|
||||
break;
|
||||
case GENERAL_AUDIO_MENU:
|
||||
current_menu->enum_id = GENERAL_AUDIO_MENU;
|
||||
current_menu->category_id = CATEGORY_SETTINGS;
|
||||
current_menu->entry = select_setting;
|
||||
break;
|
||||
case EMU_GENERAL_MENU:
|
||||
current_menu->enum_id = EMU_GENERAL_MENU;
|
||||
current_menu->category_id = CATEGORY_SETTINGS;
|
||||
current_menu->entry = select_setting;
|
||||
break;
|
||||
case EMU_VIDEO_MENU:
|
||||
current_menu->enum_id = EMU_VIDEO_MENU;
|
||||
current_menu->category_id = CATEGORY_SETTINGS;
|
||||
current_menu->entry = select_setting;
|
||||
break;
|
||||
case EMU_AUDIO_MENU:
|
||||
current_menu->enum_id = EMU_AUDIO_MENU;
|
||||
current_menu->category_id = CATEGORY_SETTINGS;
|
||||
current_menu->entry = select_setting;
|
||||
break;
|
||||
case PATH_MENU:
|
||||
current_menu->enum_id = PATH_MENU;
|
||||
current_menu->category_id = CATEGORY_SETTINGS;
|
||||
current_menu->entry = select_setting;
|
||||
break;
|
||||
case CONTROLS_MENU:
|
||||
current_menu->enum_id = CONTROLS_MENU;
|
||||
current_menu->category_id = CATEGORY_SETTINGS;
|
||||
current_menu->entry = select_setting;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
need_refresh = false;
|
||||
}
|
47
frontend/menu/utils/menu_stack.h
Normal file
47
frontend/menu/utils/menu_stack.h
Normal file
@ -0,0 +1,47 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2013 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _RMENU_STACK_H_
|
||||
#define _RMENU_STACK_H_
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char enum_id;
|
||||
unsigned char category_id;
|
||||
int (*entry)(void *data, void *state);
|
||||
} menu;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint64_t input;
|
||||
uint64_t old_state;
|
||||
#ifdef HAVE_OSKUTIL
|
||||
unsigned osk_param;
|
||||
bool (*osk_init)(void *data);
|
||||
bool (*osk_callback)(void *data);
|
||||
#endif
|
||||
} rmenu_state_t;
|
||||
|
||||
// iterate forward declarations
|
||||
int select_file(void *data, void *state);
|
||||
int select_directory(void *data, void *state);
|
||||
int select_setting(void *data, void *state);
|
||||
int select_rom(void *data, void *state);
|
||||
int ingame_menu_resize(void *data, void *state);
|
||||
int ingame_menu_screenshot(void *data, void *state);
|
||||
int ingame_menu(void *data, void *state);
|
||||
|
||||
#endif
|
@ -434,6 +434,7 @@ SCREENSHOTS
|
||||
MENU
|
||||
============================================================ */
|
||||
#if defined(HAVE_RMENU_GUI)
|
||||
#include "../frontend/menu/utils/menu_stack.c"
|
||||
#include "../frontend/menu/rmenu.c"
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user