minesweeper/src/main/js/Preferences.ts

46 lines
1.1 KiB
TypeScript

import {BasicIconFont, IconFont} from "./Display";
// @ts-ignore
const {Storage, LocalStorage} = window.fwdekker.storage;
/**
* The player's preferences.
*
* Contains a mixture of persistent and transient preferences.
*/
export class Preferences {
private readonly storage: Storage;
/**
* Constructs a new preferences container.
*
* @param storage the underlying object to store preferences in
*/
constructor(storage: Storage = new LocalStorage("/tools/minesweeper//preferences")) {
this.storage = storage;
}
/**
* The font to be used when drawing the display.
*/
font: IconFont = new BasicIconFont();
get marksEnabled(): boolean {
return this.storage.getBoolean("marksEnabled", true);
}
set marksEnabled(value: boolean) {
this.storage.setBoolean("marksEnabled", value);
}
get showTooManyFlagsHints(): boolean {
return this.storage.getBoolean("showTooManyFlagsHints", true);
}
set showTooManyFlagsHints(value: boolean) {
this.storage.setBoolean("showTooManyFlagsHints", value);
}
}