/*:
@author cfw
@plugindesc 切换地图时,居中显示地图名称
@help
切换地图时,在屏幕中央使用窗口显示当前地图名称。
默认显示150帧。
但是不会劫持用户操作,在显示窗口的时候可以乱跑,所以需要优化。
@param conTime
@desc 控制地图名窗口显示时间,默认150
@default 150
*/
//获取变量
Window_NewMapName.params = PluginManager.parameters('NewMapName');
Window_NewMapName.conTime = +Window_NewMapName.params['conTime']
//定义函数
function Window_NewMapName() {
this.initialize.apply(this, arguments);
}
Window_NewMapName.prototype = Object.create(Window_Base.prototype);
Window_NewMapName.prototype.constructor = Window_NewMapName;
Window_NewMapName.prototype.initialize = function () {
var wight = this.windowWidth();
var height = this.windowHeight();
var x = this.windowX();
var y = this.windowY();
Window_Base.prototype.initialize.call(this, x, y, wight, height);
this.opacity = 0;
this.contentsOpacity = 0;
this._showCount = 0;
this.refresh();
};
Window_NewMapName.prototype.windowX = function () {
var width = this.windowWidth();
x = (816 - width) / 2
return x;
}
Window_NewMapName.prototype.windowY = function () {
var height = this.windowHeight();
y = (624 - height) / 2
return y;
}
Window_NewMapName.prototype.windowWidth = function () {
return 360;
};
Window_NewMapName.prototype.windowHeight = function () {
return this.fittingHeight(1);
};
Window_NewMapName.prototype.update = function () {
Window_Base.prototype.update.call(this);
if (this._showCount > 0 && $gameMap.isNameDisplayEnabled()) {
this.updateFadeIn();
this._showCount--;
} else {
this.updateFadeOut();
}
};
Window_NewMapName.prototype.updateFadeIn = function () {
this.contentsOpacity += 16;
this.opacity += 16;
};
Window_NewMapName.prototype.updateFadeOut = function () {
this.contentsOpacity -= 16;
this.opacity -= 16;
};
Window_NewMapName.prototype.open = function () {
this.refresh();
this._showCount = Window_NewMapName.conTime;
};
Window_NewMapName.prototype.close = function () {
this._showCount = 0;
};
Window_NewMapName.prototype.refresh = function () {
this.contents.clear();
if ($gameMap.displayName()) {
var width = this.contentsWidth();
this.drawText($gameMap.displayName(), 0, 0, width, 'center');
}
};
//对rpg_scenes.js中Scene_Map进行修改,启用cfw_MapName
Scene_Map.prototype.createDisplayObjects = function () {
this.createSpriteset();
this.createNewMapNameWindow();
this.createWindowLayer();
this.createAllWindows();
};
Scene_Map.prototype.createNewMapNameWindow = function () {
this._mapNameWindow = new Window_NewMapName();
this.addChild(this._mapNameWindow);
};