restore missing code pieces of my last PR (#6261)

This commit is contained in:
Andrés 2018-02-08 22:24:18 -05:00 committed by bparker06
parent 09ad30f9de
commit 42e93f3197
11 changed files with 64 additions and 76 deletions

View File

@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2015-2017 - Andrés Suárez
* Copyright (C) 2015-2017 - Andrés Suárez
* Copyright (C) 2016-2017 - Brad Parker
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
@ -220,6 +220,7 @@ bool command_set_shader(const char *arg)
{
char msg[256];
enum rarch_shader_type type = RARCH_SHADER_NONE;
struct video_shader *shader = menu_shader_get();
switch (msg_hash_to_file_type(msg_hash_calculate(path_get_extension(arg))))
{
@ -245,7 +246,8 @@ bool command_set_shader(const char *arg)
msg_hash_to_str(MSG_APPLYING_SHADER),
arg);
return video_driver_set_shader(type, arg);
retroarch_set_shader_preset(arg);
return menu_shader_manager_set_preset(shader, type, arg);
}
#if defined(HAVE_COMMAND) && defined(HAVE_CHEEVOS)
@ -1295,31 +1297,13 @@ static void command_event_disable_overrides(void)
return;
/* reload the original config */
config_unload_override();
rarch_ctl(RARCH_CTL_UNSET_OVERRIDES_ACTIVE, NULL);
}
static void command_event_restore_default_shader_preset(void)
{
if (!path_is_empty(RARCH_PATH_DEFAULT_SHADER_PRESET))
{
/* auto shader preset: reload the original shader */
settings_t *settings = config_get_ptr();
const char *shader_preset = path_get(RARCH_PATH_DEFAULT_SHADER_PRESET);
if (!string_is_empty(shader_preset))
{
RARCH_LOG("%s %s\n",
msg_hash_to_str(MSG_RESTORING_DEFAULT_SHADER_PRESET_TO),
shader_preset);
strlcpy(settings->paths.path_shader,
shader_preset,
sizeof(settings->paths.path_shader));
}
}
path_clear(RARCH_PATH_DEFAULT_SHADER_PRESET);
retroarch_unset_shader_preset();
}
static void command_event_restore_remaps(void)
@ -1440,6 +1424,7 @@ static bool command_event_save_core_config(void)
{
runloop_msg_queue_push(msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET), 1, 180, true);
RARCH_ERR("[Config]: %s\n", msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET));
free (config_dir);
return false;
}

View File

@ -60,33 +60,25 @@ static int generic_shader_action_parameter_left(
return 0;
}
static int shader_action_parameter_left(unsigned type, const char *label,
bool wraparound)
static int shader_action_parameter_left(unsigned type, const char *label, bool wraparound)
{
video_shader_ctx_t shader_info;
struct video_shader_parameter *param = NULL;
video_shader_driver_get_current_shader(&shader_info);
param = &shader_info.data->parameters[type
- MENU_SETTINGS_SHADER_PARAMETER_0];
param = &shader_info.data->parameters[type - MENU_SETTINGS_SHADER_PARAMETER_0];
if (!param)
return 0;
return generic_shader_action_parameter_left(param,
type, label, wraparound);
return menu_cbs_exit();
generic_shader_action_parameter_left(param, type, label, wraparound);
param = menu_shader_manager_get_parameters(
type - MENU_SETTINGS_SHADER_PARAMETER_0);
if (!param)
return menu_cbs_exit();
return generic_shader_action_parameter_left(param, type, label, wraparound);
}
static int shader_action_parameter_preset_left(unsigned type,
const char *label,
bool wraparound)
{
struct video_shader_parameter *param = menu_shader_manager_get_parameters(
type - MENU_SETTINGS_SHADER_PRESET_PARAMETER_0);
if (!param)
return 0;
return generic_shader_action_parameter_left(param,
type, label, wraparound);
}
#endif
static int action_left_cheat(unsigned type, const char *label,
@ -617,7 +609,7 @@ static int menu_cbs_init_bind_left_compare_type(menu_file_list_cbs_t *cbs,
else if (type >= MENU_SETTINGS_SHADER_PRESET_PARAMETER_0
&& type <= MENU_SETTINGS_SHADER_PRESET_PARAMETER_LAST)
{
BIND_ACTION_LEFT(cbs, shader_action_parameter_preset_left);
BIND_ACTION_LEFT(cbs, shader_action_parameter_left);
}
#endif
else if (type >= MENU_SETTINGS_INPUT_DESC_BEGIN

View File

@ -1865,7 +1865,8 @@ default_action_dialog_start(action_ok_rename_entry,
enum
{
ACTION_OK_SHADER_PRESET_SAVE_CORE = 0,
ACTION_OK_SHADER_PRESET_SAVE_GAME
ACTION_OK_SHADER_PRESET_SAVE_GAME,
ACTION_OK_SHADER_PRESET_SAVE_PARENT
};
static int generic_action_ok_shader_preset_save(const char *path,
@ -1912,6 +1913,12 @@ static int generic_action_ok_shader_preset_save(const char *path,
fill_pathname_join(file, directory, game_name, sizeof(file));
}
break;
case ACTION_OK_SHADER_PRESET_SAVE_PARENT:
{
fill_pathname_parent_dir_name(tmp, path_get(RARCH_PATH_BASENAME), sizeof(tmp));
fill_pathname_join(file, directory, tmp, sizeof(file));
}
break;
}
if(menu_shader_manager_save_preset(file, false, true))
@ -1940,7 +1947,12 @@ static int action_ok_shader_preset_save_game(const char *path,
idx, entry_idx, ACTION_OK_SHADER_PRESET_SAVE_GAME);
}
static int action_ok_shader_preset_save_parent(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
return generic_action_ok_shader_preset_save(path, label, type,
idx, entry_idx, ACTION_OK_SHADER_PRESET_SAVE_PARENT);
}
static int generic_action_ok_remap_file_operation(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx,
@ -4047,6 +4059,9 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_CORE:
BIND_ACTION_OK(cbs, action_ok_shader_preset_save_core);
break;
case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_PARENT:
BIND_ACTION_OK(cbs, action_ok_shader_preset_save_parent);
break;
case MENU_ENUM_LABEL_CHEAT_FILE_SAVE_AS:
BIND_ACTION_OK(cbs, action_ok_cheat_file_save_as);
break;

View File

@ -71,16 +71,12 @@ int shader_action_parameter_right(unsigned type, const char *label, bool wraparo
video_shader_driver_get_current_shader(&shader_info);
param = &shader_info.data->parameters[type - MENU_SETTINGS_SHADER_PARAMETER_0];
if (!param)
return menu_cbs_exit();
return generic_shader_action_parameter_right(param, type, label, wraparound);
}
int shader_action_parameter_preset_right(unsigned type, const char *label,
bool wraparound)
{
struct video_shader_parameter *param = menu_shader_manager_get_parameters(
type - MENU_SETTINGS_SHADER_PRESET_PARAMETER_0);
generic_shader_action_parameter_right(param, type, label, wraparound);
param = menu_shader_manager_get_parameters(
type - MENU_SETTINGS_SHADER_PARAMETER_0);
if (!param)
return menu_cbs_exit();
return generic_shader_action_parameter_right(param, type, label, wraparound);
@ -481,7 +477,7 @@ static int menu_cbs_init_bind_right_compare_type(menu_file_list_cbs_t *cbs,
else if (type >= MENU_SETTINGS_SHADER_PRESET_PARAMETER_0
&& type <= MENU_SETTINGS_SHADER_PRESET_PARAMETER_LAST)
{
BIND_ACTION_RIGHT(cbs, shader_action_parameter_preset_right);
BIND_ACTION_RIGHT(cbs, shader_action_parameter_right);
}
#endif
else if (type >= MENU_SETTINGS_INPUT_DESC_BEGIN

View File

@ -132,7 +132,7 @@ static int shader_action_parameter_select(const char *path, const char *label, u
static int shader_action_parameter_preset_select(const char *path, const char *label, unsigned type,
size_t idx)
{
return shader_action_parameter_preset_right(type, label, true);
return shader_action_parameter_right(type, label, true);
}
#endif

View File

@ -16,6 +16,7 @@
#include <compat/strl.h>
#include <file/file_path.h>
#include <lists/string_list.h>
#include <string/stdstring.h>
#ifdef HAVE_CONFIG_H
#include "../../config.h"
@ -134,12 +135,7 @@ static int action_start_shader_action_parameter(unsigned type, const char *label
#endif
return 0;
}
static int action_start_shader_action_preset_parameter(unsigned type, const char *label)
{
unsigned parameter = type - MENU_SETTINGS_SHADER_PRESET_PARAMETER_0;
unsigned parameter = type - MENU_SETTINGS_SHADER_PARAMETER_0;
return menu_shader_manager_clear_parameter(parameter);
}
@ -329,7 +325,7 @@ static int menu_cbs_init_bind_start_compare_type(menu_file_list_cbs_t *cbs,
else if (type >= MENU_SETTINGS_SHADER_PRESET_PARAMETER_0
&& type <= MENU_SETTINGS_SHADER_PRESET_PARAMETER_LAST)
{
BIND_ACTION_START(cbs, action_start_shader_action_preset_parameter);
BIND_ACTION_START(cbs, action_start_shader_action_parameter);
}
else if (type >= MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN &&
type <= MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_END)

View File

@ -358,6 +358,7 @@ default_sublabel_macro(action_bind_sublabel_shader_num_passes,
default_sublabel_macro(action_bind_sublabel_shader_preset, MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET)
default_sublabel_macro(action_bind_sublabel_shader_preset_save_as, MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_AS)
default_sublabel_macro(action_bind_sublabel_shader_preset_save_core, MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_CORE)
default_sublabel_macro(action_bind_sublabel_shader_preset_save_parent, MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_PARENT)
default_sublabel_macro(action_bind_sublabel_shader_preset_save_game, MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_GAME)
default_sublabel_macro(action_bind_sublabel_shader_parameters, MENU_ENUM_SUBLABEL_VIDEO_SHADER_PARAMETERS)
default_sublabel_macro(action_bind_sublabel_shader_preset_parameters, MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_PARAMETERS)
@ -505,6 +506,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_CORE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_shader_preset_save_core);
break;
case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_PARENT:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_shader_preset_save_parent);
break;
case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_GAME:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_shader_preset_save_game);
break;

View File

@ -141,9 +141,6 @@ int action_refresh_default(file_list_t *list, file_list_t *menu_list);
int shader_action_parameter_right(unsigned type, const char *label, bool wraparound);
int shader_action_parameter_preset_right(unsigned type, const char *label,
bool wraparound);
int generic_action_ok_displaylist_push(const char *path, const char *new_path,
const char *label, unsigned type, size_t idx, size_t entry_idx,
unsigned action_type);

View File

@ -1390,12 +1390,17 @@ static int menu_displaylist_parse_shader_options(menu_displaylist_info_t *info)
MENU_SETTING_ACTION, 0, 0);
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_CORE),
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_AS),
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_CORE),
MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_CORE,
MENU_SETTING_ACTION, 0, 0);
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_PARENT),
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_PARENT),
MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_PARENT,
MENU_SETTING_ACTION, 0, 0);
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_GAME),
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_AS),
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_GAME),
MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_GAME,
MENU_SETTING_ACTION, 0, 0);
menu_entries_append_enum(info->list,
@ -1403,11 +1408,6 @@ static int menu_displaylist_parse_shader_options(menu_displaylist_info_t *info)
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PARAMETERS),
MENU_ENUM_LABEL_VIDEO_SHADER_PARAMETERS,
MENU_SETTING_ACTION, 0, 0);
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_PARAMETERS),
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_PARAMETERS),
MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_PARAMETERS,
MENU_SETTING_ACTION, 0, 0);
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_NUM_PASSES),
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_NUM_PASSES),

View File

@ -30,6 +30,7 @@
#include "../file_path_special.h"
#include "../configuration.h"
#include "../paths.h"
#include "../retroarch.h"
#include "../verbosity.h"
#ifdef HAVE_SHADER_MANAGER
@ -130,14 +131,14 @@ bool menu_shader_manager_init(void)
#ifdef HAVE_SHADER_MANAGER
settings_t *settings = config_get_ptr();
const char *config_path = path_get(RARCH_PATH_CONFIG);
const char *path_shader = settings->paths.path_shader;
const char *path_shader = retroarch_get_shader_preset();
menu_shader_manager_free();
menu_driver_shader = (struct video_shader*)
calloc(1, sizeof(struct video_shader));
if (!menu_driver_shader)
if (!menu_driver_shader || !path_shader)
return false;
/* In a multi-config setting, we can't have
@ -248,7 +249,7 @@ bool menu_shader_manager_init(void)
*
* Sets shader preset.
**/
void menu_shader_manager_set_preset(void *data,
bool menu_shader_manager_set_preset(void *data,
unsigned type, const char *preset_path)
{
#ifdef HAVE_SHADER_MANAGER
@ -260,7 +261,7 @@ void menu_shader_manager_set_preset(void *data,
if (!video_driver_set_shader((enum rarch_shader_type)type, preset_path))
{
configuration_set_bool(settings, settings->bools.video_shader_enable, false);
return;
return false;
}
/* Makes sure that we use Menu Preset shader on driver reinit.
@ -271,7 +272,7 @@ void menu_shader_manager_set_preset(void *data,
configuration_set_bool(settings, settings->bools.video_shader_enable, true);
if (!preset_path || !shader)
return;
return false;
/* Load stored Preset into menu on success.
* Used when a preset is directly loaded.
@ -280,7 +281,7 @@ void menu_shader_manager_set_preset(void *data,
conf = config_file_new(preset_path);
if (!conf)
return;
return false;
RARCH_LOG("Setting Menu shader: %s.\n", preset_path);
@ -292,6 +293,8 @@ void menu_shader_manager_set_preset(void *data,
config_file_free(conf);
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
return true;
#endif
}

View File

@ -48,7 +48,7 @@ bool menu_shader_manager_init(void);
*
* Sets shader preset.
**/
void menu_shader_manager_set_preset(
bool menu_shader_manager_set_preset(
void *data, unsigned type, const char *preset_path);
/**