Skip to content

Commit

Permalink
Use Debug class for marking settings & touch for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
AntumDeluge committed Jun 12, 2024
1 parent e3188b3 commit 5a8add7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 26 deletions.
12 changes: 6 additions & 6 deletions src/js/stendhal/action/DebugAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
Expand Down
17 changes: 0 additions & 17 deletions src/js/stendhal/ui/TouchHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
}
6 changes: 3 additions & 3 deletions src/js/stendhal/ui/dialog/SettingsDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ 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;
export class SettingsDialog extends TabDialogContentComponent {

public readonly storedStates: {[index: string]: string};
private readonly initialStates: {[index: string]: string};
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 5a8add7

Please sign in to comment.