Files
OpenFrontIO/src/core/game/UserSettings.ts
T
ilan schemoul d6b29a655c feat: left click now opens menu (to avoid misclicks), shift+left click is attack
It happens very frequently that I misclick (meant to click on neighbor,
mean to click modal, sensitive touchpad and many others) and ruin my
game (and another player's). So by default left click opens the menu. As
the attack button is in the middle you can just double click to attack.
You can also shift+click to attack.
I have updated the Help modal to document all that + the existing (just
discovered in the code) ctrl+click to open build menu.
2025-03-02 17:56:14 +01:00

40 lines
867 B
TypeScript

export class UserSettings {
get(key: string, defaultValue: boolean) {
const value = localStorage.getItem(key);
if (!value) return defaultValue;
if (value === "true") return true;
if (value === "false") return false;
}
set(key: string, value: boolean) {
localStorage.setItem(key, value ? "true" : "false");
document.body.classList.toggle("dark");
}
emojis() {
return this.get("settings.emojis", true);
}
darkMode() {
return this.get("settings.darkMode", false);
}
leftClickOpensMenu() {
return this.get("settings.leftClickOpensMenu", false);
}
toggleLeftClickOpenMenu() {
this.set("settings.leftClickOpensMenu", !this.leftClickOpensMenu());
}
toggleEmojis() {
this.set("settings.emojis", !this.emojis());
}
toggleDarkMode() {
this.set("settings.darkMode", !this.darkMode());
}
}