From 36b42f5baf2b9ca3ddb6afb2f349fafdc174a4d2 Mon Sep 17 00:00:00 2001 From: Dimava Date: Thu, 28 May 2020 18:40:40 +0300 Subject: [PATCH] add debug settings to settings menu (does not work) --- src/js/profile/application_settings.js | 8 ++++++++ src/js/profile/setting_types.js | 5 +++-- src/js/states/settings.js | 19 ++++++++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/js/profile/application_settings.js b/src/js/profile/application_settings.js index 17563ab9..200c5bef 100644 --- a/src/js/profile/application_settings.js +++ b/src/js/profile/application_settings.js @@ -2,6 +2,7 @@ import { Application } from "../application"; /* typehints:end */ +import { globalConfig } from "../core/config"; import { ReadWriteProxy } from "../core/read_write_proxy"; import { BoolSetting, EnumSetting, BaseSetting } from "./setting_types"; import { createLogger } from "../core/logging"; @@ -15,6 +16,7 @@ const logger = createLogger("application_settings"); const categoryGame = "game"; const categoryApp = "app"; +const categoryDebug = "debug"; export const uiScales = [ { @@ -200,6 +202,12 @@ export const allApplicationSettings = [ new BoolSetting("offerHints", categoryGame, (app, value) => {}), ]; +/** @type {Array} */ +export const allDebugSettings = []; +for (const k in globalConfig.debug) { + allDebugSettings.push(new BoolSetting(k, categoryDebug, (app, value) => globalConfig.debug[k] = value)); +} + export function getApplicationSettingById(id) { return allApplicationSettings.find(setting => setting.id === id); } diff --git a/src/js/profile/setting_types.js b/src/js/profile/setting_types.js index 3b1b3dd7..fe95bbc5 100644 --- a/src/js/profile/setting_types.js +++ b/src/js/profile/setting_types.js @@ -187,18 +187,19 @@ export class BoolSetting extends BaseSetting { } getHtml() { + const label = T.settings.labels[this.id] || {title : this.id}; return `
${this.enabled ? "" : standaloneOnlySettingHtml}
- +
- ${T.settings.labels[this.id].description} + ${label.description}
`; } diff --git a/src/js/states/settings.js b/src/js/states/settings.js index 4dce1fa3..0388211e 100644 --- a/src/js/states/settings.js +++ b/src/js/states/settings.js @@ -1,6 +1,7 @@ +import { globalConfig } from "../core/config"; import { TextualGameState } from "../core/textual_game_state"; import { formatSecondsToTimeAgo } from "../core/utils"; -import { allApplicationSettings } from "../profile/application_settings"; +import { allApplicationSettings, allDebugSettings } from "../profile/application_settings"; import { T } from "../translations"; export class SettingsState extends TextualGameState { @@ -54,6 +55,22 @@ export class SettingsState extends TextualGameState { html += setting.getHtml(); } + if (globalConfig.debug.showDebugSettings) { + for (let i = 0; i < allDebugSettings.length; ++i) { + const setting = allDebugSettings[i]; + + if (setting.categoryId !== lastCategory) { + lastCategory = setting.categoryId; + if (i !== 0) { + html += ""; + } + html += `${T.settings.categories[lastCategory]}`; + html += "
"; + } + + html += setting.getHtml(); + } + } if (lastCategory) { html += "
"; }