/*:
* @plugindesc Simple Centered Item Menu
* @author Undermax Games | Maxii1996
* @url https://undermax.itch.io/
* @target MZ
*
* @help
*/
(function() {
Scene_Item.prototype.createHelpWindow = function() {
const windowWidth = Graphics.width * 0.90;
const windowHeight = 100;
const wx = (Graphics.width - windowWidth) / 2;
const wy = (Graphics.height - windowHeight) / 2;
const rect = new Rectangle(wx, wy - 180, windowWidth, windowHeight);
this._helpWindow = new Window_Help(rect);
this.addWindow(this._helpWindow);
};
Scene_Item.prototype.createCategoryWindow = function() {
const categoryRect = new Rectangle(0, 0, Graphics.width, 100);
this._categoryWindow = new Window_ItemCategory(categoryRect);
this._categoryWindow.setHandler('ok', this.onCategoryOk.bind(this));
this._categoryWindow.setHandler('cancel', this.popScene.bind(this));
this._categoryWindow.hide();
this._categoryWindow.deactivate();
this._categoryWindow.selectSymbol('item');
};
Scene_Item.prototype.createItemWindow = function() {
const windowWidth = 500;
const windowHeight = 300;
const wx = (Graphics.width - windowWidth) / 2;
const wy = (Graphics.height - windowHeight) / 2 + 50;
const itemListRect = new Rectangle(wx, wy, windowWidth, windowHeight);
this._itemWindow = new Window_ItemList(itemListRect);
this._itemWindow.setHelpWindow(this._helpWindow);
this._itemWindow.setHandler('ok', this.onItemOk.bind(this));
this._itemWindow.setHandler('cancel', this.popScene.bind(this));
this.addWindow(this._itemWindow);
this._itemWindow.selectLast();
this._itemWindow.activate();
this._categoryWindow.selectSymbol('item');
this._itemWindow.setCategory('item');
this._itemWindow.refresh();
this._categoryWindow.deactivate();
this._categoryWindow.hide();
this._itemWindow.select(0);
this._itemWindow.ensureCursorVisible();
this._itemWindow.updateHelp();
};
Scene_Item.prototype.cursorRight = function(wrap) {
this._categoryWindow.select((this._categoryWindow.index() + 1) % this._categoryWindow.maxItems());
this._categoryWindow.callUpdateHelp();
this._itemWindow.setCategory(this._categoryWindow.currentSymbol());
this._itemWindow.refresh();
};
Scene_Item.prototype.cursorLeft = function(wrap) {
this._categoryWindow.select((this._categoryWindow.index() + this._categoryWindow.maxItems() - 1) % this._categoryWindow.maxItems());
this._categoryWindow.callUpdateHelp();
this._itemWindow.setCategory(this._categoryWindow.currentSymbol());
this._itemWindow.refresh();
};
Window_ItemList.prototype.maxCols = function() {
return 1;
};
Window_ItemCategory.prototype.makeCommandList = function() {
this.addCommand(TextManager.item, 'item');
this.addCommand(TextManager.weapon, 'weapon');
this.addCommand(TextManager.armor, 'armor');
this.addCommand(TextManager.keyItem, 'keyItem');
};
Window_ItemList.prototype.drawItem = function(index) {
const item = this.itemAt(index);
if (item) {
const numberWidth = this.numberWidth();
const rect = this.itemLineRect(index);
this.changePaintOpacity(this.isEnabled(item));
this.drawIcon(item.iconIndex, rect.x, rect.y);
const textWidth = this.textWidth(item.name);
const centeredX = rect.x + (rect.width - textWidth) / 2;
this.drawText(item.name, centeredX, rect.y, textWidth);
this.drawItemNumber(item, rect.x, rect.y, rect.width);
this.changePaintOpacity(1);
}
};
})();