2024-09-21 20:26:58 -05:00
|
|
|
import * as lodash from 'lodash-es';
|
2024-09-17 21:44:35 -05:00
|
|
|
import { create } from 'zustand';
|
2024-09-22 21:12:18 -05:00
|
|
|
import { persist, subscribeWithSelector } from 'zustand/middleware';
|
2024-09-17 22:13:35 -05:00
|
|
|
import { ENVIRONMENTS } from '../../constants/lightingEnvironments';
|
2024-09-21 20:26:58 -05:00
|
|
|
import { createContextualStore } from '../../core/zustand/createContextualStore';
|
2024-07-28 13:32:52 -05:00
|
|
|
import { SORT_NAMES, TankopediaDisplay } from './constants';
|
2024-07-09 14:43:33 -05:00
|
|
|
|
|
|
|
|
export type TankopediaSortBy = keyof typeof SORT_NAMES;
|
|
|
|
|
export type TankopediaSortDirection = 'ascending' | 'descending';
|
|
|
|
|
export type TankopediaTestTankDisplay = 'include' | 'exclude' | 'only';
|
2024-09-21 20:26:58 -05:00
|
|
|
|
|
|
|
|
export interface TankopediaPersistentStore {
|
|
|
|
|
wireframe: boolean;
|
|
|
|
|
opaque: boolean;
|
|
|
|
|
environment: (typeof ENVIRONMENTS)[number];
|
|
|
|
|
showGrid: boolean;
|
|
|
|
|
greenPenetration: boolean;
|
|
|
|
|
showEnvironment: boolean;
|
|
|
|
|
showSpacedArmor: boolean;
|
|
|
|
|
showExternalModules: boolean;
|
|
|
|
|
showPrimaryArmor: boolean;
|
|
|
|
|
|
2024-07-09 14:43:33 -05:00
|
|
|
sort: {
|
|
|
|
|
by: TankopediaSortBy;
|
|
|
|
|
direction: TankopediaSortDirection;
|
|
|
|
|
};
|
2024-09-21 20:26:58 -05:00
|
|
|
|
2024-07-28 13:32:52 -05:00
|
|
|
display: TankopediaDisplay;
|
2024-07-09 14:43:33 -05:00
|
|
|
}
|
|
|
|
|
|
2024-09-21 20:26:58 -05:00
|
|
|
export const TankopediaPersistent = createContextualStore(() =>
|
|
|
|
|
create<TankopediaPersistentStore>()(
|
|
|
|
|
persist(
|
2024-09-22 21:12:18 -05:00
|
|
|
subscribeWithSelector<TankopediaPersistentStore>(() => ({
|
2024-09-21 20:26:58 -05:00
|
|
|
wireframe: false,
|
|
|
|
|
opaque: false,
|
|
|
|
|
environment: ENVIRONMENTS[0],
|
|
|
|
|
showGrid: true,
|
2024-09-22 21:12:18 -05:00
|
|
|
greenPenetration: false,
|
|
|
|
|
showEnvironment: false,
|
2024-09-21 20:26:58 -05:00
|
|
|
showSpacedArmor: true,
|
|
|
|
|
showExternalModules: true,
|
|
|
|
|
showPrimaryArmor: true,
|
|
|
|
|
sort: {
|
|
|
|
|
by: 'meta.none',
|
|
|
|
|
direction: 'ascending',
|
|
|
|
|
},
|
|
|
|
|
display: TankopediaDisplay.Model,
|
2024-09-22 21:12:18 -05:00
|
|
|
})),
|
2024-09-21 20:26:58 -05:00
|
|
|
{ name: 'tankopedia', merge: (a, b) => lodash.merge(b, a) },
|
2024-09-17 21:44:35 -05:00
|
|
|
),
|
2024-09-21 20:26:58 -05:00
|
|
|
),
|
|
|
|
|
);
|