diff --git a/src/js/stendhal/SlashActionRepo.ts b/src/js/stendhal/SlashActionRepo.ts index 78729cf4b5..97b9ffd77b 100644 --- a/src/js/stendhal/SlashActionRepo.ts +++ b/src/js/stendhal/SlashActionRepo.ts @@ -30,6 +30,7 @@ import { UIComponentEnum } from "./ui/UIComponentEnum"; import { ChatLogComponent } from "./ui/component/ChatLogComponent"; import { Chat } from "./util/Chat"; +import { Debug } from "./util/Debug"; /** @@ -133,7 +134,7 @@ export class SlashActionRepo { "TOOLS": [ "progressstatus", "screenshot", - "screencap", + //"screencap", "atlas", "beginnersguide" ], @@ -222,6 +223,11 @@ export class SlashActionRepo { {type: "group", sparams: "status"} ] }; + + if (Debug.isActive("screencap")) { + grouping["TOOLS"].push("screencap"); + } + return { info: [ "For a detailed reference, visit #https://stendhalgame.org/wiki/Stendhal_Manual", diff --git a/src/js/stendhal/action/DebugAction.ts b/src/js/stendhal/action/DebugAction.ts index 3d93fc500b..148a303d82 100644 --- a/src/js/stendhal/action/DebugAction.ts +++ b/src/js/stendhal/action/DebugAction.ts @@ -51,6 +51,10 @@ export class DebugAction extends SlashAction { : "disabled")); } else if (params[0] === "touch") { Chat.log("client", "Touch debugging " + (Debug.toggle("touch") ? "enabled" : "disabled")); + } else if (params[0] === "screencap") { + Debug.setActive("screencap", !Debug.isActive("screencap")); + Chat.log("client", "Screen capture debugging " + (Debug.isActive("screencap") ? "enabled" + : "disabled")); } return true; } diff --git a/src/js/stendhal/ui/dialog/ApplicationMenuDialog.ts b/src/js/stendhal/ui/dialog/ApplicationMenuDialog.ts index 03734bed84..4cbaa12d5d 100644 --- a/src/js/stendhal/ui/dialog/ApplicationMenuDialog.ts +++ b/src/js/stendhal/ui/dialog/ApplicationMenuDialog.ts @@ -14,6 +14,7 @@ declare var stendhal: any; import { DialogContentComponent } from "../toolkit/DialogContentComponent"; import { singletons } from "../../SingletonRepo"; +import { Debug } from "../../util/Debug"; import { ScreenCapture } from "../../util/ScreenCapture"; @@ -55,12 +56,14 @@ export class ApplicationMenuDialog extends DialogContentComponent { title: "Take Screenshot", action: "screenshot", }, + /* { title: "Capture Video", alt: "Stop Capture", condition: ScreenCapture.isActive, action: "screencap" }, + */ { title: "Settings", action: "settings", @@ -122,6 +125,15 @@ export class ApplicationMenuDialog extends DialogContentComponent { constructor() { super("applicationmenudialog-template"); + if (Debug.isActive("screencap")) { + this.actions[1].children.push({ + title: "Capture Video", + alt: "Stop Capture", + condition: ScreenCapture.isActive, + action: "screencap" + }); + } + var content = ""; for (var i = 0; i < this.actions.length; i++) { content += "

" + stendhal.ui.html.esc(this.actions[i].title) + "

" diff --git a/src/js/stendhal/util/ScreenCapture.ts b/src/js/stendhal/util/ScreenCapture.ts index ee092794e7..ed100a8527 100644 --- a/src/js/stendhal/util/ScreenCapture.ts +++ b/src/js/stendhal/util/ScreenCapture.ts @@ -11,6 +11,7 @@ ***************************************************************************/ import { Chat } from "./Chat"; +import { Debug } from "./Debug"; import { DownloadUtil } from "./DownloadUtil"; @@ -61,6 +62,11 @@ export class ScreenCapture { * Sound manager from which to record audio. */ start(canvas: HTMLCanvasElement, audio?: AudioContext) { + if (!Debug.isActive("screencap")) { + Chat.log("client", "Screen capture debugging is disabled"); + return; + } + if (!this.def) { Chat.log("error", "No suitable video codec available"); return;