mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-01 05:33:31 +00:00
95b39daab9
## Description: This pr allows setting the pattern manually in using the dev console so we can see how it looks before uploading. To set it: set the b64 pattern in local storage with key: dev-pattern. This will override set pattern. Only works in singleplayer mode. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: evan
131 lines
3.0 KiB
TypeScript
131 lines
3.0 KiB
TypeScript
const PATTERN_KEY = "territoryPattern";
|
|
|
|
export class UserSettings {
|
|
get(key: string, defaultValue: boolean): boolean {
|
|
const value = localStorage.getItem(key);
|
|
if (!value) return defaultValue;
|
|
|
|
if (value === "true") return true;
|
|
|
|
if (value === "false") return false;
|
|
|
|
return defaultValue;
|
|
}
|
|
|
|
set(key: string, value: boolean) {
|
|
localStorage.setItem(key, value ? "true" : "false");
|
|
}
|
|
|
|
emojis() {
|
|
return this.get("settings.emojis", true);
|
|
}
|
|
|
|
performanceOverlay() {
|
|
return this.get("settings.performanceOverlay", false);
|
|
}
|
|
|
|
alertFrame() {
|
|
return this.get("settings.alertFrame", true);
|
|
}
|
|
|
|
anonymousNames() {
|
|
return this.get("settings.anonymousNames", false);
|
|
}
|
|
|
|
lobbyIdVisibility() {
|
|
return this.get("settings.lobbyIdVisibility", true);
|
|
}
|
|
|
|
fxLayer() {
|
|
return this.get("settings.specialEffects", true);
|
|
}
|
|
|
|
structureSprites() {
|
|
return this.get("settings.structureSprites", true);
|
|
}
|
|
|
|
darkMode() {
|
|
return this.get("settings.darkMode", false);
|
|
}
|
|
|
|
leftClickOpensMenu() {
|
|
return this.get("settings.leftClickOpensMenu", false);
|
|
}
|
|
|
|
territoryPatterns() {
|
|
return this.get("settings.territoryPatterns", true);
|
|
}
|
|
|
|
focusLocked() {
|
|
return false;
|
|
// TODO: renable when performance issues are fixed.
|
|
this.get("settings.focusLocked", true);
|
|
}
|
|
|
|
toggleLeftClickOpenMenu() {
|
|
this.set("settings.leftClickOpensMenu", !this.leftClickOpensMenu());
|
|
}
|
|
|
|
toggleFocusLocked() {
|
|
this.set("settings.focusLocked", !this.focusLocked());
|
|
}
|
|
|
|
toggleEmojis() {
|
|
this.set("settings.emojis", !this.emojis());
|
|
}
|
|
|
|
togglePerformanceOverlay() {
|
|
this.set("settings.performanceOverlay", !this.performanceOverlay());
|
|
}
|
|
|
|
toggleAlertFrame() {
|
|
this.set("settings.alertFrame", !this.alertFrame());
|
|
}
|
|
|
|
toggleRandomName() {
|
|
this.set("settings.anonymousNames", !this.anonymousNames());
|
|
}
|
|
|
|
toggleLobbyIdVisibility() {
|
|
this.set("settings.lobbyIdVisibility", !this.lobbyIdVisibility());
|
|
}
|
|
|
|
toggleFxLayer() {
|
|
this.set("settings.specialEffects", !this.fxLayer());
|
|
}
|
|
|
|
toggleStructureSprites() {
|
|
this.set("settings.structureSprites", !this.structureSprites());
|
|
}
|
|
|
|
toggleTerritoryPatterns() {
|
|
this.set("settings.territoryPatterns", !this.territoryPatterns());
|
|
}
|
|
|
|
toggleDarkMode() {
|
|
this.set("settings.darkMode", !this.darkMode());
|
|
if (this.darkMode()) {
|
|
document.documentElement.classList.add("dark");
|
|
} else {
|
|
document.documentElement.classList.remove("dark");
|
|
}
|
|
}
|
|
|
|
// For development only. Used for testing patterns, set in the console manually.
|
|
getDevOnlyPattern(): string | undefined {
|
|
return localStorage.getItem("dev-pattern") ?? undefined;
|
|
}
|
|
|
|
getSelectedPatternName(): string | undefined {
|
|
return localStorage.getItem(PATTERN_KEY) ?? undefined;
|
|
}
|
|
|
|
setSelectedPatternName(base64: string | undefined): void {
|
|
if (base64 === undefined) {
|
|
localStorage.removeItem(PATTERN_KEY);
|
|
} else {
|
|
localStorage.setItem(PATTERN_KEY, base64);
|
|
}
|
|
}
|
|
}
|