[Bug] Fix Login Screen Buttons can be Pressed While Animating (#5170)

* destroy containers when processing external containers

* make form buttons uninteractible until tweens finished instead

* fix holding enter spam

* fix conflicts
This commit is contained in:
Chris 2025-04-19 17:00:12 -04:00 committed by GitHub
parent 65294f408e
commit bda286cebb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 120 additions and 106 deletions

View File

@ -124,7 +124,7 @@ export abstract class FormModalUiHandler extends ModalUiHandler {
if (this.buttonBgs.length) { if (this.buttonBgs.length) {
this.buttonBgs[0].off("pointerdown"); this.buttonBgs[0].off("pointerdown");
this.buttonBgs[0].on("pointerdown", () => { this.buttonBgs[0].on("pointerdown", () => {
if (this.submitAction) { if (this.submitAction && globalScene.tweens.getTweensOf(this.modalContainer).length === 0) {
this.submitAction(); this.submitAction();
} }
}); });

View File

@ -40,25 +40,9 @@ export default class LoginFormUiHandler extends FormModalUiHandler {
setup(): void { setup(): void {
super.setup(); super.setup();
this.buildExternalPartyContainer(); this.buildExternalPartyContainer();
this.buildInfoContainer();
this.infoContainer = globalScene.add.container(0, 0);
this.usernameInfoImage = this.buildInteractableImage("settings_icon", "username-info-icon", {
x: 20,
scale: 0.5,
});
this.saveDownloadImage = this.buildInteractableImage("saving_icon", "save-download-icon", {
x: 0,
scale: 0.75,
});
this.infoContainer.add(this.usernameInfoImage);
this.infoContainer.add(this.saveDownloadImage);
this.getUi().add(this.infoContainer);
this.infoContainer.setVisible(false);
this.infoContainer.disableInteractive();
} }
private buildExternalPartyContainer() { private buildExternalPartyContainer() {
@ -84,6 +68,26 @@ export default class LoginFormUiHandler extends FormModalUiHandler {
this.externalPartyContainer.setVisible(false); this.externalPartyContainer.setVisible(false);
} }
private buildInfoContainer() {
this.infoContainer = globalScene.add.container(0, 0);
this.usernameInfoImage = this.buildInteractableImage("settings_icon", "username-info-icon", {
x: 20,
scale: 0.5,
});
this.saveDownloadImage = this.buildInteractableImage("saving_icon", "save-download-icon", {
x: 0,
scale: 0.75,
});
this.infoContainer.add(this.usernameInfoImage);
this.infoContainer.add(this.saveDownloadImage);
this.getUi().add(this.infoContainer);
this.infoContainer.setVisible(false);
this.infoContainer.disableInteractive();
}
override getModalTitle(_config?: ModalConfig): string { override getModalTitle(_config?: ModalConfig): string {
let key = "menu:login"; let key = "menu:login";
if (import.meta.env.VITE_SERVER_URL === "https://apibeta.pokerogue.net") { if (import.meta.env.VITE_SERVER_URL === "https://apibeta.pokerogue.net") {
@ -143,6 +147,7 @@ export default class LoginFormUiHandler extends FormModalUiHandler {
this.processExternalProvider(config); this.processExternalProvider(config);
const originalLoginAction = this.submitAction; const originalLoginAction = this.submitAction;
this.submitAction = _ => { this.submitAction = _ => {
if (globalScene.tweens.getTweensOf(this.modalContainer).length === 0) {
// Prevent overlapping overrides on action modification // Prevent overlapping overrides on action modification
this.submitAction = originalLoginAction; this.submitAction = originalLoginAction;
this.sanitizeInputs(); this.sanitizeInputs();
@ -164,6 +169,7 @@ export default class LoginFormUiHandler extends FormModalUiHandler {
onFail(error); onFail(error);
} }
}); });
}
}; };
return true; return true;
@ -221,6 +227,7 @@ export default class LoginFormUiHandler extends FormModalUiHandler {
}; };
this.usernameInfoImage.on("pointerdown", () => { this.usernameInfoImage.on("pointerdown", () => {
if (globalScene.tweens.getTweensOf(this.infoContainer).length === 0) {
const localStorageKeys = Object.keys(localStorage); // this gets the keys for localStorage const localStorageKeys = Object.keys(localStorage); // this gets the keys for localStorage
const keyToFind = "data_"; const keyToFind = "data_";
const dataKeys = localStorageKeys.filter(ls => ls.indexOf(keyToFind) >= 0); const dataKeys = localStorageKeys.filter(ls => ls.indexOf(keyToFind) >= 0);
@ -250,6 +257,7 @@ export default class LoginFormUiHandler extends FormModalUiHandler {
} }
return onFail(this.ERR_NO_SAVES); return onFail(this.ERR_NO_SAVES);
} }
}
}); });
this.saveDownloadImage.on("pointerdown", () => { this.saveDownloadImage.on("pointerdown", () => {

View File

@ -134,7 +134,11 @@ export abstract class ModalUiHandler extends UiHandler {
for (let a = 0; a < this.buttonBgs.length; a++) { for (let a = 0; a < this.buttonBgs.length; a++) {
if (a < this.buttonBgs.length) { if (a < this.buttonBgs.length) {
this.buttonBgs[a].on("pointerdown", _ => config.buttonActions[a]()); this.buttonBgs[a].on("pointerdown", _ => {
if (globalScene.tweens.getTweensOf(this.modalContainer).length === 0) {
config.buttonActions[a]();
}
});
} }
} }

View File

@ -98,6 +98,7 @@ export default class RegistrationFormUiHandler extends FormModalUiHandler {
const originalRegistrationAction = this.submitAction; const originalRegistrationAction = this.submitAction;
this.submitAction = _ => { this.submitAction = _ => {
if (globalScene.tweens.getTweensOf(this.modalContainer).length === 0) {
// Prevent overlapping overrides on action modification // Prevent overlapping overrides on action modification
this.submitAction = originalRegistrationAction; this.submitAction = originalRegistrationAction;
this.sanitizeInputs(); this.sanitizeInputs();
@ -143,6 +144,7 @@ export default class RegistrationFormUiHandler extends FormModalUiHandler {
onFail(registerError); onFail(registerError);
} }
}); });
}
}; };
return true; return true;