Builtin image viewer should now work

This commit is contained in:
twinaphex 2015-06-28 17:21:32 +02:00
parent 8882f762c4
commit 57ae359e62
17 changed files with 150 additions and 38 deletions

View File

@ -1011,6 +1011,9 @@ bool event_command(enum event_command cmd)
rarch_main_set_state(RARCH_ACTION_STATE_LOAD_CONTENT_FFMPEG);
break;
#endif
case EVENT_CMD_LOAD_CONTENT_IMAGEVIEWER:
rarch_main_set_state(RARCH_ACTION_STATE_LOAD_CONTENT_IMAGEVIEWER);
break;
case EVENT_CMD_LOAD_CONTENT:
#ifdef HAVE_DYNAMIC
event_command(EVENT_CMD_LOAD_CONTENT_PERSIST);

View File

@ -33,6 +33,7 @@ enum event_command
#ifdef HAVE_FFMPEG
EVENT_CMD_LOAD_CONTENT_FFMPEG,
#endif
EVENT_CMD_LOAD_CONTENT_IMAGEVIEWER,
/* Loads core. */
EVENT_CMD_LOAD_CORE_DEINIT,
EVENT_CMD_LOAD_CORE,

View File

@ -449,8 +449,11 @@ static void config_set_defaults(void)
settings->load_dummy_on_core_shutdown = load_dummy_on_core_shutdown;
#ifdef HAVE_FFMPEG
settings->mediaplayer.builtin_enable = true;
settings->multimedia.builtin_mediaplayer_enable = true;
#else
settings->multimedia.builtin_mediaplayer_enable = false;
#endif
settings->multimedia.builtin_imageviewer_enable = true;
settings->video.scale = scale;
settings->video.fullscreen = global->force_fullscreen ? true : fullscreen;
settings->video.windowed_fullscreen = windowed_fullscreen;
@ -1442,9 +1445,8 @@ static bool config_load_file(const char *path, bool set_defaults)
CONFIG_GET_BOOL_BASE(conf, settings, ui.suspend_screensaver_enable, "suspend_screensaver_enable");
CONFIG_GET_BOOL_BASE(conf, settings, fps_show, "fps_show");
CONFIG_GET_BOOL_BASE(conf, settings, load_dummy_on_core_shutdown, "load_dummy_on_core_shutdown");
#ifdef HAVE_FFMPEG
CONFIG_GET_BOOL_BASE(conf, settings, mediaplayer.builtin_enable, "builtin_mediaplayer_enable");
#endif
CONFIG_GET_BOOL_BASE(conf, settings, multimedia.builtin_mediaplayer_enable, "builtin_mediaplayer_enable");
CONFIG_GET_BOOL_BASE(conf, settings, multimedia.builtin_imageviewer_enable, "builtin_imageviewer_enable");
config_get_path(conf, "libretro_info_path", settings->libretro_info_path, sizeof(settings->libretro_info_path));
@ -2307,10 +2309,10 @@ bool config_save_file(const char *path)
settings->input.input_descriptor_hide_unbound);
config_set_bool(conf, "load_dummy_on_core_shutdown",
settings->load_dummy_on_core_shutdown);
#ifdef HAVE_FFMPEG
config_set_bool(conf, "builtin_mediaplayer_enable",
settings->mediaplayer.builtin_enable);
#endif
settings->multimedia.builtin_mediaplayer_enable);
config_set_bool(conf, "builtin_imageviewer_enable",
settings->multimedia.builtin_imageviewer_enable);
config_set_bool(conf, "fps_show", settings->fps_show);
config_set_bool(conf, "ui_menubar_enable", settings->ui.menubar_enable);
config_set_path(conf, "libretro_path", settings->libretro);

View File

@ -266,12 +266,11 @@ typedef struct settings
bool set_supports_no_game_enable;
} core;
#ifdef HAVE_FFMPEG
struct
{
bool builtin_enable;
} mediaplayer;
#endif
bool builtin_mediaplayer_enable;
bool builtin_imageviewer_enable;
} multimedia;
int state_slot;

View File

@ -444,15 +444,25 @@ static int deferred_push_detect_core_list(menu_displaylist_info_t *info)
(void)settings;
#ifdef HAVE_FFMPEG
if (settings->mediaplayer.builtin_enable)
if (settings->multimedia.builtin_mediaplayer_enable ||
settings->multimedia.builtin_imageviewer_enable)
{
struct retro_system_info sysinfo = {0};
libretro_ffmpeg_retro_get_system_info(&sysinfo);
strlcat(info->exts, "|", sizeof(info->exts));
strlcat(info->exts, sysinfo.valid_extensions, sizeof(info->exts));
}
#ifdef HAVE_FFMPEG
if (settings->multimedia.builtin_mediaplayer_enable)
{
libretro_ffmpeg_retro_get_system_info(&sysinfo);
strlcat(info->exts, "|", sizeof(info->exts));
strlcat(info->exts, sysinfo.valid_extensions, sizeof(info->exts));
}
if (settings->multimedia.builtin_imageviewer_enable)
{
libretro_imageviewer_retro_get_system_info(&sysinfo);
strlcat(info->exts, "|", sizeof(info->exts));
strlcat(info->exts, sysinfo.valid_extensions, sizeof(info->exts));
}
#endif
}
return menu_displaylist_push_list(info, DISPLAYLIST_CORES_DETECTED);
}
@ -478,15 +488,25 @@ static int deferred_push_default(menu_displaylist_info_t *info)
(void)settings;
#ifdef HAVE_FFMPEG
if (settings->mediaplayer.builtin_enable)
if (settings->multimedia.builtin_mediaplayer_enable ||
settings->multimedia.builtin_imageviewer_enable)
{
struct retro_system_info sysinfo = {0};
libretro_ffmpeg_retro_get_system_info(&sysinfo);
strlcat(info->exts, "|", sizeof(info->exts));
strlcat(info->exts, sysinfo.valid_extensions, sizeof(info->exts));
}
#ifdef HAVE_FFMPEG
if (settings->multimedia.builtin_mediaplayer_enable)
{
libretro_ffmpeg_retro_get_system_info(&sysinfo);
strlcat(info->exts, "|", sizeof(info->exts));
strlcat(info->exts, sysinfo.valid_extensions, sizeof(info->exts));
}
#endif
if (settings->multimedia.builtin_imageviewer_enable)
{
libretro_imageviewer_retro_get_system_info(&sysinfo);
strlcat(info->exts, "|", sizeof(info->exts));
strlcat(info->exts, sysinfo.valid_extensions, sizeof(info->exts));
}
}
return menu_displaylist_push_list(info, DISPLAYLIST_DEFAULT);
}

View File

@ -633,6 +633,19 @@ static void menu_action_setting_disp_set_label_menu_file_image(
path, "(IMG)", s2, len2);
}
static void menu_action_setting_disp_set_label_menu_file_imageviewer(
file_list_t* list,
unsigned *w, unsigned type, unsigned i,
const char *label,
char *s, size_t len,
const char *entry_label,
const char *path,
char *s2, size_t len2)
{
menu_action_setting_generic_disp_set_label(w, s, len,
path, "(IMAGE)", s2, len2);
}
static void menu_action_setting_disp_set_label_movie(
file_list_t* list,
unsigned *w, unsigned type, unsigned i,
@ -1005,6 +1018,10 @@ static int menu_cbs_init_bind_get_string_representation_compare_type(
cbs->action_get_value =
menu_action_setting_disp_set_label_menu_file_image;
break;
case MENU_FILE_IMAGEVIEWER:
cbs->action_get_value =
menu_action_setting_disp_set_label_menu_file_imageviewer;
break;
case MENU_FILE_USE_DIRECTORY:
cbs->action_get_value =
menu_action_setting_disp_set_label_menu_file_use_directory;

View File

@ -455,6 +455,7 @@ static int menu_cbs_init_bind_left_compare_type(menu_file_list_cbs_t *cbs,
case MENU_FILE_REMAP:
case MENU_FILE_MOVIE:
case MENU_FILE_MUSIC:
case MENU_FILE_IMAGEVIEWER:
case MENU_FILE_PLAYLIST_COLLECTION:
case MENU_SETTING_GROUP:
switch (menu_label_hash)

View File

@ -1127,6 +1127,27 @@ static int action_ok_file_load_ffmpeg(const char *path,
}
#endif
static int action_ok_file_load_imageviewer(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
const char *menu_path = NULL;
global_t *global = global_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
if (!menu_list)
return -1;
menu_list_get_last(menu_list->menu_stack,
&menu_path, NULL, NULL, NULL);
fill_pathname_join(global->fullpath, menu_path, path,
sizeof(global->fullpath));
menu_common_load_content(true, CORE_TYPE_IMAGEVIEWER);
return 0;
}
static int action_ok_file_load(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
@ -1917,6 +1938,9 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs,
cbs->action_ok = action_ok_file_load_ffmpeg;
#endif
break;
case MENU_FILE_IMAGEVIEWER:
cbs->action_ok = action_ok_file_load_imageviewer;
break;
case MENU_SETTINGS:
case MENU_SETTING_GROUP:
case MENU_SETTING_SUBGROUP:

View File

@ -386,6 +386,7 @@ static int menu_cbs_init_bind_right_compare_type(menu_file_list_cbs_t *cbs,
case MENU_FILE_REMAP:
case MENU_FILE_MOVIE:
case MENU_FILE_MUSIC:
case MENU_FILE_IMAGEVIEWER:
case MENU_FILE_PLAYLIST_COLLECTION:
case MENU_SETTING_GROUP:
switch (menu_label_hash)

View File

@ -574,6 +574,8 @@ static const char *menu_hash_to_str_us_label(uint32_t hash)
return "update_glsl_shaders";
case MENU_LABEL_SCREEN_RESOLUTION:
return "screen_resolution";
case MENU_LABEL_USE_BUILTIN_IMAGE_VIEWER:
return "use_builtin_image_viewer";
default:
break;
}
@ -1404,6 +1406,8 @@ const char *menu_hash_to_str_us(uint32_t hash)
return "Frame Throttle Settings";
case MENU_VALUE_SEARCH:
return "Search:";
case MENU_LABEL_VALUE_USE_BUILTIN_IMAGE_VIEWER:
return "Use Builtin Image Viewer";
default:
break;
}

View File

@ -168,7 +168,7 @@ void menu_common_load_content(bool persist, enum rarch_core_type type)
break;
#endif
case CORE_TYPE_IMAGEVIEWER:
/* TODO/FIXME */
event_command(EVENT_CMD_LOAD_CONTENT_IMAGEVIEWER);
break;
}

View File

@ -81,6 +81,7 @@ typedef enum
MENU_FILE_CARCHIVE,
MENU_FILE_IN_CARCHIVE,
MENU_FILE_IMAGE,
MENU_FILE_IMAGEVIEWER,
MENU_FILE_REMAP,
MENU_FILE_DOWNLOAD_CORE,
MENU_FILE_DOWNLOAD_CORE_INFO,

View File

@ -1980,24 +1980,30 @@ static int menu_displaylist_parse_generic(menu_displaylist_info_t *info, bool *n
break;
}
#ifdef HAVE_FFMPEG
if (settings->mediaplayer.builtin_enable)
if (settings->multimedia.builtin_mediaplayer_enable ||
settings->multimedia.builtin_imageviewer_enable)
{
switch (rarch_path_is_media_type(path))
{
case RARCH_CONTENT_MOVIE:
file_type = MENU_FILE_MOVIE;
#ifdef HAVE_FFMPEG
if (settings->multimedia.builtin_mediaplayer_enable)
file_type = MENU_FILE_MOVIE;
#endif
break;
case RARCH_CONTENT_MUSIC:
file_type = MENU_FILE_MUSIC;
#ifdef HAVE_FFMPEG
if (settings->multimedia.builtin_mediaplayer_enable)
file_type = MENU_FILE_MUSIC;
#endif
break;
case RARCH_CONTENT_IMAGE:
file_type = MENU_FILE_IMAGE;
if (settings->multimedia.builtin_imageviewer_enable)
file_type = MENU_FILE_IMAGEVIEWER;
default:
break;
}
}
#endif
menu_list_push(info->list, path, label,
file_type, 0, 0);

View File

@ -944,6 +944,9 @@ extern "C" {
#define MENU_LABEL_VALUE_INPUT_USER_BINDS 0x75fda711U
#define MENU_LABEL_USE_BUILTIN_IMAGE_VIEWER 0x5203b5bbU
#define MENU_LABEL_VALUE_USE_BUILTIN_IMAGE_VIEWER 0x1ab45d3eU
const char *menu_hash_to_str_de(uint32_t hash);
int menu_hash_get_help_de(uint32_t hash, char *s, size_t len);

View File

@ -4862,7 +4862,7 @@ static bool setting_append_list_multimedia_options(
#ifdef HAVE_FFMPEG
CONFIG_BOOL(
settings->mediaplayer.builtin_enable,
settings->multimedia.builtin_mediaplayer_enable,
menu_hash_to_str(MENU_LABEL_USE_BUILTIN_PLAYER),
menu_hash_to_str(MENU_LABEL_VALUE_USE_BUILTIN_PLAYER),
true,
@ -4875,6 +4875,19 @@ static bool setting_append_list_multimedia_options(
general_read_handler);
#endif
CONFIG_BOOL(
settings->multimedia.builtin_imageviewer_enable,
menu_hash_to_str(MENU_LABEL_USE_BUILTIN_IMAGE_VIEWER),
menu_hash_to_str(MENU_LABEL_VALUE_USE_BUILTIN_IMAGE_VIEWER),
true,
menu_hash_to_str(MENU_VALUE_OFF),
menu_hash_to_str(MENU_VALUE_ON),
group_info.name,
subgroup_info.name,
parent_group,
general_write_handler,
general_read_handler);
END_SUB_GROUP(list, list_info, parent_group);
END_GROUP(list, list_info, parent_group);

View File

@ -1204,29 +1204,36 @@ int rarch_main_init(int argc, char *argv[])
validate_cpu_features();
config_load();
#ifdef HAVE_FFMPEG
{
settings_t *settings = config_get_ptr();
if (settings && settings->mediaplayer.builtin_enable)
if (settings && (settings->multimedia.builtin_mediaplayer_enable ||
settings->multimedia.builtin_imageviewer_enable))
{
switch (rarch_path_is_media_type(global->fullpath))
{
case RARCH_CONTENT_MOVIE:
case RARCH_CONTENT_MUSIC:
global->has_set_libretro = false;
global->core_type = CORE_TYPE_FFMPEG;
if (settings->multimedia.builtin_mediaplayer_enable)
{
#ifdef HAVE_FFMPEG
global->has_set_libretro = false;
global->core_type = CORE_TYPE_FFMPEG;
#endif
}
break;
case RARCH_CONTENT_IMAGE:
global->has_set_libretro = false;
global->core_type = CORE_TYPE_IMAGEVIEWER;
if (settings->multimedia.builtin_imageviewer_enable)
{
global->has_set_libretro = false;
global->core_type = CORE_TYPE_IMAGEVIEWER;
}
break;
default:
break;
}
}
}
#endif
init_libretro_sym(global->core_type);
rarch_system_info_init();
@ -1397,6 +1404,15 @@ void rarch_main_set_state(unsigned cmd)
driver->frontend_ctx->content_loaded();
break;
#endif
case RARCH_ACTION_STATE_LOAD_CONTENT_IMAGEVIEWER:
#ifdef HAVE_MENU
/* If content loading fails, we go back to menu. */
if (!menu_load_content(CORE_TYPE_IMAGEVIEWER))
rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING);
#endif
if (driver->frontend_ctx && driver->frontend_ctx->content_loaded)
driver->frontend_ctx->content_loaded();
break;
case RARCH_ACTION_STATE_MENU_RUNNING_FINISHED:
#ifdef HAVE_MENU
menu_setting_apply_deferred();

View File

@ -34,6 +34,7 @@ enum action_state
#ifdef HAVE_FFMPEG
RARCH_ACTION_STATE_LOAD_CONTENT_FFMPEG,
#endif
RARCH_ACTION_STATE_LOAD_CONTENT_IMAGEVIEWER,
RARCH_ACTION_STATE_MENU_RUNNING,
RARCH_ACTION_STATE_MENU_RUNNING_FINISHED,
RARCH_ACTION_STATE_QUIT,