MV How to load different pictures inside a window depending on chosen save file?

Hello!

So I know how to display a picture inside a window but I would like to know how to display different pictures when player choses a save file. For example; save file 1 was made on map01 so in the window appears picture01, save file 2 was made too on map01 so in the window appears picture01 but save file 3 was made on map02 so in the window appears picture02.

How to do this?

In the spoiler there is a top window where pictures should display.

Thank you!

Spoiler: Picture
load screen.png
You need to create an If condition for each save file. The code is something like this:
Code:
var variableSave

if variableSave == file1.rpgsave {
    $gameScreen.showPicture(1, "yourPicture", 1, 600, 300, 100, 100, 255, 0)
}
if variableSave == file2.rpgsave {
    $gameScreen.showPicture(1, "yourPicture", 1, 600, 300, 100, 100, 255, 0)
}
if variableSave == file3.rpgsave {
    $gameScreen.showPicture(1, "yourPicture", 1, 600, 300, 100, 100, 255, 0)
}
// And so on...

Never coded javascript for RPG Maker MV before, to be honest. I only used a few codes here and there, so I don't really know their library well.
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.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-load-different-pictures-inside-a-window-depending-on-chosen-save-file.150178/