mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-07 05:38:27 +02:00
Move bx-events/exposed/flags files to utils/
This commit is contained in:
48
src/utils/bx-event.ts
Normal file
48
src/utils/bx-event.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { AppInterface } from "./global";
|
||||
|
||||
export enum BxEvent {
|
||||
JUMP_BACK_IN_READY = 'bx-jump-back-in-ready',
|
||||
POPSTATE = 'bx-popstate',
|
||||
|
||||
STREAM_LOADING = 'bx-stream-loading',
|
||||
STREAM_STARTING = 'bx-stream-starting',
|
||||
STREAM_STARTED = 'bx-stream-started',
|
||||
STREAM_PLAYING = 'bx-stream-playing',
|
||||
STREAM_STOPPED = 'bx-stream-stopped',
|
||||
STREAM_ERROR_PAGE = 'bx-stream-error-page',
|
||||
|
||||
STREAM_MENU_SHOWN = 'bx-stream-menu-shown',
|
||||
STREAM_MENU_HIDDEN = 'bx-stream-menu-hidden',
|
||||
|
||||
STREAM_WEBRTC_CONNECTED = 'bx-stream-webrtc-connected',
|
||||
STREAM_WEBRTC_DISCONNECTED = 'bx-stream-webrtc-disconnected',
|
||||
|
||||
CUSTOM_TOUCH_LAYOUTS_LOADED = 'bx-custom-touch-layouts-loaded',
|
||||
|
||||
REMOTE_PLAY_READY = 'bx-remote-play-ready',
|
||||
REMOTE_PLAY_FAILED = 'bx-remote-play-failed',
|
||||
|
||||
XCLOUD_SERVERS_READY = 'bx-servers-ready',
|
||||
|
||||
DATA_CHANNEL_CREATED = 'bx-data-channel-created',
|
||||
}
|
||||
|
||||
export namespace BxEvent {
|
||||
export function dispatch(target: HTMLElement | Window, eventName: string, data?: any) {
|
||||
if (!eventName) {
|
||||
alert('BxEvent.dispatch(): eventName is null');
|
||||
return;
|
||||
}
|
||||
|
||||
const event = new Event(eventName);
|
||||
|
||||
if (data) {
|
||||
for (const key in data) {
|
||||
(event as any)[key] = data[key];
|
||||
}
|
||||
}
|
||||
|
||||
AppInterface && AppInterface.onEvent(eventName);
|
||||
target.dispatchEvent(event);
|
||||
}
|
||||
}
|
26
src/utils/bx-exposed.ts
Normal file
26
src/utils/bx-exposed.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { STATES } from "./global";
|
||||
|
||||
export const BxExposed = {
|
||||
onPollingModeChanged: (mode: 'All' | 'None') => {
|
||||
if (!STATES.isPlaying) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const $screenshotBtn = document.querySelector('.bx-screenshot-button');
|
||||
const $touchControllerBar = document.getElementById('bx-touch-controller-bar');
|
||||
|
||||
if (mode !== 'None') {
|
||||
// Hide screenshot button
|
||||
$screenshotBtn && $screenshotBtn.classList.add('bx-gone');
|
||||
|
||||
// Hide touch controller bar
|
||||
$touchControllerBar && $touchControllerBar.classList.add('bx-gone');
|
||||
} else {
|
||||
// Show screenshot button
|
||||
$screenshotBtn && $screenshotBtn.classList.remove('bx-gone');
|
||||
|
||||
// Show touch controller bar
|
||||
$touchControllerBar && $touchControllerBar.classList.remove('bx-gone');
|
||||
}
|
||||
},
|
||||
};
|
25
src/utils/bx-flags.ts
Normal file
25
src/utils/bx-flags.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
type BxFlags = {
|
||||
CheckForUpdate?: boolean;
|
||||
PreloadRemotePlay?: boolean;
|
||||
PreloadUi?: boolean;
|
||||
EnableXcloudLogging?: boolean;
|
||||
SafariWorkaround?: boolean;
|
||||
|
||||
UseDevTouchLayout?: boolean;
|
||||
}
|
||||
|
||||
// Setup flags
|
||||
const DEFAULT_FLAGS: BxFlags = {
|
||||
CheckForUpdate: true,
|
||||
PreloadRemotePlay: true,
|
||||
PreloadUi: false,
|
||||
EnableXcloudLogging: false,
|
||||
SafariWorkaround: true,
|
||||
|
||||
UseDevTouchLayout: false,
|
||||
}
|
||||
|
||||
const BX_FLAGS = Object.assign(DEFAULT_FLAGS, window.BX_FLAGS || {});
|
||||
delete window.BX_FLAGS;
|
||||
|
||||
export { BX_FLAGS }
|
@@ -1,4 +1,4 @@
|
||||
import { BxEvent } from "../modules/bx-event";
|
||||
import { BxEvent } from "./bx-event";
|
||||
import { LoadingScreen } from "../modules/loading-screen";
|
||||
import { RemotePlay } from "../modules/remote-play";
|
||||
import { checkHeader } from "../modules/ui/header";
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { BxEvent } from "../modules/bx-event";
|
||||
import { BxEvent } from "./bx-event";
|
||||
import { getPref, PrefKey } from "../modules/preferences";
|
||||
import { STATES } from "./global";
|
||||
import { UserAgent } from "./user-agent";
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { BxEvent } from "../modules/bx-event";
|
||||
import { BX_FLAGS } from "../modules/bx-flags";
|
||||
import { BxEvent } from "./bx-event";
|
||||
import { BX_FLAGS } from "./bx-flags";
|
||||
import { LoadingScreen } from "../modules/loading-screen";
|
||||
import { PrefKey, getPref } from "../modules/preferences";
|
||||
import { RemotePlay } from "../modules/remote-play";
|
||||
|
Reference in New Issue
Block a user