Compare commits

...

21 Commits

Author SHA1 Message Date
d0f43db1fd Bump version to 5.7.8 2024-10-02 21:24:23 +07:00
eed0aa9d9e Fix not disabling unsupported features in Settings dialog 2024-10-02 07:17:17 +07:00
9007663a3a Lite: remove NativeMkbHandler code in built script 2024-10-01 17:47:01 +07:00
8f6bc5cb1b Detach VIRTUAL_GAMEPAD_ID from EmulatedMkbHandler 2024-10-01 17:22:33 +07:00
12d8d766dc Lite: remove XhomeInterceptor and TouchController in built script 2024-10-01 17:09:07 +07:00
aeffccaf67 Update better-xcloud.lite.user.js 2024-10-01 16:51:44 +07:00
b2736d574d Disable PatcherCache in Lite version 2024-10-01 16:49:40 +07:00
98cf893956 Fix Settings dialog opening during gameplay 2024-09-30 17:18:40 +07:00
086afafedf Update dist 2024-09-30 17:12:22 +07:00
bd58355ef5 Create better-xcloud.lite.user.js 2024-09-30 17:11:05 +07:00
109cd63a7b Bump version to 5.7.7 2024-09-26 19:50:28 +07:00
8ea6b7f81a Update better-xcloud.user.js 2024-09-26 19:49:58 +07:00
e7c10d43f5 Fix buttons layout in product details page 2024-09-26 19:46:30 +07:00
2f7a57e084 Update translations 2024-09-26 19:22:51 +07:00
c99e38b097 Update better-xcloud.user.js 2024-09-25 20:20:45 +07:00
f6ec6d7c9b Fix not calculating controller-friendly <select>'s size when switching tab 2024-09-25 20:20:06 +07:00
e69fa19ef3 Update better-xcloud.user.js 2024-09-25 19:44:33 +07:00
cc422b31a4 build: collapse if/else blocks without curly braces 2024-09-25 19:43:19 +07:00
9609d0ae7b Fix duplicated CSS strings 2024-09-25 19:43:07 +07:00
506fd71433 Update better-xcloud.user.js 2024-09-25 08:48:57 +07:00
f40b8cb0b2 build: add more minify steps 2024-09-25 08:47:01 +07:00
34 changed files with 7588 additions and 2815 deletions

View File

@ -5,6 +5,8 @@ import { sys } from "typescript";
// @ts-ignore // @ts-ignore
import txtScriptHeader from "./src/assets/header_script.txt" with { type: "text" }; import txtScriptHeader from "./src/assets/header_script.txt" with { type: "text" };
// @ts-ignore // @ts-ignore
import txtScriptHeaderLite from "./src/assets/header_script.lite.txt" with { type: "text" };
// @ts-ignore
import txtMetaHeader from "./src/assets/header_meta.txt" with { type: "text" }; import txtMetaHeader from "./src/assets/header_meta.txt" with { type: "text" };
import { assert } from "node:console"; import { assert } from "node:console";
import { ESLint } from "eslint"; import { ESLint } from "eslint";
@ -16,6 +18,8 @@ enum BuildTarget {
WEBOS = 'webos', WEBOS = 'webos',
} }
type BuildVariant = 'full' | 'lite';
const postProcess = (str: string): string => { const postProcess = (str: string): string => {
// Unescape unicode charaters // Unescape unicode charaters
str = unescape((str.replace(/\\u/g, '%u'))); str = unescape((str.replace(/\\u/g, '%u')));
@ -35,13 +39,42 @@ const postProcess = (str: string): string => {
// Add ADDITIONAL CODE block // Add ADDITIONAL CODE block
str = str.replace('var DEFAULT_FLAGS', '\n/* ADDITIONAL CODE */\n\nvar DEFAULT_FLAGS'); str = str.replace('var DEFAULT_FLAGS', '\n/* ADDITIONAL CODE */\n\nvar DEFAULT_FLAGS');
// Minify SVG str = str.replaceAll('(e) => `', 'e => `');
str = str.replaceAll(/= "(<svg.*)";/g, function(match) {
match = match.replaceAll(/\\n*\s*/g, ''); // Simplify object definitions
return match; // {[1]: "a"} => {1: "a"}
str = str.replaceAll(/\[(\d+)\]: /g, '$1: ');
// {["a"]: 1, ["b-c"]: 2} => {a: 1, "b-c": 2}
str = str.replaceAll(/\["([^"]+)"\]: /g, function(match, p1) {
if (p1.includes('-') || p1.match(/^\d/)) {
p1 = `"${p1}"`;
}
return p1 + ': ';
}); });
str = str.replaceAll('(e) => `', 'e => `'); // Minify SVG import code
const svgMap = {}
str = str.replaceAll(/var ([\w_]+) = ("<svg.*?");\n\n/g, function(match, p1, p2) {
// Remove new lines in SVG
p2 = p2.replaceAll(/\\n*\s*/g, '');
svgMap[p1] = p2;
return '';
});
for (const name in svgMap) {
str = str.replace(`: ${name}`, `: ${svgMap[name]}`);
}
// Collapse empty brackets
str = str.replaceAll(/\{[\s\n]+\}/g, '{}');
// Collapse if/else blocks without curly braces
str = str.replaceAll(/((if \(.*?\)|else)\n\s+)/g, '$2 ');
// Remove blank lines
str = str.replaceAll(/\n([\s]*)\n/g, "\n");
assert(str.includes('/* ADDITIONAL CODE */')); assert(str.includes('/* ADDITIONAL CODE */'));
assert(str.includes('window.BX_EXPOSED = BxExposed')); assert(str.includes('window.BX_EXPOSED = BxExposed'));
@ -51,7 +84,7 @@ const postProcess = (str: string): string => {
return str; return str;
} }
const build = async (target: BuildTarget, version: string, config: any={}) => { const build = async (target: BuildTarget, version: string, variant: BuildVariant, config: any={}) => {
console.log('-- Target:', target); console.log('-- Target:', target);
const startTime = performance.now(); const startTime = performance.now();
@ -59,6 +92,11 @@ const build = async (target: BuildTarget, version: string, config: any={}) => {
if (target !== BuildTarget.ALL) { if (target !== BuildTarget.ALL) {
outputScriptName += `.${target}`; outputScriptName += `.${target}`;
} }
if (variant !== 'full') {
outputScriptName += `.${variant}`;
}
let outputMetaName = outputScriptName; let outputMetaName = outputScriptName;
outputScriptName += '.user.js'; outputScriptName += '.user.js';
outputMetaName += '.meta.js'; outputMetaName += '.meta.js';
@ -74,6 +112,7 @@ const build = async (target: BuildTarget, version: string, config: any={}) => {
}, },
define: { define: {
'Bun.env.BUILD_TARGET': JSON.stringify(target), 'Bun.env.BUILD_TARGET': JSON.stringify(target),
'Bun.env.BUILD_VARIANT': JSON.stringify(variant),
'Bun.env.SCRIPT_VERSION': JSON.stringify(version), 'Bun.env.SCRIPT_VERSION': JSON.stringify(version),
}, },
}); });
@ -88,7 +127,13 @@ const build = async (target: BuildTarget, version: string, config: any={}) => {
let result = postProcess(await readFile(path, 'utf-8')); let result = postProcess(await readFile(path, 'utf-8'));
// Replace [[VERSION]] with real value // Replace [[VERSION]] with real value
const scriptHeader = txtScriptHeader.replace('[[VERSION]]', version); let scriptHeader: string;
if (variant === 'full') {
scriptHeader = txtScriptHeader;
} else {
scriptHeader = txtScriptHeaderLite;
}
scriptHeader = scriptHeader.replace('[[VERSION]]', version);
// Save to script // Save to script
await Bun.write(path, scriptHeader + result); await Bun.write(path, scriptHeader + result);
@ -121,23 +166,38 @@ const { values, positionals } = parseArgs({
options: { options: {
version: { version: {
type: 'string', type: 'string',
},
variant: {
type: 'string',
default: 'full',
}, },
}, },
strict: true, strict: true,
allowPositionals: true, allowPositionals: true,
}); }) as {
values: {
version: string,
variant: BuildVariant,
},
positionals: string[],
};
if (!values['version']) { if (!values['version']) {
console.log('Missing --version param'); console.log('Missing --version param');
sys.exit(-1); sys.exit(-1);
} }
if (values['variant'] !== 'full' && values['variant'] !== 'lite') {
console.log('--variant param must be either "full" or "lite"');
sys.exit(-1);
}
async function main() { async function main() {
const config = {}; const config = {};
console.log('Building: ', values['version']); console.log(`Building: VERSION=${values['version']}, VARIANT=${values['variant']}`);
for (const target of buildTargets) { for (const target of buildTargets) {
await build(target, values['version']!!, config); await build(target, values['version']!!, values['variant'], config);
} }
console.log('\n** Press Enter to build or Esc to exit'); console.log('\n** Press Enter to build or Esc to exit');

5
dist/better-xcloud.lite.meta.js vendored Normal file
View File

@ -0,0 +1,5 @@
// ==UserScript==
// @name Better xCloud
// @namespace https://github.com/redphx
// @version 5.7.8
// ==/UserScript==

5454
dist/better-xcloud.lite.user.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
// ==UserScript== // ==UserScript==
// @name Better xCloud // @name Better xCloud
// @namespace https://github.com/redphx // @namespace https://github.com/redphx
// @version 5.7.6 // @version 5.7.8
// ==/UserScript== // ==/UserScript==

File diff suppressed because one or more lines are too long

View File

@ -2,6 +2,7 @@
"name": "better-xcloud", "name": "better-xcloud",
"module": "src/index.ts", "module": "src/index.ts",
"type": "module", "type": "module",
"sideEffects": false,
"browserslist": [ "browserslist": [
"Chrome >= 80" "Chrome >= 80"
], ],

View File

@ -179,15 +179,3 @@ button.bx-inactive {
opacity: 0.2; opacity: 0.2;
background: transparent !important; background: transparent !important;
} }
.bx-button-shortcut {
max-width: max-content;
margin: 10px 0 0 0;
flex: 1 0 auto;
}
@media (min-width: 568px) and (max-height: 480px) {
.bx-button-shortcut {
margin: 8px 0 0 10px;
}
}

21
src/assets/css/misc.styl Normal file
View File

@ -0,0 +1,21 @@
.bx-product-details-buttons {
display: flex;
gap: 10px;
flex-direction: row;
button {
max-width: max-content;
margin: 10px 0 0 0;
display: flex;
}
}
@media (min-width: 568px) and (max-height: 480px) {
.bx-product-details-buttons {
flex-direction: column;
button {
margin: 8px 0 0 10px;
}
}
}

View File

@ -16,3 +16,4 @@
@import 'game-bar.styl'; @import 'game-bar.styl';
@import 'stream-stats.styl'; @import 'stream-stats.styl';
@import 'mkb.styl'; @import 'mkb.styl';
@import 'misc.styl';

View File

@ -0,0 +1,13 @@
// ==UserScript==
// @name Better xCloud (Lite)
// @namespace https://github.com/redphx
// @version [[VERSION]]
// @description Improve Xbox Cloud Gaming (xCloud) experience
// @author redphx
// @license MIT
// @match https://www.xbox.com/*/play*
// @match https://www.xbox.com/*/auth/msa?*loggedIn*
// @run-at document-end
// @grant none
// ==/UserScript==
"use strict";

View File

@ -1,3 +1,5 @@
import { compressCss, isFullVersion } from "@macros/build" with {type: "macro"};
import "@utils/global"; import "@utils/global";
import { BxEvent } from "@utils/bx-event"; import { BxEvent } from "@utils/bx-event";
import { BX_FLAGS } from "@utils/bx-flags"; import { BX_FLAGS } from "@utils/bx-flags";
@ -35,13 +37,11 @@ import { ProductDetailsPage } from "./modules/ui/product-details";
import { NavigationDialogManager } from "./modules/ui/dialog/navigation-dialog"; import { NavigationDialogManager } from "./modules/ui/dialog/navigation-dialog";
import { PrefKey } from "./enums/pref-keys"; import { PrefKey } from "./enums/pref-keys";
import { getPref, StreamTouchController } from "./utils/settings-storages/global-settings-storage"; import { getPref, StreamTouchController } from "./utils/settings-storages/global-settings-storage";
import { compressCss } from "@macros/build" with {type: "macro"};
import { SettingsNavigationDialog } from "./modules/ui/dialog/settings-dialog"; import { SettingsNavigationDialog } from "./modules/ui/dialog/settings-dialog";
import { StreamUiHandler } from "./modules/stream/stream-ui"; import { StreamUiHandler } from "./modules/stream/stream-ui";
import { UserAgent } from "./utils/user-agent"; import { UserAgent } from "./utils/user-agent";
import { XboxApi } from "./utils/xbox-api"; import { XboxApi } from "./utils/xbox-api";
// Handle login page // Handle login page
if (window.location.pathname.includes('/auth/msa')) { if (window.location.pathname.includes('/auth/msa')) {
const nativePushState = window.history['pushState']; const nativePushState = window.history['pushState'];
@ -63,12 +63,14 @@ if (window.location.pathname.includes('/auth/msa')) {
BxLogger.info('readyState', document.readyState); BxLogger.info('readyState', document.readyState);
if (BX_FLAGS.SafariWorkaround && document.readyState !== 'loading') { if (isFullVersion() && BX_FLAGS.SafariWorkaround && document.readyState !== 'loading') {
// Stop loading // Stop loading
window.stop(); window.stop();
// Show the reloading overlay // We need to set it to an empty string first to work around Bun's bug
const css = compressCss(` // https://github.com/oven-sh/bun/issues/12067
let css = '';
css += compressCss(`
.bx-reload-overlay { .bx-reload-overlay {
position: fixed; position: fixed;
top: 0; top: 0;
@ -115,6 +117,7 @@ if (BX_FLAGS.SafariWorkaround && document.readyState !== 'loading') {
}, '🤓 ' + t('how-to-fix')); }, '🤓 ' + t('how-to-fix'));
} }
// Show the reloading overlay
const $fragment = document.createDocumentFragment(); const $fragment = document.createDocumentFragment();
$fragment.appendChild(CE('style', {}, css)); $fragment.appendChild(CE('style', {}, css));
$fragment.appendChild(CE('div',{ $fragment.appendChild(CE('div',{
@ -189,8 +192,11 @@ window.addEventListener(BxEvent.XCLOUD_SERVERS_UNAVAILABLE, e => {
window.setTimeout(HeaderSection.watchHeader, 2000); window.setTimeout(HeaderSection.watchHeader, 2000);
// Open Settings dialog on Unsupported page // Open Settings dialog on Unsupported page
const $unsupportedPage = document.querySelector('div[class^=UnsupportedMarketPage-module__container]') as HTMLElement;
if ($unsupportedPage) {
SettingsNavigationDialog.getInstance().show(); SettingsNavigationDialog.getInstance().show();
}); }
}, {once: true});
window.addEventListener(BxEvent.XCLOUD_SERVERS_READY, e => { window.addEventListener(BxEvent.XCLOUD_SERVERS_READY, e => {
STATES.isSignedIn = true; STATES.isSignedIn = true;
@ -224,15 +230,17 @@ window.addEventListener(BxEvent.STREAM_PLAYING, e => {
STATES.isPlaying = true; STATES.isPlaying = true;
StreamUiHandler.observe(); StreamUiHandler.observe();
if (getPref(PrefKey.GAME_BAR_POSITION) !== 'off') { if (isFullVersion() && getPref(PrefKey.GAME_BAR_POSITION) !== 'off') {
const gameBar = GameBar.getInstance(); const gameBar = GameBar.getInstance();
gameBar.reset(); gameBar.reset();
gameBar.enable(); gameBar.enable();
gameBar.showBar(); gameBar.showBar();
} }
if (isFullVersion()) {
const $video = (e as any).$video as HTMLVideoElement; const $video = (e as any).$video as HTMLVideoElement;
Screenshot.updateCanvasSize($video.videoWidth, $video.videoHeight); Screenshot.updateCanvasSize($video.videoWidth, $video.videoHeight);
}
updateVideoPlayer(); updateVideoPlayer();
}); });
@ -285,9 +293,11 @@ function unload() {
return; return;
} }
if (isFullVersion()) {
// Stop MKB listeners // Stop MKB listeners
EmulatedMkbHandler.getInstance().destroy(); EmulatedMkbHandler.getInstance().destroy();
NativeMkbHandler.getInstance().destroy(); NativeMkbHandler.getInstance().destroy();
}
// Destroy StreamPlayer // Destroy StreamPlayer
STATES.currentStream.streamPlayer?.destroy(); STATES.currentStream.streamPlayer?.destroy();
@ -300,17 +310,19 @@ function unload() {
NavigationDialogManager.getInstance().hide(); NavigationDialogManager.getInstance().hide();
StreamStats.getInstance().onStoppedPlaying(); StreamStats.getInstance().onStoppedPlaying();
if (isFullVersion()) {
MouseCursorHider.stop(); MouseCursorHider.stop();
TouchController.reset(); TouchController.reset();
GameBar.getInstance().disable(); GameBar.getInstance().disable();
} }
}
window.addEventListener(BxEvent.STREAM_STOPPED, unload); window.addEventListener(BxEvent.STREAM_STOPPED, unload);
window.addEventListener('pagehide', e => { window.addEventListener('pagehide', e => {
BxEvent.dispatch(window, BxEvent.STREAM_STOPPED); BxEvent.dispatch(window, BxEvent.STREAM_STOPPED);
}); });
window.addEventListener(BxEvent.CAPTURE_SCREENSHOT, e => { isFullVersion() && window.addEventListener(BxEvent.CAPTURE_SCREENSHOT, e => {
Screenshot.takeScreenshot(); Screenshot.takeScreenshot();
}); });
@ -365,15 +377,13 @@ function waitForRootDialog() {
function main() { function main() {
waitForRootDialog();
// Monkey patches // Monkey patches
patchRtcPeerConnection(); patchRtcPeerConnection();
patchRtcCodecs(); patchRtcCodecs();
interceptHttpRequests(); interceptHttpRequests();
patchVideoApi(); patchVideoApi();
patchCanvasContext(); patchCanvasContext();
AppInterface && patchPointerLockApi(); isFullVersion() && AppInterface && patchPointerLockApi();
getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL) && patchAudioContext(); getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL) && patchAudioContext();
@ -382,6 +392,20 @@ function main() {
disableAdobeAudienceManager(); disableAdobeAudienceManager();
} }
waitForRootDialog();
// Setup UI
addCss();
Toast.setup();
GuideMenu.addEventListeners();
StreamBadges.setupEvents();
StreamStats.setupEvents();
if (isFullVersion()) {
(getPref(PrefKey.GAME_BAR_POSITION) !== 'off') && GameBar.getInstance();
Screenshot.setup();
STATES.userAgent.capabilities.touch && TouchController.updateCustomList(); STATES.userAgent.capabilities.touch && TouchController.updateCustomList();
overridePreloadState(); overridePreloadState();
@ -390,27 +414,9 @@ function main() {
// Check for Update // Check for Update
BX_FLAGS.CheckForUpdate && checkForUpdate(); BX_FLAGS.CheckForUpdate && checkForUpdate();
// Setup UI
addCss();
Toast.setup();
(getPref(PrefKey.GAME_BAR_POSITION) !== 'off') && GameBar.getInstance();
Screenshot.setup();
GuideMenu.addEventListeners();
StreamBadges.setupEvents();
StreamStats.setupEvents();
EmulatedMkbHandler.setupEvents();
Patcher.init(); Patcher.init();
disablePwa(); disablePwa();
// Show a toast when connecting/disconecting controller
if (getPref(PrefKey.CONTROLLER_SHOW_CONNECTION_STATUS)) {
window.addEventListener('gamepadconnected', e => showGamepadToast(e.gamepad));
window.addEventListener('gamepaddisconnected', e => showGamepadToast(e.gamepad));
}
// Preload Remote Play // Preload Remote Play
if (getPref(PrefKey.REMOTE_PLAY_ENABLED)) { if (getPref(PrefKey.REMOTE_PLAY_ENABLED)) {
RemotePlayManager.detect(); RemotePlayManager.detect();
@ -428,6 +434,15 @@ function main() {
// Show wait time in game card // Show wait time in game card
getPref(PrefKey.UI_GAME_CARD_SHOW_WAIT_TIME) && GameTile.setup(); getPref(PrefKey.UI_GAME_CARD_SHOW_WAIT_TIME) && GameTile.setup();
EmulatedMkbHandler.setupEvents();
}
// Show a toast when connecting/disconecting controller
if (getPref(PrefKey.CONTROLLER_SHOW_CONNECTION_STATUS)) {
window.addEventListener('gamepadconnected', e => showGamepadToast(e.gamepad));
window.addEventListener('gamepaddisconnected', e => showGamepadToast(e.gamepad));
}
} }
main(); main();

View File

@ -1,5 +1,13 @@
import stylus from 'stylus'; import stylus from 'stylus';
export const isFullVersion = () => {
return Bun.env.BUILD_VARIANT === 'full';
};
export const isLiteVersion = () => {
return Bun.env.BUILD_VARIANT === 'lite';
};
export const renderStylus = async () => { export const renderStylus = async () => {
const file = Bun.file('./src/assets/css/styles.styl'); const file = Bun.file('./src/assets/css/styles.styl');
const cssStr = await file.text(); const cssStr = await file.text();

View File

@ -3,7 +3,6 @@ import { GamepadKey } from "@enums/mkb";
import { PrompFont } from "@enums/prompt-font"; import { PrompFont } from "@enums/prompt-font";
import { CE, removeChildElements } from "@utils/html"; import { CE, removeChildElements } from "@utils/html";
import { t } from "@utils/translation"; import { t } from "@utils/translation";
import { EmulatedMkbHandler } from "./mkb/mkb-handler";
import { StreamStats } from "./stream/stream-stats"; import { StreamStats } from "./stream/stream-stats";
import { MicrophoneShortcut } from "./shortcuts/shortcut-microphone"; import { MicrophoneShortcut } from "./shortcuts/shortcut-microphone";
import { StreamUiShortcut } from "./shortcuts/shortcut-stream-ui"; import { StreamUiShortcut } from "./shortcuts/shortcut-stream-ui";
@ -15,6 +14,7 @@ import { setNearby } from "@/utils/navigation-utils";
import { PrefKey } from "@/enums/pref-keys"; import { PrefKey } from "@/enums/pref-keys";
import { getPref } from "@/utils/settings-storages/global-settings-storage"; import { getPref } from "@/utils/settings-storages/global-settings-storage";
import { SettingsNavigationDialog } from "./ui/dialog/settings-dialog"; import { SettingsNavigationDialog } from "./ui/dialog/settings-dialog";
import { VIRTUAL_GAMEPAD_ID } from "./mkb/mkb-handler";
const enum ShortcutAction { const enum ShortcutAction {
BETTER_XCLOUD_SETTINGS_SHOW = 'bx-settings-show', BETTER_XCLOUD_SETTINGS_SHOW = 'bx-settings-show',
@ -185,7 +185,7 @@ export class ControllerShortcut {
} }
// Ignore emulated gamepad // Ignore emulated gamepad
if (gamepad.id === EmulatedMkbHandler.VIRTUAL_GAMEPAD_ID) { if (gamepad.id === VIRTUAL_GAMEPAD_ID) {
continue; continue;
} }
@ -314,6 +314,7 @@ export class ControllerShortcut {
const $selectProfile = CE<HTMLSelectElement>('select', {class: 'bx-shortcut-profile', autocomplete: 'off'}); const $selectProfile = CE<HTMLSelectElement>('select', {class: 'bx-shortcut-profile', autocomplete: 'off'});
const $profile = PREF_CONTROLLER_FRIENDLY_UI ? BxSelectElement.wrap($selectProfile) : $selectProfile; const $profile = PREF_CONTROLLER_FRIENDLY_UI ? BxSelectElement.wrap($selectProfile) : $selectProfile;
$profile.classList.add('bx-full-width');
const $container = CE('div', { const $container = CE('div', {
'data-has-gamepad': 'false', 'data-has-gamepad': 'false',
@ -390,6 +391,8 @@ export class ControllerShortcut {
if (PREF_CONTROLLER_FRIENDLY_UI) { if (PREF_CONTROLLER_FRIENDLY_UI) {
const $bxSelect = BxSelectElement.wrap($select); const $bxSelect = BxSelectElement.wrap($select);
$bxSelect.classList.add('bx-full-width');
$div.appendChild($bxSelect); $div.appendChild($bxSelect);
setNearby($row, { setNearby($row, {
focus: $bxSelect, focus: $bxSelect,

View File

@ -44,7 +44,7 @@ export class LoadingScreen {
static #hideRocket() { static #hideRocket() {
let $bgStyle = LoadingScreen.#$bgStyle; let $bgStyle = LoadingScreen.#$bgStyle;
const css = compressCss(` $bgStyle.textContent! += compressCss(`
#game-stream div[class*=RocketAnimation-module__container] > svg { #game-stream div[class*=RocketAnimation-module__container] > svg {
display: none; display: none;
} }
@ -53,7 +53,6 @@ export class LoadingScreen {
display: none; display: none;
} }
`); `);
$bgStyle.textContent! += css;
} }
static #setBackground(imageUrl: string) { static #setBackground(imageUrl: string) {
@ -63,7 +62,7 @@ export class LoadingScreen {
// Limit max width to reduce image size // Limit max width to reduce image size
imageUrl = imageUrl + '?w=1920'; imageUrl = imageUrl + '?w=1920';
const css = compressCss(` $bgStyle.textContent! += compressCss(`
#game-stream { #game-stream {
background-color: transparent !important; background-color: transparent !important;
background-position: center center !important; background-position: center center !important;
@ -75,7 +74,6 @@ export class LoadingScreen {
transition: opacity 0.3s ease-in-out !important; transition: opacity 0.3s ease-in-out !important;
} }
`) + `#game-stream {background-image: linear-gradient(#00000033, #000000e6), url(${imageUrl}) !important;}`; `) + `#game-stream {background-image: linear-gradient(#00000033, #000000e6), url(${imageUrl}) !important;}`;
$bgStyle.textContent! += css;
const bg = new Image(); const bg = new Image();
bg.onload = e => { bg.onload = e => {

View File

@ -1,3 +1,5 @@
import { isFullVersion } from "@macros/build" with {type: "macro"};
import { MkbPreset } from "./mkb-preset"; import { MkbPreset } from "./mkb-preset";
import { GamepadKey, MkbPresetKey, GamepadStick, MouseMapTo, WheelCode } from "@enums/mkb"; import { GamepadKey, MkbPresetKey, GamepadStick, MouseMapTo, WheelCode } from "@enums/mkb";
import { createButton, ButtonStyle, CE } from "@utils/html"; import { createButton, ButtonStyle, CE } from "@utils/html";
@ -26,6 +28,7 @@ const PointerToMouseButton = {
4: 1, 4: 1,
} }
export const VIRTUAL_GAMEPAD_ID = 'Xbox 360 Controller';
class WebSocketMouseDataProvider extends MouseDataProvider { class WebSocketMouseDataProvider extends MouseDataProvider {
#pointerClient: PointerClient | undefined #pointerClient: PointerClient | undefined
@ -136,10 +139,8 @@ export class EmulatedMkbHandler extends MkbHandler {
static readonly DEFAULT_DEADZONE_COUNTERWEIGHT = 0.01; static readonly DEFAULT_DEADZONE_COUNTERWEIGHT = 0.01;
static readonly MAXIMUM_STICK_RANGE = 1.1; static readonly MAXIMUM_STICK_RANGE = 1.1;
static VIRTUAL_GAMEPAD_ID = 'Xbox 360 Controller';
#VIRTUAL_GAMEPAD = { #VIRTUAL_GAMEPAD = {
id: EmulatedMkbHandler.VIRTUAL_GAMEPAD_ID, id: VIRTUAL_GAMEPAD_ID,
index: 3, index: 3,
connected: false, connected: false,
hapticActuators: null, hapticActuators: null,
@ -678,7 +679,7 @@ export class EmulatedMkbHandler extends MkbHandler {
} }
static setupEvents() { static setupEvents() {
window.addEventListener(BxEvent.STREAM_PLAYING, () => { isFullVersion() && window.addEventListener(BxEvent.STREAM_PLAYING, () => {
if (STATES.currentStream.titleInfo?.details.hasMkbSupport) { if (STATES.currentStream.titleInfo?.details.hasMkbSupport) {
// Enable native MKB in Android app // Enable native MKB in Android app
if (AppInterface && getPref(PrefKey.NATIVE_MKB_ENABLED) === 'on') { if (AppInterface && getPref(PrefKey.NATIVE_MKB_ENABLED) === 'on') {

View File

@ -1,3 +1,5 @@
import { isFullVersion } from "@macros/build" with {type: "macro"};
import { CE } from "@/utils/html"; import { CE } from "@/utils/html";
import { WebGL2Player } from "./player/webgl2-player"; import { WebGL2Player } from "./player/webgl2-player";
import { Screenshot } from "@/utils/screenshot"; import { Screenshot } from "@/utils/screenshot";
@ -232,7 +234,7 @@ export class StreamPlayer {
webGL2Player.setFilter(2); webGL2Player.setFilter(2);
} }
Screenshot.updateCanvasFilters('none'); isFullVersion() && Screenshot.updateCanvasFilters('none');
webGL2Player.setSharpness(options.sharpness || 0); webGL2Player.setSharpness(options.sharpness || 0);
webGL2Player.setSaturation(options.saturation || 100); webGL2Player.setSaturation(options.saturation || 100);
@ -246,7 +248,7 @@ export class StreamPlayer {
} }
// Apply video filters to screenshots // Apply video filters to screenshots
if (getPref(PrefKey.SCREENSHOT_APPLY_FILTERS)) { if (isFullVersion() && getPref(PrefKey.SCREENSHOT_APPLY_FILTERS)) {
Screenshot.updateCanvasFilters(filters); Screenshot.updateCanvasFilters(filters);
} }

View File

@ -1,9 +1,12 @@
import { isLiteVersion } from "@macros/build" with {type: "macro"};
import { t } from "@utils/translation"; import { t } from "@utils/translation";
import { BxEvent } from "@utils/bx-event"; import { BxEvent } from "@utils/bx-event";
import { CE, createSvgIcon } from "@utils/html"; import { CE, createSvgIcon } from "@utils/html";
import { STATES } from "@utils/global"; import { STATES } from "@utils/global";
import { BxLogger } from "@/utils/bx-logger"; import { BxLogger } from "@/utils/bx-logger";
import { BxIcon } from "@/utils/bx-icon"; import { BxIcon } from "@/utils/bx-icon";
import { GuideMenuTab } from "../ui/guide-menu";
enum StreamBadge { enum StreamBadge {
PLAYTIME = 'playtime', PLAYTIME = 'playtime',
@ -344,24 +347,20 @@ export class StreamBadges {
} catch(e) {} } catch(e) {}
}); });
/* // Since the Lite version doesn't have the "..." button on System menu
Don't do this until xCloud remove the Stream Menu page // we need to display Stream badges in the Guide menu instead
isLiteVersion() && window.addEventListener(BxEvent.XCLOUD_GUIDE_MENU_SHOWN, async e => {
const where = (e as any).where as GuideMenuTab;
window.addEventListener(BxEvent.XCLOUD_GUIDE_SHOWN, async e => { if (where !== GuideMenuTab.HOME || !STATES.isPlaying) {
const where = (e as any).where as XcloudGuideWhere;
if (where !== XcloudGuideWhere.HOME || !STATES.isPlaying) {
return; 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;
}
// Add badges // Add badges
$btnQuit.insertAdjacentElement('beforebegin', await StreamBadges.getInstance().render()); $btnQuit.insertAdjacentElement('beforebegin', await StreamBadges.getInstance().render());
}
}); });
*/
} }
} }

View File

@ -1,6 +1,6 @@
import { GamepadKey } from "@/enums/mkb"; import { GamepadKey } from "@/enums/mkb";
import { PrefKey } from "@/enums/pref-keys"; import { PrefKey } from "@/enums/pref-keys";
import { EmulatedMkbHandler } from "@/modules/mkb/mkb-handler"; import { VIRTUAL_GAMEPAD_ID } from "@/modules/mkb/mkb-handler";
import { BxEvent } from "@/utils/bx-event"; import { BxEvent } from "@/utils/bx-event";
import { STATES } from "@/utils/global"; import { STATES } from "@/utils/global";
import { CE, isElementVisible } from "@/utils/html"; import { CE, isElementVisible } from "@/utils/html";
@ -171,28 +171,42 @@ export class NavigationDialogManager {
} }
// Find un-calculated <select> elements // Find un-calculated <select> elements
const $selects = $dialog.querySelectorAll('.bx-select:not([data-calculated]) select'); this.calculateSelectBoxes($dialog);
});
observer.observe(this.$container, {childList: true});
}
}
calculateSelectBoxes($root: HTMLElement) {
const $selects = $root.querySelectorAll('.bx-select:not([data-calculated]) select');
$selects.forEach($select => { $selects.forEach($select => {
const rect = $select.getBoundingClientRect();
const $parent = $select.parentElement! as HTMLElement; const $parent = $select.parentElement! as HTMLElement;
// Don't apply to select.bx-full-width elements
if ($parent.classList.contains('bx-full-width')) {
$parent.dataset.calculated = 'true'; $parent.dataset.calculated = 'true';
return;
}
const rect = $select.getBoundingClientRect();
let $label; let $label;
let width = Math.ceil(rect.width); let width = Math.ceil(rect.width);
if (!width) {
return;
}
if (($select as HTMLSelectElement).multiple) { if (($select as HTMLSelectElement).multiple) {
$label = $parent.querySelector('.bx-select-value') as HTMLElement; $label = $parent.querySelector('.bx-select-value') as HTMLElement;
width += 15; // Add checkbox's width width += 20; // Add checkbox's width
} else { } else {
$label = $parent.querySelector('div') as HTMLElement; $label = $parent.querySelector('div') as HTMLElement;
} }
// Set min-width // Set min-width
$label.style.minWidth = width + 'px'; $label.style.minWidth = width + 'px';
$parent.dataset.calculated = 'true';
}); });
});
observer.observe(this.$container, {childList: true});
}
} }
handleEvent(event: Event) { handleEvent(event: Event) {
@ -249,7 +263,7 @@ export class NavigationDialogManager {
} }
// Ignore virtual controller // Ignore virtual controller
if (gamepad.id === EmulatedMkbHandler.VIRTUAL_GAMEPAD_ID) { if (gamepad.id === VIRTUAL_GAMEPAD_ID) {
continue; continue;
} }

View File

@ -1,3 +1,5 @@
import { isFullVersion } from "@macros/build" with {type: "macro"};
import { onChangeVideoPlayerType, updateVideoPlayer } from "@/modules/stream/stream-settings-utils"; import { onChangeVideoPlayerType, updateVideoPlayer } from "@/modules/stream/stream-settings-utils";
import { ButtonStyle, CE, createButton, createSvgIcon, removeChildElements, type BxButton } from "@/utils/html"; import { ButtonStyle, CE, createButton, createSvgIcon, removeChildElements, type BxButton } from "@/utils/html";
import { NavigationDialog, NavigationDirection } from "./navigation-dialog"; import { NavigationDialog, NavigationDirection } from "./navigation-dialog";
@ -10,7 +12,7 @@ import { TouchController } from "@/modules/touch-controller";
import { VibrationManager } from "@/modules/vibration-manager"; import { VibrationManager } from "@/modules/vibration-manager";
import { BxEvent } from "@/utils/bx-event"; import { BxEvent } from "@/utils/bx-event";
import { BxIcon } from "@/utils/bx-icon"; import { BxIcon } from "@/utils/bx-icon";
import { STATES, AppInterface, deepClone, SCRIPT_VERSION, STORAGE } from "@/utils/global"; import { STATES, AppInterface, deepClone, SCRIPT_VERSION, STORAGE, SCRIPT_VARIANT } from "@/utils/global";
import { t, Translations } from "@/utils/translation"; import { t, Translations } from "@/utils/translation";
import { BxSelectElement } from "@/web-components/bx-select"; import { BxSelectElement } from "@/web-components/bx-select";
import { setNearby } from "@/utils/navigation-utils"; import { setNearby } from "@/utils/navigation-utils";
@ -38,6 +40,7 @@ type SettingTabContentItem = Partial<{
onChange: (e: any, value: number) => void; onChange: (e: any, value: number) => void;
onCreated: (setting: SettingTabContentItem, $control: any) => void; onCreated: (setting: SettingTabContentItem, $control: any) => void;
params: any; params: any;
requiredVariants?: BuildVariant | Array<BuildVariant>;
}> }>
type SettingTabContent = { type SettingTabContent = {
@ -48,12 +51,14 @@ type SettingTabContent = {
helpUrl?: string; helpUrl?: string;
content?: any; content?: any;
items?: Array<SettingTabContentItem | PrefKey | (($parent: HTMLElement) => void) | false>; items?: Array<SettingTabContentItem | PrefKey | (($parent: HTMLElement) => void) | false>;
requiredVariants?: BuildVariant | Array<BuildVariant>;
}; };
type SettingTab = { type SettingTab = {
icon: SVGElement; icon: SVGElement;
group: 'global'; group: 'global';
items: Array<SettingTabContent | false>; items: Array<SettingTabContent | false>;
requiredVariants?: BuildVariant | Array<BuildVariant>;
}; };
export class SettingsNavigationDialog extends NavigationDialog { export class SettingsNavigationDialog extends NavigationDialog {
@ -205,12 +210,14 @@ export class SettingsNavigationDialog extends NavigationDialog {
PrefKey.STREAM_COMBINE_SOURCES, PrefKey.STREAM_COMBINE_SOURCES,
], ],
}, { }, {
requiredVariants: 'full',
group: 'co-op', group: 'co-op',
label: t('local-co-op'), label: t('local-co-op'),
items: [ items: [
PrefKey.LOCAL_CO_OP_ENABLED, PrefKey.LOCAL_CO_OP_ENABLED,
], ],
}, { }, {
requiredVariants: 'full',
group: 'mkb', group: 'mkb',
label: t('mouse-and-keyboard'), label: t('mouse-and-keyboard'),
items: [ items: [
@ -219,6 +226,7 @@ export class SettingsNavigationDialog extends NavigationDialog {
PrefKey.MKB_HIDE_IDLE_CURSOR, PrefKey.MKB_HIDE_IDLE_CURSOR,
], ],
}, { }, {
requiredVariants: 'full',
group: 'touch-control', group: 'touch-control',
label: t('touch-controller'), label: t('touch-controller'),
note: !STATES.userAgent.capabilities.touch ? '⚠️ ' + t('device-unsupported-touch') : null, note: !STATES.userAgent.capabilities.touch ? '⚠️ ' + t('device-unsupported-touch') : null,
@ -247,6 +255,7 @@ export class SettingsNavigationDialog extends NavigationDialog {
PrefKey.UI_HIDE_SECTIONS, PrefKey.UI_HIDE_SECTIONS,
], ],
}, { }, {
requiredVariants: 'full',
group: 'game-bar', group: 'game-bar',
label: t('game-bar'), label: t('game-bar'),
items: [ items: [
@ -357,6 +366,7 @@ export class SettingsNavigationDialog extends NavigationDialog {
}]; }];
private readonly TAB_DISPLAY_ITEMS: Array<SettingTabContent | false> = [{ private readonly TAB_DISPLAY_ITEMS: Array<SettingTabContent | false> = [{
requiredVariants: 'full',
group: 'audio', group: 'audio',
label: t('audio'), label: t('audio'),
helpUrl: 'https://better-xcloud.github.io/ingame-features/#audio', helpUrl: 'https://better-xcloud.github.io/ingame-features/#audio',
@ -441,7 +451,7 @@ export class SettingsNavigationDialog extends NavigationDialog {
}], }],
}, },
STATES.userAgent.capabilities.touch && { isFullVersion() && STATES.userAgent.capabilities.touch && {
group: 'touch-control', group: 'touch-control',
label: t('touch-controller'), label: t('touch-controller'),
items: [{ items: [{
@ -499,18 +509,19 @@ export class SettingsNavigationDialog extends NavigationDialog {
group: 'mkb', group: 'mkb',
label: t('virtual-controller'), label: t('virtual-controller'),
helpUrl: 'https://better-xcloud.github.io/mouse-and-keyboard/', helpUrl: 'https://better-xcloud.github.io/mouse-and-keyboard/',
content: MkbRemapper.INSTANCE.render(), content: isFullVersion() && MkbRemapper.INSTANCE.render(),
}]; }];
private readonly TAB_NATIVE_MKB_ITEMS: Array<SettingTabContent | false> = [{ private readonly TAB_NATIVE_MKB_ITEMS: Array<SettingTabContent | false> = [{
requiredVariants: 'full',
group: 'native-mkb', group: 'native-mkb',
label: t('native-mkb'), label: t('native-mkb'),
items: [{ items: [isFullVersion() && {
pref: PrefKey.NATIVE_MKB_SCROLL_VERTICAL_SENSITIVITY, pref: PrefKey.NATIVE_MKB_SCROLL_VERTICAL_SENSITIVITY,
onChange: (e: any, value: number) => { onChange: (e: any, value: number) => {
NativeMkbHandler.getInstance().setVerticalScrollMultiplier(value / 100); NativeMkbHandler.getInstance().setVerticalScrollMultiplier(value / 100);
}, },
}, { }, isFullVersion() && {
pref: PrefKey.NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY, pref: PrefKey.NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY,
onChange: (e: any, value: number) => { onChange: (e: any, value: number) => {
NativeMkbHandler.getInstance().setHorizontalScrollMultiplier(value / 100); NativeMkbHandler.getInstance().setHorizontalScrollMultiplier(value / 100);
@ -519,9 +530,10 @@ export class SettingsNavigationDialog extends NavigationDialog {
}]; }];
private readonly TAB_SHORTCUTS_ITEMS: Array<SettingTabContent | false> = [{ private readonly TAB_SHORTCUTS_ITEMS: Array<SettingTabContent | false> = [{
requiredVariants: 'full',
group: 'controller-shortcuts', group: 'controller-shortcuts',
label: t('controller-shortcuts'), label: t('controller-shortcuts'),
content: ControllerShortcut.renderSettings(), content: isFullVersion() && ControllerShortcut.renderSettings(),
}]; }];
private readonly TAB_STATS_ITEMS: Array<SettingTabContent | false> = [{ private readonly TAB_STATS_ITEMS: Array<SettingTabContent | false> = [{
@ -575,24 +587,28 @@ export class SettingsNavigationDialog extends NavigationDialog {
icon: BxIcon.CONTROLLER, icon: BxIcon.CONTROLLER,
group: 'controller', group: 'controller',
items: this.TAB_CONTROLLER_ITEMS, items: this.TAB_CONTROLLER_ITEMS,
requiredVariants: 'full',
}, },
getPref(PrefKey.MKB_ENABLED) && { isFullVersion() && getPref(PrefKey.MKB_ENABLED) && {
icon: BxIcon.VIRTUAL_CONTROLLER, icon: BxIcon.VIRTUAL_CONTROLLER,
group: 'mkb', group: 'mkb',
items: this.TAB_VIRTUAL_CONTROLLER_ITEMS, items: this.TAB_VIRTUAL_CONTROLLER_ITEMS,
requiredVariants: 'full',
}, },
AppInterface && getPref(PrefKey.NATIVE_MKB_ENABLED) === 'on' && { isFullVersion() && AppInterface && getPref(PrefKey.NATIVE_MKB_ENABLED) === 'on' && {
icon: BxIcon.NATIVE_MKB, icon: BxIcon.NATIVE_MKB,
group: 'native-mkb', group: 'native-mkb',
items: this.TAB_NATIVE_MKB_ITEMS, items: this.TAB_NATIVE_MKB_ITEMS,
requiredVariants: 'full',
}, },
{ {
icon: BxIcon.COMMAND, icon: BxIcon.COMMAND,
group: 'shortcuts', group: 'shortcuts',
items: this.TAB_SHORTCUTS_ITEMS, items: this.TAB_SHORTCUTS_ITEMS,
requiredVariants: 'full',
}, },
{ {
@ -715,6 +731,15 @@ export class SettingsNavigationDialog extends NavigationDialog {
} }
} }
private isSupportedVariant(requiredVariants: BuildVariant | Array<BuildVariant> | undefined) {
if (typeof requiredVariants === 'undefined') {
return true;
}
requiredVariants = typeof requiredVariants === 'string' ? [requiredVariants] : requiredVariants;
return requiredVariants.includes(SCRIPT_VARIANT);
}
private async renderSuggestions(e: Event) { private async renderSuggestions(e: Event) {
const $btnSuggest = (e.target as HTMLElement).closest('div')!; const $btnSuggest = (e.target as HTMLElement).closest('div')!;
$btnSuggest.toggleAttribute('bx-open'); $btnSuggest.toggleAttribute('bx-open');
@ -943,6 +968,11 @@ export class SettingsNavigationDialog extends NavigationDialog {
for (const $child of Array.from(this.$settings.children)) { for (const $child of Array.from(this.$settings.children)) {
if ($child.getAttribute('data-tab-group') === settingTab.group) { if ($child.getAttribute('data-tab-group') === settingTab.group) {
$child.classList.remove('bx-gone'); $child.classList.remove('bx-gone');
// Calculate size of controller-friendly select boxes
if (getPref(PrefKey.UI_CONTROLLER_FRIENDLY)) {
this.dialogManager.calculateSelectBoxes($child as HTMLElement);
}
} else { } else {
$child.classList.add('bx-gone'); $child.classList.add('bx-gone');
} }
@ -961,7 +991,7 @@ export class SettingsNavigationDialog extends NavigationDialog {
private onGlobalSettingChanged(e: Event) { private onGlobalSettingChanged(e: Event) {
// Clear PatcherCache; // Clear PatcherCache;
PatcherCache.clear(); isFullVersion() && PatcherCache.clear();
this.$btnReload.classList.add('bx-danger'); this.$btnReload.classList.add('bx-danger');
@ -1096,6 +1126,10 @@ export class SettingsNavigationDialog extends NavigationDialog {
prefDefinition = getPrefDefinition(pref); prefDefinition = getPrefDefinition(pref);
} }
if (prefDefinition && !this.isSupportedVariant(prefDefinition.requiredVariants)) {
return;
}
let label = prefDefinition?.label || setting.label; let label = prefDefinition?.label || setting.label;
let note = prefDefinition?.note || setting.note; let note = prefDefinition?.note || setting.note;
const experimental = prefDefinition?.experimental || setting.experimental; const experimental = prefDefinition?.experimental || setting.experimental;
@ -1118,6 +1152,7 @@ export class SettingsNavigationDialog extends NavigationDialog {
} }
let $label; let $label;
const $row = CE('label', { const $row = CE('label', {
class: 'bx-settings-row', class: 'bx-settings-row',
for: `bx_setting_${pref}`, for: `bx_setting_${pref}`,
@ -1128,10 +1163,9 @@ export class SettingsNavigationDialog extends NavigationDialog {
}, },
$label = CE('span', {class: 'bx-settings-label'}, $label = CE('span', {class: 'bx-settings-label'},
label, label,
note && CE('div', {class: 'bx-settings-dialog-note'}, note), note ? CE('div', {class: 'bx-settings-dialog-note'}, note) : prefDefinition?.unsupported && CE('div', {class: 'bx-settings-dialog-note'}, t('browser-unsupported-feature')),
setting.unsupported && CE('div', {class: 'bx-settings-dialog-note'}, t('browser-unsupported-feature')),
), ),
!setting.unsupported && $control, !prefDefinition?.unsupported && $control,
); );
// Make link inside <label> focusable // Make link inside <label> focusable
@ -1144,7 +1178,7 @@ export class SettingsNavigationDialog extends NavigationDialog {
} }
$tabContent.appendChild($row); $tabContent.appendChild($row);
setting.onCreated && setting.onCreated(setting, $control); !prefDefinition?.unsupported && setting.onCreated && setting.onCreated(setting, $control);
} }
private setupDialog() { private setupDialog() {
@ -1232,6 +1266,11 @@ export class SettingsNavigationDialog extends NavigationDialog {
continue; continue;
} }
// Don't render unsupported build variant
if (!this.isSupportedVariant(settingTab.requiredVariants)) {
continue;
}
// Don't render other tabs in unsupported regions // Don't render other tabs in unsupported regions
if (settingTab.group !== 'global' && !this.renderFullSettings) { if (settingTab.group !== 'global' && !this.renderFullSettings) {
continue; continue;
@ -1250,6 +1289,10 @@ export class SettingsNavigationDialog extends NavigationDialog {
continue; continue;
} }
if (!this.isSupportedVariant(settingTabContent.requiredVariants)) {
continue;
}
// Don't render other settings in unsupported regions // Don't render other settings in unsupported regions
if (!this.renderFullSettings && settingTab.group === 'global' && settingTabContent.group !== 'general' && settingTabContent.group !== 'footer') { if (!this.renderFullSettings && settingTab.group === 'global' && settingTabContent.group !== 'general' && settingTabContent.group !== 'footer') {
continue; continue;
@ -1260,6 +1303,11 @@ export class SettingsNavigationDialog extends NavigationDialog {
// If label is "Better xCloud" => create a link to Releases page // If label is "Better xCloud" => create a link to Releases page
if (label === t('better-xcloud')) { if (label === t('better-xcloud')) {
label += ' ' + SCRIPT_VERSION; label += ' ' + SCRIPT_VERSION;
if (SCRIPT_VARIANT === 'lite') {
label += ' (Lite)';
}
label = createButton({ label = createButton({
label: label, label: label,
url: 'https://github.com/redphx/better-xcloud/releases', url: 'https://github.com/redphx/better-xcloud/releases',

View File

@ -1,3 +1,5 @@
import { isFullVersion } from "@macros/build" with {type: "macro"};
import { BxEvent } from "@/utils/bx-event"; import { BxEvent } from "@/utils/bx-event";
import { AppInterface, STATES } from "@/utils/global"; import { AppInterface, STATES } from "@/utils/global";
import { createButton, ButtonStyle, CE } from "@/utils/html"; import { createButton, ButtonStyle, CE } from "@/utils/html";
@ -22,7 +24,7 @@ export class GuideMenu {
}, {once: true}); }, {once: true});
// Close all xCloud's dialogs // Close all xCloud's dialogs
window.BX_EXPOSED.dialogRoutes.closeAll(); GuideMenu.#closeGuideMenu();
}, },
}), }),
@ -53,7 +55,7 @@ export class GuideMenu {
} }
// Close all xCloud's dialogs // Close all xCloud's dialogs
window.BX_EXPOSED.dialogRoutes.closeAll(); GuideMenu.#closeGuideMenu();
}, },
}), }),
@ -66,7 +68,7 @@ export class GuideMenu {
confirm(t('back-to-home-confirm')) && (window.location.href = window.location.href.substring(0, 31)); confirm(t('back-to-home-confirm')) && (window.location.href = window.location.href.substring(0, 31));
// Close all xCloud's dialogs // Close all xCloud's dialogs
window.BX_EXPOSED.dialogRoutes.closeAll(); GuideMenu.#closeGuideMenu();
}, },
attributes: { attributes: {
'data-state': 'playing', 'data-state': 'playing',
@ -76,6 +78,17 @@ export class GuideMenu {
static #$renderedButtons: HTMLElement; static #$renderedButtons: HTMLElement;
static #closeGuideMenu() {
if (window.BX_EXPOSED.dialogRoutes) {
window.BX_EXPOSED.dialogRoutes.closeAll();
return;
}
// Use alternative method for Lite version
const $btnClose = document.querySelector('#gamepass-dialog-root button[class^=Header-module__closeButton]') as HTMLElement;
$btnClose && $btnClose.click();
}
static #renderButtons() { static #renderButtons() {
if (GuideMenu.#$renderedButtons) { if (GuideMenu.#$renderedButtons) {
return GuideMenu.#$renderedButtons; return GuideMenu.#$renderedButtons;
@ -115,10 +128,12 @@ export class GuideMenu {
} }
static #injectHome($root: HTMLElement, isPlaying = false) { static #injectHome($root: HTMLElement, isPlaying = false) {
if (isFullVersion()) {
const $achievementsProgress = $root.querySelector('button[class*=AchievementsButton-module__progressBarContainer]'); const $achievementsProgress = $root.querySelector('button[class*=AchievementsButton-module__progressBarContainer]');
if ($achievementsProgress) { if ($achievementsProgress) {
TrueAchievements.injectAchievementsProgress($achievementsProgress as HTMLElement); TrueAchievements.injectAchievementsProgress($achievementsProgress as HTMLElement);
} }
}
// Find the element to add buttons to // Find the element to add buttons to
let $target: HTMLElement | null = null; let $target: HTMLElement | null = null;
@ -162,7 +177,7 @@ export class GuideMenu {
static observe($addedElm: HTMLElement) { static observe($addedElm: HTMLElement) {
const className = $addedElm.className; const className = $addedElm.className;
if (className.includes('AchievementsButton-module__progressBarContainer')) { if (isFullVersion() && className.includes('AchievementsButton-module__progressBarContainer')) {
TrueAchievements.injectAchievementsProgress($addedElm); TrueAchievements.injectAchievementsProgress($addedElm);
return; return;
} }
@ -174,11 +189,13 @@ export class GuideMenu {
} }
// Achievement Details page // Achievement Details page
if (isFullVersion()) {
const $achievDetailPage = $addedElm.querySelector('div[class*=AchievementDetailPage]'); const $achievDetailPage = $addedElm.querySelector('div[class*=AchievementDetailPage]');
if ($achievDetailPage) { if ($achievDetailPage) {
TrueAchievements.injectAchievementDetailPage($achievDetailPage as HTMLElement); TrueAchievements.injectAchievementDetailPage($achievDetailPage as HTMLElement);
return; return;
} }
}
// Find navigation bar // Find navigation bar
const $selectedTab = $addedElm.querySelector('div[class^=NavigationMenu] button[aria-selected=true'); const $selectedTab = $addedElm.querySelector('div[class^=NavigationMenu] button[aria-selected=true');

View File

@ -63,7 +63,7 @@ export class HeaderSection {
static checkHeader() { static checkHeader() {
let $target = document.querySelector('#PageContent div[class*=EdgewaterHeader-module__rightSectionSpacing]'); let $target = document.querySelector('#PageContent div[class*=EdgewaterHeader-module__rightSectionSpacing]');
if (!$target) { if (!$target) {
$target = document.querySelector("div[class^=UnsupportedMarketPage-module__buttons]"); $target = document.querySelector('div[class^=UnsupportedMarketPage-module__buttons]');
} }
$target && HeaderSection.#injectSettingsButton($target as HTMLElement); $target && HeaderSection.#injectSettingsButton($target as HTMLElement);

View File

@ -1,12 +1,11 @@
import { BX_FLAGS } from "@/utils/bx-flags"; import { BX_FLAGS } from "@/utils/bx-flags";
import { BxIcon } from "@/utils/bx-icon"; import { BxIcon } from "@/utils/bx-icon";
import { AppInterface } from "@/utils/global"; import { AppInterface } from "@/utils/global";
import { ButtonStyle, createButton } from "@/utils/html"; import { ButtonStyle, CE, createButton } from "@/utils/html";
import { t } from "@/utils/translation"; import { t } from "@/utils/translation";
export class ProductDetailsPage { export class ProductDetailsPage {
private static $btnShortcut = AppInterface && createButton({ private static $btnShortcut = AppInterface && createButton({
classes: ['bx-button-shortcut'],
icon: BxIcon.CREATE_SHORTCUT, icon: BxIcon.CREATE_SHORTCUT,
label: t('create-shortcut'), label: t('create-shortcut'),
style: ButtonStyle.FOCUSABLE, style: ButtonStyle.FOCUSABLE,
@ -17,7 +16,6 @@ export class ProductDetailsPage {
}); });
private static $btnWallpaper = AppInterface && createButton({ private static $btnWallpaper = AppInterface && createButton({
classes: ['bx-button-shortcut'],
icon: BxIcon.DOWNLOAD, icon: BxIcon.DOWNLOAD,
label: t('wallpaper'), label: t('wallpaper'),
style: ButtonStyle.FOCUSABLE, style: ButtonStyle.FOCUSABLE,
@ -48,17 +46,12 @@ export class ProductDetailsPage {
// Find action buttons container // Find action buttons container
const $container = document.querySelector('div[class*=ActionButtons-module__container]'); const $container = document.querySelector('div[class*=ActionButtons-module__container]');
if ($container && $container.parentElement) { if ($container && $container.parentElement) {
const fragment = document.createDocumentFragment(); $container.parentElement.appendChild(CE('div', {
class: 'bx-product-details-buttons',
// Shortcut button },
if (BX_FLAGS.DeviceInfo.deviceType === 'android') { BX_FLAGS.DeviceInfo.deviceType === 'android' && ProductDetailsPage.$btnShortcut,
fragment.appendChild(ProductDetailsPage.$btnShortcut); ProductDetailsPage.$btnWallpaper,
} ));
// Wallpaper button
fragment.appendChild(ProductDetailsPage.$btnWallpaper);
$container.parentElement.appendChild(fragment);
} }
}, 500); }, 500);
} }

View File

@ -1,7 +1,9 @@
type BuildVariant = 'full' | 'lite';
// Get type of an array's element // Get type of an array's element
type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[] ? ElementType : never; type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[] ? ElementType : never;
type PartialRecord<K extends keyof any, T> = Partial<Record<K, T>> type PartialRecord<K extends keyof any, T> = Partial<Record<K, T>>;
interface Window { interface Window {
AppInterface: any; AppInterface: any;

View File

@ -24,6 +24,7 @@ export type SettingDefinition = {
suggest: PartialRecord<SuggestedSettingCategory, any>, suggest: PartialRecord<SuggestedSettingCategory, any>,
ready: (setting: SettingDefinition) => void; ready: (setting: SettingDefinition) => void;
type: SettingElementType, type: SettingElementType,
requiredVariants: BuildVariant | Array<BuildVariant>;
// migrate?: (this: Preferences, savedPrefs: any, value: any) => void; // migrate?: (this: Preferences, savedPrefs: any, value: any) => void;
}> & ( }> & (
{} | { {} | {

View File

@ -1,3 +1,5 @@
import { isFullVersion } from "@macros/build" with {type: "macro"};
import { ControllerShortcut } from "@/modules/controller-shortcut"; import { ControllerShortcut } from "@/modules/controller-shortcut";
import { BxEvent } from "@utils/bx-event"; import { BxEvent } from "@utils/bx-event";
import { deepClone, STATES } from "@utils/global"; import { deepClone, STATES } from "@utils/global";
@ -20,7 +22,7 @@ export type SupportedInputTypeValue = (typeof SupportedInputType)[keyof typeof S
export const BxExposed = { export const BxExposed = {
getTitleInfo: () => STATES.currentStream.titleInfo, getTitleInfo: () => STATES.currentStream.titleInfo,
modifyTitleInfo: (titleInfo: XcloudTitleInfo): XcloudTitleInfo => { modifyTitleInfo: isFullVersion() && function(titleInfo: XcloudTitleInfo): XcloudTitleInfo {
// Clone the object since the original is read-only // Clone the object since the original is read-only
titleInfo = deepClone(titleInfo); titleInfo = deepClone(titleInfo);
@ -110,8 +112,8 @@ export const BxExposed = {
} }
}, },
handleControllerShortcut: ControllerShortcut.handle, handleControllerShortcut: isFullVersion() && ControllerShortcut.handle,
resetControllerShortcut: ControllerShortcut.reset, resetControllerShortcut: isFullVersion() && ControllerShortcut.reset,
overrideSettings: { overrideSettings: {
'Tv_settings': { 'Tv_settings': {

View File

@ -1,4 +1,4 @@
import { EmulatedMkbHandler } from "@modules/mkb/mkb-handler"; import { VIRTUAL_GAMEPAD_ID } from "@modules/mkb/mkb-handler";
import { t } from "@utils/translation"; import { t } from "@utils/translation";
import { Toast } from "@utils/toast"; import { Toast } from "@utils/toast";
import { BxLogger } from "@utils/bx-logger"; import { BxLogger } from "@utils/bx-logger";
@ -8,7 +8,7 @@ import { getPref } from "./settings-storages/global-settings-storage";
// Show a toast when connecting/disconecting controller // Show a toast when connecting/disconecting controller
export function showGamepadToast(gamepad: Gamepad) { export function showGamepadToast(gamepad: Gamepad) {
// Don't show Toast for virtual controller // Don't show Toast for virtual controller
if (gamepad.id === EmulatedMkbHandler.VIRTUAL_GAMEPAD_ID) { if (gamepad.id === VIRTUAL_GAMEPAD_ID) {
return; return;
} }

View File

@ -2,6 +2,7 @@ import type { BaseSettingsStore } from "./settings-storages/base-settings-storag
import { UserAgent } from "./user-agent"; import { UserAgent } from "./user-agent";
export const SCRIPT_VERSION = Bun.env.SCRIPT_VERSION!; export const SCRIPT_VERSION = Bun.env.SCRIPT_VERSION!;
export const SCRIPT_VARIANT = Bun.env.BUILD_VARIANT! as BuildVariant;
export const AppInterface = window.AppInterface; export const AppInterface = window.AppInterface;

View File

@ -1,3 +1,5 @@
import { isFullVersion } from "@macros/build" with {type: "macro"};
import { BxEvent } from "@utils/bx-event"; import { BxEvent } from "@utils/bx-event";
import { BX_FLAGS, NATIVE_FETCH } from "@utils/bx-flags"; import { BX_FLAGS, NATIVE_FETCH } from "@utils/bx-flags";
import { TouchController } from "@modules/touch-controller"; import { TouchController } from "@modules/touch-controller";
@ -222,7 +224,7 @@ export function interceptHttpRequests() {
for (let i = 1; i < obj.length; i++) { for (let i = 1; i < obj.length; i++) {
gamepassAllGames.push(obj[i].id); gamepassAllGames.push(obj[i].id);
} }
} else if (url.includes(GamePassCloudGallery.TOUCH)) { } else if (isFullVersion() && url.includes(GamePassCloudGallery.TOUCH)) {
try { try {
let customList = TouchController.getCustomList(); let customList = TouchController.getCustomList();
@ -262,7 +264,7 @@ export function interceptHttpRequests() {
requestType = 'xcloud'; requestType = 'xcloud';
} }
if (requestType === 'xhome') { if (isFullVersion() && requestType === 'xhome') {
return XhomeInterceptor.handle(request as Request); return XhomeInterceptor.handle(request as Request);
} }

View File

@ -31,7 +31,7 @@ export class Screenshot {
} }
static updateCanvasFilters(filters: string) { static updateCanvasFilters(filters: string) {
Screenshot.#canvasContext.filter = filters; Screenshot.#canvasContext && (Screenshot.#canvasContext.filter = filters);
} }
static #onAnimationEnd(e: Event) { static #onAnimationEnd(e: Event) {

View File

@ -3,6 +3,7 @@ import type { NumberStepperParams, SettingDefinitions } from "@/types/setting-de
import { BxEvent } from "../bx-event"; import { BxEvent } from "../bx-event";
import { SettingElementType } from "../setting-element"; import { SettingElementType } from "../setting-element";
import { t } from "../translation"; import { t } from "../translation";
import { SCRIPT_VARIANT } from "../global";
export class BaseSettingsStore { export class BaseSettingsStore {
private storage: Storage; private storage: Storage;
@ -18,6 +19,11 @@ export class BaseSettingsStore {
for (settingId in definitions) { for (settingId in definitions) {
const setting = definitions[settingId]; const setting = definitions[settingId];
// Convert requiredVariants to array
if (typeof setting.requiredVariants === 'string') {
setting.requiredVariants = [setting.requiredVariants];
}
/* /*
if (setting.migrate && settingId in savedPrefs) { if (setting.migrate && settingId in savedPrefs) {
setting.migrate.call(this, savedPrefs, savedPrefs[settingId]); setting.migrate.call(this, savedPrefs, savedPrefs[settingId]);
@ -58,9 +64,16 @@ export class BaseSettingsStore {
return; return;
} }
const definition = this.definitions[key];
// Return default value if build variant is different
if (definition.requiredVariants && !definition.requiredVariants.includes(SCRIPT_VARIANT)) {
return definition.default;
}
// Return default value if the feature is not supported // Return default value if the feature is not supported
if (checkUnsupported && this.definitions[key].unsupported) { if (checkUnsupported && definition.unsupported) {
return this.definitions[key].default; return definition.default;
} }
if (!(key in this.settings)) { if (!(key in this.settings)) {

View File

@ -197,6 +197,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
[PrefKey.SCREENSHOT_APPLY_FILTERS]: { [PrefKey.SCREENSHOT_APPLY_FILTERS]: {
requiredVariants: 'full',
label: t('screenshot-apply-filters'), label: t('screenshot-apply-filters'),
default: false, default: false,
}, },
@ -211,6 +212,8 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
[PrefKey.STREAM_COMBINE_SOURCES]: { [PrefKey.STREAM_COMBINE_SOURCES]: {
requiredVariants: 'full',
label: t('combine-audio-video-streams'), label: t('combine-audio-video-streams'),
default: false, default: false,
experimental: true, experimental: true,
@ -218,6 +221,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
[PrefKey.STREAM_TOUCH_CONTROLLER]: { [PrefKey.STREAM_TOUCH_CONTROLLER]: {
requiredVariants: 'full',
label: t('tc-availability'), label: t('tc-availability'),
default: StreamTouchController.ALL, default: StreamTouchController.ALL,
options: { options: {
@ -233,11 +237,13 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
}, },
[PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF]: { [PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF]: {
requiredVariants: 'full',
label: t('tc-auto-off'), label: t('tc-auto-off'),
default: false, default: false,
unsupported: !STATES.userAgent.capabilities.touch, unsupported: !STATES.userAgent.capabilities.touch,
}, },
[PrefKey.STREAM_TOUCH_CONTROLLER_DEFAULT_OPACITY]: { [PrefKey.STREAM_TOUCH_CONTROLLER_DEFAULT_OPACITY]: {
requiredVariants: 'full',
type: SettingElementType.NUMBER_STEPPER, type: SettingElementType.NUMBER_STEPPER,
label: t('tc-default-opacity'), label: t('tc-default-opacity'),
default: 100, default: 100,
@ -252,6 +258,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
unsupported: !STATES.userAgent.capabilities.touch, unsupported: !STATES.userAgent.capabilities.touch,
}, },
[PrefKey.STREAM_TOUCH_CONTROLLER_STYLE_STANDARD]: { [PrefKey.STREAM_TOUCH_CONTROLLER_STYLE_STANDARD]: {
requiredVariants: 'full',
label: t('tc-standard-layout-style'), label: t('tc-standard-layout-style'),
default: 'default', default: 'default',
options: { options: {
@ -262,6 +269,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
unsupported: !STATES.userAgent.capabilities.touch, unsupported: !STATES.userAgent.capabilities.touch,
}, },
[PrefKey.STREAM_TOUCH_CONTROLLER_STYLE_CUSTOM]: { [PrefKey.STREAM_TOUCH_CONTROLLER_STYLE_CUSTOM]: {
requiredVariants: 'full',
label: t('tc-custom-layout-style'), label: t('tc-custom-layout-style'),
default: 'default', default: 'default',
options: { options: {
@ -276,15 +284,18 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
default: false, default: false,
}, },
[PrefKey.MKB_HIDE_IDLE_CURSOR]: { [PrefKey.MKB_HIDE_IDLE_CURSOR]: {
requiredVariants: 'full',
label: t('hide-idle-cursor'), label: t('hide-idle-cursor'),
default: false, default: false,
}, },
[PrefKey.STREAM_DISABLE_FEEDBACK_DIALOG]: { [PrefKey.STREAM_DISABLE_FEEDBACK_DIALOG]: {
requiredVariants: 'full',
label: t('disable-post-stream-feedback-dialog'), label: t('disable-post-stream-feedback-dialog'),
default: false, default: false,
}, },
[PrefKey.BITRATE_VIDEO_MAX]: { [PrefKey.BITRATE_VIDEO_MAX]: {
requiredVariants: 'full',
type: SettingElementType.NUMBER_STEPPER, type: SettingElementType.NUMBER_STEPPER,
label: t('bitrate-video-maximum'), label: t('bitrate-video-maximum'),
note: '⚠️ ' + t('unexpected-behavior'), note: '⚠️ ' + t('unexpected-behavior'),
@ -306,10 +317,11 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
suggest: { suggest: {
highest: 0, highest: 0,
} },
}, },
[PrefKey.GAME_BAR_POSITION]: { [PrefKey.GAME_BAR_POSITION]: {
requiredVariants: 'full',
label: t('position'), label: t('position'),
default: 'bottom-left', default: 'bottom-left',
options: { options: {
@ -320,6 +332,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
[PrefKey.LOCAL_CO_OP_ENABLED]: { [PrefKey.LOCAL_CO_OP_ENABLED]: {
requiredVariants: 'full',
label: t('enable-local-co-op-support'), label: t('enable-local-co-op-support'),
default: false, default: false,
note: CE<HTMLAnchorElement>('a', { note: CE<HTMLAnchorElement>('a', {
@ -341,15 +354,18 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
[PrefKey.CONTROLLER_ENABLE_SHORTCUTS]: { [PrefKey.CONTROLLER_ENABLE_SHORTCUTS]: {
requiredVariants: 'full',
default: false, default: false,
}, },
[PrefKey.CONTROLLER_ENABLE_VIBRATION]: { [PrefKey.CONTROLLER_ENABLE_VIBRATION]: {
requiredVariants: 'full',
label: t('controller-vibration'), label: t('controller-vibration'),
default: true, default: true,
}, },
[PrefKey.CONTROLLER_DEVICE_VIBRATION]: { [PrefKey.CONTROLLER_DEVICE_VIBRATION]: {
requiredVariants: 'full',
label: t('device-vibration'), label: t('device-vibration'),
default: ControllerDeviceVibration.OFF, default: ControllerDeviceVibration.OFF,
options: { options: {
@ -360,6 +376,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
[PrefKey.CONTROLLER_VIBRATION_INTENSITY]: { [PrefKey.CONTROLLER_VIBRATION_INTENSITY]: {
requiredVariants: 'full',
label: t('vibration-intensity'), label: t('vibration-intensity'),
type: SettingElementType.NUMBER_STEPPER, type: SettingElementType.NUMBER_STEPPER,
default: 100, default: 100,
@ -373,6 +390,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
[PrefKey.MKB_ENABLED]: { [PrefKey.MKB_ENABLED]: {
requiredVariants: 'full',
label: t('enable-mkb'), label: t('enable-mkb'),
default: false, default: false,
unsupported: ((): string | boolean => { unsupported: ((): string | boolean => {
@ -398,6 +416,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
[PrefKey.NATIVE_MKB_ENABLED]: { [PrefKey.NATIVE_MKB_ENABLED]: {
requiredVariants: 'full',
label: t('native-mkb'), label: t('native-mkb'),
default: 'default', default: 'default',
options: { options: {
@ -419,6 +438,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
[PrefKey.NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY]: { [PrefKey.NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY]: {
requiredVariants: 'full',
label: t('horizontal-scroll-sensitivity'), label: t('horizontal-scroll-sensitivity'),
type: SettingElementType.NUMBER_STEPPER, type: SettingElementType.NUMBER_STEPPER,
default: 0, default: 0,
@ -438,6 +458,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
[PrefKey.NATIVE_MKB_SCROLL_VERTICAL_SENSITIVITY]: { [PrefKey.NATIVE_MKB_SCROLL_VERTICAL_SENSITIVITY]: {
requiredVariants: 'full',
label: t('vertical-scroll-sensitivity'), label: t('vertical-scroll-sensitivity'),
type: SettingElementType.NUMBER_STEPPER, type: SettingElementType.NUMBER_STEPPER,
default: 0, default: 0,
@ -457,10 +478,12 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
[PrefKey.MKB_DEFAULT_PRESET_ID]: { [PrefKey.MKB_DEFAULT_PRESET_ID]: {
requiredVariants: 'full',
default: 0, default: 0,
}, },
[PrefKey.MKB_ABSOLUTE_MOUSE]: { [PrefKey.MKB_ABSOLUTE_MOUSE]: {
requiredVariants: 'full',
default: false, default: false,
}, },
@ -470,6 +493,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
[PrefKey.UI_LOADING_SCREEN_GAME_ART]: { [PrefKey.UI_LOADING_SCREEN_GAME_ART]: {
requiredVariants: 'full',
label: t('show-game-art'), label: t('show-game-art'),
default: true, default: true,
}, },
@ -493,6 +517,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
[PrefKey.UI_LAYOUT]: { [PrefKey.UI_LAYOUT]: {
requiredVariants: 'full',
label: t('layout'), label: t('layout'),
default: 'default', default: 'default',
options: { options: {
@ -508,11 +533,13 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
[PrefKey.UI_HOME_CONTEXT_MENU_DISABLED]: { [PrefKey.UI_HOME_CONTEXT_MENU_DISABLED]: {
requiredVariants: 'full',
label: t('disable-home-context-menu'), label: t('disable-home-context-menu'),
default: STATES.browser.capabilities.touch, default: STATES.browser.capabilities.touch,
}, },
[PrefKey.UI_HIDE_SECTIONS]: { [PrefKey.UI_HIDE_SECTIONS]: {
requiredVariants: 'full',
label: t('hide-sections'), label: t('hide-sections'),
default: [], default: [],
multipleOptions: { multipleOptions: {
@ -529,6 +556,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
[PrefKey.UI_GAME_CARD_SHOW_WAIT_TIME]: { [PrefKey.UI_GAME_CARD_SHOW_WAIT_TIME]: {
requiredVariants: 'full',
label: t('show-wait-time-in-game-card'), label: t('show-wait-time-in-game-card'),
default: false, default: false,
}, },
@ -663,6 +691,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
default: false, default: false,
}, },
[PrefKey.AUDIO_ENABLE_VOLUME_CONTROL]: { [PrefKey.AUDIO_ENABLE_VOLUME_CONTROL]: {
requiredVariants: 'full',
label: t('enable-volume-control'), label: t('enable-volume-control'),
default: false, default: false,
}, },
@ -743,11 +772,13 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
[PrefKey.REMOTE_PLAY_ENABLED]: { [PrefKey.REMOTE_PLAY_ENABLED]: {
requiredVariants: 'full',
label: t('enable-remote-play-feature'), label: t('enable-remote-play-feature'),
default: false, default: false,
}, },
[PrefKey.REMOTE_PLAY_RESOLUTION]: { [PrefKey.REMOTE_PLAY_RESOLUTION]: {
requiredVariants: 'full',
default: StreamResolution.DIM_1080P, default: StreamResolution.DIM_1080P,
options: { options: {
[StreamResolution.DIM_1080P]: '1080p', [StreamResolution.DIM_1080P]: '1080p',
@ -756,6 +787,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
[PrefKey.GAME_FORTNITE_FORCE_CONSOLE]: { [PrefKey.GAME_FORTNITE_FORCE_CONSOLE]: {
requiredVariants: 'full',
label: '🎮 ' + t('fortnite-force-console-version'), label: '🎮 ' + t('fortnite-force-console-version'),
default: false, default: false,
note: t('fortnite-allow-stw-mode'), note: t('fortnite-allow-stw-mode'),

View File

@ -171,7 +171,7 @@ const Texts = {
(e: any) => `Dostępna jest nowa wersja ${e.version}`, (e: any) => `Dostępna jest nowa wersja ${e.version}`,
(e: any) => `Versão ${e.version} disponível`, (e: any) => `Versão ${e.version} disponível`,
, ,
, (e: any) => `เวอร์ชัน ${e.version} พร้อมใช้งานแล้ว`,
, ,
(e: any) => `Доступна версія ${e.version}`, (e: any) => `Доступна версія ${e.version}`,
(e: any) => `Đã có phiên bản ${e.version}`, (e: any) => `Đã có phiên bản ${e.version}`,
@ -232,7 +232,7 @@ const Texts = {
(e: any) => `Zalecane ustawienia dla ${e.device}`, (e: any) => `Zalecane ustawienia dla ${e.device}`,
(e: any) => `Configurações recomendadas para ${e.device}`, (e: any) => `Configurações recomendadas para ${e.device}`,
(e: any) => `Рекомендуемые настройки для ${e.device}`, (e: any) => `Рекомендуемые настройки для ${e.device}`,
, (e: any) => `การตั้งค่าที่แนะนำสำหรับ ${e.device}`,
(e: any) => `${e.device} için önerilen ayarlar`, (e: any) => `${e.device} için önerilen ayarlar`,
(e: any) => `Рекомендовані налаштування для ${e.device}`, (e: any) => `Рекомендовані налаштування для ${e.device}`,
(e: any) => `Cấu hình được đề xuất cho ${e.device}`, (e: any) => `Cấu hình được đề xuất cho ${e.device}`,

View File

@ -1,5 +1,5 @@
import { BxIcon } from "./bx-icon"; import { BxIcon } from "./bx-icon";
import { AppInterface, STATES } from "./global"; import { AppInterface, SCRIPT_VARIANT, STATES } from "./global";
import { ButtonStyle, CE, clearDataSet, createButton, getReactProps } from "./html"; import { ButtonStyle, CE, clearDataSet, createButton, getReactProps } from "./html";
import { t } from "./translation"; import { t } from "./translation";
@ -27,7 +27,7 @@ export class TrueAchievements {
TrueAchievements.open(true, dataset.xboxTitleId, dataset.id); TrueAchievements.open(true, dataset.xboxTitleId, dataset.id);
// Close all xCloud's dialogs // Close all xCloud's dialogs
window.BX_EXPOSED.dialogRoutes.closeAll(); window.BX_EXPOSED.dialogRoutes?.closeAll();
} }
private static $hiddenLink = CE<HTMLAnchorElement>('a', { private static $hiddenLink = CE<HTMLAnchorElement>('a', {
@ -53,6 +53,11 @@ export class TrueAchievements {
} }
static injectAchievementsProgress($elm: HTMLElement) { static injectAchievementsProgress($elm: HTMLElement) {
// Only do this in Full version
if (SCRIPT_VARIANT !== 'full') {
return;
}
const $parent = $elm.parentElement!; const $parent = $elm.parentElement!;
// Wrap xCloud's element with our own // Wrap xCloud's element with our own
@ -89,6 +94,11 @@ export class TrueAchievements {
} }
static injectAchievementDetailPage($parent: HTMLElement) { static injectAchievementDetailPage($parent: HTMLElement) {
// Only do this in Full version
if (SCRIPT_VARIANT !== 'full') {
return;
}
const props = getReactProps($parent); const props = getReactProps($parent);
if (!props) { if (!props) {
return; return;

View File

@ -1,3 +1,5 @@
import { isFullVersion } from "@macros/build" with {type: "macro"};
import { LoadingScreen } from "@modules/loading-screen"; import { LoadingScreen } from "@modules/loading-screen";
import { RemotePlayManager } from "@/modules/remote-play-manager"; import { RemotePlayManager } from "@/modules/remote-play-manager";
import { StreamBadges } from "@modules/stream/stream-badges"; import { StreamBadges } from "@modules/stream/stream-badges";
@ -147,7 +149,7 @@ class XcloudInterceptor {
} }
// Touch controller for all games // Touch controller for all games
if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === StreamTouchController.ALL) { if (isFullVersion() && getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === StreamTouchController.ALL) {
const titleInfo = STATES.currentStream.titleInfo; const titleInfo = STATES.currentStream.titleInfo;
if (titleInfo?.details.hasTouchSupport) { if (titleInfo?.details.hasTouchSupport) {
TouchController.disable(); TouchController.disable();
@ -187,7 +189,7 @@ class XcloudInterceptor {
} }
// Enable touch controller // Enable touch controller
if (TouchController.isEnabled()) { if (isFullVersion() && TouchController.isEnabled()) {
overrides.inputConfiguration.enableTouchInput = true; overrides.inputConfiguration.enableTouchInput = true;
overrides.inputConfiguration.maxTouchPoints = 10; overrides.inputConfiguration.maxTouchPoints = 10;
} }