From 6c5079b09787f6598c987cd6789a6ac947881098 Mon Sep 17 00:00:00 2001 From: Brandon Bay Date: Wed, 4 Sep 2024 14:48:54 -0400 Subject: [PATCH] Increase tooltip size, reverse y when necessary, and always show passive tooltip --- src/ui/starter-select-ui-handler.ts | 2 +- src/ui/ui.ts | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 2af8ac1e33d..4b470012c6c 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -3134,7 +3134,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.pokemonPassiveText.setAlpha(textAlpha); this.pokemonPassiveText.setShadowColor(this.getTextColor(textStyle, true)); - if (this.pokemonPassiveText.visible && isUnlocked && isEnabled) { + if (this.pokemonPassiveText.visible) { this.pokemonPassiveText.on("pointerover", () => this.scene.ui.showTooltip("", `${passiveAbility.description}`, true)); this.pokemonPassiveText.on("pointerout", () => this.scene.ui.hideTooltip()); } diff --git a/src/ui/ui.ts b/src/ui/ui.ts index 54e2baeffec..8e29377e47f 100644 --- a/src/ui/ui.ts +++ b/src/ui/ui.ts @@ -241,7 +241,7 @@ export default class UI extends Phaser.GameObjects.Container { this.tooltipContent = addTextObject(this.scene, 6, 16, "", TextStyle.TOOLTIP_CONTENT); this.tooltipContent.setName("text-tooltip-content"); - this.tooltipContent.setWordWrapWidth(696); + this.tooltipContent.setWordWrapWidth(850); this.tooltipContainer.add(this.tooltipBg); this.tooltipContainer.add(this.tooltipTitle); @@ -378,7 +378,7 @@ export default class UI extends Phaser.GameObjects.Container { const wrappedContent = this.tooltipContent.runWordWrap(content); this.tooltipContent.setText(wrappedContent); this.tooltipContent.y = title ? 16 : 4; - this.tooltipBg.width = Math.min(Math.max(this.tooltipTitle.displayWidth, this.tooltipContent.displayWidth) + 12, 684); + this.tooltipBg.width = Math.min(Math.max(this.tooltipTitle.displayWidth, this.tooltipContent.displayWidth) + 12, 838); this.tooltipBg.height = (title ? 31 : 19) + 10.5 * (wrappedContent.split("\n").length - 1); } @@ -389,8 +389,12 @@ export default class UI extends Phaser.GameObjects.Container { update(): void { if (this.tooltipContainer.visible) { - const reverse = this.scene.game.input.mousePointer && this.scene.game.input.mousePointer.x >= this.scene.game.canvas.width - this.tooltipBg.width * 6 - 12; - this.tooltipContainer.setPosition(!reverse ? this.scene.game.input.mousePointer!.x / 6 + 2 : this.scene.game.input.mousePointer!.x / 6 - this.tooltipBg.width - 2, this.scene.game.input.mousePointer!.y / 6 + 2); // TODO: are these bangs correct? + const xReverse = this.scene.game.input.mousePointer && this.scene.game.input.mousePointer.x >= this.scene.game.canvas.width - this.tooltipBg.width * 6 - 12; + const yReverse = this.scene.game.input.mousePointer && this.scene.game.input.mousePointer.y >= this.scene.game.canvas.height - this.tooltipBg.height * 6 - 12; + this.tooltipContainer.setPosition( + !xReverse ? this.scene.game.input.mousePointer!.x / 6 + 2 : this.scene.game.input.mousePointer!.x / 6 - this.tooltipBg.width - 2, + !yReverse ? this.scene.game.input.mousePointer!.y / 6 + 2 : this.scene.game.input.mousePointer!.y / 6 - this.tooltipBg.height - 2, + ); } }