Align 'map display name' to center screen. (Solved)

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
Everything that affects the display of the name is here.
You can try modify all the values you want, and experiment what you like.
PHP:
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);
};
Are you looking for a plug-in, or are you looking for a way to do it from the event command list's script command?

If you want to do it from within an event on the map, you would want to use a parallel process and erase the event after it runs. Use the following script snippet:

Code:
var window = SceneManager._scene._mapNameWindow;
window.x = Graphics.width / 2 - window.width / 2;

The encumbrance that follows the method above is that you'd need at least one event on every map with that code.

If you want a plug-in instead, the easiest way is to just move it after it has been created within the scene:

Code:
Scene_Map.prototype.createMapNameWindow = function() {
   this._mapNameWindow = Window_MapName();
   this.addChild(this._mapNameWindow);
};

Create a plug-in and alias that method to the following:

Code:
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;
};
Just save this piece of code as a js file and import it as a plugin. Should center the map name display (assuming you have no other plugins that affect the map name display).

Code:
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();
};
Everything that affects the display of the name is here.
You can try modify all the values you want, and experiment what you like.

Perfect, thank you!

Original thread: https://forums.rpgmakerweb.com/threads/align-map-display-name-to-center-screen-solved.81858/