62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
const {LocalStorage} = (window as any).fwdekker.storage;
|
|
|
|
import {BasicIconFont, IconFont} from "./Display";
|
|
|
|
|
|
/**
|
|
* 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 showChordableHints(): boolean {
|
|
return this.storage.getBoolean("showChordableHints", false);
|
|
}
|
|
|
|
set showChordableHints(value: boolean) {
|
|
this.storage.setBoolean("showChordableHints", value);
|
|
}
|
|
|
|
get showAllNeighborsAreMinesHints(): boolean {
|
|
return this.storage.getBoolean("showAllNeighborsAreMinesHints", false);
|
|
}
|
|
|
|
set showAllNeighborsAreMinesHints(value: boolean) {
|
|
this.storage.setBoolean("showAllNeighborsAreMinesHints", value);
|
|
}
|
|
|
|
get showTooManyFlagsHints(): boolean {
|
|
return this.storage.getBoolean("showTooManyFlagsHints", true);
|
|
}
|
|
|
|
set showTooManyFlagsHints(value: boolean) {
|
|
this.storage.setBoolean("showTooManyFlagsHints", value);
|
|
}
|
|
}
|