mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-07 08:07:18 +02:00
Add "Reload stream" & "Back to home" buttons in the Guide menu
This commit is contained in:
parent
322418ec5b
commit
8f9976da28
@ -53,3 +53,10 @@ div[data-testid=media-container] {
|
|||||||
align-self: center;
|
align-self: center;
|
||||||
background: #000;
|
background: #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#gamepass-dialog-root div[class^=Guide-module__guide] {
|
||||||
|
.bx-button {
|
||||||
|
overflow: visible;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -25,7 +25,7 @@ import { VibrationManager } from "@modules/vibration-manager";
|
|||||||
import { overridePreloadState } from "@utils/preload-state";
|
import { overridePreloadState } from "@utils/preload-state";
|
||||||
import { patchAudioContext, patchCanvasContext, patchMeControl, patchRtcCodecs, patchRtcPeerConnection, patchVideoApi } from "@utils/monkey-patches";
|
import { patchAudioContext, patchCanvasContext, patchMeControl, patchRtcCodecs, patchRtcPeerConnection, patchVideoApi } from "@utils/monkey-patches";
|
||||||
import { AppInterface, STATES } from "@utils/global";
|
import { AppInterface, STATES } from "@utils/global";
|
||||||
import { injectStreamMenuButtons } from "@modules/stream/stream-ui";
|
import { injectStreamMenuButtons, setupStreamUiEvents } from "@modules/stream/stream-ui";
|
||||||
import { BxLogger } from "@utils/bx-logger";
|
import { BxLogger } from "@utils/bx-logger";
|
||||||
import { GameBar } from "./modules/game-bar/game-bar";
|
import { GameBar } from "./modules/game-bar/game-bar";
|
||||||
import { Screenshot } from "./utils/screenshot";
|
import { Screenshot } from "./utils/screenshot";
|
||||||
@ -281,6 +281,7 @@ function main() {
|
|||||||
(getPref(PrefKey.GAME_BAR_POSITION) !== 'off') && GameBar.getInstance();
|
(getPref(PrefKey.GAME_BAR_POSITION) !== 'off') && GameBar.getInstance();
|
||||||
BX_FLAGS.PreloadUi && setupStreamUi();
|
BX_FLAGS.PreloadUi && setupStreamUi();
|
||||||
|
|
||||||
|
setupStreamUiEvents();
|
||||||
StreamBadges.setupEvents();
|
StreamBadges.setupEvents();
|
||||||
StreamStats.setupEvents();
|
StreamStats.setupEvents();
|
||||||
MkbHandler.setupEvents();
|
MkbHandler.setupEvents();
|
||||||
|
@ -340,7 +340,10 @@ export class StreamBadges {
|
|||||||
window.addEventListener(BxEvent.XCLOUD_GUIDE_SHOWN, async e => {
|
window.addEventListener(BxEvent.XCLOUD_GUIDE_SHOWN, async e => {
|
||||||
const where = (e as any).where as XcloudGuideWhere;
|
const where = (e as any).where as XcloudGuideWhere;
|
||||||
|
|
||||||
if (where === XcloudGuideWhere.HOME && STATES.isPlaying) {
|
if (where !== XcloudGuideWhere.HOME || !STATES.isPlaying) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const $btnQuit = document.querySelector('#gamepass-dialog-root a[class*=QuitGameButton]');
|
const $btnQuit = document.querySelector('#gamepass-dialog-root a[class*=QuitGameButton]');
|
||||||
if (!$btnQuit) {
|
if (!$btnQuit) {
|
||||||
return;
|
return;
|
||||||
@ -348,7 +351,6 @@ export class StreamBadges {
|
|||||||
|
|
||||||
// Add badges
|
// Add badges
|
||||||
$btnQuit.insertAdjacentElement('beforebegin', await StreamBadges.getInstance().render());
|
$btnQuit.insertAdjacentElement('beforebegin', await StreamBadges.getInstance().render());
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { STATES } from "@utils/global.ts";
|
import { STATES } from "@utils/global.ts";
|
||||||
import { createSvgIcon } from "@utils/html.ts";
|
import { ButtonStyle, createButton, createSvgIcon } from "@utils/html.ts";
|
||||||
import { BxIcon } from "@utils/bx-icon";
|
import { BxIcon } from "@utils/bx-icon";
|
||||||
import { BxEvent } from "@utils/bx-event.ts";
|
import { BxEvent, XcloudGuideWhere } from "@utils/bx-event.ts";
|
||||||
import { t } from "@utils/translation.ts";
|
import { t } from "@utils/translation.ts";
|
||||||
import { StreamBadges } from "./stream-badges.ts";
|
import { StreamBadges } from "./stream-badges.ts";
|
||||||
import { StreamStats } from "./stream-stats.ts";
|
import { StreamStats } from "./stream-stats.ts";
|
||||||
@ -269,3 +269,39 @@ export function showStreamSettings(tabId: string) {
|
|||||||
$parent.addEventListener('click', onClick);
|
$parent.addEventListener('click', onClick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function setupStreamUiEvents() {
|
||||||
|
window.addEventListener(BxEvent.XCLOUD_GUIDE_SHOWN, async e => {
|
||||||
|
const where = (e as any).where as XcloudGuideWhere;
|
||||||
|
|
||||||
|
if (where !== XcloudGuideWhere.HOME || !STATES.isPlaying) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const $btnQuit = document.querySelector('#gamepass-dialog-root a[class*=QuitGameButton]');
|
||||||
|
if (!$btnQuit) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add buttons
|
||||||
|
const $btnReload = createButton({
|
||||||
|
label: t('reload-stream'),
|
||||||
|
style: ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE,
|
||||||
|
onClick: e => {
|
||||||
|
confirm(t('confirm-reload-stream')) && window.location.reload();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const $btnHome = createButton({
|
||||||
|
label: t('back-to-home'),
|
||||||
|
style: ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE,
|
||||||
|
onClick: e => {
|
||||||
|
confirm(t('back-to-home-confirm')) && (window.location.href = window.location.href.substring(0, 31));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
$btnQuit.insertAdjacentElement('afterend', $btnReload);
|
||||||
|
$btnReload.insertAdjacentElement('afterend', $btnHome);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user