Use Debug class for marking settings & touch for debugging

This commit is contained in:
Jordan Irwin 2024-06-12 16:30:36 -07:00
parent e3188b3986
commit 5a8add7e5d
No known key found for this signature in database
GPG key ID: E3E358C2F44C290A
3 changed files with 9 additions and 26 deletions

View file

@ -13,14 +13,15 @@ import { singletons } from "../SingletonRepo";
import { ui } from "../ui/UI";
import { UIComponentEnum } from "../ui/UIComponentEnum";
import { SettingsDialog } from "../ui/dialog/SettingsDialog";
import { FloatingWindow } from "../ui/toolkit/FloatingWindow";
import { SlashAction } from "./SlashAction";
import { Chat } from "../util/Chat";
import { ShowFloatingWindowComponent } from "../ui/component/ShowFloatingWindowComponent";
import { Panel } from "ui/toolkit/Panel";
import { Chat } from "../util/Chat";
import { Debug } from "../util/Debug";
declare var marauroa: any;
declare var stendhal: any;
@ -46,11 +47,10 @@ export class DebugAction extends SlashAction {
} else if (params[0] === "log") {
Chat.debugLogEnabled = true;
} else if (params[0] === "settings") {
SettingsDialog.debugging = !SettingsDialog.debugging;
Chat.log("client", "experimental settings " + (SettingsDialog.debugging ? "enabled" : "disabled"));
Chat.log("client", "Experimental settings " + (Debug.toggle("settings") ? "enabled"
: "disabled"));
} else if (params[0] === "touch") {
stendhal.ui.touch.setDebuggingEnabled(!stendhal.ui.touch.isDebuggingEnabled());
Chat.log("client", "touch debugging " + (stendhal.ui.touch.isDebuggingEnabled() ? "enabled" : "disabled"));
Chat.log("client", "Touch debugging " + (Debug.toggle("touch") ? "enabled" : "disabled"));
}
return true;
}

View file

@ -36,9 +36,6 @@ export class TouchHandler {
/** Number of pixels touch can move before being vetoed as a long touch or double tap. */
private readonly moveThreshold = 16;
/** Property for debugging. */
private debugging = false;
/** Singleton instance. */
private static instance: TouchHandler;
@ -148,18 +145,4 @@ export class TouchHandler {
holding(): boolean {
return this.held;
}
/**
* Sets debugging property for touch events.
*/
setDebuggingEnabled(enable: boolean) {
this.debugging = enable;
}
/**
* Checks if debugging is enabled for touch events.
*/
isDebuggingEnabled(): boolean {
return this.debugging;
}
}

View file

@ -20,11 +20,11 @@ import { TabDialogContentComponent } from "../toolkit/TabDialogContentComponent"
import { Layout } from "../../data/enum/Layout";
import { Debug } from "../../util/Debug";
export class SettingsDialog extends TabDialogContentComponent {
public static debugging = false;
public readonly storedStates: {[index: string]: string};
private readonly initialStates: {[index: string]: string};
@ -108,7 +108,7 @@ export class SettingsDialog extends TabDialogContentComponent {
label.innerHTML = "";
label.appendChild(checkbox);
label.appendChild(text);
if (!SettingsDialog.debugging) {
if (!Debug.isActive("settings")) {
// hide if settings debugging is not enabled
checkbox.disabled = true;
checkbox.style.setProperty("display", "none");