Hey guys. So I've been working on a custom menu code for the past few days. Nothing crazy, or so I thought. It's simple menu command boxes, which work perfectly, except for one thing. I wanted it to be so that in the "help" submenu you can just select/scroll/hover over either the "controls" or "powerups" options and that it would show a graphic to the right of it displaying the info.
For some reason no matter how much I rework the code with different methods, I can't get any image to show up. This version is my most recent attempt. And the images are supposedly being loaded, according to console logs I did while debugging. But I see nothing on screen.
I can't tell what the issue with the code is. Or maybe if there's not an issue and it's just some weird compatibility issue on my end for some reason. Can any of you take a look at it and give me your opinion.
For some reason no matter how much I rework the code with different methods, I can't get any image to show up. This version is my most recent attempt. And the images are supposedly being loaded, according to console logs I did while debugging. But I see nothing on screen.
I can't tell what the issue with the code is. Or maybe if there's not an issue and it's just some weird compatibility issue on my end for some reason. Can any of you take a look at it and give me your opinion.
JavaScript:
/*:
* @plugindesc Plugin for pause menu.
* @author TempWarlord
*/
(function () {
"use strict";
///
var HELP_PICTURE_MAP = {
controls: "controls",
powerups: "powerups",
};
///
function Scene_PauseMenu() {
this.initialize.apply(this, arguments);
}
Scene_PauseMenu.prototype = Object.create(Scene_MenuBase.prototype);
Scene_PauseMenu.prototype.constructor = Scene_PauseMenu;
Scene_PauseMenu.prototype.initialize = function () {
Scene_MenuBase.prototype.initialize.call(this);
};
Scene_PauseMenu.prototype.create = function () {
Scene_MenuBase.prototype.create.call(this);
this.createCommandWindow();
};
Scene_PauseMenu.prototype.createCommandWindow = function () {
var windowWidth = 300;
var windowHeight = 188;
var rectX = (Graphics.boxWidth - windowWidth) / 2;
var rectY = (Graphics.boxHeight - windowHeight) / 2;
this._commandWindow = new Window_Command(rectX, rectY);
this._commandWindow.makeCommandList = function () {
this.addCommand("Volume", "volume");
this.addCommand("To Title", "title");
this.addCommand("Help", "help");
this.addCommand("Return", "cancel");
};
this._commandWindow.width = windowWidth;
this._commandWindow.height = windowHeight;
this._commandWindow.refresh();
this._commandWindow.setHandler("volume", this.commandVolume.bind(this));
this._commandWindow.setHandler("title", this.commandTitle.bind(this));
this._commandWindow.setHandler("help", this.commandHelp.bind(this));
this._commandWindow.setHandler("cancel", this.popScene.bind(this));
this.addWindow(this._commandWindow);
this._commandWindow.activate();
};
////
Scene_PauseMenu.prototype.commandVolume = function () {
SceneManager.push(Scene_Options);
};
Scene_PauseMenu.prototype.commandTitle = function () {
SceneManager.goto(Scene_Title);
};
////
function Scene_Help() {
this.initialize.apply(this, arguments);
}
Scene_Help.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Help.prototype.constructor = Scene_Help;
Scene_Help.prototype.initialize = function () {
Scene_MenuBase.prototype.initialize.call(this);
this._lastSelectionIndex = -1;
};
Scene_Help.prototype.create = function () {
Scene_MenuBase.prototype.create.call(this);
this.createPictureWindow();
this.createCommandWindow();
};
Scene_Help.prototype.createPictureWindow = function () {
var rect = new Rectangle(
240,
0,
Graphics.boxWidth - 240,
Graphics.boxHeight
);
this._pictureWindow = new Window_Base(rect);
this.addWindow(this._pictureWindow);
};
Scene_Help.prototype.createCommandWindow = function () {
var windowWidth = 300;
var windowHeight = 144;
var rectX = 0;
var rectY = 0;
this._commandWindow = new Window_Command(rectX, rectY);
this._commandWindow.makeCommandList = function () {
this.addCommand("Controls", "controls");
this.addCommand("Powerups", "powerups");
this.addCommand("Return", "cancel");
};
this._commandWindow.width = windowWidth;
this._commandWindow.height = windowHeight;
this._commandWindow.refresh();
this._commandWindow.setHandler("cancel", this.popScene.bind(this));
this.addWindow(this._commandWindow);
this._commandWindow.select(0);
this._commandWindow.activate();
};
////
Scene_PauseMenu.prototype.commandHelp = function () {
SceneManager.push(Scene_Help);
};
///
Scene_Help.prototype.update = function () {
Scene_MenuBase.prototype.update.call(this);
if (this._commandWindow && this._commandWindow.active) {
if (this._commandWindow.index() !== this._lastSelectionIndex) {
this._lastSelectionIndex = this._commandWindow.index();
var symbol = this._commandWindow.currentSymbol();
// Look up the image name in our map
var imageName = HELP_PICTURE_MAP[symbol] || "";
this._pictureWindow.contents.clear(); // Clear the old image
if (imageName) {
var bitmap = ImageManager.loadPicture(imageName);
bitmap.addLoadListener(
function () {
var drawX =
(this._pictureWindow.contentsWidth() - bitmap.width) / 2;
var drawY =
(this._pictureWindow.contentsHeight() - bitmap.height) / 2;
this._pictureWindow.contents.blt(
bitmap,
0,
0,
bitmap.width,
bitmap.height,
drawX,
drawY
);
}.bind(this)
);
}
}
}
};
////
var Scene_Map_callMenu = Scene_Map.prototype.callMenu;
Scene_Map.prototype.callMenu = function () {
SceneManager.push(Scene_PauseMenu);
};
})();