Skip to content

Conversation

Malkierian
Copy link
Contributor

@Malkierian Malkierian commented Feb 26, 2024

The aim of this PR is simple: prevent crashes from loading corrupted save files, gracefully prevent future load issues, and notify the user that something was wrong. This is accomplished by adding a new window, SohModalWindow, which is used to draw modal popups on demand with just a few inputs from code, but has options for customizing title, body, and button texts, adding a second button, and registering callbacks for each button. With certain flags, it's always centered in the window, isn't moveable, resizes itself, and has no scrollbars. This system is usable anywhere SohGui can be referenced (didn't know a better place to put the function to register a modal).

In the case of save loading errors, it catches, renames the file to filex.bak, and then registers the popup.

Two problems I can think this might have: first, as of now, it's only setup to handle static functions and I have no idea how to make it handle class-instance functions, or if that's even necessary.

Second is that, as it stands, it's only useable in C++, and I have no idea how to make the function callbacks useable in C. Theoretically, it could still be used just to print a message to the player with a C bridge function in OTRGlobals, but I don't know if that's necessary or a good idea either.

Build Artifacts

…, but not drawing if no popups are registered.

Adds error catching for save file corruption (malformed json) that renames the file in question to prevent future loading issues and uses `SohModalWindow` to inform the user of the error.
@Malkierian
Copy link
Contributor Author

brave_J6p3s77Uw2.mp4

@Malkierian Malkierian changed the title [UE Improvement] Catch save loading errors and notify user [UX Improvement] Catch save loading errors and notify user Feb 26, 2024
@garrettjoecox garrettjoecox merged commit b26f2b2 into HarbourMasters:develop-macready Feb 29, 2024
@Malkierian Malkierian deleted the modals-framework-save-corruption branch February 29, 2024 03:18
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.

3 participants