From 9c5a47092042665b552e5b02b3cabe78a3fdafe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Ricardo=20Fleury=20Oliveira?= Date: Sat, 18 May 2024 16:36:33 -0300 Subject: [PATCH] added settings and minor fixes --- src/battle-scene.ts | 1 + src/system/settings.ts | 6 +++ src/ui/starter-select-ui-handler.ts | 60 +++++++++++++++++------------ 3 files changed, 43 insertions(+), 24 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 0f75447a500..37a3a7340d7 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -97,6 +97,7 @@ export default class BattleScene extends SceneBase { public showLevelUpStats: boolean = true; public enableTutorials: boolean = import.meta.env.VITE_BYPASS_TUTORIAL === "1"; public enableRetries: boolean = false; + public candyUpgradeIconsMode: integer = 0; public uiTheme: UiTheme = UiTheme.DEFAULT; public windowType: integer = 0; public experimentalSprites: boolean = false; diff --git a/src/system/settings.ts b/src/system/settings.ts index 15c1f19aa04..4450fcc73e9 100644 --- a/src/system/settings.ts +++ b/src/system/settings.ts @@ -17,6 +17,7 @@ export enum Setting { Window_Type = "WINDOW_TYPE", Tutorials = "TUTORIALS", Enable_Retries = "ENABLE_RETRIES", + Candy_Upgrade_Icon = "CANDY_UPGRADE_ICON", Sprite_Set = "SPRITE_SET", Move_Animations = "MOVE_ANIMATIONS", Show_Stats_on_Level_Up = "SHOW_LEVEL_UP_STATS", @@ -50,6 +51,7 @@ export const settingOptions: SettingOptions = { [Setting.Window_Type]: new Array(5).fill(null).map((_, i) => (i + 1).toString()), [Setting.Tutorials]: ['Off', 'On'], [Setting.Enable_Retries]: ['Off', 'On'], + [Setting.Candy_Upgrade_Icon]: ['Off', 'Only Passive Unlocks', 'On'], [Setting.Sprite_Set]: ['Consistent', 'Mixed Animated'], [Setting.Move_Animations]: ['Off', 'On'], [Setting.Show_Stats_on_Level_Up]: ['Off', 'On'], @@ -75,6 +77,7 @@ export const settingDefaults: SettingDefaults = { [Setting.Window_Type]: 0, [Setting.Tutorials]: 1, [Setting.Enable_Retries]: 0, + [Setting.Candy_Upgrade_Icon]: 0, [Setting.Sprite_Set]: 0, [Setting.Move_Animations]: 1, [Setting.Show_Stats_on_Level_Up]: 1, @@ -123,6 +126,9 @@ export function setSetting(scene: BattleScene, setting: Setting, value: integer) case Setting.Enable_Retries: scene.enableRetries = settingOptions[setting][value] === 'On'; break; + case Setting.Candy_Upgrade_Icon: + scene.candyUpgradeIconsMode = value; + break; case Setting.Sprite_Set: scene.experimentalSprites = !!value; if (value) diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 5e11734e829..c8698e2d751 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -984,7 +984,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { if (!success) return this.scene.reset(true); }); - this.updateCandyUpgradeIcon(this.cursor); + if (this.scene.candyUpgradeIconsMode !== 0) {this.updateCandyUpgradeIcon(this.cursor)} // If the setting is not set to 0, update the candy upgrade icon ui.setMode(Mode.STARTER_SELECT); this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, undefined, undefined, undefined); return true; @@ -1009,7 +1009,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { if (!success) return this.scene.reset(true); }); - this.updateCandyUpgradeIcon(this.cursor); + if (this.scene.candyUpgradeIconsMode === 2) {this.updateCandyUpgradeIcon(this.cursor)} // If the setting is set to 2, update the candy upgrade icon this.updateStarterValueLabel(this.cursor); this.tryUpdateValue(0); ui.setMode(Mode.STARTER_SELECT); @@ -1301,26 +1301,30 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.hiddenAbilityIcons[s].setVisible(slotVisible && !!this.scene.gameData.dexData[speciesId].caughtAttr && !!(this.scene.gameData.starterData[speciesId].abilityAttr & 4)); this.classicWinIcons[s].setVisible(slotVisible && this.scene.gameData.starterData[speciesId].classicWinCount > 0); - if (!starterColors[speciesId]) { - starterColors[speciesId] = [ 'ffffff', 'ffffff' ]; // Default to white if no colors are found - } - - // Set the candy colors - this.candyUpgradeIcon[s].setTint(argbFromRgba(Utils.rgbHexToRgba(starterColors[speciesId][0]))); - this.candyUpgradeOverlayIcon[s].setTint(argbFromRgba(Utils.rgbHexToRgba(starterColors[speciesId][1]))); + if (!starterColors[speciesId]) { + starterColors[speciesId] = [ 'ffffff', 'ffffff' ]; // Default to white if no colors are found + } - // Display the candy upgrade icon and its overlay if the species has a passive ability that can be unlocked or if its value can be reduced - this.candyUpgradeIcon[s].setVisible( - slotVisible && ( - (this.scene.gameData.starterData[speciesId].candyCount >= getPassiveCandyCount(speciesStarters[speciesId]) && - !(this.scene.gameData.starterData[speciesId].passiveAttr & PassiveAttr.UNLOCKED)) || - (this.scene.gameData.starterData[speciesId].candyCount >= getValueReductionCandyCounts(speciesStarters[speciesId])[this.scene.gameData.starterData[speciesId].valueReduction] && - this.scene.gameData.starterData[speciesId].valueReduction < 2) - ) - ); - this.candyUpgradeOverlayIcon[s].setVisible( - slotVisible && this.candyUpgradeIcon[s].visible - ); + // Set the candy colors + this.candyUpgradeIcon[s].setTint(argbFromRgba(Utils.rgbHexToRgba(starterColors[speciesId][0]))); + this.candyUpgradeOverlayIcon[s].setTint(argbFromRgba(Utils.rgbHexToRgba(starterColors[speciesId][1]))); + + if (this.scene.candyUpgradeIconsMode == 1) { // 'Only Passive Unlocks' mode + this.candyUpgradeIcon[s].setVisible( + slotVisible && ( + this.scene.gameData.starterData[speciesId].candyCount >= getPassiveCandyCount(speciesStarters[speciesId]) && + !(this.scene.gameData.starterData[speciesId].passiveAttr & PassiveAttr.UNLOCKED))); + this.candyUpgradeOverlayIcon[s].setVisible(slotVisible && this.candyUpgradeIcon[s].visible); + + } else if (this.scene.candyUpgradeIconsMode == 2) { // 'On' mode + this.candyUpgradeIcon[s].setVisible( + slotVisible && ( + (this.scene.gameData.starterData[speciesId].candyCount >= getPassiveCandyCount(speciesStarters[speciesId]) && + !(this.scene.gameData.starterData[speciesId].passiveAttr & PassiveAttr.UNLOCKED)) || + (this.scene.gameData.starterData[speciesId].candyCount >= getValueReductionCandyCounts(speciesStarters[speciesId])[this.scene.gameData.starterData[speciesId].valueReduction] && + this.scene.gameData.starterData[speciesId].valueReduction < 2))); + this.candyUpgradeOverlayIcon[s].setVisible(slotVisible && this.candyUpgradeIcon[s].visible); + } } } else { changed = super.setCursor(cursor); @@ -1808,9 +1812,17 @@ export default class StarterSelectUiHandler extends MessageUiHandler { updateCandyUpgradeIcon(cursor: integer): void { const speciesId = this.genSpecies[this.getGenCursorWithScroll()][cursor].speciesId; - this.candyUpgradeIcon[cursor].setVisible( - this.scene.gameData.starterData[speciesId].candyCount >= getPassiveCandyCount(speciesStarters[speciesId]) || this.scene.gameData.starterData[speciesId].candyCount >= getValueReductionCandyCounts(speciesStarters[speciesId])[this.scene.gameData.starterData[speciesId].valueReduction]); - this.candyUpgradeOverlayIcon[cursor].setVisible(this.candyUpgradeIcon[cursor].visible); + if (this.scene.candyUpgradeIconsMode === 1) { // 'Only Passive Unlocks' mode: + this.candyUpgradeIcon[cursor].setVisible(this.scene.gameData.starterData[speciesId].candyCount >= getPassiveCandyCount(speciesStarters[speciesId]) && !(this.scene.gameData.starterData[speciesId].passiveAttr & PassiveAttr.UNLOCKED)); + this.candyUpgradeOverlayIcon[cursor].setVisible(this.candyUpgradeIcon[cursor].visible); + + } else if (this.scene.candyUpgradeIconsMode === 2) { // 'On' mode + this.candyUpgradeIcon[cursor].setVisible( + (this.scene.gameData.starterData[speciesId].candyCount >= getPassiveCandyCount(speciesStarters[speciesId]) && !(this.scene.gameData.starterData[speciesId].passiveAttr & PassiveAttr.UNLOCKED)) || + (this.scene.gameData.starterData[speciesId].candyCount >= getValueReductionCandyCounts(speciesStarters[speciesId])[this.scene.gameData.starterData[speciesId].valueReduction]) && + this.scene.gameData.starterData[speciesId].valueReduction < 2); + this.candyUpgradeOverlayIcon[cursor].setVisible(this.candyUpgradeIcon[cursor].visible); + } } tryUpdateValue(add?: integer): boolean {