Load older game saves into updated game: Attempt 2

Started by Crimson Wizard, Tue 28/05/2024 01:43:22

Previous topic - Next topic

Crimson Wizard

#20
Quote from: eri0o on Fri 15/11/2024 03:05:07CW, you backported Length, so in 3.6.2 one can check the array Length property too. So it could use a prescan_slots.Length in that for clause.

Yes that's true, I did not mention Length in this example, because it is not reported as official feature yet.

The "data" arg may be used for another thing, passing a custom user parameter, if they need to distinguish different Scan calls. As you cannot receive the array itself as event argument with this existing callback.

Quote from: eri0o on Fri 15/11/2024 03:05:07Edit2: I think this function can replace the need to have hidden a listbox to retrieve the save slots if you are rendering your save/load GUI using something else, perhaps by even supporting FileSortStyle and SortDirection - but maybe this makes this too complicated. Just random idea.

No that's also true, and may be added, I realized that after committing.
In theory one could get necessary information for sorting using script commands, but then we don't have a sorting function in api, so one would also have to write one... which is going to be an extra complication for a user.

eri0o

I tried the build from the CI to check that if I call it in game start when the event would trigger - I guess if you have a scene in After fadein it would run either before or after but not during - which is alright but I was curious. Mostly because I do setup of my GUIs in game_start, but this is fine too, I can delay the final setup of the save GUI to happen after. I want to play a bit to think how I would use this. For instance, perhaps I would show valid saves, invalid saves appear with some invalid mark and have some option to purge it.

But I couldn't test because there is a bug in the in-draft PR. If you just load a new game from a Sierra Template you will see you can save things (they appear in Saved Games) but they don't appear in the GUI - so the thing that would fill the listbox appears to have the bug too.

Crimson Wizard

Quote from: eri0o on Fri 15/11/2024 20:57:59I tried the build from the CI to check that if I call it in game start when the event would trigger - I guess if you have a scene in After fadein it would run either before or after but not during - which is alright but I was curious

I'm sorry, i don't understand this sentence.

eri0o

The callback runs when no blocking action is happening, so if a character is speaking using regular Say and the event (eEventSavesScanComplete) would happen it triggers after the blocking sequence (a single or many Say calls for example).

If you have a GUI on Screen this means it would update after such blocking calls - at least I think, which is why I wanted to test.

This is not an issue, this is more me wanting to test this.

My interest on this API is because it looks like something that could be useful for a module for custom save/load UIs that I could make without depending on the user having a listbox or any GUIs at all. So it would be something easy to setup - pass a 9-slice graphic and set a few options and done.

Crimson Wizard

#24
Quote from: eri0o on Fri 15/11/2024 21:24:42But I couldn't test because there is a bug in the in-draft PR. If you just load a new game from a Sierra Template you will see you can save things (they appear in Saved Games) but they don't appear in the GUI - so the thing that would fill the listbox appears to have the bug too.

This was a problem with saving a game, description and screenshot image were lost somewhere in the process.

Crimson Wizard

Quote from: eri0o on Fri 15/11/2024 20:57:59I tried the build from the CI to check that if I call it in game start when the event would trigger - I guess if you have a scene in After fadein it would run either before or after but not during - which is alright but I was curious.

So, when Game.ScanSaveSlots is called the scanning is scheduled, and it is executed after the current script has finished, in a post-script step. This is where it schedules the event eEventSavesScanComplete.

But then the on_event is also run in the same post-script step, right after other scheduled actions were run.

So, the whole thing completes before any other script runs.

For example, if you call Game.ScanSaveSlots in game_start, room_Load and room_AfterFadeIn:

- game_start: call Game.ScanSaveSlots, scanning is scheduled
- after game_start exits, scanning is run
- on_event is run
- room_Load: call Game.ScanSaveSlots, scanning is scheduled
- after room_Load exits, scanning is run
- on_event is run
- room_AfterFadeIn: call Game.ScanSaveSlots, scanning is scheduled
- after room_AfterFadeIn exits, scanning is run
- on_event is run
- normal game loops begin to run.



Crimson Wizard

I've started to document loading older saves feature in the manual.
https://github.com/adventuregamestudio/ags-manual/wiki/UpgradeTo362#loading-old-saves-feature
https://github.com/adventuregamestudio/ags-manual/wiki/ValidateRestoredSave

And I wonder if using a "RestoredSaveInfo.Result" would be difficult to understand to users.
Right now it's a combination of bit flags, so you have to use bitwise operators in order to check specific values, like:

Code: ags
// If there's no missing data, then simply accept it and return.
if ((info.Result & eRestoredSave_MissingData) == 0)
{
    info.Cancel = false;
    return;
}

I wonder if it makes sense to find other way.

One method that I've seen somewhere else, is to instead make an boolean "array" property and use these flag values as index. In which case their tests would be coded like:

Code: ags
// If there's no missing data, then simply accept it and return.
if (!info.Result[eRestoredSave_MissingData])
{
    info.Cancel = false;
    return;
}

Crimson Wizard

#29
So, I opened a try-out PR for the change that I described in my previous post.
https://github.com/adventuregamestudio/ags/pull/2632

I'd really like to hear someones opinion on this.

BTW, maybe there's something wrong with the way how I look at this, because now I began to wonder why did I make this flags in script API at all, and not just a set of boolean properties...
There's not too much of them.

EDIT:
Opened an alternate PR, which replaces a Result flag set with 3 distinct properties (and removes enum with flags):
https://github.com/adventuregamestudio/ags/pull/2633

eri0o

Uhm, I noticed we need to have it documented similar to  DialogOptionsRenderingInfo, with its own page.

I guess the original flags make it easier to expand the result possibilities if needed and the latest approach with boolean properties make it easier to discover what is possible through auto complete.

SMF spam blocked by CleanTalk