mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-29 02:41:44 +02:00
Compare commits
96 Commits
Author | SHA1 | Date | |
---|---|---|---|
49a6c036a3 | |||
f5a5a79a82 | |||
7ec449160a | |||
fecc5411da | |||
f704452171 | |||
135193813c | |||
bb57f72e64 | |||
69d7cbfffb | |||
92e6828cb2 | |||
12ad81e9c7 | |||
102e0bd318 | |||
9308963bc2 | |||
c90e013dc1 | |||
037927b9be | |||
dabab9acb1 | |||
a4a52c6bc3 | |||
eebd7434ea | |||
ec1805f832 | |||
34f959d5ae | |||
784a31ce43 | |||
df266d32fc | |||
a6ccd6666e | |||
fe609034d6 | |||
97ec29faa0 | |||
a34ae75131 | |||
139543aaa5 | |||
8099115959 | |||
21efa5ffdc | |||
07ebf3926b | |||
714178a82d | |||
5c2c13e0e6 | |||
3f423325b9 | |||
870a205ead | |||
421af05882 | |||
756d105f74 | |||
4d90ebca68 | |||
1297230192 | |||
a45d0f8b98 | |||
821904066b | |||
15b7869e5d | |||
2ed4e23c87 | |||
e952bf07c8 | |||
8d44dab04d | |||
6a792548fa | |||
29f6413306 | |||
53d67616c3 | |||
03ad02bd4d | |||
110106aa97 | |||
7310700dbb | |||
5a0ef88237 | |||
a6e358479a | |||
4b02fec8ac | |||
93e3f1fa49 | |||
ae9a1a68d4 | |||
adf6b05c10 | |||
e0489d30bb | |||
9f46eca956 | |||
4888c399f0 | |||
e372db8dd9 | |||
5ba4a669e6 | |||
26b28564cc | |||
ad0be634d2 | |||
6f460302cf | |||
24f0cf18d9 | |||
2df8274233 | |||
a095370ab8 | |||
339447d29c | |||
efe0caf02f | |||
6daabea288 | |||
772a642283 | |||
675fc8431c | |||
9a97053662 | |||
9d6190668b | |||
ba0b804720 | |||
1fe1f74ad5 | |||
4f7e0a4f7f | |||
070113b764 | |||
c669b80914 | |||
1e8e7f0030 | |||
edc26e366e | |||
13bd258f2a | |||
a1b6fc111c | |||
366c7c8ea4 | |||
7b5bb1e342 | |||
131da53d25 | |||
7ae90cb5b3 | |||
812e2390d0 | |||
4e133582e4 | |||
8ca6a9e08c | |||
344b6bb2c9 | |||
8b56ae218d | |||
3d2b887859 | |||
370fc7b2c2 | |||
5f4a1c24f0 | |||
382cd1aa51 | |||
d929a958ff |
14
build.ts
14
build.ts
@ -35,6 +35,14 @@ 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(/= "(<svg.*)";/g, function(match) {
|
||||||
|
match = match.replaceAll(/\\n*\s*/g, '');
|
||||||
|
return match;
|
||||||
|
});
|
||||||
|
|
||||||
|
str = str.replaceAll('(e) => `', 'e => `');
|
||||||
|
|
||||||
assert(str.includes('/* ADDITIONAL CODE */'));
|
assert(str.includes('/* ADDITIONAL CODE */'));
|
||||||
assert(str.includes('window.BX_EXPOSED = BxExposed'));
|
assert(str.includes('window.BX_EXPOSED = BxExposed'));
|
||||||
assert(str.includes('window.BxEvent = BxEvent'));
|
assert(str.includes('window.BxEvent = BxEvent'));
|
||||||
@ -85,8 +93,10 @@ const build = async (target: BuildTarget, version: string, config: any={}) => {
|
|||||||
// Save to script
|
// Save to script
|
||||||
await Bun.write(path, scriptHeader + result);
|
await Bun.write(path, scriptHeader + result);
|
||||||
|
|
||||||
// Create meta file
|
// Create meta file (don't build if it's beta version)
|
||||||
await Bun.write(outDir + '/' + outputMetaName, txtMetaHeader.replace('[[VERSION]]', version));
|
if (!version.includes('beta')) {
|
||||||
|
await Bun.write(outDir + '/' + outputMetaName, txtMetaHeader.replace('[[VERSION]]', version));
|
||||||
|
}
|
||||||
|
|
||||||
// Check with ESLint
|
// Check with ESLint
|
||||||
const eslint = new ESLint();
|
const eslint = new ESLint();
|
||||||
|
2
dist/better-xcloud.meta.js
vendored
2
dist/better-xcloud.meta.js
vendored
@ -1,5 +1,5 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Better xCloud
|
// @name Better xCloud
|
||||||
// @namespace https://github.com/redphx
|
// @namespace https://github.com/redphx
|
||||||
// @version 5.5.4
|
// @version 5.7.6
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
2119
dist/better-xcloud.user.js
vendored
2119
dist/better-xcloud.user.js
vendored
File diff suppressed because one or more lines are too long
12
package.json
12
package.json
@ -9,14 +9,14 @@
|
|||||||
"build": "build.ts"
|
"build": "build.ts"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/bun": "^1.1.6",
|
"@types/bun": "^1.1.9",
|
||||||
"@types/node": "^20.14.14",
|
"@types/node": "^22.5.5",
|
||||||
"@types/stylus": "^0.48.42",
|
"@types/stylus": "^0.48.43",
|
||||||
"eslint": "^9.8.0",
|
"eslint": "^9.10.0",
|
||||||
"eslint-plugin-compat": "^6.0.0",
|
"eslint-plugin-compat": "^6.0.1",
|
||||||
"stylus": "^0.63.0"
|
"stylus": "^0.63.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": "^5.5.2"
|
"typescript": "^5.6.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,8 +152,8 @@
|
|||||||
bottom: offset;
|
bottom: offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
body[data-input-mode=Touch] &,
|
html[data-active-input=touch] &,
|
||||||
body[data-input-mode=Mouse] & {
|
html[data-active-input=mouse] & {
|
||||||
&:focus::after {
|
&:focus::after {
|
||||||
border-color: transparent !important;
|
border-color: transparent !important;
|
||||||
}
|
}
|
||||||
|
65
src/assets/css/guide-menu.styl
Normal file
65
src/assets/css/guide-menu.styl
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
.bx-guide-home-achievements-progress {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
.bx-button {
|
||||||
|
margin-bottom: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-xds-platform=tv] & {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
html:not([data-xds-platform=tv]) & {
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
> button:first-of-type {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
> button:last-of-type {
|
||||||
|
width: 40px;
|
||||||
|
|
||||||
|
span {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bx-guide-home-buttons {
|
||||||
|
> div {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 12px;
|
||||||
|
|
||||||
|
html[data-xds-platform=tv] & {
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
button {
|
||||||
|
margin-bottom: 0 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
html:not([data-xds-platform=tv]) & {
|
||||||
|
button {
|
||||||
|
span {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-is-playing="true"] {
|
||||||
|
button[data-state='normal'] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-is-playing="false"] {
|
||||||
|
button[data-state='playing'] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,11 @@
|
|||||||
.bx-navigation-dialog {
|
.bx-navigation-dialog {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: var(--bx-navigation-dialog-z-index);
|
z-index: var(--bx-navigation-dialog-z-index);
|
||||||
|
font-family: var(--bx-title-font);
|
||||||
|
|
||||||
|
*:focus {
|
||||||
|
outline: none !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.bx-navigation-dialog-overlay {
|
.bx-navigation-dialog-overlay {
|
||||||
|
@ -1,36 +1,16 @@
|
|||||||
.bx-remote-play-popup {
|
|
||||||
width: 100%;
|
|
||||||
max-width: 1920px;
|
|
||||||
margin: auto;
|
|
||||||
position: relative;
|
|
||||||
height: 0.1px;
|
|
||||||
overflow: visible;
|
|
||||||
z-index: var(--bx-remote-play-popup-z-index);
|
|
||||||
}
|
|
||||||
|
|
||||||
.bx-remote-play-container {
|
.bx-remote-play-container {
|
||||||
position: absolute;
|
position: fixed;
|
||||||
right: 10px;
|
top: 50%;
|
||||||
top: 0;
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
|
||||||
|
color: white;
|
||||||
background: #1a1b1e;
|
background: #1a1b1e;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
width: 420px;
|
width: 420px;
|
||||||
max-width: calc(100vw - 20px);
|
max-width: calc(100vw - 20px);
|
||||||
margin: 0 0 0 auto;
|
margin: 0 0 0 auto;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
box-shadow: #00000080 0px 0px 12px 0px;
|
|
||||||
|
|
||||||
@media (min-width:480px) and (min-height:calc(480px + 1px)) {
|
|
||||||
right: calc(env(safe-area-inset-right, 0px) + 32px);
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width:768px) and (min-height:calc(480px + 1px)) {
|
|
||||||
right: calc(env(safe-area-inset-right, 0px) + 48px);
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width:1920px) and (min-height:calc(480px + 1px)) {
|
|
||||||
right: calc(env(safe-area-inset-right, 0px) + 80px);
|
|
||||||
}
|
|
||||||
|
|
||||||
> .bx-button {
|
> .bx-button {
|
||||||
display: table;
|
display: table;
|
||||||
@ -57,14 +37,6 @@
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
span {
|
|
||||||
font-weight: bold;
|
|
||||||
font-size: 18px;
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.bx-remote-play-resolution {
|
.bx-remote-play-resolution {
|
||||||
@ -114,10 +86,15 @@
|
|||||||
|
|
||||||
.bx-remote-play-power-state {
|
.bx-remote-play-power-state {
|
||||||
color: #888;
|
color: #888;
|
||||||
font-size: 14px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bx-remote-play-connect-button {
|
.bx-remote-play-connect-button {
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
margin: 4px 0;
|
margin: 4px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bx-remote-play-buttons {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
@ -26,22 +26,20 @@ button_color(name, normal, hover, active, disabled)
|
|||||||
button_color('primary', #008746, #04b358, #044e2a, #448262);
|
button_color('primary', #008746, #04b358, #044e2a, #448262);
|
||||||
button_color('danger', #c10404, #e61d1d, #a26c6c, #df5656);
|
button_color('danger', #c10404, #e61d1d, #a26c6c, #df5656);
|
||||||
|
|
||||||
--bx-fullscreen-text-z-index: 9999;
|
--bx-fullscreen-text-z-index: 99999;
|
||||||
--bx-toast-z-index: 6000;
|
--bx-toast-z-index: 60000;
|
||||||
--bx-dialog-z-index: 5000;
|
--bx-dialog-z-index: 50000;
|
||||||
|
|
||||||
--bx-dialog-overlay-z-index: 4020;
|
--bx-dialog-overlay-z-index: 40200;
|
||||||
--bx-stats-bar-z-index: 4010;
|
--bx-stats-bar-z-index: 40100;
|
||||||
--bx-mkb-pointer-lock-msg-z-index: 4000;
|
--bx-mkb-pointer-lock-msg-z-index: 40000;
|
||||||
|
|
||||||
--bx-navigation-dialog-z-index: 3010;
|
--bx-navigation-dialog-z-index: 30100;
|
||||||
--bx-navigation-dialog-overlay-z-index: 3000;
|
--bx-navigation-dialog-overlay-z-index: 30000;
|
||||||
|
|
||||||
--bx-remote-play-popup-z-index: 2000;
|
--bx-game-bar-z-index: 10000;
|
||||||
|
--bx-screenshot-animation-z-index: 9000;
|
||||||
--bx-game-bar-z-index: 1000;
|
--bx-wait-time-box-z-index: 1000;
|
||||||
--bx-wait-time-box-z-index: 100;
|
|
||||||
--bx-screenshot-animation-z-index: 10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
@ -59,7 +57,7 @@ div[class^=HUDButton-module__hiddenContainer] ~ div:not([class^=HUDButton-module
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Remove the "Cloud Gaming" text in header when the screen is too small */
|
/* Remove the "Cloud Gaming" text in header when the screen is too small */
|
||||||
@media screen and (max-width: 600px) {
|
@media screen and (max-width: 640px) {
|
||||||
header a[href="/play"] {
|
header a[href="/play"] {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@ -133,6 +131,13 @@ div[class^=HUDButton-module__hiddenContainer] ~ div:not([class^=HUDButton-module
|
|||||||
text-transform: none !important;
|
text-transform: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bx-normal-link {
|
||||||
|
text-transform: none !important;
|
||||||
|
text-align: left !important;
|
||||||
|
font-weight: 400 !important;
|
||||||
|
font-family: var(--bx-normal-font) !important;
|
||||||
|
}
|
||||||
|
|
||||||
select[multiple] {
|
select[multiple] {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
@ -168,16 +173,11 @@ div[class*=SupportedInputsBadge] {
|
|||||||
left: 0;
|
left: 0;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
background: #0000008c;
|
background: #0000008c;
|
||||||
display: none;
|
display: flex;
|
||||||
border-radius: 0 0 4px 0;
|
border-radius: 4px 0 4px 0;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 4px 8px;
|
padding: 4px 8px;
|
||||||
|
|
||||||
a[class^=BaseItem-module__container]:focus &,
|
|
||||||
button[class^=BaseItem-module__container]:focus & {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
width: 14px;
|
width: 14px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
@ -190,6 +190,7 @@ div[class*=SupportedInputsBadge] {
|
|||||||
line-height: 16px;
|
line-height: 16px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
margin-left: 2px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,42 @@
|
|||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
height: var(--bx-button-height);
|
height: var(--bx-button-height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
accent-color: var(--bx-primary-button-color);
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
accent-color: var(--bx-danger-button-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
select:disabled {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
background: transparent;
|
||||||
|
text-align-last: right;
|
||||||
|
border: none;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
select option:disabled {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=checkbox],
|
||||||
|
select {
|
||||||
|
&:focus {
|
||||||
|
filter: drop-shadow(1px 0 0 #fff) drop-shadow(-1px 0 0 #fff) drop-shadow(0 1px 0 #fff) drop-shadow(0 -1px 0 #fff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #1c9d1c;
|
||||||
|
text-decoration: none;
|
||||||
|
|
||||||
|
&:hover, &:focus {
|
||||||
|
color: #5dc21e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.bx-settings-tabs-container {
|
.bx-settings-tabs-container {
|
||||||
@ -94,7 +130,6 @@
|
|||||||
|
|
||||||
&:focus {
|
&:focus {
|
||||||
border-color: #fff;
|
border-color: #fff;
|
||||||
outline: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&[data-group=global] {
|
&[data-group=global] {
|
||||||
@ -198,11 +233,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&:focus,
|
|
||||||
*:focus {
|
|
||||||
outline: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bx-top-buttons {
|
.bx-top-buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -258,13 +288,6 @@
|
|||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type=checkbox],
|
|
||||||
select {
|
|
||||||
&:focus {
|
|
||||||
filter: drop-shadow(1px 0 0 #fff) drop-shadow(-1px 0 0 #fff) drop-shadow(0 1px 0 #fff) drop-shadow(0 -1px 0 #fff);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
&:has(input:focus), &:has(select:focus), &:has(button:focus) {
|
&:has(input:focus), &:has(select:focus), &:has(button:focus) {
|
||||||
border-left-color: white;
|
border-left-color: white;
|
||||||
@ -277,31 +300,12 @@
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
align-self: center;
|
align-self: center;
|
||||||
margin-bottom: 0 !important;
|
margin-bottom: 0 !important;
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
+ * {
|
+ * {
|
||||||
margin: 0 0 0 auto;
|
margin: 0 0 0 auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
input {
|
|
||||||
accent-color: var(--bx-primary-button-color);
|
|
||||||
|
|
||||||
&:focus {
|
|
||||||
accent-color: var(--bx-danger-button-color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
select:disabled {
|
|
||||||
-webkit-appearance: none;
|
|
||||||
background: transparent;
|
|
||||||
text-align-last: right;
|
|
||||||
border: none;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
select option:disabled {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.bx-settings-dialog-note {
|
.bx-settings-dialog-note {
|
||||||
@ -335,15 +339,6 @@
|
|||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
color: #5dc21e;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
color: #6dd72b;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:focus {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.bx-debug-info {
|
.bx-debug-info {
|
||||||
@ -404,3 +399,167 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bx-suggest-toggler {
|
||||||
|
text-align: left;
|
||||||
|
display: flex;
|
||||||
|
border-radius: 4px;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #003861;
|
||||||
|
|
||||||
|
label {
|
||||||
|
flex: 1;
|
||||||
|
margin-bottom: 0;
|
||||||
|
padding: 10px;
|
||||||
|
background: #004f87;
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
display: inline-block;
|
||||||
|
align-self: center;
|
||||||
|
padding: 10px;
|
||||||
|
width: 40px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover, &:focus {
|
||||||
|
cursor: pointer;
|
||||||
|
background: #005da1;
|
||||||
|
|
||||||
|
label {
|
||||||
|
background: #006fbe;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&[bx-open] {
|
||||||
|
span {
|
||||||
|
transform: rotate(90deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
&+ .bx-suggest-box {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bx-suggest-box {
|
||||||
|
display: none;
|
||||||
|
background: #161616;
|
||||||
|
padding: 10px;
|
||||||
|
box-shadow: 0px 0px 12px #0f0f0f inset;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bx-suggest-wrapper {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
margin: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bx-suggest-note {
|
||||||
|
font-size: 11px;
|
||||||
|
color: #8c8c8c;
|
||||||
|
font-style: italic;
|
||||||
|
font-weight: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bx-suggest-link {
|
||||||
|
font-size: 14px;
|
||||||
|
display: inline-block;
|
||||||
|
margin-top: 4px;
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bx-suggest-row {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 10px;
|
||||||
|
|
||||||
|
label {
|
||||||
|
flex: 1;
|
||||||
|
overflow: overlay;
|
||||||
|
border-radius: 4px;
|
||||||
|
|
||||||
|
.bx-suggest-label {
|
||||||
|
background: #323232;
|
||||||
|
padding: 4px 10px;
|
||||||
|
font-size: 12px;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bx-suggest-value {
|
||||||
|
padding: 6px;
|
||||||
|
font-size: 14px;
|
||||||
|
|
||||||
|
&.bx-suggest-change {
|
||||||
|
background-color: var(--bx-warning-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.bx-suggest-ok {
|
||||||
|
input {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bx-suggest-label {
|
||||||
|
background-color: #008114;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bx-suggest-value {
|
||||||
|
background-color: #13a72a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.bx-suggest-change {
|
||||||
|
.bx-suggest-label {
|
||||||
|
background-color: #a65e08;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bx-suggest-value {
|
||||||
|
background-color: #d57f18;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
label {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bx-suggest-label {
|
||||||
|
background-color: #995707;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bx-suggest-value {
|
||||||
|
background-color: #bd7115;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unchecked setting
|
||||||
|
input:not(:checked) + label {
|
||||||
|
opacity: 0.5;
|
||||||
|
|
||||||
|
.bx-suggest-label {
|
||||||
|
background-color: #2a2a2a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bx-suggest-value {
|
||||||
|
background-color: #393939;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
input:not(:checked) + label {
|
||||||
|
opacity: 1;
|
||||||
|
|
||||||
|
.bx-suggest-label {
|
||||||
|
background-color: #202020;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bx-suggest-value {
|
||||||
|
background-color: #303030;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
@import 'loading-screen.styl';
|
@import 'loading-screen.styl';
|
||||||
@import 'remote-play.styl';
|
@import 'remote-play.styl';
|
||||||
@import 'web-components.styl';
|
@import 'web-components.styl';
|
||||||
|
@import 'guide-menu.styl';
|
||||||
|
|
||||||
@import 'stream.styl';
|
@import 'stream.styl';
|
||||||
@import 'number-stepper.styl';
|
@import 'number-stepper.styl';
|
||||||
|
@ -4,12 +4,16 @@
|
|||||||
flex: 0 1 auto;
|
flex: 0 1 auto;
|
||||||
|
|
||||||
select {
|
select {
|
||||||
display: none !important;
|
// Render offscreen instead of "display: none" so we could get its size
|
||||||
|
position: absolute !important;
|
||||||
|
top: -9999px !important;
|
||||||
|
left: -9999px !important;
|
||||||
|
visibility: hidden !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
> div, button.bx-select-value {
|
> div, button.bx-select-value {
|
||||||
min-width: 110px;
|
min-width: 120px;
|
||||||
text-align: center;
|
text-align: left;
|
||||||
margin: 0 8px;
|
margin: 0 8px;
|
||||||
line-height: 24px;
|
line-height: 24px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
@ -53,7 +57,7 @@
|
|||||||
|
|
||||||
span {
|
span {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
text-align: center;
|
text-align: left;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
src/assets/svg/power.svg
Normal file
3
src/assets/svg/power.svg
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='#fff' fill-rule='evenodd' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' viewBox='0 0 32 32'>
|
||||||
|
<path d='M16 2.445v12.91m7.746-11.619C27.631 6.27 30.2 10.37 30.2 15.355c0 7.79-6.41 14.2-14.2 14.2s-14.2-6.41-14.2-14.2c0-4.985 2.569-9.085 6.454-11.619'/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 339 B |
3
src/assets/svg/speaker-slash.svg
Normal file
3
src/assets/svg/speaker-slash.svg
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns='http://www.w3.org/2000/svg' fill='#fff' stroke='none' fill-rule='evenodd' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' viewBox='0 0 32 32'>
|
||||||
|
<path d='M5.462 3.4c-.205-.23-.499-.363-.808-.363-.592 0-1.079.488-1.079 1.08a1.08 1.08 0 0 0 .289.736l4.247 4.672H2.504a2.17 2.17 0 0 0-2.16 2.16v8.637a2.17 2.17 0 0 0 2.16 2.16h6.107l9.426 7.33a1.08 1.08 0 0 0 .662.227c.592 0 1.08-.487 1.08-1.079v-6.601l5.679 6.247a1.08 1.08 0 0 0 .808.363c.592 0 1.08-.487 1.08-1.079a1.08 1.08 0 0 0-.29-.736L5.462 3.4zm-2.958 8.285h5.398v8.637H2.504v-8.637zM17.62 26.752l-7.558-5.878V11.67l7.558 8.313v6.769zm5.668-8.607c1.072-1.218 1.072-3.063 0-4.281a1.08 1.08 0 0 1-.293-.74c0-.592.487-1.079 1.079-1.079a1.08 1.08 0 0 1 .834.393 5.42 5.42 0 0 1 0 7.137 1.08 1.08 0 0 1-.81.365c-.593 0-1.08-.488-1.08-1.08 0-.263.096-.517.27-.715zM12.469 7.888c-.147-.19-.228-.423-.228-.663a1.08 1.08 0 0 1 .417-.853l5.379-4.184a1.08 1.08 0 0 1 .662-.227c.593 0 1.08.488 1.08 1.08v10.105c0 .593-.487 1.08-1.08 1.08s-1.079-.487-1.079-1.08V5.255l-3.636 2.834c-.469.362-1.153.273-1.515-.196v-.005zm19.187 8.115a10.79 10.79 0 0 1-2.749 7.199 1.08 1.08 0 0 1-.793.347c-.593 0-1.08-.487-1.08-1.079 0-.26.094-.511.264-.708 2.918-3.262 2.918-8.253 0-11.516-.184-.2-.287-.461-.287-.733 0-.592.487-1.08 1.08-1.08a1.08 1.08 0 0 1 .816.373 10.78 10.78 0 0 1 2.749 7.197z' fill-rule='nonzero'/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.4 KiB |
3
src/assets/svg/true-achievements.svg
Normal file
3
src/assets/svg/true-achievements.svg
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns='http://www.w3.org/2000/svg' fill='#fff' stroke='nons' fill-rule='evenodd' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' viewBox='0 0 32 32'>
|
||||||
|
<path d='M2.497 14.127c.781-6.01 5.542-10.849 11.551-11.708V0C6.634.858.858 6.712 0 14.127h2.497zM17.952 2.419V0C25.366.858 31.142 6.712 32 14.127h-2.497c-.781-6.01-5.542-10.849-11.551-11.708zM2.497 17.873c.781 6.01 5.542 10.849 11.551 11.708V32C6.634 31.142.858 25.288 0 17.873h2.497zm27.006 0H32C31.142 25.288 25.366 31.142 17.952 32v-2.419c6.009-.859 10.77-5.698 11.551-11.708zm-19.2-4.527h2.028a.702.702 0 1 0 0-1.404h-2.107a1.37 1.37 0 0 1-1.326-1.327V9.21a.7.7 0 0 0-.703-.703c-.387 0-.703.316-.703.7v1.408c.079 1.483 1.25 2.731 2.811 2.731zm2.809 7.337h-2.888a1.37 1.37 0 0 1-1.326-1.327v-4.917c0-.387-.316-.703-.7-.703a.7.7 0 0 0-.706.703v4.917a2.77 2.77 0 0 0 2.732 2.732h2.81c.387 0 .702-.316.702-.7.078-.393-.234-.705-.624-.705zM25.6 19.2a.7.7 0 0 0-.702-.702c-.387 0-.703.316-.703.699v.081c0 .702-.546 1.326-1.248 1.326H19.98c-.702-.078-1.248-.624-1.248-1.326v-.312c0-.78.624-1.327 1.326-1.327h2.811a2.77 2.77 0 0 0 2.731-2.732v-.312a2.68 2.68 0 0 0-2.576-2.732h-4.76a.702.702 0 1 0 0 1.405h4.526a1.37 1.37 0 0 1 1.327 1.327v.234c0 .781-.624 1.327-1.327 1.327h-2.81a2.77 2.77 0 0 0-2.731 2.732v.312a2.77 2.77 0 0 0 2.731 2.732h2.967a2.74 2.74 0 0 0 2.575-2.732s.078.078.078 0z'/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.3 KiB |
143
src/index.ts
143
src/index.ts
@ -14,9 +14,9 @@ import { Toast } from "@utils/toast";
|
|||||||
import { LoadingScreen } from "@modules/loading-screen";
|
import { LoadingScreen } from "@modules/loading-screen";
|
||||||
import { MouseCursorHider } from "@modules/mkb/mouse-cursor-hider";
|
import { MouseCursorHider } from "@modules/mkb/mouse-cursor-hider";
|
||||||
import { TouchController } from "@modules/touch-controller";
|
import { TouchController } from "@modules/touch-controller";
|
||||||
import { checkForUpdate, disablePwa } from "@utils/utils";
|
import { checkForUpdate, disablePwa, productTitleToSlug } from "@utils/utils";
|
||||||
import { Patcher } from "@modules/patcher";
|
import { Patcher } from "@modules/patcher";
|
||||||
import { RemotePlay } from "@modules/remote-play";
|
import { RemotePlayManager } from "@/modules/remote-play-manager";
|
||||||
import { onHistoryChanged, patchHistoryMethod } from "@utils/history";
|
import { onHistoryChanged, patchHistoryMethod } from "@utils/history";
|
||||||
import { VibrationManager } from "@modules/vibration-manager";
|
import { VibrationManager } from "@modules/vibration-manager";
|
||||||
import { overridePreloadState } from "@utils/preload-state";
|
import { overridePreloadState } from "@utils/preload-state";
|
||||||
@ -26,7 +26,7 @@ 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";
|
||||||
import { NativeMkbHandler } from "./modules/mkb/native-mkb-handler";
|
import { NativeMkbHandler } from "./modules/mkb/native-mkb-handler";
|
||||||
import { GuideMenu, GuideMenuTab } from "./modules/ui/guide-menu";
|
import { GuideMenu } from "./modules/ui/guide-menu";
|
||||||
import { updateVideoPlayer } from "./modules/stream/stream-settings-utils";
|
import { updateVideoPlayer } from "./modules/stream/stream-settings-utils";
|
||||||
import { UiSection } from "./enums/ui-sections";
|
import { UiSection } from "./enums/ui-sections";
|
||||||
import { HeaderSection } from "./modules/ui/header";
|
import { HeaderSection } from "./modules/ui/header";
|
||||||
@ -34,10 +34,12 @@ import { GameTile } from "./modules/ui/game-tile";
|
|||||||
import { ProductDetailsPage } from "./modules/ui/product-details";
|
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 } 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 { 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 { XboxApi } from "./utils/xbox-api";
|
||||||
|
|
||||||
|
|
||||||
// Handle login page
|
// Handle login page
|
||||||
@ -70,26 +72,65 @@ if (BX_FLAGS.SafariWorkaround && document.readyState !== 'loading') {
|
|||||||
.bx-reload-overlay {
|
.bx-reload-overlay {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
background: #000000cc;
|
background: #000000cc;
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
width: 100%;
|
|
||||||
line-height: 100vh;
|
|
||||||
color: #fff;
|
color: #fff;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-family: "Segoe UI", Arial, Helvetica, sans-serif;
|
font-family: "Segoe UI", Arial, Helvetica, sans-serif;
|
||||||
font-size: 1.3rem;
|
font-size: 1.3rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bx-reload-overlay *:focus {
|
||||||
|
outline: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bx-reload-overlay > div {
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bx-reload-overlay a {
|
||||||
|
text-decoration: none;
|
||||||
|
display: inline-block;
|
||||||
|
background: #107c10;
|
||||||
|
color: white;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 6px;
|
||||||
|
}
|
||||||
`);
|
`);
|
||||||
|
|
||||||
|
const isSafari = UserAgent.isSafari();
|
||||||
|
let $secondaryAction: HTMLElement;
|
||||||
|
if (isSafari) {
|
||||||
|
$secondaryAction = CE('p', {}, t('settings-reloading'));
|
||||||
|
} else {
|
||||||
|
$secondaryAction = CE('a', {
|
||||||
|
href: 'https://better-xcloud.github.io/troubleshooting',
|
||||||
|
target: '_blank',
|
||||||
|
}, '🤓 ' + t('how-to-fix'));
|
||||||
|
}
|
||||||
|
|
||||||
const $fragment = document.createDocumentFragment();
|
const $fragment = document.createDocumentFragment();
|
||||||
$fragment.appendChild(CE('style', {}, css));
|
$fragment.appendChild(CE('style', {}, css));
|
||||||
$fragment.appendChild(CE('div', {'class': 'bx-reload-overlay'}, t('safari-failed-message')));
|
$fragment.appendChild(CE('div',{
|
||||||
|
class: 'bx-reload-overlay',
|
||||||
|
},
|
||||||
|
CE('div', {},
|
||||||
|
CE('p', {}, t('load-failed-message')),
|
||||||
|
$secondaryAction,
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
document.documentElement.appendChild($fragment);
|
document.documentElement.appendChild($fragment);
|
||||||
|
|
||||||
// Reload the page
|
// Reload the page if using Safari
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
window.location.reload(true);
|
isSafari && window.location.reload(true);
|
||||||
|
|
||||||
// Stop processing the script
|
// Stop processing the script
|
||||||
throw new Error('[Better xCloud] Executing workaround for Safari');
|
throw new Error('[Better xCloud] Executing workaround for Safari');
|
||||||
@ -116,10 +157,10 @@ document.addEventListener('readystatechange', e => {
|
|||||||
|
|
||||||
if (STATES.isSignedIn) {
|
if (STATES.isSignedIn) {
|
||||||
// Preload Remote Play
|
// Preload Remote Play
|
||||||
getPref(PrefKey.REMOTE_PLAY_ENABLED) && RemotePlay.preload();
|
getPref(PrefKey.REMOTE_PLAY_ENABLED) && RemotePlayManager.getInstance().initialize();
|
||||||
} else {
|
} else {
|
||||||
// Show Settings button in the header when not signed in
|
// Show Settings button in the header when not signed in
|
||||||
HeaderSection.watchHeader();
|
window.setTimeout(HeaderSection.watchHeader, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide "Play with Friends" skeleton section
|
// Hide "Play with Friends" skeleton section
|
||||||
@ -153,20 +194,15 @@ window.addEventListener(BxEvent.XCLOUD_SERVERS_UNAVAILABLE, e => {
|
|||||||
|
|
||||||
window.addEventListener(BxEvent.XCLOUD_SERVERS_READY, e => {
|
window.addEventListener(BxEvent.XCLOUD_SERVERS_READY, e => {
|
||||||
STATES.isSignedIn = true;
|
STATES.isSignedIn = true;
|
||||||
HeaderSection.watchHeader();
|
window.setTimeout(HeaderSection.watchHeader, 2000);
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener(BxEvent.STREAM_LOADING, e => {
|
window.addEventListener(BxEvent.STREAM_LOADING, e => {
|
||||||
// Get title ID for screenshot's name
|
// Get title ID for screenshot's name
|
||||||
if (window.location.pathname.includes('/launch/')) {
|
if (window.location.pathname.includes('/launch/') && STATES.currentStream.titleInfo) {
|
||||||
const matches = /\/launch\/(?<title_id>[^\/]+)\/(?<product_id>\w+)/.exec(window.location.pathname);
|
STATES.currentStream.titleSlug = productTitleToSlug(STATES.currentStream.titleInfo.product.title);
|
||||||
if (matches?.groups) {
|
|
||||||
STATES.currentStream.titleId = matches.groups.title_id;
|
|
||||||
STATES.currentStream.productId = matches.groups.product_id;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
STATES.currentStream.titleId = 'remote-play';
|
STATES.currentStream.titleSlug = 'remote-play';
|
||||||
STATES.currentStream.productId = '';
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -208,10 +244,42 @@ window.addEventListener(BxEvent.STREAM_ERROR_PAGE, e => {
|
|||||||
window.addEventListener(BxEvent.XCLOUD_RENDERING_COMPONENT, e => {
|
window.addEventListener(BxEvent.XCLOUD_RENDERING_COMPONENT, e => {
|
||||||
const component = (e as any).component;
|
const component = (e as any).component;
|
||||||
if (component === 'product-details') {
|
if (component === 'product-details') {
|
||||||
ProductDetailsPage.injectShortcutButton();
|
ProductDetailsPage.injectButtons();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Detect game change
|
||||||
|
window.addEventListener(BxEvent.DATA_CHANNEL_CREATED, e => {
|
||||||
|
const dataChannel = (e as any).dataChannel;
|
||||||
|
if (!dataChannel || dataChannel.label !== 'message') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dataChannel.addEventListener('message', async (msg: MessageEvent) => {
|
||||||
|
if (msg.origin === 'better-xcloud' || typeof msg.data !== 'string') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get xboxTitleId from message
|
||||||
|
if (msg.data.includes('/titleinfo')) {
|
||||||
|
const json = JSON.parse(JSON.parse(msg.data).content);
|
||||||
|
const xboxTitleId = parseInt(json.titleid, 16);
|
||||||
|
STATES.currentStream.xboxTitleId = xboxTitleId;
|
||||||
|
|
||||||
|
// Get titleSlug for Remote Play
|
||||||
|
if (STATES.remotePlay.isPlaying) {
|
||||||
|
STATES.currentStream.titleSlug = 'remote-play';
|
||||||
|
if (json.focused) {
|
||||||
|
const productTitle = await XboxApi.getProductTitle(xboxTitleId);
|
||||||
|
if (productTitle) {
|
||||||
|
STATES.currentStream.titleSlug = productTitleToSlug(productTitle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function unload() {
|
function unload() {
|
||||||
if (!STATES.isPlaying) {
|
if (!STATES.isPlaying) {
|
||||||
return;
|
return;
|
||||||
@ -248,7 +316,7 @@ window.addEventListener(BxEvent.CAPTURE_SCREENSHOT, e => {
|
|||||||
|
|
||||||
|
|
||||||
function observeRootDialog($root: HTMLElement) {
|
function observeRootDialog($root: HTMLElement) {
|
||||||
let currentShown = false;
|
let beingShown = false;
|
||||||
|
|
||||||
const observer = new MutationObserver(mutationList => {
|
const observer = new MutationObserver(mutationList => {
|
||||||
for (const mutation of mutationList) {
|
for (const mutation of mutationList) {
|
||||||
@ -256,31 +324,20 @@ function observeRootDialog($root: HTMLElement) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BX_FLAGS.Debug && BxLogger.warning('RootDialog', 'added', mutation.addedNodes);
|
||||||
if (mutation.addedNodes.length === 1) {
|
if (mutation.addedNodes.length === 1) {
|
||||||
const $addedElm = mutation.addedNodes[0];
|
const $addedElm = mutation.addedNodes[0];
|
||||||
if ($addedElm instanceof HTMLElement && $addedElm.className) {
|
if ($addedElm instanceof HTMLElement && $addedElm.className) {
|
||||||
if ($addedElm.className.startsWith('NavigationAnimation') || $addedElm.className.startsWith('DialogRoutes') || $addedElm.className.startsWith('Dialog-module__container')) {
|
// Make sure it's Guide dialog
|
||||||
// Make sure it's Guide dialog
|
if ($root.querySelector('div[class*=GuideDialog]')) {
|
||||||
if (document.querySelector('#gamepass-dialog-root div[class*=GuideDialog]')) {
|
GuideMenu.observe($addedElm);
|
||||||
// Find navigation bar
|
|
||||||
const $selectedTab = $addedElm.querySelector('div[class^=NavigationMenu] button[aria-selected=true');
|
|
||||||
if ($selectedTab) {
|
|
||||||
let $elm: Element | null = $selectedTab;
|
|
||||||
let index;
|
|
||||||
for (index = 0; ($elm = $elm?.previousElementSibling); index++);
|
|
||||||
|
|
||||||
if (index === 0) {
|
|
||||||
BxEvent.dispatch(window, BxEvent.XCLOUD_GUIDE_MENU_SHOWN, {where: GuideMenuTab.HOME});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const shown = ($root.firstElementChild && $root.firstElementChild.childElementCount > 0) || false;
|
const shown = !!($root.firstElementChild && $root.firstElementChild.childElementCount > 0);
|
||||||
if (shown !== currentShown) {
|
if (shown !== beingShown) {
|
||||||
currentShown = shown;
|
beingShown = shown;
|
||||||
BxEvent.dispatch(window, shown ? BxEvent.XCLOUD_DIALOG_SHOWN : BxEvent.XCLOUD_DIALOG_DISMISSED);
|
BxEvent.dispatch(window, shown ? BxEvent.XCLOUD_DIALOG_SHOWN : BxEvent.XCLOUD_DIALOG_DISMISSED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -339,7 +396,7 @@ function main() {
|
|||||||
(getPref(PrefKey.GAME_BAR_POSITION) !== 'off') && GameBar.getInstance();
|
(getPref(PrefKey.GAME_BAR_POSITION) !== 'off') && GameBar.getInstance();
|
||||||
Screenshot.setup();
|
Screenshot.setup();
|
||||||
|
|
||||||
GuideMenu.observe();
|
GuideMenu.addEventListeners();
|
||||||
StreamBadges.setupEvents();
|
StreamBadges.setupEvents();
|
||||||
StreamStats.setupEvents();
|
StreamStats.setupEvents();
|
||||||
EmulatedMkbHandler.setupEvents();
|
EmulatedMkbHandler.setupEvents();
|
||||||
@ -356,10 +413,10 @@ function main() {
|
|||||||
|
|
||||||
// Preload Remote Play
|
// Preload Remote Play
|
||||||
if (getPref(PrefKey.REMOTE_PLAY_ENABLED)) {
|
if (getPref(PrefKey.REMOTE_PLAY_ENABLED)) {
|
||||||
RemotePlay.detect();
|
RemotePlayManager.detect();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === 'all') {
|
if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === StreamTouchController.ALL) {
|
||||||
TouchController.setup();
|
TouchController.setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,6 @@ export const renderStylus = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const compressCss = async (css: string) => {
|
export const compressCss = (css: string) => {
|
||||||
return await (stylus(css, {}).set('compress', true)).render();
|
return (stylus(css, {}).set('compress', true)).render();
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Screenshot } from "@utils/screenshot";
|
import { Screenshot } from "@utils/screenshot";
|
||||||
import { GamepadKey } from "@enums/mkb";
|
import { GamepadKey } from "@enums/mkb";
|
||||||
import { PrompFont } from "@enums/prompt-font";
|
import { PrompFont } from "@enums/prompt-font";
|
||||||
import { CE } 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 { EmulatedMkbHandler } from "./mkb/mkb-handler";
|
||||||
import { StreamStats } from "./stream/stream-stats";
|
import { StreamStats } from "./stream/stream-stats";
|
||||||
@ -174,9 +174,7 @@ export class ControllerShortcut {
|
|||||||
const $fragment = document.createDocumentFragment();
|
const $fragment = document.createDocumentFragment();
|
||||||
|
|
||||||
// Remove old profiles
|
// Remove old profiles
|
||||||
while ($select.firstElementChild) {
|
removeChildElements($select);
|
||||||
$select.firstElementChild.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
const gamepads = navigator.getGamepads();
|
const gamepads = navigator.getGamepads();
|
||||||
let hasGamepad = false;
|
let hasGamepad = false;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
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 { createButton, ButtonStyle, CE } from "@utils/html";
|
import { createButton, ButtonStyle, CE } from "@utils/html";
|
||||||
import { t } from "@utils/translation";
|
|
||||||
import { BaseGameBarAction } from "./action-base";
|
import { BaseGameBarAction } from "./action-base";
|
||||||
import { MicrophoneShortcut, MicrophoneState } from "../shortcuts/shortcut-microphone";
|
import { MicrophoneShortcut, MicrophoneState } from "../shortcuts/shortcut-microphone";
|
||||||
|
|
||||||
@ -15,16 +14,15 @@ export class MicrophoneAction extends BaseGameBarAction {
|
|||||||
super();
|
super();
|
||||||
|
|
||||||
const onClick = (e: Event) => {
|
const onClick = (e: Event) => {
|
||||||
BxEvent.dispatch(window, BxEvent.GAME_BAR_ACTION_ACTIVATED);
|
BxEvent.dispatch(window, BxEvent.GAME_BAR_ACTION_ACTIVATED);
|
||||||
|
|
||||||
const enabled = MicrophoneShortcut.toggle(false);
|
const enabled = MicrophoneShortcut.toggle(false);
|
||||||
this.$content.setAttribute('data-enabled', enabled.toString());
|
this.$content.setAttribute('data-enabled', enabled.toString());
|
||||||
};
|
};
|
||||||
|
|
||||||
const $btnDefault = createButton({
|
const $btnDefault = createButton({
|
||||||
style: ButtonStyle.GHOST,
|
style: ButtonStyle.GHOST,
|
||||||
icon: BxIcon.MICROPHONE,
|
icon: BxIcon.MICROPHONE,
|
||||||
title: t('show-touch-controller'),
|
|
||||||
onClick: onClick,
|
onClick: onClick,
|
||||||
classes: ['bx-activated'],
|
classes: ['bx-activated'],
|
||||||
});
|
});
|
||||||
@ -32,7 +30,6 @@ export class MicrophoneAction extends BaseGameBarAction {
|
|||||||
const $btnMuted = createButton({
|
const $btnMuted = createButton({
|
||||||
style: ButtonStyle.GHOST,
|
style: ButtonStyle.GHOST,
|
||||||
icon: BxIcon.MICROPHONE_MUTED,
|
icon: BxIcon.MICROPHONE_MUTED,
|
||||||
title: t('hide-touch-controller'),
|
|
||||||
onClick: onClick,
|
onClick: onClick,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -12,16 +12,16 @@ export class ScreenshotAction extends BaseGameBarAction {
|
|||||||
super();
|
super();
|
||||||
|
|
||||||
const onClick = (e: Event) => {
|
const onClick = (e: Event) => {
|
||||||
BxEvent.dispatch(window, BxEvent.GAME_BAR_ACTION_ACTIVATED);
|
BxEvent.dispatch(window, BxEvent.GAME_BAR_ACTION_ACTIVATED);
|
||||||
Screenshot.takeScreenshot();
|
Screenshot.takeScreenshot();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$content = createButton({
|
this.$content = createButton({
|
||||||
style: ButtonStyle.GHOST,
|
style: ButtonStyle.GHOST,
|
||||||
icon: BxIcon.SCREENSHOT,
|
icon: BxIcon.SCREENSHOT,
|
||||||
title: t('take-screenshot'),
|
title: t('take-screenshot'),
|
||||||
onClick: onClick,
|
onClick: onClick,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render(): HTMLElement {
|
render(): HTMLElement {
|
||||||
|
54
src/modules/game-bar/action-speaker.ts
Normal file
54
src/modules/game-bar/action-speaker.ts
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import { BxEvent } from "@utils/bx-event";
|
||||||
|
import { BxIcon } from "@utils/bx-icon";
|
||||||
|
import { createButton, ButtonStyle, CE } from "@utils/html";
|
||||||
|
import { BaseGameBarAction } from "./action-base";
|
||||||
|
import { SoundShortcut, SpeakerState } from "../shortcuts/shortcut-sound";
|
||||||
|
|
||||||
|
|
||||||
|
export class SpeakerAction extends BaseGameBarAction {
|
||||||
|
$content: HTMLElement;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
const onClick = (e: Event) => {
|
||||||
|
BxEvent.dispatch(window, BxEvent.GAME_BAR_ACTION_ACTIVATED);
|
||||||
|
SoundShortcut.muteUnmute();
|
||||||
|
};
|
||||||
|
|
||||||
|
const $btnEnable = createButton({
|
||||||
|
style: ButtonStyle.GHOST,
|
||||||
|
icon: BxIcon.AUDIO,
|
||||||
|
onClick: onClick,
|
||||||
|
});
|
||||||
|
|
||||||
|
const $btnMuted = createButton({
|
||||||
|
style: ButtonStyle.GHOST,
|
||||||
|
icon: BxIcon.SPEAKER_MUTED,
|
||||||
|
onClick: onClick,
|
||||||
|
classes: ['bx-activated'],
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$content = CE('div', {},
|
||||||
|
$btnEnable,
|
||||||
|
$btnMuted,
|
||||||
|
);
|
||||||
|
|
||||||
|
this.reset();
|
||||||
|
|
||||||
|
window.addEventListener(BxEvent.SPEAKER_STATE_CHANGED, e => {
|
||||||
|
const speakerState = (e as any).speakerState;
|
||||||
|
const enabled = speakerState === SpeakerState.ENABLED;
|
||||||
|
|
||||||
|
this.$content.dataset.enabled = enabled.toString();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
render(): HTMLElement {
|
||||||
|
return this.$content;
|
||||||
|
}
|
||||||
|
|
||||||
|
reset(): void {
|
||||||
|
this.$content.dataset.enabled = 'true';
|
||||||
|
}
|
||||||
|
}
|
@ -26,7 +26,6 @@ export class TouchControlAction extends BaseGameBarAction {
|
|||||||
icon: BxIcon.TOUCH_CONTROL_ENABLE,
|
icon: BxIcon.TOUCH_CONTROL_ENABLE,
|
||||||
title: t('show-touch-controller'),
|
title: t('show-touch-controller'),
|
||||||
onClick: onClick,
|
onClick: onClick,
|
||||||
classes: ['bx-activated'],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const $btnDisable = createButton({
|
const $btnDisable = createButton({
|
||||||
@ -34,6 +33,7 @@ export class TouchControlAction extends BaseGameBarAction {
|
|||||||
icon: BxIcon.TOUCH_CONTROL_DISABLE,
|
icon: BxIcon.TOUCH_CONTROL_DISABLE,
|
||||||
title: t('hide-touch-controller'),
|
title: t('hide-touch-controller'),
|
||||||
onClick: onClick,
|
onClick: onClick,
|
||||||
|
classes: ['bx-activated'],
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$content = CE('div', {},
|
this.$content = CE('div', {},
|
||||||
|
30
src/modules/game-bar/action-true-achievements.ts
Normal file
30
src/modules/game-bar/action-true-achievements.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { BxEvent } from "@/utils/bx-event";
|
||||||
|
import { BxIcon } from "@/utils/bx-icon";
|
||||||
|
import { createButton, ButtonStyle } from "@/utils/html";
|
||||||
|
import { t } from "@/utils/translation";
|
||||||
|
import { BaseGameBarAction } from "./action-base";
|
||||||
|
import { TrueAchievements } from "@/utils/true-achievements";
|
||||||
|
|
||||||
|
export class TrueAchievementsAction extends BaseGameBarAction {
|
||||||
|
$content: HTMLElement;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
const onClick = (e: Event) => {
|
||||||
|
BxEvent.dispatch(window, BxEvent.GAME_BAR_ACTION_ACTIVATED);
|
||||||
|
TrueAchievements.open(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.$content = createButton({
|
||||||
|
style: ButtonStyle.GHOST,
|
||||||
|
icon: BxIcon.TRUE_ACHIEVEMENTS,
|
||||||
|
title: t('true-achievements'),
|
||||||
|
onClick: onClick,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
render(): HTMLElement {
|
||||||
|
return this.$content;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
import { CE, createSvgIcon } from "@utils/html";
|
import { CE, clearFocus, createSvgIcon } from "@utils/html";
|
||||||
import { ScreenshotAction } from "./action-screenshot";
|
import { ScreenshotAction } from "./action-screenshot";
|
||||||
import { TouchControlAction } from "./action-touch-control";
|
import { TouchControlAction } from "./action-touch-control";
|
||||||
import { BxEvent } from "@utils/bx-event";
|
import { BxEvent } from "@utils/bx-event";
|
||||||
@ -7,12 +7,13 @@ import type { BaseGameBarAction } from "./action-base";
|
|||||||
import { STATES } from "@utils/global";
|
import { STATES } from "@utils/global";
|
||||||
import { MicrophoneAction } from "./action-microphone";
|
import { MicrophoneAction } from "./action-microphone";
|
||||||
import { PrefKey } from "@/enums/pref-keys";
|
import { PrefKey } from "@/enums/pref-keys";
|
||||||
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
import { getPref, StreamTouchController } from "@/utils/settings-storages/global-settings-storage";
|
||||||
|
import { TrueAchievementsAction } from "./action-true-achievements";
|
||||||
|
import { SpeakerAction } from "./action-speaker";
|
||||||
|
|
||||||
|
|
||||||
export class GameBar {
|
export class GameBar {
|
||||||
private static instance: GameBar;
|
private static instance: GameBar;
|
||||||
|
|
||||||
public static getInstance(): GameBar {
|
public static getInstance(): GameBar {
|
||||||
if (!GameBar.instance) {
|
if (!GameBar.instance) {
|
||||||
GameBar.instance = new GameBar();
|
GameBar.instance = new GameBar();
|
||||||
@ -42,8 +43,10 @@ export class GameBar {
|
|||||||
|
|
||||||
this.actions = [
|
this.actions = [
|
||||||
new ScreenshotAction(),
|
new ScreenshotAction(),
|
||||||
...(STATES.userAgent.capabilities.touch && (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) !== 'off') ? [new TouchControlAction()] : []),
|
...(STATES.userAgent.capabilities.touch && (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) !== StreamTouchController.OFF) ? [new TouchControlAction()] : []),
|
||||||
|
new SpeakerAction(),
|
||||||
new MicrophoneAction(),
|
new MicrophoneAction(),
|
||||||
|
new TrueAchievementsAction(),
|
||||||
];
|
];
|
||||||
|
|
||||||
// Reverse the action list if Game Bar's position is on the right side
|
// Reverse the action list if Game Bar's position is on the right side
|
||||||
@ -75,7 +78,7 @@ export class GameBar {
|
|||||||
$container.addEventListener('transitionend', e => {
|
$container.addEventListener('transitionend', e => {
|
||||||
const classList = $container.classList;
|
const classList = $container.classList;
|
||||||
if (classList.contains('bx-hide')) {
|
if (classList.contains('bx-hide')) {
|
||||||
classList.remove('bx-offscreen', 'bx-hide');
|
classList.remove('bx-hide');
|
||||||
classList.add('bx-offscreen');
|
classList.add('bx-offscreen');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -93,7 +96,7 @@ export class GameBar {
|
|||||||
|
|
||||||
// Toggle Game bar
|
// Toggle Game bar
|
||||||
const mode = (e as any).mode;
|
const mode = (e as any).mode;
|
||||||
mode !== 'None' ? this.disable() : this.enable();
|
mode !== 'none' ? this.disable() : this.enable();
|
||||||
}).bind(this));
|
}).bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,13 +128,18 @@ export class GameBar {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$container.classList.remove('bx-offscreen', 'bx-hide');
|
this.$container.classList.remove('bx-offscreen', 'bx-hide' , 'bx-gone');
|
||||||
this.$container.classList.add('bx-show');
|
this.$container.classList.add('bx-show');
|
||||||
|
|
||||||
this.beginHideTimeout();
|
this.beginHideTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
hideBar() {
|
hideBar() {
|
||||||
|
this.clearHideTimeout();
|
||||||
|
|
||||||
|
// Stop focusing Game Bar
|
||||||
|
clearFocus();
|
||||||
|
|
||||||
if (!this.$container) {
|
if (!this.$container) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import { t } from "@utils/translation";
|
|||||||
import { STATES } from "@utils/global";
|
import { STATES } from "@utils/global";
|
||||||
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 { compressCss } from "@macros/build" with {type: "macro"};
|
||||||
|
|
||||||
export class LoadingScreen {
|
export class LoadingScreen {
|
||||||
static #$bgStyle: HTMLElement;
|
static #$bgStyle: HTMLElement;
|
||||||
@ -43,7 +44,7 @@ export class LoadingScreen {
|
|||||||
static #hideRocket() {
|
static #hideRocket() {
|
||||||
let $bgStyle = LoadingScreen.#$bgStyle;
|
let $bgStyle = LoadingScreen.#$bgStyle;
|
||||||
|
|
||||||
const css = `
|
const css = compressCss(`
|
||||||
#game-stream div[class*=RocketAnimation-module__container] > svg {
|
#game-stream div[class*=RocketAnimation-module__container] > svg {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@ -51,8 +52,8 @@ export class LoadingScreen {
|
|||||||
#game-stream video[class*=RocketAnimationVideo-module__video] {
|
#game-stream video[class*=RocketAnimationVideo-module__video] {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
`;
|
`);
|
||||||
$bgStyle.textContent += css;
|
$bgStyle.textContent! += css;
|
||||||
}
|
}
|
||||||
|
|
||||||
static #setBackground(imageUrl: string) {
|
static #setBackground(imageUrl: string) {
|
||||||
@ -62,9 +63,8 @@ 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 = `
|
const css = compressCss(`
|
||||||
#game-stream {
|
#game-stream {
|
||||||
background-image: linear-gradient(#00000033, #000000e6), url(${imageUrl}) !important;
|
|
||||||
background-color: transparent !important;
|
background-color: transparent !important;
|
||||||
background-position: center center !important;
|
background-position: center center !important;
|
||||||
background-repeat: no-repeat !important;
|
background-repeat: no-repeat !important;
|
||||||
@ -74,16 +74,16 @@ export class LoadingScreen {
|
|||||||
#game-stream rect[width="800"] {
|
#game-stream rect[width="800"] {
|
||||||
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;}`;
|
||||||
$bgStyle.textContent += css;
|
$bgStyle.textContent! += css;
|
||||||
|
|
||||||
const bg = new Image();
|
const bg = new Image();
|
||||||
bg.onload = e => {
|
bg.onload = e => {
|
||||||
$bgStyle.textContent += `
|
$bgStyle.textContent += compressCss(`
|
||||||
#game-stream rect[width="800"] {
|
#game-stream rect[width="800"] {
|
||||||
opacity: 0 !important;
|
opacity: 0 !important;
|
||||||
}
|
}
|
||||||
`;
|
`);
|
||||||
};
|
};
|
||||||
bg.src = imageUrl;
|
bg.src = imageUrl;
|
||||||
}
|
}
|
||||||
@ -150,18 +150,18 @@ export class LoadingScreen {
|
|||||||
if (getPref(PrefKey.UI_LOADING_SCREEN_GAME_ART) && LoadingScreen.#$bgStyle) {
|
if (getPref(PrefKey.UI_LOADING_SCREEN_GAME_ART) && LoadingScreen.#$bgStyle) {
|
||||||
const $rocketBg = document.querySelector('#game-stream rect[width="800"]');
|
const $rocketBg = document.querySelector('#game-stream rect[width="800"]');
|
||||||
$rocketBg && $rocketBg.addEventListener('transitionend', e => {
|
$rocketBg && $rocketBg.addEventListener('transitionend', e => {
|
||||||
LoadingScreen.#$bgStyle.textContent += `
|
LoadingScreen.#$bgStyle.textContent += compressCss(`
|
||||||
#game-stream {
|
#game-stream {
|
||||||
background: #000 !important;
|
background: #000 !important;
|
||||||
}
|
}
|
||||||
`;
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
LoadingScreen.#$bgStyle.textContent += `
|
LoadingScreen.#$bgStyle.textContent += compressCss(`
|
||||||
#game-stream rect[width="800"] {
|
#game-stream rect[width="800"] {
|
||||||
opacity: 1 !important;
|
opacity: 1 !important;
|
||||||
}
|
}
|
||||||
`;
|
`);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(LoadingScreen.reset, 2000);
|
setTimeout(LoadingScreen.reset, 2000);
|
||||||
|
@ -459,7 +459,7 @@ export class EmulatedMkbHandler extends MkbHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const mode = (e as any).mode;
|
const mode = (e as any).mode;
|
||||||
if (mode === 'None') {
|
if (mode === 'none') {
|
||||||
this.#$message.classList.remove('bx-offscreen');
|
this.#$message.classList.remove('bx-offscreen');
|
||||||
} else {
|
} else {
|
||||||
this.#$message.classList.add('bx-offscreen');
|
this.#$message.classList.add('bx-offscreen');
|
||||||
|
@ -69,7 +69,7 @@ export class NativeMkbHandler extends MkbHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const mode = (e as any).mode;
|
const mode = (e as any).mode;
|
||||||
if (mode === 'None') {
|
if (mode === 'none') {
|
||||||
this.#$message.classList.remove('bx-offscreen');
|
this.#$message.classList.remove('bx-offscreen');
|
||||||
} else {
|
} else {
|
||||||
this.#$message.classList.add('bx-offscreen');
|
this.#$message.classList.add('bx-offscreen');
|
||||||
|
@ -15,7 +15,7 @@ import codeVibrationAdjust from "./patches/vibration-adjust.js" with { type: "te
|
|||||||
import { FeatureGates } from "@/utils/feature-gates.js";
|
import { FeatureGates } from "@/utils/feature-gates.js";
|
||||||
import { UiSection } from "@/enums/ui-sections.js";
|
import { UiSection } from "@/enums/ui-sections.js";
|
||||||
import { PrefKey } from "@/enums/pref-keys.js";
|
import { PrefKey } from "@/enums/pref-keys.js";
|
||||||
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
import { getPref, StreamTouchController } from "@/utils/settings-storages/global-settings-storage";
|
||||||
import { GamePassCloudGallery } from "@/enums/game-pass-gallery.js";
|
import { GamePassCloudGallery } from "@/enums/game-pass-gallery.js";
|
||||||
|
|
||||||
type PatchArray = (keyof typeof PATCHES)[];
|
type PatchArray = (keyof typeof PATCHES)[];
|
||||||
@ -54,7 +54,7 @@ const LOG_TAG = 'Patcher';
|
|||||||
const PATCHES = {
|
const PATCHES = {
|
||||||
// Disable ApplicationInsights.track() function
|
// Disable ApplicationInsights.track() function
|
||||||
disableAiTrack(str: string) {
|
disableAiTrack(str: string) {
|
||||||
const text = '.track=function(';
|
let text = '.track=function(';
|
||||||
const index = str.indexOf(text);
|
const index = str.indexOf(text);
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
return false;
|
return false;
|
||||||
@ -69,7 +69,7 @@ const PATCHES = {
|
|||||||
|
|
||||||
// Set disableTelemetry() to true
|
// Set disableTelemetry() to true
|
||||||
disableTelemetry(str: string) {
|
disableTelemetry(str: string) {
|
||||||
const text = '.disableTelemetry=function(){return!1}';
|
let text = '.disableTelemetry=function(){return!1}';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ const PATCHES = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
disableTelemetryProvider(str: string) {
|
disableTelemetryProvider(str: string) {
|
||||||
const text = 'this.enableLightweightTelemetry=!';
|
let text = 'this.enableLightweightTelemetry=!';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ const PATCHES = {
|
|||||||
|
|
||||||
// Disable IndexDB logging
|
// Disable IndexDB logging
|
||||||
disableIndexDbLogging(str: string) {
|
disableIndexDbLogging(str: string) {
|
||||||
const text = ',this.logsDb=new';
|
let text = ',this.logsDb=new';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ const PATCHES = {
|
|||||||
|
|
||||||
// Set custom website layout
|
// Set custom website layout
|
||||||
websiteLayout(str: string) {
|
websiteLayout(str: string) {
|
||||||
const text = '?"tv":"default"';
|
let text = '?"tv":"default"';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ const PATCHES = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
remotePlayKeepAlive(str: string) {
|
remotePlayKeepAlive(str: string) {
|
||||||
const text = 'onServerDisconnectMessage(e){';
|
let text = 'onServerDisconnectMessage(e){';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -143,7 +143,7 @@ const PATCHES = {
|
|||||||
|
|
||||||
// Enable Remote Play feature
|
// Enable Remote Play feature
|
||||||
remotePlayConnectMode(str: string) {
|
remotePlayConnectMode(str: string) {
|
||||||
const text = 'connectMode:"cloud-connect",';
|
let text = 'connectMode:"cloud-connect",';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -151,25 +151,44 @@ const PATCHES = {
|
|||||||
return str.replace(text, codeRemotePlayEnable);
|
return str.replace(text, codeRemotePlayEnable);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Disable achievement toast in Remote Play
|
// Remote Play: Disable achievement toast
|
||||||
remotePlayDisableAchievementToast(str: string) {
|
remotePlayDisableAchievementToast(str: string) {
|
||||||
const text = '.AchievementUnlock:{';
|
let text = '.AchievementUnlock:{';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newCode = `
|
const newCode = `if (!!window.BX_REMOTE_PLAY_CONFIG) return;`;
|
||||||
if (!!window.BX_REMOTE_PLAY_CONFIG) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
return str.replace(text, text + newCode);
|
return str.replace(text, text + newCode);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Remote Play: Prevent adding "Fortnite" to the "Jump back in" list
|
||||||
|
remotePlayRecentlyUsedTitleIds(str: string) {
|
||||||
|
let text = '(e.data.recentlyUsedTitleIds)){';
|
||||||
|
if (!str.includes(text)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const newCode = `if (window.BX_REMOTE_PLAY_CONFIG) return;`;
|
||||||
|
return str.replace(text, text + newCode);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Remote Play: change web page's title
|
||||||
|
/*
|
||||||
|
remotePlayWebTitle(str: string) {
|
||||||
|
let text = '"undefined"!==typeof e&&document.title!==e';
|
||||||
|
if (!str.includes(text)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const newCode = `if (window.BX_REMOTE_PLAY_CONFIG) { e = "${t('remote-play')} - ${t('better-xcloud')}"; }`;
|
||||||
|
return str.replace(text, newCode + text);
|
||||||
|
},
|
||||||
|
*/
|
||||||
|
|
||||||
// Block WebRTC stats collector
|
// Block WebRTC stats collector
|
||||||
blockWebRtcStatsCollector(str: string) {
|
blockWebRtcStatsCollector(str: string) {
|
||||||
const text = 'this.shouldCollectStats=!0';
|
let text = 'this.shouldCollectStats=!0';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -210,7 +229,7 @@ if (!!window.BX_REMOTE_PLAY_CONFIG) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
enableXcloudLogger(str: string) {
|
enableXcloudLogger(str: string) {
|
||||||
const text = 'this.telemetryProvider=e}log(e,t,r){';
|
let text = 'this.telemetryProvider=e}log(e,t,r){';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -226,7 +245,7 @@ logFunc(logTag, '//', logMessage);
|
|||||||
},
|
},
|
||||||
|
|
||||||
enableConsoleLogging(str: string) {
|
enableConsoleLogging(str: string) {
|
||||||
const text = 'static isConsoleLoggingAllowed(){';
|
let text = 'static isConsoleLoggingAllowed(){';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -237,7 +256,7 @@ logFunc(logTag, '//', logMessage);
|
|||||||
|
|
||||||
// Control controller vibration
|
// Control controller vibration
|
||||||
playVibration(str: string) {
|
playVibration(str: string) {
|
||||||
const text = '}playVibration(e){';
|
let text = '}playVibration(e){';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -278,7 +297,7 @@ logFunc(logTag, '//', logMessage);
|
|||||||
},
|
},
|
||||||
|
|
||||||
patchUpdateInputConfigurationAsync(str: string) {
|
patchUpdateInputConfigurationAsync(str: string) {
|
||||||
const text = 'async updateInputConfigurationAsync(e){';
|
let text = 'async updateInputConfigurationAsync(e){';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -291,7 +310,7 @@ logFunc(logTag, '//', logMessage);
|
|||||||
|
|
||||||
// Add patches that are only needed when start playing
|
// Add patches that are only needed when start playing
|
||||||
loadingEndingChunks(str: string) {
|
loadingEndingChunks(str: string) {
|
||||||
const text = '"FamilySagaManager"';
|
let text = '"FamilySagaManager"';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -316,7 +335,7 @@ logFunc(logTag, '//', logMessage);
|
|||||||
},
|
},
|
||||||
|
|
||||||
exposeTouchLayoutManager(str: string) {
|
exposeTouchLayoutManager(str: string) {
|
||||||
const text = 'this._perScopeLayoutsStream=new';
|
let text = 'this._perScopeLayoutsStream=new';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -363,7 +382,7 @@ if (window.BX_EXPOSED.stopTakRendering) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
supportLocalCoOp(str: string) {
|
supportLocalCoOp(str: string) {
|
||||||
const text = 'this.gamepadMappingsToSend=[],';
|
let text = 'this.gamepadMappingsToSend=[],';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -375,7 +394,7 @@ if (window.BX_EXPOSED.stopTakRendering) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
forceFortniteConsole(str: string) {
|
forceFortniteConsole(str: string) {
|
||||||
const text = 'sendTouchInputEnabledMessage(e){';
|
let text = 'sendTouchInputEnabledMessage(e){';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -387,14 +406,16 @@ if (window.BX_EXPOSED.stopTakRendering) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
disableTakRenderer(str: string) {
|
disableTakRenderer(str: string) {
|
||||||
const text = 'const{TakRenderer:';
|
let text = 'const{TakRenderer:';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let remotePlayCode = '';
|
let autoOffCode = '';
|
||||||
if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) !== 'off' && getPref(PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF)) {
|
if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === StreamTouchController.OFF) {
|
||||||
remotePlayCode = `
|
autoOffCode = 'return;';
|
||||||
|
} else if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF)) {
|
||||||
|
autoOffCode = `
|
||||||
const gamepads = window.navigator.getGamepads();
|
const gamepads = window.navigator.getGamepads();
|
||||||
let gamepadFound = false;
|
let gamepadFound = false;
|
||||||
|
|
||||||
@ -412,13 +433,11 @@ if (gamepadFound) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const newCode = `
|
const newCode = `
|
||||||
if (!!window.BX_REMOTE_PLAY_CONFIG) {
|
${autoOffCode}
|
||||||
${remotePlayCode}
|
|
||||||
} else {
|
const titleInfo = window.BX_EXPOSED.getTitleInfo();
|
||||||
const titleInfo = window.BX_EXPOSED.getTitleInfo();
|
if (titleInfo && !titleInfo.details.hasTouchSupport && !titleInfo.details.hasFakeTouchSupport) {
|
||||||
if (titleInfo && !titleInfo.details.hasTouchSupport && !titleInfo.details.hasFakeTouchSupport) {
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -427,7 +446,7 @@ if (!!window.BX_REMOTE_PLAY_CONFIG) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
streamCombineSources(str: string) {
|
streamCombineSources(str: string) {
|
||||||
const text = 'this.useCombinedAudioVideoStream=!!this.deviceInformation.isTizen';
|
let text = 'this.useCombinedAudioVideoStream=!!this.deviceInformation.isTizen';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -437,7 +456,7 @@ if (!!window.BX_REMOTE_PLAY_CONFIG) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
patchStreamHud(str: string) {
|
patchStreamHud(str: string) {
|
||||||
const text = 'let{onCollapse';
|
let text = 'let{onCollapse';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -450,7 +469,7 @@ e.guideUI = null;
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
// Remove the TAK Edit button when the touch controller is disabled
|
// Remove the TAK Edit button when the touch controller is disabled
|
||||||
if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === 'off') {
|
if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === StreamTouchController.OFF) {
|
||||||
newCode += 'e.canShowTakHUD = false;';
|
newCode += 'e.canShowTakHUD = false;';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,13 +478,13 @@ e.guideUI = null;
|
|||||||
},
|
},
|
||||||
|
|
||||||
broadcastPollingMode(str: string) {
|
broadcastPollingMode(str: string) {
|
||||||
const text = '.setPollingMode=e=>{';
|
let text = '.setPollingMode=e=>{';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newCode = `
|
const newCode = `
|
||||||
BxEvent.dispatch(window, BxEvent.XCLOUD_POLLING_MODE_CHANGED, {mode: e});
|
BxEvent.dispatch(window, BxEvent.XCLOUD_POLLING_MODE_CHANGED, {mode: e.toLowerCase()});
|
||||||
`;
|
`;
|
||||||
str = str.replace(text, text + newCode);
|
str = str.replace(text, text + newCode);
|
||||||
return str;
|
return str;
|
||||||
@ -483,7 +502,7 @@ BxEvent.dispatch(window, BxEvent.XCLOUD_POLLING_MODE_CHANGED, {mode: e});
|
|||||||
},
|
},
|
||||||
|
|
||||||
patchXcloudTitleInfo(str: string) {
|
patchXcloudTitleInfo(str: string) {
|
||||||
const text = 'async cloudConnect';
|
let text = 'async cloudConnect';
|
||||||
let index = str.indexOf(text);
|
let index = str.indexOf(text);
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
return false;
|
return false;
|
||||||
@ -505,7 +524,7 @@ BxLogger.info('patchXcloudTitleInfo', ${titleInfoVar});
|
|||||||
},
|
},
|
||||||
|
|
||||||
patchRemotePlayMkb(str: string) {
|
patchRemotePlayMkb(str: string) {
|
||||||
const text = 'async homeConsoleConnect';
|
let text = 'async homeConsoleConnect';
|
||||||
let index = str.indexOf(text);
|
let index = str.indexOf(text);
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
return false;
|
return false;
|
||||||
@ -533,7 +552,7 @@ BxLogger.info('patchRemotePlayMkb', ${configsVar});
|
|||||||
},
|
},
|
||||||
|
|
||||||
patchAudioMediaStream(str: string) {
|
patchAudioMediaStream(str: string) {
|
||||||
const text = '.srcObject=this.audioMediaStream,';
|
let text = '.srcObject=this.audioMediaStream,';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -545,7 +564,7 @@ BxLogger.info('patchRemotePlayMkb', ${configsVar});
|
|||||||
},
|
},
|
||||||
|
|
||||||
patchCombinedAudioVideoMediaStream(str: string) {
|
patchCombinedAudioVideoMediaStream(str: string) {
|
||||||
const text = '.srcObject=this.combinedAudioVideoStream';
|
let text = '.srcObject=this.combinedAudioVideoStream';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -556,7 +575,7 @@ BxLogger.info('patchRemotePlayMkb', ${configsVar});
|
|||||||
},
|
},
|
||||||
|
|
||||||
patchTouchControlDefaultOpacity(str: string) {
|
patchTouchControlDefaultOpacity(str: string) {
|
||||||
const text = 'opacityMultiplier:1';
|
let text = 'opacityMultiplier:1';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -568,7 +587,7 @@ BxLogger.info('patchRemotePlayMkb', ${configsVar});
|
|||||||
},
|
},
|
||||||
|
|
||||||
patchShowSensorControls(str: string) {
|
patchShowSensorControls(str: string) {
|
||||||
const text = '{shouldShowSensorControls:';
|
let text = '{shouldShowSensorControls:';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -581,7 +600,7 @@ BxLogger.info('patchRemotePlayMkb', ${configsVar});
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
exposeEventTarget(str: string) {
|
exposeEventTarget(str: string) {
|
||||||
const text ='this._eventTarget=new EventTarget';
|
let text ='this._eventTarget=new EventTarget';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -598,7 +617,7 @@ window.dispatchEvent(new Event('${BxEvent.STREAM_EVENT_TARGET_READY}'))
|
|||||||
|
|
||||||
// Class with: connectAsync(), doConnectAsync(), setPlayClient()
|
// Class with: connectAsync(), doConnectAsync(), setPlayClient()
|
||||||
exposeStreamSession(str: string) {
|
exposeStreamSession(str: string) {
|
||||||
const text =',this._connectionType=';
|
let text =',this._connectionType=';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -612,7 +631,7 @@ true` + text;
|
|||||||
},
|
},
|
||||||
|
|
||||||
skipFeedbackDialog(str: string) {
|
skipFeedbackDialog(str: string) {
|
||||||
const text = '&&this.shouldTransitionToFeedback(';
|
let text = '&&this.shouldTransitionToFeedback(';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -622,7 +641,7 @@ true` + text;
|
|||||||
},
|
},
|
||||||
|
|
||||||
enableNativeMkb(str: string) {
|
enableNativeMkb(str: string) {
|
||||||
const text = 'e.mouseSupported&&e.keyboardSupported&&e.fullscreenSupported;';
|
let text = 'e.mouseSupported&&e.keyboardSupported&&e.fullscreenSupported;';
|
||||||
if ((!str.includes(text))) {
|
if ((!str.includes(text))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -632,7 +651,7 @@ true` + text;
|
|||||||
},
|
},
|
||||||
|
|
||||||
patchMouseAndKeyboardEnabled(str: string) {
|
patchMouseAndKeyboardEnabled(str: string) {
|
||||||
const text = 'get mouseAndKeyboardEnabled(){';
|
let text = 'get mouseAndKeyboardEnabled(){';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -642,7 +661,7 @@ true` + text;
|
|||||||
},
|
},
|
||||||
|
|
||||||
exposeInputSink(str: string) {
|
exposeInputSink(str: string) {
|
||||||
const text = 'this.controlChannel=null,this.inputChannel=null';
|
let text = 'this.controlChannel=null,this.inputChannel=null';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -654,7 +673,7 @@ true` + text;
|
|||||||
},
|
},
|
||||||
|
|
||||||
disableNativeRequestPointerLock(str: string) {
|
disableNativeRequestPointerLock(str: string) {
|
||||||
const text = 'async requestPointerLock(){';
|
let text = 'async requestPointerLock(){';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -665,7 +684,7 @@ true` + text;
|
|||||||
|
|
||||||
// Fix crashing when RequestInfo.origin is empty
|
// Fix crashing when RequestInfo.origin is empty
|
||||||
patchRequestInfoCrash(str: string) {
|
patchRequestInfoCrash(str: string) {
|
||||||
const text = 'if(!e)throw new Error("RequestInfo.origin is falsy");';
|
let text = 'if(!e)throw new Error("RequestInfo.origin is falsy");';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -675,7 +694,7 @@ true` + text;
|
|||||||
},
|
},
|
||||||
|
|
||||||
exposeDialogRoutes(str: string) {
|
exposeDialogRoutes(str: string) {
|
||||||
const text = 'return{goBack:function(){';
|
let text = 'return{goBack:function(){';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -804,7 +823,7 @@ true` + text;
|
|||||||
const PREF_HIDE_SECTIONS = getPref(PrefKey.UI_HIDE_SECTIONS) as UiSection[];
|
const PREF_HIDE_SECTIONS = getPref(PrefKey.UI_HIDE_SECTIONS) as UiSection[];
|
||||||
const siglIds: GamePassCloudGallery[] = [];
|
const siglIds: GamePassCloudGallery[] = [];
|
||||||
|
|
||||||
const sections: Partial<Record<UiSection, GamePassCloudGallery>> = {
|
const sections: PartialRecord<UiSection, GamePassCloudGallery> = {
|
||||||
[UiSection.NATIVE_MKB]: GamePassCloudGallery.NATIVE_MKB,
|
[UiSection.NATIVE_MKB]: GamePassCloudGallery.NATIVE_MKB,
|
||||||
[UiSection.MOST_POPULAR]: GamePassCloudGallery.MOST_POPULAR,
|
[UiSection.MOST_POPULAR]: GamePassCloudGallery.MOST_POPULAR,
|
||||||
};
|
};
|
||||||
@ -830,7 +849,7 @@ if (e && e.id) {
|
|||||||
|
|
||||||
// Override Storage.getSettings()
|
// Override Storage.getSettings()
|
||||||
overrideStorageGetSettings(str: string) {
|
overrideStorageGetSettings(str: string) {
|
||||||
const text = '}getSetting(e){';
|
let text = '}getSetting(e){';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -894,7 +913,7 @@ if (this.baseStorageKey in window.BX_EXPOSED.overrideSettings) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
detectBrowserRouterReady(str: string) {
|
detectBrowserRouterReady(str: string) {
|
||||||
const text = 'BrowserRouter:()=>';
|
let text = 'BrowserRouter:()=>';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -912,6 +931,26 @@ if (this.baseStorageKey in window.BX_EXPOSED.overrideSettings) {
|
|||||||
str = PatcherUtils.insertAt(str, index, 'window.BxEvent.dispatch(window, window.BxEvent.XCLOUD_ROUTER_HISTORY_READY, {history: this.history});');
|
str = PatcherUtils.insertAt(str, index, 'window.BxEvent.dispatch(window, window.BxEvent.XCLOUD_ROUTER_HISTORY_READY, {history: this.history});');
|
||||||
return str;
|
return str;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Set Achievements list's filter default to "Locked"
|
||||||
|
guideAchievementsDefaultLocked(str: string) {
|
||||||
|
let index = str.indexOf('FilterButton-module__container');
|
||||||
|
index >= 0 && (index = PatcherUtils.lastIndexOf(str, '.All', index, 150));
|
||||||
|
if (index < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
str = PatcherUtils.replaceWith(str, index, '.All', '.Locked');
|
||||||
|
|
||||||
|
index = str.indexOf('"Guide_Achievements_Unlocked_Empty","Guide_Achievements_Locked_Empty"');
|
||||||
|
index >= 0 && (index = PatcherUtils.indexOf(str, '.All', index, 250));
|
||||||
|
if (index < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
str = PatcherUtils.replaceWith(str, index, '.All', '.Locked');
|
||||||
|
return str;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let PATCH_ORDERS: PatchArray = [
|
let PATCH_ORDERS: PatchArray = [
|
||||||
@ -933,6 +972,8 @@ let PATCH_ORDERS: PatchArray = [
|
|||||||
'exposeStreamSession',
|
'exposeStreamSession',
|
||||||
'exposeDialogRoutes',
|
'exposeDialogRoutes',
|
||||||
|
|
||||||
|
'guideAchievementsDefaultLocked',
|
||||||
|
|
||||||
'enableTvRoutes',
|
'enableTvRoutes',
|
||||||
AppInterface && 'detectProductDetailsPage',
|
AppInterface && 'detectProductDetailsPage',
|
||||||
|
|
||||||
@ -962,6 +1003,7 @@ let PATCH_ORDERS: PatchArray = [
|
|||||||
'remotePlayKeepAlive',
|
'remotePlayKeepAlive',
|
||||||
'remotePlayDirectConnectUrl',
|
'remotePlayDirectConnectUrl',
|
||||||
'remotePlayDisableAchievementToast',
|
'remotePlayDisableAchievementToast',
|
||||||
|
'remotePlayRecentlyUsedTitleIds',
|
||||||
STATES.userAgent.capabilities.touch && 'patchUpdateInputConfigurationAsync',
|
STATES.userAgent.capabilities.touch && 'patchUpdateInputConfigurationAsync',
|
||||||
] : []),
|
] : []),
|
||||||
|
|
||||||
@ -991,9 +1033,9 @@ let PLAYING_PATCH_ORDERS: PatchArray = [
|
|||||||
getPref(PrefKey.STREAM_DISABLE_FEEDBACK_DIALOG) && 'skipFeedbackDialog',
|
getPref(PrefKey.STREAM_DISABLE_FEEDBACK_DIALOG) && 'skipFeedbackDialog',
|
||||||
|
|
||||||
...(STATES.userAgent.capabilities.touch ? [
|
...(STATES.userAgent.capabilities.touch ? [
|
||||||
getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === 'all' && 'patchShowSensorControls',
|
getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === StreamTouchController.ALL && 'patchShowSensorControls',
|
||||||
getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === 'all' && 'exposeTouchLayoutManager',
|
getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === StreamTouchController.ALL && 'exposeTouchLayoutManager',
|
||||||
(getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === 'off' || getPref(PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF) || !STATES.userAgent.capabilities.touch) && 'disableTakRenderer',
|
(getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === StreamTouchController.OFF || getPref(PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF) || !STATES.userAgent.capabilities.touch) && 'disableTakRenderer',
|
||||||
getPref(PrefKey.STREAM_TOUCH_CONTROLLER_DEFAULT_OPACITY) !== 100 && 'patchTouchControlDefaultOpacity',
|
getPref(PrefKey.STREAM_TOUCH_CONTROLLER_DEFAULT_OPACITY) !== 100 && 'patchTouchControlDefaultOpacity',
|
||||||
'patchBabylonRendererClass',
|
'patchBabylonRendererClass',
|
||||||
] : []),
|
] : []),
|
||||||
|
232
src/modules/remote-play-manager.ts
Normal file
232
src/modules/remote-play-manager.ts
Normal file
@ -0,0 +1,232 @@
|
|||||||
|
import { STATES, AppInterface } from "@utils/global";
|
||||||
|
import { Toast } from "@utils/toast";
|
||||||
|
import { BxEvent } from "@utils/bx-event";
|
||||||
|
import { t } from "@utils/translation";
|
||||||
|
import { localRedirect } from "@modules/ui/ui";
|
||||||
|
import { BxLogger } from "@utils/bx-logger";
|
||||||
|
import { HeaderSection } from "./ui/header";
|
||||||
|
import { PrefKey } from "@/enums/pref-keys";
|
||||||
|
import { getPref, setPref } from "@/utils/settings-storages/global-settings-storage";
|
||||||
|
import { RemotePlayNavigationDialog } from "./ui/dialog/remote-play-dialog";
|
||||||
|
|
||||||
|
const LOG_TAG = 'RemotePlay';
|
||||||
|
|
||||||
|
export const enum RemotePlayConsoleState {
|
||||||
|
ON = 'On',
|
||||||
|
OFF = 'Off',
|
||||||
|
STANDBY = 'ConnectedStandby',
|
||||||
|
UNKNOWN = 'Unknown',
|
||||||
|
}
|
||||||
|
|
||||||
|
type RemotePlayRegion = {
|
||||||
|
name: string;
|
||||||
|
baseUri: string;
|
||||||
|
isDefault: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
type RemotePlayConsole = {
|
||||||
|
deviceName: string;
|
||||||
|
serverId: string;
|
||||||
|
powerState: RemotePlayConsoleState;
|
||||||
|
consoleType: string;
|
||||||
|
// playPath: string;
|
||||||
|
// outOfHomeWarning: string;
|
||||||
|
// wirelessWarning: string;
|
||||||
|
// isDevKit: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export class RemotePlayManager {
|
||||||
|
private static instance: RemotePlayManager;
|
||||||
|
public static getInstance(): RemotePlayManager {
|
||||||
|
if (!this.instance) {
|
||||||
|
this.instance = new RemotePlayManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private isInitialized = false;
|
||||||
|
|
||||||
|
private XCLOUD_TOKEN!: string;
|
||||||
|
private XHOME_TOKEN!: string;
|
||||||
|
|
||||||
|
private consoles!: Array<RemotePlayConsole>;
|
||||||
|
private regions: Array<RemotePlayRegion> = [];
|
||||||
|
|
||||||
|
initialize() {
|
||||||
|
if (this.isInitialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isInitialized = true;
|
||||||
|
|
||||||
|
this.getXhomeToken(() => {
|
||||||
|
this.getConsolesList(() => {
|
||||||
|
BxLogger.info(LOG_TAG, 'Consoles', this.consoles);
|
||||||
|
|
||||||
|
STATES.supportedRegion && HeaderSection.showRemotePlayButton();
|
||||||
|
BxEvent.dispatch(window, BxEvent.REMOTE_PLAY_READY);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
get xcloudToken() {
|
||||||
|
return this.XCLOUD_TOKEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
set xcloudToken(token: string) {
|
||||||
|
this.XCLOUD_TOKEN = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
get xhomeToken() {
|
||||||
|
return this.XHOME_TOKEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
getConsoles() {
|
||||||
|
return this.consoles;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private getXhomeToken(callback: any) {
|
||||||
|
if (this.XHOME_TOKEN) {
|
||||||
|
callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let GSSV_TOKEN;
|
||||||
|
try {
|
||||||
|
GSSV_TOKEN = JSON.parse(localStorage.getItem('xboxcom_xbl_user_info')!).tokens['http://gssv.xboxlive.com/'].token;
|
||||||
|
} catch (e) {
|
||||||
|
for (let i = 0; i < localStorage.length; i++){
|
||||||
|
const key = localStorage.key(i)!;
|
||||||
|
if (!key.startsWith('Auth.User.')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const json = JSON.parse(localStorage.getItem(key)!);
|
||||||
|
for (const token of json.tokens) {
|
||||||
|
if (!token.relyingParty.includes('gssv.xboxlive.com')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
GSSV_TOKEN = token.tokenData.token;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const request = new Request('https://xhome.gssv-play-prod.xboxlive.com/v2/login/user', {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({
|
||||||
|
offeringId: 'xhome',
|
||||||
|
token: GSSV_TOKEN,
|
||||||
|
}),
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json; charset=utf-8',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
fetch(request).then(resp => resp.json())
|
||||||
|
.then(json => {
|
||||||
|
this.regions = json.offeringSettings.regions;
|
||||||
|
this.XHOME_TOKEN = json.gsToken;
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getConsolesList(callback: any) {
|
||||||
|
if (this.consoles) {
|
||||||
|
callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Authorization': `Bearer ${this.XHOME_TOKEN}`,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Test servers one by one
|
||||||
|
for (const region of this.regions) {
|
||||||
|
try {
|
||||||
|
const request = new Request(`${region.baseUri}/v6/servers/home?mr=50`, options);
|
||||||
|
const resp = await fetch(request);
|
||||||
|
|
||||||
|
const json = await resp.json();
|
||||||
|
if (json.results.length === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.consoles = json.results;
|
||||||
|
|
||||||
|
// Store working server
|
||||||
|
STATES.remotePlay.server = region.baseUri;
|
||||||
|
|
||||||
|
break;
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// None of the servers worked
|
||||||
|
if (!STATES.remotePlay.server) {
|
||||||
|
this.consoles = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
|
||||||
|
play(serverId: string, resolution?: string) {
|
||||||
|
if (resolution) {
|
||||||
|
setPref(PrefKey.REMOTE_PLAY_RESOLUTION, resolution);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATES.remotePlay.config = {
|
||||||
|
serverId: serverId,
|
||||||
|
};
|
||||||
|
window.BX_REMOTE_PLAY_CONFIG = STATES.remotePlay.config;
|
||||||
|
|
||||||
|
localRedirect('/launch/fortnite/BT5P2X999VH2#remote-play');
|
||||||
|
}
|
||||||
|
|
||||||
|
togglePopup(force = null) {
|
||||||
|
if (!this.isReady()) {
|
||||||
|
Toast.show(t('getting-consoles-list'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.consoles.length === 0) {
|
||||||
|
Toast.show(t('no-consoles-found'), '', {instant: true});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show native dialog in Android app
|
||||||
|
if (AppInterface && AppInterface.showRemotePlayDialog) {
|
||||||
|
AppInterface.showRemotePlayDialog(JSON.stringify(this.consoles));
|
||||||
|
(document.activeElement as HTMLElement).blur();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RemotePlayNavigationDialog.getInstance().show();
|
||||||
|
}
|
||||||
|
|
||||||
|
static detect() {
|
||||||
|
if (!getPref(PrefKey.REMOTE_PLAY_ENABLED)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATES.remotePlay.isPlaying = window.location.pathname.includes('/launch/') && window.location.hash.startsWith('#remote-play');
|
||||||
|
if (STATES.remotePlay?.isPlaying) {
|
||||||
|
window.BX_REMOTE_PLAY_CONFIG = STATES.remotePlay.config;
|
||||||
|
// Remove /launch/... from URL
|
||||||
|
window.history.replaceState({origin: 'better-xcloud'}, '', 'https://www.xbox.com/' + location.pathname.substring(1, 6) + '/play');
|
||||||
|
} else {
|
||||||
|
window.BX_REMOTE_PLAY_CONFIG = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
isReady() {
|
||||||
|
return this.consoles !== null;
|
||||||
|
}
|
||||||
|
}
|
@ -1,364 +0,0 @@
|
|||||||
import { STATES, AppInterface } from "@utils/global";
|
|
||||||
import { CE, createButton, ButtonStyle } from "@utils/html";
|
|
||||||
import { BxIcon } from "@utils/bx-icon";
|
|
||||||
import { Toast } from "@utils/toast";
|
|
||||||
import { BxEvent } from "@utils/bx-event";
|
|
||||||
import { t } from "@utils/translation";
|
|
||||||
import { localRedirect } from "@modules/ui/ui";
|
|
||||||
import { BxLogger } from "@utils/bx-logger";
|
|
||||||
import { HeaderSection } from "./ui/header";
|
|
||||||
import { PrefKey } from "@/enums/pref-keys";
|
|
||||||
import { getPref, setPref } from "@/utils/settings-storages/global-settings-storage";
|
|
||||||
|
|
||||||
const LOG_TAG = 'RemotePlay';
|
|
||||||
|
|
||||||
const enum RemotePlayConsoleState {
|
|
||||||
ON = 'On',
|
|
||||||
OFF = 'Off',
|
|
||||||
STANDBY = 'ConnectedStandby',
|
|
||||||
UNKNOWN = 'Unknown',
|
|
||||||
}
|
|
||||||
|
|
||||||
type RemotePlayRegion = {
|
|
||||||
name: string;
|
|
||||||
baseUri: string;
|
|
||||||
isDefault: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
type RemotePlayConsole = {
|
|
||||||
deviceName: string;
|
|
||||||
serverId: string;
|
|
||||||
powerState: RemotePlayConsoleState;
|
|
||||||
consoleType: string;
|
|
||||||
// playPath: string;
|
|
||||||
// outOfHomeWarning: string;
|
|
||||||
// wirelessWarning: string;
|
|
||||||
// isDevKit: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export class RemotePlay {
|
|
||||||
static XCLOUD_TOKEN: string;
|
|
||||||
static XHOME_TOKEN: string;
|
|
||||||
static #CONSOLES: Array<RemotePlayConsole>;
|
|
||||||
static #REGIONS: Array<RemotePlayRegion>;
|
|
||||||
|
|
||||||
static readonly #STATE_LABELS: {[key in RemotePlayConsoleState]: string} = {
|
|
||||||
[RemotePlayConsoleState.ON]: t('powered-on'),
|
|
||||||
[RemotePlayConsoleState.OFF]: t('powered-off'),
|
|
||||||
[RemotePlayConsoleState.STANDBY]: t('standby'),
|
|
||||||
[RemotePlayConsoleState.UNKNOWN]: t('unknown'),
|
|
||||||
};
|
|
||||||
|
|
||||||
static readonly BASE_DEVICE_INFO = {
|
|
||||||
appInfo: {
|
|
||||||
env: {
|
|
||||||
clientAppId: window.location.host,
|
|
||||||
clientAppType: 'browser',
|
|
||||||
clientAppVersion: '24.17.36',
|
|
||||||
clientSdkVersion: '10.1.14',
|
|
||||||
httpEnvironment: 'prod',
|
|
||||||
sdkInstallId: '',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
dev: {
|
|
||||||
displayInfo: {
|
|
||||||
dimensions: {
|
|
||||||
widthInPixels: 1920,
|
|
||||||
heightInPixels: 1080,
|
|
||||||
},
|
|
||||||
pixelDensity: {
|
|
||||||
dpiX: 1,
|
|
||||||
dpiY: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
hw: {
|
|
||||||
make: 'Microsoft',
|
|
||||||
model: 'unknown',
|
|
||||||
sdktype: 'web',
|
|
||||||
},
|
|
||||||
os: {
|
|
||||||
name: 'windows',
|
|
||||||
ver: '22631.2715',
|
|
||||||
platform: 'desktop',
|
|
||||||
},
|
|
||||||
browser: {
|
|
||||||
browserName: 'chrome',
|
|
||||||
browserVersion: '125.0',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
static #$content: HTMLElement;
|
|
||||||
|
|
||||||
static #initialize() {
|
|
||||||
if (RemotePlay.#$content) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RemotePlay.#$content = CE('div', {}, t('getting-consoles-list'));
|
|
||||||
RemotePlay.#getXhomeToken(() => {
|
|
||||||
RemotePlay.#getConsolesList(() => {
|
|
||||||
BxLogger.info(LOG_TAG, 'Consoles', RemotePlay.#CONSOLES);
|
|
||||||
if (RemotePlay.#CONSOLES && RemotePlay.#CONSOLES.length > 0) {
|
|
||||||
STATES.supportedRegion && HeaderSection.showRemotePlayButton();
|
|
||||||
}
|
|
||||||
|
|
||||||
RemotePlay.#renderConsoles();
|
|
||||||
BxEvent.dispatch(window, BxEvent.REMOTE_PLAY_READY);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static #renderConsoles() {
|
|
||||||
const $fragment = CE('div', {'class': 'bx-remote-play-container'});
|
|
||||||
|
|
||||||
if (!RemotePlay.#CONSOLES || RemotePlay.#CONSOLES.length === 0) {
|
|
||||||
$fragment.appendChild(CE('span', {}, t('no-consoles-found')));
|
|
||||||
RemotePlay.#$content = CE('div', {}, $fragment);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const $settingNote = CE('p', {});
|
|
||||||
|
|
||||||
const resolutions = [1080, 720];
|
|
||||||
const currentResolution = getPref(PrefKey.REMOTE_PLAY_RESOLUTION);
|
|
||||||
const $resolutionGroup = CE('div', {});
|
|
||||||
for (const resolution of resolutions) {
|
|
||||||
const value = `${resolution}p`;
|
|
||||||
const id = `bx_radio_xhome_resolution_${resolution}`;
|
|
||||||
|
|
||||||
const $radio = CE<HTMLInputElement>('input', {
|
|
||||||
'type': 'radio',
|
|
||||||
'value': value,
|
|
||||||
'id': id,
|
|
||||||
'name': 'bx_radio_xhome_resolution',
|
|
||||||
}, value);
|
|
||||||
|
|
||||||
$radio.addEventListener('change', e => {
|
|
||||||
const value = (e.target as HTMLInputElement).value;
|
|
||||||
|
|
||||||
$settingNote.textContent = value === '1080p' ? '✅ ' + t('can-stream-xbox-360-games') : '❌ ' + t('cant-stream-xbox-360-games');
|
|
||||||
setPref(PrefKey.REMOTE_PLAY_RESOLUTION, value);
|
|
||||||
});
|
|
||||||
|
|
||||||
const $label = CE('label', {
|
|
||||||
'for': id,
|
|
||||||
'class': 'bx-remote-play-resolution',
|
|
||||||
}, $radio, `${resolution}p`);
|
|
||||||
|
|
||||||
$resolutionGroup.appendChild($label);
|
|
||||||
|
|
||||||
if (currentResolution === value) {
|
|
||||||
$radio.checked = true;
|
|
||||||
$radio.dispatchEvent(new Event('change'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const $qualitySettings = CE('div', {'class': 'bx-remote-play-settings'},
|
|
||||||
CE('div', {},
|
|
||||||
CE('label', {}, t('target-resolution'), $settingNote),
|
|
||||||
$resolutionGroup,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$fragment.appendChild($qualitySettings);
|
|
||||||
|
|
||||||
// Render concoles list
|
|
||||||
for (let con of RemotePlay.#CONSOLES) {
|
|
||||||
const $child = CE('div', {'class': 'bx-remote-play-device-wrapper'},
|
|
||||||
CE('div', {'class': 'bx-remote-play-device-info'},
|
|
||||||
CE('div', {},
|
|
||||||
CE('span', {'class': 'bx-remote-play-device-name'}, con.deviceName),
|
|
||||||
CE('span', {'class': 'bx-remote-play-console-type'}, con.consoleType.replace('Xbox', ''))
|
|
||||||
),
|
|
||||||
CE('div', {'class': 'bx-remote-play-power-state'}, RemotePlay.#STATE_LABELS[con.powerState]),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Connect button
|
|
||||||
createButton({
|
|
||||||
classes: ['bx-remote-play-connect-button'],
|
|
||||||
label: t('console-connect'),
|
|
||||||
style: ButtonStyle.PRIMARY | ButtonStyle.FOCUSABLE,
|
|
||||||
onClick: e => {
|
|
||||||
RemotePlay.play(con.serverId);
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
$fragment.appendChild($child);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add Help button
|
|
||||||
$fragment.appendChild(createButton({
|
|
||||||
icon: BxIcon.QUESTION,
|
|
||||||
style: ButtonStyle.GHOST | ButtonStyle.FOCUSABLE,
|
|
||||||
url: 'https://better-xcloud.github.io/remote-play',
|
|
||||||
label: t('help'),
|
|
||||||
}));
|
|
||||||
|
|
||||||
RemotePlay.#$content = CE('div', {}, $fragment);
|
|
||||||
}
|
|
||||||
|
|
||||||
static #getXhomeToken(callback: any) {
|
|
||||||
if (RemotePlay.XHOME_TOKEN) {
|
|
||||||
callback();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let GSSV_TOKEN;
|
|
||||||
try {
|
|
||||||
GSSV_TOKEN = JSON.parse(localStorage.getItem('xboxcom_xbl_user_info')!).tokens['http://gssv.xboxlive.com/'].token;
|
|
||||||
} catch (e) {
|
|
||||||
for (let i = 0; i < localStorage.length; i++){
|
|
||||||
const key = localStorage.key(i)!;
|
|
||||||
if (!key.startsWith('Auth.User.')) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const json = JSON.parse(localStorage.getItem(key)!);
|
|
||||||
for (const token of json.tokens) {
|
|
||||||
if (!token.relyingParty.includes('gssv.xboxlive.com')) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
GSSV_TOKEN = token.tokenData.token;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const request = new Request('https://xhome.gssv-play-prod.xboxlive.com/v2/login/user', {
|
|
||||||
method: 'POST',
|
|
||||||
body: JSON.stringify({
|
|
||||||
offeringId: 'xhome',
|
|
||||||
token: GSSV_TOKEN,
|
|
||||||
}),
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json; charset=utf-8',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
fetch(request).then(resp => resp.json())
|
|
||||||
.then(json => {
|
|
||||||
RemotePlay.#REGIONS = json.offeringSettings.regions;
|
|
||||||
RemotePlay.XHOME_TOKEN = json.gsToken;
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static async #getConsolesList(callback: any) {
|
|
||||||
if (RemotePlay.#CONSOLES) {
|
|
||||||
callback();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const options = {
|
|
||||||
method: 'GET',
|
|
||||||
headers: {
|
|
||||||
'Authorization': `Bearer ${RemotePlay.XHOME_TOKEN}`,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// Test servers one by one
|
|
||||||
for (const region of RemotePlay.#REGIONS) {
|
|
||||||
try {
|
|
||||||
const request = new Request(`${region.baseUri}/v6/servers/home?mr=50`, options);
|
|
||||||
const resp = await fetch(request);
|
|
||||||
|
|
||||||
const json = await resp.json();
|
|
||||||
RemotePlay.#CONSOLES = json.results;
|
|
||||||
|
|
||||||
// Store working server
|
|
||||||
STATES.remotePlay.server = region.baseUri;
|
|
||||||
|
|
||||||
callback();
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
if (RemotePlay.#CONSOLES) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// None of the servers worked
|
|
||||||
if (!STATES.remotePlay.server) {
|
|
||||||
RemotePlay.#CONSOLES = [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static play(serverId: string, resolution?: string) {
|
|
||||||
if (resolution) {
|
|
||||||
setPref(PrefKey.REMOTE_PLAY_RESOLUTION, resolution);
|
|
||||||
}
|
|
||||||
|
|
||||||
STATES.remotePlay.config = {
|
|
||||||
serverId: serverId,
|
|
||||||
};
|
|
||||||
window.BX_REMOTE_PLAY_CONFIG = STATES.remotePlay.config;
|
|
||||||
|
|
||||||
localRedirect('/launch/fortnite/BT5P2X999VH2#remote-play');
|
|
||||||
RemotePlay.detachPopup();
|
|
||||||
}
|
|
||||||
|
|
||||||
static preload() {
|
|
||||||
RemotePlay.#initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
static detachPopup() {
|
|
||||||
// Detach popup from body
|
|
||||||
const $popup = document.querySelector('.bx-remote-play-popup');
|
|
||||||
$popup && $popup.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
static togglePopup(force = null) {
|
|
||||||
if (!getPref(PrefKey.REMOTE_PLAY_ENABLED) || !RemotePlay.isReady()) {
|
|
||||||
Toast.show(t('getting-consoles-list'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RemotePlay.#initialize();
|
|
||||||
|
|
||||||
if (AppInterface && AppInterface.showRemotePlayDialog) {
|
|
||||||
AppInterface.showRemotePlayDialog(JSON.stringify(RemotePlay.#CONSOLES));
|
|
||||||
(document.activeElement as HTMLElement).blur();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (document.querySelector('.bx-remote-play-popup')) {
|
|
||||||
if (force === false) {
|
|
||||||
RemotePlay.#$content.classList.add('bx-gone');
|
|
||||||
} else {
|
|
||||||
RemotePlay.#$content.classList.toggle('bx-gone');
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const $header = document.querySelector('#gamepass-root header')!;
|
|
||||||
|
|
||||||
const group = $header.firstElementChild!.getAttribute('data-group')!;
|
|
||||||
RemotePlay.#$content.setAttribute('data-group', group);
|
|
||||||
RemotePlay.#$content.classList.add('bx-remote-play-popup');
|
|
||||||
RemotePlay.#$content.classList.remove('bx-gone');
|
|
||||||
|
|
||||||
$header.insertAdjacentElement('afterend', RemotePlay.#$content);
|
|
||||||
}
|
|
||||||
|
|
||||||
static detect() {
|
|
||||||
if (!getPref(PrefKey.REMOTE_PLAY_ENABLED)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
STATES.remotePlay.isPlaying = window.location.pathname.includes('/launch/') && window.location.hash.startsWith('#remote-play');
|
|
||||||
if (STATES.remotePlay?.isPlaying) {
|
|
||||||
window.BX_REMOTE_PLAY_CONFIG = STATES.remotePlay.config;
|
|
||||||
// Remove /launch/... from URL
|
|
||||||
window.history.replaceState({origin: 'better-xcloud'}, '', 'https://www.xbox.com/' + location.pathname.substring(1, 6) + '/play');
|
|
||||||
} else {
|
|
||||||
window.BX_REMOTE_PLAY_CONFIG = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static isReady() {
|
|
||||||
return RemotePlay.#CONSOLES !== null && RemotePlay.#CONSOLES.length > 0;
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,6 +4,12 @@ import { Toast } from "@utils/toast";
|
|||||||
import { ceilToNearest, floorToNearest } from "@/utils/utils";
|
import { ceilToNearest, floorToNearest } from "@/utils/utils";
|
||||||
import { PrefKey } from "@/enums/pref-keys";
|
import { PrefKey } from "@/enums/pref-keys";
|
||||||
import { getPref, setPref } from "@/utils/settings-storages/global-settings-storage";
|
import { getPref, setPref } from "@/utils/settings-storages/global-settings-storage";
|
||||||
|
import { BxEvent } from "@/utils/bx-event";
|
||||||
|
|
||||||
|
export enum SpeakerState {
|
||||||
|
ENABLED,
|
||||||
|
MUTED,
|
||||||
|
}
|
||||||
|
|
||||||
export class SoundShortcut {
|
export class SoundShortcut {
|
||||||
static adjustGainNodeVolume(amount: number): number {
|
static adjustGainNodeVolume(amount: number): number {
|
||||||
@ -64,6 +70,10 @@ export class SoundShortcut {
|
|||||||
|
|
||||||
SoundShortcut.setGainNodeVolume(targetValue);
|
SoundShortcut.setGainNodeVolume(targetValue);
|
||||||
Toast.show(`${t('stream')} ❯ ${t('volume')}`, status, {instant: true});
|
Toast.show(`${t('stream')} ❯ ${t('volume')}`, status, {instant: true});
|
||||||
|
|
||||||
|
BxEvent.dispatch(window, BxEvent.SPEAKER_STATE_CHANGED, {
|
||||||
|
speakerState: targetValue === 0 ? SpeakerState.MUTED : SpeakerState.ENABLED,
|
||||||
|
})
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,6 +89,10 @@ export class SoundShortcut {
|
|||||||
|
|
||||||
const status = $media.muted ? t('muted') : t('unmuted');
|
const status = $media.muted ? t('muted') : t('unmuted');
|
||||||
Toast.show(`${t('stream')} ❯ ${t('volume')}`, status, {instant: true});
|
Toast.show(`${t('stream')} ❯ ${t('volume')}`, status, {instant: true});
|
||||||
|
|
||||||
|
BxEvent.dispatch(window, BxEvent.SPEAKER_STATE_CHANGED, {
|
||||||
|
speakerState: $media.muted ? SpeakerState.MUTED : SpeakerState.ENABLED,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
import { GamepadKey } from "@/enums/mkb";
|
import { GamepadKey } from "@/enums/mkb";
|
||||||
|
import { PrefKey } from "@/enums/pref-keys";
|
||||||
import { EmulatedMkbHandler } from "@/modules/mkb/mkb-handler";
|
import { EmulatedMkbHandler } 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 } from "@/utils/html";
|
import { CE, isElementVisible } from "@/utils/html";
|
||||||
import { setNearby } from "@/utils/navigation-utils";
|
import { setNearby } from "@/utils/navigation-utils";
|
||||||
|
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
||||||
|
|
||||||
export enum NavigationDirection {
|
export enum NavigationDirection {
|
||||||
UP = 1,
|
UP = 1,
|
||||||
@ -80,7 +82,7 @@ export abstract class NavigationDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleGamepad(button: GamepadKey): boolean {
|
handleGamepad(button: GamepadKey): boolean {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,6 +156,43 @@ export class NavigationDialogManager {
|
|||||||
|
|
||||||
// Hide dialog when the Guide menu is shown
|
// Hide dialog when the Guide menu is shown
|
||||||
window.addEventListener(BxEvent.XCLOUD_GUIDE_MENU_SHOWN, e => this.hide());
|
window.addEventListener(BxEvent.XCLOUD_GUIDE_MENU_SHOWN, e => this.hide());
|
||||||
|
|
||||||
|
// Calculate minimum width of controller-friendly <select> elements
|
||||||
|
if (getPref(PrefKey.UI_CONTROLLER_FRIENDLY)) {
|
||||||
|
const observer = new MutationObserver(mutationList => {
|
||||||
|
if (mutationList.length === 0 || mutationList[0].addedNodes.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get dialog
|
||||||
|
const $dialog = mutationList[0].addedNodes[0];
|
||||||
|
if (!$dialog || !($dialog instanceof HTMLElement)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find un-calculated <select> elements
|
||||||
|
const $selects = $dialog.querySelectorAll('.bx-select:not([data-calculated]) select');
|
||||||
|
$selects.forEach($select => {
|
||||||
|
const rect = $select.getBoundingClientRect();
|
||||||
|
const $parent = $select.parentElement! as HTMLElement;
|
||||||
|
$parent.dataset.calculated = 'true';
|
||||||
|
|
||||||
|
let $label;
|
||||||
|
let width = Math.ceil(rect.width);
|
||||||
|
|
||||||
|
if (($select as HTMLSelectElement).multiple) {
|
||||||
|
$label = $parent.querySelector('.bx-select-value') as HTMLElement;
|
||||||
|
width += 15; // Add checkbox's width
|
||||||
|
} else {
|
||||||
|
$label = $parent.querySelector('div') as HTMLElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set min-width
|
||||||
|
$label.style.minWidth = width + 'px';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
observer.observe(this.$container, {childList: true});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleEvent(event: Event) {
|
handleEvent(event: Event) {
|
||||||
@ -519,11 +558,8 @@ export class NavigationDialogManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rect = $elm.getBoundingClientRect();
|
|
||||||
const isVisible = !!rect.width && !!rect.height;
|
|
||||||
|
|
||||||
// Ignore hidden element
|
// Ignore hidden element
|
||||||
if (!isVisible) {
|
if (!isElementVisible($elm)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,7 +583,7 @@ export class NavigationDialogManager {
|
|||||||
const children = Array.from($elm.children);
|
const children = Array.from($elm.children);
|
||||||
|
|
||||||
// Search from right to left if the orientation is horizontal
|
// Search from right to left if the orientation is horizontal
|
||||||
const orientation = ($elm as NavigationElement).nearby?.orientation;
|
const orientation = ($elm as NavigationElement).nearby?.orientation || 'vertical';
|
||||||
if (orientation === 'horizontal' || (orientation === 'vertical' && direction === NavigationDirection.UP)) {
|
if (orientation === 'horizontal' || (orientation === 'vertical' && direction === NavigationDirection.UP)) {
|
||||||
children.reverse();
|
children.reverse();
|
||||||
}
|
}
|
||||||
|
135
src/modules/ui/dialog/remote-play-dialog.ts
Normal file
135
src/modules/ui/dialog/remote-play-dialog.ts
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
import { ButtonStyle, CE, createButton } from "@/utils/html";
|
||||||
|
import { NavigationDialog, type NavigationElement } from "./navigation-dialog";
|
||||||
|
import { PrefKey } from "@/enums/pref-keys";
|
||||||
|
import { BxIcon } from "@/utils/bx-icon";
|
||||||
|
import { getPref, setPref } from "@/utils/settings-storages/global-settings-storage";
|
||||||
|
import { t } from "@/utils/translation";
|
||||||
|
import { RemotePlayConsoleState, RemotePlayManager } from "@/modules/remote-play-manager";
|
||||||
|
import { BxSelectElement } from "@/web-components/bx-select";
|
||||||
|
import { BxEvent } from "@/utils/bx-event";
|
||||||
|
|
||||||
|
|
||||||
|
export class RemotePlayNavigationDialog extends NavigationDialog {
|
||||||
|
private static instance: RemotePlayNavigationDialog;
|
||||||
|
public static getInstance(): RemotePlayNavigationDialog {
|
||||||
|
if (!RemotePlayNavigationDialog.instance) {
|
||||||
|
RemotePlayNavigationDialog.instance = new RemotePlayNavigationDialog();
|
||||||
|
}
|
||||||
|
return RemotePlayNavigationDialog.instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly STATE_LABELS: Record<RemotePlayConsoleState, string> = {
|
||||||
|
[RemotePlayConsoleState.ON]: t('powered-on'),
|
||||||
|
[RemotePlayConsoleState.OFF]: t('powered-off'),
|
||||||
|
[RemotePlayConsoleState.STANDBY]: t('standby'),
|
||||||
|
[RemotePlayConsoleState.UNKNOWN]: t('unknown'),
|
||||||
|
};
|
||||||
|
|
||||||
|
$container!: HTMLElement;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.setupDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private setupDialog() {
|
||||||
|
const $fragment = CE('div', {'class': 'bx-remote-play-container'});
|
||||||
|
|
||||||
|
const $settingNote = CE('p', {});
|
||||||
|
|
||||||
|
const currentResolution = getPref(PrefKey.REMOTE_PLAY_RESOLUTION);
|
||||||
|
let $resolutions : HTMLSelectElement | NavigationElement = CE<HTMLSelectElement>('select', {},
|
||||||
|
CE('option', {value: '1080p'}, '1080p'),
|
||||||
|
CE('option', {value: '720p'}, '720p'),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (getPref(PrefKey.UI_CONTROLLER_FRIENDLY)) {
|
||||||
|
$resolutions = BxSelectElement.wrap($resolutions as HTMLSelectElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
$resolutions.addEventListener('input', (e: Event) => {
|
||||||
|
const value = (e.target as HTMLSelectElement).value;
|
||||||
|
|
||||||
|
$settingNote.textContent = value === '1080p' ? '✅ ' + t('can-stream-xbox-360-games') : '❌ ' + t('cant-stream-xbox-360-games');
|
||||||
|
setPref(PrefKey.REMOTE_PLAY_RESOLUTION, value);
|
||||||
|
});
|
||||||
|
|
||||||
|
($resolutions as any).value = currentResolution;
|
||||||
|
BxEvent.dispatch($resolutions, 'input', {
|
||||||
|
manualTrigger: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const $qualitySettings = CE('div', {
|
||||||
|
class: 'bx-remote-play-settings',
|
||||||
|
}, CE('div', {},
|
||||||
|
CE('label', {}, t('target-resolution'), $settingNote),
|
||||||
|
$resolutions,
|
||||||
|
));
|
||||||
|
|
||||||
|
$fragment.appendChild($qualitySettings);
|
||||||
|
|
||||||
|
// Render consoles list
|
||||||
|
const manager = RemotePlayManager.getInstance();
|
||||||
|
const consoles = manager.getConsoles();
|
||||||
|
|
||||||
|
for (let con of consoles) {
|
||||||
|
const $child = CE('div', {class: 'bx-remote-play-device-wrapper'},
|
||||||
|
CE('div', {class: 'bx-remote-play-device-info'},
|
||||||
|
CE('div', {},
|
||||||
|
CE('span', {class: 'bx-remote-play-device-name'}, con.deviceName),
|
||||||
|
CE('span', {class: 'bx-remote-play-console-type'}, con.consoleType.replace('Xbox', ''))
|
||||||
|
),
|
||||||
|
CE('div', {class: 'bx-remote-play-power-state'}, this.STATE_LABELS[con.powerState]),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Connect button
|
||||||
|
createButton({
|
||||||
|
classes: ['bx-remote-play-connect-button'],
|
||||||
|
label: t('console-connect'),
|
||||||
|
style: ButtonStyle.PRIMARY | ButtonStyle.FOCUSABLE,
|
||||||
|
onClick: e => manager.play(con.serverId),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
$fragment.appendChild($child);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add buttons
|
||||||
|
$fragment.appendChild(
|
||||||
|
CE('div', {
|
||||||
|
class: 'bx-remote-play-buttons',
|
||||||
|
_nearby: {
|
||||||
|
orientation: 'horizontal',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
createButton({
|
||||||
|
icon: BxIcon.QUESTION,
|
||||||
|
style: ButtonStyle.GHOST | ButtonStyle.FOCUSABLE,
|
||||||
|
url: 'https://better-xcloud.github.io/remote-play',
|
||||||
|
label: t('help'),
|
||||||
|
}),
|
||||||
|
|
||||||
|
createButton({
|
||||||
|
style: ButtonStyle.GHOST | ButtonStyle.FOCUSABLE,
|
||||||
|
label: t('close'),
|
||||||
|
onClick: e => this.hide(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
this.$container = $fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
getDialog(): NavigationDialog {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
getContent(): HTMLElement {
|
||||||
|
return this.$container;
|
||||||
|
}
|
||||||
|
|
||||||
|
focusIfNeeded(): void {
|
||||||
|
const $btnConnect = this.$container.querySelector('.bx-remote-play-device-wrapper button') as HTMLElement;
|
||||||
|
$btnConnect && $btnConnect.focus();
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
import { onChangeVideoPlayerType, updateVideoPlayer } from "@/modules/stream/stream-settings-utils";
|
import { onChangeVideoPlayerType, updateVideoPlayer } from "@/modules/stream/stream-settings-utils";
|
||||||
import { ButtonStyle, CE, createButton, createSvgIcon } 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";
|
||||||
import { ControllerShortcut } from "@/modules/controller-shortcut";
|
import { ControllerShortcut } from "@/modules/controller-shortcut";
|
||||||
import { MkbRemapper } from "@/modules/mkb/mkb-remapper";
|
import { MkbRemapper } from "@/modules/mkb/mkb-remapper";
|
||||||
@ -17,13 +17,13 @@ import { setNearby } from "@/utils/navigation-utils";
|
|||||||
import { PatcherCache } from "@/modules/patcher";
|
import { PatcherCache } from "@/modules/patcher";
|
||||||
import { UserAgentProfile } from "@/enums/user-agent";
|
import { UserAgentProfile } from "@/enums/user-agent";
|
||||||
import { UserAgent } from "@/utils/user-agent";
|
import { UserAgent } from "@/utils/user-agent";
|
||||||
import { BX_FLAGS } from "@/utils/bx-flags";
|
import { BX_FLAGS, NATIVE_FETCH } from "@/utils/bx-flags";
|
||||||
import { copyToClipboard } from "@/utils/utils";
|
import { copyToClipboard } from "@/utils/utils";
|
||||||
import { GamepadKey } from "@/enums/mkb";
|
import { GamepadKey } from "@/enums/mkb";
|
||||||
import { PrefKey, StorageKey } from "@/enums/pref-keys";
|
import { PrefKey, StorageKey } from "@/enums/pref-keys";
|
||||||
import { getPref, getPrefDefinition, setPref } from "@/utils/settings-storages/global-settings-storage";
|
import { ControllerDeviceVibration, getPref, getPrefDefinition, setPref, StreamTouchController } from "@/utils/settings-storages/global-settings-storage";
|
||||||
import { SettingElement } from "@/utils/setting-element";
|
import { SettingElement, type BxHtmlSettingElement } from "@/utils/setting-element";
|
||||||
import type { SettingDefinition } from "@/types/setting-definition";
|
import type { RecommendedSettings, SettingDefinition, SuggestedSettingCategory as SuggestedSettingProfile } from "@/types/setting-definition";
|
||||||
import { FullscreenText } from "../fullscreen-text";
|
import { FullscreenText } from "../fullscreen-text";
|
||||||
|
|
||||||
|
|
||||||
@ -72,9 +72,19 @@ export class SettingsNavigationDialog extends NavigationDialog {
|
|||||||
private $btnReload!: HTMLElement;
|
private $btnReload!: HTMLElement;
|
||||||
private $btnGlobalReload!: HTMLButtonElement;
|
private $btnGlobalReload!: HTMLButtonElement;
|
||||||
private $noteGlobalReload!: HTMLElement;
|
private $noteGlobalReload!: HTMLElement;
|
||||||
|
private $btnSuggestion!: HTMLButtonElement;
|
||||||
|
|
||||||
private renderFullSettings: boolean;
|
private renderFullSettings: boolean;
|
||||||
|
|
||||||
|
private suggestedSettings: Record<SuggestedSettingProfile, PartialRecord<PrefKey, any>> = {
|
||||||
|
recommended: {},
|
||||||
|
default: {},
|
||||||
|
lowest: {},
|
||||||
|
highest: {},
|
||||||
|
};
|
||||||
|
private suggestedSettingLabels: PartialRecord<PrefKey, string> = {};
|
||||||
|
private settingElements: PartialRecord<PrefKey, HTMLElement> = {};
|
||||||
|
|
||||||
private readonly TAB_GLOBAL_ITEMS: Array<SettingTabContent | false> = [{
|
private readonly TAB_GLOBAL_ITEMS: Array<SettingTabContent | false> = [{
|
||||||
group: 'general',
|
group: 'general',
|
||||||
label: t('better-xcloud'),
|
label: t('better-xcloud'),
|
||||||
@ -87,12 +97,19 @@ export class SettingsNavigationDialog extends NavigationDialog {
|
|||||||
|
|
||||||
// "New version available" button
|
// "New version available" button
|
||||||
if (!SCRIPT_VERSION.includes('beta') && PREF_LATEST_VERSION && PREF_LATEST_VERSION != SCRIPT_VERSION) {
|
if (!SCRIPT_VERSION.includes('beta') && PREF_LATEST_VERSION && PREF_LATEST_VERSION != SCRIPT_VERSION) {
|
||||||
// Show new version indicator
|
// Show new version button
|
||||||
topButtons.push(createButton({
|
const opts = {
|
||||||
label: `🌟 Version ${PREF_LATEST_VERSION} available`,
|
label: '🌟 ' + t('new-version-available', {version: PREF_LATEST_VERSION}),
|
||||||
style: ButtonStyle.PRIMARY | ButtonStyle.FOCUSABLE | ButtonStyle.FULL_WIDTH,
|
style: ButtonStyle.PRIMARY | ButtonStyle.FOCUSABLE | ButtonStyle.FULL_WIDTH,
|
||||||
url: 'https://github.com/redphx/better-xcloud/releases/latest',
|
} as BxButton;
|
||||||
}));
|
|
||||||
|
if (AppInterface && AppInterface.updateLatestScript) {
|
||||||
|
opts.onClick = e => AppInterface.updateLatestScript();
|
||||||
|
} else {
|
||||||
|
opts.url = 'https://github.com/redphx/better-xcloud/releases/latest';
|
||||||
|
}
|
||||||
|
|
||||||
|
topButtons.push(createButton(opts));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Buttons for Android app
|
// Buttons for Android app
|
||||||
@ -135,6 +152,17 @@ export class SettingsNavigationDialog extends NavigationDialog {
|
|||||||
}, t('settings-reload-note'));
|
}, t('settings-reload-note'));
|
||||||
topButtons.push(this.$noteGlobalReload);
|
topButtons.push(this.$noteGlobalReload);
|
||||||
|
|
||||||
|
// Suggestion
|
||||||
|
this.$btnSuggestion = CE('div', {
|
||||||
|
class: 'bx-suggest-toggler bx-focusable',
|
||||||
|
tabindex: 0,
|
||||||
|
}, CE('label', {}, t('suggest-settings')),
|
||||||
|
CE('span', {}, '❯'),
|
||||||
|
);
|
||||||
|
this.$btnSuggestion.addEventListener('click', this.renderSuggestions.bind(this));
|
||||||
|
|
||||||
|
topButtons.push(this.$btnSuggestion);
|
||||||
|
|
||||||
// Add buttons to parent
|
// Add buttons to parent
|
||||||
const $div = CE('div', {
|
const $div = CE('div', {
|
||||||
class: 'bx-top-buttons',
|
class: 'bx-top-buttons',
|
||||||
@ -306,7 +334,10 @@ export class SettingsNavigationDialog extends NavigationDialog {
|
|||||||
label: 'Debug info',
|
label: 'Debug info',
|
||||||
style: ButtonStyle.GHOST | ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE,
|
style: ButtonStyle.GHOST | ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE,
|
||||||
onClick: e => {
|
onClick: e => {
|
||||||
(e.target as HTMLElement).closest('button')?.nextElementSibling?.classList.toggle('bx-gone');
|
const $pre = (e.target as HTMLElement).closest('button')?.nextElementSibling!;
|
||||||
|
|
||||||
|
$pre.classList.toggle('bx-gone');
|
||||||
|
$pre.scrollIntoView();
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
CE('pre', {
|
CE('pre', {
|
||||||
@ -617,6 +648,291 @@ export class SettingsNavigationDialog extends NavigationDialog {
|
|||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async getRecommendedSettings(deviceCode: string): Promise<string | null> {
|
||||||
|
// Get recommended settings from GitHub
|
||||||
|
try {
|
||||||
|
const response = await NATIVE_FETCH(`https://raw.githubusercontent.com/redphx/better-xcloud/gh-pages/devices/${deviceCode.toLowerCase()}.json`);
|
||||||
|
const json = (await response.json()) as RecommendedSettings;
|
||||||
|
const recommended: PartialRecord<PrefKey, any> = {};
|
||||||
|
|
||||||
|
// Only supports schema version 1
|
||||||
|
if (json.schema_version !== 1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const scriptSettings = json.settings.script;
|
||||||
|
|
||||||
|
// Set base settings
|
||||||
|
if (scriptSettings._base) {
|
||||||
|
let base = typeof scriptSettings._base === 'string' ? [scriptSettings._base] : scriptSettings._base;
|
||||||
|
for (const profile of base) {
|
||||||
|
Object.assign(recommended, this.suggestedSettings[profile]);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete scriptSettings._base;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override settings
|
||||||
|
let key: Exclude<keyof typeof scriptSettings, '_base'>;
|
||||||
|
// @ts-ignore
|
||||||
|
for (key in scriptSettings) {
|
||||||
|
recommended[key] = scriptSettings[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update device type in BxFlags
|
||||||
|
BX_FLAGS.DeviceInfo.deviceType = json.device_type;
|
||||||
|
|
||||||
|
this.suggestedSettings.recommended = recommended;
|
||||||
|
|
||||||
|
return json.device_name;
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private addDefaultSuggestedSetting(prefKey: PrefKey, value: any) {
|
||||||
|
let key: keyof typeof this.suggestedSettings;
|
||||||
|
for (key in this.suggestedSettings) {
|
||||||
|
if (key !== 'default' && !(prefKey in this.suggestedSettings)) {
|
||||||
|
this.suggestedSettings[key][prefKey] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private generateDefaultSuggestedSettings() {
|
||||||
|
let key: keyof typeof this.suggestedSettings;
|
||||||
|
for (key in this.suggestedSettings) {
|
||||||
|
if (key === 'default') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let prefKey: PrefKey;
|
||||||
|
for (prefKey in this.suggestedSettings[key]) {
|
||||||
|
if (!(prefKey in this.suggestedSettings.default)) {
|
||||||
|
this.suggestedSettings.default[prefKey] = getPrefDefinition(prefKey).default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async renderSuggestions(e: Event) {
|
||||||
|
const $btnSuggest = (e.target as HTMLElement).closest('div')!;
|
||||||
|
$btnSuggest.toggleAttribute('bx-open');
|
||||||
|
|
||||||
|
let $content = $btnSuggest.nextElementSibling as HTMLElement;
|
||||||
|
if ($content) {
|
||||||
|
BxEvent.dispatch($content.querySelector('select'), 'input');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get labels
|
||||||
|
for (const settingTab of this.SETTINGS_UI) {
|
||||||
|
if (!settingTab || !settingTab.items) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const settingTabContent of settingTab.items) {
|
||||||
|
if (!settingTabContent || !settingTabContent.items) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const setting of settingTabContent.items) {
|
||||||
|
let prefKey: PrefKey | undefined;
|
||||||
|
|
||||||
|
if (typeof setting === 'string') {
|
||||||
|
prefKey = setting;
|
||||||
|
} else if (typeof setting === 'object') {
|
||||||
|
prefKey = setting.pref as PrefKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prefKey) {
|
||||||
|
this.suggestedSettingLabels[prefKey] = settingTabContent.label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get recommended settings for Android devices
|
||||||
|
let recommendedDevice: string | null = '';
|
||||||
|
|
||||||
|
if (BX_FLAGS.DeviceInfo.deviceType.includes('android')) {
|
||||||
|
if (BX_FLAGS.DeviceInfo.androidInfo) {
|
||||||
|
const deviceCode = BX_FLAGS.DeviceInfo.androidInfo.board;
|
||||||
|
recommendedDevice = await this.getRecommendedSettings(deviceCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// recommendedDevice = await this.getRecommendedSettings('foster_e');
|
||||||
|
|
||||||
|
const hasRecommendedSettings = Object.keys(this.suggestedSettings.recommended).length > 0;
|
||||||
|
|
||||||
|
// Add some specific setings based on device type
|
||||||
|
const deviceType = BX_FLAGS.DeviceInfo.deviceType;
|
||||||
|
if (deviceType === 'android-handheld') {
|
||||||
|
// Disable touch
|
||||||
|
this.addDefaultSuggestedSetting(PrefKey.STREAM_TOUCH_CONTROLLER, StreamTouchController.OFF);
|
||||||
|
// Enable device vibration
|
||||||
|
this.addDefaultSuggestedSetting(PrefKey.CONTROLLER_DEVICE_VIBRATION, ControllerDeviceVibration.ON);
|
||||||
|
} else if (deviceType === 'android') {
|
||||||
|
// Enable device vibration
|
||||||
|
this.addDefaultSuggestedSetting(PrefKey.CONTROLLER_DEVICE_VIBRATION, ControllerDeviceVibration.AUTO);
|
||||||
|
} else if (deviceType === 'android-tv') {
|
||||||
|
// Disable touch
|
||||||
|
this.addDefaultSuggestedSetting(PrefKey.STREAM_TOUCH_CONTROLLER, StreamTouchController.OFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set value for Default profile
|
||||||
|
this.generateDefaultSuggestedSettings();
|
||||||
|
|
||||||
|
// Start rendering
|
||||||
|
const $suggestedSettings = CE('div', {class: 'bx-suggest-wrapper'});
|
||||||
|
const $select = CE<HTMLSelectElement>('select', {},
|
||||||
|
hasRecommendedSettings && CE('option', {value: 'recommended'}, t('recommended')),
|
||||||
|
!hasRecommendedSettings && CE('option', {value: 'highest'}, t('highest-quality')),
|
||||||
|
CE('option', {value: 'default'}, t('default')),
|
||||||
|
CE('option', {value: 'lowest'}, t('lowest-quality')),
|
||||||
|
);
|
||||||
|
$select.addEventListener('input', e => {
|
||||||
|
const profile = $select.value as SuggestedSettingProfile;
|
||||||
|
|
||||||
|
// Empty children
|
||||||
|
removeChildElements($suggestedSettings);
|
||||||
|
const fragment = document.createDocumentFragment();
|
||||||
|
|
||||||
|
let note: HTMLElement | string | undefined;
|
||||||
|
if (profile === 'recommended') {
|
||||||
|
note = t('recommended-settings-for-device', {device: recommendedDevice});
|
||||||
|
} else if (profile === 'highest') {
|
||||||
|
// Add note for "Highest quality" profile
|
||||||
|
note = '⚠️ ' + t('highest-quality-note');
|
||||||
|
}
|
||||||
|
|
||||||
|
note && fragment.appendChild(CE('div', {class: 'bx-suggest-note'}, note));
|
||||||
|
|
||||||
|
const settings = this.suggestedSettings[profile];
|
||||||
|
let prefKey: PrefKey;
|
||||||
|
for (prefKey in settings) {
|
||||||
|
const currentValue = getPref(prefKey, false);
|
||||||
|
const suggestedValue = settings[prefKey];
|
||||||
|
const currentValueText = STORAGE.Global.getValueText(prefKey, currentValue);
|
||||||
|
const isSameValue = currentValue === suggestedValue;
|
||||||
|
|
||||||
|
let $child: HTMLElement;
|
||||||
|
let $value: HTMLElement | string;
|
||||||
|
if (isSameValue) {
|
||||||
|
// No changes
|
||||||
|
$value = currentValueText;
|
||||||
|
} else {
|
||||||
|
const suggestedValueText = STORAGE.Global.getValueText(prefKey, suggestedValue);
|
||||||
|
$value = currentValueText + ' ➔ ' + suggestedValueText;
|
||||||
|
}
|
||||||
|
|
||||||
|
let $checkbox: HTMLInputElement;
|
||||||
|
const breadcrumb = this.suggestedSettingLabels[prefKey] + ' ❯ ' + STORAGE.Global.getLabel(prefKey);
|
||||||
|
|
||||||
|
$child = CE('div', {
|
||||||
|
class: `bx-suggest-row ${isSameValue ? 'bx-suggest-ok' : 'bx-suggest-change'}`,
|
||||||
|
},
|
||||||
|
$checkbox = CE('input', {
|
||||||
|
type: 'checkbox',
|
||||||
|
tabindex: 0,
|
||||||
|
checked: true,
|
||||||
|
id: `bx_suggest_${prefKey}`,
|
||||||
|
}),
|
||||||
|
CE('label', {
|
||||||
|
for: `bx_suggest_${prefKey}`,
|
||||||
|
},
|
||||||
|
CE('div', {
|
||||||
|
class: 'bx-suggest-label',
|
||||||
|
}, breadcrumb),
|
||||||
|
CE('div', {
|
||||||
|
class: 'bx-suggest-value',
|
||||||
|
}, $value),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isSameValue) {
|
||||||
|
$checkbox.disabled = true;
|
||||||
|
$checkbox.checked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment.appendChild($child);
|
||||||
|
}
|
||||||
|
|
||||||
|
$suggestedSettings.appendChild(fragment);
|
||||||
|
});
|
||||||
|
|
||||||
|
BxEvent.dispatch($select, 'input');
|
||||||
|
|
||||||
|
const onClickApply = () => {
|
||||||
|
const profile = $select.value as SuggestedSettingProfile;
|
||||||
|
const settings = this.suggestedSettings[profile];
|
||||||
|
|
||||||
|
let prefKey: PrefKey;
|
||||||
|
for (prefKey in settings) {
|
||||||
|
const suggestedValue = settings[prefKey];
|
||||||
|
const $checkBox = $content.querySelector(`#bx_suggest_${prefKey}`) as HTMLInputElement;
|
||||||
|
if (!$checkBox.checked || $checkBox.disabled) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const $control = this.settingElements[prefKey] as HTMLElement;
|
||||||
|
|
||||||
|
// Set value directly if the control element is not available
|
||||||
|
if (!$control) {
|
||||||
|
setPref(prefKey, suggestedValue);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('setValue' in $control) {
|
||||||
|
($control as BxHtmlSettingElement).setValue(suggestedValue);
|
||||||
|
} else {
|
||||||
|
($control as HTMLInputElement).value = suggestedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
BxEvent.dispatch($control, 'input', {
|
||||||
|
manualTrigger: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh suggested settings
|
||||||
|
BxEvent.dispatch($select, 'input');
|
||||||
|
};
|
||||||
|
|
||||||
|
// Apply button
|
||||||
|
const $btnApply = createButton({
|
||||||
|
label: t('apply'),
|
||||||
|
style: ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE,
|
||||||
|
onClick: onClickApply,
|
||||||
|
});
|
||||||
|
|
||||||
|
$content = CE('div', {
|
||||||
|
class: 'bx-suggest-box',
|
||||||
|
_nearby: {
|
||||||
|
orientation: 'vertical',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
BxSelectElement.wrap($select),
|
||||||
|
$suggestedSettings,
|
||||||
|
$btnApply,
|
||||||
|
|
||||||
|
BX_FLAGS.DeviceInfo.deviceType.includes('android') && CE('a', {
|
||||||
|
class: 'bx-suggest-link bx-focusable',
|
||||||
|
href: 'https://better-xcloud.github.io/guide/android-webview-tweaks/',
|
||||||
|
target: '_blank',
|
||||||
|
tabindex: 0,
|
||||||
|
}, '🤓 ' + t('how-to-improve-app-performance')),
|
||||||
|
|
||||||
|
BX_FLAGS.DeviceInfo.deviceType.includes('android') && !hasRecommendedSettings && CE('a', {
|
||||||
|
class: 'bx-suggest-link bx-focusable',
|
||||||
|
href: 'https://github.com/redphx/better-xcloud-devices',
|
||||||
|
target: '_blank',
|
||||||
|
tabindex: 0,
|
||||||
|
}, t('suggest-settings-link')),
|
||||||
|
);
|
||||||
|
|
||||||
|
$btnSuggest?.insertAdjacentElement('afterend', $content);
|
||||||
|
}
|
||||||
|
|
||||||
private renderTab(settingTab: SettingTab) {
|
private renderTab(settingTab: SettingTab) {
|
||||||
const $svg = createSvgIcon(settingTab.icon as any);
|
const $svg = createSvgIcon(settingTab.icon as any);
|
||||||
$svg.dataset.group = settingTab.group;
|
$svg.dataset.group = settingTab.group;
|
||||||
@ -771,6 +1087,8 @@ export class SettingsNavigationDialog extends NavigationDialog {
|
|||||||
if ($control instanceof HTMLSelectElement && getPref(PrefKey.UI_CONTROLLER_FRIENDLY)) {
|
if ($control instanceof HTMLSelectElement && getPref(PrefKey.UI_CONTROLLER_FRIENDLY)) {
|
||||||
$control = BxSelectElement.wrap($control);
|
$control = BxSelectElement.wrap($control);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pref && (this.settingElements[pref] = $control);
|
||||||
}
|
}
|
||||||
|
|
||||||
let prefDefinition: SettingDefinition | null = null;
|
let prefDefinition: SettingDefinition | null = null;
|
||||||
@ -782,6 +1100,13 @@ export class SettingsNavigationDialog extends NavigationDialog {
|
|||||||
let note = prefDefinition?.note || setting.note;
|
let note = prefDefinition?.note || setting.note;
|
||||||
const experimental = prefDefinition?.experimental || setting.experimental;
|
const experimental = prefDefinition?.experimental || setting.experimental;
|
||||||
|
|
||||||
|
if (settingTabContent.label && setting.pref) {
|
||||||
|
if (prefDefinition?.suggest) {
|
||||||
|
typeof prefDefinition.suggest.lowest !== 'undefined' && (this.suggestedSettings.lowest[setting.pref] = prefDefinition.suggest.lowest);
|
||||||
|
typeof prefDefinition.suggest.highest !== 'undefined' && (this.suggestedSettings.highest[setting.pref] = prefDefinition.suggest.highest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add Experimental text
|
// Add Experimental text
|
||||||
if (experimental) {
|
if (experimental) {
|
||||||
label = '🧪 ' + label;
|
label = '🧪 ' + label;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
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 { CE, createSvgIcon, getReactProps } from "@/utils/html";
|
import { CE, createSvgIcon, getReactProps, isElementVisible } from "@/utils/html";
|
||||||
import { XcloudApi } from "@/utils/xcloud-api";
|
import { XcloudApi } from "@/utils/xcloud-api";
|
||||||
|
|
||||||
export class GameTile {
|
export class GameTile {
|
||||||
@ -23,6 +23,11 @@ export class GameTile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async #showWaitTime($elm: HTMLElement, productId: string) {
|
static async #showWaitTime($elm: HTMLElement, productId: string) {
|
||||||
|
if (($elm as any).hasWaitTime) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
($elm as any).hasWaitTime = true;
|
||||||
|
|
||||||
let totalWaitTime;
|
let totalWaitTime;
|
||||||
|
|
||||||
const api = XcloudApi.getInstance();
|
const api = XcloudApi.getInstance();
|
||||||
@ -34,7 +39,7 @@ export class GameTile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof totalWaitTime === 'number' && $elm.isConnected) {
|
if (typeof totalWaitTime === 'number' && isElementVisible($elm)) {
|
||||||
const $div = CE('div', {'class': 'bx-game-tile-wait-time'},
|
const $div = CE('div', {'class': 'bx-game-tile-wait-time'},
|
||||||
createSvgIcon(BxIcon.PLAYTIME),
|
createSvgIcon(BxIcon.PLAYTIME),
|
||||||
CE('span', {}, GameTile.#secondsToHms(totalWaitTime)),
|
CE('span', {}, GameTile.#secondsToHms(totalWaitTime)),
|
||||||
@ -43,45 +48,61 @@ export class GameTile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static requestWaitTime($elm: HTMLElement, productId: string) {
|
static #requestWaitTime($elm: HTMLElement, productId: string) {
|
||||||
GameTile.#timeout && clearTimeout(GameTile.#timeout);
|
GameTile.#timeout && clearTimeout(GameTile.#timeout);
|
||||||
GameTile.#timeout = window.setTimeout(async () => {
|
GameTile.#timeout = window.setTimeout(async () => {
|
||||||
if (!($elm as any).hasWaitTime) {
|
GameTile.#showWaitTime($elm, productId);
|
||||||
($elm as any).hasWaitTime = true;
|
}, 500);
|
||||||
GameTile.#showWaitTime($elm, productId);
|
}
|
||||||
|
|
||||||
|
static #findProductId($elm: HTMLElement): string | null {
|
||||||
|
let productId = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (($elm.tagName === 'BUTTON' && $elm.className.includes('MruGameCard')) || (($elm.tagName === 'A' && $elm.className.includes('GameCard')))) {
|
||||||
|
let props = getReactProps($elm.parentElement!);
|
||||||
|
|
||||||
|
// When context menu is enabled
|
||||||
|
if (Array.isArray(props.children)) {
|
||||||
|
productId = props.children[0].props.productId;
|
||||||
|
} else {
|
||||||
|
productId = props.children.props.productId;
|
||||||
|
}
|
||||||
|
} else if ($elm.tagName === 'A' && $elm.className.includes('GameItem')) {
|
||||||
|
let props = getReactProps($elm.parentElement!);
|
||||||
|
props = props.children.props;
|
||||||
|
if (props.location !== 'NonStreamableGameItem') {
|
||||||
|
if ('productId' in props) {
|
||||||
|
productId = props.productId;
|
||||||
|
} else {
|
||||||
|
// Search page
|
||||||
|
productId = props.children.props.productId;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, 1000);
|
} catch (e) {}
|
||||||
|
|
||||||
|
return productId;
|
||||||
}
|
}
|
||||||
|
|
||||||
static setup() {
|
static setup() {
|
||||||
window.addEventListener(BxEvent.NAVIGATION_FOCUS_CHANGED, e => {
|
window.addEventListener(BxEvent.NAVIGATION_FOCUS_CHANGED, e => {
|
||||||
let productId;
|
|
||||||
const $elm = (e as any).element;
|
const $elm = (e as any).element;
|
||||||
try {
|
const className = $elm.className || '';
|
||||||
if (($elm.tagName === 'BUTTON' && $elm.className.includes('MruGameCard')) || (($elm.tagName === 'A' && $elm.className.includes('GameCard')))) {
|
if (className.includes('MruGameCard')) {
|
||||||
let props = getReactProps($elm.parentElement);
|
// Show the wait time of every games in the "Jump back in" section all at once
|
||||||
|
const $ol = $elm.closest('ol');
|
||||||
// When context menu is enabled
|
if ($ol && !($ol as any).hasWaitTime) {
|
||||||
if (Array.isArray(props.children)) {
|
($ol as any).hasWaitTime = true;
|
||||||
productId = props.children[0].props.productId;
|
$ol.querySelectorAll('button[class*=MruGameCard]').forEach(($elm: HTMLElement) => {
|
||||||
} else {
|
const productId = GameTile.#findProductId($elm);
|
||||||
productId = props.children.props.productId;
|
productId && GameTile.#showWaitTime($elm, productId);
|
||||||
}
|
});
|
||||||
} else if ($elm.tagName === 'A' && $elm.className.includes('GameItem')) {
|
|
||||||
let props = getReactProps($elm.parentElement);
|
|
||||||
props = props.children.props;
|
|
||||||
if (props.location !== 'NonStreamableGameItem') {
|
|
||||||
if ('productId' in props) {
|
|
||||||
productId = props.productId;
|
|
||||||
} else {
|
|
||||||
// Search page
|
|
||||||
productId = props.children.props.productId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} else {
|
||||||
|
const productId = GameTile.#findProductId($elm);
|
||||||
productId && GameTile.requestWaitTime($elm, productId);
|
productId && GameTile.#requestWaitTime($elm, productId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ import { AppInterface, STATES } from "@/utils/global";
|
|||||||
import { createButton, ButtonStyle, CE } from "@/utils/html";
|
import { createButton, ButtonStyle, CE } from "@/utils/html";
|
||||||
import { t } from "@/utils/translation";
|
import { t } from "@/utils/translation";
|
||||||
import { SettingsNavigationDialog } from "./dialog/settings-dialog";
|
import { SettingsNavigationDialog } from "./dialog/settings-dialog";
|
||||||
|
import { TrueAchievements } from "@/utils/true-achievements";
|
||||||
|
import { BxIcon } from "@/utils/bx-icon";
|
||||||
|
|
||||||
export enum GuideMenuTab {
|
export enum GuideMenuTab {
|
||||||
HOME = 'home',
|
HOME = 'home',
|
||||||
@ -24,27 +26,24 @@ export class GuideMenu {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
appSettings: createButton({
|
closeApp: AppInterface && createButton({
|
||||||
label: t('app-settings'),
|
icon: BxIcon.POWER,
|
||||||
style: ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE,
|
|
||||||
onClick: e => {
|
|
||||||
// Close all xCloud's dialogs
|
|
||||||
window.BX_EXPOSED.dialogRoutes.closeAll();
|
|
||||||
|
|
||||||
AppInterface.openAppSettings && AppInterface.openAppSettings();
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
|
|
||||||
closeApp: createButton({
|
|
||||||
label: t('close-app'),
|
label: t('close-app'),
|
||||||
|
title: t('close-app'),
|
||||||
style: ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE | ButtonStyle.DANGER,
|
style: ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE | ButtonStyle.DANGER,
|
||||||
onClick: e => {
|
onClick: e => {
|
||||||
AppInterface.closeApp();
|
AppInterface.closeApp();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
attributes: {
|
||||||
|
'data-state': 'normal',
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
reloadPage: createButton({
|
reloadPage: createButton({
|
||||||
|
icon: BxIcon.REFRESH,
|
||||||
label: t('reload-page'),
|
label: t('reload-page'),
|
||||||
|
title: t('reload-page'),
|
||||||
style: ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE,
|
style: ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE,
|
||||||
onClick: e => {
|
onClick: e => {
|
||||||
if (STATES.isPlaying) {
|
if (STATES.isPlaying) {
|
||||||
@ -59,74 +58,92 @@ export class GuideMenu {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
backToHome: createButton({
|
backToHome: createButton({
|
||||||
|
icon: BxIcon.HOME,
|
||||||
label: t('back-to-home'),
|
label: t('back-to-home'),
|
||||||
|
title: t('back-to-home'),
|
||||||
style: ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE,
|
style: ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE,
|
||||||
onClick: e => {
|
onClick: e => {
|
||||||
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
|
||||||
|
window.BX_EXPOSED.dialogRoutes.closeAll();
|
||||||
|
},
|
||||||
|
attributes: {
|
||||||
|
'data-state': 'playing',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
static #renderButtons(buttons: HTMLElement[]) {
|
static #$renderedButtons: HTMLElement;
|
||||||
const $div = CE('div', {});
|
|
||||||
|
|
||||||
for (const $button of buttons) {
|
static #renderButtons() {
|
||||||
$div.appendChild($button);
|
if (GuideMenu.#$renderedButtons) {
|
||||||
|
return GuideMenu.#$renderedButtons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const $div = CE('div', {
|
||||||
|
class: 'bx-guide-home-buttons',
|
||||||
|
});
|
||||||
|
|
||||||
|
const buttons = [
|
||||||
|
GuideMenu.#BUTTONS.scriptSettings,
|
||||||
|
[
|
||||||
|
GuideMenu.#BUTTONS.backToHome,
|
||||||
|
GuideMenu.#BUTTONS.reloadPage,
|
||||||
|
GuideMenu.#BUTTONS.closeApp,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const $button of buttons) {
|
||||||
|
if (!$button) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($button instanceof HTMLElement) {
|
||||||
|
$div.appendChild($button);
|
||||||
|
} else if (Array.isArray($button)) {
|
||||||
|
const $wrapper = CE('div', {});
|
||||||
|
for (const $child of $button) {
|
||||||
|
$child && $wrapper.appendChild($child);
|
||||||
|
}
|
||||||
|
$div.appendChild($wrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GuideMenu.#$renderedButtons = $div;
|
||||||
return $div;
|
return $div;
|
||||||
}
|
}
|
||||||
|
|
||||||
static #injectHome($root: HTMLElement) {
|
static #injectHome($root: HTMLElement, isPlaying = false) {
|
||||||
// Find the last divider
|
const $achievementsProgress = $root.querySelector('button[class*=AchievementsButton-module__progressBarContainer]');
|
||||||
const $dividers = $root.querySelectorAll('div[class*=Divider-module__divider]');
|
if ($achievementsProgress) {
|
||||||
if (!$dividers) {
|
TrueAchievements.injectAchievementsProgress($achievementsProgress as HTMLElement);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const buttons: HTMLElement[] = [];
|
// Find the element to add buttons to
|
||||||
|
let $target: HTMLElement | null = null;
|
||||||
|
if (isPlaying) {
|
||||||
|
// Quit button
|
||||||
|
$target = $root.querySelector('a[class*=QuitGameButton]');
|
||||||
|
|
||||||
// "Better xCloud" button
|
// Hide xCloud's Home button
|
||||||
buttons.push(GuideMenu.#BUTTONS.scriptSettings);
|
const $btnXcloudHome = $root.querySelector('div[class^=HomeButtonWithDivider]') as HTMLElement;
|
||||||
|
$btnXcloudHome && ($btnXcloudHome.style.display = 'none');
|
||||||
// "App settings" button
|
} else {
|
||||||
AppInterface && buttons.push(GuideMenu.#BUTTONS.appSettings);
|
// Last divider
|
||||||
|
const $dividers = $root.querySelectorAll('div[class*=Divider-module__divider]');
|
||||||
// "Reload page" button
|
if ($dividers) {
|
||||||
buttons.push(GuideMenu.#BUTTONS.reloadPage);
|
$target = $dividers[$dividers.length - 1] as HTMLElement;
|
||||||
|
}
|
||||||
// "Close app" buttons
|
|
||||||
AppInterface && buttons.push(GuideMenu.#BUTTONS.closeApp);
|
|
||||||
|
|
||||||
const $buttons = GuideMenu.#renderButtons(buttons);
|
|
||||||
|
|
||||||
const $lastDivider = $dividers[$dividers.length - 1];
|
|
||||||
$lastDivider.insertAdjacentElement('afterend', $buttons);
|
|
||||||
}
|
|
||||||
|
|
||||||
static #injectHomePlaying($root: HTMLElement) {
|
|
||||||
const $btnQuit = $root.querySelector('a[class*=QuitGameButton]');
|
|
||||||
if (!$btnQuit) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const buttons: HTMLElement[] = [];
|
if (!$target) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
buttons.push(GuideMenu.#BUTTONS.scriptSettings);
|
const $buttons = GuideMenu.#renderButtons();
|
||||||
AppInterface && buttons.push(GuideMenu.#BUTTONS.appSettings);
|
$buttons.dataset.isPlaying = isPlaying.toString();
|
||||||
|
$target.insertAdjacentElement('afterend', $buttons);
|
||||||
// Reload page
|
|
||||||
buttons.push(GuideMenu.#BUTTONS.reloadPage);
|
|
||||||
|
|
||||||
// Back to home
|
|
||||||
buttons.push(GuideMenu.#BUTTONS.backToHome);
|
|
||||||
|
|
||||||
const $buttons = GuideMenu.#renderButtons(buttons);
|
|
||||||
$btnQuit.insertAdjacentElement('afterend', $buttons);
|
|
||||||
|
|
||||||
// Hide xCloud's Home button
|
|
||||||
const $btnXcloudHome = $root.querySelector('div[class^=HomeButtonWithDivider]') as HTMLElement;
|
|
||||||
$btnXcloudHome && ($btnXcloudHome.style.display = 'none');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async #onShown(e: Event) {
|
static async #onShown(e: Event) {
|
||||||
@ -134,17 +151,45 @@ export class GuideMenu {
|
|||||||
|
|
||||||
if (where === GuideMenuTab.HOME) {
|
if (where === GuideMenuTab.HOME) {
|
||||||
const $root = document.querySelector('#gamepass-dialog-root div[role=dialog] div[role=tabpanel] div[class*=HomeLandingPage]') as HTMLElement;
|
const $root = document.querySelector('#gamepass-dialog-root div[role=dialog] div[role=tabpanel] div[class*=HomeLandingPage]') as HTMLElement;
|
||||||
if ($root) {
|
$root && GuideMenu.#injectHome($root, STATES.isPlaying);
|
||||||
if (STATES.isPlaying) {
|
|
||||||
GuideMenu.#injectHomePlaying($root);
|
|
||||||
} else {
|
|
||||||
GuideMenu.#injectHome($root);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static observe() {
|
static addEventListeners() {
|
||||||
window.addEventListener(BxEvent.XCLOUD_GUIDE_MENU_SHOWN, GuideMenu.#onShown);
|
window.addEventListener(BxEvent.XCLOUD_GUIDE_MENU_SHOWN, GuideMenu.#onShown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static observe($addedElm: HTMLElement) {
|
||||||
|
const className = $addedElm.className;
|
||||||
|
|
||||||
|
if (className.includes('AchievementsButton-module__progressBarContainer')) {
|
||||||
|
TrueAchievements.injectAchievementsProgress($addedElm);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!className.startsWith('NavigationAnimation') &&
|
||||||
|
!className.startsWith('DialogRoutes') &&
|
||||||
|
!className.startsWith('Dialog-module__container')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Achievement Details page
|
||||||
|
const $achievDetailPage = $addedElm.querySelector('div[class*=AchievementDetailPage]');
|
||||||
|
if ($achievDetailPage) {
|
||||||
|
TrueAchievements.injectAchievementDetailPage($achievDetailPage as HTMLElement);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find navigation bar
|
||||||
|
const $selectedTab = $addedElm.querySelector('div[class^=NavigationMenu] button[aria-selected=true');
|
||||||
|
if ($selectedTab) {
|
||||||
|
let $elm: Element | null = $selectedTab;
|
||||||
|
let index;
|
||||||
|
for (index = 0; ($elm = $elm?.previousElementSibling); index++);
|
||||||
|
|
||||||
|
if (index === 0) {
|
||||||
|
BxEvent.dispatch(window, BxEvent.XCLOUD_GUIDE_MENU_SHOWN, {where: GuideMenuTab.HOME});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { SCRIPT_VERSION } from "@utils/global";
|
import { SCRIPT_VERSION } from "@utils/global";
|
||||||
import { createButton, ButtonStyle, CE } from "@utils/html";
|
import { createButton, ButtonStyle, CE, isElementVisible } from "@utils/html";
|
||||||
import { BxIcon } from "@utils/bx-icon";
|
import { BxIcon } from "@utils/bx-icon";
|
||||||
import { getPreferredServerRegion } from "@utils/region";
|
import { getPreferredServerRegion } from "@utils/region";
|
||||||
import { RemotePlay } from "@modules/remote-play";
|
import { RemotePlayManager } from "@/modules/remote-play-manager";
|
||||||
import { t } from "@utils/translation";
|
import { t } from "@utils/translation";
|
||||||
import { SettingsNavigationDialog } from "./dialog/settings-dialog";
|
import { SettingsNavigationDialog } from "./dialog/settings-dialog";
|
||||||
import { PrefKey } from "@/enums/pref-keys";
|
import { PrefKey } from "@/enums/pref-keys";
|
||||||
@ -15,7 +15,7 @@ export class HeaderSection {
|
|||||||
title: t('remote-play'),
|
title: t('remote-play'),
|
||||||
style: ButtonStyle.GHOST | ButtonStyle.FOCUSABLE | ButtonStyle.CIRCULAR,
|
style: ButtonStyle.GHOST | ButtonStyle.FOCUSABLE | ButtonStyle.CIRCULAR,
|
||||||
onClick: e => {
|
onClick: e => {
|
||||||
RemotePlay.togglePopup();
|
RemotePlayManager.getInstance().togglePopup();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -44,12 +44,16 @@ export class HeaderSection {
|
|||||||
const PREF_LATEST_VERSION = getPref(PrefKey.LATEST_VERSION);
|
const PREF_LATEST_VERSION = getPref(PrefKey.LATEST_VERSION);
|
||||||
|
|
||||||
// Setup Settings button
|
// Setup Settings button
|
||||||
const $settingsBtn = HeaderSection.#$settingsBtn;
|
const $btnSettings = HeaderSection.#$settingsBtn;
|
||||||
$settingsBtn.querySelector('span')!.textContent = getPreferredServerRegion(true) || t('better-xcloud');
|
if (isElementVisible(HeaderSection.#$buttonsWrapper)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$btnSettings.querySelector('span')!.textContent = getPreferredServerRegion(true) || t('better-xcloud');
|
||||||
|
|
||||||
// Show new update status
|
// Show new update status
|
||||||
if (!SCRIPT_VERSION.includes('beta') && PREF_LATEST_VERSION && PREF_LATEST_VERSION !== SCRIPT_VERSION) {
|
if (!SCRIPT_VERSION.includes('beta') && PREF_LATEST_VERSION && PREF_LATEST_VERSION !== SCRIPT_VERSION) {
|
||||||
$settingsBtn.setAttribute('data-update-available', 'true');
|
$btnSettings.setAttribute('data-update-available', 'true');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the Settings button to the web page
|
// Add the Settings button to the web page
|
||||||
@ -75,6 +79,9 @@ export class HeaderSection {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HeaderSection.#timeout && clearTimeout(HeaderSection.#timeout);
|
||||||
|
HeaderSection.#timeout = null;
|
||||||
|
|
||||||
HeaderSection.#observer && HeaderSection.#observer.disconnect();
|
HeaderSection.#observer && HeaderSection.#observer.disconnect();
|
||||||
HeaderSection.#observer = new MutationObserver(mutationList => {
|
HeaderSection.#observer = new MutationObserver(mutationList => {
|
||||||
HeaderSection.#timeout && clearTimeout(HeaderSection.#timeout);
|
HeaderSection.#timeout && clearTimeout(HeaderSection.#timeout);
|
||||||
|
@ -5,30 +5,60 @@ import { ButtonStyle, createButton } from "@/utils/html";
|
|||||||
import { t } from "@/utils/translation";
|
import { t } from "@/utils/translation";
|
||||||
|
|
||||||
export class ProductDetailsPage {
|
export class ProductDetailsPage {
|
||||||
private static $btnShortcut = createButton({
|
private static $btnShortcut = AppInterface && createButton({
|
||||||
classes: ['bx-button-shortcut'],
|
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,
|
||||||
tabIndex: 0,
|
tabIndex: 0,
|
||||||
onClick: e => {
|
onClick: e => {
|
||||||
AppInterface && AppInterface.createShortcut(window.location.pathname.substring(6));
|
AppInterface.createShortcut(window.location.pathname.substring(6));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
private static shortcutTimeoutId: number | null = null;
|
private static $btnWallpaper = AppInterface && createButton({
|
||||||
|
classes: ['bx-button-shortcut'],
|
||||||
|
icon: BxIcon.DOWNLOAD,
|
||||||
|
label: t('wallpaper'),
|
||||||
|
style: ButtonStyle.FOCUSABLE,
|
||||||
|
tabIndex: 0,
|
||||||
|
onClick: async e => {
|
||||||
|
try {
|
||||||
|
const matches = /\/games\/(?<titleSlug>[^\/]+)\/(?<productId>\w+)/.exec(window.location.pathname);
|
||||||
|
if (!matches?.groups) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
static injectShortcutButton() {
|
const titleSlug = matches.groups.titleSlug.replaceAll('\%' + '7C', '-');
|
||||||
if (!AppInterface || BX_FLAGS.DeviceInfo.deviceType !== 'android') {
|
const productId = matches.groups.productId;
|
||||||
|
AppInterface.downloadWallpapers(titleSlug, productId);
|
||||||
|
} catch (e) {}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
private static injectTimeoutId: number | null = null;
|
||||||
|
|
||||||
|
static injectButtons() {
|
||||||
|
if (!AppInterface) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProductDetailsPage.shortcutTimeoutId && clearTimeout(ProductDetailsPage.shortcutTimeoutId);
|
ProductDetailsPage.injectTimeoutId && clearTimeout(ProductDetailsPage.injectTimeoutId);
|
||||||
ProductDetailsPage.shortcutTimeoutId = window.setTimeout(() => {
|
ProductDetailsPage.injectTimeoutId = window.setTimeout(() => {
|
||||||
// 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) {
|
if ($container && $container.parentElement) {
|
||||||
$container.parentElement?.appendChild(ProductDetailsPage.$btnShortcut);
|
const fragment = document.createDocumentFragment();
|
||||||
|
|
||||||
|
// Shortcut button
|
||||||
|
if (BX_FLAGS.DeviceInfo.deviceType === 'android') {
|
||||||
|
fragment.appendChild(ProductDetailsPage.$btnShortcut);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wallpaper button
|
||||||
|
fragment.appendChild(ProductDetailsPage.$btnWallpaper);
|
||||||
|
|
||||||
|
$container.parentElement.appendChild(fragment);
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ export function localRedirect(path: string) {
|
|||||||
|
|
||||||
const $anchor = CE<HTMLAnchorElement>('a', {
|
const $anchor = CE<HTMLAnchorElement>('a', {
|
||||||
href: url,
|
href: url,
|
||||||
class: 'bx-hidden bx-offscreen'
|
class: 'bx-hidden bx-offscreen',
|
||||||
}, '');
|
}, '');
|
||||||
$anchor.addEventListener('click', e => {
|
$anchor.addEventListener('click', e => {
|
||||||
// Remove element after clicking on it
|
// Remove element after clicking on it
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { AppInterface } from "@utils/global";
|
import { AppInterface } from "@utils/global";
|
||||||
import { BxEvent } from "@utils/bx-event";
|
import { BxEvent } from "@utils/bx-event";
|
||||||
import { PrefKey } from "@/enums/pref-keys";
|
import { PrefKey } from "@/enums/pref-keys";
|
||||||
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
import { ControllerDeviceVibration, getPref } from "@/utils/settings-storages/global-settings-storage";
|
||||||
|
|
||||||
const VIBRATION_DATA_MAP = {
|
const VIBRATION_DATA_MAP = {
|
||||||
'gamepadIndex': 8,
|
'gamepadIndex': 8,
|
||||||
@ -69,9 +69,9 @@ export class VibrationManager {
|
|||||||
const value = getPref(PrefKey.CONTROLLER_DEVICE_VIBRATION);
|
const value = getPref(PrefKey.CONTROLLER_DEVICE_VIBRATION);
|
||||||
let enabled;
|
let enabled;
|
||||||
|
|
||||||
if (value === 'on') {
|
if (value === ControllerDeviceVibration.ON) {
|
||||||
enabled = true;
|
enabled = true;
|
||||||
} else if (value === 'auto') {
|
} else if (value === ControllerDeviceVibration.AUTO) {
|
||||||
enabled = true;
|
enabled = true;
|
||||||
const gamepads = window.navigator.getGamepads();
|
const gamepads = window.navigator.getGamepads();
|
||||||
for (const gamepad of gamepads) {
|
for (const gamepad of gamepads) {
|
||||||
|
48
src/types/index.d.ts
vendored
48
src/types/index.d.ts
vendored
@ -48,9 +48,9 @@ type BxStates = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
currentStream: Partial<{
|
currentStream: Partial<{
|
||||||
titleId: string;
|
titleSlug: string;
|
||||||
productId: string;
|
|
||||||
titleInfo: XcloudTitleInfo;
|
titleInfo: XcloudTitleInfo;
|
||||||
|
xboxTitleId: number;
|
||||||
|
|
||||||
streamPlayer: StreamPlayer | null;
|
streamPlayer: StreamPlayer | null;
|
||||||
|
|
||||||
@ -65,18 +65,18 @@ type BxStates = {
|
|||||||
config: {
|
config: {
|
||||||
serverId: string;
|
serverId: string;
|
||||||
};
|
};
|
||||||
|
titleId?: string;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
pointerServerPort: number;
|
pointerServerPort: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
type DualEnum = {[index: string]: number} & {[index: number]: string};
|
|
||||||
|
|
||||||
type XcloudTitleInfo = {
|
type XcloudTitleInfo = {
|
||||||
titleId: string,
|
titleId: string,
|
||||||
|
|
||||||
details: {
|
details: {
|
||||||
productId: string;
|
productId: string;
|
||||||
|
xboxTitleId: number;
|
||||||
supportedInputTypes: InputType[];
|
supportedInputTypes: InputType[];
|
||||||
supportedTabs: any[];
|
supportedTabs: any[];
|
||||||
hasNativeTouchSupport: boolean;
|
hasNativeTouchSupport: boolean;
|
||||||
@ -86,6 +86,7 @@ type XcloudTitleInfo = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
product: {
|
product: {
|
||||||
|
title: string;
|
||||||
heroImageUrl: string;
|
heroImageUrl: string;
|
||||||
titledHeroImageUrl: string;
|
titledHeroImageUrl: string;
|
||||||
tileImageUrl: string;
|
tileImageUrl: string;
|
||||||
@ -120,3 +121,42 @@ type MkbMouseWheel = {
|
|||||||
vertical: number;
|
vertical: number;
|
||||||
horizontal: number;
|
horizontal: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type XboxAchievement = {
|
||||||
|
version: number;
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
gamerscore: number;
|
||||||
|
isSecret: boolean;
|
||||||
|
isUnlocked: boolean;
|
||||||
|
description: {
|
||||||
|
locked: string;
|
||||||
|
unlocked: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
imageUrl: string,
|
||||||
|
requirements: Array<{
|
||||||
|
current: number;
|
||||||
|
target: number;
|
||||||
|
percentComplete: number;
|
||||||
|
}>;
|
||||||
|
|
||||||
|
percentComplete: 0,
|
||||||
|
rarity: {
|
||||||
|
currentCategory: string;
|
||||||
|
currentPercentage: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
rewards: Array<{
|
||||||
|
value: number;
|
||||||
|
valueType: string;
|
||||||
|
type: string;
|
||||||
|
}>;
|
||||||
|
|
||||||
|
title: {
|
||||||
|
id: string;
|
||||||
|
scid: string;
|
||||||
|
productId: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
18
src/types/setting-definition.d.ts
vendored
18
src/types/setting-definition.d.ts
vendored
@ -1,3 +1,19 @@
|
|||||||
|
import type { PrefKey } from "@/enums/pref-keys";
|
||||||
|
import type { SettingElementType } from "@/utils/setting-element";
|
||||||
|
|
||||||
|
export type SuggestedSettingCategory = 'recommended' | 'lowest' | 'highest' | 'default';
|
||||||
|
export type RecommendedSettings = {
|
||||||
|
schema_version: 1,
|
||||||
|
device_name: string,
|
||||||
|
device_type: 'android' | 'android-tv' | 'android-handheld' | 'webos',
|
||||||
|
settings: {
|
||||||
|
app: any,
|
||||||
|
script: {
|
||||||
|
_base?: 'lowest' | 'highest',
|
||||||
|
} & PartialRecord<PrefKey, any>,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export type SettingDefinition = {
|
export type SettingDefinition = {
|
||||||
default: any;
|
default: any;
|
||||||
} & Partial<{
|
} & Partial<{
|
||||||
@ -5,7 +21,9 @@ export type SettingDefinition = {
|
|||||||
note: string | HTMLElement;
|
note: string | HTMLElement;
|
||||||
experimental: boolean;
|
experimental: boolean;
|
||||||
unsupported: string | boolean;
|
unsupported: string | boolean;
|
||||||
|
suggest: PartialRecord<SuggestedSettingCategory, any>,
|
||||||
ready: (setting: SettingDefinition) => void;
|
ready: (setting: SettingDefinition) => void;
|
||||||
|
type: SettingElementType,
|
||||||
// migrate?: (this: Preferences, savedPrefs: any, value: any) => void;
|
// migrate?: (this: Preferences, savedPrefs: any, value: any) => void;
|
||||||
}> & (
|
}> & (
|
||||||
{} | {
|
{} | {
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import { AppInterface } from "@utils/global";
|
import { AppInterface } from "@utils/global";
|
||||||
|
import { BxLogger } from "./bx-logger";
|
||||||
|
import { BX_FLAGS } from "./bx-flags";
|
||||||
|
|
||||||
|
|
||||||
export namespace BxEvent {
|
export namespace BxEvent {
|
||||||
@ -35,6 +37,7 @@ export namespace BxEvent {
|
|||||||
|
|
||||||
export const GAME_BAR_ACTION_ACTIVATED = 'bx-game-bar-action-activated';
|
export const GAME_BAR_ACTION_ACTIVATED = 'bx-game-bar-action-activated';
|
||||||
export const MICROPHONE_STATE_CHANGED = 'bx-microphone-state-changed';
|
export const MICROPHONE_STATE_CHANGED = 'bx-microphone-state-changed';
|
||||||
|
export const SPEAKER_STATE_CHANGED = 'bx-speaker-state-changed';
|
||||||
|
|
||||||
export const CAPTURE_SCREENSHOT = 'bx-capture-screenshot';
|
export const CAPTURE_SCREENSHOT = 'bx-capture-screenshot';
|
||||||
|
|
||||||
@ -51,7 +54,7 @@ export namespace BxEvent {
|
|||||||
|
|
||||||
export const XCLOUD_POLLING_MODE_CHANGED = 'bx-xcloud-polling-mode-changed';
|
export const XCLOUD_POLLING_MODE_CHANGED = 'bx-xcloud-polling-mode-changed';
|
||||||
|
|
||||||
export const XCLOUD_RENDERING_COMPONENT = 'bx-xcloud-rendering-page';
|
export const XCLOUD_RENDERING_COMPONENT = 'bx-xcloud-rendering-component';
|
||||||
|
|
||||||
export const XCLOUD_ROUTER_HISTORY_READY = 'bx-xcloud-router-history-ready';
|
export const XCLOUD_ROUTER_HISTORY_READY = 'bx-xcloud-router-history-ready';
|
||||||
|
|
||||||
@ -75,6 +78,8 @@ export namespace BxEvent {
|
|||||||
|
|
||||||
target.dispatchEvent(event);
|
target.dispatchEvent(event);
|
||||||
AppInterface && AppInterface.onEvent(eventName);
|
AppInterface && AppInterface.onEvent(eventName);
|
||||||
|
|
||||||
|
BX_FLAGS.Debug && BxLogger.warning('BxEvent', 'dispatch', eventName, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import { BxLogger } from "./bx-logger";
|
|||||||
import { BX_FLAGS } from "./bx-flags";
|
import { BX_FLAGS } from "./bx-flags";
|
||||||
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 } from "./settings-storages/global-settings-storage";
|
import { getPref, StreamTouchController } from "./settings-storages/global-settings-storage";
|
||||||
|
|
||||||
export enum SupportedInputType {
|
export enum SupportedInputType {
|
||||||
CONTROLLER = 'Controller',
|
CONTROLLER = 'Controller',
|
||||||
@ -41,7 +41,7 @@ export const BxExposed = {
|
|||||||
let touchControllerAvailability = getPref(PrefKey.STREAM_TOUCH_CONTROLLER);
|
let touchControllerAvailability = getPref(PrefKey.STREAM_TOUCH_CONTROLLER);
|
||||||
|
|
||||||
// Disable touch control when gamepad found
|
// Disable touch control when gamepad found
|
||||||
if (touchControllerAvailability !== 'off' && getPref(PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF)) {
|
if (touchControllerAvailability !== StreamTouchController.OFF && getPref(PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF)) {
|
||||||
const gamepads = window.navigator.getGamepads();
|
const gamepads = window.navigator.getGamepads();
|
||||||
let gamepadFound = false;
|
let gamepadFound = false;
|
||||||
|
|
||||||
@ -52,10 +52,10 @@ export const BxExposed = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gamepadFound && (touchControllerAvailability = 'off');
|
gamepadFound && (touchControllerAvailability = StreamTouchController.OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (touchControllerAvailability === 'off') {
|
if (touchControllerAvailability === StreamTouchController.OFF) {
|
||||||
// Disable touch on all games (not native touch)
|
// Disable touch on all games (not native touch)
|
||||||
supportedInputTypes = supportedInputTypes.filter(i => i !== SupportedInputType.CUSTOM_TOUCH_OVERLAY && i !== SupportedInputType.GENERIC_TOUCH);
|
supportedInputTypes = supportedInputTypes.filter(i => i !== SupportedInputType.CUSTOM_TOUCH_OVERLAY && i !== SupportedInputType.GENERIC_TOUCH);
|
||||||
// Empty TABs
|
// Empty TABs
|
||||||
@ -68,7 +68,7 @@ export const BxExposed = {
|
|||||||
supportedInputTypes.includes(SupportedInputType.CUSTOM_TOUCH_OVERLAY) ||
|
supportedInputTypes.includes(SupportedInputType.CUSTOM_TOUCH_OVERLAY) ||
|
||||||
supportedInputTypes.includes(SupportedInputType.GENERIC_TOUCH);
|
supportedInputTypes.includes(SupportedInputType.GENERIC_TOUCH);
|
||||||
|
|
||||||
if (!titleInfo.details.hasTouchSupport && touchControllerAvailability === 'all') {
|
if (!titleInfo.details.hasTouchSupport && touchControllerAvailability === StreamTouchController.ALL) {
|
||||||
// Add generic touch support for non touch-supported games
|
// Add generic touch support for non touch-supported games
|
||||||
titleInfo.details.hasFakeTouchSupport = true;
|
titleInfo.details.hasFakeTouchSupport = true;
|
||||||
supportedInputTypes.push(SupportedInputType.GENERIC_TOUCH);
|
supportedInputTypes.push(SupportedInputType.GENERIC_TOUCH);
|
||||||
@ -128,6 +128,18 @@ export const BxExposed = {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const dict = {
|
||||||
|
bubbles: true,
|
||||||
|
cancelable: true,
|
||||||
|
key: 'XF86Back',
|
||||||
|
code: 'XF86Back',
|
||||||
|
keyCode: 4,
|
||||||
|
which: 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
document.body.dispatchEvent(new KeyboardEvent('keydown', dict));
|
||||||
|
document.body.dispatchEvent(new KeyboardEvent('keyup', dict));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
|
import { BxLogger } from "./bx-logger";
|
||||||
|
|
||||||
type BxFlags = {
|
type BxFlags = {
|
||||||
|
Debug: boolean;
|
||||||
|
|
||||||
CheckForUpdate: boolean;
|
CheckForUpdate: boolean;
|
||||||
EnableXcloudLogging: boolean;
|
EnableXcloudLogging: boolean;
|
||||||
SafariWorkaround: boolean;
|
SafariWorkaround: boolean;
|
||||||
@ -7,13 +11,19 @@ type BxFlags = {
|
|||||||
FeatureGates: {[key: string]: boolean} | null,
|
FeatureGates: {[key: string]: boolean} | null,
|
||||||
|
|
||||||
DeviceInfo: {
|
DeviceInfo: {
|
||||||
deviceType: 'android' | 'android-tv' | 'webos' | 'unknown',
|
deviceType: 'android' | 'android-tv' | 'android-handheld' | 'webos' | 'unknown',
|
||||||
userAgent?: string,
|
userAgent?: string,
|
||||||
|
|
||||||
|
androidInfo?: {
|
||||||
|
board: string,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup flags
|
// Setup flags
|
||||||
const DEFAULT_FLAGS: BxFlags = {
|
const DEFAULT_FLAGS: BxFlags = {
|
||||||
|
Debug: false,
|
||||||
|
|
||||||
CheckForUpdate: true,
|
CheckForUpdate: true,
|
||||||
EnableXcloudLogging: false,
|
EnableXcloudLogging: false,
|
||||||
SafariWorkaround: true,
|
SafariWorkaround: true,
|
||||||
@ -35,4 +45,6 @@ if (!BX_FLAGS.DeviceInfo.userAgent) {
|
|||||||
BX_FLAGS.DeviceInfo.userAgent = window.navigator.userAgent;
|
BX_FLAGS.DeviceInfo.userAgent = window.navigator.userAgent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BxLogger.info('BxFlags', BX_FLAGS);
|
||||||
|
|
||||||
export const NATIVE_FETCH = window.fetch;
|
export const NATIVE_FETCH = window.fetch;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import iconBetterXcloud from "@assets/svg/better-xcloud.svg" with { type: "text" };
|
import iconBetterXcloud from "@assets/svg/better-xcloud.svg" with { type: "text" };
|
||||||
|
import iconTrueAchievements from "@assets/svg/true-achievements.svg" with { type: "text" };
|
||||||
import iconClose from "@assets/svg/close.svg" with { type: "text" };
|
import iconClose from "@assets/svg/close.svg" with { type: "text" };
|
||||||
import iconCommand from "@assets/svg/command.svg" with { type: "text" };
|
import iconCommand from "@assets/svg/command.svg" with { type: "text" };
|
||||||
import iconController from "@assets/svg/controller.svg" with { type: "text" };
|
import iconController from "@assets/svg/controller.svg" with { type: "text" };
|
||||||
@ -9,9 +10,11 @@ import iconDisplay from "@assets/svg/display.svg" with { type: "text" };
|
|||||||
import iconHome from "@assets/svg/home.svg" with { type: "text" };
|
import iconHome from "@assets/svg/home.svg" with { type: "text" };
|
||||||
import iconNativeMkb from "@assets/svg/native-mkb.svg" with { type: "text" };
|
import iconNativeMkb from "@assets/svg/native-mkb.svg" with { type: "text" };
|
||||||
import iconNew from "@assets/svg/new.svg" with { type: "text" };
|
import iconNew from "@assets/svg/new.svg" with { type: "text" };
|
||||||
|
import iconPower from "@assets/svg/power.svg" with { type: "text" };
|
||||||
import iconQuestion from "@assets/svg/question.svg" with { type: "text" };
|
import iconQuestion from "@assets/svg/question.svg" with { type: "text" };
|
||||||
import iconRefresh from "@assets/svg/refresh.svg" with { type: "text" };
|
import iconRefresh from "@assets/svg/refresh.svg" with { type: "text" };
|
||||||
import iconRemotePlay from "@assets/svg/remote-play.svg" with { type: "text" };
|
import iconRemotePlay from "@assets/svg/remote-play.svg" with { type: "text" };
|
||||||
|
import iconSpeakerSlash from "@assets/svg/speaker-slash.svg" with { type: "text" };
|
||||||
import iconStreamSettings from "@assets/svg/stream-settings.svg" with { type: "text" };
|
import iconStreamSettings from "@assets/svg/stream-settings.svg" with { type: "text" };
|
||||||
import iconStreamStats from "@assets/svg/stream-stats.svg" with { type: "text" };
|
import iconStreamStats from "@assets/svg/stream-stats.svg" with { type: "text" };
|
||||||
import iconTouchControlDisable from "@assets/svg/touch-control-disable.svg" with { type: "text" };
|
import iconTouchControlDisable from "@assets/svg/touch-control-disable.svg" with { type: "text" };
|
||||||
@ -37,6 +40,7 @@ import iconUpload from "@assets/svg/upload.svg" with { type: "text" };
|
|||||||
|
|
||||||
export const BxIcon = {
|
export const BxIcon = {
|
||||||
BETTER_XCLOUD: iconBetterXcloud,
|
BETTER_XCLOUD: iconBetterXcloud,
|
||||||
|
TRUE_ACHIEVEMENTS: iconTrueAchievements,
|
||||||
STREAM_SETTINGS: iconStreamSettings,
|
STREAM_SETTINGS: iconStreamSettings,
|
||||||
STREAM_STATS: iconStreamStats,
|
STREAM_STATS: iconStreamStats,
|
||||||
CLOSE: iconClose,
|
CLOSE: iconClose,
|
||||||
@ -50,6 +54,7 @@ export const BxIcon = {
|
|||||||
COPY: iconCopy,
|
COPY: iconCopy,
|
||||||
TRASH: iconTrash,
|
TRASH: iconTrash,
|
||||||
CURSOR_TEXT: iconCursorText,
|
CURSOR_TEXT: iconCursorText,
|
||||||
|
POWER: iconPower,
|
||||||
QUESTION: iconQuestion,
|
QUESTION: iconQuestion,
|
||||||
REFRESH: iconRefresh,
|
REFRESH: iconRefresh,
|
||||||
VIRTUAL_CONTROLLER: iconVirtualController,
|
VIRTUAL_CONTROLLER: iconVirtualController,
|
||||||
@ -60,6 +65,7 @@ export const BxIcon = {
|
|||||||
CARET_LEFT: iconCaretLeft,
|
CARET_LEFT: iconCaretLeft,
|
||||||
CARET_RIGHT: iconCaretRight,
|
CARET_RIGHT: iconCaretRight,
|
||||||
SCREENSHOT: iconCamera,
|
SCREENSHOT: iconCamera,
|
||||||
|
SPEAKER_MUTED: iconSpeakerSlash,
|
||||||
TOUCH_CONTROL_ENABLE: iconTouchControlEnable,
|
TOUCH_CONTROL_ENABLE: iconTouchControlEnable,
|
||||||
TOUCH_CONTROL_DISABLE: iconTouchControlDisable,
|
TOUCH_CONTROL_DISABLE: iconTouchControlDisable,
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { BxEvent } from "@utils/bx-event";
|
import { BxEvent } from "@utils/bx-event";
|
||||||
import { LoadingScreen } from "@modules/loading-screen";
|
import { LoadingScreen } from "@modules/loading-screen";
|
||||||
import { RemotePlay } from "@modules/remote-play";
|
import { RemotePlayManager } from "@/modules/remote-play-manager";
|
||||||
import { HeaderSection } from "@/modules/ui/header";
|
import { HeaderSection } from "@/modules/ui/header";
|
||||||
import { NavigationDialogManager } from "@/modules/ui/dialog/navigation-dialog";
|
import { NavigationDialogManager } from "@/modules/ui/dialog/navigation-dialog";
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ export function onHistoryChanged(e: PopStateEvent) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.setTimeout(RemotePlay.detect, 10);
|
window.setTimeout(RemotePlayManager.detect, 10);
|
||||||
|
|
||||||
// Hide Global settings
|
// Hide Global settings
|
||||||
const $settings = document.querySelector('.bx-settings-container');
|
const $settings = document.querySelector('.bx-settings-container');
|
||||||
@ -35,9 +35,6 @@ export function onHistoryChanged(e: PopStateEvent) {
|
|||||||
// Hide Navigation dialog
|
// Hide Navigation dialog
|
||||||
NavigationDialogManager.getInstance().hide();
|
NavigationDialogManager.getInstance().hide();
|
||||||
|
|
||||||
// Hide Remote Play popup
|
|
||||||
RemotePlay.detachPopup();
|
|
||||||
|
|
||||||
LoadingScreen.reset();
|
LoadingScreen.reset();
|
||||||
window.setTimeout(HeaderSection.watchHeader, 2000);
|
window.setTimeout(HeaderSection.watchHeader, 2000);
|
||||||
|
|
||||||
|
@ -2,8 +2,38 @@ import type { BxIcon } from "@utils/bx-icon";
|
|||||||
import { setNearby } from "./navigation-utils";
|
import { setNearby } from "./navigation-utils";
|
||||||
import type { NavigationNearbyElements } from "@/modules/ui/dialog/navigation-dialog";
|
import type { NavigationNearbyElements } from "@/modules/ui/dialog/navigation-dialog";
|
||||||
|
|
||||||
type BxButton = {
|
export enum ButtonStyle {
|
||||||
style?: number | string | ButtonStyle;
|
PRIMARY = 1,
|
||||||
|
DANGER = 2,
|
||||||
|
GHOST = 4,
|
||||||
|
FROSTED = 8,
|
||||||
|
DROP_SHADOW = 16,
|
||||||
|
FOCUSABLE = 32,
|
||||||
|
FULL_WIDTH = 64,
|
||||||
|
FULL_HEIGHT = 128,
|
||||||
|
TALL = 256,
|
||||||
|
CIRCULAR = 512,
|
||||||
|
NORMAL_CASE = 1024,
|
||||||
|
NORMAL_LINK = 2048,
|
||||||
|
}
|
||||||
|
|
||||||
|
const ButtonStyleClass = {
|
||||||
|
[ButtonStyle.PRIMARY]: 'bx-primary',
|
||||||
|
[ButtonStyle.DANGER]: 'bx-danger',
|
||||||
|
[ButtonStyle.GHOST]: 'bx-ghost',
|
||||||
|
[ButtonStyle.FROSTED]: 'bx-frosted',
|
||||||
|
[ButtonStyle.DROP_SHADOW]: 'bx-drop-shadow',
|
||||||
|
[ButtonStyle.FOCUSABLE]: 'bx-focusable',
|
||||||
|
[ButtonStyle.FULL_WIDTH]: 'bx-full-width',
|
||||||
|
[ButtonStyle.FULL_HEIGHT]: 'bx-full-height',
|
||||||
|
[ButtonStyle.TALL]: 'bx-tall',
|
||||||
|
[ButtonStyle.CIRCULAR]: 'bx-circular',
|
||||||
|
[ButtonStyle.NORMAL_CASE]: 'bx-normal-case',
|
||||||
|
[ButtonStyle.NORMAL_LINK]: 'bx-normal-link',
|
||||||
|
}
|
||||||
|
|
||||||
|
export type BxButton = {
|
||||||
|
style?: ButtonStyle;
|
||||||
url?: string;
|
url?: string;
|
||||||
classes?: string[];
|
classes?: string[];
|
||||||
icon?: typeof BxIcon;
|
icon?: typeof BxIcon;
|
||||||
@ -15,8 +45,6 @@ type BxButton = {
|
|||||||
attributes?: {[key: string]: any},
|
attributes?: {[key: string]: any},
|
||||||
}
|
}
|
||||||
|
|
||||||
type ButtonStyle = {[index: string]: number} & {[index: number]: string};
|
|
||||||
|
|
||||||
// Quickly create a tree of elements without having to use innerHTML
|
// Quickly create a tree of elements without having to use innerHTML
|
||||||
type CreateElementOptions = {
|
type CreateElementOptions = {
|
||||||
[index: string]: any;
|
[index: string]: any;
|
||||||
@ -80,20 +108,7 @@ export const createSvgIcon = (icon: typeof BxIcon) => {
|
|||||||
return svgParser(icon.toString());
|
return svgParser(icon.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ButtonStyle: DualEnum = {};
|
const ButtonStyleIndices = Object.keys(ButtonStyleClass).map(i => parseInt(i));
|
||||||
ButtonStyle[ButtonStyle.PRIMARY = 1] = 'bx-primary';
|
|
||||||
ButtonStyle[ButtonStyle.DANGER = 2] = 'bx-danger';
|
|
||||||
ButtonStyle[ButtonStyle.GHOST = 4] = 'bx-ghost';
|
|
||||||
ButtonStyle[ButtonStyle.FROSTED = 8] = 'bx-frosted';
|
|
||||||
ButtonStyle[ButtonStyle.DROP_SHADOW = 16] = 'bx-drop-shadow';
|
|
||||||
ButtonStyle[ButtonStyle.FOCUSABLE = 32] = 'bx-focusable';
|
|
||||||
ButtonStyle[ButtonStyle.FULL_WIDTH = 64] = 'bx-full-width';
|
|
||||||
ButtonStyle[ButtonStyle.FULL_HEIGHT = 128] = 'bx-full-height';
|
|
||||||
ButtonStyle[ButtonStyle.TALL = 256] = 'bx-tall';
|
|
||||||
ButtonStyle[ButtonStyle.CIRCULAR = 512] = 'bx-circular';
|
|
||||||
ButtonStyle[ButtonStyle.NORMAL_CASE = 1024] = 'bx-normal-case';
|
|
||||||
|
|
||||||
const ButtonStyleIndices = Object.keys(ButtonStyle).splice(0, Object.keys(ButtonStyle).length / 2).map(i => parseInt(i));
|
|
||||||
|
|
||||||
export const createButton = <T=HTMLButtonElement>(options: BxButton): T => {
|
export const createButton = <T=HTMLButtonElement>(options: BxButton): T => {
|
||||||
let $btn;
|
let $btn;
|
||||||
@ -106,8 +121,8 @@ export const createButton = <T=HTMLButtonElement>(options: BxButton): T => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const style = (options.style || 0) as number;
|
const style = (options.style || 0) as number;
|
||||||
style && ButtonStyleIndices.forEach(index => {
|
style && ButtonStyleIndices.forEach((index: keyof typeof ButtonStyleClass) => {
|
||||||
(style & index) && $btn.classList.add(ButtonStyle[index] as string);
|
(style & index) && $btn.classList.add(ButtonStyleClass[index] as string);
|
||||||
});
|
});
|
||||||
|
|
||||||
options.classes && $btn.classList.add(...options.classes);
|
options.classes && $btn.classList.add(...options.classes);
|
||||||
@ -146,5 +161,29 @@ export function escapeHtml(html: string): string {
|
|||||||
return $span.innerHTML;
|
return $span.innerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isElementVisible($elm: HTMLElement): boolean {
|
||||||
|
const rect = $elm.getBoundingClientRect();
|
||||||
|
return (rect.x >= 0 || rect.y >= 0) && !!rect.width && !!rect.height;
|
||||||
|
}
|
||||||
|
|
||||||
export const CTN = document.createTextNode.bind(document);
|
export const CTN = document.createTextNode.bind(document);
|
||||||
window.BX_CE = createElement;
|
window.BX_CE = createElement;
|
||||||
|
|
||||||
|
export function removeChildElements($parent: HTMLElement) {
|
||||||
|
while ($parent.firstElementChild) {
|
||||||
|
$parent.firstElementChild.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function clearFocus() {
|
||||||
|
if (document.activeElement instanceof HTMLElement) {
|
||||||
|
document.activeElement.blur();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function clearDataSet($elm: HTMLElement) {
|
||||||
|
Object.keys($elm.dataset).forEach(key => {
|
||||||
|
delete $elm.dataset[key];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -254,6 +254,7 @@ export function patchPointerLockApi() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// const nativeRequestPointerLock = HTMLElement.prototype.requestPointerLock;
|
// const nativeRequestPointerLock = HTMLElement.prototype.requestPointerLock;
|
||||||
|
// @ts-ignore
|
||||||
HTMLElement.prototype.requestPointerLock = function() {
|
HTMLElement.prototype.requestPointerLock = function() {
|
||||||
pointerLockElement = document.documentElement;
|
pointerLockElement = document.documentElement;
|
||||||
window.dispatchEvent(new Event(BxEvent.POINTER_LOCK_REQUESTED));
|
window.dispatchEvent(new Event(BxEvent.POINTER_LOCK_REQUESTED));
|
||||||
|
@ -71,7 +71,7 @@ export class Screenshot {
|
|||||||
// Get data URL and pass to parent app
|
// Get data URL and pass to parent app
|
||||||
if (AppInterface) {
|
if (AppInterface) {
|
||||||
const data = $canvas.toDataURL('image/png').split(';base64,')[1];
|
const data = $canvas.toDataURL('image/png').split(';base64,')[1];
|
||||||
AppInterface.saveScreenshot(currentStream.titleId, data);
|
AppInterface.saveScreenshot(currentStream.titleSlug, data);
|
||||||
|
|
||||||
// Free screenshot from memory
|
// Free screenshot from memory
|
||||||
canvasContext.clearRect(0, 0, $canvas.width, $canvas.height);
|
canvasContext.clearRect(0, 0, $canvas.width, $canvas.height);
|
||||||
@ -84,7 +84,7 @@ export class Screenshot {
|
|||||||
// Download screenshot
|
// Download screenshot
|
||||||
const now = +new Date;
|
const now = +new Date;
|
||||||
const $anchor = CE<HTMLAnchorElement>('a', {
|
const $anchor = CE<HTMLAnchorElement>('a', {
|
||||||
'download': `${currentStream.titleId}-${now}.png`,
|
'download': `${currentStream.titleSlug}-${now}.png`,
|
||||||
'href': URL.createObjectURL(blob!),
|
'href': URL.createObjectURL(blob!),
|
||||||
});
|
});
|
||||||
$anchor.click();
|
$anchor.click();
|
||||||
|
@ -4,6 +4,7 @@ import { setNearby } from "./navigation-utils";
|
|||||||
import type { PrefKey } from "@/enums/pref-keys";
|
import type { PrefKey } from "@/enums/pref-keys";
|
||||||
import type { BaseSettingsStore } from "./settings-storages/base-settings-storage";
|
import type { BaseSettingsStore } from "./settings-storages/base-settings-storage";
|
||||||
import { type MultipleOptionsParams, type NumberStepperParams } from "@/types/setting-definition";
|
import { type MultipleOptionsParams, type NumberStepperParams } from "@/types/setting-definition";
|
||||||
|
import { BxEvent } from "./bx-event";
|
||||||
|
|
||||||
export enum SettingElementType {
|
export enum SettingElementType {
|
||||||
OPTIONS = 'options',
|
OPTIONS = 'options',
|
||||||
@ -13,16 +14,26 @@ export enum SettingElementType {
|
|||||||
CHECKBOX = 'checkbox',
|
CHECKBOX = 'checkbox',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface BxBaseSettingElement {
|
||||||
|
setValue: (value: any) => void,
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BxHtmlSettingElement extends HTMLElement, BxBaseSettingElement {};
|
||||||
|
|
||||||
|
export interface BxSelectSettingElement extends HTMLSelectElement, BxBaseSettingElement {}
|
||||||
|
|
||||||
export class SettingElement {
|
export class SettingElement {
|
||||||
static #renderOptions(key: string, setting: PreferenceSetting, currentValue: any, onChange: any) {
|
static #renderOptions(key: string, setting: PreferenceSetting, currentValue: any, onChange: any): BxSelectSettingElement {
|
||||||
const $control = CE<HTMLSelectElement>('select', {
|
const $control = CE<BxSelectSettingElement>('select', {
|
||||||
// title: setting.label,
|
// title: setting.label,
|
||||||
tabindex: 0,
|
tabindex: 0,
|
||||||
}) as HTMLSelectElement;
|
});
|
||||||
|
|
||||||
let $parent: HTMLElement;
|
let $parent: HTMLElement;
|
||||||
if (setting.optionsGroup) {
|
if (setting.optionsGroup) {
|
||||||
$parent = CE('optgroup', {'label': setting.optionsGroup});
|
$parent = CE('optgroup', {
|
||||||
|
label: setting.optionsGroup,
|
||||||
|
});
|
||||||
$control.appendChild($parent);
|
$control.appendChild($parent);
|
||||||
} else {
|
} else {
|
||||||
$parent = $control;
|
$parent = $control;
|
||||||
@ -44,19 +55,20 @@ export class SettingElement {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Custom method
|
// Custom method
|
||||||
($control as any).setValue = (value: any) => {
|
$control.setValue = (value: any) => {
|
||||||
$control.value = value;
|
$control.value = value;
|
||||||
};
|
};
|
||||||
|
|
||||||
return $control;
|
return $control;
|
||||||
}
|
}
|
||||||
|
|
||||||
static #renderMultipleOptions(key: string, setting: PreferenceSetting, currentValue: any, onChange: any, params: MultipleOptionsParams={}) {
|
static #renderMultipleOptions(key: string, setting: PreferenceSetting, currentValue: any, onChange: any, params: MultipleOptionsParams={}): BxSelectSettingElement {
|
||||||
const $control = CE<HTMLSelectElement>('select', {
|
const $control = CE<BxSelectSettingElement>('select', {
|
||||||
// title: setting.label,
|
// title: setting.label,
|
||||||
multiple: true,
|
multiple: true,
|
||||||
tabindex: 0,
|
tabindex: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (params && params.size) {
|
if (params && params.size) {
|
||||||
$control.setAttribute('size', params.size.toString());
|
$control.setAttribute('size', params.size.toString());
|
||||||
}
|
}
|
||||||
@ -75,7 +87,7 @@ export class SettingElement {
|
|||||||
|
|
||||||
const $parent = target.parentElement!;
|
const $parent = target.parentElement!;
|
||||||
$parent.focus();
|
$parent.focus();
|
||||||
$parent.dispatchEvent(new Event('input'));
|
BxEvent.dispatch($parent, 'input');
|
||||||
});
|
});
|
||||||
|
|
||||||
$control.appendChild($option);
|
$control.appendChild($option);
|
||||||
@ -100,9 +112,15 @@ export class SettingElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static #renderNumber(key: string, setting: PreferenceSetting, currentValue: any, onChange: any) {
|
static #renderNumber(key: string, setting: PreferenceSetting, currentValue: any, onChange: any) {
|
||||||
const $control = CE('input', {'tabindex': 0, 'type': 'number', 'min': setting.min, 'max': setting.max}) as HTMLInputElement;
|
const $control = CE<HTMLInputElement>('input', {
|
||||||
|
tabindex: 0,
|
||||||
|
type: 'number',
|
||||||
|
min: setting.min,
|
||||||
|
max: setting.max,
|
||||||
|
});
|
||||||
|
|
||||||
$control.value = currentValue;
|
$control.value = currentValue;
|
||||||
onChange && $control.addEventListener('change', (e: Event) => {
|
onChange && $control.addEventListener('input', (e: Event) => {
|
||||||
const target = e.target as HTMLInputElement;
|
const target = e.target as HTMLInputElement;
|
||||||
|
|
||||||
const value = Math.max(setting.min!, Math.min(setting.max!, parseInt(target.value)));
|
const value = Math.max(setting.min!, Math.min(setting.max!, parseInt(target.value)));
|
||||||
@ -118,10 +136,14 @@ export class SettingElement {
|
|||||||
const $control = CE('input', {'type': 'checkbox', 'tabindex': 0}) as HTMLInputElement;
|
const $control = CE('input', {'type': 'checkbox', 'tabindex': 0}) as HTMLInputElement;
|
||||||
$control.checked = currentValue;
|
$control.checked = currentValue;
|
||||||
|
|
||||||
onChange && $control.addEventListener('change', e => {
|
onChange && $control.addEventListener('input', e => {
|
||||||
!(e as any).ignoreOnChange && onChange(e, (e.target as HTMLInputElement).checked);
|
!(e as any).ignoreOnChange && onChange(e, (e.target as HTMLInputElement).checked);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
($control as any).setValue = (value: boolean) => {
|
||||||
|
$control.checked = !!value;
|
||||||
|
};
|
||||||
|
|
||||||
return $control;
|
return $control;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,77 +184,21 @@ export class SettingElement {
|
|||||||
$btnInc.classList.toggle('bx-inactive', controlValue === MAX);
|
$btnInc.classList.toggle('bx-inactive', controlValue === MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
const $wrapper = CE('div', {'class': 'bx-number-stepper', id: `bx_setting_${key}`},
|
const $wrapper = CE<BxHtmlSettingElement>('div', {'class': 'bx-number-stepper', id: `bx_setting_${key}`},
|
||||||
$btnDec = CE('button', {
|
$btnDec = CE('button', {
|
||||||
'data-type': 'dec',
|
'data-type': 'dec',
|
||||||
type: 'button',
|
type: 'button',
|
||||||
class: options.hideSlider ? 'bx-focusable' : '',
|
class: options.hideSlider ? 'bx-focusable' : '',
|
||||||
tabindex: options.hideSlider ? 0 : -1,
|
tabindex: options.hideSlider ? 0 : -1,
|
||||||
}, '-') as HTMLButtonElement,
|
}, '-') as HTMLButtonElement,
|
||||||
$text = CE('span', {}, renderTextValue(value)) as HTMLSpanElement,
|
$text = CE('span', {}, renderTextValue(value)) as HTMLSpanElement,
|
||||||
$btnInc = CE('button', {
|
$btnInc = CE('button', {
|
||||||
'data-type': 'inc',
|
'data-type': 'inc',
|
||||||
type: 'button',
|
type: 'button',
|
||||||
class: options.hideSlider ? 'bx-focusable' : '',
|
class: options.hideSlider ? 'bx-focusable' : '',
|
||||||
tabindex: options.hideSlider ? 0 : -1,
|
tabindex: options.hideSlider ? 0 : -1,
|
||||||
}, '+') as HTMLButtonElement,
|
}, '+') as HTMLButtonElement,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (options.disabled) {
|
|
||||||
($wrapper as any).disabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!options.disabled && !options.hideSlider) {
|
|
||||||
$range = CE('input', {
|
|
||||||
id: `bx_setting_${key}`,
|
|
||||||
type: 'range',
|
|
||||||
min: MIN,
|
|
||||||
max: MAX,
|
|
||||||
value: value,
|
|
||||||
step: STEPS,
|
|
||||||
tabindex: 0,
|
|
||||||
}) as HTMLInputElement;
|
|
||||||
|
|
||||||
$range.addEventListener('input', e => {
|
|
||||||
value = parseInt((e.target as HTMLInputElement).value);
|
|
||||||
const valueChanged = controlValue !== value;
|
|
||||||
|
|
||||||
if (!valueChanged) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
controlValue = value;
|
|
||||||
updateButtonsVisibility();
|
|
||||||
$text.textContent = renderTextValue(value);
|
|
||||||
|
|
||||||
!(e as any).ignoreOnChange && onChange && onChange(e, value);
|
|
||||||
});
|
|
||||||
|
|
||||||
$wrapper.appendChild($range);
|
|
||||||
|
|
||||||
if (options.ticks || options.exactTicks) {
|
|
||||||
const markersId = `markers-${key}`;
|
|
||||||
const $markers = CE('datalist', {'id': markersId});
|
|
||||||
$range.setAttribute('list', markersId);
|
|
||||||
|
|
||||||
if (options.exactTicks) {
|
|
||||||
let start = Math.max(Math.floor(MIN / options.exactTicks), 1) * options.exactTicks;
|
|
||||||
|
|
||||||
if (start === MIN) {
|
|
||||||
start += options.exactTicks;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = start; i < MAX; i += options.exactTicks) {
|
|
||||||
$markers.appendChild(CE<HTMLOptionElement>('option', {'value': i}));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (let i = MIN + options.ticks!; i < MAX; i += options.ticks!) {
|
|
||||||
$markers.appendChild(CE<HTMLOptionElement>('option', {'value': i}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$wrapper.appendChild($markers);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.disabled) {
|
if (options.disabled) {
|
||||||
$btnInc.disabled = true;
|
$btnInc.disabled = true;
|
||||||
@ -240,9 +206,66 @@ export class SettingElement {
|
|||||||
|
|
||||||
$btnDec.disabled = true;
|
$btnDec.disabled = true;
|
||||||
$btnDec.classList.add('bx-inactive');
|
$btnDec.classList.add('bx-inactive');
|
||||||
|
|
||||||
|
($wrapper as any).disabled = true;
|
||||||
return $wrapper;
|
return $wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$range = CE<HTMLInputElement>('input', {
|
||||||
|
id: `bx_setting_${key}`,
|
||||||
|
type: 'range',
|
||||||
|
min: MIN,
|
||||||
|
max: MAX,
|
||||||
|
value: value,
|
||||||
|
step: STEPS,
|
||||||
|
tabindex: 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
options.hideSlider && $range.classList.add('bx-gone');
|
||||||
|
|
||||||
|
$range.addEventListener('input', e => {
|
||||||
|
value = parseInt((e.target as HTMLInputElement).value);
|
||||||
|
const valueChanged = controlValue !== value;
|
||||||
|
|
||||||
|
if (!valueChanged) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
controlValue = value;
|
||||||
|
updateButtonsVisibility();
|
||||||
|
$text.textContent = renderTextValue(value);
|
||||||
|
|
||||||
|
!(e as any).ignoreOnChange && onChange && onChange(e, value);
|
||||||
|
});
|
||||||
|
|
||||||
|
$wrapper.addEventListener('input', e => {
|
||||||
|
BxEvent.dispatch($range, 'input');
|
||||||
|
});
|
||||||
|
$wrapper.appendChild($range);
|
||||||
|
|
||||||
|
if (options.ticks || options.exactTicks) {
|
||||||
|
const markersId = `markers-${key}`;
|
||||||
|
const $markers = CE('datalist', {'id': markersId});
|
||||||
|
$range.setAttribute('list', markersId);
|
||||||
|
|
||||||
|
if (options.exactTicks) {
|
||||||
|
let start = Math.max(Math.floor(MIN / options.exactTicks), 1) * options.exactTicks;
|
||||||
|
|
||||||
|
if (start === MIN) {
|
||||||
|
start += options.exactTicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = start; i < MAX; i += options.exactTicks) {
|
||||||
|
$markers.appendChild(CE<HTMLOptionElement>('option', {'value': i}));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (let i = MIN + options.ticks!; i < MAX; i += options.ticks!) {
|
||||||
|
$markers.appendChild(CE<HTMLOptionElement>('option', {'value': i}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$wrapper.appendChild($markers);
|
||||||
|
}
|
||||||
|
|
||||||
updateButtonsVisibility();
|
updateButtonsVisibility();
|
||||||
|
|
||||||
let interval: number;
|
let interval: number;
|
||||||
@ -278,16 +301,14 @@ export class SettingElement {
|
|||||||
|
|
||||||
const onMouseDown = (e: PointerEvent) => {
|
const onMouseDown = (e: PointerEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
isHolding = true;
|
isHolding = true;
|
||||||
|
|
||||||
const args = arguments;
|
const args = arguments;
|
||||||
interval && clearInterval(interval);
|
interval && clearInterval(interval);
|
||||||
interval = window.setInterval(() => {
|
interval = window.setInterval(() => {
|
||||||
const event = new Event('click');
|
e.target && BxEvent.dispatch(e.target as HTMLElement, 'click', {
|
||||||
(event as any).arguments = args;
|
arguments: args,
|
||||||
|
});
|
||||||
e.target?.dispatchEvent(event);
|
|
||||||
}, 200);
|
}, 200);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -301,11 +322,9 @@ export class SettingElement {
|
|||||||
const onContextMenu = (e: Event) => e.preventDefault();
|
const onContextMenu = (e: Event) => e.preventDefault();
|
||||||
|
|
||||||
// Custom method
|
// Custom method
|
||||||
($wrapper as any).setValue = (value: any) => {
|
$wrapper.setValue = (value: any) => {
|
||||||
controlValue = parseInt(value);
|
|
||||||
|
|
||||||
$text.textContent = renderTextValue(value);
|
$text.textContent = renderTextValue(value);
|
||||||
$range && ($range.value = value);
|
$range.value = value;
|
||||||
};
|
};
|
||||||
|
|
||||||
$btnDec.addEventListener('click', onClick);
|
$btnDec.addEventListener('click', onClick);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import type { PrefKey } from "@/enums/pref-keys";
|
import type { PrefKey } from "@/enums/pref-keys";
|
||||||
import type { SettingDefinitions } from "@/types/setting-definition";
|
import type { NumberStepperParams, SettingDefinitions } from "@/types/setting-definition";
|
||||||
import { BxEvent } from "../bx-event";
|
import { BxEvent } from "../bx-event";
|
||||||
|
import { SettingElementType } from "../setting-element";
|
||||||
|
import { t } from "../translation";
|
||||||
|
|
||||||
export class BaseSettingsStore {
|
export class BaseSettingsStore {
|
||||||
private storage: Storage;
|
private storage: Storage;
|
||||||
@ -12,7 +14,8 @@ export class BaseSettingsStore {
|
|||||||
this.storage = window.localStorage;
|
this.storage = window.localStorage;
|
||||||
this.storageKey = storageKey;
|
this.storageKey = storageKey;
|
||||||
|
|
||||||
for (const settingId in definitions) {
|
let settingId: keyof typeof definitions
|
||||||
|
for (settingId in definitions) {
|
||||||
const setting = definitions[settingId];
|
const setting = definitions[settingId];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -49,14 +52,14 @@ export class BaseSettingsStore {
|
|||||||
return this.definitions[key];
|
return this.definitions[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
getSetting(key: PrefKey) {
|
getSetting(key: PrefKey, checkUnsupported = true) {
|
||||||
if (typeof key === 'undefined') {
|
if (typeof key === 'undefined') {
|
||||||
debugger;
|
debugger;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return default value if the feature is not supported
|
// Return default value if the feature is not supported
|
||||||
if (this.definitions[key].unsupported) {
|
if (checkUnsupported && this.definitions[key].unsupported) {
|
||||||
return this.definitions[key].default;
|
return this.definitions[key].default;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,4 +124,32 @@ export class BaseSettingsStore {
|
|||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getLabel(key: PrefKey): string {
|
||||||
|
return this.definitions[key].label || key;
|
||||||
|
}
|
||||||
|
|
||||||
|
getValueText(key: PrefKey, value: any): string {
|
||||||
|
const definition = this.definitions[key];
|
||||||
|
if (definition.type === SettingElementType.NUMBER_STEPPER) {
|
||||||
|
const params = (definition as any).params as NumberStepperParams;
|
||||||
|
if (params.customTextValue) {
|
||||||
|
const text = params.customTextValue(value);
|
||||||
|
if (text) {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return value.toString();
|
||||||
|
} else if ('options' in definition) {
|
||||||
|
const options = (definition as any).options;
|
||||||
|
if (value in options) {
|
||||||
|
return options[value];
|
||||||
|
}
|
||||||
|
} else if (typeof value === 'boolean') {
|
||||||
|
return value ? t('on') : t('off')
|
||||||
|
}
|
||||||
|
|
||||||
|
return value.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,7 @@ import { StreamPlayerType, StreamVideoProcessing } from "@/enums/stream-player";
|
|||||||
import { UiSection } from "@/enums/ui-sections";
|
import { UiSection } from "@/enums/ui-sections";
|
||||||
import { UserAgentProfile } from "@/enums/user-agent";
|
import { UserAgentProfile } from "@/enums/user-agent";
|
||||||
import { StreamStat } from "@/modules/stream/stream-stats";
|
import { StreamStat } from "@/modules/stream/stream-stats";
|
||||||
import type { PreferenceSetting } from "@/types/preferences";
|
import { type SettingDefinition, type SettingDefinitions } from "@/types/setting-definition";
|
||||||
import { type SettingDefinitions } from "@/types/setting-definition";
|
|
||||||
import { BX_FLAGS } from "../bx-flags";
|
import { BX_FLAGS } from "../bx-flags";
|
||||||
import { STATES, AppInterface, STORAGE } from "../global";
|
import { STATES, AppInterface, STORAGE } from "../global";
|
||||||
import { CE } from "../html";
|
import { CE } from "../html";
|
||||||
@ -15,8 +14,33 @@ import { BaseSettingsStore as BaseSettingsStorage } from "./base-settings-storag
|
|||||||
import { SettingElementType } from "../setting-element";
|
import { SettingElementType } from "../setting-element";
|
||||||
|
|
||||||
|
|
||||||
|
export const enum StreamResolution {
|
||||||
|
DIM_720P = '720p',
|
||||||
|
DIM_1080P = '1080p',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const enum CodecProfile {
|
||||||
|
DEFAULT = 'default',
|
||||||
|
LOW = 'low',
|
||||||
|
NORMAL = 'normal',
|
||||||
|
HIGH = 'high',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const enum StreamTouchController {
|
||||||
|
DEFAULT = 'default',
|
||||||
|
ALL = 'all',
|
||||||
|
OFF = 'off',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const enum ControllerDeviceVibration {
|
||||||
|
ON = 'on',
|
||||||
|
AUTO = 'auto',
|
||||||
|
OFF = 'off',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function getSupportedCodecProfiles() {
|
function getSupportedCodecProfiles() {
|
||||||
const options: {[index: string]: string} = {
|
const options: PartialRecord<CodecProfile, string> = {
|
||||||
default: t('default'),
|
default: t('default'),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -46,25 +70,25 @@ function getSupportedCodecProfiles() {
|
|||||||
|
|
||||||
if (hasLowCodec) {
|
if (hasLowCodec) {
|
||||||
if (!hasNormalCodec && !hasHighCodec) {
|
if (!hasNormalCodec && !hasHighCodec) {
|
||||||
options.default = `${t('visual-quality-low')} (${t('default')})`;
|
options[CodecProfile.DEFAULT] = `${t('visual-quality-low')} (${t('default')})`;
|
||||||
} else {
|
} else {
|
||||||
options.low = t('visual-quality-low');
|
options[CodecProfile.LOW] = t('visual-quality-low');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasNormalCodec) {
|
if (hasNormalCodec) {
|
||||||
if (!hasLowCodec && !hasHighCodec) {
|
if (!hasLowCodec && !hasHighCodec) {
|
||||||
options.default = `${t('visual-quality-normal')} (${t('default')})`;
|
options[CodecProfile.DEFAULT] = `${t('visual-quality-normal')} (${t('default')})`;
|
||||||
} else {
|
} else {
|
||||||
options.normal = t('visual-quality-normal');
|
options[CodecProfile.NORMAL] = t('visual-quality-normal');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasHighCodec) {
|
if (hasHighCodec) {
|
||||||
if (!hasLowCodec && !hasNormalCodec) {
|
if (!hasLowCodec && !hasNormalCodec) {
|
||||||
options.default = `${t('visual-quality-high')} (${t('default')})`;
|
options[CodecProfile.DEFAULT] = `${t('visual-quality-high')} (${t('default')})`;
|
||||||
} else {
|
} else {
|
||||||
options.high = t('visual-quality-high');
|
options[CodecProfile.HIGH] = t('visual-quality-high');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,8 +135,8 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
|||||||
'da-DK': 'dansk',
|
'da-DK': 'dansk',
|
||||||
'de-DE': 'Deutsch',
|
'de-DE': 'Deutsch',
|
||||||
'el-GR': 'Ελληνικά',
|
'el-GR': 'Ελληνικά',
|
||||||
'en-GB': 'English (United Kingdom)',
|
'en-GB': 'English (UK)',
|
||||||
'en-US': 'English (United States)',
|
'en-US': 'English (US)',
|
||||||
'es-ES': 'español (España)',
|
'es-ES': 'español (España)',
|
||||||
'es-MX': 'español (Latinoamérica)',
|
'es-MX': 'español (Latinoamérica)',
|
||||||
'fi-FI': 'suomi',
|
'fi-FI': 'suomi',
|
||||||
@ -140,25 +164,31 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
|||||||
default: 'auto',
|
default: 'auto',
|
||||||
options: {
|
options: {
|
||||||
auto: t('default'),
|
auto: t('default'),
|
||||||
'720p': '720p',
|
[StreamResolution.DIM_720P]: '720p',
|
||||||
'1080p': '1080p',
|
[StreamResolution.DIM_1080P]: '1080p',
|
||||||
|
},
|
||||||
|
suggest: {
|
||||||
|
lowest: StreamResolution.DIM_720P,
|
||||||
|
highest: StreamResolution.DIM_1080P,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[PrefKey.STREAM_CODEC_PROFILE]: {
|
[PrefKey.STREAM_CODEC_PROFILE]: {
|
||||||
label: t('visual-quality'),
|
label: t('visual-quality'),
|
||||||
default: 'default',
|
default: 'default',
|
||||||
options: getSupportedCodecProfiles(),
|
options: getSupportedCodecProfiles(),
|
||||||
ready: (setting: PreferenceSetting) => {
|
ready: (setting: SettingDefinition) => {
|
||||||
const options: any = setting.options;
|
const options = (setting as any).options;
|
||||||
const keys = Object.keys(options);
|
const keys = Object.keys(options);
|
||||||
|
|
||||||
if (keys.length <= 1) { // Unsupported
|
if (keys.length <= 1) { // Unsupported
|
||||||
setting.unsupported = true;
|
setting.unsupported = true;
|
||||||
setting.note = '⚠️ ' + t('browser-unsupported-feature');
|
setting.note = '⚠️ ' + t('browser-unsupported-feature');
|
||||||
} else {
|
|
||||||
// Set default value to the best codec profile
|
|
||||||
// setting.default = keys[keys.length - 1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setting.suggest = {
|
||||||
|
lowest: keys.length === 1 ? keys[0] : keys[1],
|
||||||
|
highest: keys[keys.length - 1],
|
||||||
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[PrefKey.PREFER_IPV6_SERVER]: {
|
[PrefKey.PREFER_IPV6_SERVER]: {
|
||||||
@ -189,16 +219,16 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
|||||||
|
|
||||||
[PrefKey.STREAM_TOUCH_CONTROLLER]: {
|
[PrefKey.STREAM_TOUCH_CONTROLLER]: {
|
||||||
label: t('tc-availability'),
|
label: t('tc-availability'),
|
||||||
default: 'all',
|
default: StreamTouchController.ALL,
|
||||||
options: {
|
options: {
|
||||||
default: t('default'),
|
[StreamTouchController.DEFAULT]: t('default'),
|
||||||
all: t('tc-all-games'),
|
[StreamTouchController.ALL]: t('tc-all-games'),
|
||||||
off: t('off'),
|
[StreamTouchController.OFF]: t('off'),
|
||||||
},
|
},
|
||||||
unsupported: !STATES.userAgent.capabilities.touch,
|
unsupported: !STATES.userAgent.capabilities.touch,
|
||||||
ready: (setting: PreferenceSetting) => {
|
ready: (setting: SettingDefinition) => {
|
||||||
if (setting.unsupported) {
|
if (setting.unsupported) {
|
||||||
setting.default = 'default';
|
setting.default = StreamTouchController.DEFAULT;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -274,6 +304,9 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
suggest: {
|
||||||
|
highest: 0,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
[PrefKey.GAME_BAR_POSITION]: {
|
[PrefKey.GAME_BAR_POSITION]: {
|
||||||
@ -318,11 +351,11 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
|||||||
|
|
||||||
[PrefKey.CONTROLLER_DEVICE_VIBRATION]: {
|
[PrefKey.CONTROLLER_DEVICE_VIBRATION]: {
|
||||||
label: t('device-vibration'),
|
label: t('device-vibration'),
|
||||||
default: 'off',
|
default: ControllerDeviceVibration.OFF,
|
||||||
options: {
|
options: {
|
||||||
on: t('on'),
|
[ControllerDeviceVibration.ON]: t('on'),
|
||||||
auto: t('device-vibration-not-using-gamepad'),
|
[ControllerDeviceVibration.AUTO]: t('device-vibration-not-using-gamepad'),
|
||||||
off: t('off'),
|
[ControllerDeviceVibration.OFF]: t('off'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -346,7 +379,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
|||||||
const userAgent = ((window.navigator as any).orgUserAgent || window.navigator.userAgent || '').toLowerCase();
|
const userAgent = ((window.navigator as any).orgUserAgent || window.navigator.userAgent || '').toLowerCase();
|
||||||
return !AppInterface && userAgent.match(/(android|iphone|ipad)/) ? t('browser-unsupported-feature') : false;
|
return !AppInterface && userAgent.match(/(android|iphone|ipad)/) ? t('browser-unsupported-feature') : false;
|
||||||
})(),
|
})(),
|
||||||
ready: (setting: PreferenceSetting) => {
|
ready: (setting: SettingDefinition) => {
|
||||||
let note;
|
let note;
|
||||||
let url;
|
let url;
|
||||||
if (setting.unsupported) {
|
if (setting.unsupported) {
|
||||||
@ -372,16 +405,15 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
|||||||
on: t('on'),
|
on: t('on'),
|
||||||
off: t('off'),
|
off: t('off'),
|
||||||
},
|
},
|
||||||
ready: (setting: PreferenceSetting) => {
|
ready: (setting: SettingDefinition) => {
|
||||||
if (AppInterface) {
|
if (AppInterface) {
|
||||||
|
|
||||||
} else if (UserAgent.isMobile()) {
|
} else if (UserAgent.isMobile()) {
|
||||||
setting.unsupported = true;
|
setting.unsupported = true;
|
||||||
setting.default = 'off';
|
setting.default = 'off';
|
||||||
delete setting.options!['default'];
|
delete (setting as any).options['default'];
|
||||||
delete setting.options!['on'];
|
delete (setting as any).options['on'];
|
||||||
} else {
|
} else {
|
||||||
delete setting.options!['on'];
|
delete (setting as any).options['on'];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -530,6 +562,10 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
|||||||
[StreamPlayerType.VIDEO]: t('default'),
|
[StreamPlayerType.VIDEO]: t('default'),
|
||||||
[StreamPlayerType.WEBGL2]: t('webgl2'),
|
[StreamPlayerType.WEBGL2]: t('webgl2'),
|
||||||
},
|
},
|
||||||
|
suggest: {
|
||||||
|
lowest: StreamPlayerType.VIDEO,
|
||||||
|
highest: StreamPlayerType.WEBGL2,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
[PrefKey.VIDEO_PROCESSING]: {
|
[PrefKey.VIDEO_PROCESSING]: {
|
||||||
label: t('clarity-boost'),
|
label: t('clarity-boost'),
|
||||||
@ -538,15 +574,22 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
|||||||
[StreamVideoProcessing.USM]: t('unsharp-masking'),
|
[StreamVideoProcessing.USM]: t('unsharp-masking'),
|
||||||
[StreamVideoProcessing.CAS]: t('amd-fidelity-cas'),
|
[StreamVideoProcessing.CAS]: t('amd-fidelity-cas'),
|
||||||
},
|
},
|
||||||
|
suggest: {
|
||||||
|
lowest: StreamVideoProcessing.USM,
|
||||||
|
highest: StreamVideoProcessing.CAS,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
[PrefKey.VIDEO_POWER_PREFERENCE]: {
|
[PrefKey.VIDEO_POWER_PREFERENCE]: {
|
||||||
label: t('renderer-configuration'),
|
label: t('renderer-configuration'),
|
||||||
default: 'default',
|
default: 'default',
|
||||||
options: {
|
options: {
|
||||||
'default': t('default'),
|
'default': t('default'),
|
||||||
'low-power': t('low-power'),
|
'low-power': t('battery-saving'),
|
||||||
'high-performance': t('high-performance'),
|
'high-performance': t('high-performance'),
|
||||||
},
|
},
|
||||||
|
suggest: {
|
||||||
|
highest: 'low-power',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
[PrefKey.VIDEO_SHARPNESS]: {
|
[PrefKey.VIDEO_SHARPNESS]: {
|
||||||
label: t('sharpness'),
|
label: t('sharpness'),
|
||||||
@ -561,6 +604,10 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
|||||||
return value === 0 ? t('off') : value.toString();
|
return value === 0 ? t('off') : value.toString();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
suggest: {
|
||||||
|
lowest: 0,
|
||||||
|
highest: 4,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
[PrefKey.VIDEO_RATIO]: {
|
[PrefKey.VIDEO_RATIO]: {
|
||||||
label: t('aspect-ratio'),
|
label: t('aspect-ratio'),
|
||||||
@ -701,10 +748,10 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
|||||||
},
|
},
|
||||||
|
|
||||||
[PrefKey.REMOTE_PLAY_RESOLUTION]: {
|
[PrefKey.REMOTE_PLAY_RESOLUTION]: {
|
||||||
default: '1080p',
|
default: StreamResolution.DIM_1080P,
|
||||||
options: {
|
options: {
|
||||||
'1080p': '1080p',
|
[StreamResolution.DIM_1080P]: '1080p',
|
||||||
'720p': '720p',
|
[StreamResolution.DIM_720P]: '720p',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import { NATIVE_FETCH } from "./bx-flags";
|
|||||||
import { BxLogger } from "./bx-logger";
|
import { BxLogger } from "./bx-logger";
|
||||||
|
|
||||||
export const SUPPORTED_LANGUAGES = {
|
export const SUPPORTED_LANGUAGES = {
|
||||||
'en-US': 'English (United States)',
|
'en-US': 'English (US)',
|
||||||
|
|
||||||
'ca-CA': 'Català',
|
'ca-CA': 'Català',
|
||||||
'da-DK': 'dansk',
|
'da-DK': 'dansk',
|
||||||
@ -47,6 +47,7 @@ const Texts = {
|
|||||||
"badge-playtime": "Playtime",
|
"badge-playtime": "Playtime",
|
||||||
"badge-server": "Server",
|
"badge-server": "Server",
|
||||||
"badge-video": "Video",
|
"badge-video": "Video",
|
||||||
|
"battery-saving": "Battery saving",
|
||||||
"better-xcloud": "Better xCloud",
|
"better-xcloud": "Better xCloud",
|
||||||
"bitrate-audio-maximum": "Maximum audio bitrate",
|
"bitrate-audio-maximum": "Maximum audio bitrate",
|
||||||
"bitrate-video-maximum": "Maximum video bitrate",
|
"bitrate-video-maximum": "Maximum video bitrate",
|
||||||
@ -113,6 +114,7 @@ const Texts = {
|
|||||||
"fortnite-force-console-version": "Fortnite: force console version",
|
"fortnite-force-console-version": "Fortnite: force console version",
|
||||||
"game-bar": "Game Bar",
|
"game-bar": "Game Bar",
|
||||||
"getting-consoles-list": "Getting the list of consoles...",
|
"getting-consoles-list": "Getting the list of consoles...",
|
||||||
|
"guide": "Guide",
|
||||||
"help": "Help",
|
"help": "Help",
|
||||||
"hide": "Hide",
|
"hide": "Hide",
|
||||||
"hide-idle-cursor": "Hide mouse cursor on idle",
|
"hide-idle-cursor": "Hide mouse cursor on idle",
|
||||||
@ -121,8 +123,12 @@ const Texts = {
|
|||||||
"hide-system-menu-icon": "Hide System menu's icon",
|
"hide-system-menu-icon": "Hide System menu's icon",
|
||||||
"hide-touch-controller": "Hide touch controller",
|
"hide-touch-controller": "Hide touch controller",
|
||||||
"high-performance": "High performance",
|
"high-performance": "High performance",
|
||||||
|
"highest-quality": "Highest quality",
|
||||||
|
"highest-quality-note": "Your device may not be powerful enough to use these settings",
|
||||||
"horizontal-scroll-sensitivity": "Horizontal scroll sensitivity",
|
"horizontal-scroll-sensitivity": "Horizontal scroll sensitivity",
|
||||||
"horizontal-sensitivity": "Horizontal sensitivity",
|
"horizontal-sensitivity": "Horizontal sensitivity",
|
||||||
|
"how-to-fix": "How to fix",
|
||||||
|
"how-to-improve-app-performance": "How to improve app's performance",
|
||||||
"ignore": "Ignore",
|
"ignore": "Ignore",
|
||||||
"import": "Import",
|
"import": "Import",
|
||||||
"increase": "Increase",
|
"increase": "Increase",
|
||||||
@ -134,9 +140,10 @@ const Texts = {
|
|||||||
"large": "Large",
|
"large": "Large",
|
||||||
"layout": "Layout",
|
"layout": "Layout",
|
||||||
"left-stick": "Left stick",
|
"left-stick": "Left stick",
|
||||||
|
"load-failed-message": "Failed to run Better xCloud",
|
||||||
"loading-screen": "Loading screen",
|
"loading-screen": "Loading screen",
|
||||||
"local-co-op": "Local co-op",
|
"local-co-op": "Local co-op",
|
||||||
"low-power": "Low power",
|
"lowest-quality": "Lowest quality",
|
||||||
"map-mouse-to": "Map mouse to",
|
"map-mouse-to": "Map mouse to",
|
||||||
"may-not-work-properly": "May not work properly!",
|
"may-not-work-properly": "May not work properly!",
|
||||||
"menu": "Menu",
|
"menu": "Menu",
|
||||||
@ -150,6 +157,27 @@ const Texts = {
|
|||||||
"name": "Name",
|
"name": "Name",
|
||||||
"native-mkb": "Native Mouse & Keyboard",
|
"native-mkb": "Native Mouse & Keyboard",
|
||||||
"new": "New",
|
"new": "New",
|
||||||
|
"new-version-available": [
|
||||||
|
(e: any) => `Version ${e.version} available`,
|
||||||
|
,
|
||||||
|
,
|
||||||
|
(e: any) => `Version ${e.version} verfügbar`,
|
||||||
|
,
|
||||||
|
(e: any) => `Versión ${e.version} disponible`,
|
||||||
|
(e: any) => `Version ${e.version} disponible`,
|
||||||
|
(e: any) => `Disponibile la versione ${e.version}`,
|
||||||
|
(e: any) => `Ver ${e.version} が利用可能です`,
|
||||||
|
(e: any) => `${e.version} 버전 사용가능`,
|
||||||
|
(e: any) => `Dostępna jest nowa wersja ${e.version}`,
|
||||||
|
(e: any) => `Versão ${e.version} disponível`,
|
||||||
|
,
|
||||||
|
,
|
||||||
|
,
|
||||||
|
(e: any) => `Доступна версія ${e.version}`,
|
||||||
|
(e: any) => `Đã có phiên bản ${e.version}`,
|
||||||
|
(e: any) => `版本 ${e.version} 可供更新`,
|
||||||
|
(e: any) => `已可更新為 ${e.version} 版`,
|
||||||
|
],
|
||||||
"no-consoles-found": "No consoles found",
|
"no-consoles-found": "No consoles found",
|
||||||
"normal": "Normal",
|
"normal": "Normal",
|
||||||
"off": "Off",
|
"off": "Off",
|
||||||
@ -189,6 +217,28 @@ const Texts = {
|
|||||||
],
|
],
|
||||||
"press-to-bind": "Press a key or do a mouse click to bind...",
|
"press-to-bind": "Press a key or do a mouse click to bind...",
|
||||||
"prompt-preset-name": "Preset's name:",
|
"prompt-preset-name": "Preset's name:",
|
||||||
|
"recommended": "Recommended",
|
||||||
|
"recommended-settings-for-device": [
|
||||||
|
(e: any) => `Recommended settings for ${e.device}`,
|
||||||
|
(e: any) => `Configuració recomanada per a ${e.device}`,
|
||||||
|
,
|
||||||
|
(e: any) => `Empfohlene Einstellungen für ${e.device}`,
|
||||||
|
,
|
||||||
|
(e: any) => `Ajustes recomendados para ${e.device}`,
|
||||||
|
(e: any) => `Paramètres recommandés pour ${e.device}`,
|
||||||
|
(e: any) => `Configurazioni consigliate per ${e.device}`,
|
||||||
|
(e: any) => `${e.device} の推奨設定`,
|
||||||
|
(e: any) => `다음 기기에서 권장되는 설정: ${e.device}`,
|
||||||
|
(e: any) => `Zalecane ustawienia dla ${e.device}`,
|
||||||
|
(e: any) => `Configurações recomendadas para ${e.device}`,
|
||||||
|
(e: any) => `Рекомендуемые настройки для ${e.device}`,
|
||||||
|
,
|
||||||
|
(e: any) => `${e.device} için önerilen ayarlar`,
|
||||||
|
(e: any) => `Рекомендовані налаштування для ${e.device}`,
|
||||||
|
(e: any) => `Cấu hình được đề xuất cho ${e.device}`,
|
||||||
|
(e: any) => `${e.device} 的推荐设置`,
|
||||||
|
(e: any) => `${e.device} 推薦的設定`,
|
||||||
|
],
|
||||||
"reduce-animations": "Reduce UI animations",
|
"reduce-animations": "Reduce UI animations",
|
||||||
"region": "Region",
|
"region": "Region",
|
||||||
"reload-page": "Reload page",
|
"reload-page": "Reload page",
|
||||||
@ -202,7 +252,6 @@ const Texts = {
|
|||||||
"rocket-always-show": "Always show",
|
"rocket-always-show": "Always show",
|
||||||
"rocket-animation": "Rocket animation",
|
"rocket-animation": "Rocket animation",
|
||||||
"rocket-hide-queue": "Hide when queuing",
|
"rocket-hide-queue": "Hide when queuing",
|
||||||
"safari-failed-message": "Failed to run Better xCloud. Retrying, please wait...",
|
|
||||||
"saturation": "Saturation",
|
"saturation": "Saturation",
|
||||||
"save": "Save",
|
"save": "Save",
|
||||||
"screen": "Screen",
|
"screen": "Screen",
|
||||||
@ -250,6 +299,8 @@ const Texts = {
|
|||||||
"stream-settings": "Stream settings",
|
"stream-settings": "Stream settings",
|
||||||
"stream-stats": "Stream stats",
|
"stream-stats": "Stream stats",
|
||||||
"stretch": "Stretch",
|
"stretch": "Stretch",
|
||||||
|
"suggest-settings": "Suggest settings",
|
||||||
|
"suggest-settings-link": "Suggest recommended settings for this device",
|
||||||
"support-better-xcloud": "Support Better xCloud",
|
"support-better-xcloud": "Support Better xCloud",
|
||||||
"swap-buttons": "Swap buttons",
|
"swap-buttons": "Swap buttons",
|
||||||
"take-screenshot": "Take screenshot",
|
"take-screenshot": "Take screenshot",
|
||||||
@ -291,6 +342,7 @@ const Texts = {
|
|||||||
],
|
],
|
||||||
"touch-controller": "Touch controller",
|
"touch-controller": "Touch controller",
|
||||||
"transparent-background": "Transparent background",
|
"transparent-background": "Transparent background",
|
||||||
|
"true-achievements": "TrueAchievements",
|
||||||
"ui": "UI",
|
"ui": "UI",
|
||||||
"unexpected-behavior": "May cause unexpected behavior",
|
"unexpected-behavior": "May cause unexpected behavior",
|
||||||
"united-states": "United States",
|
"united-states": "United States",
|
||||||
@ -314,6 +366,7 @@ const Texts = {
|
|||||||
"volume": "Volume",
|
"volume": "Volume",
|
||||||
"wait-time-countdown": "Countdown",
|
"wait-time-countdown": "Countdown",
|
||||||
"wait-time-estimated": "Estimated finish time",
|
"wait-time-estimated": "Estimated finish time",
|
||||||
|
"wallpaper": "Wallpaper",
|
||||||
"webgl2": "WebGL2",
|
"webgl2": "WebGL2",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
150
src/utils/true-achievements.ts
Normal file
150
src/utils/true-achievements.ts
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
import { BxIcon } from "./bx-icon";
|
||||||
|
import { AppInterface, STATES } from "./global";
|
||||||
|
import { ButtonStyle, CE, clearDataSet, createButton, getReactProps } from "./html";
|
||||||
|
import { t } from "./translation";
|
||||||
|
|
||||||
|
export class TrueAchievements {
|
||||||
|
private static $link = createButton({
|
||||||
|
label: t('true-achievements'),
|
||||||
|
url: '#',
|
||||||
|
icon: BxIcon.TRUE_ACHIEVEMENTS,
|
||||||
|
style: ButtonStyle.FOCUSABLE | ButtonStyle.GHOST | ButtonStyle.FULL_WIDTH | ButtonStyle.NORMAL_LINK,
|
||||||
|
onClick: TrueAchievements.onClick,
|
||||||
|
}) as HTMLAnchorElement;
|
||||||
|
|
||||||
|
static $button = createButton({
|
||||||
|
label: t('true-achievements'),
|
||||||
|
title: t('true-achievements'),
|
||||||
|
icon: BxIcon.TRUE_ACHIEVEMENTS,
|
||||||
|
style: ButtonStyle.FOCUSABLE,
|
||||||
|
onClick: TrueAchievements.onClick,
|
||||||
|
}) as HTMLAnchorElement;
|
||||||
|
|
||||||
|
private static onClick(e: Event) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const dataset = TrueAchievements.$link.dataset;
|
||||||
|
TrueAchievements.open(true, dataset.xboxTitleId, dataset.id);
|
||||||
|
|
||||||
|
// Close all xCloud's dialogs
|
||||||
|
window.BX_EXPOSED.dialogRoutes.closeAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static $hiddenLink = CE<HTMLAnchorElement>('a', {
|
||||||
|
target: '_blank',
|
||||||
|
});
|
||||||
|
|
||||||
|
private static updateIds(xboxTitleId?: string, id?: string) {
|
||||||
|
const $link = TrueAchievements.$link;
|
||||||
|
const $button = TrueAchievements.$button;
|
||||||
|
|
||||||
|
clearDataSet($link);
|
||||||
|
clearDataSet($button);
|
||||||
|
|
||||||
|
if (xboxTitleId) {
|
||||||
|
$link.dataset.xboxTitleId = xboxTitleId;
|
||||||
|
$button.dataset.xboxTitleId = xboxTitleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id) {
|
||||||
|
$link.dataset.id = id;
|
||||||
|
$button.dataset.id = id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static injectAchievementsProgress($elm: HTMLElement) {
|
||||||
|
const $parent = $elm.parentElement!;
|
||||||
|
|
||||||
|
// Wrap xCloud's element with our own
|
||||||
|
const $div = CE('div', {
|
||||||
|
class: 'bx-guide-home-achievements-progress',
|
||||||
|
}, $elm);
|
||||||
|
|
||||||
|
// Get xboxTitleId of the game
|
||||||
|
let xboxTitleId: string | number | undefined;
|
||||||
|
try {
|
||||||
|
const $container = $parent.closest('div[class*=AchievementsPreview-module__container]') as HTMLElement;
|
||||||
|
if ($container) {
|
||||||
|
const props = getReactProps($container);
|
||||||
|
xboxTitleId = props.children.props.data.data.xboxTitleId;
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
if (!xboxTitleId) {
|
||||||
|
xboxTitleId = TrueAchievements.getStreamXboxTitleId();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof xboxTitleId !== 'undefined') {
|
||||||
|
xboxTitleId = xboxTitleId.toString();
|
||||||
|
}
|
||||||
|
TrueAchievements.updateIds(xboxTitleId);
|
||||||
|
|
||||||
|
if (document.documentElement.dataset.xdsPlatform === 'tv') {
|
||||||
|
$div.appendChild(TrueAchievements.$link);
|
||||||
|
} else {
|
||||||
|
$div.appendChild(TrueAchievements.$button);
|
||||||
|
}
|
||||||
|
|
||||||
|
$parent.appendChild($div);
|
||||||
|
}
|
||||||
|
|
||||||
|
static injectAchievementDetailPage($parent: HTMLElement) {
|
||||||
|
const props = getReactProps($parent);
|
||||||
|
if (!props) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Achievement list
|
||||||
|
const achievementList: XboxAchievement[] = props.children.props.data.data;
|
||||||
|
|
||||||
|
// Get current achievement name
|
||||||
|
const $header = $parent.querySelector('div[class*=AchievementDetailHeader]') as HTMLElement;
|
||||||
|
const achievementName = getReactProps($header).children[0].props.achievementName;
|
||||||
|
|
||||||
|
// Find achievement based on name
|
||||||
|
let id: string | undefined;
|
||||||
|
let xboxTitleId: string | undefined;
|
||||||
|
for (const achiev of achievementList) {
|
||||||
|
if (achiev.name === achievementName) {
|
||||||
|
id = achiev.id;
|
||||||
|
xboxTitleId = achiev.title.id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Found achievement -> add TrueAchievements button
|
||||||
|
if (id) {
|
||||||
|
TrueAchievements.updateIds(xboxTitleId, id);
|
||||||
|
$parent.appendChild(TrueAchievements.$link);
|
||||||
|
}
|
||||||
|
} catch (e) {};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static getStreamXboxTitleId() : number | undefined {
|
||||||
|
return STATES.currentStream.xboxTitleId || STATES.currentStream.titleInfo?.details.xboxTitleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
static open(override: boolean, xboxTitleId?: number | string, id?: number | string) {
|
||||||
|
if (!xboxTitleId || xboxTitleId === 'undefined') {
|
||||||
|
xboxTitleId = TrueAchievements.getStreamXboxTitleId();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AppInterface && AppInterface.openTrueAchievementsLink) {
|
||||||
|
AppInterface.openTrueAchievementsLink(override, xboxTitleId?.toString(), id?.toString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let url = 'https://www.trueachievements.com';
|
||||||
|
if (xboxTitleId) {
|
||||||
|
url += `/deeplink/${xboxTitleId}`;
|
||||||
|
|
||||||
|
if (id) {
|
||||||
|
url += `/${id}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TrueAchievements.$hiddenLink.href = url;
|
||||||
|
TrueAchievements.$hiddenLink.click();
|
||||||
|
}
|
||||||
|
}
|
@ -110,3 +110,13 @@ export async function copyToClipboard(text: string, showToast=true): Promise<boo
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function productTitleToSlug(title: string): string {
|
||||||
|
return title.replace(/[;,/?:@&=+_`~$%#^*()!^\u2122\xae\xa9]/g, '')
|
||||||
|
.replace(/\|/g, '-')
|
||||||
|
.replace(/ {2,}/g, ' ')
|
||||||
|
.trim()
|
||||||
|
.substr(0, 50)
|
||||||
|
.replace(/ /g, '-')
|
||||||
|
.toLowerCase();
|
||||||
|
}
|
||||||
|
25
src/utils/xbox-api.ts
Normal file
25
src/utils/xbox-api.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { NATIVE_FETCH } from "./bx-flags"
|
||||||
|
|
||||||
|
export class XboxApi {
|
||||||
|
private static CACHED_TITLES: Record<string, string> = {};
|
||||||
|
|
||||||
|
static async getProductTitle(xboxTitleId: number | string): Promise<string | null> {
|
||||||
|
xboxTitleId = xboxTitleId.toString();
|
||||||
|
if (XboxApi.CACHED_TITLES[xboxTitleId]) {
|
||||||
|
return XboxApi.CACHED_TITLES[xboxTitleId];
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const url = `https://displaycatalog.mp.microsoft.com/v7.0/products/lookup?market=US&languages=en&value=${xboxTitleId}&alternateId=XboxTitleId&fieldsTemplate=browse`;
|
||||||
|
const resp = await NATIVE_FETCH(url);
|
||||||
|
const json = await resp.json();
|
||||||
|
|
||||||
|
const productTitle = json['Products'][0]['LocalizedProperties'][0]['ProductTitle'];
|
||||||
|
XboxApi.CACHED_TITLES[xboxTitleId] = productTitle;
|
||||||
|
|
||||||
|
return productTitle;
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
import { LoadingScreen } from "@modules/loading-screen";
|
import { LoadingScreen } from "@modules/loading-screen";
|
||||||
import { RemotePlay } from "@modules/remote-play";
|
import { RemotePlayManager } from "@/modules/remote-play-manager";
|
||||||
import { StreamBadges } from "@modules/stream/stream-badges";
|
import { StreamBadges } from "@modules/stream/stream-badges";
|
||||||
import { TouchController } from "@modules/touch-controller";
|
import { TouchController } from "@modules/touch-controller";
|
||||||
import { BxEvent } from "./bx-event";
|
import { BxEvent } from "./bx-event";
|
||||||
@ -9,7 +9,7 @@ import { patchIceCandidates } from "./network";
|
|||||||
import { getPreferredServerRegion } from "./region";
|
import { getPreferredServerRegion } from "./region";
|
||||||
import { BypassServerIps } from "@/enums/bypass-servers";
|
import { BypassServerIps } from "@/enums/bypass-servers";
|
||||||
import { PrefKey } from "@/enums/pref-keys";
|
import { PrefKey } from "@/enums/pref-keys";
|
||||||
import { getPref } from "./settings-storages/global-settings-storage";
|
import { getPref, StreamResolution, StreamTouchController } from "./settings-storages/global-settings-storage";
|
||||||
|
|
||||||
export
|
export
|
||||||
class XcloudInterceptor {
|
class XcloudInterceptor {
|
||||||
@ -30,7 +30,7 @@ class XcloudInterceptor {
|
|||||||
const obj = await response.clone().json();
|
const obj = await response.clone().json();
|
||||||
|
|
||||||
// Store xCloud token
|
// Store xCloud token
|
||||||
RemotePlay.XCLOUD_TOKEN = obj.gsToken;
|
RemotePlayManager.getInstance().xcloudToken = obj.gsToken;
|
||||||
|
|
||||||
// Get server list
|
// Get server list
|
||||||
const serverEmojis = {
|
const serverEmojis = {
|
||||||
@ -111,7 +111,7 @@ class XcloudInterceptor {
|
|||||||
|
|
||||||
// Force stream's resolution
|
// Force stream's resolution
|
||||||
if (PREF_STREAM_TARGET_RESOLUTION !== 'auto') {
|
if (PREF_STREAM_TARGET_RESOLUTION !== 'auto') {
|
||||||
const osName = (PREF_STREAM_TARGET_RESOLUTION === '720p') ? 'android' : 'windows';
|
const osName = (PREF_STREAM_TARGET_RESOLUTION === StreamResolution.DIM_720P) ? 'android' : 'windows';
|
||||||
body.settings.osName = osName;
|
body.settings.osName = osName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ class XcloudInterceptor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Touch controller for all games
|
// Touch controller for all games
|
||||||
if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === 'all') {
|
if (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();
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { RemotePlay } from "@/modules/remote-play";
|
|
||||||
import { TouchController } from "@/modules/touch-controller";
|
import { TouchController } from "@/modules/touch-controller";
|
||||||
import { BxEvent } from "./bx-event";
|
import { BxEvent } from "./bx-event";
|
||||||
import { SupportedInputType } from "./bx-exposed";
|
import { SupportedInputType } from "./bx-exposed";
|
||||||
@ -6,12 +5,53 @@ import { NATIVE_FETCH } from "./bx-flags";
|
|||||||
import { STATES } from "./global";
|
import { STATES } from "./global";
|
||||||
import { patchIceCandidates } from "./network";
|
import { patchIceCandidates } from "./network";
|
||||||
import { PrefKey } from "@/enums/pref-keys";
|
import { PrefKey } from "@/enums/pref-keys";
|
||||||
import { getPref } from "./settings-storages/global-settings-storage";
|
import { getPref, StreamResolution, StreamTouchController } from "./settings-storages/global-settings-storage";
|
||||||
import type { RemotePlayConsoleAddresses } from "@/types/network";
|
import type { RemotePlayConsoleAddresses } from "@/types/network";
|
||||||
|
import { RemotePlayManager } from "@/modules/remote-play-manager";
|
||||||
|
|
||||||
export class XhomeInterceptor {
|
export class XhomeInterceptor {
|
||||||
static #consoleAddrs: RemotePlayConsoleAddresses = {};
|
static #consoleAddrs: RemotePlayConsoleAddresses = {};
|
||||||
|
|
||||||
|
private static readonly BASE_DEVICE_INFO = {
|
||||||
|
appInfo: {
|
||||||
|
env: {
|
||||||
|
clientAppId: window.location.host,
|
||||||
|
clientAppType: 'browser',
|
||||||
|
clientAppVersion: '24.17.36',
|
||||||
|
clientSdkVersion: '10.1.14',
|
||||||
|
httpEnvironment: 'prod',
|
||||||
|
sdkInstallId: '',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
dev: {
|
||||||
|
displayInfo: {
|
||||||
|
dimensions: {
|
||||||
|
widthInPixels: 1920,
|
||||||
|
heightInPixels: 1080,
|
||||||
|
},
|
||||||
|
pixelDensity: {
|
||||||
|
dpiX: 1,
|
||||||
|
dpiY: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
hw: {
|
||||||
|
make: 'Microsoft',
|
||||||
|
model: 'unknown',
|
||||||
|
sdktype: 'web',
|
||||||
|
},
|
||||||
|
os: {
|
||||||
|
name: 'windows',
|
||||||
|
ver: '22631.2715',
|
||||||
|
platform: 'desktop',
|
||||||
|
},
|
||||||
|
browser: {
|
||||||
|
browserName: 'chrome',
|
||||||
|
browserVersion: '125.0',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
static async #handleLogin(request: Request) {
|
static async #handleLogin(request: Request) {
|
||||||
try {
|
try {
|
||||||
const clone = (request as Request).clone();
|
const clone = (request as Request).clone();
|
||||||
@ -42,7 +82,7 @@ export class XhomeInterceptor {
|
|||||||
|
|
||||||
const processPorts = (port: number): number[] => {
|
const processPorts = (port: number): number[] => {
|
||||||
const ports = new Set<number>();
|
const ports = new Set<number>();
|
||||||
ports.add(port);
|
port && ports.add(port);
|
||||||
ports.add(9002);
|
ports.add(9002);
|
||||||
|
|
||||||
return Array.from(ports);
|
return Array.from(ports);
|
||||||
@ -70,7 +110,7 @@ export class XhomeInterceptor {
|
|||||||
static async #handleInputConfigs(request: Request | URL, opts: {[index: string]: any}) {
|
static async #handleInputConfigs(request: Request | URL, opts: {[index: string]: any}) {
|
||||||
const response = await NATIVE_FETCH(request);
|
const response = await NATIVE_FETCH(request);
|
||||||
|
|
||||||
if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) !== 'all') {
|
if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) !== StreamTouchController.ALL) {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +151,7 @@ export class XhomeInterceptor {
|
|||||||
for (const pair of (clone.headers as any).entries()) {
|
for (const pair of (clone.headers as any).entries()) {
|
||||||
headers[pair[0]] = pair[1];
|
headers[pair[0]] = pair[1];
|
||||||
}
|
}
|
||||||
headers.authorization = `Bearer ${RemotePlay.XCLOUD_TOKEN}`;
|
headers.authorization = `Bearer ${RemotePlayManager.getInstance().xcloudToken}`;
|
||||||
|
|
||||||
const index = request.url.indexOf('.xboxlive.com');
|
const index = request.url.indexOf('.xboxlive.com');
|
||||||
request = new Request('https://wus.core.gssv-play-prod' + request.url.substring(index), {
|
request = new Request('https://wus.core.gssv-play-prod' + request.url.substring(index), {
|
||||||
@ -146,11 +186,11 @@ export class XhomeInterceptor {
|
|||||||
headers[pair[0]] = pair[1];
|
headers[pair[0]] = pair[1];
|
||||||
}
|
}
|
||||||
// Add xHome token to headers
|
// Add xHome token to headers
|
||||||
headers.authorization = `Bearer ${RemotePlay.XHOME_TOKEN}`;
|
headers.authorization = `Bearer ${RemotePlayManager.getInstance().xhomeToken}`;
|
||||||
|
|
||||||
// Patch resolution
|
// Patch resolution
|
||||||
const deviceInfo = RemotePlay.BASE_DEVICE_INFO;
|
const deviceInfo = XhomeInterceptor.BASE_DEVICE_INFO;
|
||||||
if (getPref(PrefKey.REMOTE_PLAY_RESOLUTION) === '720p') {
|
if (getPref(PrefKey.REMOTE_PLAY_RESOLUTION) === StreamResolution.DIM_720P) {
|
||||||
deviceInfo.dev.os.name = 'android';
|
deviceInfo.dev.os.name = 'android';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import type { NavigationElement } from "@/modules/ui/dialog/navigation-dialog";
|
import type { NavigationElement } from "@/modules/ui/dialog/navigation-dialog";
|
||||||
|
import { BxEvent } from "@/utils/bx-event";
|
||||||
|
import type { BxSelectSettingElement } from "@/utils/setting-element";
|
||||||
import { ButtonStyle, CE, createButton } from "@utils/html";
|
import { ButtonStyle, CE, createButton } from "@utils/html";
|
||||||
|
|
||||||
export class BxSelectElement {
|
export class BxSelectElement {
|
||||||
@ -40,7 +42,7 @@ export class BxSelectElement {
|
|||||||
const $option = getOptionAtIndex(visibleIndex);
|
const $option = getOptionAtIndex(visibleIndex);
|
||||||
$option && ($option.selected = (e.target as HTMLInputElement).checked);
|
$option && ($option.selected = (e.target as HTMLInputElement).checked);
|
||||||
|
|
||||||
$select.dispatchEvent(new Event('input'));
|
BxEvent.dispatch($select, 'input');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$content = CE('div', {},
|
$content = CE('div', {},
|
||||||
@ -122,7 +124,7 @@ export class BxSelectElement {
|
|||||||
if (isMultiple) {
|
if (isMultiple) {
|
||||||
render();
|
render();
|
||||||
} else {
|
} else {
|
||||||
$select.dispatchEvent(new Event('input'));
|
BxEvent.dispatch($select, 'input');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -162,6 +164,10 @@ export class BxSelectElement {
|
|||||||
Object.defineProperty($div, 'value', {
|
Object.defineProperty($div, 'value', {
|
||||||
get() {
|
get() {
|
||||||
return $select.value;
|
return $select.value;
|
||||||
|
},
|
||||||
|
|
||||||
|
set(value) {
|
||||||
|
($div as any).setValue(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -178,7 +184,15 @@ export class BxSelectElement {
|
|||||||
$div.dispatchEvent = function() {
|
$div.dispatchEvent = function() {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
return $select.dispatchEvent.apply($select, arguments);
|
return $select.dispatchEvent.apply($select, arguments);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
($div as any).setValue = (value: any) => {
|
||||||
|
if ('setValue' in $select) {
|
||||||
|
($select as BxSelectSettingElement).setValue(value);
|
||||||
|
} else {
|
||||||
|
$select.value = value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return $div;
|
return $div;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user