allowSmall -> defaultShowSmall, allow it to be overrided

This commit is contained in:
thepaperpilot 2022-03-02 20:28:11 -06:00
parent 48ef321c89
commit b9f28f764f
3 changed files with 4 additions and 4 deletions

View file

@ -9,7 +9,7 @@
"versionTitle": "Initial Commit", "versionTitle": "Initial Commit",
"allowGoBack": true, "allowGoBack": true,
"allowSmall": false, "defaultShowSmall": false,
"defaultDecimalsShown": 2, "defaultDecimalsShown": 2,
"useHeader": true, "useHeader": true,
"banner": null, "banner": null,

View file

@ -6,14 +6,14 @@ import { State, persistent } from "@/game/persistence";
export interface Resource<T = DecimalSource> extends Ref<T> { export interface Resource<T = DecimalSource> extends Ref<T> {
displayName: string; displayName: string;
precision: number; precision: number;
small: boolean; small?: boolean;
} }
export function createResource<T extends State>( export function createResource<T extends State>(
defaultValue: T | Ref<T>, defaultValue: T | Ref<T>,
displayName = "points", displayName = "points",
precision = 0, precision = 0,
small = false small = undefined
): Resource<T> { ): Resource<T> {
const resource: Partial<Resource<T>> = persistent(defaultValue); const resource: Partial<Resource<T>> = persistent(defaultValue);
resource.displayName = displayName; resource.displayName = displayName;

View file

@ -64,7 +64,7 @@ const thousandth = new Decimal(0.001);
const zero = new Decimal(0); const zero = new Decimal(0);
export function format(num: DecimalSource, precision?: number, small?: boolean): string { export function format(num: DecimalSource, precision?: number, small?: boolean): string {
if (precision == null) precision = projInfo.defaultDecimalsShown; if (precision == null) precision = projInfo.defaultDecimalsShown;
small = small || projInfo.allowSmall; small = small ?? projInfo.defaultShowSmall;
num = new Decimal(num); num = new Decimal(num);
if (isNaN(num.sign) || isNaN(num.layer) || isNaN(num.mag)) { if (isNaN(num.sign) || isNaN(num.layer) || isNaN(num.mag)) {
return "NaN"; return "NaN";