Source: Scene_Status.js

Scene_Status.js

//-----------------------------------------------------------------------------
// Scene_Status
//
// The scene class of the status screen.
/**
 * The scene class of the status screen.
 *
 * @class
 * @extends Scene_MenuBase
 */
function Scene_Status() {
    this.initialize(...arguments);
}

Scene_Status.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Status.prototype.constructor = Scene_Status;

Scene_Status.prototype.initialize = function() {
    Scene_MenuBase.prototype.initialize.call(this);
};

Scene_Status.prototype.create = function() {
    Scene_MenuBase.prototype.create.call(this);
    this.createProfileWindow();
    this.createStatusWindow();
    this.createStatusParamsWindow();
    this.createStatusEquipWindow();
};

/**
 * Get the height of the help area
 *
 * @return {number} The height of the help area
 * @override
 */
Scene_Status.prototype.helpAreaHeight = function() {
    return 0;
};

/**
 * Create the profile window
 */
Scene_Status.prototype.createProfileWindow = function() {
    const rect = this.profileWindowRect();
    this._profileWindow = new Window_Help(rect);
    this.addWindow(this._profileWindow);
};

/**
 * Get the rectangle representing the profile window's x/y/width/height
 *
 * @return {Rectangle} A rectangle representing the profile window
 */
Scene_Status.prototype.profileWindowRect = function() {
    const ww = Graphics.boxWidth;
    const wh = this.profileHeight();
    const wx = 0;
    const wy = this.mainAreaBottom() - wh;
    return new Rectangle(wx, wy, ww, wh);
};

/**
 * Create the status window
 */
Scene_Status.prototype.createStatusWindow = function() {
    const rect = this.statusWindowRect();
    this._statusWindow = new Window_Status(rect);
    this._statusWindow.setHandler("cancel", this.popScene.bind(this));
    this._statusWindow.setHandler("pagedown", this.nextActor.bind(this));
    this._statusWindow.setHandler("pageup", this.previousActor.bind(this));
    this.addWindow(this._statusWindow);
};

/**
 * Get a rectangle representing the status window's x/y/width/height
 *
 * @return {Rectangle} A rectangle representing the status window
 */
Scene_Status.prototype.statusWindowRect = function() {
    const wx = 0;
    const wy = this.mainAreaTop();
    const ww = Graphics.boxWidth;
    const wh = this.statusParamsWindowRect().y - wy;
    return new Rectangle(wx, wy, ww, wh);
};

/**
 * Creates the status params window
 */
Scene_Status.prototype.createStatusParamsWindow = function() {
    const rect = this.statusParamsWindowRect();
    this._statusParamsWindow = new Window_StatusParams(rect);
    this.addWindow(this._statusParamsWindow);
};

/**
 * Get a rectangle representing the status param window's x/y/width/height
 *
 * @return {Rectangle} A rectangle representing the status param window
 */
Scene_Status.prototype.statusParamsWindowRect = function() {
    const ww = this.statusParamsWidth();
    const wh = this.statusParamsHeight();
    const wx = 0;
    const wy = this.mainAreaBottom() - this.profileHeight() - wh;
    return new Rectangle(wx, wy, ww, wh);
};

/**
 * Creates the status equip window
 */
Scene_Status.prototype.createStatusEquipWindow = function() {
    const rect = this.statusEquipWindowRect();
    this._statusEquipWindow = new Window_StatusEquip(rect);
    this.addWindow(this._statusEquipWindow);
};

/**
 * Get a rectangle representing the status equip window's x/y/width/height
 *
 * @return {Rectangle} A rectangle representing the status equip window
 */
Scene_Status.prototype.statusEquipWindowRect = function() {
    const ww = Graphics.boxWidth - this.statusParamsWidth();
    const wh = this.statusParamsHeight();
    const wx = this.statusParamsWidth();
    const wy = this.mainAreaBottom() - this.profileHeight() - wh;
    return new Rectangle(wx, wy, ww, wh);
};

/**
 * Get the width of the status param window
 *
 * @return {number} The width of the status params window
 */
Scene_Status.prototype.statusParamsWidth = function() {
    return 300;
};

/**
 * Get the height of the status param window
 *
 * @return {number} The height of the status params window
 */
Scene_Status.prototype.statusParamsHeight = function() {
    return this.calcWindowHeight(6, false);
};

/**
 * Get the height of the profile window
 *
 * @return {number} The height of the profile window
 */
Scene_Status.prototype.profileHeight = function() {
    return this.calcWindowHeight(2, false);
};

Scene_Status.prototype.start = function() {
    Scene_MenuBase.prototype.start.call(this);
    this.refreshActor();
};

/**
 * Check if the scene should create the page buttons
 *
 * @return {boolean} If the status scene needs page buttons
 * @override
 */
Scene_Status.prototype.needsPageButtons = function() {
    return true;
};

/**
 * Refresh the scene's windows for the actor
 */
Scene_Status.prototype.refreshActor = function() {
    const actor = this.actor();
    this._profileWindow.setText(actor.profile());
    this._statusWindow.setActor(actor);
    this._statusParamsWindow.setActor(actor);
    this._statusEquipWindow.setActor(actor);
};

Scene_Status.prototype.onActorChange = function() {
    Scene_MenuBase.prototype.onActorChange.call(this);
    this.refreshActor();
    this._statusWindow.activate();
};