//=============================================================================
// Window_NameBox
//=============================================================================
Yanfly.DisableWebGLMask = false;
function Window_NameBox() {
this.initialize.apply(this, arguments);
}
Window_NameBox.prototype = Object.create(Window_Base.prototype);
Window_NameBox.prototype.constructor = Window_NameBox;
Window_NameBox.prototype.initialize = function(parentWindow) {
this._parentWindow = parentWindow;
Window_Base.prototype.initialize.call(this, 0, 0, 240, this.windowHeight());
this._text = '';
this._lastNameText = '';
this._openness = 0;
this._closeCounter = 0;
this.deactivate();
if (eval(Yanfly.Param.MSGNameBoxClear)) {
this.backOpacity = 0;
this.opacity = 0;
}
this.hide();
};
Window_NameBox.prototype.windowWidth = function() {
this.resetFontSettings();
var dw = this.textWidthEx(this._text);
dw += this.padding * 2;
var width = dw + eval(Yanfly.Param.MSGNameBoxPadding)
return Math.ceil(width);
};
Window_NameBox.prototype.textWidthEx = function(text) {
return this.drawTextEx(text, 0, this.contents.height);
};
Window_NameBox.prototype.calcNormalCharacter = function(textState) {
return this.textWidth(textState.text[textState.index++]);
};
Window_NameBox.prototype.windowHeight = function() {
return this.fittingHeight(1);
};
Window_NameBox.prototype.standardFontFace = function() {
return $gameSystem.getMessageFontName();
};
Window_NameBox.prototype.standardFontSize = function() {
return $gameSystem.getMessageFontSize();
};
Window_NameBox.prototype.update = function() {
Window_Base.prototype.update.call(this);
if (this.active) return;
if (this.isClosed()) return;
if (this.isClosing()) return;
if (this._closeCounter-- > 0) return;
if (this._parentWindow.isClosing()) {
this._openness = this._parentWindow.openness;
}
this.close();
};
Window_NameBox.prototype.refresh = function(text, position) {
this.show();
this._lastNameText = text;
this._text = Yanfly.Param.MSGNameBoxText + text;
this._position = position;
this.width = this.windowWidth();
this.createContents();
this.contents.clear();
this.resetFontSettings();
this.changeTextColor(this.textColor(Yanfly.Param.MSGNameBoxColor));
var padding = eval(Yanfly.Param.MSGNameBoxPadding) / 2;
this.drawTextEx(this._text, padding, 0, this.contents.width);
this._parentWindow.adjustWindowSettings();
this._parentWindow.updatePlacement();
this.adjustPositionX();
this.adjustPositionY();
this.open();
this.activate();
this._closeCounter = 4;
return '';
};
Window_NameBox.prototype.adjustPositionX = function() {
if (this._position === 1) {
this.x = this._parentWindow.x;
this.x += eval(Yanfly.Param.MSGNameBoxBufferX);
} else if (this._position === 2) {
this.x = this._parentWindow.x;
this.x += this._parentWindow.width * 3 / 10;
this.x -= this.width / 2;
} else if (this._position === 3) {
this.x = this._parentWindow.x;
this.x += this._parentWindow.width / 2;
this.x -= this.width / 2;
} else if (this._position === 4) {
this.x = this._parentWindow.x;
this.x += this._parentWindow.width * 7 / 10;
this.x -= this.width / 2;
} else {
this.x = this._parentWindow.x + this._parentWindow.width;
this.x -= this.width;
this.x -= eval(Yanfly.Param.MSGNameBoxBufferX);
}
this.x = this.x.clamp(0, Graphics.boxWidth - this.width);
};
Window_NameBox.prototype.adjustPositionY = function() {
if ($gameMessage.positionType() === 0) {
this.y = this._parentWindow.y + this._parentWindow.height;
this.y -= eval(Yanfly.Param.MSGNameBoxBufferY);
} else {
this.y = this._parentWindow.y;
this.y -= this.height;
this.y += eval(Yanfly.Param.MSGNameBoxBufferY);
}
if (this.y < 0) {
this.y = this._parentWindow.y + this._parentWindow.height;
this.y -= eval(Yanfly.Param.MSGNameBoxBufferY);
}
};