Fix window.js

This commit is contained in:
dazedanon 2025-05-30 08:39:51 -05:00
parent c9fa8d1b10
commit 99f45ee0ed

View file

@ -28,114 +28,10 @@ Window_Base.prototype.initialize = function(rect) {
this._dimmerSprite = null;
};
Window_Base.prototype.destroy = function (options) {
this.destroyContents();
if (this._dimmerSprite) {
this._dimmerSprite.bitmap.destroy();
}
Window.prototype.destroy.call(this, options);
};
Window_Base.prototype.checkRectObject = function (rect) {
if (typeof rect !== "object" || !("x" in rect)) {
// Probably MV plugin is used
throw new Error("Argument must be a Rectangle");
}
};
Window_Base.prototype.lineHeight = function () {
return 36;
};
Window_Base.prototype.itemWidth = function () {
return this.innerWidth;
};
Window_Base.prototype.itemHeight = function () {
return this.lineHeight();
};
Window_Base.prototype.itemPadding = function () {
return 8;
};
Window_Base.prototype.baseTextRect = function () {
const rect = new Rectangle(0, 0, this.innerWidth, this.innerHeight);
rect.pad(-this.itemPadding(), 0);
return rect;
};
Window_Base.prototype.loadWindowskin = function () {
this.windowskin = ImageManager.loadSystem("Window");
};
Window_Base.prototype.updatePadding = function () {
this.padding = $gameSystem.windowPadding();
};
Window_Base.prototype.updateBackOpacity = function () {
this.backOpacity = $gameSystem.windowOpacity();
};
Window_Base.prototype.fittingHeight = function (numLines) {
return numLines * this.itemHeight() + $gameSystem.windowPadding() * 2;
};
Window_Base.prototype.updateTone = function () {
const tone = $gameSystem.windowTone();
this.setTone(tone[0], tone[1], tone[2]);
};
Window_Base.prototype.createContents = function () {
const width = this.contentsWidth();
const height = this.contentsHeight();
this.destroyContents();
this.contents = new Bitmap(width, height);
this.contentsBack = new Bitmap(width, height);
this.resetFontSettings();
};
Window_Base.prototype.destroyContents = function () {
if (this.contents) {
this.contents.destroy();
}
if (this.contentsBack) {
this.contentsBack.destroy();
}
};
Window_Base.prototype.contentsWidth = function () {
return this.innerWidth;
};
Window_Base.prototype.contentsHeight = function () {
return this.innerHeight;
};
Window_Base.prototype.resetFontSettings = function () {
this.contents.fontFace = $gameSystem.mainFontFace();
this.contents.fontSize = $gameSystem.mainFontSize() - 4;
this.resetTextColor();
};
Window_Base.prototype.resetTextColor = function () {
this.changeTextColor(ColorManager.normalColor());
this.changeOutlineColor(ColorManager.outlineColor());
};
Window_Base.prototype.update = function () {
Window.prototype.update.call(this);
this.updateTone();
this.updateOpen();
this.updateClose();
this.updateBackgroundDimmer();
};
Window_Base.prototype.updateOpen = function () {
if (this._opening) {
this.openness += 32;
if (this.isOpen()) {
this._opening = false;
Window_Base.prototype.destroy = function(options) {
this.destroyContents();
if (this._dimmerSprite) {
this._dimmerSprite.bitmap.destroy();
}
Window.prototype.destroy.call(this, options);
};
@ -218,7 +114,7 @@ Window_Base.prototype.contentsHeight = function() {
Window_Base.prototype.resetFontSettings = function() {
this.contents.fontFace = $gameSystem.mainFontFace();
this.contents.fontSize = $gameSystem.mainFontSize();
this.contents.fontSize = $gameSystem.mainFontSize() - 4;
this.resetTextColor();
};
@ -235,28 +131,13 @@ Window_Base.prototype.update = function() {
this.updateBackgroundDimmer();
};
Window_Base.prototype.drawTextExHelp = function (text, x, y, width) {
this.resetFontSettings();
this.contents.fontSize = 24;
const textState = this.createTextState(text, x, y, width);
this.processAllText(textState);
return textState.outputWidth;
};
Window_Base.prototype.drawTextExSkillTree = function (text, x, y, width) {
this.resetFontSettings();
this.contents.fontSize = 18;
const textState = this.createTextState(text, x, y, width);
this.processAllText(textState);
return textState.outputWidth;
};
Window_Base.prototype.textSizeEx = function (text) {
this.resetFontSettings();
const textState = this.createTextState(text, 0, 0, 0);
textState.drawing = false;
this.processAllText(textState);
return { width: textState.outputWidth, height: textState.outputHeight };
Window_Base.prototype.updateOpen = function() {
if (this._opening) {
this.openness += 32;
if (this.isOpen()) {
this._opening = false;
}
}
};
Window_Base.prototype.updateClose = function() {
@ -348,12 +229,28 @@ Window_Base.prototype.drawTextEx = function(text, x, y, width) {
return textState.outputWidth;
};
Window_Base.prototype.textSizeEx = function(text) {
this.resetFontSettings();
const textState = this.createTextState(text, 0, 0, 0);
textState.drawing = false;
this.processAllText(textState);
return { width: textState.outputWidth, height: textState.outputHeight };
Window_Base.prototype.drawTextExHelp = function (text, x, y, width) {
this.resetFontSettings();
this.contents.fontSize = 24;
const textState = this.createTextState(text, x, y, width);
this.processAllText(textState);
return textState.outputWidth;
};
Window_Base.prototype.drawTextExSkillTree = function (text, x, y, width) {
this.resetFontSettings();
this.contents.fontSize = 18;
const textState = this.createTextState(text, x, y, width);
this.processAllText(textState);
return textState.outputWidth;
};
Window_Base.prototype.textSizeEx = function (text) {
this.resetFontSettings();
const textState = this.createTextState(text, 0, 0, 0);
textState.drawing = false;
this.processAllText(textState);
return { width: textState.outputWidth, height: textState.outputHeight };
};
Window_Base.prototype.createTextState = function(text, x, y, width) {