Skip to content

Commit 40b4503

Browse files
authored
State slot hotkey adjustments (#18388)
* Allow Auto slot with state hotkeys * Hide state thumbnail widget on state load * State slot msg reformat
1 parent 5650d91 commit 40b4503

4 files changed

Lines changed: 34 additions & 16 deletions

File tree

command.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ static void command_post_state_loaded(void)
9393
if (frame_time_counter_reset_after_load_state)
9494
video_st->frame_time_count = 0;
9595
}
96+
#if defined(HAVE_GFX_WIDGETS) && defined(HAVE_SCREENSHOTS)
97+
{
98+
gfx_widget_state_slot_show(dispwidget_get_ptr(), NULL, NULL);
99+
}
100+
#endif
96101
}
97102

98103
#if defined(HAVE_COMMAND)

gfx/widgets/gfx_widget_screenshot.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ static void gfx_widget_screenshot_fadeout(void *userdata)
100100
gfx_animation_push(&entry);
101101
}
102102

103+
static void gfx_widget_screenshot_dispose(void *userdata)
104+
{
105+
gfx_widget_screenshot_state_t *state = &p_w_screenshot_st;
106+
107+
state->loaded = false;
108+
video_driver_texture_unload(&state->texture);
109+
state->texture = 0;
110+
}
111+
103112
static void gfx_widgets_play_screenshot_flash(void *data)
104113
{
105114
gfx_animation_ctx_entry_t entry;
@@ -136,6 +145,12 @@ void gfx_widget_state_slot_show(
136145

137146
state->state_slot = true;
138147

148+
if (!shotname || !filename)
149+
{
150+
gfx_widget_screenshot_dispose(NULL);
151+
return;
152+
}
153+
139154
strlcpy(state->filename, filename, sizeof(state->filename));
140155
strlcpy(state->shotname, shotname, sizeof(state->shotname));
141156
}
@@ -160,15 +175,6 @@ void gfx_widget_screenshot_taken(
160175
}
161176
}
162177

163-
static void gfx_widget_screenshot_dispose(void *userdata)
164-
{
165-
gfx_widget_screenshot_state_t *state = &p_w_screenshot_st;
166-
167-
state->loaded = false;
168-
video_driver_texture_unload(&state->texture);
169-
state->texture = 0;
170-
}
171-
172178
static void gfx_widget_screenshot_end(void *userdata)
173179
{
174180
gfx_animation_ctx_entry_t entry;

intl/msg_hash_us.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15080,11 +15080,11 @@ MSG_HASH(
1508015080
)
1508115081
MSG_HASH(
1508215082
MSG_LOADED_STATE_FROM_SLOT,
15083-
"Loaded state from slot #%d."
15083+
"Loaded state from slot: %d."
1508415084
)
1508515085
MSG_HASH(
1508615086
MSG_LOADED_STATE_FROM_SLOT_AUTO,
15087-
"Loaded state from slot #-1 (Auto)."
15087+
"Loaded state from slot: Auto."
1508815088
)
1508915089
MSG_HASH(
1509015090
MSG_LOADING,
@@ -15288,11 +15288,11 @@ MSG_HASH(
1528815288
)
1528915289
MSG_HASH(
1529015290
MSG_SAVED_STATE_TO_SLOT,
15291-
"Saved state to slot #%d."
15291+
"Saved state to slot: %d."
1529215292
)
1529315293
MSG_HASH(
1529415294
MSG_SAVED_STATE_TO_SLOT_AUTO,
15295-
"Saved state to slot #-1 (Auto)."
15295+
"Saved state to slot: Auto."
1529615296
)
1529715297
MSG_HASH(
1529815298
MSG_SAVED_SUCCESSFULLY_TO,

runloop.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6900,9 +6900,9 @@ static enum runloop_state_enum runloop_check_state(
69006900
{
69016901
check = true;
69026902
state_slot--;
6903-
/* Wrap to 0 */
6903+
/* Wrap to Auto */
69046904
if (state_slot < 0)
6905-
state_slot = 0;
6905+
state_slot = -1;
69066906
}
69076907

69086908
if (check)
@@ -6925,10 +6925,17 @@ static enum runloop_state_enum runloop_check_state(
69256925

69266926
if (state_slot > 0)
69276927
_len += snprintf(path + _len, sizeof(path) - _len, "%d", state_slot);
6928+
else if (state_slot < 0)
6929+
_len = fill_pathname_join_delim(path,
6930+
runloop_st->name.savestate, "auto", '.', sizeof(path));
69286931

69296932
strlcpy(path + _len, FILE_PATH_PNG_EXTENSION, sizeof(path) - _len);
69306933

6931-
snprintf(msg, sizeof(msg), "%d", state_slot);
6934+
if (state_slot < 0)
6935+
snprintf(msg, sizeof(msg), "%s", "Auto");
6936+
else
6937+
snprintf(msg, sizeof(msg), "%d", state_slot);
6938+
69326939
gfx_widget_state_slot_show(dispwidget_get_ptr(), msg, path);
69336940
}
69346941
else

0 commit comments

Comments
 (0)