From e778ebb0b2419ed792a6f880095a3cff183af71d Mon Sep 17 00:00:00 2001 From: Adrian Date: Mon, 21 Oct 2024 17:04:51 -0400 Subject: [PATCH] fix tests --- src/ui/battle-message-ui-handler.ts | 12 ++++++------ src/ui/message-ui-handler.ts | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/ui/battle-message-ui-handler.ts b/src/ui/battle-message-ui-handler.ts index 3ef4c3111d3..ee970913ee3 100644 --- a/src/ui/battle-message-ui-handler.ts +++ b/src/ui/battle-message-ui-handler.ts @@ -155,16 +155,16 @@ export default class BattleMessageUiHandler extends MessageUiHandler { clearText(): void { super.clearText(); - if (this.message.getData("originalMaxLines")) { - this.message.setMaxLines(this.message.getData("originalMaxLines")); + if (this.message.data?.values?.originalMaxLines) { + this.message.setMaxLines(this.message.data?.values?.originalMaxLines); this.message.data.remove("originalMaxLines"); } - if (this.message.getData("originalMaxWidth")) { - this.message.setWordWrapWidth(this.message.getData("originalMaxWidth")); + if (this.message.data?.values?.originalMaxWidth) { + this.message.setWordWrapWidth(this.message.data?.values?.originalMaxWidth); this.message.data.remove("originalMaxWidth"); } - if (this.message.getData("originalFontSize")) { - this.message.setFontSize(this.message.getData("originalFontSize")); + if (this.message.data?.values?.originalFontSize) { + this.message.setFontSize(this.message.data?.values?.originalFontSize); this.message.data.remove("originalFontSize"); } } diff --git a/src/ui/message-ui-handler.ts b/src/ui/message-ui-handler.ts index fa17a7b1a7f..bfb5484459c 100644 --- a/src/ui/message-ui-handler.ts +++ b/src/ui/message-ui-handler.ts @@ -97,7 +97,7 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler { } } - const wasTextAdjusted = this.message.getData("originalMaxWidth") || this.message.getData("originalFontSize") || this.message.getData("originalMaxLines"); + const wasTextAdjusted = this.message.data?.values?.originalMaxWidth || this.message.data?.values?.originalFontSize || this.message.data?.values?.originalMaxLines; if (!!wasTextAdjusted) { const isWidthOverflow = (this.message.style.wordWrapWidth && this.textSize(newText).width > this.message.style.wordWrapWidth); const isHeightOverflow = (this.textHeight(newText) + (this.message.y / this.message.scale) > this.textHeight(text)); @@ -303,8 +303,8 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler { // If any style changes were made in previous tryAdjustText() calls, revert to the original data. // [Note] Be aware that if dynamic styles are being applied to the same this.message from another source for attributes such as fontSize, maxLines, wordWrap, this may cause issues. - if (this.message.getData("originalMaxLines")) { - this.message.style.setMaxLines(this.message.getData("originalMaxLines")); + if (this.message.data?.values?.originalMaxLines) { + this.message.style.setMaxLines(this.message.data?.values?.originalMaxLines); this.message.data.remove("originalMaxLines"); } @@ -312,11 +312,11 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler { const paddingY = posY / this.message.scale - this.message.lineSpacing; const maxHeight = referenceGuide.getBounds().height - (paddingY * 2); - const maxWidth = this.message.getData("originalMaxWidth") ?? Math.floor(opts?.maxWidth ?? this.message.style.wordWrapWidth ?? referenceGuide.getBounds().width) - paddingX; - this.message.setData("originalMaxWidth", this.message.getData("originalMaxWidth") ?? maxWidth); + const maxWidth = this.message.data?.values?.originalMaxWidth ?? Math.floor(opts?.maxWidth ?? this.message.style.wordWrapWidth ?? referenceGuide.getBounds().width) - paddingX; + this.message.setData("originalMaxWidth", this.message.data?.values?.originalMaxWidth ?? maxWidth); this.message.setWordWrapWidth(maxWidth); - const fontSize = this.message.getData("originalFontSize") ?? parseInt(this.message.style.fontSize.toString()); + const fontSize = this.message.data?.values?.originalFontSize ?? parseInt(this.message.style.fontSize.toString()); this.message.setData("originalFontSize", fontSize); this.message.setFontSize(fontSize); @@ -362,7 +362,7 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler { ) { this.message.setFontSize(getFontSize() - 1); - if (!this.message.getData("originalMaxLines")) { + if (!this.message.data?.values?.originalMaxLines) { this.message.setData("originalMaxLines", this.message.style.maxLines); } this.message.setMaxLines(Math.ceil(this.textHeight(text) / (this.textSize(text).lineHeight + posY + this.textWrapped(text).length)));