From fbb9dc9fa05924a6125450339a438c6628a37e98 Mon Sep 17 00:00:00 2001 From: Jordan Irwin Date: Wed, 12 Jun 2024 16:50:54 -0700 Subject: [PATCH] Add support for viewport video capture using application menu --- .../ui/dialog/ApplicationMenuDialog.ts | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/js/stendhal/ui/dialog/ApplicationMenuDialog.ts b/src/js/stendhal/ui/dialog/ApplicationMenuDialog.ts index 01b04379c6e..03734bed84a 100644 --- a/src/js/stendhal/ui/dialog/ApplicationMenuDialog.ts +++ b/src/js/stendhal/ui/dialog/ApplicationMenuDialog.ts @@ -14,6 +14,15 @@ declare var stendhal: any; import { DialogContentComponent } from "../toolkit/DialogContentComponent"; import { singletons } from "../../SingletonRepo"; +import { ScreenCapture } from "../../util/ScreenCapture"; + + +interface MenuAction { + title: string, + action: string, + alt?: string, + condition?: Function +} export class ApplicationMenuDialog extends DialogContentComponent { @@ -37,7 +46,7 @@ export class ApplicationMenuDialog extends DialogContentComponent { title: "Logout", action: "logout" } - ] + ] as MenuAction[] }, { title: "Tools", @@ -46,11 +55,17 @@ 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", } - ] + ] as MenuAction[] }, { title: "Commands", @@ -71,7 +86,7 @@ export class ApplicationMenuDialog extends DialogContentComponent { title: "Travel Log", action: "progressstatus", } - ] + ] as MenuAction[] }, { title: "Help", @@ -100,7 +115,7 @@ export class ApplicationMenuDialog extends DialogContentComponent { title: "About", action: "about", } - ] + ] as MenuAction[] }, ] @@ -111,7 +126,12 @@ export class ApplicationMenuDialog extends DialogContentComponent { for (var i = 0; i < this.actions.length; i++) { content += "

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

" for (var j = 0; j < this.actions[i].children.length; j++) { - content += "
"; + const action = this.actions[i].children[j]; + let title = action.title; + if (action.alt && action.condition && action.condition()) { + title = action.alt; + } + content += "
"; } content += "
"; }