MV Custom Biography plugin, some problems.

I just wrote "heart" of my plugin to display main heroes biography
Spoiler
Screenshot_3.png

However I stuck at few major problems:

#1 How to add and bind new menu command to main menu?
#2 How to display list of all present party members before showing biography?
#3 How to get and pass argument to drawActorFace method, since it's take as 1st argument Game_Actors object?
#4 How to return to previous menu, when esc key is pressed?

I'm attaching a code to make things easier.
Spoiler
JavaScript:
function Scene_Biography() {
    this.initialize.apply(this, arguments);
}

Scene_Biography.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Biography.prototype.constructor = Scene_Biography;

Scene_Biography.prototype.initialize = function() {
    Scene_MenuBase.prototype.initialize.call(this);
   
};

Scene_Biography.prototype.create = function(){
    Scene_MenuBase.prototype.create.call(this);
    this._windowActorStats = new Window_ActorStats(64, 64, 448, 448);
    this._windowActorBio = new Window_ActorBio(64 + 448, 64, 448, 448);
    this.addWindow(this._windowActorStats);
    this.addWindow(this._windowActorBio);
}

function Window_ActorStats() {
    this.initialize.apply(this, arguments);
}

Window_ActorStats.prototype = Object.create(Window_Base.prototype);
Window_ActorStats.prototype.constructor = Window_ActorStats;

Window_ActorStats.prototype.initialize = function(x, y, width, height) {
    Window_Base.prototype.initialize.call(this, x, y, width, height);
    this.drawAllItems(this.actorId());
    this.refresh();
};

Window_ActorStats.prototype.actorId = function(){
    return $gameActors.actor($gameParty._targetActorId) || $gameActors.actor(1);
}

Window_ActorStats.prototype.lineHeight = function(){
    return 36;
}

Window_ActorStats.prototype.drawAllItems = function(){
    this.drawActorFace(this.actorId(), 8, 8, 144, 144);
    this.drawTextEx("\\hc[ffcc00][Lv. %1]\\hc[ffffff] - %2".format(this.actorId().level, this.actorId().name()), 160, 8);
    this.drawTextEx($dataClasses[this.actorId()._classId].name, 160, 8 + this.lineHeight());
    this.drawTextEx("\\hc[32cd32]Life: %1 / %2\\hc[ffffff]".format(this.actorId().hp, this.actorId().mhp), 160, 8 + (this.lineHeight()*2));
    this.drawTextEx("\\hc[87ceeb]Magic: %1 / %2\\hc[ffffff]".format(this.actorId().mp, this.actorId().mmp), 160, 8 + (this.lineHeight()*3));
   
    this.drawText("Offensive stats:", 8, 160, "center")
    this.drawTextEx("Strength: %1".format(this.actorId().atk), 16, 176 + this.lineHeight());
    this.drawTextEx("Inteligence: %1".format(this.actorId().mat), 16, (176 + this.lineHeight()*2));
    this.drawTextEx("Agility: %1".format(this.actorId().agi), 16, 176 + (this.lineHeight()*3));
   
    this.drawText("Defensive stats:", 232, 160, "center")
    this.drawTextEx("Defense: %1".format(this.actorId().def), 248, 176 + this.lineHeight());
    this.drawTextEx("Resistance: %1".format(this.actorId().mdf), 248, (176 + this.lineHeight()*2));
    this.drawTextEx("Luck: %1".format(this.actorId().luk), 248, 176 + (this.lineHeight()*3));  
}

Window_ActorStats.prototype.refresh = function() {
    if (this.contents) {
        this.contents.clear();
        this.drawAllItems();
    }
};


function Window_ActorBio() {
    this.initialize.apply(this, arguments);
}

Window_ActorBio.prototype = Object.create(Window_Base.prototype);
Window_ActorBio.prototype.constructor = Window_ActorBio;

Window_ActorBio.prototype.initialize = function(x, y, width, height) {
    Window_Base.prototype.initialize.call(this, x, y, width, height);
    this.drawBio();
};

Window_ActorBio.prototype.actorId = function(){
    return $gameActors.actor($gameParty._targetActorId) || $gameActors.actor(1);
}

Window_ActorBio.prototype.drawBio = function(){
    this.drawTextEx(this.actorId().profile(), 8, 8);
}

Thank you for your time and help.
Here's a rough outline:
  1. The window populates its own commands, the scene binds those commands to results:
    • Add command: Window_MenuCommand.prototype.makeCommandList
    • Bind command: Scene_Menu.prototype.createCommandWindow

  2. Bind the command to the scene's commandPersonal method (lets user select an actor), then add a new case to the onPersonalOk method.

  3. drawActorFace is defined on Window_StatusBase, but you are inheriting from Window_Base. Instead, I suggest you just use the Window_Base method drawFace: name, index, x, y (optional width & height).

    [Edit @Soulrender: actually you probably just wanted to know how to get the actor selected in point 2, sorry. It's $gameParty.menuActor(). 😊]

    [Edit 2: oops, the RMMV core scripts do define drawActorFace on Window_Base. I was looking at the RMMZ code instead...sorry for any confusion! 😴]

  4. You can add a check to your scene's update method for the appropriate input, as seen in Scene_Gameover.prototype.update, or Scene_Map.prototype.updateCallMenu.
I'm guessing you can figure out the details from there, but I (or someone else) can probably elaborate if necessary~ 👋
@caethyril - It took me so far 2 mogs of coffee, but somehow I managed to solve first 3 points, but the last, 4th point for some reason is not going well... :/

JavaScript:
Scene_Biography.prototype.update = function() {
    if (this.isActive() && !this.isBusy() && this.isTriggered()) {
        SceneManager.push(Scene_Menu);
    }
    Scene_Base.prototype.update.call(this);
};

Scene_Biography.prototype.isTriggered = function() {
    return Input.isTriggered('escape') || TouchInput.isTriggered();
};

In main menu pressing escape key before entering Scene_Biography works OK, but then, regardles of item menu position, Scene_Biography is brought back, making unable to return to game. :/
In main menu pressing escape key before entering Scene_Biography works OK, but then, regardles of item menu position, Scene_Biography is brought back, making unable to return to game. :/
This is because you use SceneManager.push(Scene_Menu); to exit the Scene_Biography what you want to use is this.popScene(). The reason is because the SceneManager has a stack of previous scenes. So when you call SceneManager.push(Scene_Menu); you add your Scene_Biography to the top of this stack and change the active scene to Scene_Menu. When you then try to escape from the Scene_Menu it properly calls this.popScene() which changes the active scene to the scene on top of the stack and removes it from the stack.

In your case because you call SceneManager.push(Scene_Menu); the stack probably ends up looking like this: [Scene_Map, Scene_Menu, Scene_Biography] after "returning" to the Scene_Menu, however if you change this to this.popScene() then it would look like this [Scene_Map]. So the next time this.popScene() is called it will return to the Scene_Map.
@Magnus0808 Ok, Thank you, that solves almost everything, but now I wonder, why it does not play cancel sound...

Edit:
I added
Code:
SoundManager.playCancel()
and it work, but I'm still confused, why it's not playing by default, like in other scenes...
I added
Code:
SoundManager.playCancel()
and it work, but I'm still confused, why it's not playing by default, like in other scenes...
I assume it's the cancel sound associated with Window_Selectable.prototype.processCancel. The standard menu scenes all have at least one selectable window to handle input. Check out Scene_Status for a relatively simple example~

I suggested handling it in your scene's update method because you weren't using any input-handling windows.
Ok, thank you all for your time and help. Plugin works now in 100% as planned, but I'm not happy how the code looks

Original thread: https://forums.rpgmakerweb.com/threads/custom-biography-plugin-some-problems.137910/