State slot hotkey adjustments (#14881)

This commit is contained in:
sonninnos 2023-01-21 14:47:55 +02:00 committed by GitHub
parent 70c4fbeb93
commit 3b129e6098
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 17 deletions

View File

@ -13536,7 +13536,7 @@ MSG_HASH(
) )
MSG_HASH( MSG_HASH(
MSG_LOADED_STATE_FROM_SLOT_AUTO, MSG_LOADED_STATE_FROM_SLOT_AUTO,
"Loaded state from slot #-1 (auto)." "Loaded state from slot #-1 (Auto)."
) )
MSG_HASH( MSG_HASH(
MSG_LOADING, MSG_LOADING,
@ -13720,7 +13720,7 @@ MSG_HASH(
) )
MSG_HASH( MSG_HASH(
MSG_SAVED_STATE_TO_SLOT_AUTO, MSG_SAVED_STATE_TO_SLOT_AUTO,
"Saved state to slot #-1 (auto)." "Saved state to slot #-1 (Auto)."
) )
MSG_HASH( MSG_HASH(
MSG_SAVED_SUCCESSFULLY_TO, MSG_SAVED_SUCCESSFULLY_TO,

View File

@ -6276,25 +6276,47 @@ static enum runloop_state_enum runloop_check_state(
if (!check2) if (!check2)
{ {
check2 = should_slot_decrease && !old_should_slot_decrease; check2 = should_slot_decrease && !old_should_slot_decrease;
check1 = state_slot > 0; check1 = state_slot > -1;
addition = -1; addition = -1;
/* Wrap-around to 999 */
if (check2 && !check1 && state_slot + addition < -1)
{
state_slot = 1000;
check1 = true;
}
} }
/* Wrap-around to -1 (Auto) */
else if (state_slot + addition > 999)
state_slot = -2;
if (check2) if (check2)
{ {
size_t _len; size_t _len;
char msg[128]; char msg[128];
int cur_state_slot = state_slot; int cur_state_slot = state_slot + addition;
if (check1) if (check1)
configuration_set_int(settings, settings->ints.state_slot, configuration_set_int(settings, settings->ints.state_slot,
cur_state_slot + addition); cur_state_slot);
_len = strlcpy(msg, msg_hash_to_str(MSG_STATE_SLOT), sizeof(msg)); _len = strlcpy(msg, msg_hash_to_str(MSG_STATE_SLOT), sizeof(msg));
snprintf(msg + _len, snprintf(msg + _len,
sizeof(msg) - _len, sizeof(msg) - _len,
": %d", ": %d",
settings->ints.state_slot); settings->ints.state_slot);
runloop_msg_queue_push(msg, 2, 180, true, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); if (cur_state_slot < 0)
strlcat(msg, " (Auto)", sizeof(msg));
#ifdef HAVE_GFX_WIDGETS
if (dispwidget_get_ptr()->active)
gfx_widget_set_generic_message(msg, 1000);
else
#endif
runloop_msg_queue_push(msg, 2, 60, true, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
RARCH_LOG("[State]: %s\n", msg); RARCH_LOG("[State]: %s\n", msg);
} }

View File

@ -775,7 +775,7 @@ static void task_save_handler(retro_task_t *task)
const char *failed_undo_str = msg_hash_to_str( const char *failed_undo_str = msg_hash_to_str(
MSG_FAILED_TO_UNDO_SAVE_STATE); MSG_FAILED_TO_UNDO_SAVE_STATE);
RARCH_ERR("[State]: %s \"%s\".\n", failed_undo_str, RARCH_ERR("[State]: %s \"%s\".\n", failed_undo_str,
undo_save_buf.path); undo_save_buf.path);
err[0] = '\0'; err[0] = '\0';
snprintf(err, err_size - 1, "%s \"RAM\".", failed_undo_str); snprintf(err, err_size - 1, "%s \"RAM\".", failed_undo_str);
} }
@ -951,12 +951,12 @@ static void task_load_handler(retro_task_t *task)
* data */ * data */
if (!(state->file = intfstream_open_rzip_file(state->path, if (!(state->file = intfstream_open_rzip_file(state->path,
RETRO_VFS_FILE_ACCESS_READ))) RETRO_VFS_FILE_ACCESS_READ)))
goto end; goto not_found;
#else #else
if (!(state->file = intfstream_open_file(state->path, if (!(state->file = intfstream_open_file(state->path,
RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_READ,
RETRO_VFS_FILE_ACCESS_HINT_NONE))) RETRO_VFS_FILE_ACCESS_HINT_NONE)))
goto end; goto not_found;
#endif #endif
if ((state->size = intfstream_get_size(state->file)) < 0) if ((state->size = intfstream_get_size(state->file)) < 0)
@ -990,7 +990,7 @@ static void task_load_handler(retro_task_t *task)
snprintf(msg, snprintf(msg,
8192 * sizeof(char), 8192 * sizeof(char),
msg_hash_to_str(MSG_AUTOLOADING_SAVESTATE_FAILED), msg_hash_to_str(MSG_AUTOLOADING_SAVESTATE_FAILED),
state->path); path_basename(state->path));
task_set_error(task, strdup(msg)); task_set_error(task, strdup(msg));
free(msg); free(msg);
} }
@ -1012,13 +1012,14 @@ static void task_load_handler(retro_task_t *task)
size_t msg_size = 8192 * sizeof(char); size_t msg_size = 8192 * sizeof(char);
char *msg = (char*)malloc(msg_size); char *msg = (char*)malloc(msg_size);
msg[0] = '\0';
if (state->flags & SAVE_TASK_FLAG_AUTOLOAD) if (state->flags & SAVE_TASK_FLAG_AUTOLOAD)
{ {
msg[0] = '\0';
snprintf(msg, snprintf(msg,
msg_size - 1, msg_size - 1,
msg_hash_to_str(MSG_AUTOLOADING_SAVESTATE_SUCCEEDED), msg_hash_to_str(MSG_AUTOLOADING_SAVESTATE_SUCCEEDED),
state->path); path_basename(state->path));
} }
else else
{ {
@ -1027,12 +1028,9 @@ static void task_load_handler(retro_task_t *task)
msg_hash_to_str(MSG_LOADED_STATE_FROM_SLOT_AUTO), msg_hash_to_str(MSG_LOADED_STATE_FROM_SLOT_AUTO),
msg_size - 1); msg_size - 1);
else else
{
msg[0] = '\0';
snprintf(msg, msg_size - 1, snprintf(msg, msg_size - 1,
msg_hash_to_str(MSG_LOADED_STATE_FROM_SLOT), msg_hash_to_str(MSG_LOADED_STATE_FROM_SLOT),
state->state_slot); state->state_slot);
}
} }
task_set_title(task, strdup(msg)); task_set_title(task, strdup(msg));
@ -1044,6 +1042,23 @@ static void task_load_handler(retro_task_t *task)
return; return;
not_found:
{
size_t msg_size = 8192 * sizeof(char);
char *msg = (char*)malloc(msg_size);
msg[0] = '\0';
snprintf(msg,
msg_size - 1,
"%s \"%s\".",
msg_hash_to_str(MSG_FAILED_TO_LOAD_STATE),
path_basename(state->path));
task_set_title(task, strdup(msg));
free(msg);
}
end: end:
task_load_handler_finished(task, state); task_load_handler_finished(task, state);
} }
@ -1334,7 +1349,7 @@ static void task_push_save_state(const char *path, void *data, size_t size, bool
/* Delay OSD messages and widgets for a few frames /* Delay OSD messages and widgets for a few frames
* to prevent GPU screenshots from having notifications */ * to prevent GPU screenshots from having notifications */
runloop_state_t *runloop_st = runloop_state_get_ptr(); runloop_state_t *runloop_st = runloop_state_get_ptr();
runloop_st->msg_queue_delay = 10; runloop_st->msg_queue_delay = 12;
state->flags |= SAVE_TASK_FLAG_THUMBNAIL_ENABLE; state->flags |= SAVE_TASK_FLAG_THUMBNAIL_ENABLE;
} }
state->state_slot = settings->ints.state_slot; state->state_slot = settings->ints.state_slot;