Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UI bug] mGBA doesn't update savestate screenshots until you move the cursor over other savestates #2929

Merged
merged 9 commits into from
May 23, 2023

Conversation

Utagai
Copy link
Contributor

@Utagai Utagai commented May 21, 2023

Fixes #2183.

Hi, this is my first PR and @endrift may remember me asking a question or two on the Discord server.

⚠️ I haven't touched C in about... 5 years. And this is my first time making changes to this codebase. Please let me know if I'm doing anything wrong or if I'm making any style mistakes etc.

The change itself is quite small but I'll explain it anyways: extend the SCREENSHOT_* enums in the gui-runner.c file to include a SCREENSHOT_STALE. This is distinct from SCREENSHOT_INVALID because we do not want to just draw the current frame onto the background, we want to draw the actual save state screenshot PNG. This is a case that I considered to be equivalent to the != SCREENSHOT_INVALID case in terms of handling, since we basically just want to reload the new PNG image bytes into the background buffer.

P.S. CONTRIBUTING.md states that my commit messages should be tagged with their relevant components, but I am not familiar enough with this codebase to be know which components I'm touching. I didn't see any components in the document referring to mGUI.

src/feature/gui/gui-runner.c Outdated Show resolved Hide resolved
Copy link
Member

@endrift endrift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to update _tryAutosave to mark the screenshot as invalid if the ID is 0.

src/feature/gui/gui-runner.c Outdated Show resolved Hide resolved
src/feature/gui/gui-runner.c Outdated Show resolved Hide resolved
src/feature/gui/gui-runner.c Outdated Show resolved Hide resolved
@Utagai Utagai requested a review from endrift May 21, 2023 22:56
Copy link
Member

@endrift endrift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed my comment about _tryAutosave it seems.

src/feature/gui/gui-runner.c Outdated Show resolved Hide resolved
@Utagai
Copy link
Contributor Author

Utagai commented May 21, 2023

Oops... my bad for the mistakes there! On it.

@Utagai Utagai requested a review from endrift May 22, 2023 23:22
Copy link
Member

@endrift endrift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last thing: since this is a user-reported bug with visible changes, please add an entry to the CHANGES file in the "Other fixes" section, using the mGUI prefix. Changes are sorted alphabetically by section then by when they were added, so if there are other mGUI changes it goes at the bottom of those, but otherwise it goes in alphabetically between the other entries.

@@ -656,6 +656,9 @@ void mGUIRun(struct mGUIRunner* runner, const char* path) {
runner->core->reset(runner->core);
break;
case RUNNER_SAVE_STATE:
// If we are saving state, then the screenshot stored for the state previously should no longer be considered up-to-date.
// Therefore, mark it as stale, so that at draw time, we will re-draw to the new save state's screenshot.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This phrasing is a bit funky. Not super important, but I might change it a bit like so:

Suggested change
// Therefore, mark it as stale, so that at draw time, we will re-draw to the new save state's screenshot.
// Therefore, mark it as stale so that at draw time we load the new save state's screenshot.

@Utagai
Copy link
Contributor Author

Utagai commented May 23, 2023

Thanks! Hopefully I updated the CHANGES file correctly. 😅

@Utagai Utagai requested a review from endrift May 23, 2023 21:39
@endrift endrift merged commit 196f507 into mgba-emu:master May 23, 2023
endrift pushed a commit that referenced this pull request Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Switch][UI bug] mGBA doesn't update savestate screenshots until you move the cursor over other savestates
2 participants