Is there a simple piece of code that will allow me to align the map display name to the center screen instead of to the default left?
Thanks in advance,
Beth
Thanks in advance,
Beth
function Window_MapName() {
this.initialize.apply(this, arguments);
}
Window_MapName.prototype = Object.create(Window_Base.prototype);
Window_MapName.prototype.constructor = Window_MapName;
Window_MapName.prototype.initialize = function() {
var wight = this.windowWidth();
var height = this.windowHeight();
Window_Base.prototype.initialize.call(this, 0, 0, wight, height);
this.opacity = 0;
this.contentsOpacity = 0;
this._showCount = 0;
this.refresh();
};
Window_MapName.prototype.windowWidth = function() {
return 360;
};
Window_MapName.prototype.windowHeight = function() {
return this.fittingHeight(1);
};
Window_MapName.prototype.update = function() {
Window_Base.prototype.update.call(this);
if (this._showCount > 0 && $gameMap.isNameDisplayEnabled()) {
this.updateFadeIn();
this._showCount--;
} else {
this.updateFadeOut();
}
};
Window_MapName.prototype.updateFadeIn = function() {
this.contentsOpacity += 16;
};
Window_MapName.prototype.updateFadeOut = function() {
this.contentsOpacity -= 16;
};
Window_MapName.prototype.open = function() {
this.refresh();
this._showCount = 150;
};
Window_MapName.prototype.close = function() {
this._showCount = 0;
};
Window_MapName.prototype.refresh = function() {
this.contents.clear();
if ($gameMap.displayName()) {
var width = this.contentsWidth();
this.drawBackground(0, 0, width, this.lineHeight());
this.drawText($gameMap.displayName(), 0, 0, width, 'center');
}
};
Window_MapName.prototype.drawBackground = function(x, y, width, height) {
var color1 = this.dimColor1();
var color2 = this.dimColor2();
this.contents.gradientFillRect(x, y, width / 2, height, color2, color1);
this.contents.gradientFillRect(x + width / 2, y, width / 2, height, color1, color2);
};
var window = SceneManager._scene._mapNameWindow;
window.x = Graphics.width / 2 - window.width / 2;
Scene_Map.prototype.createMapNameWindow = function() {
this._mapNameWindow = Window_MapName();
this.addChild(this._mapNameWindow);
};
var _Scene_Map_createMapNameWindow = Scene_Map.prototype.createMapNameWindow;
Scene_Map.prototype.createMapNameWindow = function() {
_Scene_Map_createMapNameWindow.call(this);
this.x = Graphics.width / 2 - this.width / 2;
};
Window_MapName.prototype.initialize = function() {
var wight = this.windowWidth();
var height = this.windowHeight();
var x = (Graphics.boxWidth - wight) / 2;
Window_Base.prototype.initialize.call(this, x, 0, wight, height);
this.opacity = 0;
this.contentsOpacity = 0;
this._showCount = 0;
this.refresh();
};
Original thread: https://forums.rpgmakerweb.com/threads/align-map-display-name-to-center-screen-solved.81858/