From f5f98ec5377e836e6ed972e60715f0302baf8074 Mon Sep 17 00:00:00 2001 From: prime <10091050+prime-dialga@users.noreply.github.com> Date: Fri, 7 Jun 2024 22:45:49 +0200 Subject: [PATCH] [Bug] fixed wrong stacking of move info overlay issues (#1888) * fixed wrongly stacking overlay issues - starter selection - IVs are now behind the overlay - the overlay should clear when exiting it via controller (requires tests as i don't have a controller) - TM - will prevent C/Shift from showing the overlay until the next item selection, when selecting a TM as item reward. - will prevent C/Shift from showing the overlay when canceling item selection * removed reference to previously deleted resource * fixed override --- src/loading-scene.ts | 1 - src/ui/modifier-select-ui-handler.ts | 11 +++++++++++ src/ui/starter-select-ui-handler.ts | 20 +++++++++++--------- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/loading-scene.ts b/src/loading-scene.ts index 522962d5829..5713bf69fde 100644 --- a/src/loading-scene.ts +++ b/src/loading-scene.ts @@ -135,7 +135,6 @@ export class LoadingScene extends SceneBase { this.loadImage("summary_stats_overlay_exp", "ui"); this.loadImage("summary_moves", "ui"); this.loadImage("summary_moves_effect", "ui"); - this.loadImage("summary_moves_effect_type", "ui"); this.loadImage("summary_moves_overlay_row", "ui"); this.loadImage("summary_moves_overlay_pp", "ui"); this.loadAtlas("summary_moves_cursor", "ui"); diff --git a/src/ui/modifier-select-ui-handler.ts b/src/ui/modifier-select-ui-handler.ts index f6738a33d98..61941c28b2c 100644 --- a/src/ui/modifier-select-ui-handler.ts +++ b/src/ui/modifier-select-ui-handler.ts @@ -20,6 +20,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { private rerollCostText: Phaser.GameObjects.Text; private lockRarityButtonText: Phaser.GameObjects.Text; private moveInfoOverlay : MoveInfoOverlay; + private moveInfoOverlayActive : boolean = false; private rowCursor: integer = 0; private player: boolean; @@ -99,6 +100,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { this.awaitingActionInput = true; this.onActionInput = args[2]; } + this.moveInfoOverlay.active = this.moveInfoOverlayActive; return false; } @@ -242,6 +244,10 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { if (!originalOnActionInput(this.rowCursor, this.cursor)) { this.awaitingActionInput = true; this.onActionInput = originalOnActionInput; + } else { + this.moveInfoOverlayActive = this.moveInfoOverlay.active; + this.moveInfoOverlay.setVisible(false); + this.moveInfoOverlay.active = false; // this is likely unnecessary, but it should help future prove the UI } } } else if (button === Button.CANCEL) { @@ -252,6 +258,9 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { this.awaitingActionInput = false; this.onActionInput = null; originalOnActionInput(-1); + this.moveInfoOverlayActive = this.moveInfoOverlay.active; + this.moveInfoOverlay.setVisible(false); + this.moveInfoOverlay.active = false; // don't clear here as we might need to restore the UI in case the user cancels the action } } } else { @@ -403,6 +412,8 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { clear() { super.clear(); + this.moveInfoOverlay.clear(); + this.moveInfoOverlayActive = false; this.awaitingActionInput = false; this.onActionInput = null; this.getUi().clearText(); diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 1dbb60915ca..29926568d80 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -663,15 +663,6 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.message.setOrigin(0, 0); this.starterSelectMessageBoxContainer.add(this.message); - const overlayScale = 1; // scale for the move info. "2/3" might be another good option... - this.moveInfoOverlay = new MoveInfoOverlay(this.scene, { - scale: overlayScale, - top: true, - x: 1, - y: this.scene.game.canvas.height / 6 - MoveInfoOverlay.getHeight(overlayScale) - 29, - }); - this.starterSelectContainer.add(this.moveInfoOverlay); - const date = new Date(); date.setUTCHours(0, 0, 0, 0); @@ -716,12 +707,23 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.starterSelectContainer.add(this.statsContainer); + // add the info overlay last to be the top most ui element and prevent the IVs from overlaying this + const overlayScale = 1; + this.moveInfoOverlay = new MoveInfoOverlay(this.scene, { + scale: overlayScale, + top: true, + x: 1, + y: this.scene.game.canvas.height / 6 - MoveInfoOverlay.getHeight(overlayScale) - 29, + }); + this.starterSelectContainer.add(this.moveInfoOverlay); + this.scene.eventTarget.addEventListener(BattleSceneEventType.CANDY_UPGRADE_NOTIFICATION_CHANGED, (e) => this.onCandyUpgradeDisplayChanged(e)); this.updateInstructions(); } show(args: any[]): boolean { + this.moveInfoOverlay.clear(); // clear this when removing a menu; the cancel button doesn't seem to trigger this automatically on controllers if (args.length >= 2 && args[0] instanceof Function && typeof args[1] === "number") { super.show(args); this.starterSelectCallback = args[0] as StarterSelectCallback;