Skip to content

Commit

Permalink
Hide screen capture behing debugging property
Browse files Browse the repository at this point in the history
  • Loading branch information
AntumDeluge committed Jul 15, 2024
1 parent fbb9dc9 commit 6ca668b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/js/stendhal/SlashActionRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";


/**
Expand Down Expand Up @@ -133,7 +134,7 @@ export class SlashActionRepo {
"TOOLS": [
"progressstatus",
"screenshot",
"screencap",
//"screencap",
"atlas",
"beginnersguide"
],
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions src/js/stendhal/action/DebugAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
12 changes: 12 additions & 0 deletions src/js/stendhal/ui/dialog/ApplicationMenuDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";


Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 += "<div class=\"inlineblock buttonColumn\"><h4 class=\"menugroup\">" + stendhal.ui.html.esc(this.actions[i].title) + "</h4>"
Expand Down
6 changes: 6 additions & 0 deletions src/js/stendhal/util/ScreenCapture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
***************************************************************************/

import { Chat } from "./Chat";
import { Debug } from "./Debug";
import { DownloadUtil } from "./DownloadUtil";


Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 6ca668b

Please sign in to comment.