Squashed commit of the following:

commit 2faed50e5c2165647e389d794de673038d56241e
Author: redphx <96280+redphx@users.noreply.github.com>
Date:   Fri May 24 18:09:25 2024 +0700

    Make shortcuts work with controller

commit b8f6c503ba7969de3a232644d3f6b53532a4b7bb
Author: redphx <96280+redphx@users.noreply.github.com>
Date:   Fri May 24 17:01:15 2024 +0700

    Update translations

commit 6f6c0899e5a09cd5534e06a9e272bf78c74536dc
Author: redphx <96280+redphx@users.noreply.github.com>
Date:   Fri May 24 17:00:50 2024 +0700

    Preload PrompFont

commit 1bf0f2b9dae77890d35091bed970b942c4d61fbc
Author: redphx <96280+redphx@users.noreply.github.com>
Date:   Fri May 24 07:08:05 2024 +0700

    Render Controller shortcuts settings

commit 2f24965c73a941be2ebc8a3509dc540a47b4e38d
Author: redphx <96280+redphx@users.noreply.github.com>
Date:   Thu May 23 17:21:55 2024 +0700

    Fix not able to capture screenshot after switching games

commit 6ac791e2dfb17215ee82d449047d0cd11d185c42
Author: redphx <96280+redphx@users.noreply.github.com>
Date:   Thu May 23 17:11:19 2024 +0700

    Hijack the Home button
This commit is contained in:
redphx
2024-05-24 18:10:38 +07:00
parent 22e29e1d92
commit 07c1757237
17 changed files with 606 additions and 58 deletions

View File

@@ -3,21 +3,24 @@ import { CE } from "./html";
export class Screenshot {
static setup() {
const currentStream = STATES.currentStream;
if (!currentStream.$screenshotCanvas) {
currentStream.$screenshotCanvas = CE<HTMLCanvasElement>('canvas', {'class': 'bx-gone'});
static #$canvas: HTMLCanvasElement;
static #canvasContext: CanvasRenderingContext2D;
currentStream.screenshotCanvasContext = currentStream.$screenshotCanvas.getContext('2d', {
alpha: false,
willReadFrequently: false,
});
static setup() {
if (Screenshot.#$canvas) {
return;
}
// document.documentElement.appendChild(currentStream.$screenshotCanvas!);
Screenshot.#$canvas = CE<HTMLCanvasElement>('canvas', {'class': 'bx-gone'});
Screenshot.#canvasContext = Screenshot.#$canvas.getContext('2d', {
alpha: false,
willReadFrequently: false,
})!;
}
static updateCanvasSize(width: number, height: number) {
const $canvas = STATES.currentStream.$screenshotCanvas;
const $canvas = Screenshot.#$canvas;
if ($canvas) {
$canvas.width = width;
$canvas.height = height;
@@ -25,7 +28,7 @@ export class Screenshot {
}
static updateCanvasFilters(filters: string) {
STATES.currentStream.screenshotCanvasContext && (STATES.currentStream.screenshotCanvasContext.filter = filters);
Screenshot.#canvasContext.filter = filters;
}
private static onAnimationEnd(e: Event) {
@@ -35,7 +38,7 @@ export class Screenshot {
static takeScreenshot(callback?: any) {
const currentStream = STATES.currentStream;
const $video = currentStream.$video;
const $canvas = currentStream.$screenshotCanvas;
const $canvas = Screenshot.#$canvas;
if (!$video || !$canvas) {
return;
}
@@ -43,7 +46,7 @@ export class Screenshot {
$video.parentElement?.addEventListener('animationend', this.onAnimationEnd);
$video.parentElement?.classList.add('bx-taking-screenshot');
const canvasContext = currentStream.screenshotCanvasContext!;
const canvasContext = Screenshot.#canvasContext;
canvasContext.drawImage($video, 0, 0, $canvas.width, $canvas.height);
// Get data URL and pass to parent app