From 308bbb3b2de4ef128523106a900533d0f9eb3c61 Mon Sep 17 00:00:00 2001 From: David Yang Date: Fri, 17 Jan 2025 13:44:03 +0800 Subject: [PATCH 1/3] [UI/UX] Spend all button for gacha --- public/locales | 2 +- src/ui/egg-gacha-ui-handler.ts | 51 ++++++++++++++++++++++++++++------ 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/public/locales b/public/locales index acad8499a4c..60a8e3335f5 160000 --- a/public/locales +++ b/public/locales @@ -1 +1 @@ -Subproject commit acad8499a4ca488a9871902de140f635235f309a +Subproject commit 60a8e3335f5cec7e37d6f2c0d09e588a46d25468 diff --git a/src/ui/egg-gacha-ui-handler.ts b/src/ui/egg-gacha-ui-handler.ts index 82e361fac39..6330fb51f3d 100644 --- a/src/ui/egg-gacha-ui-handler.ts +++ b/src/ui/egg-gacha-ui-handler.ts @@ -199,8 +199,6 @@ export default class EggGachaUiHandler extends MessageUiHandler { this.updateGachaInfo(g); }); - this.eggGachaOptionsContainer = globalScene.add.container(); - this.eggGachaOptionsContainer = globalScene.add.container((globalScene.game.canvas.width / 6), 148); this.eggGachaContainer.add(this.eggGachaOptionsContainer); @@ -211,12 +209,14 @@ export default class EggGachaUiHandler extends MessageUiHandler { const multiplierOne = "x1"; const multiplierTen = "x10"; + const multiplierNone = ""; const pullOptions = [ { multiplier: multiplierOne, description: `1 ${i18next.t("egg:pull")}`, icon: getVoucherTypeIcon(VoucherType.REGULAR) }, { multiplier: multiplierTen, description: `10 ${i18next.t("egg:pulls")}`, icon: getVoucherTypeIcon(VoucherType.REGULAR) }, { multiplier: multiplierOne, description: `5 ${i18next.t("egg:pulls")}`, icon: getVoucherTypeIcon(VoucherType.PLUS) }, { multiplier: multiplierOne, description: `10 ${i18next.t("egg:pulls")}`, icon: getVoucherTypeIcon(VoucherType.PREMIUM) }, - { multiplier: multiplierOne, description: `25 ${i18next.t("egg:pulls")}`, icon: getVoucherTypeIcon(VoucherType.GOLDEN) } + { multiplier: multiplierOne, description: `25 ${i18next.t("egg:pulls")}`, icon: getVoucherTypeIcon(VoucherType.GOLDEN) }, + { multiplier: multiplierNone, description: `${i18next.t("egg:all")}`, icon: getVoucherTypeIcon(VoucherType.GOLDEN) } ]; const resolvedLanguage = i18next.resolvedLanguage ?? "en"; @@ -238,7 +238,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { TextStyle.WINDOW, ); - optionText.setLineSpacing(28); + optionText.setLineSpacing(13); optionText.setFontSize("80px"); this.eggGachaOptionsContainer.add(optionText); @@ -248,7 +248,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { pullOptions.forEach((option, i) => { const icon = globalScene.add.sprite(0, 0, "items", option.icon); icon.setScale(3 * this.scale); - icon.setPositionRelative(this.eggGachaOptionSelectBg, 20, 9 + (48 + i * 96) * this.scale); + icon.setPositionRelative(this.eggGachaOptionSelectBg, 20, 9 + (48 + i * 81) * this.scale); this.eggGachaOptionsContainer.add(icon); }); @@ -496,7 +496,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { ease: "Sine.easeOut", duration: overlayEaseInDuration, onComplete: () => { - const rowItems = 5; + const rowItems = Math.max(Math.ceil(eggs.length / 11), 5); const rows = Math.ceil(eggs.length / rowItems); const cols = Math.min(eggs.length, rowItems); const height = this.eggGachaOverlay.displayHeight - this.eggGachaMessageBox.displayHeight; @@ -709,6 +709,41 @@ export default class EggGachaUiHandler extends MessageUiHandler { } break; case 5: + if (!globalScene.gameData.voucherCounts[VoucherType.REGULAR] && !globalScene.gameData.voucherCounts[VoucherType.PLUS] + && !globalScene.gameData.voucherCounts[VoucherType.PREMIUM] && !globalScene.gameData.voucherCounts[VoucherType.GOLDEN] && + !Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) { + error = true; + this.showError(i18next.t("egg:noVouchers")); + } else if (globalScene.gameData.eggs.length < 99 || Overrides.UNLIMITED_EGG_COUNT_OVERRIDE) { + let pulls = 0; + let eggSpace = 99 - globalScene.gameData.eggs.length; + + if (!Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) { + const voucherTypes = [[ VoucherType.GOLDEN, 25 ], [ VoucherType.PREMIUM, 10 ], [ VoucherType.PLUS, 5 ], [ VoucherType.REGULAR, 1 ]]; + voucherTypes.forEach(voucherType => { + const vouchersUsed = Math.min(globalScene.gameData.voucherCounts[voucherType[0]], ~~(eggSpace / voucherType[1])); + this.consumeVouchers(voucherType[0], vouchersUsed); + const pullsUsed = vouchersUsed * voucherType[1]; + pulls += pullsUsed; + eggSpace -= pullsUsed; + }); + } else { + pulls = eggSpace; + } + + if (pulls === 0) { + error = true; + this.showError(i18next.t("egg:vouchersExceedEggCap")); + } else { + this.pull(pulls); + success = true; + } + } else { + error = true; + this.showError(i18next.t("egg:tooManyEggs")); + } + break; + case 6: ui.revertMode(); success = true; break; @@ -724,7 +759,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { } break; case Button.DOWN: - if (this.cursor < 5) { + if (this.cursor < 6) { success = this.setCursor(this.cursor + 1); } break; @@ -760,7 +795,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { } this.cursorObj.setScale(this.scale * 6); - this.cursorObj.setPositionRelative(this.eggGachaOptionSelectBg, 10, 9 + (48 + this.cursor * 96) * this.scale); + this.cursorObj.setPositionRelative(this.eggGachaOptionSelectBg, 10, 9 + (48 + this.cursor * 81) * this.scale); return ret; } From 54b31d3c60d56c2954fcfeaf97f97a0b4363bca1 Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Mon, 20 Jan 2025 06:13:57 -0800 Subject: [PATCH 2/3] Update locales submodule --- public/locales | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/locales b/public/locales index 60a8e3335f5..7b171433857 160000 --- a/public/locales +++ b/public/locales @@ -1 +1 @@ -Subproject commit 60a8e3335f5cec7e37d6f2c0d09e588a46d25468 +Subproject commit 7b1714338573274600c4b08ca2cc0868439c168d From e0717f4ae5263479e258554a141bb23d1d73d4ba Mon Sep 17 00:00:00 2001 From: David Yang Date: Mon, 20 Jan 2025 22:16:10 +0800 Subject: [PATCH 3/3] Formatting amendments --- src/ui/egg-gacha-ui-handler.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ui/egg-gacha-ui-handler.ts b/src/ui/egg-gacha-ui-handler.ts index 6330fb51f3d..42b38303af7 100644 --- a/src/ui/egg-gacha-ui-handler.ts +++ b/src/ui/egg-gacha-ui-handler.ts @@ -709,9 +709,13 @@ export default class EggGachaUiHandler extends MessageUiHandler { } break; case 5: - if (!globalScene.gameData.voucherCounts[VoucherType.REGULAR] && !globalScene.gameData.voucherCounts[VoucherType.PLUS] - && !globalScene.gameData.voucherCounts[VoucherType.PREMIUM] && !globalScene.gameData.voucherCounts[VoucherType.GOLDEN] && - !Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) { + if ( + !globalScene.gameData.voucherCounts[VoucherType.REGULAR] + && !globalScene.gameData.voucherCounts[VoucherType.PLUS] + && !globalScene.gameData.voucherCounts[VoucherType.PREMIUM] + && !globalScene.gameData.voucherCounts[VoucherType.GOLDEN] + && !Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE + ) { error = true; this.showError(i18next.t("egg:noVouchers")); } else if (globalScene.gameData.eggs.length < 99 || Overrides.UNLIMITED_EGG_COUNT_OVERRIDE) { @@ -721,7 +725,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { if (!Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) { const voucherTypes = [[ VoucherType.GOLDEN, 25 ], [ VoucherType.PREMIUM, 10 ], [ VoucherType.PLUS, 5 ], [ VoucherType.REGULAR, 1 ]]; voucherTypes.forEach(voucherType => { - const vouchersUsed = Math.min(globalScene.gameData.voucherCounts[voucherType[0]], ~~(eggSpace / voucherType[1])); + const vouchersUsed = Math.min(globalScene.gameData.voucherCounts[voucherType[0]], Math.floor(eggSpace / voucherType[1])); this.consumeVouchers(voucherType[0], vouchersUsed); const pullsUsed = vouchersUsed * voucherType[1]; pulls += pullsUsed;