This commit is contained in:
redphx
2024-12-05 17:10:39 +07:00
parent c836e33f7b
commit 9199351af1
207 changed files with 9833 additions and 6953 deletions

View File

@@ -1,18 +1,21 @@
import { PrefKey } from "@/enums/pref-keys";
import { getPref } from "@/utils/settings-storages/global-settings-storage";
import { limitVideoPlayerFps } from "../stream/stream-settings-utils";
import { BxEvent } from "@/utils/bx-event";
export class RendererShortcut {
static toggleVisibility(): boolean {
static toggleVisibility() {
const $mediaContainer = document.querySelector('#game-stream div[data-testid="media-container"]');
if (!$mediaContainer) {
return true;
BxEvent.dispatch(window, BxEvent.VIDEO_VISIBILITY_CHANGED, { isShowing: true });
return;
}
$mediaContainer.classList.toggle('bx-gone');
const isShowing = !$mediaContainer.classList.contains('bx-gone');
// Switch FPS
limitVideoPlayerFps(isShowing ? getPref(PrefKey.VIDEO_MAX_FPS) : 0);
return isShowing;
BxEvent.dispatch(window, BxEvent.VIDEO_VISIBILITY_CHANGED, { isShowing });
}
}

View File

@@ -0,0 +1,59 @@
import { PrefKey } from "@/enums/pref-keys";
import { ShortcutAction } from "@/enums/shortcut-actions";
import { AppInterface, STATES } from "@/utils/global";
import { getPref } from "@/utils/settings-storages/global-settings-storage";
import { t } from "@/utils/translation";
type ShortcutActions = {
[key: string]: {
[key in ShortcutAction]?: string[];
};
};
export const SHORTCUT_ACTIONS: ShortcutActions = {
// Script
[t('better-xcloud')]: {
[ShortcutAction.BETTER_XCLOUD_SETTINGS_SHOW]: [t('settings'), t('show')],
},
// Device
...(!!AppInterface ? {
[t('device')]: {
[ShortcutAction.DEVICE_SOUND_TOGGLE]: [t('sound'), t('toggle')],
[ShortcutAction.DEVICE_VOLUME_INC]: [t('volume'), t('increase')],
[ShortcutAction.DEVICE_VOLUME_DEC]: [t('volume'), t('decrease')],
[ShortcutAction.DEVICE_BRIGHTNESS_INC]: [t('brightness'), t('increase')],
[ShortcutAction.DEVICE_BRIGHTNESS_DEC]: [t('brightness'), t('decrease')],
},
} : {}),
// Stream
[t('stream')]: {
[ShortcutAction.STREAM_SCREENSHOT_CAPTURE]: [t('take-screenshot')],
[ShortcutAction.STREAM_VIDEO_TOGGLE]: [t('video'), t('toggle')],
[ShortcutAction.STREAM_SOUND_TOGGLE]: [t('sound'), t('toggle')],
...(getPref(PrefKey.AUDIO_VOLUME_CONTROL_ENABLED) ? {
[ShortcutAction.STREAM_VOLUME_INC]: [t('volume'), t('increase')],
[ShortcutAction.STREAM_VOLUME_DEC]: [t('volume'), t('decrease')],
} : {}),
[ShortcutAction.STREAM_MENU_SHOW]: [t('menu'), t('show')],
[ShortcutAction.STREAM_STATS_TOGGLE]: [t('stats'), t('show-hide')],
[ShortcutAction.STREAM_MICROPHONE_TOGGLE]: [t('microphone'), t('toggle')],
},
// MKB
...(STATES.browser.capabilities.mkb ? {
[t('mouse-and-keyboard')]: {
[ShortcutAction.MKB_TOGGLE]: [t('toggle')],
},
} : {}),
// Other
[t('other')]: {
[ShortcutAction.TRUE_ACHIEVEMENTS_OPEN]: [t('true-achievements'), t('show')],
},
} as const;

View File

@@ -13,11 +13,11 @@ export enum SpeakerState {
export class SoundShortcut {
static adjustGainNodeVolume(amount: number): number {
if (!getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL)) {
if (!getPref(PrefKey.AUDIO_VOLUME_CONTROL_ENABLED)) {
return 0;
}
const currentValue = getPref(PrefKey.AUDIO_VOLUME);
const currentValue = getPref<AudioVolume>(PrefKey.AUDIO_VOLUME);
let nearestValue: number;
if (amount > 0) { // Increase
@@ -47,9 +47,9 @@ export class SoundShortcut {
}
static muteUnmute() {
if (getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL) && STATES.currentStream.audioGainNode) {
if (getPref(PrefKey.AUDIO_VOLUME_CONTROL_ENABLED) && STATES.currentStream.audioGainNode) {
const gainValue = STATES.currentStream.audioGainNode.gain.value;
const settingValue = getPref(PrefKey.AUDIO_VOLUME);
const settingValue = getPref<AudioVolume>(PrefKey.AUDIO_VOLUME);
let targetValue: number;
if (settingValue === 0) { // settingValue is 0 => set to 100
@@ -73,7 +73,7 @@ export class SoundShortcut {
BxEvent.dispatch(window, BxEvent.SPEAKER_STATE_CHANGED, {
speakerState: targetValue === 0 ? SpeakerState.MUTED : SpeakerState.ENABLED,
})
});
return;
}