//=============================================================================
// Window_ThingCommand
//=============================================================================
function Window_ThingCommand() {
this.initialize.apply(this, arguments);
}
Window_ThingCommand.prototype = Object.create(Window_Command.prototype);
Window_ThingCommand.prototype.constructor = Window_ThingCommand;
Window_ThingCommand.prototype.initialize = function (x, y) {
Window_Command.prototype.initialize.call(this, x, y);
};
Window_ThingCommand.prototype.windowWidth = function () {
return 192;
};
Window_ThingCommand.prototype.numVisibleRows = function () {
return 2;
};
// Create all commands for the command window
Window_ThingCommand.prototype.makeCommandList = function () {
// Command names
var thingCommands = ['Thing1', 'Thing2'];
// Loop over all comamnd names
for (var i = 0; i < thingCommands.length; i++) {
// Get name for command
var name = thingCommands[i];
// Add command and the index, for reference later
this.addCommand(name, 'thing', true, i);
}
};
Window_ThingCommand.prototype.update = function() {
Window_Selectable.prototype.update.call(this);
// Update the text window. Set the thing id to the current id of the command
if (this._textWindow) this._textWindow.setThingId(this.currentExt());
};
Window_ThingCommand.prototype.setTextWindow = function(textWindow) {
this._textWindow = textWindow;
this._textWindow.refresh();
}
//=============================================================================
// Window_Text
//=============================================================================
function Window_Text() {
this.initialize.apply(this, arguments);
}
Window_Text.prototype = Object.create(Window_Selectable.prototype);
Window_Text.prototype.constructor = Window_Text;
Window_Text.prototype.initialize = function (x, y, w, h) {
Window_Selectable.prototype.initialize.call(this, x, y, w, h);
this._thingId = 0;
this._thingText = ['This is text for thing 1', 'This is text for thing 2'];
};
// Set thing id
Window_Text.prototype.setThingId = function (id) {
// Checks if the id really has changed, if yes then update the text window
if (this._thingId !== id) {
this._thingId = id;
this.refresh();
}
};
// Get the text for the current thing id
Window_Text.prototype.text = function () {
return this._thingText[this._thingId];
};
Window_Text.prototype.refresh = function () {
this.contents.clear();
this.drawText(this.text(), this.textPadding(), 0);
};
//=============================================================================
// Scene_Example
//=============================================================================
function Scene_Example() {
this.initialize.apply(this, arguments);
}
Scene_Example.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Example.prototype.constructor = Scene_Example;
Scene_Example.prototype.initialize = function () {
Scene_MenuBase.prototype.initialize.call(this);
};
Scene_Example.prototype.create = function () {
Scene_MenuBase.prototype.create.call(this);
this.createCommandWindow();
this.createTextWindow();
this.update();
};
Scene_Example.prototype.createCommandWindow = function () {
this._commandWindow = new Window_ThingCommand(0, 0);
this._commandWindow.setHandler('thing', this.onCommandThing.bind(this));
this.addWindow(this._commandWindow);
};
Scene_Example.prototype.createTextWindow = function () {
this._textWindow = new Window_Text(this._commandWindow.width, 0, Graphics.boxWidth - 192, Graphics.boxHeight);
this._commandWindow.setTextWindow(this._textWindow);
this.addWindow(this._textWindow);
};
Scene_Example.prototype.onCommandThing = function () {
// This method would be called when pressing okay on a command in the command window
// However at the moment there is only text displayed and the text changes when the cursor
// is changed. So this method is empty because it's not needed at the moment
};