1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Dark mode support and much other stuff

This commit is contained in:
tobspr
2020-05-17 13:24:47 +02:00
parent 53386e1cd9
commit 68769cb7ef
35 changed files with 243 additions and 83 deletions

View File

@@ -6,7 +6,7 @@ import { ReadWriteProxy } from "../core/read_write_proxy";
import { BoolSetting, EnumSetting, BaseSetting } from "./setting_types";
import { createLogger } from "../core/logging";
import { ExplainedResult } from "../core/explained_result";
import { THEMES } from "../game/theme";
import { THEMES, THEME, applyGameTheme } from "../game/theme";
const logger = createLogger("application_settings");
@@ -68,26 +68,14 @@ export const allApplicationSettings = [
},
G_IS_STANDALONE
),
new EnumSetting("theme", {
options: Object.keys(THEMES),
valueGetter: theme => theme,
textGetter: theme => theme.substr(0, 1).toUpperCase() + theme.substr(1),
category: categoryApp,
restartRequired: false,
changeCb:
/**
* @param {Application} app
*/
(app, id) => document.body.setAttribute("data-theme", id),
}),
new BoolSetting(
"soundsMuted",
categoryApp,
/**
* @param {Application} app
*/
(app, value) => app.sound.setSoundsMuted(value),
false
(app, value) => app.sound.setSoundsMuted(value)
),
new BoolSetting(
"musicMuted",
@@ -95,11 +83,25 @@ export const allApplicationSettings = [
/**
* @param {Application} app
*/
(app, value) => app.sound.setMusicMuted(value),
false
(app, value) => app.sound.setMusicMuted(value)
),
// GAME
new EnumSetting("theme", {
options: Object.keys(THEMES),
valueGetter: theme => theme,
textGetter: theme => theme.substr(0, 1).toUpperCase() + theme.substr(1),
category: categoryGame,
restartRequired: false,
changeCb:
/**
* @param {Application} app
*/
(app, id) => {
applyGameTheme(id);
document.body.setAttribute("data-theme", id);
},
}),
];
export function getApplicationSettingById(id) {