Add setting to change money format (#1261)
* Add setting to change money format This setting can currently be set either on "normal" or "abbreviated". "normal" will show all the numbers, while "abbreviated" will abbreviate to the most significant numbers and use a suffix to show the power-10. A new enum has been added for MoneyFormat as well. * Update src/battle-scene.ts Co-authored-by: Franck TROUILLEZ <57403591+francktrouillez@users.noreply.github.com> --------- Co-authored-by: Benjamin Odom <bennybroseph@gmail.com>
This commit is contained in:
parent
17e4edeb8d
commit
99835c27c8
|
@ -56,6 +56,7 @@ import { Localizable } from "./plugins/i18n";
|
|||
import * as Overrides from "./overrides";
|
||||
import {InputsController} from "./inputs-controller";
|
||||
import {UiInputs} from "./ui-inputs";
|
||||
import { MoneyFormat } from "./enums/money-format";
|
||||
import { NewArenaEvent } from "./battle-scene-events";
|
||||
|
||||
export const bypassLogin = import.meta.env.VITE_BYPASS_LOGIN === "1";
|
||||
|
@ -92,6 +93,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 moneyFormat: MoneyFormat = MoneyFormat.NORMAL;
|
||||
public uiTheme: UiTheme = UiTheme.DEFAULT;
|
||||
public windowType: integer = 0;
|
||||
public experimentalSprites: boolean = false;
|
||||
|
@ -1263,9 +1265,16 @@ export default class BattleScene extends SceneBase {
|
|||
this.biomeWaveText.setVisible(true);
|
||||
}
|
||||
|
||||
updateMoneyText(): void {
|
||||
this.moneyText.setText(`₽${Utils.formatFancyLargeNumber(this.money, 3)}`);
|
||||
this.moneyText.setVisible(true);
|
||||
updateMoneyText(forceVisible: boolean = true): void {
|
||||
if (this.money === undefined) {
|
||||
return;
|
||||
}
|
||||
const formattedMoney =
|
||||
this.moneyFormat === MoneyFormat.ABBREVIATED ? Utils.formatFancyLargeNumber(this.money, 3) : this.money.toLocaleString();
|
||||
this.moneyText.setText(`₽${formattedMoney}`);
|
||||
if (forceVisible) {
|
||||
this.moneyText.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
updateScoreText(): void {
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
export enum MoneyFormat {
|
||||
NORMAL,
|
||||
ABBREVIATED
|
||||
}
|
|
@ -5,6 +5,7 @@ import BattleScene from "../battle-scene";
|
|||
import { hasTouchscreen } from "../touch-controls";
|
||||
import { updateWindowType } from "../ui/ui-theme";
|
||||
import { PlayerGender } from "./game-data";
|
||||
import { MoneyFormat } from "../enums/money-format";
|
||||
|
||||
export enum Setting {
|
||||
Game_Speed = "GAME_SPEED",
|
||||
|
@ -17,6 +18,7 @@ export enum Setting {
|
|||
Window_Type = "WINDOW_TYPE",
|
||||
Tutorials = "TUTORIALS",
|
||||
Enable_Retries = "ENABLE_RETRIES",
|
||||
Money_Format = "MONEY_FORMAT",
|
||||
Sprite_Set = "SPRITE_SET",
|
||||
Move_Animations = "MOVE_ANIMATIONS",
|
||||
Show_Stats_on_Level_Up = "SHOW_LEVEL_UP_STATS",
|
||||
|
@ -50,6 +52,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.Money_Format]: ["Normal", "Abbreviated"],
|
||||
[Setting.Sprite_Set]: ["Consistent", "Mixed Animated"],
|
||||
[Setting.Move_Animations]: ["Off", "On"],
|
||||
[Setting.Show_Stats_on_Level_Up]: ["Off", "On"],
|
||||
|
@ -75,6 +78,7 @@ export const settingDefaults: SettingDefaults = {
|
|||
[Setting.Window_Type]: 0,
|
||||
[Setting.Tutorials]: 1,
|
||||
[Setting.Enable_Retries]: 0,
|
||||
[Setting.Money_Format]: 0,
|
||||
[Setting.Sprite_Set]: 0,
|
||||
[Setting.Move_Animations]: 1,
|
||||
[Setting.Show_Stats_on_Level_Up]: 1,
|
||||
|
@ -123,6 +127,17 @@ export function setSetting(scene: BattleScene, setting: Setting, value: integer)
|
|||
case Setting.Enable_Retries:
|
||||
scene.enableRetries = settingOptions[setting][value] === "On";
|
||||
break;
|
||||
case Setting.Money_Format:
|
||||
switch (settingOptions[setting][value]) {
|
||||
case "Normal":
|
||||
scene.moneyFormat = MoneyFormat.NORMAL;
|
||||
break;
|
||||
case "Abbreviated":
|
||||
scene.moneyFormat = MoneyFormat.ABBREVIATED;
|
||||
break;
|
||||
}
|
||||
scene.updateMoneyText(false);
|
||||
break;
|
||||
case Setting.Sprite_Set:
|
||||
scene.experimentalSprites = !!value;
|
||||
if (value) {
|
||||
|
|
Loading…
Reference in New Issue