UNPKG

@kitten-science/kitten-scientists

Version:

Add-on for the wonderful incremental browser game: https://kittensgame.com/web/

75 lines 3.39 kB
import { type Locale } from "date-fns/locale"; import { type EngineState, type SupportedLocale } from "../Engine.js"; import type { SettingOptions } from "../settings/Settings.js"; import type { StateSettings } from "../settings/StateSettings.js"; import { Unique } from "../tools/Entries.js"; import type { KGSaveData } from "../types/_save.js"; import { SettingsList } from "./components/SettingsList.js"; import { SettingsPanel } from "./components/SettingsPanel.js"; import type { UiComponent } from "./components/UiComponent.js"; export type StoredGame = { label: string; game: KGSaveData; timestamp: string; }; export type StoredState = { label: string; state: EngineState; timestamp: string; }; export declare class StateManagementUi extends SettingsPanel<StateSettings> { readonly games: Unique<StoredGame>[]; /** * The states persisted to local storage. They use Unique<T> so that when we * provide a state to the engine to load or get a state from the engine to * save, we are not accidentally sharing a reference to a live object. */ readonly states: Unique<StoredState>[]; readonly gameList: SettingsList; readonly stateList: SettingsList; readonly locale: Locale; constructor(parent: UiComponent, settings: StateSettings, locale: SettingOptions<SupportedLocale>); private _loadGames; private _storeGames; private _loadStates; private _storeStates; private _refreshGameList; private _refreshStateList; copyState(state?: EngineState): Promise<void>; copyGame(game?: KGSaveData): Promise<void>; /** * Request text input from the user, and try to import it. * * Things users might paste, in no specific order: * 1. Kittens Game Save, uncompressed line-agnostic JSON * 2. Kittens Game Save, lz-string compressed single-line UTF-8 string * 3. Kittens Game Save, lz-string compressed single-line UTF-16 string * 4. Kitten Scientists Settings, uncompressed line-agnostic JSON * 5. Kitten Scientists Settings, lz-string compressed single-line Base64 string * 6. Kitten Scientists Settings Export, multi-line string where all lines are either: * - #4, but must be single-line * - #5 * 7. Kitten Scientists Settings Export, multi-line string where each line is * an uncompressed JSON string serialization of: * { * label: "The label the user previously assigned to these settings.", * state: "The same options as #6", * timestamp: "Last time the settings were modified. As new Date().toISOString().", * } */ import(): void; storeGame(game?: KGSaveData, label?: string): string | null; storeState(state?: EngineState, label?: string): string | null; storeStateFactoryDefaults(): void; storeAutoSave(state: EngineState): void; exportStateAll(): void; loadGame(game: KGSaveData): Promise<void>; loadState(state: EngineState): void; loadAutoSave(): void; updateGame(game: Unique<StoredGame>, newGame: KGSaveData): void; updateState(state: Unique<StoredState>, newState: EngineState): void; deleteGame(game: Unique<StoredGame>, force?: boolean): void; deleteState(state: Unique<StoredState>, force?: boolean): void; private _destructiveActionPrevented; } //# sourceMappingURL=StateManagementUi.d.ts.map