MV Main Menu equivalent of Window_ShopStatus.prototype.refresh

I am running a plugin that lets me display sprites on the various menu screens, but I am having trouble with duplicate images stacking on top of each other when I change the party formation around. The 2 sprites who are swapped will overlay one onto the other like so.

1709520427134.png


The same issue was occurring with the shop scene, but I was able to fix this by adding the following lines to the top of Window_ShopStatus.prototype.refresh = function():

this.contents.clear();
if (this._actorSprite) {
this._actorSprite.destroy();
delete this._actorSprite;
}


So I was wondering, is there an equivalent for this function that applies to the main menu/formation screen? I was not able to find anything that worked similarly in rpg_windows.js. I even tried pasting the code under every refresh function, as well as those that contain this.contents.clear(); , but alas no luck.

The duplicated sprites do disappear when I access another part of the menu such as Skills or Status, or when I close the menu and reopen it. This gives me some ideas but I am not entirely sure how to approach this either.

Any pointers?
I am having trouble with duplicate images stacking on top of each other when I change the party formation around
because you're drawing on top of the finished product.
each entry on the menu is it's own thing: the image, the health bars and the name.
modify the object entry, not the finished product menu.
Based on just the default function I've found, I don't see a reason why it should be happening.

JavaScript:
Scene_Menu.prototype.onFormationOk = function() {
    var index = this._statusWindow.index();
    var actor = $gameParty.members()[index];
    var pendingIndex = this._statusWindow.pendingIndex();
    if (pendingIndex >= 0) {
        $gameParty.swapOrder(index, pendingIndex);
        this._statusWindow.setPendingIndex(-1);
        this._statusWindow.redrawItem(index);
    } else {
        this._statusWindow.setPendingIndex(index);
    }
    this._statusWindow.activate();
};

Perhaps you're missing the call to redrawItem in your custom plugin...
Thank you both of you for your pointers. Kyonides, it seems like I was looking in rpg_window.js by mistake, that function in rpg_scenes.js looks like it may be what I am looking for. Will start looking through the scenes.js file and seeing if I can get this working. Something tells me I may need modified code or a different approach however for this section.

For what I did and how I ended up in this situation see spoiler.

Spoiler: Changes
The plugin I am using (VE_SpriteInWindows.js) was not suffering from this problem in its original form, however I had to modify it due to some issues with it never being properly completed for charsets. The sprites would find themselves on the map x,y instead of screen x,y, so I more or less swapped from setImage to new Sprite.

I removed this function:
this._character.setImage(characterName, characterIndex);
this._spriteX = x + 64;

this._spriteY = y + 64;
this._mainSprite.update();
this.update();

and added this instead, which fixed the core issue:
var characterName = battler.characterName();
var characterIndex = battler.characterIndex();
this._actorSprite = new Sprite(ImageManager.loadCharacter(characterName, characterIndex));


Then added the following to Window_ShopStatus.prototype.refresh = function():

this.contents.clear();
if (this._actorSprite) {
this._actorSprite.destroy();
delete this._actorSprite;
}
This fixed the shop menu's sprite duplication. Going to go mess with Scene_Menu.prototype.onFormationOk now.


This section of code might be what you are referring to that needs a redraw function btw kyonides?

Code:
    //=============================================================================
    // Window_Selectable
    //=============================================================================

    VictorEngine.SpriteInWindows.drawAllItems = Window_Selectable.prototype.drawAllItems;
    Window_Selectable.prototype.drawAllItems = function() {
        var top  = this.topIndex();
        var max  = this.maxItems();
        var page = this.maxPageItems() + top;
        this._battlerSprites.forEach(function(sprite, index) {
            if (sprite) sprite.visible = index >= top && index < page && index < max;
        });
        this._charsetSprites.forEach(function(sprite, index) {
            if (sprite) sprite.visible = index >= top && index < page && index < max;
        });
        VictorEngine.SpriteInWindows.drawAllItems.call(this);
    };
   
    Window_Selectable.prototype.isSelected = function(index) {
        return this.index() === index || this.cursorAll();
    };

Any further guidance if I am overlooking anything will be appreciated.
It gotta be extremely simple.

JavaScript:
Window_MenuStatus.prototype.drawItemImage = function(index) {
    var actor = $gameParty.members()[index];
    var rect = this.itemRect(index);
    this.changePaintOpacity(actor.isBattleMember());
    this.drawActorFace(actor, rect.x + 1, rect.y + 1, Window_Base._faceWidth, Window_Base._faceHeight);
    this.changePaintOpacity(true);
};

The only thing you ever needed to replace was the call to drawActorFace function every single time it appeared on your custom or default plugins. The scenes plugin should have taken care of the rest, including the clearing of the whole area.
Thank you, drawActorFace is actually replaced with the plugin I am using, so calling it is no problem. I do see now how I can replace the entire plugin if I need to with this knowledge though.

I did find out what my error was too. The if statement I was using was set up to only show one sprite at a time, deleting the rest. So the entire party is hidden except for the selected unit. I had thought it was looking for duplicates mistakenly.

Code:
if (this._actorSprite) {
this._actorSprite.destroy();
delete this._actorSprite;
 }

So now I need to figure out how to prevent this from blocking out all the sprites after the first, yet still delete duplicate sprites.

Original thread: https://forums.rpgmakerweb.com/threads/main-menu-equivalent-of-window_shopstatus-prototype-refresh.166451/