Hi JS Wizards,
I've got a question for you. I'm working in the Equipment Slot window in the Equipment Scene and I'm having trouble individually positioning my 3 slots. I have maxCols set to 3 but have no idea how to code it so I can set each individual slot on an X/Y coordinate. Right now, all 3 slots are on the same X plane and put in even columns and I'm trying to be able to individually set them at their own location.
Any ideas on how I would code that?
Thanks,
Zer0
I've got a question for you. I'm working in the Equipment Slot window in the Equipment Scene and I'm having trouble individually positioning my 3 slots. I have maxCols set to 3 but have no idea how to code it so I can set each individual slot on an X/Y coordinate. Right now, all 3 slots are on the same X plane and put in even columns and I'm trying to be able to individually set them at their own location.
Any ideas on how I would code that?
Thanks,
Zer0
JavaScript:
// ----------------------------------------------------------
// These functions draw the actor data/value and refreshes it
function Window_EquipSlot() {
this.initialize(...arguments);
}
Window_EquipSlot.prototype = Object.create(Window_StatusBase.prototype);
Window_EquipSlot.prototype.constructor = Window_EquipSlot;
Window_EquipSlot.prototype.initialize = function(rect) {
Window_StatusBase.prototype.initialize.call(this, rect);
this._actor = null;
this.refresh();
};
Window_EquipSlot.prototype.setActor = function(actor) {
if (this._actor !== actor) {
this._actor = actor;
this.refresh();
}
};
Window_EquipSlot.prototype.update = function() {
Window_StatusBase.prototype.update.call(this);
if (this._itemWindow) {
this._itemWindow.setSlotId(this.index());
}
};
Window_EquipSlot.prototype.maxItems = function() {
return this._actor ? this._actor.equipSlots().length : 0;
};
Window_EquipSlot.prototype.maxCols = function() {
return 3;
};
Window_EquipSlot.prototype.item = function() {
return this.itemAt(this.index());
};
Window_EquipSlot.prototype.itemAt = function(index) {
return this._actor ? this._actor.equips()[index] : null;
};
Window_EquipSlot.prototype.drawItemName = function(item, x, y, width) {
if (item) {
const iconY = y + (this.lineHeight() - ImageManager.iconHeight) / 2;
//const textMargin = ImageManager.iconWidth + 4;
//const itemWidth = Math.max(0, width - textMargin);
this.drawIcon(item.iconIndex, x, iconY);
}
};
Window_EquipSlot.prototype.drawItem = function(index) {
if (this._actor) {
const slotName = this.actorSlotName(this._actor, index);
const item = this.itemAt(index);
const slotNameWidth = this.slotNameWidth();
const rect = this.itemLineRect(index);
const itemWidth = rect.width - slotNameWidth;
this.drawText(slotName, rect.x, rect.y, slotNameWidth, rect.height);
this.drawItemName(item, rect.x + 20, rect.y, 50);
}
};
Window_EquipSlot.prototype.slotNameWidth = function() {
return 138;
};
Window_EquipSlot.prototype.isEnabled = function(index) {
return this._actor ? this._actor.isEquipChangeOk(index) : false;
};
Window_EquipSlot.prototype.isCurrentItemEnabled = function() {
return this.isEnabled(this.index());
};
Window_EquipSlot.prototype.setStatusWindow = function(statusWindow) {
this._statusWindow = statusWindow;
this.callUpdateHelp();
};
Window_EquipSlot.prototype.setItemWindow = function(itemWindow) {
this._itemWindow = itemWindow;
};
Window_EquipSlot.prototype.updateHelp = function() {
Window_StatusBase.prototype.updateHelp.call(this);
this.setHelpWindowItem(this.item());
if (this._statusWindow) {
this._statusWindow.setTempActor(null);
}
};
//=======================================================================