Hi,
If your saved games remain medium to small in size, that's a fine solution, and I'd continue using it. Each saved game will contain data like this:
[SavedGameData: {slotData}, {regularSaveData} ]
where {slotData} is the extra info (save time, game time, player level, etc)
However, if your saved games become very large, then to show the custom data for all of the saved games you will need to read all of the saved games first, which could take more time than you want. Instead, you could save each slot like this:
{slotData}, [SavedGameData: {regularSaveData} ]
This way, when showing the "load game" screen, you can read each slot's {slotData} without having to read and parse the regular save data.
One way to do this is to make your own subclass of
SavedGameDataStorer (or one of its subclasses such as
DiskSavedGameDataStorer).
Before saving, store the slot data in a key just like in your post.
Then override StoreSavedGameData(slot, savedGameData) to do this: (pseudocode)
Code: Select all
public void StoreSavedGameData(int slot, SavedGameData savedGameData)
{
// Get the slot data and save it first:
var slotData = save.GetData(SlotData.KEY);
/* save slotData here */
// Then save the regular save data:
/* save savedGameData here */
}
Override RetrieveSavedGameData(slot, savedGameData) to skip the slotData: (pseudocode)
Code: Select all
public SavedGameData RetrieveSavedGameData(int slot)
{
// Skip slotData:
/* read past slotData */
// Read regular save data:
/* read and return savedGameData */
}
Finally, add a new method called something like RetrieveSlotData(int slot): (pseudocode)
Code: Select all
public SlotData RetrieveSlotData(int slot)
{
/* read and return slotData */
// No need to read regular save data; just return slotData.
}
To show the "load game" panel, use RetrieveSlotData() to get the slot data without having to read each saved game's full data.