/*:
* @plugindesc v0.1 Allows for linebreaks in event labels.
* @author Patrick Tietz <ptietz.official[at]gmail.com>
*
* @help
*
* ######################################
* # General Instructions #
* ######################################
*
* Thank you for using EventMiniLabel_Ext.
*
* This Plugin extends YEP_EventMiniLabel
* by adding support for YEP_MessageCore's
* <br>-Tags.
*
* So, make sure to load this plugin
* AFTER YEP_EventMiniLabel.
*
* The plugin does not add any plugin commands.
*
* Credits for the YEP-Plugins go to
* the original auther Yanfly Engine Plugins.
*
* Have fun making games! :)
*
*
* ######################################
* # Terms of use #
* ######################################
*
* You may freely use, copy and modify this script
* in any commercial or non-commercial game.
*
* Re-distribution of the source code as is, is prohibited.
* You may link to the source, you got it from, though.
* The distribution of your modified code is allowed,
* as long as the original author is kept visible.
*
* Crediting the author in the game, however,
* is not required, although much appreciated.
*
* Screenshots packed with this plugin are for
* demonstrational purpose only.
* Credits for the original software
* "RPG Maker MV" go to
* Copyright (c) 2015 KADOKAWA CORPORATION / YOJI OJIMA
*
* *** PLEASE DO MAKE SURE TO MEET YANFLY'S
* TERMS OF USE AS WELL.
*
*/
Window_EventMiniLabel.prototype.windowHeight = function(nl=1) {
var height = this.fittingHeight(nl)
height = Math.max(height, 36 + this.standardPadding() * 2);
return height;
};
Window_EventMiniLabel.prototype.refresh = function() {
if (Imported.YEP_SelfSwVar) {
$gameTemp.setSelfSwVarEvent(this._character._mapId, this._character._eventId);
}
this.contents.clear();
var txtArr = this._text.split( "<br>" );
var maxTxWidth = 0;
var txWidths = [];
for ( var i = 0; i < txtArr.length; i++ )
{
var txWidth = this.textWidthEx(txtArr[i]);
txWidths[i] = txWidth;
maxTxWidth = maxTxWidth > txWidth ? maxTxWidth : txWidth;
}
maxTxWidth += this.textPadding() * 2;
var width = maxTxWidth;
this.width = Math.max(width, Yanfly.Param.EMWMinWidth);
this.width += this.standardPadding() * 2;
this.height = this.windowHeight( txtArr.length );
this.createContents();
for ( var i = 0; i < txtArr.length; i++ )
{
var tw = txWidths[i] + (this.textPadding() * 2);
var wx = (this.contents.width - tw) / 2;
console.log(wx);
var wy = i * this.standardFontSize();
this.drawTextEx(txtArr[i], wx + this.textPadding(), wy);
}
if (Imported.YEP_SelfSwVar) $gameTemp.clearSelfSwVarEvent();
};