//-----------------------------------------------------------------------------
// Scene_Title
//
// The scene class of the title screen.
/**
* The scene class of the title screen.
*
* @class
* @extends Scene_Base
*/
function Scene_Title() {
this.initialize(...arguments);
}
Scene_Title.prototype = Object.create(Scene_Base.prototype);
Scene_Title.prototype.constructor = Scene_Title;
Scene_Title.prototype.initialize = function() {
Scene_Base.prototype.initialize.call(this);
};
Scene_Title.prototype.create = function() {
Scene_Base.prototype.create.call(this);
this.createBackground();
this.createForeground();
this.createWindowLayer();
this.createCommandWindow();
};
Scene_Title.prototype.start = function() {
Scene_Base.prototype.start.call(this);
SceneManager.clearStack();
this.adjustBackground();
this.playTitleMusic();
this.startFadeIn(this.fadeSpeed(), false);
};
Scene_Title.prototype.update = function() {
if (!this.isBusy()) {
this._commandWindow.open();
}
Scene_Base.prototype.update.call(this);
};
Scene_Title.prototype.isBusy = function() {
return (
this._commandWindow.isClosing() ||
Scene_Base.prototype.isBusy.call(this)
);
};
Scene_Title.prototype.terminate = function() {
Scene_Base.prototype.terminate.call(this);
SceneManager.snapForBackground();
if (this._gameTitleSprite) {
this._gameTitleSprite.bitmap.destroy();
}
};
/**
* Creates the scene's background
*/
Scene_Title.prototype.createBackground = function() {
this._backSprite1 = new Sprite(
ImageManager.loadTitle1($dataSystem.title1Name)
);
this._backSprite2 = new Sprite(
ImageManager.loadTitle2($dataSystem.title2Name)
);
this.addChild(this._backSprite1);
this.addChild(this._backSprite2);
};
/**
* Creates the scene's foreground
*/
Scene_Title.prototype.createForeground = function() {
this._gameTitleSprite = new Sprite(
new Bitmap(Graphics.width, Graphics.height)
);
this.addChild(this._gameTitleSprite);
if ($dataSystem.optDrawTitle) {
this.drawGameTitle();
}
};
/**
* Draws the game's title
*/
Scene_Title.prototype.drawGameTitle = function() {
const x = 20;
const y = Graphics.height / 4;
const maxWidth = Graphics.width - x * 2;
const text = $dataSystem.gameTitle;
const bitmap = this._gameTitleSprite.bitmap;
bitmap.fontFace = $gameSystem.mainFontFace();
bitmap.outlineColor = "black";
bitmap.outlineWidth = 8;
bitmap.fontSize = 72;
bitmap.drawText(text, x, y, maxWidth, 48, "center");
};
/**
* Adjusts the game's background images by fitting them to screen and centering them
*/
Scene_Title.prototype.adjustBackground = function() {
this.scaleSprite(this._backSprite1);
this.scaleSprite(this._backSprite2);
this.centerSprite(this._backSprite1);
this.centerSprite(this._backSprite2);
};
/**
* Creates the title command window
*/
Scene_Title.prototype.createCommandWindow = function() {
const background = $dataSystem.titleCommandWindow.background;
const rect = this.commandWindowRect();
this._commandWindow = new Window_TitleCommand(rect);
this._commandWindow.setBackgroundType(background);
this._commandWindow.setHandler("newGame", this.commandNewGame.bind(this));
this._commandWindow.setHandler("continue", this.commandContinue.bind(this));
this._commandWindow.setHandler("options", this.commandOptions.bind(this));
this.addWindow(this._commandWindow);
};
/**
* The rectangle object for the x/y/width/height of the command window
*
* @return {Rectangle} The rectangle that represents the command window
*/
Scene_Title.prototype.commandWindowRect = function() {
const offsetX = $dataSystem.titleCommandWindow.offsetX;
const offsetY = $dataSystem.titleCommandWindow.offsetY;
const ww = this.mainCommandWidth();
const wh = this.calcWindowHeight(3, true);
const wx = (Graphics.boxWidth - ww) / 2 + offsetX;
const wy = Graphics.boxHeight - wh - 96 + offsetY;
return new Rectangle(wx, wy, ww, wh);
};
/**
* Processing when the new game command is chosen
*/
Scene_Title.prototype.commandNewGame = function() {
DataManager.setupNewGame();
this._commandWindow.close();
this.fadeOutAll();
SceneManager.goto(Scene_Map);
};
/**
* Processing when the continue command is chosen
*/
Scene_Title.prototype.commandContinue = function() {
this._commandWindow.close();
SceneManager.push(Scene_Load);
};
/**
* Processing when the options command is chosen
*/
Scene_Title.prototype.commandOptions = function() {
this._commandWindow.close();
SceneManager.push(Scene_Options);
};
/**
* Plays the title screen music
*/
Scene_Title.prototype.playTitleMusic = function() {
AudioManager.playBgm($dataSystem.titleBgm);
AudioManager.stopBgs();
AudioManager.stopMe();
};