Hey,
Savestate info is stored in two ways. You have the saves file itself which contains all the data needed to load the savestate, and you have the "global info" file which contains a slice of every savestate used to display the info in your selection window without having to load the entire save data.
By default, the global info for each savestate consists of the battle parties character- and face graphics, the playtime and the save date. If you want to also use the map id and don't want to load each individual save file to find it out, the first step would be to extend
DataManager.makeSavefileInfo to include it in the global info:
Code:
(function() {
const oldSavefileInfo = DataManager.makeSavefileInfo;
DataManager.makeSavefileInfo = function() {
let info = oldSavefileInfo.call(this);
info.mapId = $gameMap.mapId();
return info;
};
})();
You can of course also just copy the original method from the
js/xxx_managers.js file in your project folder and add the map id there, using a function snapshot is generally preferred for compatibility with other plugins that may try to also extend this function.
You should be able to use
MV:
DataManager.loadSavefileInfo( SAVESLOT_ID
)
MZ:
DataManager.savefileInfo( SAVESLOT_ID
)
to access your savestates info. Note that in rare cases the result will be null if something went wrong or if the player has tampered with the file and broke it, so you should probably check for that:
Code:
let info = DataManager.loadSavefileInfo(4);
if (info) {
let bitmap = ImageManager.loadPicture("Picture" + info.mapId);
// You can do whatever you want with the map Id here
} else {
let bitmap = ImageManager.loadEmptyBitmap();
// Fallback if the info could not be retrieved
}
Optional, but if you are using additional bitmaps in your previews, the game has a function to preload them, so this might reduce lag a bit. You can extend the function
MV:
DataManager.loadAllSavefileImages
MZ:
DataManager.loadSavefileImages
to reserve the pictures you are going to show
(If you are using the ImageManager).
Edit: a bit slow
Edit2:
but I would like to know how to display different pictures when player choses a save file
Generally you would have to check the index of your selection window to see which savestate the player has currently selected. If you are within your Scene_File
(or Scene_Load/Scene_Save) you can use
this.savefileId() to get the currently selected file.