Source: Window_EquipItem.js

Window_EquipItem.js

//-----------------------------------------------------------------------------
// Window_EquipItem
//
// The window for selecting an equipment item on the equipment screen.
/**
 * The window for selecting an equipment item on the equipment screen.
 *
 * @class
 * @extends Window_ItemList
 */
function Window_EquipItem() {
    this.initialize(...arguments);
}

Window_EquipItem.prototype = Object.create(Window_ItemList.prototype);
Window_EquipItem.prototype.constructor = Window_EquipItem;

Window_EquipItem.prototype.initialize = function(rect) {
    Window_ItemList.prototype.initialize.call(this, rect);
    this._actor = null;
    this._slotId = 0;
};

/**
 * Get the maximum amount of columns the window supports
 *
 * @return {number} The number of columns in the window
 */
Window_EquipItem.prototype.maxCols = function() {
    return 1;
};

/**
 * Get the amount of spacing between columns
 *
 * @return {number} Spacing between columns
 */
Window_EquipItem.prototype.colSpacing = function() {
    return 8;
};

/**
 * Sets the actor object for the window
 *
 * @param {Game_Actor} actor - The Game Actor object
 */
Window_EquipItem.prototype.setActor = function(actor) {
    if (this._actor !== actor) {
        this._actor = actor;
        this.refresh();
        this.scrollTo(0, 0);
    }
};

/**
 * Sets the slot id for the window
 *
 * @param {number} slotId - The new slot id
 */
Window_EquipItem.prototype.setSlotId = function(slotId) {
    if (this._slotId !== slotId) {
        this._slotId = slotId;
        this.refresh();
        this.scrollTo(0, 0);
    }
};

/**
 * Check if the window should include the weapon/armor
 *
 * @param {Object} item - The weapon/armor object to check for inclusion
 * @return {boolean} True if the weapon/armor should be included in the window
 */
Window_EquipItem.prototype.includes = function(item) {
    if (item === null) {
        return true;
    }
    return (
        this._actor &&
        this._actor.canEquip(item) &&
        item.etypeId === this.etypeId()
    );
};

/**
 * Get the equipment type id of the current slot id
 *
 * @return {number} The equipment type id
 */
Window_EquipItem.prototype.etypeId = function() {
    if (this._actor && this._slotId >= 0) {
        return this._actor.equipSlots()[this._slotId];
    } else {
        return 0;
    }
};

/**
 * Check if an item is enabled
 *
 * @return {boolean} True if enabled
 */
Window_EquipItem.prototype.isEnabled = function(/*item*/) {
    return true;
};

/**
 * Selects the last item if remembered
 */
Window_EquipItem.prototype.selectLast = function() {
    //
};

/**
 * Sets the status window
 *
 * @param {Window_EquipStatus} statusWindow - The status window
 */
Window_EquipItem.prototype.setStatusWindow = function(statusWindow) {
    this._statusWindow = statusWindow;
    this.callUpdateHelp();
};

Window_EquipItem.prototype.updateHelp = function() {
    Window_ItemList.prototype.updateHelp.call(this);
    if (this._actor && this._statusWindow && this._slotId >= 0) {
        const actor = JsonEx.makeDeepCopy(this._actor);
        actor.forceChangeEquip(this._slotId, this.item());
        this._statusWindow.setTempActor(actor);
    }
};

/**
 * Processing when the OK sound should play. In Window_EquipItem, this does nothing.
 */
Window_EquipItem.prototype.playOkSound = function() {
    //
};