mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
* Move more code to command.c
* Buildfix for CTR/3DS
This commit is contained in:
parent
69e8416e45
commit
f59b420fde
290
command.c
290
command.c
@ -48,6 +48,7 @@
|
||||
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
|
||||
#include "gfx/video_shader_parse.h"
|
||||
#endif
|
||||
#include "autosave.h"
|
||||
#include "command.h"
|
||||
#include "core_info.h"
|
||||
#include "cheat_manager.h"
|
||||
@ -1305,3 +1306,292 @@ bool command_set_shader(command_t *cmd, const char *arg)
|
||||
return apply_shader(settings, type, arg, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIGFILE
|
||||
bool command_event_save_core_config(
|
||||
const char *dir_menu_config,
|
||||
const char *rarch_path_config)
|
||||
{
|
||||
char msg[128];
|
||||
char config_name[PATH_MAX_LENGTH];
|
||||
char config_path[PATH_MAX_LENGTH];
|
||||
char config_dir[PATH_MAX_LENGTH];
|
||||
bool found_path = false;
|
||||
bool overrides_active = false;
|
||||
const char *core_path = NULL;
|
||||
runloop_state_t *runloop_st = runloop_state_get_ptr();
|
||||
|
||||
msg[0] = '\0';
|
||||
config_dir[0] = '\0';
|
||||
|
||||
if (!string_is_empty(dir_menu_config))
|
||||
strlcpy(config_dir, dir_menu_config, sizeof(config_dir));
|
||||
else if (!string_is_empty(rarch_path_config)) /* Fallback */
|
||||
fill_pathname_basedir(config_dir, rarch_path_config,
|
||||
sizeof(config_dir));
|
||||
|
||||
if (string_is_empty(config_dir))
|
||||
{
|
||||
runloop_msg_queue_push(msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
RARCH_ERR("[Config]: %s\n", msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET));
|
||||
return false;
|
||||
}
|
||||
|
||||
core_path = path_get(RARCH_PATH_CORE);
|
||||
config_name[0] = '\0';
|
||||
config_path[0] = '\0';
|
||||
|
||||
/* Infer file name based on libretro core. */
|
||||
if (path_is_valid(core_path))
|
||||
{
|
||||
unsigned i;
|
||||
RARCH_LOG("%s\n", msg_hash_to_str(MSG_USING_CORE_NAME_FOR_NEW_CONFIG));
|
||||
|
||||
/* In case of collision, find an alternative name. */
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
char tmp[64];
|
||||
|
||||
fill_pathname_base_noext(
|
||||
config_name,
|
||||
core_path,
|
||||
sizeof(config_name));
|
||||
|
||||
fill_pathname_join(config_path, config_dir, config_name,
|
||||
sizeof(config_path));
|
||||
|
||||
if (i)
|
||||
snprintf(tmp, sizeof(tmp), "-%u.cfg", i);
|
||||
else
|
||||
{
|
||||
tmp[0] = '\0';
|
||||
strlcpy(tmp, ".cfg", sizeof(tmp));
|
||||
}
|
||||
|
||||
strlcat(config_path, tmp, sizeof(config_path));
|
||||
|
||||
if (!path_is_valid(config_path))
|
||||
{
|
||||
found_path = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found_path)
|
||||
{
|
||||
/* Fallback to system time... */
|
||||
RARCH_WARN("[Config]: %s\n",
|
||||
msg_hash_to_str(MSG_CANNOT_INFER_NEW_CONFIG_PATH));
|
||||
fill_dated_filename(config_name, ".cfg", sizeof(config_name));
|
||||
fill_pathname_join(config_path, config_dir, config_name,
|
||||
sizeof(config_path));
|
||||
}
|
||||
|
||||
if (runloop_st->overrides_active)
|
||||
{
|
||||
/* Overrides block config file saving,
|
||||
* make it appear as overrides weren't enabled
|
||||
* for a manual save. */
|
||||
runloop_st->overrides_active = false;
|
||||
overrides_active = true;
|
||||
}
|
||||
|
||||
#ifdef HAVE_CONFIGFILE
|
||||
command_event_save_config(config_path, msg, sizeof(msg));
|
||||
#endif
|
||||
|
||||
if (!string_is_empty(msg))
|
||||
runloop_msg_queue_push(msg, 1, 180, true, NULL,
|
||||
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
|
||||
runloop_st->overrides_active = overrides_active;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void command_event_save_current_config(enum override_type type)
|
||||
{
|
||||
runloop_state_t *runloop_st = runloop_state_get_ptr();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case OVERRIDE_NONE:
|
||||
{
|
||||
if (path_is_empty(RARCH_PATH_CONFIG))
|
||||
{
|
||||
char msg[128];
|
||||
msg[0] = '\0';
|
||||
strcpy_literal(msg, "[Config]: Config directory not set, cannot save configuration.");
|
||||
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
}
|
||||
else
|
||||
{
|
||||
char msg[256];
|
||||
msg[0] = '\0';
|
||||
command_event_save_config(path_get(RARCH_PATH_CONFIG), msg, sizeof(msg));
|
||||
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OVERRIDE_GAME:
|
||||
case OVERRIDE_CORE:
|
||||
case OVERRIDE_CONTENT_DIR:
|
||||
{
|
||||
char msg[128];
|
||||
msg[0] = '\0';
|
||||
if (config_save_overrides(type, &runloop_st->system))
|
||||
{
|
||||
strlcpy(msg, msg_hash_to_str(MSG_OVERRIDES_SAVED_SUCCESSFULLY), sizeof(msg));
|
||||
/* set overrides to active so the original config can be
|
||||
restored after closing content */
|
||||
runloop_st->overrides_active = true;
|
||||
}
|
||||
else
|
||||
strlcpy(msg, msg_hash_to_str(MSG_OVERRIDES_ERROR_SAVING), sizeof(msg));
|
||||
RARCH_LOG("[Config - Overrides]: %s\n", msg);
|
||||
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool command_event_main_state(unsigned cmd)
|
||||
{
|
||||
retro_ctx_size_info_t info;
|
||||
char msg[128];
|
||||
char state_path[16384];
|
||||
const global_t *global = global_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
bool ret = false;
|
||||
bool push_msg = true;
|
||||
|
||||
state_path[0] = msg[0] = '\0';
|
||||
|
||||
retroarch_get_current_savestate_path(state_path, sizeof(state_path));
|
||||
|
||||
core_serialize_size(&info);
|
||||
|
||||
if (info.size)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case CMD_EVENT_SAVE_STATE:
|
||||
case CMD_EVENT_SAVE_STATE_TO_RAM:
|
||||
{
|
||||
video_driver_state_t *video_st =
|
||||
video_state_get_ptr();
|
||||
bool savestate_auto_index =
|
||||
settings->bools.savestate_auto_index;
|
||||
unsigned savestate_max_keep =
|
||||
settings->uints.savestate_max_keep;
|
||||
bool frame_time_counter_reset_after_save_state =
|
||||
settings->bools.frame_time_counter_reset_after_save_state;
|
||||
|
||||
if (cmd == CMD_EVENT_SAVE_STATE)
|
||||
content_save_state(state_path, true, false);
|
||||
else
|
||||
content_save_state_to_ram();
|
||||
|
||||
/* Clean up excess savestates if necessary */
|
||||
if (savestate_auto_index && (savestate_max_keep > 0))
|
||||
command_event_set_savestate_garbage_collect(global,
|
||||
settings->uints.savestate_max_keep,
|
||||
settings->bools.show_hidden_files
|
||||
);
|
||||
|
||||
if (frame_time_counter_reset_after_save_state)
|
||||
video_st->frame_time_count = 0;
|
||||
|
||||
ret = true;
|
||||
push_msg = false;
|
||||
}
|
||||
break;
|
||||
case CMD_EVENT_LOAD_STATE:
|
||||
case CMD_EVENT_LOAD_STATE_FROM_RAM:
|
||||
{
|
||||
bool res = false;
|
||||
if (cmd == CMD_EVENT_LOAD_STATE)
|
||||
res = content_load_state(state_path, false, false);
|
||||
else
|
||||
res = content_load_state_from_ram();
|
||||
|
||||
if (res)
|
||||
{
|
||||
#ifdef HAVE_CHEEVOS
|
||||
if (rcheevos_hardcore_active())
|
||||
{
|
||||
rcheevos_pause_hardcore();
|
||||
runloop_msg_queue_push(msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_DISABLED), 0, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
}
|
||||
#endif
|
||||
ret = true;
|
||||
#ifdef HAVE_NETWORKING
|
||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_LOAD_SAVESTATE, NULL);
|
||||
#endif
|
||||
{
|
||||
video_driver_state_t *video_st =
|
||||
video_state_get_ptr();
|
||||
bool frame_time_counter_reset_after_load_state =
|
||||
settings->bools.frame_time_counter_reset_after_load_state;
|
||||
if (frame_time_counter_reset_after_load_state)
|
||||
video_st->frame_time_count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
push_msg = false;
|
||||
break;
|
||||
case CMD_EVENT_UNDO_LOAD_STATE:
|
||||
command_event_undo_load_state(msg, sizeof(msg));
|
||||
ret = true;
|
||||
break;
|
||||
case CMD_EVENT_UNDO_SAVE_STATE:
|
||||
command_event_undo_save_state(msg, sizeof(msg));
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
strlcpy(msg, msg_hash_to_str(
|
||||
MSG_CORE_DOES_NOT_SUPPORT_SAVESTATES), sizeof(msg));
|
||||
|
||||
if (push_msg)
|
||||
runloop_msg_queue_push(msg, 2, 180, true, NULL,
|
||||
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
|
||||
if (!string_is_empty(msg))
|
||||
RARCH_LOG("%s\n", msg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool command_event_disk_control_append_image(
|
||||
const char *path)
|
||||
{
|
||||
runloop_state_t *runloop_st = runloop_state_get_ptr();
|
||||
rarch_system_info_t *sys_info = runloop_st ? (rarch_system_info_t*)&runloop_st->system : NULL;
|
||||
if ( !sys_info ||
|
||||
!disk_control_append_image(&sys_info->disk_control, path))
|
||||
return false;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
if (runloop_st->use_sram)
|
||||
autosave_deinit();
|
||||
#endif
|
||||
|
||||
/* TODO/FIXME: Need to figure out what to do with subsystems case. */
|
||||
if (path_is_empty(RARCH_PATH_SUBSYSTEM))
|
||||
{
|
||||
/* Update paths for our new image.
|
||||
* If we actually use append_image, we assume that we
|
||||
* started out in a single disk case, and that this way
|
||||
* of doing it makes the most sense. */
|
||||
path_set(RARCH_PATH_NAMES, path);
|
||||
runloop_path_fill_names();
|
||||
}
|
||||
|
||||
command_event(CMD_EVENT_AUTOSAVE_INIT, NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
31
command.h
31
command.h
@ -482,6 +482,37 @@ static const struct cmd_map map[] = {
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIGFILE
|
||||
/**
|
||||
* command_event_save_core_config:
|
||||
*
|
||||
* Saves a new (core) configuration to a file. Filename is based
|
||||
* on heuristics to avoid typing.
|
||||
*
|
||||
* Returns: true (1) on success, otherwise false (0).
|
||||
**/
|
||||
bool command_event_save_core_config(
|
||||
const char *dir_menu_config,
|
||||
const char *rarch_path_config);
|
||||
|
||||
/**
|
||||
* command_event_save_current_config:
|
||||
*
|
||||
* Saves current configuration file to disk, and (optionally)
|
||||
* autosave state.
|
||||
**/
|
||||
void command_event_save_current_config(enum override_type type);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* command_event_disk_control_append_image:
|
||||
* @path : Path to disk image.
|
||||
*
|
||||
* Appends disk image to disk image list.
|
||||
**/
|
||||
bool command_event_disk_control_append_image(const char *path);
|
||||
|
||||
bool command_event_main_state(unsigned cmd);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
|
@ -302,7 +302,6 @@ static bool ctr_update_state_date_from_file(void *data)
|
||||
#ifdef USE_CTRULIB_2
|
||||
time_t mtime;
|
||||
struct tm *t = NULL;
|
||||
bool file_exists = false;
|
||||
#else
|
||||
time_t ft;
|
||||
u64 mtime;
|
||||
@ -315,18 +314,13 @@ static bool ctr_update_state_date_from_file(void *data)
|
||||
return false;
|
||||
|
||||
#ifdef USE_CTRULIB_2
|
||||
file_exists = archive_getmtime(state_path + 5, &mtime) == 0;
|
||||
if (archive_getmtime(state_path + 5, &mtime) != 0)
|
||||
goto error;
|
||||
#else
|
||||
file_exists = sdmc_getmtime(state_path + 5, &mtime) == 0;
|
||||
if (sdmc_getmtime( state_path + 5, &mtime) != 0)
|
||||
goto error;
|
||||
#endif
|
||||
|
||||
if (!file_exists)
|
||||
{
|
||||
ctr->state_data_exist = false;
|
||||
snprintf(ctr->state_date, sizeof(ctr->state_date), "00/00/0000");
|
||||
return false;
|
||||
}
|
||||
|
||||
ctr->state_data_exist = true;
|
||||
|
||||
#ifdef USE_CTRULIB_2
|
||||
@ -339,6 +333,11 @@ static bool ctr_update_state_date_from_file(void *data)
|
||||
t->tm_mon + 1, t->tm_mday, t->tm_year + 1900);
|
||||
|
||||
return true;
|
||||
|
||||
error:
|
||||
ctr->state_data_exist = false;
|
||||
snprintf(ctr->state_date, sizeof(ctr->state_date), "00/00/0000");
|
||||
return false;
|
||||
}
|
||||
|
||||
static void ctr_state_thumbnail_geom(void *data)
|
||||
|
345
retroarch.c
345
retroarch.c
@ -3294,10 +3294,11 @@ static void path_init_savefile_internal(global_t *global)
|
||||
path_init_savefile_rtc(global->name.savefile);
|
||||
}
|
||||
|
||||
static void runloop_path_fill_names(runloop_state_t *runloop_st,
|
||||
input_driver_state_t *input_st)
|
||||
void runloop_path_fill_names(void)
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
runloop_state_t *runloop_st = runloop_state_get_ptr();
|
||||
input_driver_state_t *input_st = input_state_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
path_init_savefile_internal(global);
|
||||
|
||||
@ -5245,43 +5246,6 @@ static bool is_narrator_running(struct rarch_state *p_rarch,
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* command_event_disk_control_append_image:
|
||||
* @path : Path to disk image.
|
||||
*
|
||||
* Appends disk image to disk image list.
|
||||
**/
|
||||
static bool command_event_disk_control_append_image(
|
||||
runloop_state_t *runloop_st,
|
||||
rarch_system_info_t *sys_info,
|
||||
const char *path)
|
||||
{
|
||||
input_driver_state_t *input_st = input_state_get_ptr();
|
||||
if ( !sys_info ||
|
||||
!disk_control_append_image(&sys_info->disk_control, path))
|
||||
return false;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
if (runloop_st->use_sram)
|
||||
autosave_deinit();
|
||||
#endif
|
||||
|
||||
/* TODO/FIXME: Need to figure out what to do with subsystems case. */
|
||||
if (path_is_empty(RARCH_PATH_SUBSYSTEM))
|
||||
{
|
||||
/* Update paths for our new image.
|
||||
* If we actually use append_image, we assume that we
|
||||
* started out in a single disk case, and that this way
|
||||
* of doing it makes the most sense. */
|
||||
path_set(RARCH_PATH_NAMES, path);
|
||||
runloop_path_fill_names(runloop_st, input_st);
|
||||
}
|
||||
|
||||
command_event(CMD_EVENT_AUTOSAVE_INIT, NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void command_event_deinit_core(
|
||||
struct rarch_state *p_rarch,
|
||||
bool reinit)
|
||||
@ -5384,7 +5348,7 @@ static bool event_init_content(
|
||||
if (contentless)
|
||||
path_init_savefile_internal(global);
|
||||
else
|
||||
runloop_path_fill_names(runloop_st, input_st);
|
||||
runloop_path_fill_names();
|
||||
|
||||
if (!content_init())
|
||||
return false;
|
||||
@ -5453,8 +5417,7 @@ static void runloop_update_runtime_log(
|
||||
free(runtime_log);
|
||||
}
|
||||
|
||||
|
||||
static void command_event_runtime_log_deinit(
|
||||
static void runloop_runtime_log_deinit(
|
||||
runloop_state_t *runloop_st,
|
||||
bool content_runtime_log,
|
||||
bool content_runtime_log_aggregate,
|
||||
@ -5505,7 +5468,7 @@ static void command_event_runtime_log_deinit(
|
||||
sizeof(runloop_st->runtime_core_path));
|
||||
}
|
||||
|
||||
static void command_event_runtime_log_init(runloop_state_t *runloop_st)
|
||||
static void runloop_runtime_log_init(runloop_state_t *runloop_st)
|
||||
{
|
||||
const char *content_path = path_get(RARCH_PATH_CONTENT);
|
||||
const char *core_path = path_get(RARCH_PATH_CORE);
|
||||
@ -5688,291 +5651,15 @@ static bool command_event_init_core(
|
||||
fastforward_ratio);
|
||||
runloop_st->frame_limit_last_time = cpu_features_get_time_usec();
|
||||
|
||||
command_event_runtime_log_init(runloop_st);
|
||||
runloop_runtime_log_init(runloop_st);
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef HAVE_CONFIGFILE
|
||||
/**
|
||||
* command_event_save_core_config:
|
||||
*
|
||||
* Saves a new (core) configuration to a file. Filename is based
|
||||
* on heuristics to avoid typing.
|
||||
*
|
||||
* Returns: true (1) on success, otherwise false (0).
|
||||
**/
|
||||
static bool command_event_save_core_config(
|
||||
const char *dir_menu_config,
|
||||
const char *rarch_path_config)
|
||||
{
|
||||
char msg[128];
|
||||
char config_name[PATH_MAX_LENGTH];
|
||||
char config_path[PATH_MAX_LENGTH];
|
||||
char config_dir[PATH_MAX_LENGTH];
|
||||
bool found_path = false;
|
||||
bool overrides_active = false;
|
||||
const char *core_path = NULL;
|
||||
runloop_state_t *runloop_st = &runloop_state;
|
||||
|
||||
msg[0] = '\0';
|
||||
config_dir[0] = '\0';
|
||||
|
||||
if (!string_is_empty(dir_menu_config))
|
||||
strlcpy(config_dir, dir_menu_config, sizeof(config_dir));
|
||||
else if (!string_is_empty(rarch_path_config)) /* Fallback */
|
||||
fill_pathname_basedir(config_dir, rarch_path_config,
|
||||
sizeof(config_dir));
|
||||
|
||||
if (string_is_empty(config_dir))
|
||||
{
|
||||
runloop_msg_queue_push(msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
RARCH_ERR("[Config]: %s\n", msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET));
|
||||
return false;
|
||||
}
|
||||
|
||||
core_path = path_get(RARCH_PATH_CORE);
|
||||
config_name[0] = '\0';
|
||||
config_path[0] = '\0';
|
||||
|
||||
/* Infer file name based on libretro core. */
|
||||
if (path_is_valid(core_path))
|
||||
{
|
||||
unsigned i;
|
||||
RARCH_LOG("%s\n", msg_hash_to_str(MSG_USING_CORE_NAME_FOR_NEW_CONFIG));
|
||||
|
||||
/* In case of collision, find an alternative name. */
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
char tmp[64];
|
||||
|
||||
fill_pathname_base_noext(
|
||||
config_name,
|
||||
core_path,
|
||||
sizeof(config_name));
|
||||
|
||||
fill_pathname_join(config_path, config_dir, config_name,
|
||||
sizeof(config_path));
|
||||
|
||||
if (i)
|
||||
snprintf(tmp, sizeof(tmp), "-%u.cfg", i);
|
||||
else
|
||||
{
|
||||
tmp[0] = '\0';
|
||||
strlcpy(tmp, ".cfg", sizeof(tmp));
|
||||
}
|
||||
|
||||
strlcat(config_path, tmp, sizeof(config_path));
|
||||
|
||||
if (!path_is_valid(config_path))
|
||||
{
|
||||
found_path = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found_path)
|
||||
{
|
||||
/* Fallback to system time... */
|
||||
RARCH_WARN("[Config]: %s\n",
|
||||
msg_hash_to_str(MSG_CANNOT_INFER_NEW_CONFIG_PATH));
|
||||
fill_dated_filename(config_name, ".cfg", sizeof(config_name));
|
||||
fill_pathname_join(config_path, config_dir, config_name,
|
||||
sizeof(config_path));
|
||||
}
|
||||
|
||||
if (runloop_st->overrides_active)
|
||||
{
|
||||
/* Overrides block config file saving,
|
||||
* make it appear as overrides weren't enabled
|
||||
* for a manual save. */
|
||||
runloop_st->overrides_active = false;
|
||||
overrides_active = true;
|
||||
}
|
||||
|
||||
#ifdef HAVE_CONFIGFILE
|
||||
command_event_save_config(config_path, msg, sizeof(msg));
|
||||
#endif
|
||||
|
||||
if (!string_is_empty(msg))
|
||||
runloop_msg_queue_push(msg, 1, 180, true, NULL,
|
||||
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
|
||||
runloop_st->overrides_active = overrides_active;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* event_save_current_config:
|
||||
*
|
||||
* Saves current configuration file to disk, and (optionally)
|
||||
* autosave state.
|
||||
**/
|
||||
static void command_event_save_current_config(
|
||||
enum override_type type)
|
||||
{
|
||||
runloop_state_t *runloop_st = &runloop_state;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case OVERRIDE_NONE:
|
||||
{
|
||||
if (path_is_empty(RARCH_PATH_CONFIG))
|
||||
{
|
||||
char msg[128];
|
||||
msg[0] = '\0';
|
||||
strcpy_literal(msg, "[Config]: Config directory not set, cannot save configuration.");
|
||||
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
}
|
||||
else
|
||||
{
|
||||
char msg[256];
|
||||
msg[0] = '\0';
|
||||
command_event_save_config(path_get(RARCH_PATH_CONFIG), msg, sizeof(msg));
|
||||
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OVERRIDE_GAME:
|
||||
case OVERRIDE_CORE:
|
||||
case OVERRIDE_CONTENT_DIR:
|
||||
{
|
||||
char msg[128];
|
||||
msg[0] = '\0';
|
||||
if (config_save_overrides(type, &runloop_st->system))
|
||||
{
|
||||
strlcpy(msg, msg_hash_to_str(MSG_OVERRIDES_SAVED_SUCCESSFULLY), sizeof(msg));
|
||||
/* set overrides to active so the original config can be
|
||||
restored after closing content */
|
||||
runloop_st->overrides_active = true;
|
||||
}
|
||||
else
|
||||
strlcpy(msg, msg_hash_to_str(MSG_OVERRIDES_ERROR_SAVING), sizeof(msg));
|
||||
RARCH_LOG("[Config - Overrides]: %s\n", msg);
|
||||
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool command_event_main_state(unsigned cmd)
|
||||
{
|
||||
retro_ctx_size_info_t info;
|
||||
char msg[128];
|
||||
char state_path[16384];
|
||||
const global_t *global = global_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
bool ret = false;
|
||||
bool push_msg = true;
|
||||
|
||||
state_path[0] = msg[0] = '\0';
|
||||
|
||||
retroarch_get_current_savestate_path(state_path, sizeof(state_path));
|
||||
|
||||
core_serialize_size(&info);
|
||||
|
||||
if (info.size)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case CMD_EVENT_SAVE_STATE:
|
||||
case CMD_EVENT_SAVE_STATE_TO_RAM:
|
||||
{
|
||||
video_driver_state_t *video_st =
|
||||
video_state_get_ptr();
|
||||
bool savestate_auto_index =
|
||||
settings->bools.savestate_auto_index;
|
||||
unsigned savestate_max_keep =
|
||||
settings->uints.savestate_max_keep;
|
||||
bool frame_time_counter_reset_after_save_state =
|
||||
settings->bools.frame_time_counter_reset_after_save_state;
|
||||
|
||||
if (cmd == CMD_EVENT_SAVE_STATE)
|
||||
content_save_state(state_path, true, false);
|
||||
else
|
||||
content_save_state_to_ram();
|
||||
|
||||
/* Clean up excess savestates if necessary */
|
||||
if (savestate_auto_index && (savestate_max_keep > 0))
|
||||
command_event_set_savestate_garbage_collect(global,
|
||||
settings->uints.savestate_max_keep,
|
||||
settings->bools.show_hidden_files
|
||||
);
|
||||
|
||||
if (frame_time_counter_reset_after_save_state)
|
||||
video_st->frame_time_count = 0;
|
||||
|
||||
ret = true;
|
||||
push_msg = false;
|
||||
}
|
||||
break;
|
||||
case CMD_EVENT_LOAD_STATE:
|
||||
case CMD_EVENT_LOAD_STATE_FROM_RAM:
|
||||
{
|
||||
bool res = false;
|
||||
if (cmd == CMD_EVENT_LOAD_STATE)
|
||||
res = content_load_state(state_path, false, false);
|
||||
else
|
||||
res = content_load_state_from_ram();
|
||||
|
||||
if (res)
|
||||
{
|
||||
#ifdef HAVE_CHEEVOS
|
||||
if (rcheevos_hardcore_active())
|
||||
{
|
||||
rcheevos_pause_hardcore();
|
||||
runloop_msg_queue_push(msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_DISABLED), 0, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
}
|
||||
#endif
|
||||
ret = true;
|
||||
#ifdef HAVE_NETWORKING
|
||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_LOAD_SAVESTATE, NULL);
|
||||
#endif
|
||||
{
|
||||
video_driver_state_t *video_st =
|
||||
video_state_get_ptr();
|
||||
bool frame_time_counter_reset_after_load_state =
|
||||
settings->bools.frame_time_counter_reset_after_load_state;
|
||||
if (frame_time_counter_reset_after_load_state)
|
||||
video_st->frame_time_count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
push_msg = false;
|
||||
break;
|
||||
case CMD_EVENT_UNDO_LOAD_STATE:
|
||||
command_event_undo_load_state(msg, sizeof(msg));
|
||||
ret = true;
|
||||
break;
|
||||
case CMD_EVENT_UNDO_SAVE_STATE:
|
||||
command_event_undo_save_state(msg, sizeof(msg));
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
strlcpy(msg, msg_hash_to_str(
|
||||
MSG_CORE_DOES_NOT_SUPPORT_SAVESTATES), sizeof(msg));
|
||||
|
||||
if (push_msg)
|
||||
runloop_msg_queue_push(msg, 2, 180, true, NULL,
|
||||
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
|
||||
if (!string_is_empty(msg))
|
||||
RARCH_LOG("%s\n", msg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void command_event_reinit(const int flags)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
input_driver_state_t *input_st = input_state_get_ptr();
|
||||
video_driver_state_t *video_st =
|
||||
video_state_get_ptr();
|
||||
video_driver_state_t *video_st = video_state_get_ptr();
|
||||
#ifdef HAVE_MENU
|
||||
bool video_fullscreen = settings->bools.video_fullscreen;
|
||||
bool adaptive_vsync = settings->bools.video_adaptive_vsync;
|
||||
@ -6589,7 +6276,7 @@ bool command_event(enum event_command cmd, void *data)
|
||||
if (sys_info)
|
||||
disk_control_save_image_index(&sys_info->disk_control);
|
||||
|
||||
command_event_runtime_log_deinit(runloop_st,
|
||||
runloop_runtime_log_deinit(runloop_st,
|
||||
settings->bools.content_runtime_log,
|
||||
settings->bools.content_runtime_log_aggregate,
|
||||
settings->paths.directory_runtime_log,
|
||||
@ -7028,7 +6715,7 @@ bool command_event(enum event_command cmd, void *data)
|
||||
if (sys_info)
|
||||
disk_control_save_image_index(&sys_info->disk_control);
|
||||
|
||||
command_event_runtime_log_deinit(runloop_st,
|
||||
runloop_runtime_log_deinit(runloop_st,
|
||||
settings->bools.content_runtime_log,
|
||||
settings->bools.content_runtime_log_aggregate,
|
||||
settings->paths.directory_runtime_log,
|
||||
@ -7620,18 +7307,16 @@ bool command_event(enum event_command cmd, void *data)
|
||||
/* Get initial disk eject state */
|
||||
bool initial_disk_ejected = disk_control_get_eject_state(&sys_info->disk_control);
|
||||
#endif
|
||||
rarch_system_info_t *
|
||||
sys_info = &runloop_st->system;
|
||||
/* Append disk image */
|
||||
bool success =
|
||||
command_event_disk_control_append_image(&runloop_state,
|
||||
sys_info, path);
|
||||
command_event_disk_control_append_image(path);
|
||||
|
||||
#if defined(HAVE_MENU)
|
||||
/* Appending a disk image may or may not affect
|
||||
* the disk tray eject status. If status has changed,
|
||||
* must refresh the disk options menu */
|
||||
if (initial_disk_ejected != disk_control_get_eject_state(&sys_info->disk_control))
|
||||
if (initial_disk_ejected != disk_control_get_eject_state(
|
||||
&sys_info->disk_control))
|
||||
{
|
||||
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
|
||||
menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL);
|
||||
@ -9939,7 +9624,7 @@ static bool retroarch_environment_cb(unsigned cmd, void *data)
|
||||
* since normal command.c CMD_EVENT_CORE_DEINIT event
|
||||
* will not occur until after the current content has
|
||||
* been cleared (causing log to be skipped) */
|
||||
command_event_runtime_log_deinit(runloop_st,
|
||||
runloop_runtime_log_deinit(runloop_st,
|
||||
settings->bools.content_runtime_log,
|
||||
settings->bools.content_runtime_log_aggregate,
|
||||
settings->paths.directory_runtime_log,
|
||||
|
Loading…
x
Reference in New Issue
Block a user