2015-05-10 10:55:20 +02:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2017-01-22 13:40:32 +01:00
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2015-05-10 10:55:20 +02:00
|
|
|
* Copyright (C) 2014-2015 - Jay McCarthy
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2015-06-13 19:12:10 +02:00
|
|
|
#include <compat/strl.h>
|
2016-03-20 14:53:54 +01:00
|
|
|
#include <lists/string_list.h>
|
2016-07-08 16:27:16 +02:00
|
|
|
#include <string/stdstring.h>
|
2015-06-13 19:12:10 +02:00
|
|
|
|
2016-09-15 19:46:23 +02:00
|
|
|
#include "menu_input_dialog.h"
|
|
|
|
|
2016-09-15 00:20:43 +02:00
|
|
|
#include "../menu_driver.h"
|
2015-05-10 10:55:20 +02:00
|
|
|
|
2015-06-02 12:37:56 +02:00
|
|
|
/* This file provides an abstraction of the currently displayed
|
|
|
|
* menu.
|
|
|
|
*
|
2015-06-12 16:07:12 +02:00
|
|
|
* It is organized into an event-based system where the UI companion
|
2015-06-02 12:37:56 +02:00
|
|
|
* calls this functions and RetroArch responds by changing the global
|
|
|
|
* state (including arranging for these functions to return different
|
|
|
|
* values).
|
|
|
|
*
|
|
|
|
* Its only interaction back to the UI is to arrange for
|
|
|
|
* notify_list_loaded on the UI companion.
|
|
|
|
*/
|
|
|
|
|
2015-05-10 11:06:58 +02:00
|
|
|
enum menu_entry_type menu_entry_get_type(uint32_t i)
|
2015-05-10 10:33:17 +02:00
|
|
|
{
|
2015-10-18 20:21:12 +02:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2015-05-10 10:33:17 +02:00
|
|
|
|
2015-06-26 18:35:35 +02:00
|
|
|
/* XXX Really a special kind of ST_ACTION, but this should be changed */
|
2016-03-18 22:23:51 +01:00
|
|
|
if (menu_setting_ctl(MENU_SETTING_CTL_IS_OF_PATH_TYPE, (void*)setting))
|
2015-05-10 10:33:17 +02:00
|
|
|
return MENU_ENTRY_PATH;
|
2015-06-06 21:36:58 +02:00
|
|
|
|
|
|
|
if (setting)
|
|
|
|
{
|
2016-10-31 15:01:40 +01:00
|
|
|
switch (setting_get_type(setting))
|
2015-06-06 21:36:58 +02:00
|
|
|
{
|
|
|
|
case ST_BOOL:
|
|
|
|
return MENU_ENTRY_BOOL;
|
|
|
|
case ST_BIND:
|
|
|
|
return MENU_ENTRY_BIND;
|
|
|
|
case ST_INT:
|
|
|
|
return MENU_ENTRY_INT;
|
|
|
|
case ST_UINT:
|
|
|
|
return MENU_ENTRY_UINT;
|
|
|
|
case ST_FLOAT:
|
|
|
|
return MENU_ENTRY_FLOAT;
|
|
|
|
case ST_PATH:
|
|
|
|
return MENU_ENTRY_PATH;
|
|
|
|
case ST_DIR:
|
|
|
|
return MENU_ENTRY_DIR;
|
2015-10-11 23:07:43 +02:00
|
|
|
case ST_STRING_OPTIONS:
|
|
|
|
return MENU_ENTRY_ENUM;
|
2015-06-06 21:36:58 +02:00
|
|
|
case ST_STRING:
|
|
|
|
return MENU_ENTRY_STRING;
|
|
|
|
case ST_HEX:
|
|
|
|
return MENU_ENTRY_HEX;
|
2015-10-11 23:07:43 +02:00
|
|
|
|
|
|
|
default:
|
2015-06-06 21:36:58 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-06-03 10:24:09 +02:00
|
|
|
|
|
|
|
return MENU_ENTRY_ACTION;
|
2015-05-09 19:30:11 -04:00
|
|
|
}
|
|
|
|
|
2017-09-28 06:02:14 +02:00
|
|
|
void menu_entry_free(menu_entry_t *entry)
|
|
|
|
{
|
2017-09-29 18:22:11 +02:00
|
|
|
if (!entry)
|
|
|
|
return;
|
|
|
|
if (entry->label && !string_is_empty(entry->label))
|
|
|
|
free(entry->label);
|
|
|
|
if (entry->rich_label && !string_is_empty(entry->rich_label))
|
|
|
|
free(entry->rich_label);
|
|
|
|
if (entry->sublabel && !string_is_empty(entry->sublabel))
|
|
|
|
free(entry->sublabel);
|
|
|
|
if (entry->path && !string_is_empty(entry->path))
|
|
|
|
free(entry->path);
|
|
|
|
if (entry->value && !string_is_empty(entry->value))
|
|
|
|
free(entry->value);
|
2017-09-28 06:02:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void menu_entry_init(menu_entry_t *entry)
|
|
|
|
{
|
2017-09-29 18:22:11 +02:00
|
|
|
entry->path = NULL;
|
|
|
|
entry->label = NULL;
|
|
|
|
entry->value = NULL;
|
|
|
|
entry->sublabel = NULL;
|
|
|
|
entry->rich_label = NULL;
|
2017-09-28 06:02:14 +02:00
|
|
|
entry->enum_idx = MSG_UNKNOWN;
|
|
|
|
entry->entry_idx = 0;
|
|
|
|
entry->idx = 0;
|
|
|
|
entry->type = 0;
|
|
|
|
entry->spacing = 0;
|
|
|
|
}
|
|
|
|
|
2017-09-28 06:51:48 +02:00
|
|
|
void menu_entry_get_path(menu_entry_t *entry, char *s, size_t len)
|
2015-05-10 10:33:17 +02:00
|
|
|
{
|
2017-09-28 06:51:48 +02:00
|
|
|
if (!entry)
|
|
|
|
return;
|
|
|
|
strlcpy(s, entry->path, len);
|
2015-05-09 19:30:11 -04:00
|
|
|
}
|
2015-05-10 10:33:17 +02:00
|
|
|
|
2017-09-28 06:19:34 +02:00
|
|
|
void menu_entry_get_rich_label(menu_entry_t *entry, char *s, size_t len)
|
2016-07-08 16:55:21 +02:00
|
|
|
{
|
2017-09-28 06:19:34 +02:00
|
|
|
if (!entry)
|
|
|
|
return;
|
|
|
|
if (!string_is_empty(entry->rich_label))
|
|
|
|
strlcpy(s, entry->rich_label, len);
|
2016-07-08 16:55:21 +02:00
|
|
|
else
|
2017-09-28 06:19:34 +02:00
|
|
|
strlcpy(s, entry->path, len);
|
2016-07-08 16:55:21 +02:00
|
|
|
}
|
|
|
|
|
2017-09-28 06:37:48 +02:00
|
|
|
bool menu_entry_get_sublabel(menu_entry_t *entry, char *s, size_t len)
|
2016-10-20 15:49:00 +02:00
|
|
|
{
|
2017-09-28 06:37:48 +02:00
|
|
|
if (!entry)
|
|
|
|
return false;
|
|
|
|
if (string_is_empty(entry->sublabel))
|
2016-10-20 16:10:20 +02:00
|
|
|
return false;
|
|
|
|
|
2017-09-28 06:37:48 +02:00
|
|
|
strlcpy(s, entry->sublabel, len);
|
2016-10-20 16:10:20 +02:00
|
|
|
return true;
|
2016-10-20 15:49:00 +02:00
|
|
|
}
|
|
|
|
|
2017-09-28 06:40:15 +02:00
|
|
|
void menu_entry_get_label(menu_entry_t *entry, char *s, size_t len)
|
2015-06-01 15:21:43 +02:00
|
|
|
{
|
2017-09-28 06:40:15 +02:00
|
|
|
if (!entry)
|
|
|
|
return;
|
|
|
|
strlcpy(s, entry->label, len);
|
2015-06-01 15:21:43 +02:00
|
|
|
}
|
|
|
|
|
2017-09-28 06:44:04 +02:00
|
|
|
unsigned menu_entry_get_spacing(menu_entry_t *entry)
|
2015-06-01 15:13:49 +02:00
|
|
|
{
|
2017-09-28 06:44:04 +02:00
|
|
|
if (!entry)
|
|
|
|
return 0;
|
|
|
|
return entry->spacing;
|
2015-06-01 15:13:49 +02:00
|
|
|
}
|
|
|
|
|
2017-09-28 07:15:29 +02:00
|
|
|
unsigned menu_entry_get_type_new(menu_entry_t *entry)
|
2015-06-01 15:21:43 +02:00
|
|
|
{
|
2017-09-28 07:15:29 +02:00
|
|
|
if (!entry)
|
|
|
|
return 0;
|
|
|
|
return entry->type;
|
2015-06-01 15:21:43 +02:00
|
|
|
}
|
|
|
|
|
2015-05-10 11:12:50 +02:00
|
|
|
uint32_t menu_entry_get_bool_value(uint32_t i)
|
2015-05-10 10:33:17 +02:00
|
|
|
{
|
2015-10-18 20:21:12 +02:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2015-10-11 17:17:05 +02:00
|
|
|
bool *ptr = (bool*)setting_get_ptr(setting);
|
2015-10-11 14:23:32 +02:00
|
|
|
if (!ptr)
|
|
|
|
return 0;
|
|
|
|
return *ptr;
|
2015-05-09 19:30:11 -04:00
|
|
|
}
|
|
|
|
|
2015-05-10 10:33:17 +02:00
|
|
|
struct string_list *menu_entry_enum_values(uint32_t i)
|
|
|
|
{
|
2015-10-18 20:21:12 +02:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2016-10-23 03:13:49 +02:00
|
|
|
const char *values = setting->values;
|
2015-09-28 02:02:54 +02:00
|
|
|
|
|
|
|
if (!values)
|
|
|
|
return NULL;
|
|
|
|
return string_split(values, "|");
|
2015-05-09 19:30:11 -04:00
|
|
|
}
|
|
|
|
|
2015-05-10 11:06:58 +02:00
|
|
|
void menu_entry_enum_set_value_with_string(uint32_t i, const char *s)
|
2015-05-10 10:33:17 +02:00
|
|
|
{
|
2015-10-18 20:21:12 +02:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2016-08-29 03:07:20 +02:00
|
|
|
setting_set_with_string_representation(setting, s);
|
2015-05-09 19:30:11 -04:00
|
|
|
}
|
|
|
|
|
2015-05-10 10:33:17 +02:00
|
|
|
int32_t menu_entry_bind_index(uint32_t i)
|
|
|
|
{
|
2015-10-18 20:21:12 +02:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2015-09-28 02:02:54 +02:00
|
|
|
|
2016-10-23 03:25:27 +02:00
|
|
|
if (setting)
|
|
|
|
return setting->index - 1;
|
2015-05-10 10:33:17 +02:00
|
|
|
return 0;
|
2015-05-09 19:30:11 -04:00
|
|
|
}
|
2015-05-10 10:33:17 +02:00
|
|
|
|
|
|
|
void menu_entry_bind_key_set(uint32_t i, int32_t value)
|
|
|
|
{
|
2015-10-18 20:21:12 +02:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2016-02-14 17:22:01 +01:00
|
|
|
struct retro_keybind *keybind = (struct retro_keybind*)
|
|
|
|
setting_get_ptr(setting);
|
2015-10-11 14:31:41 +02:00
|
|
|
if (keybind)
|
|
|
|
keybind->key = (enum retro_key)value;
|
2015-05-09 19:30:11 -04:00
|
|
|
}
|
2015-05-10 10:33:17 +02:00
|
|
|
|
|
|
|
void menu_entry_bind_joykey_set(uint32_t i, int32_t value)
|
|
|
|
{
|
2015-10-18 20:21:12 +02:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2016-02-14 17:22:01 +01:00
|
|
|
struct retro_keybind *keybind = (struct retro_keybind*)
|
|
|
|
setting_get_ptr(setting);
|
2015-10-11 14:31:41 +02:00
|
|
|
if (keybind)
|
|
|
|
keybind->joykey = value;
|
2015-05-09 19:30:11 -04:00
|
|
|
}
|
|
|
|
|
2015-05-10 10:33:17 +02:00
|
|
|
void menu_entry_bind_joyaxis_set(uint32_t i, int32_t value)
|
|
|
|
{
|
2015-10-18 20:21:12 +02:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2016-02-14 17:22:01 +01:00
|
|
|
struct retro_keybind *keybind = (struct retro_keybind*)
|
|
|
|
setting_get_ptr(setting);
|
2015-10-11 14:31:41 +02:00
|
|
|
if (keybind)
|
|
|
|
keybind->joyaxis = value;
|
2015-05-09 19:30:11 -04:00
|
|
|
}
|
|
|
|
|
2015-05-10 10:33:17 +02:00
|
|
|
void menu_entry_pathdir_selected(uint32_t i)
|
|
|
|
{
|
2015-10-18 20:21:12 +02:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2016-03-18 22:23:51 +01:00
|
|
|
|
|
|
|
if (menu_setting_ctl(MENU_SETTING_CTL_IS_OF_PATH_TYPE, (void*)setting))
|
2016-03-18 23:31:11 +01:00
|
|
|
menu_setting_ctl(MENU_SETTING_CTL_ACTION_RIGHT, setting);
|
2015-05-09 19:30:11 -04:00
|
|
|
}
|
2015-05-10 10:33:17 +02:00
|
|
|
|
2015-06-02 14:07:47 +02:00
|
|
|
bool menu_entry_pathdir_allow_empty(uint32_t i)
|
2015-05-10 10:33:17 +02:00
|
|
|
{
|
2015-10-18 20:21:12 +02:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2016-10-23 03:13:49 +02:00
|
|
|
uint64_t flags = setting->flags;
|
2015-09-28 02:02:54 +02:00
|
|
|
|
|
|
|
return flags & SD_FLAG_ALLOW_EMPTY;
|
2015-05-09 19:30:11 -04:00
|
|
|
}
|
|
|
|
|
2015-05-10 10:33:17 +02:00
|
|
|
uint32_t menu_entry_pathdir_for_directory(uint32_t i)
|
|
|
|
{
|
2015-10-18 20:21:12 +02:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2016-10-23 03:13:49 +02:00
|
|
|
uint64_t flags = setting->flags;
|
2015-09-28 02:02:54 +02:00
|
|
|
|
|
|
|
return flags & SD_FLAG_PATH_DIR;
|
2015-05-09 19:30:11 -04:00
|
|
|
}
|
2015-05-10 10:33:17 +02:00
|
|
|
|
2015-05-10 18:18:46 +02:00
|
|
|
void menu_entry_pathdir_extensions(uint32_t i, char *s, size_t len)
|
2015-05-10 10:33:17 +02:00
|
|
|
{
|
2015-10-18 20:21:12 +02:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2016-10-23 03:13:49 +02:00
|
|
|
const char *values = setting->values;
|
2015-09-28 02:02:54 +02:00
|
|
|
|
|
|
|
if (!values)
|
|
|
|
return;
|
|
|
|
|
|
|
|
strlcpy(s, values, len);
|
2015-05-09 19:30:11 -04:00
|
|
|
}
|
2015-05-10 10:33:17 +02:00
|
|
|
|
|
|
|
void menu_entry_reset(uint32_t i)
|
|
|
|
{
|
2016-10-16 00:53:51 +02:00
|
|
|
menu_entry_t entry;
|
|
|
|
|
2017-09-28 06:02:14 +02:00
|
|
|
menu_entry_init(&entry);
|
2015-10-27 10:10:33 +01:00
|
|
|
menu_entry_get(&entry, 0, i, NULL, true);
|
2015-05-15 00:58:06 +02:00
|
|
|
|
|
|
|
menu_entry_action(&entry, i, MENU_ACTION_START);
|
2015-05-10 10:33:17 +02:00
|
|
|
}
|
|
|
|
|
2017-09-28 06:32:49 +02:00
|
|
|
void menu_entry_get_value(menu_entry_t *entry, char *s, size_t len)
|
2015-05-10 10:33:17 +02:00
|
|
|
{
|
2017-09-28 06:32:49 +02:00
|
|
|
if (!entry)
|
|
|
|
return;
|
|
|
|
strlcpy(s, entry->value, len);
|
2015-05-09 19:30:11 -04:00
|
|
|
}
|
2015-05-10 10:33:17 +02:00
|
|
|
|
2015-05-10 11:06:58 +02:00
|
|
|
void menu_entry_set_value(uint32_t i, const char *s)
|
2015-05-10 10:33:17 +02:00
|
|
|
{
|
2015-10-18 20:21:12 +02:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2016-08-29 03:07:20 +02:00
|
|
|
setting_set_with_string_representation(setting, s);
|
2015-05-09 19:30:11 -04:00
|
|
|
}
|
|
|
|
|
2015-05-10 10:33:17 +02:00
|
|
|
uint32_t menu_entry_num_has_range(uint32_t i)
|
|
|
|
{
|
2015-10-18 20:21:12 +02:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2016-10-23 03:13:49 +02:00
|
|
|
uint64_t flags = setting->flags;
|
2015-09-28 02:02:54 +02:00
|
|
|
|
|
|
|
return (flags & SD_FLAG_HAS_RANGE);
|
2015-05-09 19:30:11 -04:00
|
|
|
}
|
|
|
|
|
2015-05-10 10:33:17 +02:00
|
|
|
float menu_entry_num_min(uint32_t i)
|
|
|
|
{
|
2015-10-18 20:21:12 +02:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2016-10-23 03:13:49 +02:00
|
|
|
double min = setting->min;
|
2015-09-28 02:02:54 +02:00
|
|
|
return (float)min;
|
2015-05-09 19:30:11 -04:00
|
|
|
}
|
2015-05-10 10:33:17 +02:00
|
|
|
|
|
|
|
float menu_entry_num_max(uint32_t i)
|
|
|
|
{
|
2015-10-18 20:21:12 +02:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2016-10-23 03:13:49 +02:00
|
|
|
double max = setting->max;
|
2015-09-28 02:02:54 +02:00
|
|
|
return (float)max;
|
2015-05-09 19:30:11 -04:00
|
|
|
}
|
|
|
|
|
2015-10-27 10:10:33 +01:00
|
|
|
void menu_entry_get(menu_entry_t *entry, size_t stack_idx,
|
|
|
|
size_t i, void *userdata, bool use_representation)
|
2015-05-10 11:23:00 +02:00
|
|
|
{
|
2017-09-29 18:22:11 +02:00
|
|
|
char newpath[255];
|
2015-10-17 17:51:40 +02:00
|
|
|
const char *path = NULL;
|
|
|
|
const char *entry_label = NULL;
|
|
|
|
menu_file_list_cbs_t *cbs = NULL;
|
2015-10-27 10:10:33 +01:00
|
|
|
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(stack_idx);
|
2017-09-28 06:19:34 +02:00
|
|
|
file_list_t *list = (userdata) ? (file_list_t*)userdata : selection_buf;
|
2015-05-10 11:23:00 +02:00
|
|
|
|
2017-09-29 18:22:11 +02:00
|
|
|
newpath[0] = '\0';
|
|
|
|
|
2015-05-10 11:23:00 +02:00
|
|
|
if (!list)
|
|
|
|
return;
|
|
|
|
|
2015-10-18 21:54:20 +02:00
|
|
|
menu_entries_get_at_offset(list, i, &path, &entry_label, &entry->type,
|
|
|
|
&entry->entry_idx, NULL);
|
2015-05-10 11:23:00 +02:00
|
|
|
|
2015-10-19 16:32:51 +02:00
|
|
|
cbs = menu_entries_get_actiondata_at_offset(list, i);
|
2015-05-10 11:23:00 +02:00
|
|
|
|
2016-06-17 21:03:00 +02:00
|
|
|
if (cbs)
|
2015-08-18 01:58:18 +02:00
|
|
|
{
|
2016-07-09 13:49:31 +02:00
|
|
|
const char *label = NULL;
|
|
|
|
enum msg_hash_enums enum_idx = MSG_UNKNOWN;
|
|
|
|
|
2017-09-28 06:19:34 +02:00
|
|
|
entry->enum_idx = cbs->enum_idx;
|
2016-06-17 21:03:00 +02:00
|
|
|
|
2016-07-09 13:49:31 +02:00
|
|
|
menu_entries_get_last_stack(NULL, &label, NULL, &enum_idx, NULL);
|
2016-06-17 21:03:00 +02:00
|
|
|
|
2016-07-09 13:49:31 +02:00
|
|
|
if (cbs->action_get_value && use_representation)
|
2017-09-29 18:22:11 +02:00
|
|
|
{
|
|
|
|
entry->value = (char*)malloc(255 *
|
|
|
|
sizeof(char));
|
|
|
|
entry->value[0] = '\0';
|
2016-06-17 21:03:00 +02:00
|
|
|
cbs->action_get_value(list,
|
2017-02-26 10:33:03 +01:00
|
|
|
&entry->spacing, entry->type, (unsigned)i, label,
|
2017-09-29 18:22:11 +02:00
|
|
|
entry->value,
|
|
|
|
255 * sizeof(char),
|
2016-06-17 21:03:00 +02:00
|
|
|
entry_label, path,
|
2017-09-29 18:22:11 +02:00
|
|
|
newpath,
|
|
|
|
sizeof(newpath)
|
|
|
|
);
|
|
|
|
}
|
2016-07-08 16:24:05 +02:00
|
|
|
|
2016-07-08 16:42:40 +02:00
|
|
|
if (cbs->action_label)
|
2017-09-29 18:22:11 +02:00
|
|
|
{
|
|
|
|
entry->rich_label = (char*)malloc(255 *
|
|
|
|
sizeof(char));
|
|
|
|
entry->rich_label[0] = '\0';
|
2016-07-09 13:49:31 +02:00
|
|
|
cbs->action_label(list,
|
2017-02-26 10:33:03 +01:00
|
|
|
entry->type, (unsigned)i,
|
2016-07-09 13:49:31 +02:00
|
|
|
label, path,
|
|
|
|
entry->rich_label,
|
2017-09-29 18:22:11 +02:00
|
|
|
255 * sizeof(char));
|
|
|
|
}
|
2016-10-20 15:57:35 +02:00
|
|
|
|
|
|
|
if (cbs->action_sublabel)
|
2017-09-29 18:22:11 +02:00
|
|
|
{
|
|
|
|
entry->sublabel = (char*)malloc(255 *
|
|
|
|
sizeof(char));
|
|
|
|
entry->sublabel[0] = '\0';
|
2016-10-20 15:57:35 +02:00
|
|
|
cbs->action_sublabel(list,
|
2017-02-26 10:33:03 +01:00
|
|
|
entry->type, (unsigned)i,
|
2016-10-20 15:57:35 +02:00
|
|
|
label, path,
|
|
|
|
entry->sublabel,
|
2017-09-29 18:22:11 +02:00
|
|
|
255 * sizeof(char));
|
|
|
|
}
|
2015-08-18 01:58:18 +02:00
|
|
|
}
|
2015-05-10 11:23:00 +02:00
|
|
|
|
2017-02-26 10:33:03 +01:00
|
|
|
entry->idx = (unsigned)i;
|
2015-05-10 11:23:00 +02:00
|
|
|
|
2015-05-10 16:42:49 +02:00
|
|
|
if (path && !use_representation)
|
2017-09-29 18:22:11 +02:00
|
|
|
strlcpy(newpath, path, sizeof(newpath));
|
|
|
|
else if (cbs && cbs->setting && cbs->setting->enum_value_idx != MSG_UNKNOWN
|
2016-10-27 02:23:21 +02:00
|
|
|
&& !cbs->setting->dont_use_enum_idx_representation)
|
2017-09-29 18:22:11 +02:00
|
|
|
strlcpy(newpath, msg_hash_to_str(cbs->setting->enum_value_idx), sizeof(newpath));
|
|
|
|
|
|
|
|
if (!string_is_empty(newpath))
|
|
|
|
entry->path = strdup(newpath);
|
2016-10-26 09:03:56 +02:00
|
|
|
|
2015-05-10 11:23:00 +02:00
|
|
|
if (entry_label)
|
2017-09-29 18:22:11 +02:00
|
|
|
entry->label = strdup(entry_label);
|
2015-05-10 11:23:00 +02:00
|
|
|
}
|
|
|
|
|
2015-06-01 15:08:58 +02:00
|
|
|
bool menu_entry_is_currently_selected(unsigned id)
|
2015-05-10 11:23:00 +02:00
|
|
|
{
|
2017-04-23 14:31:49 +02:00
|
|
|
return (id == menu_navigation_get_selection());
|
2015-05-10 11:23:00 +02:00
|
|
|
}
|
|
|
|
|
2015-06-02 14:17:37 +02:00
|
|
|
/* Performs whatever actions are associated with menu entry 'i'.
|
|
|
|
*
|
|
|
|
* This is the most important function because it does all the work
|
|
|
|
* associated with clicking on things in the UI.
|
|
|
|
*
|
|
|
|
* This includes loading cores and updating the
|
|
|
|
* currently displayed menu. */
|
2015-05-15 04:38:58 +02:00
|
|
|
int menu_entry_select(uint32_t i)
|
2015-05-09 19:30:11 -04:00
|
|
|
{
|
2016-10-16 00:53:51 +02:00
|
|
|
menu_entry_t entry;
|
|
|
|
|
2017-04-23 14:31:49 +02:00
|
|
|
menu_navigation_set_selection(i);
|
2015-09-25 15:59:23 +02:00
|
|
|
|
2017-09-28 06:02:14 +02:00
|
|
|
menu_entry_init(&entry);
|
2015-10-27 10:10:33 +01:00
|
|
|
menu_entry_get(&entry, 0, i, NULL, false);
|
2015-05-10 10:33:17 +02:00
|
|
|
|
2015-06-01 07:38:59 +02:00
|
|
|
return menu_entry_action(&entry, i, MENU_ACTION_SELECT);
|
2015-05-09 19:30:11 -04:00
|
|
|
}
|
2015-05-11 01:27:00 +02:00
|
|
|
|
2015-05-15 04:41:57 +02:00
|
|
|
int menu_entry_action(menu_entry_t *entry, unsigned i, enum menu_action action)
|
2015-05-11 01:27:00 +02:00
|
|
|
{
|
2015-10-17 17:51:40 +02:00
|
|
|
int ret = 0;
|
2016-02-14 17:22:01 +01:00
|
|
|
file_list_t *selection_buf =
|
|
|
|
menu_entries_get_selection_buf_ptr(0);
|
|
|
|
menu_file_list_cbs_t *cbs =
|
|
|
|
menu_entries_get_actiondata_at_offset(selection_buf, i);
|
2015-05-11 01:27:00 +02:00
|
|
|
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case MENU_ACTION_UP:
|
2015-05-18 15:31:53 +02:00
|
|
|
if (cbs && cbs->action_up)
|
2015-05-18 17:58:21 +02:00
|
|
|
ret = cbs->action_up(entry->type, entry->label);
|
2015-05-18 15:31:53 +02:00
|
|
|
break;
|
2015-05-11 01:27:00 +02:00
|
|
|
case MENU_ACTION_DOWN:
|
2015-05-18 15:31:53 +02:00
|
|
|
if (cbs && cbs->action_down)
|
2015-05-18 17:58:21 +02:00
|
|
|
ret = cbs->action_down(entry->type, entry->label);
|
2015-05-11 01:27:00 +02:00
|
|
|
break;
|
|
|
|
case MENU_ACTION_SCROLL_UP:
|
2017-05-17 04:57:43 +02:00
|
|
|
menu_driver_ctl(MENU_NAVIGATION_CTL_DESCEND_ALPHABET, NULL);
|
2015-05-11 01:27:00 +02:00
|
|
|
break;
|
|
|
|
case MENU_ACTION_SCROLL_DOWN:
|
2017-05-17 04:57:43 +02:00
|
|
|
menu_driver_ctl(MENU_NAVIGATION_CTL_ASCEND_ALPHABET, NULL);
|
2015-05-11 01:27:00 +02:00
|
|
|
break;
|
|
|
|
case MENU_ACTION_CANCEL:
|
|
|
|
if (cbs && cbs->action_cancel)
|
2016-02-14 17:22:01 +01:00
|
|
|
ret = cbs->action_cancel(entry->path,
|
|
|
|
entry->label, entry->type, i);
|
2015-05-11 01:27:00 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MENU_ACTION_OK:
|
|
|
|
if (cbs && cbs->action_ok)
|
2016-02-14 17:22:01 +01:00
|
|
|
ret = cbs->action_ok(entry->path,
|
|
|
|
entry->label, entry->type, i, entry->entry_idx);
|
2015-05-11 01:27:00 +02:00
|
|
|
break;
|
|
|
|
case MENU_ACTION_START:
|
|
|
|
if (cbs && cbs->action_start)
|
2015-05-18 17:58:21 +02:00
|
|
|
ret = cbs->action_start(entry->type, entry->label);
|
2015-05-11 01:27:00 +02:00
|
|
|
break;
|
|
|
|
case MENU_ACTION_LEFT:
|
2015-05-18 15:56:32 +02:00
|
|
|
if (cbs && cbs->action_left)
|
2015-05-18 17:58:21 +02:00
|
|
|
ret = cbs->action_left(entry->type, entry->label, false);
|
2015-05-18 15:56:32 +02:00
|
|
|
break;
|
2015-05-11 01:27:00 +02:00
|
|
|
case MENU_ACTION_RIGHT:
|
2015-05-18 15:56:32 +02:00
|
|
|
if (cbs && cbs->action_right)
|
2015-05-18 17:58:21 +02:00
|
|
|
ret = cbs->action_right(entry->type, entry->label, false);
|
2015-05-11 01:27:00 +02:00
|
|
|
break;
|
2015-06-01 07:21:00 +02:00
|
|
|
case MENU_ACTION_INFO:
|
2015-05-31 22:40:26 +02:00
|
|
|
if (cbs && cbs->action_info)
|
|
|
|
ret = cbs->action_info(entry->type, entry->label);
|
2015-05-11 01:27:00 +02:00
|
|
|
break;
|
2015-06-01 07:38:59 +02:00
|
|
|
case MENU_ACTION_SELECT:
|
|
|
|
if (cbs && cbs->action_select)
|
2016-02-14 17:22:01 +01:00
|
|
|
ret = cbs->action_select(entry->path,
|
|
|
|
entry->label, entry->type, i);
|
2015-06-01 07:38:59 +02:00
|
|
|
break;
|
2015-05-11 01:27:00 +02:00
|
|
|
case MENU_ACTION_SEARCH:
|
2016-09-15 17:18:24 +02:00
|
|
|
menu_input_dialog_start_search();
|
2015-05-11 01:27:00 +02:00
|
|
|
break;
|
|
|
|
|
2015-05-26 01:10:27 +02:00
|
|
|
case MENU_ACTION_SCAN:
|
2015-05-27 06:57:01 +02:00
|
|
|
if (cbs && cbs->action_scan)
|
2016-02-14 17:22:01 +01:00
|
|
|
ret = cbs->action_scan(entry->path,
|
|
|
|
entry->label, entry->type, i);
|
2015-05-11 01:27:00 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-10-19 16:32:51 +02:00
|
|
|
cbs = menu_entries_get_actiondata_at_offset(selection_buf, i);
|
2015-08-22 20:24:19 +02:00
|
|
|
|
2015-12-11 21:41:59 +01:00
|
|
|
if (menu_entries_ctl(MENU_ENTRIES_CTL_NEEDS_REFRESH, NULL))
|
2015-08-22 02:07:10 +02:00
|
|
|
{
|
|
|
|
if (cbs && cbs->action_refresh)
|
|
|
|
{
|
2015-12-12 02:14:50 +01:00
|
|
|
bool refresh = false;
|
2015-10-27 10:33:19 +01:00
|
|
|
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
|
2015-10-17 17:51:40 +02:00
|
|
|
|
|
|
|
cbs->action_refresh(selection_buf, menu_stack);
|
2015-12-12 02:14:50 +01:00
|
|
|
menu_entries_ctl(MENU_ENTRIES_CTL_UNSET_REFRESH, &refresh);
|
2015-08-22 02:07:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-18 17:58:21 +02:00
|
|
|
return ret;
|
2015-05-11 01:27:00 +02:00
|
|
|
}
|