2013-04-17 21:31:49 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
|
|
* Copyright (C) 2011-2014 - Daniel De Matteis
|
2014-04-13 10:12:12 +00:00
|
|
|
*
|
2013-04-17 21:31:49 +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 "menu_common.h"
|
|
|
|
|
2014-04-14 00:32:54 +00:00
|
|
|
void menu_update_system_info(void *data, bool *load_no_rom)
|
2014-03-02 13:07:07 +00:00
|
|
|
{
|
2014-06-10 00:06:10 +00:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
2014-03-02 13:07:07 +00:00
|
|
|
|
2014-03-05 21:39:00 +00:00
|
|
|
#ifdef HAVE_DYNAMIC
|
2014-06-10 00:06:10 +00:00
|
|
|
libretro_free_system_info(&menu->info);
|
2014-05-09 16:51:20 +00:00
|
|
|
if (*g_settings.libretro)
|
2014-03-02 13:07:07 +00:00
|
|
|
{
|
2014-06-10 00:06:10 +00:00
|
|
|
libretro_get_system_info(g_settings.libretro, &menu->info, load_no_rom);
|
2014-03-05 21:39:00 +00:00
|
|
|
#endif
|
2014-03-02 13:07:07 +00:00
|
|
|
// Keep track of info for the currently selected core.
|
2014-06-10 00:06:10 +00:00
|
|
|
if (menu->core_info)
|
2014-03-02 13:07:07 +00:00
|
|
|
{
|
2014-06-10 00:06:10 +00:00
|
|
|
if (core_info_list_get_info(menu->core_info, menu->core_info_current, g_settings.libretro))
|
2014-03-02 13:07:07 +00:00
|
|
|
{
|
2014-06-10 00:06:10 +00:00
|
|
|
const core_info_t *info = (const core_info_t*)menu->core_info_current;
|
2014-03-02 13:07:07 +00:00
|
|
|
|
|
|
|
RARCH_LOG("[Core Info]:\n");
|
|
|
|
if (info->display_name)
|
|
|
|
RARCH_LOG(" Display Name: %s\n", info->display_name);
|
|
|
|
if (info->supported_extensions)
|
|
|
|
RARCH_LOG(" Supported Extensions: %s\n", info->supported_extensions);
|
|
|
|
if (info->authors)
|
|
|
|
RARCH_LOG(" Authors: %s\n", info->authors);
|
|
|
|
if (info->permissions)
|
|
|
|
RARCH_LOG(" Permissions: %s\n", info->permissions);
|
|
|
|
}
|
|
|
|
}
|
2014-03-05 21:39:00 +00:00
|
|
|
#ifdef HAVE_DYNAMIC
|
2014-03-02 13:07:07 +00:00
|
|
|
}
|
|
|
|
#endif
|
2014-03-05 21:39:00 +00:00
|
|
|
}
|
2014-03-02 13:07:07 +00:00
|
|
|
|
2014-05-22 01:12:56 +00:00
|
|
|
// When selection is presented back, returns 0. If it can make a decision right now, returns -1.
|
2014-05-22 04:19:15 +00:00
|
|
|
int menu_defer_core(void *info_, const char *dir, const char *path, char *deferred_path, size_t sizeof_deferred_path)
|
2014-05-22 01:12:56 +00:00
|
|
|
{
|
2014-05-22 04:19:15 +00:00
|
|
|
core_info_list_t *core_info;
|
|
|
|
const core_info_t *info;
|
2014-05-22 04:20:10 +00:00
|
|
|
size_t supported;
|
|
|
|
|
2014-05-22 04:19:15 +00:00
|
|
|
core_info = (core_info_list_t*)info_;
|
|
|
|
info = NULL;
|
2014-05-22 04:20:10 +00:00
|
|
|
supported = 0;
|
2014-05-22 01:12:56 +00:00
|
|
|
|
2014-05-22 04:19:15 +00:00
|
|
|
fill_pathname_join(deferred_path, dir, path, sizeof_deferred_path);
|
2014-05-22 01:12:56 +00:00
|
|
|
|
2014-05-22 04:19:15 +00:00
|
|
|
if (core_info)
|
|
|
|
core_info_list_get_supported_cores(core_info, deferred_path, &info, &supported);
|
2014-05-22 01:12:56 +00:00
|
|
|
|
|
|
|
if (supported == 1) // Can make a decision right now.
|
|
|
|
{
|
2014-05-22 04:19:15 +00:00
|
|
|
strlcpy(g_extern.fullpath, deferred_path, sizeof(g_extern.fullpath));
|
2014-05-22 01:12:56 +00:00
|
|
|
strlcpy(g_settings.libretro, info->path, sizeof(g_settings.libretro));
|
|
|
|
|
|
|
|
#ifdef HAVE_DYNAMIC
|
|
|
|
g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME);
|
|
|
|
#else
|
|
|
|
rarch_environment_cb(RETRO_ENVIRONMENT_SET_LIBRETRO_PATH, (void*)g_settings.libretro);
|
|
|
|
rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)g_extern.fullpath);
|
|
|
|
#endif
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-30 17:33:10 +00:00
|
|
|
void menu_rom_history_push(const char *path,
|
2013-05-17 16:22:03 +00:00
|
|
|
const char *core_path,
|
|
|
|
const char *core_name)
|
|
|
|
{
|
2014-05-31 19:45:16 +00:00
|
|
|
if (driver.menu && driver.menu->history)
|
|
|
|
rom_history_push(driver.menu->history, path, core_path, core_name);
|
2013-05-17 16:22:03 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 17:33:10 +00:00
|
|
|
void menu_rom_history_push_current(void)
|
2013-05-17 16:33:16 +00:00
|
|
|
{
|
|
|
|
// g_extern.fullpath can be relative here.
|
|
|
|
// Ensure we're pushing absolute path.
|
|
|
|
char tmp[PATH_MAX];
|
2014-05-30 17:33:10 +00:00
|
|
|
|
2014-05-31 19:45:16 +00:00
|
|
|
if (!driver.menu)
|
2014-05-30 17:33:10 +00:00
|
|
|
return;
|
2013-05-30 20:53:40 +00:00
|
|
|
|
2014-04-04 12:58:42 +00:00
|
|
|
strlcpy(tmp, g_extern.fullpath, sizeof(tmp));
|
2013-05-30 20:53:40 +00:00
|
|
|
|
2013-05-17 16:33:16 +00:00
|
|
|
if (*tmp)
|
|
|
|
path_resolve_realpath(tmp, sizeof(tmp));
|
|
|
|
|
2013-11-03 04:49:46 +00:00
|
|
|
if (g_extern.system.no_game || *tmp)
|
2014-05-30 17:33:10 +00:00
|
|
|
menu_rom_history_push(*tmp ? tmp : NULL,
|
2013-11-03 04:49:46 +00:00
|
|
|
g_settings.libretro,
|
|
|
|
g_extern.system.info.library_name);
|
2013-05-17 16:33:16 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 17:33:10 +00:00
|
|
|
void load_menu_game_prepare(void)
|
2013-04-28 14:38:13 +00:00
|
|
|
{
|
2014-05-31 19:45:16 +00:00
|
|
|
if (!driver.menu)
|
2014-05-30 17:33:10 +00:00
|
|
|
return;
|
2014-05-09 03:47:32 +00:00
|
|
|
|
2014-05-31 19:45:16 +00:00
|
|
|
if (*g_extern.fullpath || driver.menu->load_no_rom)
|
2013-04-28 14:38:13 +00:00
|
|
|
{
|
2013-10-10 23:28:26 +00:00
|
|
|
if (*g_extern.fullpath)
|
2013-04-28 15:30:08 +00:00
|
|
|
{
|
|
|
|
char tmp[PATH_MAX];
|
|
|
|
char str[PATH_MAX];
|
2013-04-28 14:38:13 +00:00
|
|
|
|
2013-04-28 15:30:08 +00:00
|
|
|
fill_pathname_base(tmp, g_extern.fullpath, sizeof(tmp));
|
|
|
|
snprintf(str, sizeof(str), "INFO - Loading %s ...", tmp);
|
|
|
|
msg_queue_push(g_extern.msg_queue, str, 1, 1);
|
|
|
|
}
|
2013-04-28 14:38:13 +00:00
|
|
|
|
2013-11-03 14:17:45 +00:00
|
|
|
#ifdef RARCH_CONSOLE
|
|
|
|
if (g_extern.system.no_game || *g_extern.fullpath)
|
|
|
|
#endif
|
2014-05-30 17:33:10 +00:00
|
|
|
menu_rom_history_push(*g_extern.fullpath ? g_extern.fullpath : NULL,
|
2013-11-03 09:46:10 +00:00
|
|
|
g_settings.libretro,
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.menu->info.library_name ? driver.menu->info.library_name : "");
|
2013-04-28 14:38:13 +00:00
|
|
|
}
|
|
|
|
|
2014-06-09 23:42:26 +00:00
|
|
|
// redraw menu frame
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.menu->old_input_state = driver.menu->trigger_state = 0;
|
|
|
|
driver.menu->do_held = false;
|
|
|
|
driver.menu->msg_force = true;
|
2013-09-19 12:49:07 +00:00
|
|
|
|
2014-04-14 00:32:54 +00:00
|
|
|
if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->iterate)
|
2014-06-09 23:42:26 +00:00
|
|
|
driver.menu_ctx->backend->iterate(MENU_ACTION_NOOP);
|
2013-04-29 20:01:41 +00:00
|
|
|
|
2013-04-28 14:38:13 +00:00
|
|
|
// Draw frame for loading message
|
2014-03-25 09:19:02 +00:00
|
|
|
if (driver.video_data && driver.video_poke && driver.video_poke->set_texture_enable)
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.video_poke->set_texture_enable(driver.video_data, driver.menu->frame_buf_show, MENU_TEXTURE_FULLSCREEN);
|
2013-04-28 14:38:13 +00:00
|
|
|
|
2013-04-28 14:58:58 +00:00
|
|
|
if (driver.video)
|
|
|
|
rarch_render_cached_frame();
|
2013-04-28 14:38:13 +00:00
|
|
|
|
2014-03-25 09:19:02 +00:00
|
|
|
if (driver.video_data && driver.video_poke && driver.video_poke->set_texture_enable)
|
|
|
|
driver.video_poke->set_texture_enable(driver.video_data, false,
|
2013-04-28 14:38:13 +00:00
|
|
|
MENU_TEXTURE_FULLSCREEN);
|
|
|
|
}
|
|
|
|
|
2014-05-30 17:33:10 +00:00
|
|
|
void load_menu_game_history(unsigned game_index)
|
2013-04-29 01:05:46 +00:00
|
|
|
{
|
|
|
|
const char *path = NULL;
|
2013-08-25 09:07:06 +00:00
|
|
|
const char *core_path = NULL;
|
2013-04-29 01:05:46 +00:00
|
|
|
const char *core_name = NULL;
|
2014-05-09 03:47:32 +00:00
|
|
|
|
2014-05-31 19:45:16 +00:00
|
|
|
if (!driver.menu)
|
2014-05-09 03:47:32 +00:00
|
|
|
return;
|
|
|
|
|
2014-05-31 19:45:16 +00:00
|
|
|
rom_history_get_index(driver.menu->history,
|
2013-08-25 09:07:06 +00:00
|
|
|
game_index, &path, &core_path, &core_name);
|
2013-04-29 01:05:46 +00:00
|
|
|
|
2014-01-03 20:32:42 +00:00
|
|
|
// SET_LIBRETRO_PATH is unsafe here.
|
|
|
|
// Risks booting different and wrong core if core doesn't exist anymore.
|
|
|
|
strlcpy(g_settings.libretro, core_path, sizeof(g_settings.libretro));
|
2013-05-02 12:42:58 +00:00
|
|
|
|
|
|
|
if (path)
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.menu->load_no_rom = false;
|
2013-05-02 12:42:58 +00:00
|
|
|
else
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.menu->load_no_rom = true;
|
2013-04-29 01:05:46 +00:00
|
|
|
|
2013-08-25 09:07:06 +00:00
|
|
|
rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)path);
|
2013-08-24 23:37:15 +00:00
|
|
|
|
|
|
|
#if defined(HAVE_DYNAMIC)
|
2014-05-31 19:45:16 +00:00
|
|
|
menu_update_system_info(driver.menu, NULL);
|
2013-04-29 01:05:46 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-05-09 03:47:32 +00:00
|
|
|
static void menu_init_history(void *data)
|
2013-09-15 13:36:45 +00:00
|
|
|
{
|
2014-06-10 00:06:10 +00:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
2014-05-09 03:47:32 +00:00
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
if (!menu)
|
2014-05-30 17:33:10 +00:00
|
|
|
return;
|
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
if (menu->history)
|
2013-09-15 13:36:45 +00:00
|
|
|
{
|
2014-06-10 00:06:10 +00:00
|
|
|
rom_history_free(menu->history);
|
|
|
|
menu->history = NULL;
|
2013-09-15 13:36:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*g_extern.config_path)
|
|
|
|
{
|
|
|
|
char history_path[PATH_MAX];
|
|
|
|
if (*g_settings.game_history_path)
|
|
|
|
strlcpy(history_path, g_settings.game_history_path, sizeof(history_path));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fill_pathname_resolve_relative(history_path, g_extern.config_path,
|
|
|
|
".retroarch-game-history.txt", sizeof(history_path));
|
|
|
|
}
|
|
|
|
|
2014-06-09 23:42:26 +00:00
|
|
|
RARCH_LOG("[Menu]: Opening history: %s.\n", history_path);
|
2014-06-10 00:06:10 +00:00
|
|
|
menu->history = rom_history_init(history_path, g_settings.game_history_size);
|
2013-09-15 13:36:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-09 03:47:32 +00:00
|
|
|
static void menu_update_libretro_info(void *data)
|
2013-09-15 13:36:45 +00:00
|
|
|
{
|
2014-06-10 00:06:10 +00:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
2014-05-09 03:47:32 +00:00
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
if (!menu)
|
2014-05-09 03:47:32 +00:00
|
|
|
return;
|
|
|
|
|
2013-10-31 01:53:01 +00:00
|
|
|
#ifndef HAVE_DYNAMIC
|
2014-06-10 00:06:10 +00:00
|
|
|
retro_get_system_info(&menu->info);
|
2013-10-31 01:53:01 +00:00
|
|
|
#endif
|
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
core_info_list_free(menu->core_info);
|
|
|
|
menu->core_info = NULL;
|
2014-05-09 16:51:20 +00:00
|
|
|
if (*g_settings.libretro_directory)
|
2014-06-10 00:06:10 +00:00
|
|
|
menu->core_info = core_info_list_new(g_settings.libretro_directory);
|
2014-03-02 13:07:07 +00:00
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
menu_update_system_info(menu, NULL);
|
2013-09-15 13:36:45 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 17:33:10 +00:00
|
|
|
void load_menu_game_prepare_dummy(void)
|
2014-01-23 19:00:25 +00:00
|
|
|
{
|
2014-05-31 19:45:16 +00:00
|
|
|
if (!driver.menu)
|
2014-05-09 03:47:32 +00:00
|
|
|
return;
|
|
|
|
|
2014-01-23 19:00:25 +00:00
|
|
|
// Starts dummy core.
|
|
|
|
*g_extern.fullpath = '\0';
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.menu->load_no_rom = false;
|
2014-01-23 19:00:25 +00:00
|
|
|
|
|
|
|
g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME);
|
|
|
|
g_extern.lifecycle_state &= ~(1ULL << MODE_GAME);
|
|
|
|
g_extern.system.shutdown = false;
|
|
|
|
}
|
|
|
|
|
2014-05-30 17:33:10 +00:00
|
|
|
bool load_menu_game(void)
|
2013-04-28 14:38:13 +00:00
|
|
|
{
|
2014-06-08 12:06:02 +00:00
|
|
|
int rarch_argc, ret;
|
|
|
|
unsigned i;
|
2014-05-09 03:47:32 +00:00
|
|
|
struct rarch_main_wrap args = {0};
|
2014-06-02 23:45:25 +00:00
|
|
|
char *argv_copy[MAX_ARGS];
|
2014-06-03 00:28:38 +00:00
|
|
|
char *rarch_argv[MAX_ARGS] = {NULL};
|
2014-05-09 03:47:32 +00:00
|
|
|
|
2014-05-31 19:45:16 +00:00
|
|
|
if (!driver.menu)
|
2014-05-30 15:49:04 +00:00
|
|
|
return false;
|
|
|
|
|
2014-05-31 19:45:16 +00:00
|
|
|
args.no_rom = driver.menu->load_no_rom;
|
2014-07-17 22:39:31 +00:00
|
|
|
args.verbose = g_extern.verbosity;
|
2013-04-28 14:38:13 +00:00
|
|
|
args.config_path = *g_extern.config_path ? g_extern.config_path : NULL;
|
|
|
|
args.sram_path = *g_extern.savefile_dir ? g_extern.savefile_dir : NULL;
|
|
|
|
args.state_path = *g_extern.savestate_dir ? g_extern.savestate_dir : NULL;
|
2013-04-28 14:58:58 +00:00
|
|
|
args.rom_path = *g_extern.fullpath ? g_extern.fullpath : NULL;
|
2013-09-15 13:36:45 +00:00
|
|
|
args.libretro_path = *g_settings.libretro ? g_settings.libretro : NULL;
|
2014-05-09 03:47:32 +00:00
|
|
|
|
2014-06-03 00:28:38 +00:00
|
|
|
rarch_argc = 0;
|
|
|
|
ret = 0;
|
2014-06-02 23:45:25 +00:00
|
|
|
|
2014-06-03 00:28:38 +00:00
|
|
|
rarch_main_init_wrap(&args, &rarch_argc, rarch_argv);
|
2014-06-02 23:45:25 +00:00
|
|
|
|
2014-06-03 00:28:38 +00:00
|
|
|
if (rarch_argc > 0)
|
|
|
|
{
|
|
|
|
// The pointers themselves are not const, and can be messed around with by getopt_long().
|
|
|
|
memcpy(argv_copy, rarch_argv, sizeof(rarch_argv));
|
2014-06-02 23:45:25 +00:00
|
|
|
|
2014-06-03 00:28:38 +00:00
|
|
|
if (g_extern.main_is_init)
|
|
|
|
rarch_main_deinit();
|
2014-06-03 00:01:49 +00:00
|
|
|
|
2014-06-03 00:28:38 +00:00
|
|
|
ret = rarch_main_init(rarch_argc, rarch_argv);
|
2014-06-02 23:45:25 +00:00
|
|
|
|
2014-06-03 00:28:38 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(argv_copy); i++)
|
|
|
|
free(argv_copy[i]);
|
|
|
|
}
|
2014-05-30 17:33:10 +00:00
|
|
|
|
|
|
|
if (ret != 0)
|
2013-04-28 14:38:13 +00:00
|
|
|
{
|
2014-05-09 03:47:32 +00:00
|
|
|
char name[PATH_MAX], msg[PATH_MAX];
|
|
|
|
|
2013-05-01 01:45:02 +00:00
|
|
|
fill_pathname_base(name, g_extern.fullpath, sizeof(name));
|
|
|
|
snprintf(msg, sizeof(msg), "Failed to load %s.\n", name);
|
|
|
|
msg_queue_push(g_extern.msg_queue, msg, 1, 90);
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.menu->msg_force = true;
|
2013-04-28 14:38:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
2014-05-09 03:47:32 +00:00
|
|
|
|
2014-05-31 19:45:16 +00:00
|
|
|
// Update menu state which depends on config.
|
|
|
|
menu_update_libretro_info(driver.menu);
|
|
|
|
menu_init_history(driver.menu);
|
2014-05-30 15:49:04 +00:00
|
|
|
|
2014-05-31 19:45:16 +00:00
|
|
|
if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->shader_manager_init)
|
|
|
|
driver.menu_ctx->backend->shader_manager_init(driver.menu);
|
2014-05-09 03:47:32 +00:00
|
|
|
|
|
|
|
return true;
|
2013-04-28 14:38:13 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 15:49:04 +00:00
|
|
|
void *menu_init(const void *data)
|
2013-04-18 12:57:28 +00:00
|
|
|
{
|
2014-06-10 00:06:10 +00:00
|
|
|
menu_handle_t *menu;
|
2014-05-30 15:49:04 +00:00
|
|
|
menu_ctx_driver_t *menu_ctx = (menu_ctx_driver_t*)data;
|
2014-05-09 03:47:32 +00:00
|
|
|
|
2014-05-30 15:49:04 +00:00
|
|
|
if (!menu_ctx)
|
2014-05-09 03:47:32 +00:00
|
|
|
return NULL;
|
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
menu = (menu_handle_t*)menu_ctx->init();
|
2014-05-26 21:18:49 +00:00
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
if (!menu)
|
2014-05-27 17:21:44 +00:00
|
|
|
return NULL;
|
2013-04-18 16:33:03 +00:00
|
|
|
|
2014-05-30 15:49:04 +00:00
|
|
|
strlcpy(g_settings.menu.driver, menu_ctx->ident, sizeof(g_settings.menu.driver));
|
2014-05-26 21:18:49 +00:00
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
menu->menu_stack = (file_list_t*)calloc(1, sizeof(file_list_t));
|
|
|
|
menu->selection_buf = (file_list_t*)calloc(1, sizeof(file_list_t));
|
|
|
|
menu->core_info_current = (core_info_t*)calloc(1, sizeof(core_info_t));
|
2014-05-31 19:08:32 +00:00
|
|
|
#ifdef HAVE_SHADER_MANAGER
|
2014-06-10 00:06:10 +00:00
|
|
|
menu->shader = (struct gfx_shader*)calloc(1, sizeof(struct gfx_shader));
|
2014-05-31 19:08:32 +00:00
|
|
|
#endif
|
2014-06-10 00:06:10 +00:00
|
|
|
file_list_push(menu->menu_stack, "", MENU_SETTINGS, 0);
|
|
|
|
menu_clear_navigation(menu);
|
|
|
|
menu->push_start_screen = g_settings.menu_show_start_screen;
|
|
|
|
g_settings.menu_show_start_screen = false;
|
2014-04-14 00:32:54 +00:00
|
|
|
|
2014-05-30 15:49:04 +00:00
|
|
|
if (menu_ctx && menu_ctx->backend && menu_ctx->backend->entries_init)
|
2014-06-10 00:06:10 +00:00
|
|
|
menu_ctx->backend->entries_init(menu, MENU_SETTINGS);
|
2013-11-04 12:18:07 +00:00
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
menu->trigger_state = 0;
|
|
|
|
menu->old_input_state = 0;
|
|
|
|
menu->do_held = false;
|
|
|
|
menu->frame_buf_show = true;
|
|
|
|
menu->current_pad = 0;
|
2013-04-19 15:53:01 +00:00
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
menu_update_libretro_info(menu);
|
2013-04-22 20:14:25 +00:00
|
|
|
|
2014-05-30 15:49:04 +00:00
|
|
|
if (menu_ctx && menu_ctx->backend && menu_ctx->backend->shader_manager_init)
|
2014-06-10 00:06:10 +00:00
|
|
|
menu_ctx->backend->shader_manager_init(menu);
|
2013-04-28 01:48:35 +00:00
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
menu_init_history(menu);
|
|
|
|
menu->last_time = rarch_get_time_usec();
|
2014-05-09 03:47:32 +00:00
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
return menu;
|
2013-04-18 12:57:28 +00:00
|
|
|
}
|
|
|
|
|
2014-05-09 03:47:32 +00:00
|
|
|
void menu_free(void *data)
|
2013-04-18 12:57:28 +00:00
|
|
|
{
|
2014-06-10 00:06:10 +00:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
2014-05-09 03:47:32 +00:00
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
if (!menu)
|
2014-05-09 03:47:32 +00:00
|
|
|
return;
|
2014-05-31 19:08:32 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_SHADER_MANAGER
|
2014-06-10 00:06:10 +00:00
|
|
|
if (menu->shader)
|
|
|
|
free(menu->shader);
|
|
|
|
menu->shader = NULL;
|
2014-05-31 19:08:32 +00:00
|
|
|
#endif
|
2014-05-09 03:47:32 +00:00
|
|
|
|
2014-04-01 02:03:55 +00:00
|
|
|
if (driver.menu_ctx && driver.menu_ctx->free)
|
2014-06-10 00:06:10 +00:00
|
|
|
driver.menu_ctx->free(menu);
|
2013-04-18 15:29:04 +00:00
|
|
|
|
2014-03-06 01:14:38 +00:00
|
|
|
#ifdef HAVE_DYNAMIC
|
2014-06-10 00:06:10 +00:00
|
|
|
libretro_free_system_info(&menu->info);
|
2014-03-06 01:14:38 +00:00
|
|
|
#endif
|
2013-11-04 12:18:07 +00:00
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
file_list_free(menu->menu_stack);
|
|
|
|
file_list_free(menu->selection_buf);
|
2013-11-04 12:18:07 +00:00
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
rom_history_free(menu->history);
|
|
|
|
core_info_list_free(menu->core_info);
|
2013-04-28 01:48:35 +00:00
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
if (menu->core_info_current)
|
|
|
|
free(menu->core_info_current);
|
2014-05-31 18:37:37 +00:00
|
|
|
|
2014-05-30 18:53:10 +00:00
|
|
|
free(data);
|
2013-04-18 12:57:28 +00:00
|
|
|
}
|
2013-04-19 15:53:01 +00:00
|
|
|
|
2013-05-05 19:42:14 +00:00
|
|
|
void menu_ticker_line(char *buf, size_t len, unsigned index, const char *str, bool selected)
|
2013-05-05 09:26:02 +00:00
|
|
|
{
|
|
|
|
size_t str_len = strlen(str);
|
|
|
|
if (str_len <= len)
|
|
|
|
{
|
|
|
|
strlcpy(buf, str, len + 1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-05 19:42:14 +00:00
|
|
|
if (!selected)
|
2013-05-05 20:19:27 +00:00
|
|
|
{
|
|
|
|
strlcpy(buf, str, len + 1 - 3);
|
|
|
|
strlcat(buf, "...", len + 1);
|
|
|
|
}
|
2013-05-05 09:26:02 +00:00
|
|
|
else
|
2013-05-05 19:42:14 +00:00
|
|
|
{
|
|
|
|
// Wrap long strings in options with some kind of ticker line.
|
|
|
|
unsigned ticker_period = 2 * (str_len - len) + 4;
|
|
|
|
unsigned phase = index % ticker_period;
|
|
|
|
|
|
|
|
unsigned phase_left_stop = 2;
|
|
|
|
unsigned phase_left_moving = phase_left_stop + (str_len - len);
|
|
|
|
unsigned phase_right_stop = phase_left_moving + 2;
|
|
|
|
|
|
|
|
unsigned left_offset = phase - phase_left_stop;
|
|
|
|
unsigned right_offset = (str_len - len) - (phase - phase_right_stop);
|
|
|
|
|
|
|
|
// Ticker period: [Wait at left (2 ticks), Progress to right (type_len - w), Wait at right (2 ticks), Progress to left].
|
|
|
|
if (phase < phase_left_stop)
|
|
|
|
strlcpy(buf, str, len + 1);
|
|
|
|
else if (phase < phase_left_moving)
|
|
|
|
strlcpy(buf, str + left_offset, len + 1);
|
|
|
|
else if (phase < phase_right_stop)
|
|
|
|
strlcpy(buf, str + str_len - len, len + 1);
|
|
|
|
else
|
|
|
|
strlcpy(buf, str + right_offset, len + 1);
|
|
|
|
}
|
2013-05-05 09:26:02 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 17:33:10 +00:00
|
|
|
void menu_flush_stack_type(unsigned final_type)
|
2013-11-04 15:23:37 +00:00
|
|
|
{
|
|
|
|
unsigned type;
|
2014-05-30 17:33:10 +00:00
|
|
|
|
2014-05-31 19:45:16 +00:00
|
|
|
if (!driver.menu)
|
2014-05-30 17:33:10 +00:00
|
|
|
return;
|
|
|
|
|
2013-11-04 15:23:37 +00:00
|
|
|
type = 0;
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.menu->need_refresh = true;
|
|
|
|
file_list_get_last(driver.menu->menu_stack, NULL, &type);
|
2013-11-04 15:23:37 +00:00
|
|
|
while (type != final_type)
|
|
|
|
{
|
2014-05-31 19:45:16 +00:00
|
|
|
file_list_pop(driver.menu->menu_stack, &driver.menu->selection_ptr);
|
|
|
|
file_list_get_last(driver.menu->menu_stack, NULL, &type);
|
2013-11-04 15:23:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-30 18:53:10 +00:00
|
|
|
bool menu_iterate(void)
|
2013-04-19 15:53:01 +00:00
|
|
|
{
|
2013-11-04 15:23:37 +00:00
|
|
|
unsigned action;
|
2013-04-19 15:53:01 +00:00
|
|
|
static bool initial_held = true;
|
|
|
|
static bool first_held = false;
|
2014-05-09 03:47:32 +00:00
|
|
|
uint64_t input_state;
|
2014-05-14 01:47:11 +00:00
|
|
|
int32_t input_entry_ret, ret;
|
2014-04-13 10:12:12 +00:00
|
|
|
|
2014-05-09 03:47:32 +00:00
|
|
|
input_state = 0;
|
2014-02-28 00:44:03 +00:00
|
|
|
input_entry_ret = 0;
|
|
|
|
ret = 0;
|
2014-05-09 03:47:32 +00:00
|
|
|
|
2014-05-31 19:45:16 +00:00
|
|
|
if (!driver.menu)
|
2014-05-09 03:47:32 +00:00
|
|
|
return false;
|
2013-04-19 15:53:01 +00:00
|
|
|
|
2013-11-07 20:44:44 +00:00
|
|
|
if (g_extern.lifecycle_state & (1ULL << MODE_MENU_PREINIT))
|
2013-04-19 15:53:01 +00:00
|
|
|
{
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.menu->need_refresh = true;
|
2013-11-07 20:44:44 +00:00
|
|
|
g_extern.lifecycle_state &= ~(1ULL << MODE_MENU_PREINIT);
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.menu->old_input_state |= 1ULL << RARCH_MENU_TOGGLE;
|
2013-04-19 15:53:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rarch_input_poll();
|
2014-03-17 10:34:25 +00:00
|
|
|
rarch_check_block_hotkey();
|
2013-04-19 15:53:01 +00:00
|
|
|
#ifdef HAVE_OVERLAY
|
|
|
|
rarch_check_overlay();
|
|
|
|
#endif
|
2014-02-08 15:27:09 +00:00
|
|
|
rarch_check_fullscreen();
|
2013-04-19 15:53:01 +00:00
|
|
|
|
|
|
|
if (input_key_pressed_func(RARCH_QUIT_KEY) || !video_alive_func())
|
|
|
|
{
|
2013-11-07 20:44:44 +00:00
|
|
|
g_extern.lifecycle_state |= (1ULL << MODE_GAME);
|
2014-03-17 10:34:25 +00:00
|
|
|
return false;
|
2013-04-19 15:53:01 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 17:33:10 +00:00
|
|
|
input_state = menu_input();
|
2013-04-19 15:53:01 +00:00
|
|
|
|
2014-05-31 19:45:16 +00:00
|
|
|
if (driver.menu->do_held)
|
2013-04-19 15:53:01 +00:00
|
|
|
{
|
2013-04-20 22:01:49 +00:00
|
|
|
if (!first_held)
|
2013-04-19 15:53:01 +00:00
|
|
|
{
|
|
|
|
first_held = true;
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.menu->delay_timer = initial_held ? 12 : 6;
|
|
|
|
driver.menu->delay_count = 0;
|
2013-04-19 15:53:01 +00:00
|
|
|
}
|
|
|
|
|
2014-05-31 19:45:16 +00:00
|
|
|
if (driver.menu->delay_count >= driver.menu->delay_timer)
|
2013-04-19 15:53:01 +00:00
|
|
|
{
|
|
|
|
first_held = false;
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.menu->trigger_state = input_state;
|
|
|
|
driver.menu->scroll_accel = min(driver.menu->scroll_accel + 1, 64);
|
2013-04-19 15:53:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
initial_held = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
first_held = false;
|
|
|
|
initial_held = true;
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.menu->scroll_accel = 0;
|
2013-04-19 15:53:01 +00:00
|
|
|
}
|
|
|
|
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.menu->delay_count++;
|
|
|
|
driver.menu->old_input_state = input_state;
|
2013-09-19 12:49:07 +00:00
|
|
|
|
2013-12-09 15:18:58 +00:00
|
|
|
if (driver.block_input)
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.menu->trigger_state = 0;
|
2013-12-09 15:18:58 +00:00
|
|
|
|
2014-06-09 23:42:26 +00:00
|
|
|
action = MENU_ACTION_NOOP;
|
2013-09-26 20:34:06 +00:00
|
|
|
|
|
|
|
// don't run anything first frame, only capture held inputs for old_input_state
|
2014-05-31 19:45:16 +00:00
|
|
|
if (driver.menu->trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_UP))
|
2014-06-09 23:42:26 +00:00
|
|
|
action = MENU_ACTION_UP;
|
2014-05-31 19:45:16 +00:00
|
|
|
else if (driver.menu->trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN))
|
2014-06-09 23:42:26 +00:00
|
|
|
action = MENU_ACTION_DOWN;
|
2014-05-31 19:45:16 +00:00
|
|
|
else if (driver.menu->trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT))
|
2014-06-09 23:42:26 +00:00
|
|
|
action = MENU_ACTION_LEFT;
|
2014-05-31 19:45:16 +00:00
|
|
|
else if (driver.menu->trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT))
|
2014-06-09 23:42:26 +00:00
|
|
|
action = MENU_ACTION_RIGHT;
|
2014-05-31 19:45:16 +00:00
|
|
|
else if (driver.menu->trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_L))
|
2014-06-09 23:42:26 +00:00
|
|
|
action = MENU_ACTION_SCROLL_UP;
|
2014-05-31 19:45:16 +00:00
|
|
|
else if (driver.menu->trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_R))
|
2014-06-09 23:42:26 +00:00
|
|
|
action = MENU_ACTION_SCROLL_DOWN;
|
2014-05-31 19:45:16 +00:00
|
|
|
else if (driver.menu->trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_B))
|
2014-06-09 23:42:26 +00:00
|
|
|
action = MENU_ACTION_CANCEL;
|
2014-05-31 19:45:16 +00:00
|
|
|
else if (driver.menu->trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_A))
|
2014-06-09 23:42:26 +00:00
|
|
|
action = MENU_ACTION_OK;
|
2014-05-31 19:45:16 +00:00
|
|
|
else if (driver.menu->trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_START))
|
2014-06-09 23:42:26 +00:00
|
|
|
action = MENU_ACTION_START;
|
2014-05-31 19:45:16 +00:00
|
|
|
else if (driver.menu->trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT))
|
2014-06-09 23:42:26 +00:00
|
|
|
action = MENU_ACTION_SELECT;
|
2013-09-26 20:34:06 +00:00
|
|
|
|
2014-04-14 00:32:54 +00:00
|
|
|
if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->iterate)
|
2014-05-30 18:23:20 +00:00
|
|
|
input_entry_ret = driver.menu_ctx->backend->iterate(action);
|
2014-03-09 15:47:36 +00:00
|
|
|
|
2014-03-25 09:19:02 +00:00
|
|
|
if (driver.video_data && driver.video_poke && driver.video_poke->set_texture_enable)
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.video_poke->set_texture_enable(driver.video_data, driver.menu->frame_buf_show, MENU_TEXTURE_FULLSCREEN);
|
2013-04-19 15:53:01 +00:00
|
|
|
|
|
|
|
rarch_render_cached_frame();
|
|
|
|
|
2014-06-10 00:44:19 +00:00
|
|
|
// Throttle in case VSync is broken (avoid 1000+ FPS Menu).
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.menu->time = rarch_get_time_usec();
|
|
|
|
driver.menu->delta = (driver.menu->time - driver.menu->last_time) / 1000;
|
|
|
|
driver.menu->target_msec = 750 / g_settings.video.refresh_rate; // Try to sleep less, so we can hopefully rely on FPS logger.
|
|
|
|
driver.menu->sleep_msec = driver.menu->target_msec - driver.menu->delta;
|
2014-05-09 15:29:41 +00:00
|
|
|
|
2014-05-31 19:45:16 +00:00
|
|
|
if (driver.menu->sleep_msec > 0)
|
|
|
|
rarch_sleep((unsigned int)driver.menu->sleep_msec);
|
|
|
|
driver.menu->last_time = rarch_get_time_usec();
|
2013-07-06 18:39:19 +00:00
|
|
|
|
2014-03-25 09:19:02 +00:00
|
|
|
if (driver.video_data && driver.video_poke && driver.video_poke->set_texture_enable)
|
|
|
|
driver.video_poke->set_texture_enable(driver.video_data, false,
|
2013-04-20 08:56:04 +00:00
|
|
|
MENU_TEXTURE_FULLSCREEN);
|
2013-04-19 15:53:01 +00:00
|
|
|
|
2014-04-01 02:03:55 +00:00
|
|
|
if (driver.menu_ctx && driver.menu_ctx->input_postprocess)
|
2014-05-31 19:45:16 +00:00
|
|
|
ret = driver.menu_ctx->input_postprocess(driver.menu->old_input_state);
|
2013-11-04 15:37:51 +00:00
|
|
|
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
unsigned type = 0;
|
2014-05-31 19:45:16 +00:00
|
|
|
file_list_get_last(driver.menu->menu_stack, NULL, &type);
|
2014-06-09 23:42:26 +00:00
|
|
|
while (type != MENU_SETTINGS)
|
2013-11-04 15:37:51 +00:00
|
|
|
{
|
2014-05-31 19:45:16 +00:00
|
|
|
file_list_pop(driver.menu->menu_stack, &driver.menu->selection_ptr);
|
|
|
|
file_list_get_last(driver.menu->menu_stack, NULL, &type);
|
2013-11-04 15:37:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret || input_entry_ret)
|
2014-03-17 10:34:25 +00:00
|
|
|
return false;
|
2013-04-19 15:53:01 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2013-09-15 13:36:45 +00:00
|
|
|
|
|
|
|
// Quite intrusive and error prone.
|
|
|
|
// Likely to have lots of small bugs.
|
|
|
|
// Cleanly exit the main loop to ensure that all the tiny details get set properly.
|
|
|
|
// This should mitigate most of the smaller bugs.
|
2014-05-30 17:33:10 +00:00
|
|
|
bool menu_replace_config(const char *path)
|
2013-09-15 13:36:45 +00:00
|
|
|
{
|
2014-05-31 19:45:16 +00:00
|
|
|
if (!driver.menu)
|
2014-05-30 17:33:10 +00:00
|
|
|
return false;
|
2014-05-09 03:47:32 +00:00
|
|
|
|
2014-05-31 19:45:16 +00:00
|
|
|
if (strcmp(path, g_extern.config_path) == 0)
|
2013-09-15 13:36:45 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (g_extern.config_save_on_exit && *g_extern.config_path)
|
|
|
|
config_save_file(g_extern.config_path);
|
|
|
|
|
|
|
|
strlcpy(g_extern.config_path, path, sizeof(g_extern.config_path));
|
|
|
|
g_extern.block_config_read = false;
|
|
|
|
|
|
|
|
// Load dummy core.
|
|
|
|
*g_extern.fullpath = '\0';
|
|
|
|
*g_settings.libretro = '\0'; // Load core in new config.
|
2013-11-07 20:44:44 +00:00
|
|
|
g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME);
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.menu->load_no_rom = false;
|
2013-09-15 13:36:45 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-22 10:48:33 +00:00
|
|
|
// Save a new config to a file. Filename is based on heuristics to avoid typing.
|
|
|
|
bool menu_save_new_config(void)
|
|
|
|
{
|
|
|
|
char config_dir[PATH_MAX];
|
|
|
|
*config_dir = '\0';
|
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
if (*g_settings.menu_config_directory)
|
|
|
|
strlcpy(config_dir, g_settings.menu_config_directory, sizeof(config_dir));
|
2013-09-22 10:48:33 +00:00
|
|
|
else if (*g_extern.config_path) // Fallback
|
|
|
|
fill_pathname_basedir(config_dir, g_extern.config_path, sizeof(config_dir));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const char *msg = "Config directory not set. Cannot save new config.";
|
|
|
|
msg_queue_clear(g_extern.msg_queue);
|
|
|
|
msg_queue_push(g_extern.msg_queue, msg, 1, 180);
|
|
|
|
RARCH_ERR("%s\n", msg);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool found_path = false;
|
|
|
|
char config_name[PATH_MAX];
|
|
|
|
char config_path[PATH_MAX];
|
2014-05-09 16:51:20 +00:00
|
|
|
if (*g_settings.libretro && path_file_exists(g_settings.libretro)) // Infer file name based on libretro core.
|
2013-09-22 10:48:33 +00:00
|
|
|
{
|
2013-10-22 13:08:17 +00:00
|
|
|
unsigned i;
|
2013-09-22 10:48:33 +00:00
|
|
|
// In case of collision, find an alternative name.
|
2013-10-22 13:08:17 +00:00
|
|
|
for (i = 0; i < 16; i++)
|
2013-09-22 10:48:33 +00:00
|
|
|
{
|
|
|
|
fill_pathname_base(config_name, g_settings.libretro, sizeof(config_name));
|
|
|
|
path_remove_extension(config_name);
|
|
|
|
fill_pathname_join(config_path, config_dir, config_name, sizeof(config_path));
|
|
|
|
|
|
|
|
char tmp[64];
|
|
|
|
*tmp = '\0';
|
|
|
|
if (i)
|
|
|
|
snprintf(tmp, sizeof(tmp), "-%u.cfg", i);
|
|
|
|
else
|
|
|
|
strlcpy(tmp, ".cfg", sizeof(tmp));
|
|
|
|
|
|
|
|
strlcat(config_path, tmp, sizeof(config_path));
|
|
|
|
|
|
|
|
if (!path_file_exists(config_path))
|
|
|
|
{
|
|
|
|
found_path = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fallback to system time ...
|
|
|
|
if (!found_path)
|
|
|
|
{
|
|
|
|
RARCH_WARN("Cannot infer new config path. Use current time.\n");
|
|
|
|
fill_dated_filename(config_name, "cfg", sizeof(config_name));
|
|
|
|
fill_pathname_join(config_path, config_dir, config_name, sizeof(config_path));
|
|
|
|
}
|
|
|
|
|
|
|
|
char msg[512];
|
|
|
|
bool ret;
|
|
|
|
if (config_save_file(config_path))
|
|
|
|
{
|
|
|
|
strlcpy(g_extern.config_path, config_path, sizeof(g_extern.config_path));
|
|
|
|
snprintf(msg, sizeof(msg), "Saved new config to \"%s\".", config_path);
|
|
|
|
RARCH_LOG("%s\n", msg);
|
|
|
|
ret = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
snprintf(msg, sizeof(msg), "Failed saving config to \"%s\".", config_path);
|
|
|
|
RARCH_ERR("%s\n", msg);
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg_queue_clear(g_extern.msg_queue);
|
|
|
|
msg_queue_push(g_extern.msg_queue, msg, 1, 180);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-11-08 03:48:31 +00:00
|
|
|
static inline int menu_list_get_first_char(file_list_t *buf, unsigned offset)
|
2013-11-04 10:57:24 +00:00
|
|
|
{
|
|
|
|
const char *path = NULL;
|
2013-11-08 03:48:31 +00:00
|
|
|
file_list_get_alt_at_offset(buf, offset, &path);
|
2013-11-04 10:57:24 +00:00
|
|
|
int ret = tolower(*path);
|
2014-04-13 10:12:12 +00:00
|
|
|
|
2013-11-04 10:57:24 +00:00
|
|
|
// "Normalize" non-alphabetical entries so they are lumped together for purposes of jumping.
|
|
|
|
if (ret < 'a')
|
|
|
|
ret = 'a' - 1;
|
|
|
|
else if (ret > 'z')
|
|
|
|
ret = 'z' + 1;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-11-08 03:48:31 +00:00
|
|
|
static inline bool menu_list_elem_is_dir(file_list_t *buf, unsigned offset)
|
2013-11-04 10:57:24 +00:00
|
|
|
{
|
|
|
|
const char *path = NULL;
|
|
|
|
unsigned type = 0;
|
2013-11-08 03:48:31 +00:00
|
|
|
file_list_get_at_offset(buf, offset, &path, &type);
|
2014-06-09 23:42:26 +00:00
|
|
|
return type != MENU_FILE_PLAIN;
|
2013-11-04 10:57:24 +00:00
|
|
|
}
|
|
|
|
|
2014-06-01 00:29:19 +00:00
|
|
|
void menu_build_scroll_indices(void *data)
|
2013-11-04 10:57:24 +00:00
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
int current;
|
|
|
|
bool current_is_dir;
|
2014-06-01 00:29:19 +00:00
|
|
|
file_list_t *buf = (file_list_t*)data;
|
2014-05-30 20:06:54 +00:00
|
|
|
|
2014-06-01 00:29:19 +00:00
|
|
|
if (!driver.menu || !buf)
|
2014-05-30 20:06:54 +00:00
|
|
|
return;
|
2013-11-04 10:57:24 +00:00
|
|
|
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.menu->scroll_indices_size = 0;
|
2013-11-04 10:57:24 +00:00
|
|
|
if (!buf->size)
|
|
|
|
return;
|
|
|
|
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.menu->scroll_indices[driver.menu->scroll_indices_size++] = 0;
|
2013-11-04 10:57:24 +00:00
|
|
|
|
2013-11-08 02:37:06 +00:00
|
|
|
current = menu_list_get_first_char(buf, 0);
|
|
|
|
current_is_dir = menu_list_elem_is_dir(buf, 0);
|
2013-11-04 10:57:24 +00:00
|
|
|
|
|
|
|
for (i = 1; i < buf->size; i++)
|
|
|
|
{
|
|
|
|
int first;
|
|
|
|
bool is_dir;
|
|
|
|
|
2013-11-08 02:37:06 +00:00
|
|
|
first = menu_list_get_first_char(buf, i);
|
|
|
|
is_dir = menu_list_elem_is_dir(buf, i);
|
2013-11-04 10:57:24 +00:00
|
|
|
|
|
|
|
if ((current_is_dir && !is_dir) || (first > current))
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.menu->scroll_indices[driver.menu->scroll_indices_size++] = i;
|
2013-11-04 10:57:24 +00:00
|
|
|
|
|
|
|
current = first;
|
|
|
|
current_is_dir = is_dir;
|
|
|
|
}
|
|
|
|
|
2014-05-31 19:45:16 +00:00
|
|
|
driver.menu->scroll_indices[driver.menu->scroll_indices_size++] = buf->size - 1;
|
2013-11-04 10:57:24 +00:00
|
|
|
}
|