mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-08 22:27:44 +02:00
Rename EventBus events
This commit is contained in:
22
src/index.ts
22
src/index.ts
@@ -191,9 +191,7 @@ window.addEventListener('popstate', onHistoryChanged);
|
||||
window.history.pushState = patchHistoryMethod('pushState');
|
||||
window.history.replaceState = patchHistoryMethod('replaceState');
|
||||
|
||||
BxEventBus.Script.on('xcloudServerUnavailable', () => {
|
||||
BxEventBus.Script.off('xcloudServerUnavailable', null);
|
||||
|
||||
BxEventBus.Script.once('xcloudServerUnavailable', () => {
|
||||
STATES.supportedRegion = false;
|
||||
window.setTimeout(HeaderSection.watchHeader, 2000);
|
||||
|
||||
@@ -204,12 +202,12 @@ BxEventBus.Script.on('xcloudServerUnavailable', () => {
|
||||
}
|
||||
});
|
||||
|
||||
BxEventBus.Script.on('xcloudServerReady', () => {
|
||||
BxEventBus.Script.on('xcloud.server.ready', () => {
|
||||
STATES.isSignedIn = true;
|
||||
window.setTimeout(HeaderSection.watchHeader, 2000);
|
||||
});
|
||||
|
||||
BxEventBus.Stream.on('stateLoading', () => {
|
||||
BxEventBus.Stream.on('state.loading', () => {
|
||||
// Get title ID for screenshot's name
|
||||
if (window.location.pathname.includes('/launch/') && STATES.currentStream.titleInfo) {
|
||||
STATES.currentStream.titleSlug = productTitleToSlug(STATES.currentStream.titleInfo.product.title);
|
||||
@@ -219,9 +217,9 @@ BxEventBus.Stream.on('stateLoading', () => {
|
||||
});
|
||||
|
||||
// Setup loading screen
|
||||
getPref(PrefKey.LOADING_SCREEN_GAME_ART) && BxEventBus.Script.on('titleInfoReady', LoadingScreen.setup);
|
||||
getPref(PrefKey.LOADING_SCREEN_GAME_ART) && BxEventBus.Script.on('titleInfo.ready', LoadingScreen.setup);
|
||||
|
||||
BxEventBus.Stream.on('stateStarting', () => {
|
||||
BxEventBus.Stream.on('state.starting', () => {
|
||||
// Hide loading screen
|
||||
LoadingScreen.hide();
|
||||
|
||||
@@ -235,7 +233,7 @@ BxEventBus.Stream.on('stateStarting', () => {
|
||||
}
|
||||
});
|
||||
|
||||
BxEventBus.Stream.on('statePlaying', payload => {
|
||||
BxEventBus.Stream.on('state.playing', payload => {
|
||||
window.BX_STREAM_SETTINGS = StreamSettings.settings;
|
||||
StreamSettings.refreshAllSettings();
|
||||
|
||||
@@ -265,8 +263,8 @@ BxEventBus.Stream.on('statePlaying', payload => {
|
||||
updateVideoPlayer();
|
||||
});
|
||||
|
||||
BxEventBus.Stream.on('stateError', () => {
|
||||
BxEventBus.Stream.emit('stateStopped', {});
|
||||
BxEventBus.Stream.on('state.error', () => {
|
||||
BxEventBus.Stream.emit('state.stopped', {});
|
||||
});
|
||||
|
||||
isFullVersion() && window.addEventListener(BxEvent.XCLOUD_RENDERING_COMPONENT, e => {
|
||||
@@ -346,9 +344,9 @@ function unload() {
|
||||
}
|
||||
}
|
||||
|
||||
BxEventBus.Stream.on('stateStopped', unload);
|
||||
BxEventBus.Stream.on('state.stopped', unload);
|
||||
window.addEventListener('pagehide', e => {
|
||||
BxEventBus.Stream.emit('stateStopped', {});
|
||||
BxEventBus.Stream.emit('state.stopped', {});
|
||||
});
|
||||
|
||||
isFullVersion() && window.addEventListener(BxEvent.CAPTURE_SCREENSHOT, e => {
|
||||
|
@@ -47,7 +47,7 @@ export class DeviceVibrationManager {
|
||||
}
|
||||
});
|
||||
|
||||
BxEventBus.Script.on('deviceVibrationUpdated', () => this.setupDataChannel());
|
||||
BxEventBus.Script.on('deviceVibration.updated', () => this.setupDataChannel());
|
||||
}
|
||||
|
||||
private setupDataChannel() {
|
||||
|
@@ -518,7 +518,7 @@ export class EmulatedMkbHandler extends MkbHandler {
|
||||
window.addEventListener('keyup', this.onKeyboardEvent);
|
||||
|
||||
window.addEventListener(BxEvent.XCLOUD_POLLING_MODE_CHANGED, this.onPollingModeChanged);
|
||||
window.addEventListener(BxEvent.XCLOUD_DIALOG_SHOWN, this.onDialogShown);
|
||||
BxEventBus.Script.on('dialog.shown', this.onDialogShown);
|
||||
|
||||
if (AppInterface) {
|
||||
// Android app doesn't support PointerLock API so we need to use a different method
|
||||
@@ -569,7 +569,7 @@ export class EmulatedMkbHandler extends MkbHandler {
|
||||
}
|
||||
|
||||
window.removeEventListener(BxEvent.XCLOUD_POLLING_MODE_CHANGED, this.onPollingModeChanged);
|
||||
window.removeEventListener(BxEvent.XCLOUD_DIALOG_SHOWN, this.onDialogShown);
|
||||
BxEventBus.Script.off('dialog.shown', this.onDialogShown);
|
||||
|
||||
this.mouseDataProvider?.destroy();
|
||||
|
||||
@@ -640,7 +640,7 @@ export class EmulatedMkbHandler extends MkbHandler {
|
||||
|
||||
static setupEvents() {
|
||||
if (isFullVersion()) {
|
||||
BxEventBus.Stream.on('statePlaying', () => {
|
||||
BxEventBus.Stream.on('state.playing', () => {
|
||||
if (STATES.currentStream.titleInfo?.details.hasMkbSupport) {
|
||||
// Enable native MKB in Android app
|
||||
NativeMkbHandler.getInstance()?.init();
|
||||
@@ -650,7 +650,7 @@ export class EmulatedMkbHandler extends MkbHandler {
|
||||
});
|
||||
|
||||
if (EmulatedMkbHandler.isAllowed()) {
|
||||
BxEventBus.Script.on('mkbSettingUpdated', () => {
|
||||
BxEventBus.Script.on('mkb.setting.updated', () => {
|
||||
EmulatedMkbHandler.getInstance()?.refreshPresetData();
|
||||
});
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ export class MkbPopup {
|
||||
constructor() {
|
||||
this.render();
|
||||
|
||||
BxEventBus.Script.on('keyboardShortcutsUpdated', () => {
|
||||
BxEventBus.Script.on('keyboardShortcuts.updated', () => {
|
||||
const $newButton = this.createActivateButton();
|
||||
this.$btnActivate.replaceWith($newButton);
|
||||
this.$btnActivate = $newButton;
|
||||
|
@@ -12,6 +12,7 @@ import { KeyHelper } from "./key-helper";
|
||||
import { StreamSettings } from "@/utils/stream-settings";
|
||||
import { ShortcutAction } from "@/enums/shortcut-actions";
|
||||
import { NativeMkbMode } from "@/enums/pref-values";
|
||||
import { BxEventBus } from "@/utils/bx-event-bus";
|
||||
|
||||
type NativeMouseData = {
|
||||
X: number,
|
||||
@@ -100,10 +101,6 @@ export class NativeMkbHandler extends MkbHandler {
|
||||
this.onKeyboardEvent(event as KeyboardEvent);
|
||||
break;
|
||||
|
||||
case BxEvent.XCLOUD_DIALOG_SHOWN:
|
||||
this.onDialogShown();
|
||||
break;
|
||||
|
||||
case BxEvent.POINTER_LOCK_REQUESTED:
|
||||
this.onPointerLockRequested(event);
|
||||
break;
|
||||
@@ -135,10 +132,10 @@ export class NativeMkbHandler extends MkbHandler {
|
||||
|
||||
window.addEventListener('keyup', this);
|
||||
|
||||
window.addEventListener(BxEvent.XCLOUD_DIALOG_SHOWN, this);
|
||||
window.addEventListener(BxEvent.POINTER_LOCK_REQUESTED, this);
|
||||
window.addEventListener(BxEvent.POINTER_LOCK_EXITED, this);
|
||||
window.addEventListener(BxEvent.XCLOUD_POLLING_MODE_CHANGED, this);
|
||||
BxEventBus.Script.on('dialog.shown', this.onDialogShown);
|
||||
|
||||
const shortcutKey = StreamSettings.findKeyboardShortcut(ShortcutAction.MKB_TOGGLE);
|
||||
if (shortcutKey) {
|
||||
@@ -199,10 +196,10 @@ export class NativeMkbHandler extends MkbHandler {
|
||||
|
||||
window.removeEventListener('keyup', this);
|
||||
|
||||
window.removeEventListener(BxEvent.XCLOUD_DIALOG_SHOWN, this);
|
||||
window.removeEventListener(BxEvent.POINTER_LOCK_REQUESTED, this);
|
||||
window.removeEventListener(BxEvent.POINTER_LOCK_EXITED, this);
|
||||
window.removeEventListener(BxEvent.XCLOUD_POLLING_MODE_CHANGED, this);
|
||||
BxEventBus.Script.off('dialog.shown', this.onDialogShown);
|
||||
|
||||
this.waitForMouseData(false);
|
||||
document.pointerLockElement && document.exitPointerLock();
|
||||
|
@@ -230,7 +230,7 @@ export class StreamStats {
|
||||
}
|
||||
|
||||
static setupEvents() {
|
||||
BxEventBus.Stream.on('statePlaying', () => {
|
||||
BxEventBus.Stream.on('state.playing', () => {
|
||||
const PREF_STATS_QUICK_GLANCE = getPref(PrefKey.STATS_QUICK_GLANCE_ENABLED);
|
||||
const PREF_STATS_SHOW_WHEN_PLAYING = getPref(PrefKey.STATS_SHOW_WHEN_PLAYING);
|
||||
|
||||
|
@@ -243,7 +243,7 @@ export class StreamUiHandler {
|
||||
|
||||
// Error Page: .PureErrorPage.ErrorScreen
|
||||
if (className.includes('PureErrorPage')) {
|
||||
BxEventBus.Stream.emit('stateError', {});
|
||||
BxEventBus.Stream.emit('state.error', {});
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -2,6 +2,7 @@ import { GamepadKey } from "@/enums/gamepad";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { VIRTUAL_GAMEPAD_ID } from "@/modules/mkb/mkb-handler";
|
||||
import { BxEvent } from "@/utils/bx-event";
|
||||
import { BxEventBus } from "@/utils/bx-event-bus";
|
||||
import { BxLogger } from "@/utils/bx-logger";
|
||||
import { CE, isElementVisible } from "@/utils/html";
|
||||
import { setNearby } from "@/utils/navigation-utils";
|
||||
@@ -439,7 +440,7 @@ export class NavigationDialogManager {
|
||||
show(dialog: NavigationDialog, configs={}, clearStack=false) {
|
||||
this.clearGamepadHoldingInterval();
|
||||
|
||||
BxEvent.dispatch(window, BxEvent.XCLOUD_DIALOG_SHOWN);
|
||||
BxEventBus.Script.emit('dialog.shown', {});
|
||||
|
||||
// Stop xCloud's navigation polling
|
||||
window.BX_EXPOSED.disableGamepadPolling = true;
|
||||
@@ -479,7 +480,7 @@ export class NavigationDialogManager {
|
||||
// Unlock scroll bar
|
||||
document.body.classList.remove('bx-no-scroll');
|
||||
|
||||
BxEvent.dispatch(window, BxEvent.XCLOUD_DIALOG_DISMISSED);
|
||||
BxEventBus.Script.emit('dialog.dismissed', {});
|
||||
|
||||
// Hide content
|
||||
this.$overlay.classList.add('bx-gone');
|
||||
|
@@ -436,7 +436,7 @@ export class SettingsDialog extends NavigationDialog {
|
||||
onCreated: (setting: SettingTabSectionItem, $elm: HTMLElement) => {
|
||||
const $range = $elm.querySelector<HTMLInputElement>('input[type=range')!;
|
||||
|
||||
BxEventBus.Script.on('settingChanged', payload => {
|
||||
BxEventBus.Script.on('setting.changed', payload => {
|
||||
const { storageKey, settingKey, settingValue } = payload;
|
||||
if (storageKey === StorageKey.GLOBAL && settingKey === PrefKey.AUDIO_VOLUME) {
|
||||
$range.value = settingValue;
|
||||
|
@@ -7,6 +7,7 @@ import { t } from "@/utils/translation";
|
||||
import { SettingsDialog } from "./dialog/settings-dialog";
|
||||
import { TrueAchievements } from "@/utils/true-achievements";
|
||||
import { BxIcon } from "@/utils/bx-icon";
|
||||
import { BxEventBus } from "@/utils/bx-event-bus";
|
||||
|
||||
export enum GuideMenuTab {
|
||||
HOME = 'home',
|
||||
@@ -40,9 +41,9 @@ export class GuideMenu {
|
||||
style: ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE | ButtonStyle.PRIMARY,
|
||||
onClick: () => {
|
||||
// Wait until the Guide dialog is closed
|
||||
window.addEventListener(BxEvent.XCLOUD_DIALOG_DISMISSED, e => {
|
||||
BxEventBus.Script.once('xcloudDialogDismissed', () => {
|
||||
setTimeout(() => SettingsDialog.getInstance().show(), 50);
|
||||
}, { once: true });
|
||||
});
|
||||
|
||||
// Close all xCloud's dialogs
|
||||
this.closeGuideMenu();
|
||||
|
@@ -1,26 +1,30 @@
|
||||
import type { PrefKey, StorageKey } from "@/enums/pref-keys";
|
||||
import { BX_FLAGS } from "./bx-flags";
|
||||
import { BxLogger } from "./bx-logger";
|
||||
import { AppInterface } from "./global";
|
||||
|
||||
type EventCallback<T = any> = (payload: T) => void;
|
||||
|
||||
type ScriptEvents = {
|
||||
xcloudServerReady: {};
|
||||
xcloudServerUnavailable: {};
|
||||
'xcloud.server.ready': {};
|
||||
'xcloud.server.unavailable': {};
|
||||
|
||||
titleInfoReady: {};
|
||||
settingChanged: {
|
||||
'dialog.shown': {},
|
||||
'dialog.dismissed': {},
|
||||
|
||||
'titleInfo.ready': {};
|
||||
'setting.changed': {
|
||||
storageKey: StorageKey;
|
||||
settingKey: PrefKey;
|
||||
settingValue: any;
|
||||
};
|
||||
|
||||
mkbSettingUpdated: {};
|
||||
keyboardShortcutsUpdated: {};
|
||||
deviceVibrationUpdated: {};
|
||||
'mkb.setting.updated': {};
|
||||
'keyboardShortcuts.updated': {};
|
||||
'deviceVibration.updated': {};
|
||||
|
||||
// GH pages
|
||||
listForcedNativeMkbUpdated: {
|
||||
'list.forcedNativeMkb.updated': {
|
||||
data: {
|
||||
data: any;
|
||||
};
|
||||
@@ -28,20 +32,25 @@ type ScriptEvents = {
|
||||
};
|
||||
|
||||
type StreamEvents = {
|
||||
stateLoading: {};
|
||||
stateStarting: {};
|
||||
statePlaying: { $video?: HTMLVideoElement };
|
||||
stateStopped: {};
|
||||
stateError: {};
|
||||
'state.loading': {};
|
||||
'state.starting': {};
|
||||
'state.playing': { $video?: HTMLVideoElement };
|
||||
'state.stopped': {};
|
||||
'state.error': {};
|
||||
|
||||
dataChannelCreated: { dataChannel: RTCDataChannel };
|
||||
};
|
||||
|
||||
export class BxEventBus<TEvents extends Record<string, any>> {
|
||||
private listeners: Map<keyof TEvents, Set<EventCallback<any>>> = new Map();
|
||||
private group: string;
|
||||
|
||||
static readonly Script = new BxEventBus<ScriptEvents>();
|
||||
static readonly Stream = new BxEventBus<StreamEvents>();
|
||||
static readonly Script = new BxEventBus<ScriptEvents>('script');
|
||||
static readonly Stream = new BxEventBus<StreamEvents>('stream');
|
||||
|
||||
constructor(group: string) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
on<K extends keyof TEvents>(event: K, callback: EventCallback<TEvents[K]>): void {
|
||||
if (!this.listeners.has(event)) {
|
||||
@@ -52,6 +61,16 @@ export class BxEventBus<TEvents extends Record<string, any>> {
|
||||
BX_FLAGS.Debug && BxLogger.warning('EventBus', 'on', event, callback);
|
||||
}
|
||||
|
||||
once<K extends keyof TEvents>(event: string, callback: EventCallback<TEvents[K]>): void {
|
||||
const wrapper = (...args: any[]) => {
|
||||
// @ts-ignore
|
||||
callback(...args);
|
||||
this.off(event, wrapper);
|
||||
};
|
||||
|
||||
this.on(event, wrapper);
|
||||
}
|
||||
|
||||
off<K extends keyof TEvents>(event: K, callback: EventCallback<TEvents[K]> | null): void {
|
||||
BX_FLAGS.Debug && BxLogger.warning('EventBus', 'off', event, callback);
|
||||
|
||||
@@ -77,12 +96,13 @@ export class BxEventBus<TEvents extends Record<string, any>> {
|
||||
}
|
||||
|
||||
emit<K extends keyof TEvents>(event: K, payload: TEvents[K]): void {
|
||||
BX_FLAGS.Debug && BxLogger.warning('EventBus', 'emit', event, payload);
|
||||
|
||||
const callbacks = this.listeners.get(event) || [];
|
||||
for (const callback of callbacks) {
|
||||
callback(payload);
|
||||
}
|
||||
|
||||
AppInterface && AppInterface.onEventBus(this.group + '.' + (event as string));
|
||||
BX_FLAGS.Debug && BxLogger.warning('EventBus', 'emit', event, payload);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -28,10 +28,6 @@ export namespace BxEvent {
|
||||
|
||||
export const NAVIGATION_FOCUS_CHANGED = 'bx-nav-focus-changed';
|
||||
|
||||
// xCloud Dialog events
|
||||
export const XCLOUD_DIALOG_SHOWN = 'bx-xcloud-dialog-shown';
|
||||
export const XCLOUD_DIALOG_DISMISSED = 'bx-xcloud-dialog-dismissed';
|
||||
|
||||
export const XCLOUD_GUIDE_MENU_SHOWN = 'bx-xcloud-guide-menu-shown';
|
||||
|
||||
export const XCLOUD_POLLING_MODE_CHANGED = 'bx-xcloud-polling-mode-changed';
|
||||
|
@@ -139,7 +139,7 @@ export const BxExposed = {
|
||||
|
||||
// Save this info in STATES
|
||||
STATES.currentStream.titleInfo = titleInfo;
|
||||
BxEventBus.Script.emit('titleInfoReady', {});
|
||||
BxEventBus.Script.emit('titleInfo.ready', {});
|
||||
|
||||
return titleInfo;
|
||||
},
|
||||
|
@@ -53,7 +53,7 @@ export class GhPagesUtils {
|
||||
if (json.$schemaVersion === supportedSchema) {
|
||||
// Save to storage
|
||||
window.localStorage.setItem(key, JSON.stringify(json));
|
||||
BxEventBus.Script.emit('listForcedNativeMkbUpdated', {
|
||||
BxEventBus.Script.emit('list.forcedNativeMkb.updated', {
|
||||
data: json,
|
||||
});
|
||||
}
|
||||
|
@@ -33,5 +33,5 @@ export function onHistoryChanged(e: PopStateEvent) {
|
||||
LoadingScreen.reset();
|
||||
window.setTimeout(HeaderSection.watchHeader, 2000);
|
||||
|
||||
BxEventBus.Stream.emit('stateStopped', {});
|
||||
BxEventBus.Stream.emit('state.stopped', {});
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ export function patchVideoApi() {
|
||||
} satisfies StreamPlayerOptions;
|
||||
STATES.currentStream.streamPlayer = new StreamPlayer(this, getPref(PrefKey.VIDEO_PLAYER_TYPE), playerOptions);
|
||||
|
||||
BxEventBus.Stream.emit('statePlaying', {
|
||||
BxEventBus.Stream.emit('state.playing', {
|
||||
$video: this,
|
||||
})
|
||||
}
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import { GuideMenu } from "@/modules/ui/guide-menu";
|
||||
import { BxEvent } from "./bx-event";
|
||||
import { BX_FLAGS } from "./bx-flags";
|
||||
import { BxLogger } from "./bx-logger";
|
||||
import { BxIcon } from "./bx-icon";
|
||||
@@ -7,6 +6,7 @@ import { AppInterface } from "./global";
|
||||
import { createButton, ButtonStyle } from "./html";
|
||||
import { t } from "./translation";
|
||||
import { parseDetailsPath } from "./utils";
|
||||
import { BxEventBus } from "./bx-event-bus";
|
||||
|
||||
|
||||
export class RootDialogObserver {
|
||||
@@ -85,7 +85,7 @@ export class RootDialogObserver {
|
||||
const shown = !!($root.firstElementChild && $root.firstElementChild.childElementCount > 0);
|
||||
if (shown !== beingShown) {
|
||||
beingShown = shown;
|
||||
BxEvent.dispatch(window, shown ? BxEvent.XCLOUD_DIALOG_SHOWN : BxEvent.XCLOUD_DIALOG_DISMISSED);
|
||||
BxEventBus.Script.emit(shown ? 'dialog.shown' : 'dialog.dismissed', {});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@@ -93,7 +93,7 @@ export class BaseSettingsStore {
|
||||
this.settings[key] = this.validateValue('get', key, value);
|
||||
this.saveSettings();
|
||||
|
||||
emitEvent && BxEventBus.Script.emit('settingChanged', {
|
||||
emitEvent && BxEventBus.Script.emit('setting.changed', {
|
||||
storageKey: this.storageKey,
|
||||
settingKey: key,
|
||||
settingValue: value,
|
||||
|
@@ -432,7 +432,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
if (!setting.unsupported) {
|
||||
(setting as any).multipleOptions = GhPagesUtils.getNativeMkbCustomList(true);
|
||||
|
||||
BxEventBus.Script.on('listForcedNativeMkbUpdated', payload => {
|
||||
BxEventBus.Script.on('list.forcedNativeMkb.updated', payload => {
|
||||
(setting as any).multipleOptions = payload.data.data;
|
||||
});
|
||||
}
|
||||
|
@@ -110,7 +110,7 @@ export class StreamSettings {
|
||||
}
|
||||
|
||||
StreamSettings.settings.deviceVibrationIntensity = intensity;
|
||||
BxEventBus.Script.emit('deviceVibrationUpdated', {});
|
||||
BxEventBus.Script.emit('deviceVibration.updated', {});
|
||||
}
|
||||
|
||||
static async refreshMkbSettings() {
|
||||
@@ -148,7 +148,7 @@ export class StreamSettings {
|
||||
settings.mkbPreset = converted;
|
||||
|
||||
setPref(PrefKey.MKB_P1_MAPPING_PRESET_ID, orgPreset.id);
|
||||
BxEventBus.Script.emit('mkbSettingUpdated', {});
|
||||
BxEventBus.Script.emit('mkb.setting.updated', {});
|
||||
}
|
||||
|
||||
static async refreshKeyboardShortcuts() {
|
||||
@@ -159,7 +159,7 @@ export class StreamSettings {
|
||||
settings.keyboardShortcuts = null;
|
||||
|
||||
setPref(PrefKey.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID, presetId);
|
||||
BxEventBus.Script.emit('keyboardShortcutsUpdated', {});
|
||||
BxEventBus.Script.emit('keyboardShortcuts.updated', {});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ export class StreamSettings {
|
||||
settings.keyboardShortcuts = converted;
|
||||
|
||||
setPref(PrefKey.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID, orgPreset.id);
|
||||
BxEventBus.Script.emit('keyboardShortcutsUpdated', {});
|
||||
BxEventBus.Script.emit('keyboardShortcuts.updated', {});
|
||||
}
|
||||
|
||||
static async refreshAllSettings() {
|
||||
|
@@ -310,7 +310,7 @@ export class StreamStatsCollector {
|
||||
}
|
||||
|
||||
static setupEvents() {
|
||||
BxEventBus.Stream.on('statePlaying', () => {
|
||||
BxEventBus.Stream.on('state.playing', () => {
|
||||
StreamStatsCollector.getInstance().reset();
|
||||
});
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ export class XcloudInterceptor {
|
||||
const response = await NATIVE_FETCH(request, init);
|
||||
if (response.status !== 200) {
|
||||
// Unsupported region
|
||||
BxEventBus.Script.emit('xcloudServerUnavailable', {});
|
||||
BxEventBus.Script.emit('xcloud.server.unavailable', {});
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ export class XcloudInterceptor {
|
||||
STATES.serverRegions[region.name] = Object.assign({}, region);
|
||||
}
|
||||
|
||||
BxEventBus.Script.emit('xcloudServerReady', {});
|
||||
BxEventBus.Script.emit('xcloud.server.ready', {});
|
||||
|
||||
const preferredRegion = getPreferredServerRegion();
|
||||
if (preferredRegion && preferredRegion in STATES.serverRegions) {
|
||||
@@ -107,7 +107,7 @@ export class XcloudInterceptor {
|
||||
}
|
||||
|
||||
private static async handlePlay(request: RequestInfo | URL, init?: RequestInit) {
|
||||
BxEventBus.Stream.emit('stateLoading', {});
|
||||
BxEventBus.Stream.emit('state.loading', {});
|
||||
|
||||
const PREF_STREAM_TARGET_RESOLUTION = getPref<StreamResolution>(PrefKey.STREAM_RESOLUTION);
|
||||
const PREF_STREAM_PREFERRED_LOCALE = getPref<StreamPreferredLocale>(PrefKey.STREAM_PREFERRED_LOCALE);
|
||||
@@ -189,7 +189,7 @@ export class XcloudInterceptor {
|
||||
return response;
|
||||
}
|
||||
|
||||
BxEventBus.Stream.emit('stateStarting', {});
|
||||
BxEventBus.Stream.emit('state.starting', {});
|
||||
|
||||
const obj = JSON.parse(text);
|
||||
let overrides = JSON.parse(obj.clientStreamingConfigOverrides || '{}') || {};
|
||||
|
@@ -36,7 +36,7 @@ export class XhomeInterceptor {
|
||||
}
|
||||
|
||||
private static async handleConfiguration(request: Request | URL) {
|
||||
BxEventBus.Stream.emit('stateStarting', {});
|
||||
BxEventBus.Stream.emit('state.starting', {});
|
||||
|
||||
const response = await NATIVE_FETCH(request);
|
||||
const obj = await response.clone().json();
|
||||
@@ -125,7 +125,7 @@ export class XhomeInterceptor {
|
||||
}
|
||||
|
||||
private static async handlePlay(request: RequestInfo | URL) {
|
||||
BxEventBus.Stream.emit('stateLoading', {});
|
||||
BxEventBus.Stream.emit('state.loading', {});
|
||||
|
||||
const clone = (request as Request).clone();
|
||||
const body = await clone.json();
|
||||
|
Reference in New Issue
Block a user