one-winged-sinope/js/plugins/MapNameFontSize.js

39 lines
1.3 KiB
JavaScript

/*:
* @plugindesc Shrinks the map display name font size and widens the window for longer translated names.
* @author DazedTranslations
*
* @param FontSize
* @desc Font size for the map name display.
* @default 20
* @type number
*
* @param WindowWidth
* @desc Width of the map name window.
* @default 560
* @type number
*/
(() => {
const params = PluginManager.parameters('MapNameFontSize');
const fontSize = Number(params['FontSize'] || 20);
const windowWidth = Number(params['WindowWidth'] || 560);
const _Scene_Map_mapNameWindowRect = Scene_Map.prototype.mapNameWindowRect;
Scene_Map.prototype.mapNameWindowRect = function() {
const rect = _Scene_Map_mapNameWindowRect.call(this);
rect.width = windowWidth;
return rect;
};
const _Window_MapName_refresh = Window_MapName.prototype.refresh;
Window_MapName.prototype.refresh = function() {
this.contents.clear();
if ($gameMap.displayName()) {
this.contents.fontSize = fontSize;
const width = this.innerWidth;
this.drawBackground(0, 0, width, this.lineHeight());
this.drawText($gameMap.displayName(), 0, 0, width, "center");
this.resetFontSettings();
}
};
})();