Source: Window_MenuStatus.js

Window_MenuStatus.js

//-----------------------------------------------------------------------------
// Window_MenuStatus
//
// The window for displaying party member status on the menu screen.
/**
 * The window for displaying party member status on the menu screen.
 *
 * @class
 * @extends Window_StatusBase
 */
function Window_MenuStatus() {
    this.initialize(...arguments);
}

Window_MenuStatus.prototype = Object.create(Window_StatusBase.prototype);
Window_MenuStatus.prototype.constructor = Window_MenuStatus;

Window_MenuStatus.prototype.initialize = function(rect) {
    Window_StatusBase.prototype.initialize.call(this, rect);
    this._formationMode = false;
    this._pendingIndex = -1;
    this.refresh();
};

/**
 * Get the maximum amount of items in the window
 *
 * @return {number} The maximum amount of items in the window
 */
Window_MenuStatus.prototype.maxItems = function() {
    return $gameParty.size();
};

/**
 * Get how many rows should be visible at one time
 *
 * @return {number} The amount of rows visible at one time
 */
Window_MenuStatus.prototype.numVisibleRows = function() {
    return 4;
};

/**
 * Get the height of an item
 *
 * @return {number} The height of an item
 */
Window_MenuStatus.prototype.itemHeight = function() {
    return Math.floor(this.innerHeight / this.numVisibleRows());
};

/**
 * Get an actor at a given index
 *
 * @param {number} index - The index of the actor
 * @return {Game_Actor} The game actor object
 */
Window_MenuStatus.prototype.actor = function(index) {
    return $gameParty.members()[index];
};

/**
 * Draw the item at the given index
 *
 * @param {number} index - The index to draw
 */
Window_MenuStatus.prototype.drawItem = function(index) {
    this.drawPendingItemBackground(index);
    this.drawItemImage(index);
    this.drawItemStatus(index);
};

/**
 * Draw a pending item background at the given index
 *
 * @param {number} index - The index to draw
 */
Window_MenuStatus.prototype.drawPendingItemBackground = function(index) {
    if (index === this._pendingIndex) {
        const rect = this.itemRect(index);
        const color = ColorManager.pendingColor();
        this.changePaintOpacity(false);
        this.contents.fillRect(rect.x, rect.y, rect.width, rect.height, color);
        this.changePaintOpacity(true);
    }
};

/**
 * Draw an item image at the given index
 *
 * @param {number} index - The index to draw
 */
Window_MenuStatus.prototype.drawItemImage = function(index) {
    const actor = this.actor(index);
    const rect = this.itemRect(index);
    const width = ImageManager.standardFaceWidth;
    const height = rect.height - 2;
    this.changePaintOpacity(actor.isBattleMember());
    this.drawActorFace(actor, rect.x + 1, rect.y + 1, width, height);
    this.changePaintOpacity(true);
};

/**
 * Draw the item status at the given index
 *
 * @param {number} index - The index to draw
 */
Window_MenuStatus.prototype.drawItemStatus = function(index) {
    const actor = this.actor(index);
    const rect = this.itemRect(index);
    const x = rect.x + 180;
    const y = rect.y + Math.floor(rect.height / 2 - this.lineHeight() * 1.5);
    this.drawActorSimpleStatus(actor, x, y);
};

Window_MenuStatus.prototype.processOk = function() {
    Window_StatusBase.prototype.processOk.call(this);
    const actor = this.actor(this.index());
    $gameParty.setMenuActor(actor);
};

/**
 * Check if the current item is enabled
 *
 * @return {boolean} True if the item is enabled
 */
Window_MenuStatus.prototype.isCurrentItemEnabled = function() {
    if (this._formationMode) {
        const actor = this.actor(this.index());
        return actor && actor.isFormationChangeOk();
    } else {
        return true;
    }
};

/**
 * Select the last actor, if remembered
 */
Window_MenuStatus.prototype.selectLast = function() {
    this.smoothSelect($gameParty.menuActor().index() || 0);
};

/**
 * Check if the window is in formation mode
 *
 * @return {boolean} True if the window is in formation mode
 */
Window_MenuStatus.prototype.formationMode = function() {
    return this._formationMode;
};

/**
 * Sets the formation mode of the window
 *
 * @param {boolean} formationMode - If the window should be in formation mode or not
 */
Window_MenuStatus.prototype.setFormationMode = function(formationMode) {
    this._formationMode = formationMode;
};

/**
 * Get the pending index of the window
 *
 * @return {number} The pending index of the window
 */
Window_MenuStatus.prototype.pendingIndex = function() {
    return this._pendingIndex;
};

/**
 * Sets the pending index of the window
 *
 * @param {number} index - The new pending index
 */
Window_MenuStatus.prototype.setPendingIndex = function(index) {
    const lastPendingIndex = this._pendingIndex;
    this._pendingIndex = index;
    this.redrawItem(this._pendingIndex);
    this.redrawItem(lastPendingIndex);
};