//=============================================================================
// Window_EquipSlot
//=============================================================================
Yanfly.Equip.Window_EquipSlot_setActor = Window_EquipSlot.prototype.setActor;
Window_EquipSlot.prototype.setActor = function(actor) {
this.setSlotNameWidth(actor);
Yanfly.Equip.Window_EquipSlot_setActor.call(this, actor);
};
Window_EquipSlot.prototype.refresh = function() {
if (this._actor) this._actor.refresh();
Window_Selectable.prototype.refresh.call(this);
};
Window_EquipSlot.prototype.isEnabled = function(index) {
if (this._actor) {
return Yanfly.Equip.Game_Actor_isEquipChangeOk.call(this._actor, index);
} else {
return false;
}
};
Window_EquipSlot.prototype.drawItem = function(index) {
if (!this._actor) return;
var rect = this.itemRectForText(index);
this.changeTextColor(this.systemColor());
this.changePaintOpacity(this.isEnabled(index));
var ww1 = this._nameWidth;
this.drawText(this.slotName(index), rect.x, rect.y, ww1);
var ww2 = rect.width - ww1;
var item = this._actor.equips()[index];
if (item) {
this.drawItemName(item, rect.x + ww1, rect.y, ww2);
} else {
this.drawEmptySlot(rect.x + ww1, rect.y, ww2);
}
this.changePaintOpacity(true);
};
Window_EquipSlot.prototype.setSlotNameWidth = function(actor) {
if (!actor) return;
this._nameWidth = 0;
for (var i = 0; i < actor.equipSlots().length; ++i) {
var text = $dataSystem.equipTypes[actor.equipSlots()[i]] + ' ';
this._nameWidth = Math.max(this._nameWidth, this.textWidth(text));
}
};
Window_EquipSlot.prototype.drawEmptySlot = function(wx, wy, ww) {
this.changePaintOpacity(false);
var ibw = Window_Base._iconWidth + 4;
this.resetTextColor();
this.drawIcon(Yanfly.Icon.EmptyEquip, wx + 2, wy + 2);
var text = Yanfly.Param.EquipEmptyText;
this.drawText(text, wx + ibw, wy, ww - ibw);
};
Window_EquipSlot.prototype.setInfoWindow = function(infoWindow) {
this._infoWindow = infoWindow;
this.update();
};
Yanfly.Equip.Window_ItemList_updateHelp = Window_EquipSlot.prototype.updateHelp;
Window_EquipSlot.prototype.updateHelp = function() {
Yanfly.Equip.Window_ItemList_updateHelp.call(this);
if (SceneManager._scene instanceof Scene_Equip && this._infoWindow) {
this._infoWindow.setItem(this.item());
}
};