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
|
2015-01-07 16:46:50 +00:00
|
|
|
* Copyright (C) 2011-2015 - 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/>.
|
|
|
|
*/
|
|
|
|
|
2015-06-05 16:23:06 +00:00
|
|
|
#include <file/file_path.h>
|
|
|
|
|
2015-01-10 03:53:37 +00:00
|
|
|
#include "menu.h"
|
2015-09-07 00:43:52 +00:00
|
|
|
#include "menu_cbs.h"
|
2015-09-25 23:23:10 +00:00
|
|
|
#include "menu_display.h"
|
2015-06-23 10:53:49 +00:00
|
|
|
#include "menu_hash.h"
|
2014-09-24 05:56:47 +00:00
|
|
|
#include "menu_shader.h"
|
2015-06-13 17:12:10 +00:00
|
|
|
|
|
|
|
#include "../general.h"
|
2014-10-28 18:54:23 +00:00
|
|
|
#include "../frontend/frontend.h"
|
2013-04-17 21:31:49 +00:00
|
|
|
|
2014-09-01 00:11:51 +00:00
|
|
|
static void menu_environment_get(int *argc, char *argv[],
|
|
|
|
void *args, void *params_data)
|
2014-07-27 18:24:06 +00:00
|
|
|
{
|
|
|
|
struct rarch_main_wrap *wrap_args = (struct rarch_main_wrap*)params_data;
|
2015-03-21 03:43:18 +00:00
|
|
|
global_t *global = global_get_ptr();
|
2015-03-20 19:43:22 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2015-04-14 10:56:37 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2014-10-16 22:28:03 +00:00
|
|
|
|
|
|
|
if (!wrap_args)
|
|
|
|
return;
|
2014-07-27 18:24:06 +00:00
|
|
|
|
2015-04-14 10:56:37 +00:00
|
|
|
wrap_args->no_content = menu->load_no_content;
|
2015-07-27 15:18:10 +00:00
|
|
|
if (!global->has_set.verbosity)
|
2015-03-21 03:43:18 +00:00
|
|
|
wrap_args->verbose = global->verbosity;
|
|
|
|
|
2015-07-27 15:18:10 +00:00
|
|
|
wrap_args->config_path = *global->path.config ? global->path.config : NULL;
|
|
|
|
wrap_args->sram_path = *global->dir.savefile ? global->dir.savefile : NULL;
|
|
|
|
wrap_args->state_path = *global->dir.savestate ? global->dir.savestate : NULL;
|
|
|
|
wrap_args->content_path = *global->path.fullpath ? global->path.fullpath : NULL;
|
2015-03-21 03:43:18 +00:00
|
|
|
|
2015-07-27 15:18:10 +00:00
|
|
|
if (!global->has_set.libretro)
|
2015-03-20 19:43:22 +00:00
|
|
|
wrap_args->libretro_path = *settings->libretro ? settings->libretro : NULL;
|
2014-07-27 18:24:06 +00:00
|
|
|
wrap_args->touched = true;
|
|
|
|
}
|
|
|
|
|
2015-06-08 09:38:27 +00:00
|
|
|
static void menu_push_to_history_playlist(void)
|
2013-04-28 14:38:13 +00:00
|
|
|
{
|
2015-03-20 19:43:22 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2015-03-21 03:43:18 +00:00
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
|
2015-03-20 19:43:22 +00:00
|
|
|
if (!settings->history_list_enable)
|
2014-10-17 02:17:28 +00:00
|
|
|
return;
|
|
|
|
|
2015-07-27 15:18:10 +00:00
|
|
|
if (*global->path.fullpath)
|
2014-09-06 19:52:24 +00:00
|
|
|
{
|
2015-09-22 20:14:03 +00:00
|
|
|
char tmp[PATH_MAX_LENGTH];
|
|
|
|
char str[PATH_MAX_LENGTH];
|
2014-09-11 23:11:14 +00:00
|
|
|
|
2015-07-27 15:18:10 +00:00
|
|
|
fill_pathname_base(tmp, global->path.fullpath, sizeof(tmp));
|
2014-10-11 14:52:52 +00:00
|
|
|
snprintf(str, sizeof(str), "INFO - Loading %s ...", tmp);
|
2015-09-22 20:14:03 +00:00
|
|
|
menu_display_msg_queue_push(str, 1, 1, false);
|
2014-09-06 19:52:24 +00:00
|
|
|
}
|
|
|
|
|
2014-10-12 00:31:25 +00:00
|
|
|
content_playlist_push(g_defaults.history,
|
2015-07-27 15:18:10 +00:00
|
|
|
global->path.fullpath,
|
2015-05-25 22:12:49 +00:00
|
|
|
NULL,
|
2015-03-20 19:43:22 +00:00
|
|
|
settings->libretro,
|
2015-05-25 22:12:49 +00:00
|
|
|
global->menu.info.library_name,
|
2015-06-08 21:38:03 +00:00
|
|
|
NULL,
|
2015-05-25 22:12:49 +00:00
|
|
|
NULL);
|
2014-10-11 14:52:52 +00:00
|
|
|
}
|
|
|
|
|
2015-01-10 05:09:30 +00:00
|
|
|
/**
|
|
|
|
* menu_load_content:
|
|
|
|
*
|
|
|
|
* Loads content into currently selected core.
|
|
|
|
* Will also optionally push the content entry to the history playlist.
|
|
|
|
*
|
|
|
|
* Returns: true (1) if successful, otherwise false (0).
|
|
|
|
**/
|
2015-06-23 04:44:29 +00:00
|
|
|
bool menu_load_content(enum rarch_core_type type)
|
2014-10-11 14:52:52 +00:00
|
|
|
{
|
2015-09-26 21:51:35 +00:00
|
|
|
bool msg_force = true;
|
2015-04-14 10:56:37 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-03-21 03:43:18 +00:00
|
|
|
driver_t *driver = driver_get_ptr();
|
|
|
|
global_t *global = global_get_ptr();
|
2015-03-18 18:40:00 +00:00
|
|
|
|
2014-09-06 19:52:24 +00:00
|
|
|
/* redraw menu frame */
|
2015-09-26 21:51:35 +00:00
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_SET_MSG_FORCE, &msg_force);
|
2014-09-06 19:52:24 +00:00
|
|
|
|
2015-08-21 02:33:55 +00:00
|
|
|
menu_iterate(true, MENU_ACTION_NOOP);
|
2015-08-21 02:56:14 +00:00
|
|
|
menu_iterate_render();
|
2014-07-27 23:00:16 +00:00
|
|
|
|
2014-08-02 22:00:41 +00:00
|
|
|
if (!(main_load_content(0, NULL, NULL, menu_environment_get,
|
2015-03-18 18:40:00 +00:00
|
|
|
driver->frontend_ctx->process_args)))
|
2013-04-28 14:38:13 +00:00
|
|
|
{
|
2015-06-12 22:09:09 +00:00
|
|
|
char name[PATH_MAX_LENGTH] = {0};
|
|
|
|
char msg[PATH_MAX_LENGTH] = {0};
|
2014-05-09 03:47:32 +00:00
|
|
|
|
2015-07-27 15:18:10 +00:00
|
|
|
fill_pathname_base(name, global->path.fullpath, sizeof(name));
|
2013-05-01 01:45:02 +00:00
|
|
|
snprintf(msg, sizeof(msg), "Failed to load %s.\n", name);
|
2015-09-22 20:14:03 +00:00
|
|
|
menu_display_msg_queue_push(msg, 1, 90, false);
|
2014-07-27 06:17:38 +00:00
|
|
|
|
2013-04-28 14:38:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
2014-05-09 03:47:32 +00:00
|
|
|
|
2015-04-14 10:56:37 +00:00
|
|
|
menu_shader_manager_init(menu);
|
2014-05-09 03:47:32 +00:00
|
|
|
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_HISTORY_INIT);
|
2015-03-22 22:17:29 +00:00
|
|
|
|
2015-07-27 15:18:10 +00:00
|
|
|
if (*global->path.fullpath || (menu && menu->load_no_content))
|
2015-06-08 09:38:27 +00:00
|
|
|
menu_push_to_history_playlist();
|
2015-03-22 22:17:29 +00:00
|
|
|
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_VIDEO_SET_ASPECT_RATIO);
|
|
|
|
event_command(EVENT_CMD_RESUME);
|
2014-08-02 16:41:43 +00:00
|
|
|
|
2014-05-09 03:47:32 +00:00
|
|
|
return true;
|
2013-04-28 14:38:13 +00:00
|
|
|
}
|
|
|
|
|
2015-09-07 00:28:26 +00:00
|
|
|
int menu_common_load_content(
|
|
|
|
const char *core_path, const char *fullpath,
|
|
|
|
bool persist, enum rarch_core_type type)
|
2015-06-08 09:38:27 +00:00
|
|
|
{
|
2015-09-26 21:51:35 +00:00
|
|
|
bool msg_force = true;
|
2015-09-07 00:28:26 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
global_t *global = global_get_ptr();
|
2015-06-23 10:53:49 +00:00
|
|
|
menu_list_t *menu_list = menu_list_get_ptr();
|
2015-09-07 00:34:27 +00:00
|
|
|
enum event_command cmd = EVENT_CMD_NONE;
|
2015-06-08 09:38:27 +00:00
|
|
|
|
2015-09-07 00:28:26 +00:00
|
|
|
if (core_path)
|
|
|
|
{
|
|
|
|
strlcpy(settings->libretro, core_path, sizeof(settings->libretro));
|
|
|
|
event_command(EVENT_CMD_LOAD_CORE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fullpath)
|
|
|
|
{
|
|
|
|
strlcpy(global->path.fullpath, fullpath, sizeof(global->path.fullpath));
|
|
|
|
}
|
|
|
|
|
2015-06-23 04:44:29 +00:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case CORE_TYPE_PLAIN:
|
|
|
|
case CORE_TYPE_DUMMY:
|
2015-09-07 00:34:27 +00:00
|
|
|
cmd = persist ? EVENT_CMD_LOAD_CONTENT_PERSIST : EVENT_CMD_LOAD_CONTENT;
|
2015-06-23 04:44:29 +00:00
|
|
|
break;
|
|
|
|
#ifdef HAVE_FFMPEG
|
|
|
|
case CORE_TYPE_FFMPEG:
|
2015-09-07 00:34:27 +00:00
|
|
|
cmd = EVENT_CMD_LOAD_CONTENT_FFMPEG;
|
2015-06-23 04:44:29 +00:00
|
|
|
break;
|
|
|
|
#endif
|
2015-06-28 15:02:01 +00:00
|
|
|
case CORE_TYPE_IMAGEVIEWER:
|
2015-06-28 16:55:00 +00:00
|
|
|
#ifdef HAVE_IMAGEVIEWER
|
2015-09-07 00:34:27 +00:00
|
|
|
cmd = EVENT_CMD_LOAD_CONTENT_IMAGEVIEWER;
|
2015-06-28 16:55:00 +00:00
|
|
|
#endif
|
2015-06-28 15:02:01 +00:00
|
|
|
break;
|
2015-06-23 04:44:29 +00:00
|
|
|
}
|
2015-06-08 09:38:27 +00:00
|
|
|
|
2015-09-07 00:34:27 +00:00
|
|
|
if (cmd != EVENT_CMD_NONE)
|
|
|
|
event_command(cmd);
|
|
|
|
|
2015-06-14 02:01:21 +00:00
|
|
|
menu_list_flush_stack(menu_list, NULL, MENU_SETTINGS);
|
2015-09-26 21:51:35 +00:00
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_SET_MSG_FORCE, &msg_force);
|
2015-06-23 10:53:49 +00:00
|
|
|
|
2015-09-07 00:43:52 +00:00
|
|
|
generic_action_ok_displaylist_push("",
|
|
|
|
"", 0, 0, 0, ACTION_OK_DL_CONTENT_SETTINGS);
|
2015-09-04 14:55:26 +00:00
|
|
|
|
|
|
|
return -1;
|
2015-06-08 09:38:27 +00:00
|
|
|
}
|
|
|
|
|
2015-08-21 18:56:12 +00:00
|
|
|
/**
|
|
|
|
* menu_free:
|
|
|
|
* @menu : Menu handle.
|
|
|
|
*
|
|
|
|
* Frees a menu handle
|
|
|
|
**/
|
|
|
|
void menu_free(menu_handle_t *menu)
|
|
|
|
{
|
|
|
|
global_t *global = global_get_ptr();
|
2015-09-25 20:01:34 +00:00
|
|
|
if (!menu)
|
2015-08-21 18:56:12 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (menu->playlist)
|
|
|
|
content_playlist_free(menu->playlist);
|
|
|
|
menu->playlist = NULL;
|
|
|
|
|
|
|
|
menu_shader_free(menu);
|
2015-09-24 12:17:03 +00:00
|
|
|
|
2015-09-24 19:02:28 +00:00
|
|
|
menu_input_free();
|
2015-09-25 17:32:35 +00:00
|
|
|
menu_navigation_free();
|
2015-08-21 18:56:12 +00:00
|
|
|
menu_driver_free(menu);
|
|
|
|
|
|
|
|
#ifdef HAVE_DYNAMIC
|
|
|
|
libretro_free_system_info(&global->menu.info);
|
|
|
|
#endif
|
|
|
|
|
2015-09-25 23:23:10 +00:00
|
|
|
menu_display_free();
|
2015-08-21 19:19:29 +00:00
|
|
|
menu_entries_free();
|
2015-08-21 18:56:12 +00:00
|
|
|
|
|
|
|
event_command(EVENT_CMD_HISTORY_DEINIT);
|
|
|
|
|
|
|
|
if (global->core_info.list)
|
|
|
|
core_info_list_free(global->core_info.list);
|
|
|
|
|
|
|
|
if (global->core_info.current)
|
|
|
|
free(global->core_info.current);
|
|
|
|
global->core_info.current = NULL;
|
|
|
|
|
|
|
|
free(menu);
|
|
|
|
}
|
|
|
|
|
2015-01-09 20:54:08 +00:00
|
|
|
/**
|
|
|
|
* menu_init:
|
|
|
|
* @data : Menu context handle.
|
|
|
|
*
|
|
|
|
* Create and initialize menu handle.
|
|
|
|
*
|
|
|
|
* Returns: menu handle on success, otherwise NULL.
|
|
|
|
**/
|
2014-05-30 15:49:04 +00:00
|
|
|
void *menu_init(const void *data)
|
2013-04-18 12:57:28 +00:00
|
|
|
{
|
2015-03-22 03:48:50 +00:00
|
|
|
menu_handle_t *menu = NULL;
|
2014-05-30 15:49:04 +00:00
|
|
|
menu_ctx_driver_t *menu_ctx = (menu_ctx_driver_t*)data;
|
2015-03-22 03:48:50 +00:00
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
settings_t *settings = config_get_ptr();
|
2015-08-21 18:54:56 +00:00
|
|
|
|
2014-05-30 15:49:04 +00:00
|
|
|
if (!menu_ctx)
|
2014-05-09 03:47:32 +00:00
|
|
|
return NULL;
|
|
|
|
|
2014-07-25 21:33:49 +00:00
|
|
|
if (!(menu = (menu_handle_t*)menu_ctx->init()))
|
2014-05-27 17:21:44 +00:00
|
|
|
return NULL;
|
2013-04-18 16:33:03 +00:00
|
|
|
|
2015-03-20 19:43:22 +00:00
|
|
|
strlcpy(settings->menu.driver, menu_ctx->ident,
|
|
|
|
sizeof(settings->menu.driver));
|
2014-05-26 21:18:49 +00:00
|
|
|
|
2015-08-21 19:19:29 +00:00
|
|
|
if (!menu_entries_init(menu))
|
2015-02-12 18:14:10 +00:00
|
|
|
goto error;
|
2014-10-17 23:17:00 +00:00
|
|
|
|
2015-07-27 15:18:10 +00:00
|
|
|
global->core_info.current = (core_info_t*)calloc(1, sizeof(core_info_t));
|
|
|
|
if (!global->core_info.current)
|
2015-02-12 18:14:10 +00:00
|
|
|
goto error;
|
|
|
|
|
2014-05-31 19:08:32 +00:00
|
|
|
#ifdef HAVE_SHADER_MANAGER
|
2015-01-19 20:24:08 +00:00
|
|
|
menu->shader = (struct video_shader*)calloc(1, sizeof(struct video_shader));
|
2015-02-12 18:14:10 +00:00
|
|
|
if (!menu->shader)
|
|
|
|
goto error;
|
2014-05-31 19:08:32 +00:00
|
|
|
#endif
|
2015-06-15 00:08:25 +00:00
|
|
|
|
2015-07-08 03:48:03 +00:00
|
|
|
menu->push_help_screen = settings->menu_show_start_screen;
|
2015-07-17 13:03:17 +00:00
|
|
|
menu->help_screen_type = MENU_HELP_WELCOME;
|
2015-03-20 19:43:22 +00:00
|
|
|
settings->menu_show_start_screen = false;
|
2014-04-14 00:32:54 +00:00
|
|
|
|
2015-07-08 14:45:04 +00:00
|
|
|
#if 0
|
|
|
|
if (settings->bundle_assets_extract_enable &&
|
|
|
|
(strcmp(PACKAGE_VERSION, settings->bundle_assets_last_extracted_version) != 0)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
menu->push_help_screen = true;
|
|
|
|
menu->help_screen_type = MENU_HELP_EXTRACT;
|
|
|
|
|
|
|
|
rarch_main_data_msg_queue_push(DATA_TYPE_FILE, "cb_bundle_extract", "cb_bundle_extract", 0, 1, true);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-09-24 05:56:47 +00:00
|
|
|
menu_shader_manager_init(menu);
|
2013-04-28 01:48:35 +00:00
|
|
|
|
2015-09-25 23:23:10 +00:00
|
|
|
if (!menu_display_init())
|
2015-02-12 18:14:10 +00:00
|
|
|
goto error;
|
2015-02-10 23:40:18 +00:00
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
return menu;
|
2015-08-21 18:56:12 +00:00
|
|
|
|
2015-02-12 18:14:10 +00:00
|
|
|
error:
|
2015-08-21 18:56:12 +00:00
|
|
|
menu_free(menu);
|
|
|
|
|
2015-02-12 18:14:10 +00:00
|
|
|
return NULL;
|
2013-04-18 12:57:28 +00:00
|
|
|
}
|
|
|
|
|