Understanding the code of the Windows in MV was very hard, at least for me.
First you need to create your new window with your new features, for illustration, I'm creating a Confirm window, with options Confirm and Cancel:
Using the Window_Command as parent Class, I create the Window_GameConfirm:
Spoiler
Code:
//##Creating the class
function Window_GameConfirm() {
this.initialize.apply(this, arguments);
}
//##Setting the inheritance of the Window_Command class
Window_GameConfirm.prototype = Object.create(Window_Command.prototype);
Window_GameConfirm.prototype.constructor = Window_Command;
//Rewriting this function for setting my desired width of the Window
Window_GameConfirm.prototype.windowWidth = function() {
return 450;
};
//Rewriting this function to adjust the height of my Window, using 3 rows
Window_GameConfirm.prototype.windowHeight = function() {
return this.fittingHeight(3);
};
//Rewriting this function to set the commands of my window
Window_GameConfirm.prototype.makeCommandList = function() {
this.addCommand("Confirm", 'confirm');
this.addCommand("Cancel", 'cancel');
};
Note: You can check all the base functions for the parent class I'm using searching for "function Window_Command()" on rpg_windows.js.
Your new windows is ready, but now you need to make it shine, the system that tells the game to open, close or active your window is the Scene of the game, the MV has various Scenes (Scene_Title, Scene_Map, Scene_Item).
In your case, as you say that this will be in Item Window Menu, I think you should use Scene_Item
So, you will need to add some new stuff on Scene_Item:
Spoiler
Code:
var parent_Scene_Item_createItemWindow = Scene_Item.prototype.createItemWindow;
Scene_Item.prototype.createItemWindow = function() {
//Here will create all already existing windows
parent_Scene_Item_createItemWindow.call(this);
//And here you gonna create your new custom Window(x and y must be set for your coord on the screen)
this._myCustomWindow = new Window_GameConfirm(x, y);
//Here you gonna bind the functions that will handle each option in your menu
this._myCustomWindow.setHandler('confirm', this.onMyCustomOk.bind(this));
this._myCustomWindow.setHandler('cancel', this.onMyCustomCancel.bind(this));
//Here you actually tells the Scene_Item to add your new Window in the drawing process of the scene
this.addWindow(this._myCustomWindow);
};
You can't forget to add the code of what happens when any of the conditions are selected:
Spoiler
Code:
//Function
Scene_Item.prototype.onMyCustomOk= function() {
var item = this.item();
//Do whaterever you want with the selected Item
}
//Function for closing the Custom Window
Scene_Item.prototype.onMyCustomCancel= function() {
this._myCustomWindow.deactivate();
this._myCustomWindow.deselect();
this._myCustomWindow.hide();
//You need to remember to activete the old Window or
// the game will looks likes is frozen
this._itemWindow.activate();
};
Ok, you new Windows is ready and the Scene should create it when you pop up the Item List Menu, but will not show yet, for this happen, you need to rewrite the exactly code you want to call your new Window.
Assuming you want to pop your new window when you use a Item, you can rewrite this function:
Spoiler
Code:
var parent_Scene_Item_onActionUse = Scene_Item.prototype.onActionUse;
Scene_Item.prototype.onActionUse = function() {
//Here, instead of "== true", you add any condition to show your
//new Window only when it's some special item for instance
if(this.item() == true){
this._myCustomWindow.show();
this._myCustomWindow.activate();
this._myCustomWindow.selectLast();
}else{
parent_Scene_Item_onActionUse.call(this)
}
Well, that's a lot of things. I really expend a lot of time to understand a bit of how it works, this code is just for illustration, there are probably some errors but I think it will help you a little bit to understand the idea of how MV handles the Window. Cheers!