mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-02-12 02:49:20 +00:00
add debug settings to settings menu (does not work)
This commit is contained in:
parent
a0c732d1f0
commit
36b42f5baf
@ -2,6 +2,7 @@
|
|||||||
import { Application } from "../application";
|
import { Application } from "../application";
|
||||||
/* typehints:end */
|
/* typehints:end */
|
||||||
|
|
||||||
|
import { globalConfig } from "../core/config";
|
||||||
import { ReadWriteProxy } from "../core/read_write_proxy";
|
import { ReadWriteProxy } from "../core/read_write_proxy";
|
||||||
import { BoolSetting, EnumSetting, BaseSetting } from "./setting_types";
|
import { BoolSetting, EnumSetting, BaseSetting } from "./setting_types";
|
||||||
import { createLogger } from "../core/logging";
|
import { createLogger } from "../core/logging";
|
||||||
@ -15,6 +16,7 @@ const logger = createLogger("application_settings");
|
|||||||
|
|
||||||
const categoryGame = "game";
|
const categoryGame = "game";
|
||||||
const categoryApp = "app";
|
const categoryApp = "app";
|
||||||
|
const categoryDebug = "debug";
|
||||||
|
|
||||||
export const uiScales = [
|
export const uiScales = [
|
||||||
{
|
{
|
||||||
@ -200,6 +202,12 @@ export const allApplicationSettings = [
|
|||||||
new BoolSetting("offerHints", categoryGame, (app, value) => {}),
|
new BoolSetting("offerHints", categoryGame, (app, value) => {}),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/** @type {Array<BaseSetting>} */
|
||||||
|
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) {
|
export function getApplicationSettingById(id) {
|
||||||
return allApplicationSettings.find(setting => setting.id === id);
|
return allApplicationSettings.find(setting => setting.id === id);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -187,18 +187,19 @@ export class BoolSetting extends BaseSetting {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getHtml() {
|
getHtml() {
|
||||||
|
const label = T.settings.labels[this.id] || {title : this.id};
|
||||||
return `
|
return `
|
||||||
<div class="setting cardbox ${this.enabled ? "enabled" : "disabled"}">
|
<div class="setting cardbox ${this.enabled ? "enabled" : "disabled"}">
|
||||||
${this.enabled ? "" : standaloneOnlySettingHtml}
|
${this.enabled ? "" : standaloneOnlySettingHtml}
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label>${T.settings.labels[this.id].title}</label>
|
<label>${label.title}</label>
|
||||||
<div class="value checkbox checked" data-setting="${this.id}">
|
<div class="value checkbox checked" data-setting="${this.id}">
|
||||||
<span class="knob"></span>
|
<span class="knob"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="desc">
|
<div class="desc">
|
||||||
${T.settings.labels[this.id].description}
|
${label.description}
|
||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
|
import { globalConfig } from "../core/config";
|
||||||
import { TextualGameState } from "../core/textual_game_state";
|
import { TextualGameState } from "../core/textual_game_state";
|
||||||
import { formatSecondsToTimeAgo } from "../core/utils";
|
import { formatSecondsToTimeAgo } from "../core/utils";
|
||||||
import { allApplicationSettings } from "../profile/application_settings";
|
import { allApplicationSettings, allDebugSettings } from "../profile/application_settings";
|
||||||
import { T } from "../translations";
|
import { T } from "../translations";
|
||||||
|
|
||||||
export class SettingsState extends TextualGameState {
|
export class SettingsState extends TextualGameState {
|
||||||
@ -54,6 +55,22 @@ export class SettingsState extends TextualGameState {
|
|||||||
|
|
||||||
html += setting.getHtml();
|
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 += "</div>";
|
||||||
|
}
|
||||||
|
html += `<strong class="categoryLabel">${T.settings.categories[lastCategory]}</strong>`;
|
||||||
|
html += "<div class='settingsContainer'>";
|
||||||
|
}
|
||||||
|
|
||||||
|
html += setting.getHtml();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (lastCategory) {
|
if (lastCategory) {
|
||||||
html += "</div>";
|
html += "</div>";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user