added settings and minor fixes

This commit is contained in:
José Ricardo Fleury Oliveira 2024-05-18 16:36:33 -03:00
parent 139f500d9d
commit 9c5a470920
3 changed files with 43 additions and 24 deletions

View File

@ -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;

View File

@ -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)

View File

@ -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
}
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])));
// Set the candy colors
this.candyUpgradeIcon[s].setTint(argbFromRgba(Utils.rgbHexToRgba(starterColors[speciesId][0])));
this.candyUpgradeOverlayIcon[s].setTint(argbFromRgba(Utils.rgbHexToRgba(starterColors[speciesId][1])));
// 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
);
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 {