[P3][UI] Fix egg gacha overlay not getting cleared properly (#4600)

This commit is contained in:
MokaStitcher 2024-10-08 17:10:54 +02:00 committed by GitHub
parent 6e10f6600f
commit 0ede7b057d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 37 additions and 16 deletions

View File

@ -156,6 +156,7 @@ class DefaultOverrides {
readonly EGG_VARIANT_OVERRIDE: VariantTier | null = null; readonly EGG_VARIANT_OVERRIDE: VariantTier | null = null;
readonly EGG_FREE_GACHA_PULLS_OVERRIDE: boolean = false; readonly EGG_FREE_GACHA_PULLS_OVERRIDE: boolean = false;
readonly EGG_GACHA_PULL_COUNT_OVERRIDE: number = 0; readonly EGG_GACHA_PULL_COUNT_OVERRIDE: number = 0;
readonly UNLIMITED_EGG_COUNT_OVERRIDE: boolean = false;
// ------------------------- // -------------------------
// MYSTERY ENCOUNTER OVERRIDES // MYSTERY ENCOUNTER OVERRIDES

View File

@ -34,6 +34,7 @@ export default class EggGachaUiHandler extends MessageUiHandler {
private cursorObj: Phaser.GameObjects.Image; private cursorObj: Phaser.GameObjects.Image;
private transitioning: boolean; private transitioning: boolean;
private transitionCancelled: boolean; private transitionCancelled: boolean;
private summaryFinished: boolean;
private defaultText: string; private defaultText: string;
private scale: number = 0.1666666667; private scale: number = 0.1666666667;
@ -479,7 +480,12 @@ export default class EggGachaUiHandler extends MessageUiHandler {
} }
showSummary(eggs: Egg[]): void { showSummary(eggs: Egg[]): void {
this.transitioning = false; // the overlay will appear faster if the egg pulling animation was skipped
const overlayEaseInDuration = this.getDelayValue(750);
this.summaryFinished = false;
this.transitionCancelled = false;
this.setTransitioning(true);
this.eggGachaSummaryContainer.setVisible(true); this.eggGachaSummaryContainer.setVisible(true);
const eggScale = eggs.length < 20 ? 1 : 0.5; const eggScale = eggs.length < 20 ? 1 : 0.5;
@ -488,12 +494,14 @@ export default class EggGachaUiHandler extends MessageUiHandler {
targets: this.eggGachaOverlay, targets: this.eggGachaOverlay,
alpha: 0.5, alpha: 0.5,
ease: "Sine.easeOut", ease: "Sine.easeOut",
duration: 750, duration: overlayEaseInDuration,
onComplete: () => { onComplete: () => {
const rowItems = 5; const rowItems = 5;
const rows = Math.ceil(eggs.length / rowItems); const rows = Math.ceil(eggs.length / rowItems);
const cols = Math.min(eggs.length, rowItems); const cols = Math.min(eggs.length, rowItems);
const height = this.eggGachaOverlay.displayHeight - this.eggGachaMessageBox.displayHeight; const height = this.eggGachaOverlay.displayHeight - this.eggGachaMessageBox.displayHeight;
// Create sprites for each egg
const eggContainers = eggs.map((egg, t) => { const eggContainers = eggs.map((egg, t) => {
const col = t % rowItems; const col = t % rowItems;
const row = Math.floor(t / rowItems); const row = Math.floor(t / rowItems);
@ -515,14 +523,24 @@ export default class EggGachaUiHandler extends MessageUiHandler {
return ret; return ret;
}); });
eggContainers.forEach((eggContainer, e) => { // If action/cancel was pressed when the overlay was easing in, show all eggs at once
// Otherwise show the eggs one by one with a small delay between each
eggContainers.forEach((eggContainer, index) => {
const delay = !this.transitionCancelled ? this.getDelayValue(index * 100) : 0;
this.scene.time.delayedCall(delay, () =>
this.scene.tweens.add({ this.scene.tweens.add({
targets: eggContainer, targets: eggContainer,
delay: this.getDelayValue(e * 100),
duration: this.getDelayValue(350), duration: this.getDelayValue(350),
scale: eggScale, scale: eggScale,
ease: "Sine.easeOut" ease: "Sine.easeOut",
}); onComplete: () => {
if (index === eggs.length - 1) {
this.setTransitioning(false);
this.summaryFinished = true;
}
}
}));
}); });
} }
}); });
@ -540,6 +558,7 @@ export default class EggGachaUiHandler extends MessageUiHandler {
this.eggGachaSummaryContainer.setAlpha(1); this.eggGachaSummaryContainer.setAlpha(1);
this.eggGachaSummaryContainer.removeAll(true); this.eggGachaSummaryContainer.removeAll(true);
this.setTransitioning(false); this.setTransitioning(false);
this.summaryFinished = false;
this.eggGachaOptionsContainer.setVisible(true); this.eggGachaOptionsContainer.setVisible(true);
} }
}); });
@ -613,7 +632,7 @@ export default class EggGachaUiHandler extends MessageUiHandler {
} else { } else {
if (this.eggGachaSummaryContainer.visible) { if (this.eggGachaSummaryContainer.visible) {
if (button === Button.ACTION || button === Button.CANCEL) { if (this.summaryFinished && (button === Button.ACTION || button === Button.CANCEL)) {
this.hideSummary(); this.hideSummary();
success = true; success = true;
} }
@ -625,7 +644,7 @@ export default class EggGachaUiHandler extends MessageUiHandler {
if (!this.scene.gameData.voucherCounts[VoucherType.REGULAR] && !Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) { if (!this.scene.gameData.voucherCounts[VoucherType.REGULAR] && !Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) {
error = true; error = true;
this.showError(i18next.t("egg:notEnoughVouchers")); this.showError(i18next.t("egg:notEnoughVouchers"));
} else if (this.scene.gameData.eggs.length < 99) { } else if (this.scene.gameData.eggs.length < 99 || Overrides.UNLIMITED_EGG_COUNT_OVERRIDE) {
if (!Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) { if (!Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) {
this.consumeVouchers(VoucherType.REGULAR, 1); this.consumeVouchers(VoucherType.REGULAR, 1);
} }
@ -640,7 +659,7 @@ export default class EggGachaUiHandler extends MessageUiHandler {
if (!this.scene.gameData.voucherCounts[VoucherType.PLUS] && !Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) { if (!this.scene.gameData.voucherCounts[VoucherType.PLUS] && !Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) {
error = true; error = true;
this.showError(i18next.t("egg:notEnoughVouchers")); this.showError(i18next.t("egg:notEnoughVouchers"));
} else if (this.scene.gameData.eggs.length < 95) { } else if (this.scene.gameData.eggs.length < 95 || Overrides.UNLIMITED_EGG_COUNT_OVERRIDE) {
if (!Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) { if (!Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) {
this.consumeVouchers(VoucherType.PLUS, 1); this.consumeVouchers(VoucherType.PLUS, 1);
} }
@ -657,7 +676,7 @@ export default class EggGachaUiHandler extends MessageUiHandler {
|| (this.cursor === 3 && !this.scene.gameData.voucherCounts[VoucherType.PREMIUM] && !Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE)) { || (this.cursor === 3 && !this.scene.gameData.voucherCounts[VoucherType.PREMIUM] && !Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE)) {
error = true; error = true;
this.showError(i18next.t("egg:notEnoughVouchers")); this.showError(i18next.t("egg:notEnoughVouchers"));
} else if (this.scene.gameData.eggs.length < 90) { } else if (this.scene.gameData.eggs.length < 90 || Overrides.UNLIMITED_EGG_COUNT_OVERRIDE) {
if (this.cursor === 3) { if (this.cursor === 3) {
if (!Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) { if (!Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) {
this.consumeVouchers(VoucherType.PREMIUM, 1); this.consumeVouchers(VoucherType.PREMIUM, 1);
@ -678,7 +697,7 @@ export default class EggGachaUiHandler extends MessageUiHandler {
if (!this.scene.gameData.voucherCounts[VoucherType.GOLDEN] && !Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) { if (!this.scene.gameData.voucherCounts[VoucherType.GOLDEN] && !Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) {
error = true; error = true;
this.showError(i18next.t("egg:notEnoughVouchers")); this.showError(i18next.t("egg:notEnoughVouchers"));
} else if (this.scene.gameData.eggs.length < 75) { } else if (this.scene.gameData.eggs.length < 75 || Overrides.UNLIMITED_EGG_COUNT_OVERRIDE) {
if (!Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) { if (!Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) {
this.consumeVouchers(VoucherType.GOLDEN, 1); this.consumeVouchers(VoucherType.GOLDEN, 1);
} }

View File

@ -1789,7 +1789,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
options.push({ options.push({
label: `x${sameSpeciesEggCost} ${i18next.t("starterSelectUiHandler:sameSpeciesEgg")}`, label: `x${sameSpeciesEggCost} ${i18next.t("starterSelectUiHandler:sameSpeciesEgg")}`,
handler: () => { handler: () => {
if (this.scene.gameData.eggs.length < 99 && (Overrides.FREE_CANDY_UPGRADE_OVERRIDE || candyCount >= sameSpeciesEggCost)) { if ((this.scene.gameData.eggs.length < 99 || Overrides.UNLIMITED_EGG_COUNT_OVERRIDE)
&& (Overrides.FREE_CANDY_UPGRADE_OVERRIDE || candyCount >= sameSpeciesEggCost)) {
if (!Overrides.FREE_CANDY_UPGRADE_OVERRIDE) { if (!Overrides.FREE_CANDY_UPGRADE_OVERRIDE) {
starterData.candyCount -= sameSpeciesEggCost; starterData.candyCount -= sameSpeciesEggCost;
} }