Optimize + refactor code

This commit is contained in:
redphx
2024-10-21 20:50:12 +07:00
parent 075b15aa48
commit de76364a46
44 changed files with 1794 additions and 1274 deletions

View File

@@ -2,7 +2,7 @@ import { BxIcon } from "@utils/bx-icon";
import { createButton, ButtonStyle } from "@utils/html";
import { BaseGameBarAction } from "./action-base";
import { t } from "@utils/translation";
import { Screenshot } from "@/utils/screenshot";
import { ScreenshotManager } from "@/utils/screenshot-manager";
export class ScreenshotAction extends BaseGameBarAction {
$content: HTMLElement;
@@ -20,6 +20,6 @@ export class ScreenshotAction extends BaseGameBarAction {
onClick(e: Event): void {
super.onClick(e);
Screenshot.takeScreenshot();
ScreenshotManager.getInstance().takeScreenshot();
}
}

View File

@@ -18,6 +18,6 @@ export class TrueAchievementsAction extends BaseGameBarAction {
onClick(e: Event) {
super.onClick(e);
TrueAchievements.open(false);
TrueAchievements.getInstance().open(false);
}
}

View File

@@ -11,11 +11,13 @@ import { getPref, StreamTouchController, type GameBarPosition } from "@/utils/se
import { TrueAchievementsAction } from "./action-true-achievements";
import { SpeakerAction } from "./action-speaker";
import { RendererAction } from "./action-renderer";
import { BxLogger } from "@/utils/bx-logger";
export class GameBar {
private static instance: GameBar;
public static getInstance = () => GameBar.instance ?? (GameBar.instance = new GameBar());
private readonly LOG_TAG = 'GameBar';
private static readonly VISIBLE_DURATION = 2000;
@@ -27,6 +29,8 @@ export class GameBar {
private actions: BaseGameBarAction[] = [];
private constructor() {
BxLogger.info(this.LOG_TAG, 'constructor()');
let $container;
const position = getPref(PrefKey.GAME_BAR_POSITION) as GameBarPosition;