2015-10-03 01:15:47 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2017-01-22 12:40:32 +00:00
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2015-10-03 01:15:47 +00:00
|
|
|
* Copyright (C) 2012-2015 - Michael Lelli
|
2017-01-22 12:40:32 +00:00
|
|
|
* Copyright (C) 2016-2017 - Brad Parker
|
2015-10-03 01:15:47 +00:00
|
|
|
*
|
|
|
|
* 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 <compat/strl.h>
|
2015-12-26 06:37:44 +00:00
|
|
|
#include <string/stdstring.h>
|
2015-10-03 01:15:47 +00:00
|
|
|
|
|
|
|
#include "menu_generic.h"
|
|
|
|
|
2015-12-06 16:55:27 +00:00
|
|
|
#include "../menu_driver.h"
|
2016-09-15 13:57:25 +00:00
|
|
|
#include "../widgets/menu_dialog.h"
|
2016-09-15 18:35:39 +00:00
|
|
|
#include "../widgets/menu_input_bind_dialog.h"
|
2015-10-03 01:15:47 +00:00
|
|
|
|
2015-11-23 11:03:38 +00:00
|
|
|
#include "../../verbosity.h"
|
2016-09-05 05:04:15 +00:00
|
|
|
#include "../../content.h"
|
|
|
|
#include "../../retroarch.h"
|
2015-10-03 02:21:38 +00:00
|
|
|
|
|
|
|
static enum action_iterate_type action_iterate_type(uint32_t hash)
|
|
|
|
{
|
|
|
|
switch (hash)
|
|
|
|
{
|
|
|
|
case MENU_LABEL_HELP:
|
|
|
|
case MENU_LABEL_HELP_CONTROLS:
|
|
|
|
case MENU_LABEL_HELP_WHAT_IS_A_CORE:
|
|
|
|
case MENU_LABEL_HELP_LOADING_CONTENT:
|
|
|
|
case MENU_LABEL_HELP_CHANGE_VIRTUAL_GAMEPAD:
|
2015-11-08 17:52:04 +00:00
|
|
|
case MENU_LABEL_CHEEVOS_DESCRIPTION:
|
2015-10-03 02:21:38 +00:00
|
|
|
case MENU_LABEL_HELP_AUDIO_VIDEO_TROUBLESHOOTING:
|
|
|
|
case MENU_LABEL_HELP_SCANNING_CONTENT:
|
|
|
|
return ITERATE_TYPE_HELP;
|
|
|
|
case MENU_LABEL_INFO_SCREEN:
|
|
|
|
return ITERATE_TYPE_INFO;
|
|
|
|
case MENU_LABEL_CUSTOM_BIND:
|
|
|
|
case MENU_LABEL_CUSTOM_BIND_ALL:
|
|
|
|
case MENU_LABEL_CUSTOM_BIND_DEFAULTS:
|
|
|
|
return ITERATE_TYPE_BIND;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ITERATE_TYPE_DEFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* menu_iterate:
|
|
|
|
* @input : input sample for this frame
|
|
|
|
* @old_input : input sample of the previous frame
|
|
|
|
* @trigger_input : difference' input sample - difference
|
|
|
|
* between 'input' and 'old_input'
|
|
|
|
*
|
|
|
|
* Runs RetroArch menu for one frame.
|
|
|
|
*
|
2016-09-05 15:35:27 +00:00
|
|
|
* Returns: 0 on success, -1 if we need to quit out of the loop.
|
2015-10-03 02:21:38 +00:00
|
|
|
**/
|
2015-12-10 18:38:46 +00:00
|
|
|
int generic_menu_iterate(void *data, void *userdata, enum menu_action action)
|
2015-10-03 02:21:38 +00:00
|
|
|
{
|
|
|
|
enum action_iterate_type iterate_type;
|
2016-07-26 13:12:20 +00:00
|
|
|
unsigned file_type = 0;
|
2016-06-17 14:08:47 +00:00
|
|
|
int ret = 0;
|
|
|
|
uint32_t hash = 0;
|
2016-06-19 22:31:13 +00:00
|
|
|
enum msg_hash_enums enum_idx = MSG_UNKNOWN;
|
2016-12-04 03:43:53 +00:00
|
|
|
const char *label = NULL;
|
2016-06-17 14:08:47 +00:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
2017-04-23 12:31:49 +00:00
|
|
|
size_t selection = menu_navigation_get_selection();
|
2016-06-17 14:08:47 +00:00
|
|
|
|
2016-07-26 13:12:20 +00:00
|
|
|
menu_entries_get_last_stack(NULL, &label, &file_type, &enum_idx, NULL);
|
2015-10-03 02:21:38 +00:00
|
|
|
|
2015-10-17 17:21:18 +00:00
|
|
|
if (!menu)
|
2015-10-03 02:21:38 +00:00
|
|
|
return 0;
|
|
|
|
|
2017-09-28 06:55:40 +00:00
|
|
|
menu->menu_state_msg[0] = '\0';
|
2017-02-24 03:53:54 +00:00
|
|
|
|
|
|
|
if (!string_is_empty(label))
|
|
|
|
hash = msg_hash_calculate(label);
|
2015-10-03 02:21:38 +00:00
|
|
|
iterate_type = action_iterate_type(hash);
|
|
|
|
|
2016-10-30 01:58:22 +00:00
|
|
|
menu_driver_set_binding_state(iterate_type == ITERATE_TYPE_BIND);
|
|
|
|
|
2015-12-11 20:41:59 +00:00
|
|
|
if ( action != MENU_ACTION_NOOP
|
2016-09-05 15:35:27 +00:00
|
|
|
|| menu_entries_ctl(MENU_ENTRIES_CTL_NEEDS_REFRESH, NULL)
|
2016-05-08 10:33:28 +00:00
|
|
|
|| menu_display_get_update_pending())
|
2015-10-03 02:21:38 +00:00
|
|
|
{
|
2015-10-11 10:58:21 +00:00
|
|
|
BIT64_SET(menu->state, MENU_STATE_RENDER_FRAMEBUFFER);
|
2015-10-03 02:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (iterate_type)
|
|
|
|
{
|
|
|
|
case ITERATE_TYPE_HELP:
|
2016-09-15 14:07:20 +00:00
|
|
|
ret = menu_dialog_iterate(
|
2017-09-28 06:55:40 +00:00
|
|
|
menu->menu_state_msg, sizeof(menu->menu_state_msg), label);
|
2015-10-03 02:21:38 +00:00
|
|
|
BIT64_SET(menu->state, MENU_STATE_RENDER_MESSAGEBOX);
|
|
|
|
BIT64_SET(menu->state, MENU_STATE_POST_ITERATE);
|
2016-09-05 05:04:15 +00:00
|
|
|
if (ret == 1 || action == MENU_ACTION_OK)
|
|
|
|
{
|
2016-09-02 03:14:09 +00:00
|
|
|
BIT64_SET(menu->state, MENU_STATE_POP_STACK);
|
2016-09-15 14:07:20 +00:00
|
|
|
menu_dialog_set_active(false);
|
2016-09-05 05:04:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (action == MENU_ACTION_CANCEL)
|
|
|
|
{
|
|
|
|
BIT64_SET(menu->state, MENU_STATE_POP_STACK);
|
2016-09-15 14:07:20 +00:00
|
|
|
menu_dialog_set_active(false);
|
2016-09-05 05:04:15 +00:00
|
|
|
}
|
2015-10-03 02:21:38 +00:00
|
|
|
break;
|
|
|
|
case ITERATE_TYPE_BIND:
|
|
|
|
{
|
2016-02-25 16:55:45 +00:00
|
|
|
menu_input_ctx_bind_t bind;
|
|
|
|
|
2017-09-28 06:55:40 +00:00
|
|
|
bind.s = menu->menu_state_msg;
|
|
|
|
bind.len = sizeof(menu->menu_state_msg);
|
2016-02-25 16:55:45 +00:00
|
|
|
|
2016-09-15 18:45:00 +00:00
|
|
|
if (menu_input_key_bind_iterate(&bind))
|
2016-02-25 16:55:45 +00:00
|
|
|
{
|
2016-04-25 17:09:30 +00:00
|
|
|
menu_entries_pop_stack(&selection, 0, 0);
|
2017-04-23 12:31:49 +00:00
|
|
|
menu_navigation_set_selection(selection);
|
2016-02-25 16:55:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
BIT64_SET(menu->state, MENU_STATE_RENDER_MESSAGEBOX);
|
2015-10-03 02:21:38 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ITERATE_TYPE_INFO:
|
|
|
|
{
|
2016-07-27 14:37:28 +00:00
|
|
|
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
|
2017-10-01 15:25:41 +00:00
|
|
|
menu_file_list_cbs_t *cbs = selection_buf ?
|
2017-10-02 05:07:18 +00:00
|
|
|
(menu_file_list_cbs_t*)
|
|
|
|
file_list_get_actiondata_at_offset(selection_buf, selection)
|
2017-10-01 15:25:41 +00:00
|
|
|
: NULL;
|
2015-10-03 02:21:38 +00:00
|
|
|
|
2016-07-24 10:36:02 +00:00
|
|
|
if (cbs->enum_idx != MSG_UNKNOWN)
|
|
|
|
{
|
2016-09-05 15:35:27 +00:00
|
|
|
ret = menu_hash_get_help_enum(cbs->enum_idx,
|
2017-09-28 06:55:40 +00:00
|
|
|
menu->menu_state_msg, sizeof(menu->menu_state_msg));
|
2016-07-24 10:36:02 +00:00
|
|
|
}
|
2016-07-26 13:12:20 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned type = 0;
|
|
|
|
enum msg_hash_enums enum_idx = MSG_UNKNOWN;
|
|
|
|
menu_entries_get_at_offset(selection_buf, selection,
|
|
|
|
NULL, NULL, &type, NULL, NULL);
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
2016-07-27 14:37:28 +00:00
|
|
|
case FILE_TYPE_FONT:
|
|
|
|
enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_FONT;
|
|
|
|
break;
|
|
|
|
case FILE_TYPE_RDB:
|
|
|
|
enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_RDB;
|
|
|
|
break;
|
|
|
|
case FILE_TYPE_OVERLAY:
|
|
|
|
enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_OVERLAY;
|
|
|
|
break;
|
|
|
|
case FILE_TYPE_CHEAT:
|
|
|
|
enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_CHEAT;
|
|
|
|
break;
|
|
|
|
case FILE_TYPE_SHADER_PRESET:
|
|
|
|
enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_SHADER_PRESET;
|
|
|
|
break;
|
|
|
|
case FILE_TYPE_SHADER:
|
|
|
|
enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_SHADER;
|
|
|
|
break;
|
2016-07-27 14:49:13 +00:00
|
|
|
case FILE_TYPE_REMAP:
|
|
|
|
enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_REMAP;
|
|
|
|
break;
|
2016-07-27 18:47:54 +00:00
|
|
|
case FILE_TYPE_RECORD_CONFIG:
|
|
|
|
enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_RECORD_CONFIG;
|
|
|
|
break;
|
|
|
|
case FILE_TYPE_CURSOR:
|
|
|
|
enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_CURSOR;
|
|
|
|
break;
|
2016-07-27 19:01:39 +00:00
|
|
|
case FILE_TYPE_CONFIG:
|
|
|
|
enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_CONFIG;
|
|
|
|
break;
|
2016-07-27 19:28:33 +00:00
|
|
|
case FILE_TYPE_CARCHIVE:
|
|
|
|
enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_COMPRESSED_ARCHIVE;
|
|
|
|
break;
|
2016-07-29 23:36:09 +00:00
|
|
|
case FILE_TYPE_DIRECTORY:
|
|
|
|
enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_DIRECTORY;
|
|
|
|
break;
|
2016-07-26 13:12:20 +00:00
|
|
|
case FILE_TYPE_VIDEOFILTER: /* TODO/FIXME */
|
|
|
|
case FILE_TYPE_AUDIOFILTER: /* TODO/FIXME */
|
|
|
|
case FILE_TYPE_SHADER_SLANG: /* TODO/FIXME */
|
|
|
|
case FILE_TYPE_SHADER_GLSL: /* TODO/FIXME */
|
|
|
|
case FILE_TYPE_SHADER_HLSL: /* TODO/FIXME */
|
|
|
|
case FILE_TYPE_SHADER_CG: /* TODO/FIXME */
|
|
|
|
case FILE_TYPE_SHADER_PRESET_GLSLP: /* TODO/FIXME */
|
|
|
|
case FILE_TYPE_SHADER_PRESET_HLSLP: /* TODO/FIXME */
|
|
|
|
case FILE_TYPE_SHADER_PRESET_CGP: /* TODO/FIXME */
|
|
|
|
case FILE_TYPE_SHADER_PRESET_SLANGP: /* TODO/FIXME */
|
|
|
|
case FILE_TYPE_PLAIN:
|
|
|
|
enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_PLAIN_FILE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (enum_idx != MSG_UNKNOWN)
|
2016-09-05 15:35:27 +00:00
|
|
|
ret = menu_hash_get_help_enum(enum_idx,
|
2017-09-28 06:55:40 +00:00
|
|
|
menu->menu_state_msg, sizeof(menu->menu_state_msg));
|
2016-07-26 13:12:20 +00:00
|
|
|
|
|
|
|
}
|
2015-10-03 02:21:38 +00:00
|
|
|
}
|
|
|
|
BIT64_SET(menu->state, MENU_STATE_RENDER_MESSAGEBOX);
|
|
|
|
BIT64_SET(menu->state, MENU_STATE_POST_ITERATE);
|
2016-09-04 19:45:41 +00:00
|
|
|
if (action == MENU_ACTION_OK || action == MENU_ACTION_CANCEL)
|
2016-09-29 02:25:55 +00:00
|
|
|
{
|
2015-10-03 02:21:38 +00:00
|
|
|
BIT64_SET(menu->state, MENU_STATE_POP_STACK);
|
2016-09-29 02:25:55 +00:00
|
|
|
}
|
|
|
|
menu_dialog_set_active(false);
|
2015-10-03 02:21:38 +00:00
|
|
|
break;
|
|
|
|
case ITERATE_TYPE_DEFAULT:
|
2017-09-28 04:02:14 +00:00
|
|
|
{
|
|
|
|
menu_entry_t entry;
|
|
|
|
/* FIXME: Crappy hack, needed for mouse controls
|
|
|
|
* to not be completely broken in case we press back.
|
|
|
|
*
|
|
|
|
* We need to fix this entire mess, mouse controls
|
|
|
|
* should not rely on a hack like this in order to work. */
|
|
|
|
selection = MAX(MIN(selection, (menu_entries_get_size() - 1)), 0);
|
|
|
|
|
|
|
|
menu_entry_init(&entry);
|
|
|
|
menu_entry_get(&entry, 0, selection, NULL, false);
|
|
|
|
ret = menu_entry_action(&entry,
|
|
|
|
(unsigned)selection, (enum menu_action)action);
|
|
|
|
menu_entry_free(&entry);
|
|
|
|
if (ret)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
BIT64_SET(menu->state, MENU_STATE_POST_ITERATE);
|
|
|
|
|
|
|
|
/* Have to defer it so we let settings refresh. */
|
|
|
|
menu_dialog_push();
|
|
|
|
}
|
2015-10-03 02:21:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-10-11 10:58:21 +00:00
|
|
|
BIT64_SET(menu->state, MENU_STATE_BLIT);
|
2015-10-03 02:21:38 +00:00
|
|
|
|
|
|
|
if (BIT64_GET(menu->state, MENU_STATE_POP_STACK))
|
|
|
|
{
|
|
|
|
size_t new_selection_ptr = selection;
|
2016-04-25 17:09:30 +00:00
|
|
|
menu_entries_pop_stack(&new_selection_ptr, 0, 0);
|
2017-04-23 12:31:49 +00:00
|
|
|
menu_navigation_set_selection(selection);
|
2015-10-03 02:21:38 +00:00
|
|
|
}
|
2016-09-05 15:35:27 +00:00
|
|
|
|
2015-10-03 02:21:38 +00:00
|
|
|
if (BIT64_GET(menu->state, MENU_STATE_POST_ITERATE))
|
|
|
|
menu_input_post_iterate(&ret, action);
|
|
|
|
|
|
|
|
end:
|
|
|
|
if (ret)
|
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-03 01:15:47 +00:00
|
|
|
bool generic_menu_init_list(void *data)
|
|
|
|
{
|
2017-09-10 20:38:03 +00:00
|
|
|
menu_displaylist_info_t info;
|
2016-12-04 03:43:53 +00:00
|
|
|
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
|
|
|
|
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
|
2015-10-03 01:15:47 +00:00
|
|
|
|
2017-09-10 20:38:03 +00:00
|
|
|
menu_displaylist_info_init(&info);
|
|
|
|
|
2017-09-28 00:45:03 +00:00
|
|
|
info.label = strdup(
|
|
|
|
msg_hash_to_str(MENU_ENUM_LABEL_MAIN_MENU));
|
2016-06-17 21:47:23 +00:00
|
|
|
info.enum_idx = MENU_ENUM_LABEL_MAIN_MENU;
|
2015-10-03 01:15:47 +00:00
|
|
|
|
2017-09-28 01:06:54 +00:00
|
|
|
menu_entries_append_enum(menu_stack,
|
|
|
|
info.path,
|
2016-06-16 11:13:43 +00:00
|
|
|
info.label,
|
|
|
|
MENU_ENUM_LABEL_MAIN_MENU,
|
|
|
|
info.type, info.flags, 0);
|
2015-10-22 01:02:03 +00:00
|
|
|
|
|
|
|
info.list = selection_buf;
|
|
|
|
|
2016-02-24 22:05:54 +00:00
|
|
|
if (menu_displaylist_ctl(DISPLAYLIST_MAIN_MENU, &info))
|
2017-05-26 18:12:52 +00:00
|
|
|
menu_displaylist_process(&info);
|
2015-10-03 01:15:47 +00:00
|
|
|
|
2017-09-10 20:57:26 +00:00
|
|
|
menu_displaylist_info_free(&info);
|
|
|
|
|
2015-10-03 01:15:47 +00:00
|
|
|
return true;
|
|
|
|
}
|