mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-03 06:07:19 +02:00
Game-specific settings (#623)
This commit is contained in:
parent
91c8172564
commit
e3f971845f
9
build.ts
9
build.ts
@ -21,6 +21,7 @@ enum BuildTarget {
|
||||
type BuildVariant = 'full' | 'lite';
|
||||
|
||||
const MINIFY_SYNTAX = true;
|
||||
const INDENT_SPACES = false;
|
||||
|
||||
function minifySvgImports(str: string): string {
|
||||
// Minify SVG imports
|
||||
@ -128,8 +129,12 @@ function postProcess(str: string): string {
|
||||
str = minifyIfElse(str);
|
||||
|
||||
str = str.replaceAll(/\n(\s+)/g, (match, p1) => {
|
||||
const len = p1.length / 2;
|
||||
return '\n' + ' '.repeat(len);
|
||||
if (INDENT_SPACES) {
|
||||
const len = p1.length / 2;
|
||||
return '\n' + ' '.repeat(len);
|
||||
} else {
|
||||
return '\n';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
20
bun.lock
Executable file → Normal file
20
bun.lock
Executable file → Normal file
@ -1,5 +1,5 @@
|
||||
{
|
||||
"lockfileVersion": 0,
|
||||
"lockfileVersion": 1,
|
||||
"workspaces": {
|
||||
"": {
|
||||
"devDependencies": {
|
||||
@ -24,15 +24,15 @@
|
||||
|
||||
"@eslint/config-array": ["@eslint/config-array@0.19.0", "", { "dependencies": { "@eslint/object-schema": "^2.1.4", "debug": "^4.3.1", "minimatch": "^3.1.2" } }, "sha512-zdHg2FPIFNKPdcHWtiNT+jEFCHYVplAXRDlQDyqy0zGx/q2parwh7brGJSiTxRk/TSMkbM//zt/f5CHgyTyaSQ=="],
|
||||
|
||||
"@eslint/core": ["@eslint/core@0.9.0", "", {}, "sha512-7ATR9F0e4W85D/0w7cU0SNj7qkAexMG+bAHEZOjo9akvGuhHE2m7umzWzfnpa0XAg5Kxc1BWmtPMV67jJ+9VUg=="],
|
||||
"@eslint/core": ["@eslint/core@0.10.0", "", { "dependencies": { "@types/json-schema": "^7.0.15" } }, "sha512-gFHJ+xBOo4G3WRlR1e/3G8A6/KZAH6zcE/hkLRCZTi/B9avAG365QhFA8uOGzTMqgTghpn7/fSnscW++dpMSAw=="],
|
||||
|
||||
"@eslint/eslintrc": ["@eslint/eslintrc@3.2.0", "", { "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", "espree": "^10.0.1", "globals": "^14.0.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", "minimatch": "^3.1.2", "strip-json-comments": "^3.1.1" } }, "sha512-grOjVNN8P3hjJn/eIETF1wwd12DdnwFDoyceUJLYYdkpbwq3nLi+4fqrTAONx7XDALqlL220wC/RHSC/QTI/0w=="],
|
||||
|
||||
"@eslint/js": ["@eslint/js@9.17.0", "", {}, "sha512-Sxc4hqcs1kTu0iID3kcZDW3JHq2a77HO9P8CP6YEA/FpH3Ll8UXE2r/86Rz9YJLKme39S9vU5OWNjC6Xl0Cr3w=="],
|
||||
"@eslint/js": ["@eslint/js@9.19.0", "", {}, "sha512-rbq9/g38qjfqFLOVPvwjIvFFdNziEC5S65jmjPw5r6A//QH+W91akh9irMwjDN8zKUTak6W9EsAv4m/7Wnw0UQ=="],
|
||||
|
||||
"@eslint/object-schema": ["@eslint/object-schema@2.1.4", "", {}, "sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ=="],
|
||||
|
||||
"@eslint/plugin-kit": ["@eslint/plugin-kit@0.2.3", "", { "dependencies": { "levn": "^0.4.1" } }, "sha512-2b/g5hRmpbb1o4GnTZax9N9m0FXzz9OV42ZzI4rDDMDuHUqigAiQCEWChBWCY4ztAGVRjoWT19v0yMmc5/L5kA=="],
|
||||
"@eslint/plugin-kit": ["@eslint/plugin-kit@0.2.5", "", { "dependencies": { "@eslint/core": "^0.10.0", "levn": "^0.4.1" } }, "sha512-lB05FkqEdUg2AA0xEbUz0SnkXT1LcCTa438W4IWTUh4hdOnVbQyOJ81OrDXsJk/LSiJHubgGEFoR5EHq1NsH1A=="],
|
||||
|
||||
"@humanfs/core": ["@humanfs/core@0.19.1", "", {}, "sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA=="],
|
||||
|
||||
@ -48,13 +48,13 @@
|
||||
|
||||
"@pkgjs/parseargs": ["@pkgjs/parseargs@0.11.0", "", {}, "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg=="],
|
||||
|
||||
"@types/bun": ["@types/bun@1.1.14", "", { "dependencies": { "bun-types": "1.1.37" } }, "sha512-opVYiFGtO2af0dnWBdZWlioLBoxSdDO5qokaazLhq8XQtGZbY4pY3/JxY8Zdf/hEwGubbp7ErZXoN1+h2yesxA=="],
|
||||
"@types/bun": ["@types/bun@1.2.0", "", { "dependencies": { "bun-types": "1.2.0" } }, "sha512-5N1JqdahfpBlAv4wy6svEYcd/YfO2GNrbL95JOmFx8nkE6dbK4R0oSE5SpBA4vBRqgrOUAXF8Dpiz+gi7r80SA=="],
|
||||
|
||||
"@types/estree": ["@types/estree@1.0.6", "", {}, "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw=="],
|
||||
|
||||
"@types/json-schema": ["@types/json-schema@7.0.15", "", {}, "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA=="],
|
||||
|
||||
"@types/node": ["@types/node@22.10.2", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ=="],
|
||||
"@types/node": ["@types/node@22.10.10", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-X47y/mPNzxviAGY5TcYPtYL8JsY3kAq2n8fMmKoRCxq/c4v4pyGNCzM2R6+M5/umG4ZfHuT+sgqDYqWc9rJ6ww=="],
|
||||
|
||||
"@types/stylus": ["@types/stylus@0.48.43", "", { "dependencies": { "@types/node": "*" } }, "sha512-72dv/zdhuyXWVHUXG2VTPEQdOG+oen95/DNFx2aMFFaY6LoITI6PwEqf5x31JF49kp2w9hvUzkNfTGBIeg61LQ=="],
|
||||
|
||||
@ -80,7 +80,7 @@
|
||||
|
||||
"browserslist": ["browserslist@4.24.3", "", { "dependencies": { "caniuse-lite": "^1.0.30001688", "electron-to-chromium": "^1.5.73", "node-releases": "^2.0.19", "update-browserslist-db": "^1.1.1" }, "bin": { "browserslist": "cli.js" } }, "sha512-1CPmv8iobE2fyRMV97dAcMVegvvWKxmq94hkLiAkUGwKVTyDLw33K+ZxiFrREKmmps4rIw6grcCFCnTMSZ/YiA=="],
|
||||
|
||||
"bun-types": ["bun-types@1.1.37", "", { "dependencies": { "@types/node": "~20.12.8", "@types/ws": "~8.5.10" } }, "sha512-C65lv6eBr3LPJWFZ2gswyrGZ82ljnH8flVE03xeXxKhi2ZGtFiO4isRKTKnitbSqtRAcaqYSR6djt1whI66AbA=="],
|
||||
"bun-types": ["bun-types@1.2.0", "", { "dependencies": { "@types/node": "*", "@types/ws": "~8.5.10" } }, "sha512-KEaJxyZfbV/c4eyG0vyehDpYmBGreNiQbZIqvVHJwZ4BmeuWlNZ7EAzMN2Zcd7ailmS/tGVW0BgYbGf+lGEpWw=="],
|
||||
|
||||
"callsites": ["callsites@3.1.0", "", {}, "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ=="],
|
||||
|
||||
@ -110,7 +110,7 @@
|
||||
|
||||
"escape-string-regexp": ["escape-string-regexp@4.0.0", "", {}, "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA=="],
|
||||
|
||||
"eslint": ["eslint@9.17.0", "", { "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", "@eslint/config-array": "^0.19.0", "@eslint/core": "^0.9.0", "@eslint/eslintrc": "^3.2.0", "@eslint/js": "9.17.0", "@eslint/plugin-kit": "^0.2.3", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.1", "@types/estree": "^1.0.6", "@types/json-schema": "^7.0.15", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.6", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", "eslint-scope": "^8.2.0", "eslint-visitor-keys": "^4.2.0", "espree": "^10.3.0", "esquery": "^1.5.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^8.0.0", "find-up": "^5.0.0", "glob-parent": "^6.0.2", "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "json-stable-stringify-without-jsonify": "^1.0.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.3" }, "peerDependencies": { "jiti": "*" }, "optionalPeers": ["jiti"], "bin": { "eslint": "bin/eslint.js" } }, "sha512-evtlNcpJg+cZLcnVKwsai8fExnqjGPicK7gnUtlNuzu+Fv9bI0aLpND5T44VLQtoMEnI57LoXO9XAkIXwohKrA=="],
|
||||
"eslint": ["eslint@9.19.0", "", { "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", "@eslint/config-array": "^0.19.0", "@eslint/core": "^0.10.0", "@eslint/eslintrc": "^3.2.0", "@eslint/js": "9.19.0", "@eslint/plugin-kit": "^0.2.5", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.1", "@types/estree": "^1.0.6", "@types/json-schema": "^7.0.15", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.6", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", "eslint-scope": "^8.2.0", "eslint-visitor-keys": "^4.2.0", "espree": "^10.3.0", "esquery": "^1.5.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^8.0.0", "find-up": "^5.0.0", "glob-parent": "^6.0.2", "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "json-stable-stringify-without-jsonify": "^1.0.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.3" }, "peerDependencies": { "jiti": "*" }, "optionalPeers": ["jiti"], "bin": { "eslint": "bin/eslint.js" } }, "sha512-ug92j0LepKlbbEv6hD911THhoRHmbdXt2gX+VDABAW/Ir7D3nqKdv5Pf5vtlyY6HQMTEP2skXY43ueqTCWssEA=="],
|
||||
|
||||
"eslint-plugin-compat": ["eslint-plugin-compat@6.0.2", "", { "dependencies": { "@mdn/browser-compat-data": "^5.5.35", "ast-metadata-inferer": "^0.8.1", "browserslist": "^4.24.2", "caniuse-lite": "^1.0.30001687", "find-up": "^5.0.0", "globals": "^15.7.0", "lodash.memoize": "^4.1.2", "semver": "^7.6.2" }, "peerDependencies": { "eslint": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0" } }, "sha512-1ME+YfJjmOz1blH0nPZpHgjMGK4kjgEeoYqGCqoBPQ/mGu/dJzdoP0f1C8H2jcWZjzhZjAMccbM/VdXhPORIfA=="],
|
||||
|
||||
@ -280,8 +280,6 @@
|
||||
|
||||
"ast-metadata-inferer/@mdn/browser-compat-data": ["@mdn/browser-compat-data@5.6.26", "", {}, "sha512-7NdgdOR7lkzrN70zGSULmrcvKyi/aJjpTJRCbuy8IZuHiLkPTvsr10jW0MJgWzK2l2wTmhdQvegTw6yNU5AVNQ=="],
|
||||
|
||||
"bun-types/@types/node": ["@types/node@20.12.14", "", { "dependencies": { "undici-types": "~5.26.4" } }, "sha512-scnD59RpYD91xngrQQLGkE+6UrHUPzeKZWhhjBSa3HSkwjbQc38+q3RoIVEwxQGRw3M+j5hpNAM+lgV3cVormg=="],
|
||||
|
||||
"foreground-child/cross-spawn": ["cross-spawn@7.0.3", "", { "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w=="],
|
||||
|
||||
"glob/minimatch": ["minimatch@9.0.5", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow=="],
|
||||
@ -302,8 +300,6 @@
|
||||
|
||||
"@types/ws/@types/node/undici-types": ["undici-types@5.26.5", "", {}, "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="],
|
||||
|
||||
"bun-types/@types/node/undici-types": ["undici-types@5.26.5", "", {}, "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="],
|
||||
|
||||
"glob/minimatch/brace-expansion": ["brace-expansion@2.0.1", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA=="],
|
||||
|
||||
"string-width-cjs/strip-ansi/ansi-regex": ["ansi-regex@5.0.1", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="],
|
||||
|
@ -10,10 +10,10 @@
|
||||
"build": "build.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "^1.1.14",
|
||||
"@types/node": "^22.10.2",
|
||||
"@types/bun": "^1.2.0",
|
||||
"@types/node": "^22.10.10",
|
||||
"@types/stylus": "^0.48.43",
|
||||
"eslint": "^9.17.0",
|
||||
"eslint": "^9.19.0",
|
||||
"eslint-plugin-compat": "^6.0.2",
|
||||
"stylus": "^0.64.0"
|
||||
},
|
||||
|
@ -37,6 +37,7 @@
|
||||
&:disabled {
|
||||
cursor: default;
|
||||
background-color: unquote('rgb(var(--button-disabled-rgb))');
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
&.bx-ghost {
|
||||
|
@ -25,7 +25,7 @@ button_color(name, normal, hover, active, disabled)
|
||||
button_color('default', #2d3036, #515863, #222428, #8e8e8e);
|
||||
button_color('primary', #008746, #04b358, #044e2a, #448262);
|
||||
button_color('warning', #c16e04, #fa9005, #965603, #a2816c);
|
||||
button_color('danger', #c10404, #e61d1d, #a26c6c, #df5656);
|
||||
button_color('danger', #c10404, #e61d1d, #a26c6c, #bd8282);
|
||||
|
||||
--bx-fullscreen-text-z-index: 9999;
|
||||
--bx-toast-z-index: 6000;
|
||||
@ -47,7 +47,7 @@ button_color(name, normal, hover, active, disabled)
|
||||
@font-face {
|
||||
font-family: 'promptfont';
|
||||
src: url('https://redphx.github.io/better-xcloud/fonts/promptfont.otf');
|
||||
unicode-range: U+2196-E011;
|
||||
unicode-range: U+2196-E011, U+27F6, U+FF31;
|
||||
}
|
||||
|
||||
/* Fix Stream menu buttons not hiding */
|
||||
|
@ -98,10 +98,8 @@
|
||||
tabsWidth = 48px;
|
||||
|
||||
flex-direction: column;
|
||||
padding: 10px;
|
||||
margin-left: tabsWidth;
|
||||
width: 450px;
|
||||
max-width: calc(100vw - tabsWidth);
|
||||
background: #1a1b1e;
|
||||
color: #fff;
|
||||
font-weight: 400;
|
||||
@ -112,13 +110,6 @@
|
||||
overflow: overlay;
|
||||
z-index: 1;
|
||||
|
||||
> div[data-tab-group=mkb] {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.bx-top-buttons {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@ -284,7 +275,8 @@
|
||||
color: #828282;
|
||||
}
|
||||
|
||||
.bx-settings-tab-contents {
|
||||
.bx-settings-tab-content {
|
||||
padding: 10px;
|
||||
border-radius-size = 6px;
|
||||
|
||||
> div {
|
||||
@ -307,6 +299,14 @@
|
||||
border-radius: border-radius-size;
|
||||
}
|
||||
}
|
||||
|
||||
&:not([data-game-id="-1"]) {
|
||||
.bx-settings-row[data-override=true], .bx-settings-row:has(*[data-override=true]) {
|
||||
border-left: 4px solid orange !important;
|
||||
border-top-left-radius: 0 !important;
|
||||
border-bottom-left-radius: 0 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.bx-suggest-toggler {
|
||||
@ -533,3 +533,53 @@
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.bx-stream-settings-selection {
|
||||
margin-bottom: 8px;
|
||||
position: sticky;
|
||||
z-index: 1000;
|
||||
top: 0;
|
||||
|
||||
> div {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
background: #222222;
|
||||
padding: 10px;
|
||||
border-bottom: 4px solid #353638;
|
||||
box-shadow: 0 0 6px #000;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
|
||||
.bx-select {
|
||||
flex: 1;
|
||||
|
||||
label {
|
||||
font-weight: bold;
|
||||
font-size: 1.1rem;
|
||||
line-height: initial;
|
||||
|
||||
span {
|
||||
line-height: initial;
|
||||
}
|
||||
}
|
||||
|
||||
.bx-select-indicators {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
p {
|
||||
font-family: var(--bx-promptfont-font), var(--bx-normal-font);
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
background: #505050f2;
|
||||
height: 25px;
|
||||
line-height: 23px;
|
||||
position: absolute;
|
||||
bottom: -25px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
text-shadow: 0 1px #000;
|
||||
}
|
||||
}
|
||||
|
6
src/assets/svg/global-restore.svg
Normal file
6
src/assets/svg/global-restore.svg
Normal file
@ -0,0 +1,6 @@
|
||||
<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='M1.681 16h28.638'/>
|
||||
<path d='M16 30.319C8.145 30.319 1.681 23.855 1.681 16S8.145 1.681 16 1.681 30.319 8.145 30.319 16'/>
|
||||
<path d='M16 30.319S10.034 25.546 10.034 16 16 1.681 16 1.681 21.966 6.454 21.966 16m-.238 8.592l-2.864 2.864 2.864 2.863'/>
|
||||
<path d='M21.728 20.773h5.25a3.36 3.36 0 0 1 3.341 3.341 3.36 3.36 0 0 1-3.341 3.342h-8.114'/>
|
||||
</svg>
|
After Width: | Height: | Size: 545 B |
125
src/enums/mkb.ts
125
src/enums/mkb.ts
@ -37,131 +37,6 @@ export const enum MkbPresetKey {
|
||||
}
|
||||
|
||||
|
||||
export type KeyCode =
|
||||
| 'Backspace'
|
||||
| 'Tab'
|
||||
| 'Enter'
|
||||
| 'ShiftLeft'
|
||||
| 'ShiftRight'
|
||||
| 'ControlLeft'
|
||||
| 'ControlRight'
|
||||
| 'AltLeft'
|
||||
| 'AltRight'
|
||||
| 'Pause'
|
||||
| 'CapsLock'
|
||||
| 'Escape'
|
||||
| 'Space'
|
||||
| 'PageUp'
|
||||
| 'PageDown'
|
||||
| 'End'
|
||||
| 'Home'
|
||||
| 'ArrowLeft'
|
||||
| 'ArrowUp'
|
||||
| 'ArrowRight'
|
||||
| 'ArrowDown'
|
||||
| 'PrintScreen'
|
||||
| 'Insert'
|
||||
| 'Delete'
|
||||
| 'Digit0'
|
||||
| 'Digit1'
|
||||
| 'Digit2'
|
||||
| 'Digit3'
|
||||
| 'Digit4'
|
||||
| 'Digit5'
|
||||
| 'Digit6'
|
||||
| 'Digit7'
|
||||
| 'Digit8'
|
||||
| 'Digit9'
|
||||
| 'KeyA'
|
||||
| 'KeyB'
|
||||
| 'KeyC'
|
||||
| 'KeyD'
|
||||
| 'KeyE'
|
||||
| 'KeyF'
|
||||
| 'KeyG'
|
||||
| 'KeyH'
|
||||
| 'KeyI'
|
||||
| 'KeyJ'
|
||||
| 'KeyK'
|
||||
| 'KeyL'
|
||||
| 'KeyM'
|
||||
| 'KeyN'
|
||||
| 'KeyO'
|
||||
| 'KeyP'
|
||||
| 'KeyQ'
|
||||
| 'KeyR'
|
||||
| 'KeyS'
|
||||
| 'KeyT'
|
||||
| 'KeyU'
|
||||
| 'KeyV'
|
||||
| 'KeyW'
|
||||
| 'KeyX'
|
||||
| 'KeyY'
|
||||
| 'KeyZ'
|
||||
| 'MetaLeft'
|
||||
| 'MetaRight'
|
||||
| 'ContextMenu'
|
||||
| 'F1'
|
||||
| 'F2'
|
||||
| 'F3'
|
||||
| 'F4'
|
||||
| 'F5'
|
||||
| 'F6'
|
||||
| 'F7'
|
||||
| 'F8'
|
||||
| 'F9'
|
||||
| 'F10'
|
||||
| 'F11'
|
||||
| 'F12'
|
||||
| 'NumLock'
|
||||
| 'ScrollLock'
|
||||
| 'AudioVolumeMute'
|
||||
| 'AudioVolumeDown'
|
||||
| 'AudioVolumeUp'
|
||||
| 'MediaTrackNext'
|
||||
| 'MediaTrackPrevious'
|
||||
| 'MediaStop'
|
||||
| 'MediaPlayPause'
|
||||
| 'LaunchMail'
|
||||
| 'LaunchMediaPlayer'
|
||||
| 'LaunchApplication1'
|
||||
| 'LaunchApplication2'
|
||||
| 'Semicolon'
|
||||
| 'Equal'
|
||||
| 'Comma'
|
||||
| 'Minus'
|
||||
| 'Period'
|
||||
| 'Slash'
|
||||
| 'Backquote'
|
||||
| 'BracketLeft'
|
||||
| 'Backslash'
|
||||
| 'BracketRight'
|
||||
| 'Quote'
|
||||
| 'Numpad0'
|
||||
| 'Numpad1'
|
||||
| 'Numpad2'
|
||||
| 'Numpad3'
|
||||
| 'Numpad4'
|
||||
| 'Numpad5'
|
||||
| 'Numpad6'
|
||||
| 'Numpad7'
|
||||
| 'Numpad8'
|
||||
| 'Numpad9'
|
||||
| 'NumpadMultiply'
|
||||
| 'NumpadAdd'
|
||||
| 'NumpadSubtract'
|
||||
| 'NumpadDecimal'
|
||||
| 'NumpadDivide';
|
||||
|
||||
export type KeyCodeExcludeModifiers = Exclude<KeyCode,
|
||||
'ShiftLeft'
|
||||
| 'ShiftRight'
|
||||
| 'ControlLeft'
|
||||
| 'ControlRight'
|
||||
| 'AltLeft'
|
||||
| 'AltRight'
|
||||
>
|
||||
|
||||
export const enum KeyModifier {
|
||||
CTRL = 1,
|
||||
ALT = 2,
|
||||
|
@ -1,7 +1,9 @@
|
||||
import type { BaseSettingsStorage } from "@/utils/settings-storages/base-settings-storage";
|
||||
import type { BlockFeature, CodecProfile, DeviceVibrationMode, GameBarPosition, LoadingScreenRocket, NativeMkbMode, StreamPlayerType, StreamResolution, StreamStat, StreamStatPosition, StreamVideoProcessing, TouchControllerMode, TouchControllerStyleCustom, TouchControllerStyleStandard, UiLayout, UiSection, VideoPosition, VideoPowerPreference, VideoRatio } from "./pref-values"
|
||||
|
||||
export const enum StorageKey {
|
||||
GLOBAL = 'BetterXcloud',
|
||||
STREAM = 'BetterXcloud.Stream',
|
||||
|
||||
LOCALE = 'BetterXcloud.Locale',
|
||||
LOCALE_TRANSLATIONS = 'BetterXcloud.Locale.Translations',
|
||||
@ -16,7 +18,7 @@ export const enum StorageKey {
|
||||
}
|
||||
|
||||
|
||||
export const enum PrefKey {
|
||||
export const enum GlobalPref {
|
||||
VERSION_LAST_CHECK = 'version.lastCheck',
|
||||
VERSION_LATEST = 'version.latest',
|
||||
VERSION_CURRENT = 'version.current',
|
||||
@ -43,26 +45,11 @@ export const enum PrefKey {
|
||||
|
||||
GAME_BAR_POSITION = 'gameBar.position',
|
||||
|
||||
LOCAL_CO_OP_ENABLED = 'localCoOp.enabled',
|
||||
|
||||
DEVICE_VIBRATION_MODE = 'deviceVibration.mode',
|
||||
DEVICE_VIBRATION_INTENSITY = 'deviceVibration.intensity',
|
||||
|
||||
CONTROLLER_POLLING_RATE = 'controller.pollingRate',
|
||||
|
||||
NATIVE_MKB_MODE = 'nativeMkb.mode',
|
||||
NATIVE_MKB_FORCED_GAMES = 'nativeMkb.forcedGames',
|
||||
NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY = 'nativeMkb.scroll.sensitivityX',
|
||||
NATIVE_MKB_SCROLL_VERTICAL_SENSITIVITY = 'nativeMkb.scroll.sensitivityY',
|
||||
|
||||
MKB_ENABLED = 'mkb.enabled',
|
||||
MKB_HIDE_IDLE_CURSOR = 'mkb.cursor.hideIdle',
|
||||
MKB_P1_MAPPING_PRESET_ID = 'mkb.p1.preset.mappingId',
|
||||
MKB_P1_SLOT = 'mkb.p1.slot',
|
||||
MKB_P2_MAPPING_PRESET_ID = 'mkb.p2.preset.mappingId',
|
||||
MKB_P2_SLOT = 'mkb.p2.slot',
|
||||
|
||||
KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID = 'keyboardShortcuts.preset.inGameId',
|
||||
|
||||
SCREENSHOT_APPLY_FILTERS = 'screenshot.applyFilters',
|
||||
|
||||
@ -88,6 +75,84 @@ export const enum PrefKey {
|
||||
UI_REDUCE_ANIMATIONS = 'ui.reduceAnimations',
|
||||
UI_IMAGE_QUALITY = 'ui.imageQuality',
|
||||
|
||||
AUDIO_MIC_ON_PLAYING = 'audio.mic.onPlaying',
|
||||
AUDIO_VOLUME_CONTROL_ENABLED = 'audio.volume.booster.enabled',
|
||||
|
||||
REMOTE_PLAY_ENABLED = 'xhome.enabled',
|
||||
REMOTE_PLAY_STREAM_RESOLUTION = 'xhome.video.resolution',
|
||||
|
||||
GAME_FORTNITE_FORCE_CONSOLE = 'game.fortnite.forceConsole',
|
||||
}
|
||||
|
||||
export type GlobalPrefTypeMap = {
|
||||
[GlobalPref.AUDIO_MIC_ON_PLAYING]: boolean;
|
||||
[GlobalPref.AUDIO_VOLUME_CONTROL_ENABLED]: boolean;
|
||||
[GlobalPref.BLOCK_FEATURES]: BlockFeature[];
|
||||
[GlobalPref.BLOCK_TRACKING]: boolean;
|
||||
[GlobalPref.GAME_BAR_POSITION]: GameBarPosition;
|
||||
[GlobalPref.GAME_FORTNITE_FORCE_CONSOLE]: boolean;
|
||||
[GlobalPref.LOADING_SCREEN_GAME_ART]: boolean;
|
||||
[GlobalPref.LOADING_SCREEN_ROCKET]: LoadingScreenRocket;
|
||||
[GlobalPref.LOADING_SCREEN_SHOW_WAIT_TIME]: boolean;
|
||||
[GlobalPref.MKB_ENABLED]: boolean;
|
||||
[GlobalPref.MKB_HIDE_IDLE_CURSOR]: boolean;
|
||||
[GlobalPref.NATIVE_MKB_FORCED_GAMES]: string[];
|
||||
[GlobalPref.NATIVE_MKB_MODE]: NativeMkbMode;
|
||||
[GlobalPref.REMOTE_PLAY_ENABLED]: boolean;
|
||||
[GlobalPref.REMOTE_PLAY_STREAM_RESOLUTION]: StreamResolution;
|
||||
[GlobalPref.SCREENSHOT_APPLY_FILTERS]: boolean;
|
||||
[GlobalPref.SERVER_BYPASS_RESTRICTION]: string;
|
||||
[GlobalPref.SERVER_PREFER_IPV6]: boolean;
|
||||
[GlobalPref.SERVER_REGION]: string;
|
||||
[GlobalPref.STREAM_CODEC_PROFILE]: CodecProfile;
|
||||
[GlobalPref.STREAM_COMBINE_SOURCES]: boolean;
|
||||
[GlobalPref.STREAM_MAX_VIDEO_BITRATE]: number;
|
||||
[GlobalPref.STREAM_PREFERRED_LOCALE]: StreamPreferredLocale;
|
||||
[GlobalPref.STREAM_RESOLUTION]: StreamResolution;
|
||||
[GlobalPref.TOUCH_CONTROLLER_AUTO_OFF]: boolean;
|
||||
[GlobalPref.TOUCH_CONTROLLER_DEFAULT_OPACITY]: number;
|
||||
[GlobalPref.TOUCH_CONTROLLER_MODE]: TouchControllerMode;
|
||||
[GlobalPref.TOUCH_CONTROLLER_STYLE_CUSTOM]: TouchControllerStyleCustom;
|
||||
[GlobalPref.TOUCH_CONTROLLER_STYLE_STANDARD]: TouchControllerStyleStandard;
|
||||
[GlobalPref.UI_CONTROLLER_FRIENDLY]: boolean;
|
||||
[GlobalPref.UI_CONTROLLER_SHOW_STATUS]: boolean;
|
||||
[GlobalPref.UI_DISABLE_FEEDBACK_DIALOG]: boolean;
|
||||
[GlobalPref.UI_GAME_CARD_SHOW_WAIT_TIME]: boolean;
|
||||
[GlobalPref.UI_HIDE_SECTIONS]: UiSection[];
|
||||
[GlobalPref.UI_HIDE_SYSTEM_MENU_ICON]: boolean;
|
||||
[GlobalPref.UI_IMAGE_QUALITY]: number;
|
||||
[GlobalPref.UI_LAYOUT]: UiLayout;
|
||||
[GlobalPref.UI_REDUCE_ANIMATIONS]: boolean;
|
||||
[GlobalPref.UI_SCROLLBAR_HIDE]: boolean;
|
||||
[GlobalPref.UI_SIMPLIFY_STREAM_MENU]: boolean;
|
||||
[GlobalPref.UI_SKIP_SPLASH_VIDEO]: boolean;
|
||||
[GlobalPref.VERSION_CURRENT]: string;
|
||||
[GlobalPref.VERSION_LAST_CHECK]: number;
|
||||
[GlobalPref.VERSION_LATEST]: string;
|
||||
|
||||
[GlobalPref.SCRIPT_LOCALE]: string;
|
||||
[GlobalPref.USER_AGENT_PROFILE]: string;
|
||||
}
|
||||
|
||||
export const enum StreamPref {
|
||||
LOCAL_CO_OP_ENABLED = 'localCoOp.enabled',
|
||||
|
||||
DEVICE_VIBRATION_MODE = 'deviceVibration.mode',
|
||||
DEVICE_VIBRATION_INTENSITY = 'deviceVibration.intensity',
|
||||
|
||||
CONTROLLER_POLLING_RATE = 'controller.pollingRate',
|
||||
CONTROLLER_SETTINGS = 'controller.settings',
|
||||
|
||||
NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY = 'nativeMkb.scroll.sensitivityX',
|
||||
NATIVE_MKB_SCROLL_VERTICAL_SENSITIVITY = 'nativeMkb.scroll.sensitivityY',
|
||||
|
||||
MKB_P1_MAPPING_PRESET_ID = 'mkb.p1.preset.mappingId',
|
||||
MKB_P1_SLOT = 'mkb.p1.slot',
|
||||
MKB_P2_MAPPING_PRESET_ID = 'mkb.p2.preset.mappingId',
|
||||
MKB_P2_SLOT = 'mkb.p2.slot',
|
||||
|
||||
KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID = 'keyboardShortcuts.preset.inGameId',
|
||||
|
||||
VIDEO_PLAYER_TYPE = 'video.player.type',
|
||||
VIDEO_POWER_PREFERENCE = 'video.player.powerPreference',
|
||||
VIDEO_PROCESSING = 'video.processing',
|
||||
@ -99,8 +164,6 @@ export const enum PrefKey {
|
||||
VIDEO_SATURATION = 'video.saturation',
|
||||
VIDEO_POSITION = 'video.position',
|
||||
|
||||
AUDIO_MIC_ON_PLAYING = 'audio.mic.onPlaying',
|
||||
AUDIO_VOLUME_CONTROL_ENABLED = 'audio.volume.booster.enabled',
|
||||
AUDIO_VOLUME = 'audio.volume',
|
||||
|
||||
STATS_ITEMS = 'stats.items',
|
||||
@ -111,85 +174,137 @@ export const enum PrefKey {
|
||||
STATS_OPACITY_ALL = 'stats.opacity.all',
|
||||
STATS_OPACITY_BACKGROUND = 'stats.opacity.background',
|
||||
STATS_CONDITIONAL_FORMATTING = 'stats.colors',
|
||||
|
||||
REMOTE_PLAY_ENABLED = 'xhome.enabled',
|
||||
REMOTE_PLAY_STREAM_RESOLUTION = 'xhome.video.resolution',
|
||||
|
||||
GAME_FORTNITE_FORCE_CONSOLE = 'game.fortnite.forceConsole',
|
||||
}
|
||||
|
||||
|
||||
export type PrefTypeMap = {
|
||||
[PrefKey.AUDIO_MIC_ON_PLAYING]: boolean,
|
||||
[PrefKey.AUDIO_VOLUME_CONTROL_ENABLED]: boolean,
|
||||
[PrefKey.AUDIO_VOLUME]: number,
|
||||
[PrefKey.BLOCK_FEATURES]: BlockFeature[],
|
||||
[PrefKey.BLOCK_TRACKING]: boolean,
|
||||
[PrefKey.CONTROLLER_POLLING_RATE]: number,
|
||||
[PrefKey.DEVICE_VIBRATION_INTENSITY]: number,
|
||||
[PrefKey.DEVICE_VIBRATION_MODE]: DeviceVibrationMode,
|
||||
[PrefKey.GAME_BAR_POSITION]: GameBarPosition,
|
||||
[PrefKey.GAME_FORTNITE_FORCE_CONSOLE]: boolean,
|
||||
[PrefKey.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID]: number,
|
||||
[PrefKey.LOADING_SCREEN_GAME_ART]: boolean,
|
||||
[PrefKey.LOADING_SCREEN_ROCKET]: LoadingScreenRocket,
|
||||
[PrefKey.LOADING_SCREEN_SHOW_WAIT_TIME]: boolean,
|
||||
[PrefKey.LOCAL_CO_OP_ENABLED]: boolean,
|
||||
[PrefKey.MKB_ENABLED]: boolean,
|
||||
[PrefKey.MKB_HIDE_IDLE_CURSOR]: boolean,
|
||||
[PrefKey.MKB_P1_MAPPING_PRESET_ID]: number,
|
||||
[PrefKey.MKB_P1_SLOT]: number,
|
||||
[PrefKey.NATIVE_MKB_FORCED_GAMES]: string[],
|
||||
[PrefKey.NATIVE_MKB_MODE]: NativeMkbMode,
|
||||
[PrefKey.NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY]: number,
|
||||
[PrefKey.NATIVE_MKB_SCROLL_VERTICAL_SENSITIVITY]: number,
|
||||
[PrefKey.REMOTE_PLAY_ENABLED]: boolean,
|
||||
[PrefKey.REMOTE_PLAY_STREAM_RESOLUTION]: StreamResolution,
|
||||
[PrefKey.SCREENSHOT_APPLY_FILTERS]: boolean,
|
||||
[PrefKey.SERVER_BYPASS_RESTRICTION]: string,
|
||||
[PrefKey.SERVER_PREFER_IPV6]: boolean,
|
||||
[PrefKey.SERVER_REGION]: string,
|
||||
[PrefKey.STATS_CONDITIONAL_FORMATTING]: boolean,
|
||||
[PrefKey.STATS_ITEMS]: StreamStat[],
|
||||
[PrefKey.STATS_OPACITY_ALL]: number,
|
||||
[PrefKey.STATS_OPACITY_BACKGROUND]: number,
|
||||
[PrefKey.STATS_POSITION]: StreamStatPosition,
|
||||
[PrefKey.STATS_QUICK_GLANCE_ENABLED]: boolean,
|
||||
[PrefKey.STATS_SHOW_WHEN_PLAYING]: boolean,
|
||||
[PrefKey.STATS_TEXT_SIZE]: string,
|
||||
[PrefKey.STREAM_CODEC_PROFILE]: CodecProfile,
|
||||
[PrefKey.STREAM_COMBINE_SOURCES]: boolean,
|
||||
[PrefKey.STREAM_MAX_VIDEO_BITRATE]: number,
|
||||
[PrefKey.STREAM_PREFERRED_LOCALE]: StreamPreferredLocale,
|
||||
[PrefKey.STREAM_RESOLUTION]: StreamResolution,
|
||||
[PrefKey.TOUCH_CONTROLLER_AUTO_OFF]: boolean,
|
||||
[PrefKey.TOUCH_CONTROLLER_DEFAULT_OPACITY]: number,
|
||||
[PrefKey.TOUCH_CONTROLLER_MODE]: TouchControllerMode,
|
||||
[PrefKey.TOUCH_CONTROLLER_STYLE_CUSTOM]: TouchControllerStyleCustom,
|
||||
[PrefKey.TOUCH_CONTROLLER_STYLE_STANDARD]: TouchControllerStyleStandard,
|
||||
[PrefKey.UI_CONTROLLER_FRIENDLY]: boolean,
|
||||
[PrefKey.UI_CONTROLLER_SHOW_STATUS]: boolean,
|
||||
[PrefKey.UI_DISABLE_FEEDBACK_DIALOG]: boolean,
|
||||
[PrefKey.UI_GAME_CARD_SHOW_WAIT_TIME]: boolean,
|
||||
[PrefKey.UI_HIDE_SECTIONS]: UiSection[],
|
||||
[PrefKey.UI_HIDE_SYSTEM_MENU_ICON]: boolean,
|
||||
[PrefKey.UI_IMAGE_QUALITY]: number,
|
||||
[PrefKey.UI_LAYOUT]: UiLayout,
|
||||
[PrefKey.UI_REDUCE_ANIMATIONS]: boolean,
|
||||
[PrefKey.UI_SCROLLBAR_HIDE]: boolean,
|
||||
[PrefKey.UI_SIMPLIFY_STREAM_MENU]: boolean,
|
||||
[PrefKey.UI_SKIP_SPLASH_VIDEO]: boolean,
|
||||
[PrefKey.VERSION_CURRENT]: string,
|
||||
[PrefKey.VERSION_LAST_CHECK]: number,
|
||||
[PrefKey.VERSION_LATEST]: string,
|
||||
[PrefKey.VIDEO_BRIGHTNESS]: number,
|
||||
[PrefKey.VIDEO_CONTRAST]: number,
|
||||
[PrefKey.VIDEO_MAX_FPS]: number,
|
||||
[PrefKey.VIDEO_PLAYER_TYPE]: StreamPlayerType,
|
||||
[PrefKey.VIDEO_POSITION]: VideoPosition,
|
||||
[PrefKey.VIDEO_POWER_PREFERENCE]: VideoPowerPreference,
|
||||
[PrefKey.VIDEO_PROCESSING]: StreamVideoProcessing,
|
||||
[PrefKey.VIDEO_RATIO]: VideoRatio,
|
||||
[PrefKey.VIDEO_SATURATION]: number,
|
||||
[PrefKey.VIDEO_SHARPNESS]: number,
|
||||
export type StreamPrefTypeMap = {
|
||||
[StreamPref.AUDIO_VOLUME]: number;
|
||||
[StreamPref.CONTROLLER_POLLING_RATE]: number;
|
||||
[StreamPref.CONTROLLER_SETTINGS]: ControllerSettings;
|
||||
[StreamPref.DEVICE_VIBRATION_INTENSITY]: number;
|
||||
[StreamPref.DEVICE_VIBRATION_MODE]: DeviceVibrationMode;
|
||||
[StreamPref.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID]: number;
|
||||
[StreamPref.LOCAL_CO_OP_ENABLED]: boolean;
|
||||
[StreamPref.MKB_P1_MAPPING_PRESET_ID]: number;
|
||||
[StreamPref.MKB_P1_SLOT]: number;
|
||||
[StreamPref.MKB_P2_MAPPING_PRESET_ID]: number;
|
||||
[StreamPref.MKB_P2_SLOT]: number;
|
||||
[StreamPref.NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY]: number;
|
||||
[StreamPref.NATIVE_MKB_SCROLL_VERTICAL_SENSITIVITY]: number;
|
||||
[StreamPref.STATS_CONDITIONAL_FORMATTING]: boolean;
|
||||
[StreamPref.STATS_ITEMS]: StreamStat[];
|
||||
[StreamPref.STATS_OPACITY_ALL]: number;
|
||||
[StreamPref.STATS_OPACITY_BACKGROUND]: number;
|
||||
[StreamPref.STATS_POSITION]: StreamStatPosition;
|
||||
[StreamPref.STATS_QUICK_GLANCE_ENABLED]: boolean;
|
||||
[StreamPref.STATS_SHOW_WHEN_PLAYING]: boolean;
|
||||
[StreamPref.STATS_TEXT_SIZE]: string;
|
||||
[StreamPref.VIDEO_BRIGHTNESS]: number;
|
||||
[StreamPref.VIDEO_CONTRAST]: number;
|
||||
[StreamPref.VIDEO_MAX_FPS]: number;
|
||||
[StreamPref.VIDEO_PLAYER_TYPE]: StreamPlayerType;
|
||||
[StreamPref.VIDEO_POSITION]: VideoPosition;
|
||||
[StreamPref.VIDEO_POWER_PREFERENCE]: VideoPowerPreference;
|
||||
[StreamPref.VIDEO_PROCESSING]: StreamVideoProcessing;
|
||||
[StreamPref.VIDEO_RATIO]: VideoRatio;
|
||||
[StreamPref.VIDEO_SATURATION]: number;
|
||||
[StreamPref.VIDEO_SHARPNESS]: number;
|
||||
}
|
||||
|
||||
export type AllPrefs = GlobalPref | StreamPref;
|
||||
|
||||
export const ALL_PREFS: {
|
||||
global: GlobalPref[],
|
||||
stream: StreamPref[],
|
||||
} = {
|
||||
global: [
|
||||
GlobalPref.AUDIO_MIC_ON_PLAYING,
|
||||
GlobalPref.AUDIO_VOLUME_CONTROL_ENABLED,
|
||||
GlobalPref.BLOCK_FEATURES,
|
||||
GlobalPref.BLOCK_TRACKING,
|
||||
GlobalPref.GAME_BAR_POSITION,
|
||||
GlobalPref.GAME_FORTNITE_FORCE_CONSOLE,
|
||||
GlobalPref.LOADING_SCREEN_GAME_ART,
|
||||
GlobalPref.LOADING_SCREEN_ROCKET,
|
||||
GlobalPref.LOADING_SCREEN_SHOW_WAIT_TIME,
|
||||
GlobalPref.MKB_ENABLED,
|
||||
GlobalPref.MKB_HIDE_IDLE_CURSOR,
|
||||
GlobalPref.NATIVE_MKB_FORCED_GAMES,
|
||||
GlobalPref.NATIVE_MKB_MODE,
|
||||
GlobalPref.REMOTE_PLAY_ENABLED,
|
||||
GlobalPref.REMOTE_PLAY_STREAM_RESOLUTION,
|
||||
GlobalPref.SCREENSHOT_APPLY_FILTERS,
|
||||
GlobalPref.SERVER_BYPASS_RESTRICTION,
|
||||
GlobalPref.SERVER_PREFER_IPV6,
|
||||
GlobalPref.SERVER_REGION,
|
||||
GlobalPref.STREAM_CODEC_PROFILE,
|
||||
GlobalPref.STREAM_COMBINE_SOURCES,
|
||||
GlobalPref.STREAM_MAX_VIDEO_BITRATE,
|
||||
GlobalPref.STREAM_PREFERRED_LOCALE,
|
||||
GlobalPref.STREAM_RESOLUTION,
|
||||
GlobalPref.TOUCH_CONTROLLER_AUTO_OFF,
|
||||
GlobalPref.TOUCH_CONTROLLER_DEFAULT_OPACITY,
|
||||
GlobalPref.TOUCH_CONTROLLER_MODE,
|
||||
GlobalPref.TOUCH_CONTROLLER_STYLE_CUSTOM,
|
||||
GlobalPref.TOUCH_CONTROLLER_STYLE_STANDARD,
|
||||
GlobalPref.UI_CONTROLLER_FRIENDLY,
|
||||
GlobalPref.UI_CONTROLLER_SHOW_STATUS,
|
||||
GlobalPref.UI_DISABLE_FEEDBACK_DIALOG,
|
||||
GlobalPref.UI_GAME_CARD_SHOW_WAIT_TIME,
|
||||
GlobalPref.UI_HIDE_SECTIONS,
|
||||
GlobalPref.UI_HIDE_SYSTEM_MENU_ICON,
|
||||
GlobalPref.UI_IMAGE_QUALITY,
|
||||
GlobalPref.UI_LAYOUT,
|
||||
GlobalPref.UI_REDUCE_ANIMATIONS,
|
||||
GlobalPref.UI_SCROLLBAR_HIDE,
|
||||
GlobalPref.UI_SIMPLIFY_STREAM_MENU,
|
||||
GlobalPref.UI_SKIP_SPLASH_VIDEO,
|
||||
GlobalPref.VERSION_CURRENT,
|
||||
GlobalPref.VERSION_LAST_CHECK,
|
||||
GlobalPref.VERSION_LATEST,
|
||||
|
||||
GlobalPref.SCRIPT_LOCALE,
|
||||
GlobalPref.USER_AGENT_PROFILE,
|
||||
],
|
||||
stream: [
|
||||
StreamPref.AUDIO_VOLUME,
|
||||
StreamPref.CONTROLLER_POLLING_RATE,
|
||||
StreamPref.CONTROLLER_SETTINGS,
|
||||
StreamPref.DEVICE_VIBRATION_INTENSITY,
|
||||
StreamPref.DEVICE_VIBRATION_MODE,
|
||||
StreamPref.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID,
|
||||
StreamPref.LOCAL_CO_OP_ENABLED,
|
||||
StreamPref.MKB_P1_MAPPING_PRESET_ID,
|
||||
StreamPref.MKB_P1_SLOT,
|
||||
StreamPref.MKB_P2_MAPPING_PRESET_ID,
|
||||
StreamPref.MKB_P2_SLOT,
|
||||
StreamPref.NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY,
|
||||
StreamPref.NATIVE_MKB_SCROLL_VERTICAL_SENSITIVITY,
|
||||
StreamPref.STATS_CONDITIONAL_FORMATTING,
|
||||
StreamPref.STATS_ITEMS,
|
||||
StreamPref.STATS_OPACITY_ALL,
|
||||
StreamPref.STATS_OPACITY_BACKGROUND,
|
||||
StreamPref.STATS_POSITION,
|
||||
StreamPref.STATS_QUICK_GLANCE_ENABLED,
|
||||
StreamPref.STATS_SHOW_WHEN_PLAYING,
|
||||
StreamPref.STATS_TEXT_SIZE,
|
||||
StreamPref.VIDEO_BRIGHTNESS,
|
||||
StreamPref.VIDEO_CONTRAST,
|
||||
StreamPref.VIDEO_MAX_FPS,
|
||||
StreamPref.VIDEO_PLAYER_TYPE,
|
||||
StreamPref.VIDEO_POSITION,
|
||||
StreamPref.VIDEO_POWER_PREFERENCE,
|
||||
StreamPref.VIDEO_PROCESSING,
|
||||
StreamPref.VIDEO_RATIO,
|
||||
StreamPref.VIDEO_SATURATION,
|
||||
StreamPref.VIDEO_SHARPNESS,
|
||||
],
|
||||
} as const;
|
||||
|
||||
export type AnySettingsStorage = BaseSettingsStorage<GlobalPref> | BaseSettingsStorage<StreamPref>;
|
||||
export type AnyPref = GlobalPref | StreamPref;
|
||||
|
||||
export type PrefTypeMap<Key> = Key extends GlobalPref
|
||||
? GlobalPrefTypeMap
|
||||
: Key extends StreamPref
|
||||
? StreamPrefTypeMap
|
||||
: never;
|
||||
|
59
src/index.ts
59
src/index.ts
@ -32,8 +32,7 @@ import { HeaderSection } from "./modules/ui/header";
|
||||
import { GameTile } from "./modules/ui/game-tile";
|
||||
import { ProductDetailsPage } from "./modules/ui/product-details";
|
||||
import { NavigationDialogManager } from "./modules/ui/dialog/navigation-dialog";
|
||||
import { PrefKey } from "./enums/pref-keys";
|
||||
import { getPref } from "./utils/settings-storages/global-settings-storage";
|
||||
import { GlobalPref, StreamPref } from "./enums/pref-keys";
|
||||
import { SettingsDialog } from "./modules/ui/dialog/settings-dialog";
|
||||
import { StreamUiHandler } from "./modules/stream/stream-ui";
|
||||
import { UserAgent } from "./utils/user-agent";
|
||||
@ -45,6 +44,11 @@ import { KeyboardShortcutHandler } from "./modules/mkb/keyboard-shortcut-handler
|
||||
import { GhPagesUtils } from "./utils/gh-pages";
|
||||
import { DeviceVibrationManager } from "./modules/device-vibration-manager";
|
||||
import { BxEventBus } from "./utils/bx-event-bus";
|
||||
import { getGlobalPref, getStreamPref } from "./utils/pref-utils";
|
||||
import { SettingsManager } from "./modules/settings-manager";
|
||||
import { Toast } from "./utils/toast";
|
||||
|
||||
SettingsManager.getInstance();
|
||||
|
||||
// Handle login page
|
||||
if (window.location.pathname.includes('/auth/msa')) {
|
||||
@ -173,7 +177,7 @@ document.addEventListener('readystatechange', e => {
|
||||
}
|
||||
|
||||
// Hide "Play with Friends" skeleton section
|
||||
if (getPref(PrefKey.UI_HIDE_SECTIONS).includes(UiSection.FRIENDS) || getPref(PrefKey.BLOCK_FEATURES).includes(BlockFeature.FRIENDS)) {
|
||||
if (getGlobalPref(GlobalPref.UI_HIDE_SECTIONS).includes(UiSection.FRIENDS) || getGlobalPref(GlobalPref.BLOCK_FEATURES).includes(BlockFeature.FRIENDS)) {
|
||||
const $parent = document.querySelector('div[class*=PlayWithFriendsSkeleton]')?.closest<HTMLElement>('div[class*=HomePage-module]');
|
||||
$parent && ($parent.style.display = 'none');
|
||||
}
|
||||
@ -219,7 +223,7 @@ BxEventBus.Stream.on('state.loading', () => {
|
||||
});
|
||||
|
||||
// Setup loading screen
|
||||
getPref(PrefKey.LOADING_SCREEN_GAME_ART) && BxEventBus.Script.on('titleInfo.ready', LoadingScreen.setup);
|
||||
getGlobalPref(GlobalPref.LOADING_SCREEN_GAME_ART) && BxEventBus.Script.on('titleInfo.ready', LoadingScreen.setup);
|
||||
|
||||
BxEventBus.Stream.on('state.starting', () => {
|
||||
// Hide loading screen
|
||||
@ -260,7 +264,10 @@ BxEventBus.Stream.on('state.playing', payload => {
|
||||
ScreenshotManager.getInstance().updateCanvasSize($video.videoWidth, $video.videoHeight);
|
||||
|
||||
// Setup local co-op
|
||||
getPref(PrefKey.LOCAL_CO_OP_ENABLED) && BxExposed.toggleLocalCoOp(getPref(PrefKey.LOCAL_CO_OP_ENABLED));
|
||||
if (getStreamPref(StreamPref.LOCAL_CO_OP_ENABLED)) {
|
||||
BxExposed.toggleLocalCoOp(true);
|
||||
Toast.show(t('local-co-op'), t('enabled'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -295,20 +302,32 @@ BxEventBus.Stream.on('dataChannelCreated', payload => {
|
||||
}
|
||||
|
||||
// Get xboxTitleId from message
|
||||
const currentStream = STATES.currentStream;
|
||||
const json = JSON.parse(JSON.parse(msg.data).content);
|
||||
const xboxTitleId = parseInt(json.titleid, 16);
|
||||
STATES.currentStream.xboxTitleId = xboxTitleId;
|
||||
const currentId = currentStream.xboxTitleId ?? null;
|
||||
let newId: number = parseInt(json.titleid, 16);
|
||||
|
||||
// Get titleSlug for Remote Play
|
||||
if (STATES.remotePlay.isPlaying) {
|
||||
STATES.currentStream.titleSlug = 'remote-play';
|
||||
currentStream.titleSlug = 'remote-play';
|
||||
if (json.focused) {
|
||||
const productTitle = await XboxApi.getProductTitle(xboxTitleId);
|
||||
const productTitle = await XboxApi.getProductTitle(newId);
|
||||
if (productTitle) {
|
||||
STATES.currentStream.titleSlug = productTitleToSlug(productTitle);
|
||||
currentStream.titleSlug = productTitleToSlug(productTitle);
|
||||
} else {
|
||||
newId = -1;
|
||||
}
|
||||
} else {
|
||||
newId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentId !== newId) {
|
||||
currentStream.xboxTitleId = newId;
|
||||
BxEventBus.Stream.emit('xboxTitleId.changed', {
|
||||
id: newId,
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -345,6 +364,8 @@ function unload() {
|
||||
TouchController.reset();
|
||||
|
||||
GameBar.getInstance()?.disable();
|
||||
|
||||
BxEventBus.Stream.emit('xboxTitleId.changed', { id: -1 });
|
||||
}
|
||||
}
|
||||
|
||||
@ -362,8 +383,8 @@ function main() {
|
||||
GhPagesUtils.fetchLatestCommit();
|
||||
|
||||
if (isFullVersion()) {
|
||||
if (getPref(PrefKey.NATIVE_MKB_MODE) !== NativeMkbMode.OFF) {
|
||||
const customList = getPref(PrefKey.NATIVE_MKB_FORCED_GAMES);
|
||||
if (getGlobalPref(GlobalPref.NATIVE_MKB_MODE) !== NativeMkbMode.OFF) {
|
||||
const customList = getGlobalPref(GlobalPref.NATIVE_MKB_FORCED_GAMES);
|
||||
BX_FLAGS.ForceNativeMkbTitles.push(...customList);
|
||||
}
|
||||
}
|
||||
@ -378,9 +399,9 @@ function main() {
|
||||
patchCanvasContext();
|
||||
isFullVersion() && AppInterface && patchPointerLockApi();
|
||||
|
||||
getPref(PrefKey.AUDIO_VOLUME_CONTROL_ENABLED) && patchAudioContext();
|
||||
getGlobalPref(GlobalPref.AUDIO_VOLUME_CONTROL_ENABLED) && patchAudioContext();
|
||||
|
||||
if (getPref(PrefKey.BLOCK_TRACKING)) {
|
||||
if (getGlobalPref(GlobalPref.BLOCK_TRACKING)) {
|
||||
patchMeControl();
|
||||
disableAdobeAudienceManager();
|
||||
}
|
||||
@ -407,28 +428,28 @@ function main() {
|
||||
disablePwa();
|
||||
|
||||
// Preload Remote Play
|
||||
if (getPref(PrefKey.REMOTE_PLAY_ENABLED)) {
|
||||
if (getGlobalPref(GlobalPref.REMOTE_PLAY_ENABLED)) {
|
||||
RemotePlayManager.detect();
|
||||
}
|
||||
|
||||
if (getPref(PrefKey.TOUCH_CONTROLLER_MODE) === TouchControllerMode.ALL) {
|
||||
if (getGlobalPref(GlobalPref.TOUCH_CONTROLLER_MODE) === TouchControllerMode.ALL) {
|
||||
TouchController.setup();
|
||||
}
|
||||
|
||||
// Start PointerProviderServer
|
||||
if (AppInterface && (getPref(PrefKey.MKB_ENABLED) || getPref(PrefKey.NATIVE_MKB_MODE) === NativeMkbMode.ON)) {
|
||||
if (AppInterface && (getGlobalPref(GlobalPref.MKB_ENABLED) || getGlobalPref(GlobalPref.NATIVE_MKB_MODE) === NativeMkbMode.ON)) {
|
||||
STATES.pointerServerPort = AppInterface.startPointerServer() || 9269;
|
||||
BxLogger.info('startPointerServer', 'Port', STATES.pointerServerPort.toString());
|
||||
}
|
||||
|
||||
// Show wait time in game card
|
||||
getPref(PrefKey.UI_GAME_CARD_SHOW_WAIT_TIME) && GameTile.setup();
|
||||
getGlobalPref(GlobalPref.UI_GAME_CARD_SHOW_WAIT_TIME) && GameTile.setup();
|
||||
|
||||
EmulatedMkbHandler.setupEvents();
|
||||
}
|
||||
|
||||
// Show a toast when connecting/disconecting controller
|
||||
if (getPref(PrefKey.UI_CONTROLLER_SHOW_STATUS)) {
|
||||
if (getGlobalPref(GlobalPref.UI_CONTROLLER_SHOW_STATUS)) {
|
||||
window.addEventListener('gamepadconnected', e => showGamepadToast(e.gamepad));
|
||||
window.addEventListener('gamepaddisconnected', e => showGamepadToast(e.gamepad));
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ export class DeviceVibrationManager {
|
||||
}
|
||||
});
|
||||
|
||||
BxEventBus.Script.on('deviceVibration.updated', () => this.setupDataChannel());
|
||||
BxEventBus.Stream.on('deviceVibration.updated', () => this.setupDataChannel());
|
||||
}
|
||||
|
||||
private setupDataChannel() {
|
||||
|
@ -6,21 +6,21 @@ import { BxIcon } from "@utils/bx-icon";
|
||||
import type { BaseGameBarAction } from "./base-action";
|
||||
import { STATES } from "@utils/global";
|
||||
import { MicrophoneAction } from "./microphone-action";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { GlobalPref } from "@/enums/pref-keys";
|
||||
import { TrueAchievementsAction } from "./true-achievements-action";
|
||||
import { SpeakerAction } from "./speaker-action";
|
||||
import { RendererAction } from "./renderer-action";
|
||||
import { BxLogger } from "@/utils/bx-logger";
|
||||
import { GameBarPosition, TouchControllerMode } from "@/enums/pref-values";
|
||||
import { BxEventBus } from "@/utils/bx-event-bus";
|
||||
import { getGlobalPref } from "@/utils/pref-utils";
|
||||
|
||||
|
||||
export class GameBar {
|
||||
private static instance: GameBar | null | undefined;
|
||||
public static getInstance(): typeof GameBar['instance'] {
|
||||
if (typeof GameBar.instance === 'undefined') {
|
||||
if (getPref(PrefKey.GAME_BAR_POSITION) !== GameBarPosition.OFF) {
|
||||
if (getGlobalPref(GlobalPref.GAME_BAR_POSITION) !== GameBarPosition.OFF) {
|
||||
GameBar.instance = new GameBar();
|
||||
} else {
|
||||
GameBar.instance = null;
|
||||
@ -46,7 +46,7 @@ export class GameBar {
|
||||
|
||||
let $container;
|
||||
|
||||
const position = getPref(PrefKey.GAME_BAR_POSITION);
|
||||
const position = getGlobalPref(GlobalPref.GAME_BAR_POSITION);
|
||||
|
||||
const $gameBar = CE('div', { id: 'bx-game-bar', class: 'bx-gone', 'data-position': position },
|
||||
$container = CE('div', { class: 'bx-game-bar-container bx-offscreen' }),
|
||||
@ -55,7 +55,7 @@ export class GameBar {
|
||||
|
||||
this.actions = [
|
||||
new ScreenshotAction(),
|
||||
...(STATES.userAgent.capabilities.touch && (getPref(PrefKey.TOUCH_CONTROLLER_MODE) !== TouchControllerMode.OFF) ? [new TouchControlAction()] : []),
|
||||
...(STATES.userAgent.capabilities.touch && (getGlobalPref(GlobalPref.TOUCH_CONTROLLER_MODE) !== TouchControllerMode.OFF) ? [new TouchControlAction()] : []),
|
||||
new SpeakerAction(),
|
||||
new RendererAction(),
|
||||
new MicrophoneAction(),
|
||||
|
@ -2,8 +2,8 @@ import { CE } from "@utils/html";
|
||||
import { getPreferredServerRegion } from "@utils/region";
|
||||
import { t } from "@utils/translation";
|
||||
import { STATES } from "@utils/global";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { GlobalPref } from "@/enums/pref-keys";
|
||||
import { getGlobalPref } from "@/utils/pref-utils";
|
||||
import { compressCss } from "@macros/build" with { type: "macro" };
|
||||
import { LoadingScreenRocket } from "@/enums/pref-values";
|
||||
|
||||
@ -37,7 +37,7 @@ export class LoadingScreen {
|
||||
|
||||
LoadingScreen.setBackground(titleInfo.product.heroImageUrl || titleInfo.product.titledHeroImageUrl || titleInfo.product.tileImageUrl);
|
||||
|
||||
if (getPref(PrefKey.LOADING_SCREEN_ROCKET) === LoadingScreenRocket.HIDE) {
|
||||
if (getGlobalPref(GlobalPref.LOADING_SCREEN_ROCKET) === LoadingScreenRocket.HIDE) {
|
||||
LoadingScreen.hideRocket();
|
||||
}
|
||||
}
|
||||
@ -63,7 +63,7 @@ export class LoadingScreen {
|
||||
// Limit max width to reduce image size
|
||||
imageUrl = imageUrl + '?w=1920';
|
||||
|
||||
const imageQuality = getPref(PrefKey.UI_IMAGE_QUALITY);
|
||||
const imageQuality = getGlobalPref(GlobalPref.UI_IMAGE_QUALITY);
|
||||
if (imageQuality !== 90) {
|
||||
imageUrl += '&q=' + imageQuality;
|
||||
}
|
||||
@ -94,7 +94,7 @@ export class LoadingScreen {
|
||||
|
||||
static setupWaitTime(waitTime: number) {
|
||||
// Hide rocket when queing
|
||||
if (getPref(PrefKey.LOADING_SCREEN_ROCKET) === LoadingScreenRocket.HIDE_QUEUE) {
|
||||
if (getGlobalPref(GlobalPref.LOADING_SCREEN_ROCKET) === LoadingScreenRocket.HIDE_QUEUE) {
|
||||
LoadingScreen.hideRocket();
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ export class LoadingScreen {
|
||||
LoadingScreen.orgWebTitle && (document.title = LoadingScreen.orgWebTitle);
|
||||
LoadingScreen.$waitTimeBox && LoadingScreen.$waitTimeBox.classList.add('bx-gone');
|
||||
|
||||
if (getPref(PrefKey.LOADING_SCREEN_GAME_ART) && LoadingScreen.$bgStyle) {
|
||||
if (getGlobalPref(GlobalPref.LOADING_SCREEN_GAME_ART) && LoadingScreen.$bgStyle) {
|
||||
const $rocketBg = document.querySelector('#game-stream rect[width="800"]');
|
||||
$rocketBg && $rocketBg.addEventListener('transitionend', e => {
|
||||
LoadingScreen.$bgStyle.textContent += compressCss(`
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { MouseButtonCode, WheelCode, type KeyCode } from "@/enums/mkb";
|
||||
import { MouseButtonCode, WheelCode } from "@/enums/mkb";
|
||||
|
||||
export const enum KeyModifier {
|
||||
CTRL = 1,
|
||||
|
@ -11,8 +11,8 @@ import { BxLogger } from "@utils/bx-logger";
|
||||
import { PointerClient } from "./pointer-client";
|
||||
import { NativeMkbHandler } from "./native-mkb-handler";
|
||||
import { MkbHandler, MouseDataProvider } from "./base-mkb-handler";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { GlobalPref, StreamPref } from "@/enums/pref-keys";
|
||||
import { getGlobalPref, getStreamPref } from "@/utils/pref-utils";
|
||||
import { GamepadKey, GamepadStick } from "@/enums/gamepad";
|
||||
import { MkbPopup } from "./mkb-popup";
|
||||
import type { MkbConvertedPresetData } from "@/types/presets";
|
||||
@ -134,7 +134,7 @@ export class EmulatedMkbHandler extends MkbHandler {
|
||||
private static readonly LOG_TAG = 'EmulatedMkbHandler';
|
||||
|
||||
static isAllowed() {
|
||||
return getPref(PrefKey.MKB_ENABLED) && (AppInterface || !UserAgent.isMobile());
|
||||
return getGlobalPref(GlobalPref.MKB_ENABLED) && (AppInterface || !UserAgent.isMobile());
|
||||
}
|
||||
|
||||
private PRESET!: MkbConvertedPresetData | null;
|
||||
@ -233,10 +233,10 @@ export class EmulatedMkbHandler extends MkbHandler {
|
||||
private vectorLength = (x: number, y: number): number => Math.sqrt(x ** 2 + y ** 2);
|
||||
|
||||
resetXcloudGamepads() {
|
||||
const index = getPref(PrefKey.MKB_P1_SLOT) - 1;
|
||||
const index = getStreamPref(StreamPref.MKB_P1_SLOT) - 1;
|
||||
|
||||
this.xCloudGamepad = generateVirtualControllerMapping(0, {
|
||||
GamepadIndex: getPref(PrefKey.LOCAL_CO_OP_ENABLED) ? index : 0,
|
||||
GamepadIndex: getStreamPref(StreamPref.LOCAL_CO_OP_ENABLED) ? index : 0,
|
||||
Dirty: true,
|
||||
});
|
||||
this.VIRTUAL_GAMEPAD.index = index;
|
||||
@ -590,7 +590,7 @@ export class EmulatedMkbHandler extends MkbHandler {
|
||||
this.isPolling = true;
|
||||
this.escKeyDownTime = -1;
|
||||
|
||||
window.BX_EXPOSED.toggleLocalCoOp(getPref(PrefKey.LOCAL_CO_OP_ENABLED));
|
||||
window.BX_EXPOSED.toggleLocalCoOp(getStreamPref(StreamPref.LOCAL_CO_OP_ENABLED));
|
||||
this.resetXcloudGamepads();
|
||||
window.navigator.getGamepads = this.patchedGetGamepads;
|
||||
|
||||
@ -650,7 +650,7 @@ export class EmulatedMkbHandler extends MkbHandler {
|
||||
});
|
||||
|
||||
if (EmulatedMkbHandler.isAllowed()) {
|
||||
BxEventBus.Script.on('mkb.setting.updated', () => {
|
||||
BxEventBus.Stream.on('mkb.setting.updated', () => {
|
||||
EmulatedMkbHandler.getInstance()?.refreshPresetData();
|
||||
});
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ export class MkbPopup {
|
||||
constructor() {
|
||||
this.render();
|
||||
|
||||
BxEventBus.Script.on('keyboardShortcuts.updated', () => {
|
||||
BxEventBus.Stream.on('keyboardShortcuts.updated', () => {
|
||||
const $newButton = this.createActivateButton();
|
||||
this.$btnActivate.replaceWith($newButton);
|
||||
this.$btnActivate = $newButton;
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { GlobalPref } from "@/enums/pref-keys";
|
||||
import { getGlobalPref } from "@/utils/pref-utils";
|
||||
|
||||
export class MouseCursorHider {
|
||||
private static instance: MouseCursorHider | null | undefined;
|
||||
public static getInstance(): typeof MouseCursorHider['instance'] {
|
||||
if (typeof MouseCursorHider.instance === 'undefined') {
|
||||
if (!getPref(PrefKey.MKB_ENABLED) && getPref(PrefKey.MKB_HIDE_IDLE_CURSOR)) {
|
||||
if (!getGlobalPref(GlobalPref.MKB_ENABLED) && getGlobalPref(GlobalPref.MKB_HIDE_IDLE_CURSOR)) {
|
||||
MouseCursorHider.instance = new MouseCursorHider();
|
||||
} else {
|
||||
MouseCursorHider.instance = null;
|
||||
|
@ -4,8 +4,7 @@ import { AppInterface, STATES } from "@/utils/global";
|
||||
import { MkbHandler } from "./base-mkb-handler";
|
||||
import { t } from "@/utils/translation";
|
||||
import { BxEvent } from "@/utils/bx-event";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { GlobalPref, StreamPref } from "@/enums/pref-keys";
|
||||
import { BxLogger } from "@/utils/bx-logger";
|
||||
import { MkbPopup } from "./mkb-popup";
|
||||
import { KeyHelper } from "./key-helper";
|
||||
@ -13,7 +12,7 @@ import { StreamSettings } from "@/utils/stream-settings";
|
||||
import { ShortcutAction } from "@/enums/shortcut-actions";
|
||||
import { NativeMkbMode } from "@/enums/pref-values";
|
||||
import { BxEventBus } from "@/utils/bx-event-bus";
|
||||
import type { NativeMouseData, XcloudInputChannel } from "@/utils/gamepad";
|
||||
import { getStreamPref, getGlobalPref } from "@/utils/pref-utils";
|
||||
|
||||
export class NativeMkbHandler extends MkbHandler {
|
||||
private static instance: NativeMkbHandler | null | undefined;
|
||||
@ -31,7 +30,7 @@ export class NativeMkbHandler extends MkbHandler {
|
||||
private readonly LOG_TAG = 'NativeMkbHandler';
|
||||
|
||||
static isAllowed = () => {
|
||||
return STATES.browser.capabilities.emulatedNativeMkb && getPref(PrefKey.NATIVE_MKB_MODE) === NativeMkbMode.ON;
|
||||
return STATES.browser.capabilities.emulatedNativeMkb && getGlobalPref(GlobalPref.NATIVE_MKB_MODE) === NativeMkbMode.ON;
|
||||
}
|
||||
|
||||
private pointerClient: PointerClient | undefined;
|
||||
@ -113,8 +112,8 @@ export class NativeMkbHandler extends MkbHandler {
|
||||
Toast.show('Cannot enable Mouse & Keyboard feature');
|
||||
}
|
||||
|
||||
this.mouseVerticalMultiply = getPref(PrefKey.NATIVE_MKB_SCROLL_VERTICAL_SENSITIVITY);
|
||||
this.mouseHorizontalMultiply = getPref(PrefKey.NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY);
|
||||
this.mouseVerticalMultiply = getStreamPref(StreamPref.NATIVE_MKB_SCROLL_VERTICAL_SENSITIVITY);
|
||||
this.mouseHorizontalMultiply = getStreamPref(StreamPref.NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY);
|
||||
|
||||
window.addEventListener('keyup', this);
|
||||
|
||||
|
@ -11,8 +11,8 @@ import codeGameCardIcons from "./patches/game-card-icons.js" with { type: "text"
|
||||
import codeLocalCoOpEnable from "./patches/local-co-op-enable.js" with { type: "text" };
|
||||
import codeRemotePlayKeepAlive from "./patches/remote-play-keep-alive.js" with { type: "text" };
|
||||
import codeVibrationAdjust from "./patches/vibration-adjust.js" with { type: "text" };
|
||||
import { PrefKey, StorageKey } from "@/enums/pref-keys.js";
|
||||
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { GlobalPref, StorageKey } from "@/enums/pref-keys.js";
|
||||
import { getGlobalPref } from "@/utils/pref-utils.js";
|
||||
import { GamePassCloudGallery } from "@/enums/game-pass-gallery";
|
||||
import { t } from "@/utils/translation";
|
||||
import { BlockFeature, NativeMkbMode, TouchControllerMode, UiLayout, UiSection } from "@/enums/pref-values";
|
||||
@ -89,7 +89,7 @@ const PATCHES = {
|
||||
return false;
|
||||
}
|
||||
|
||||
const layout = getPref(PrefKey.UI_LAYOUT) === UiLayout.TV ? UiLayout.TV : UiLayout.DEFAULT;
|
||||
const layout = getGlobalPref(GlobalPref.UI_LAYOUT) === UiLayout.TV ? UiLayout.TV : UiLayout.DEFAULT;
|
||||
return str.replace(text, `?"${layout}":"${layout}"`);
|
||||
},
|
||||
|
||||
@ -189,7 +189,7 @@ remotePlayServerId: (window.BX_REMOTE_PLAY_CONFIG && window.BX_REMOTE_PLAY_CONFI
|
||||
str = PatcherUtils.replaceWith(str, setTimeoutIndex, tmp, tmpPatched);
|
||||
|
||||
// Block gamepad stats collecting
|
||||
if (getPref(PrefKey.BLOCK_TRACKING)) {
|
||||
if (getGlobalPref(GlobalPref.BLOCK_TRACKING)) {
|
||||
codeBlock = codeBlock.replace('this.inputPollingIntervalStats.addValue', '');
|
||||
codeBlock = codeBlock.replace('this.inputPollingDurationStats.addValue', '');
|
||||
}
|
||||
@ -377,9 +377,9 @@ if (window.BX_EXPOSED.stopTakRendering) {
|
||||
}
|
||||
|
||||
let autoOffCode = '';
|
||||
if (getPref(PrefKey.TOUCH_CONTROLLER_MODE) === TouchControllerMode.OFF) {
|
||||
if (getGlobalPref(GlobalPref.TOUCH_CONTROLLER_MODE) === TouchControllerMode.OFF) {
|
||||
autoOffCode = 'return;';
|
||||
} else if (getPref(PrefKey.TOUCH_CONTROLLER_AUTO_OFF)) {
|
||||
} else if (getGlobalPref(GlobalPref.TOUCH_CONTROLLER_AUTO_OFF)) {
|
||||
autoOffCode = `
|
||||
const gamepads = window.navigator.getGamepads();
|
||||
let gamepadFound = false;
|
||||
@ -434,7 +434,7 @@ e.guideUI = null;
|
||||
`;
|
||||
|
||||
// Remove the TAK Edit button when the touch controller is disabled
|
||||
if (getPref(PrefKey.TOUCH_CONTROLLER_MODE) === TouchControllerMode.OFF) {
|
||||
if (getGlobalPref(GlobalPref.TOUCH_CONTROLLER_MODE) === TouchControllerMode.OFF) {
|
||||
newCode += 'e.canShowTakHUD = false;';
|
||||
}
|
||||
|
||||
@ -554,7 +554,7 @@ BxLogger.info('patchRemotePlayMkb', ${configsVar});
|
||||
return false;
|
||||
}
|
||||
|
||||
const opacity = (getPref(PrefKey.TOUCH_CONTROLLER_DEFAULT_OPACITY) / 100).toFixed(1);
|
||||
const opacity = (getGlobalPref(GlobalPref.TOUCH_CONTROLLER_DEFAULT_OPACITY) / 100).toFixed(1);
|
||||
const newCode = `opacityMultiplier: ${opacity}`;
|
||||
str = str.replace(text, newCode);
|
||||
return str;
|
||||
@ -790,7 +790,7 @@ true` + text;
|
||||
return false;
|
||||
}
|
||||
|
||||
const PREF_HIDE_SECTIONS = getPref(PrefKey.UI_HIDE_SECTIONS);
|
||||
const PREF_HIDE_SECTIONS = getGlobalPref(GlobalPref.UI_HIDE_SECTIONS);
|
||||
const siglIds: GamePassCloudGallery[] = [];
|
||||
|
||||
const sections: PartialRecord<UiSection, GamePassCloudGallery> = {
|
||||
@ -981,7 +981,7 @@ if (this.baseStorageKey in window.BX_EXPOSED.overrideSettings) {
|
||||
|
||||
// Find index after {
|
||||
index = str.indexOf('{', index) + 1;
|
||||
const blockFeatures = getPref(PrefKey.BLOCK_FEATURES);
|
||||
const blockFeatures = getGlobalPref(GlobalPref.BLOCK_FEATURES);
|
||||
const filters = [];
|
||||
if (blockFeatures.includes(BlockFeature.NOTIFICATIONS_INVITES)) {
|
||||
filters.push('GameInvite', 'PartyInvite');
|
||||
@ -1097,7 +1097,7 @@ ${subsVar} = subs;
|
||||
// Find "return" keyword
|
||||
index = PatcherUtils.indexOf(str, 'return', index, 200);
|
||||
|
||||
const newCode = `${paramVar}.set('q', ${getPref(PrefKey.UI_IMAGE_QUALITY)});`;
|
||||
const newCode = `${paramVar}.set('q', ${getGlobalPref(GlobalPref.UI_IMAGE_QUALITY)});`;
|
||||
str = PatcherUtils.insertAt(str, index, newCode);
|
||||
|
||||
return str;
|
||||
@ -1111,13 +1111,13 @@ ${subsVar} = subs;
|
||||
return false;
|
||||
}
|
||||
|
||||
str = PatcherUtils.insertAt(str, index, `&q=${getPref(PrefKey.UI_IMAGE_QUALITY)}`);
|
||||
str = PatcherUtils.insertAt(str, index, `&q=${getGlobalPref(GlobalPref.UI_IMAGE_QUALITY)}`);
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
let PATCH_ORDERS = PatcherUtils.filterPatches([
|
||||
...(AppInterface && getPref(PrefKey.NATIVE_MKB_MODE) === NativeMkbMode.ON ? [
|
||||
...(AppInterface && getGlobalPref(GlobalPref.NATIVE_MKB_MODE) === NativeMkbMode.ON ? [
|
||||
'enableNativeMkb',
|
||||
'disableAbsoluteMouse',
|
||||
] : []),
|
||||
@ -1126,7 +1126,7 @@ let PATCH_ORDERS = PatcherUtils.filterPatches([
|
||||
'gameCardCustomIcons',
|
||||
// 'gameCardPassTitle',
|
||||
|
||||
...(getPref(PrefKey.UI_IMAGE_QUALITY) < 90 ? [
|
||||
...(getGlobalPref(GlobalPref.UI_IMAGE_QUALITY) < 90 ? [
|
||||
'setImageQuality',
|
||||
] : []),
|
||||
|
||||
@ -1154,16 +1154,16 @@ let PATCH_ORDERS = PatcherUtils.filterPatches([
|
||||
|
||||
'supportLocalCoOp',
|
||||
'overrideStorageGetSettings',
|
||||
getPref(PrefKey.UI_GAME_CARD_SHOW_WAIT_TIME) && 'patchSetCurrentFocus',
|
||||
getGlobalPref(GlobalPref.UI_GAME_CARD_SHOW_WAIT_TIME) && 'patchSetCurrentFocus',
|
||||
|
||||
getPref(PrefKey.UI_LAYOUT) !== UiLayout.DEFAULT && 'websiteLayout',
|
||||
getPref(PrefKey.GAME_FORTNITE_FORCE_CONSOLE) && 'forceFortniteConsole',
|
||||
getGlobalPref(GlobalPref.UI_LAYOUT) !== UiLayout.DEFAULT && 'websiteLayout',
|
||||
getGlobalPref(GlobalPref.GAME_FORTNITE_FORCE_CONSOLE) && 'forceFortniteConsole',
|
||||
|
||||
...(STATES.userAgent.capabilities.touch ? [
|
||||
'disableTouchContextMenu',
|
||||
] : []),
|
||||
|
||||
...(getPref(PrefKey.BLOCK_TRACKING) ? [
|
||||
...(getGlobalPref(GlobalPref.BLOCK_TRACKING) ? [
|
||||
'disableAiTrack',
|
||||
'disableTelemetry',
|
||||
|
||||
@ -1173,7 +1173,7 @@ let PATCH_ORDERS = PatcherUtils.filterPatches([
|
||||
'disableTelemetryProvider',
|
||||
] : []),
|
||||
|
||||
...(getPref(PrefKey.REMOTE_PLAY_ENABLED) ? [
|
||||
...(getGlobalPref(GlobalPref.REMOTE_PLAY_ENABLED) ? [
|
||||
'remotePlayKeepAlive',
|
||||
'remotePlayDirectConnectUrl',
|
||||
'remotePlayDisableAchievementToast',
|
||||
@ -1188,7 +1188,7 @@ let PATCH_ORDERS = PatcherUtils.filterPatches([
|
||||
] : []),
|
||||
]);
|
||||
|
||||
const hideSections = getPref(PrefKey.UI_HIDE_SECTIONS);
|
||||
const hideSections = getGlobalPref(GlobalPref.UI_HIDE_SECTIONS);
|
||||
let HOME_PAGE_PATCH_ORDERS = PatcherUtils.filterPatches([
|
||||
hideSections.includes(UiSection.NEWS) && 'ignoreNewsSection',
|
||||
hideSections.includes(UiSection.FRIENDS) && 'ignorePlayWithFriendsSection',
|
||||
@ -1196,7 +1196,7 @@ let HOME_PAGE_PATCH_ORDERS = PatcherUtils.filterPatches([
|
||||
STATES.browser.capabilities.touch && hideSections.includes(UiSection.TOUCH) && 'ignorePlayWithTouchSection',
|
||||
hideSections.some(value => [UiSection.NATIVE_MKB, UiSection.MOST_POPULAR].includes(value)) && 'ignoreSiglSections',
|
||||
|
||||
...(getPref(PrefKey.UI_IMAGE_QUALITY) < 90 ? [
|
||||
...(getGlobalPref(GlobalPref.UI_IMAGE_QUALITY) < 90 ? [
|
||||
'setBackgroundImageQuality',
|
||||
] : []),
|
||||
|
||||
@ -1206,8 +1206,6 @@ let HOME_PAGE_PATCH_ORDERS = PatcherUtils.filterPatches([
|
||||
]);
|
||||
|
||||
// Only when playing
|
||||
// TODO: check this
|
||||
// @ts-ignore
|
||||
let STREAM_PAGE_PATCH_ORDERS = PatcherUtils.filterPatches([
|
||||
'exposeInputChannel',
|
||||
|
||||
@ -1221,34 +1219,34 @@ let STREAM_PAGE_PATCH_ORDERS = PatcherUtils.filterPatches([
|
||||
// 'exposeEventTarget',
|
||||
|
||||
// Patch volume control for normal stream
|
||||
getPref(PrefKey.AUDIO_VOLUME_CONTROL_ENABLED) && !getPref(PrefKey.STREAM_COMBINE_SOURCES) && 'patchAudioMediaStream',
|
||||
getGlobalPref(GlobalPref.AUDIO_VOLUME_CONTROL_ENABLED) && !getGlobalPref(GlobalPref.STREAM_COMBINE_SOURCES) && 'patchAudioMediaStream',
|
||||
// Patch volume control for combined audio+video stream
|
||||
getPref(PrefKey.AUDIO_VOLUME_CONTROL_ENABLED) && getPref(PrefKey.STREAM_COMBINE_SOURCES) && 'patchCombinedAudioVideoMediaStream',
|
||||
getGlobalPref(GlobalPref.AUDIO_VOLUME_CONTROL_ENABLED) && getGlobalPref(GlobalPref.STREAM_COMBINE_SOURCES) && 'patchCombinedAudioVideoMediaStream',
|
||||
|
||||
// Skip feedback dialog
|
||||
getPref(PrefKey.UI_DISABLE_FEEDBACK_DIALOG) && 'skipFeedbackDialog',
|
||||
getGlobalPref(GlobalPref.UI_DISABLE_FEEDBACK_DIALOG) && 'skipFeedbackDialog',
|
||||
|
||||
...(STATES.userAgent.capabilities.touch ? [
|
||||
getPref(PrefKey.TOUCH_CONTROLLER_MODE) === TouchControllerMode.ALL && 'patchShowSensorControls',
|
||||
getPref(PrefKey.TOUCH_CONTROLLER_MODE) === TouchControllerMode.ALL && 'exposeTouchLayoutManager',
|
||||
(getPref(PrefKey.TOUCH_CONTROLLER_MODE) === TouchControllerMode.OFF || getPref(PrefKey.TOUCH_CONTROLLER_AUTO_OFF)) && 'disableTakRenderer',
|
||||
getPref(PrefKey.TOUCH_CONTROLLER_DEFAULT_OPACITY) !== 100 && 'patchTouchControlDefaultOpacity',
|
||||
(getPref(PrefKey.TOUCH_CONTROLLER_MODE) !== TouchControllerMode.OFF && (getPref(PrefKey.MKB_ENABLED) || getPref(PrefKey.NATIVE_MKB_MODE) === NativeMkbMode.ON)) && 'patchBabylonRendererClass',
|
||||
getGlobalPref(GlobalPref.TOUCH_CONTROLLER_MODE) === TouchControllerMode.ALL && 'patchShowSensorControls',
|
||||
getGlobalPref(GlobalPref.TOUCH_CONTROLLER_MODE) === TouchControllerMode.ALL && 'exposeTouchLayoutManager',
|
||||
(getGlobalPref(GlobalPref.TOUCH_CONTROLLER_MODE) === TouchControllerMode.OFF || getGlobalPref(GlobalPref.TOUCH_CONTROLLER_AUTO_OFF)) && 'disableTakRenderer',
|
||||
getGlobalPref(GlobalPref.TOUCH_CONTROLLER_DEFAULT_OPACITY) !== 100 && 'patchTouchControlDefaultOpacity',
|
||||
(getGlobalPref(GlobalPref.TOUCH_CONTROLLER_MODE) !== TouchControllerMode.OFF && (getGlobalPref(GlobalPref.MKB_ENABLED) || getGlobalPref(GlobalPref.NATIVE_MKB_MODE) === NativeMkbMode.ON)) && 'patchBabylonRendererClass',
|
||||
] : []),
|
||||
|
||||
BX_FLAGS.EnableXcloudLogging && 'enableConsoleLogging',
|
||||
|
||||
'patchPollGamepads',
|
||||
|
||||
getPref(PrefKey.STREAM_COMBINE_SOURCES) && 'streamCombineSources',
|
||||
getGlobalPref(GlobalPref.STREAM_COMBINE_SOURCES) && 'streamCombineSources',
|
||||
|
||||
...(getPref(PrefKey.REMOTE_PLAY_ENABLED) ? [
|
||||
...(getGlobalPref(GlobalPref.REMOTE_PLAY_ENABLED) ? [
|
||||
'patchRemotePlayMkb',
|
||||
'remotePlayConnectMode',
|
||||
] : []),
|
||||
|
||||
// Native MKB
|
||||
...(AppInterface && getPref(PrefKey.NATIVE_MKB_MODE) === NativeMkbMode.ON ? [
|
||||
...(AppInterface && getGlobalPref(GlobalPref.NATIVE_MKB_MODE) === NativeMkbMode.ON ? [
|
||||
'patchMouseAndKeyboardEnabled',
|
||||
'disableNativeRequestPointerLock',
|
||||
] : []),
|
||||
|
@ -53,6 +53,9 @@ $this$.toggleLocalCoOp = (enable: boolean) => {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Don't show toast
|
||||
(gamepad as any)._noToast = true;
|
||||
|
||||
window.dispatchEvent(new GamepadEvent('gamepaddisconnected', { gamepad }));
|
||||
window.dispatchEvent(new GamepadEvent('gamepadconnected', { gamepad }));
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
import vertClarityBoost from "./shaders/clarity_boost.vert" with { type: "text" };
|
||||
import fsClarityBoost from "./shaders/clarity_boost.fs" with { type: "text" };
|
||||
import { BxLogger } from "@/utils/bx-logger";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { StreamPref } from "@/enums/pref-keys";
|
||||
import { getStreamPref } from "@/utils/pref-utils";
|
||||
|
||||
|
||||
export class WebGL2Player {
|
||||
@ -143,13 +143,13 @@ export class WebGL2Player {
|
||||
}
|
||||
|
||||
private setupShaders() {
|
||||
BxLogger.info(this.LOG_TAG, 'Setting up', getPref(PrefKey.VIDEO_POWER_PREFERENCE));
|
||||
BxLogger.info(this.LOG_TAG, 'Setting up', getStreamPref(StreamPref.VIDEO_POWER_PREFERENCE));
|
||||
|
||||
const gl = this.$canvas.getContext('webgl2', {
|
||||
isBx: true,
|
||||
antialias: true,
|
||||
alpha: false,
|
||||
powerPreference: getPref(PrefKey.VIDEO_POWER_PREFERENCE),
|
||||
powerPreference: getStreamPref(StreamPref.VIDEO_POWER_PREFERENCE),
|
||||
}) as WebGL2RenderingContext;
|
||||
this.gl = gl;
|
||||
|
||||
|
@ -5,8 +5,8 @@ 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 { GlobalPref } from "@/enums/pref-keys";
|
||||
import { getGlobalPref, setGlobalPref } from "@/utils/pref-utils";
|
||||
import { RemotePlayDialog } from "./ui/dialog/remote-play-dialog";
|
||||
|
||||
export const enum RemotePlayConsoleState {
|
||||
@ -37,7 +37,7 @@ export class RemotePlayManager {
|
||||
private static instance: RemotePlayManager | null | undefined;
|
||||
public static getInstance(): typeof RemotePlayManager['instance'] {
|
||||
if (typeof RemotePlayManager.instance === 'undefined') {
|
||||
if (getPref(PrefKey.REMOTE_PLAY_ENABLED)) {
|
||||
if (getGlobalPref(GlobalPref.REMOTE_PLAY_ENABLED)) {
|
||||
RemotePlayManager.instance = new RemotePlayManager();
|
||||
} else {
|
||||
RemotePlayManager.instance = null;
|
||||
@ -186,7 +186,7 @@ export class RemotePlayManager {
|
||||
|
||||
play(serverId: string, resolution?: string) {
|
||||
if (resolution) {
|
||||
setPref(PrefKey.REMOTE_PLAY_STREAM_RESOLUTION, resolution);
|
||||
setGlobalPref(GlobalPref.REMOTE_PLAY_STREAM_RESOLUTION, resolution, 'ui');
|
||||
}
|
||||
|
||||
STATES.remotePlay.config = {
|
||||
@ -221,7 +221,7 @@ export class RemotePlayManager {
|
||||
}
|
||||
|
||||
static detect() {
|
||||
if (!getPref(PrefKey.REMOTE_PLAY_ENABLED)) {
|
||||
if (!getGlobalPref(GlobalPref.REMOTE_PLAY_ENABLED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
345
src/modules/settings-manager.ts
Normal file
345
src/modules/settings-manager.ts
Normal file
@ -0,0 +1,345 @@
|
||||
import { GlobalPref, StreamPref, type AnyPref } from "@/enums/pref-keys";
|
||||
import { limitVideoPlayerFps, onChangeVideoPlayerType, updateVideoPlayer } from "./stream/stream-settings-utils";
|
||||
import { StreamStats } from "./stream/stream-stats";
|
||||
import { SoundShortcut } from "./shortcuts/sound-shortcut";
|
||||
import { STATES } from "@/utils/global";
|
||||
import { getGamePref, getStreamPref, hasGamePref, isStreamPref, setGameIdPref } from "@/utils/pref-utils";
|
||||
import { BxExposed } from "@/utils/bx-exposed";
|
||||
import { StreamSettings } from "@/utils/stream-settings";
|
||||
import { NativeMkbHandler } from "./mkb/native-mkb-handler";
|
||||
import { BxEventBus } from "@/utils/bx-event-bus";
|
||||
import { SettingElement } from "@/utils/setting-element";
|
||||
import { CE } from "@/utils/html";
|
||||
import { t } from "@/utils/translation";
|
||||
import { BxSelectElement } from "@/web-components/bx-select";
|
||||
import { XboxApi } from "@/utils/xbox-api";
|
||||
import { EmulatedMkbHandler } from "./mkb/mkb-handler";
|
||||
|
||||
type SettingType = Partial<{
|
||||
hidden: true;
|
||||
onChange: () => void;
|
||||
alwaysTriggerOnChange: boolean; // Always trigger onChange(), not just when playing
|
||||
$element: HTMLElement;
|
||||
}>;
|
||||
|
||||
export class SettingsManager {
|
||||
private static instance: SettingsManager;
|
||||
public static getInstance = () => SettingsManager.instance ?? (SettingsManager.instance = new SettingsManager());
|
||||
|
||||
private $streamSettingsSelection!: HTMLElement;
|
||||
private $tips!: HTMLElement;
|
||||
private playingGameId: number = -1;
|
||||
private targetGameId: number = -1;
|
||||
|
||||
// @ts-ignore
|
||||
private SETTINGS: Record<GlobalPref | StreamPref, SettingType> = {
|
||||
// [GlobalPref.VERSION_LATEST]: { hidden: true },
|
||||
// [GlobalPref.VERSION_LAST_CHECK]: { hidden: true },
|
||||
// [GlobalPref.VERSION_CURRENT]: { hidden: true },
|
||||
|
||||
[StreamPref.LOCAL_CO_OP_ENABLED]: {
|
||||
onChange: () => {
|
||||
BxExposed.toggleLocalCoOp(getStreamPref(StreamPref.LOCAL_CO_OP_ENABLED));
|
||||
},
|
||||
},
|
||||
[StreamPref.DEVICE_VIBRATION_MODE]: {
|
||||
onChange: StreamSettings.refreshControllerSettings,
|
||||
},
|
||||
[StreamPref.DEVICE_VIBRATION_INTENSITY]: {
|
||||
onChange: StreamSettings.refreshControllerSettings,
|
||||
},
|
||||
[StreamPref.CONTROLLER_POLLING_RATE]: {
|
||||
onChange: StreamSettings.refreshControllerSettings,
|
||||
},
|
||||
[StreamPref.CONTROLLER_SETTINGS]: {
|
||||
onChange: StreamSettings.refreshControllerSettings,
|
||||
},
|
||||
[StreamPref.NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY]: {
|
||||
onChange: () => {
|
||||
const value = getStreamPref(StreamPref.NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY);
|
||||
NativeMkbHandler.getInstance()?.setHorizontalScrollMultiplier(value / 100);
|
||||
},
|
||||
},
|
||||
[StreamPref.NATIVE_MKB_SCROLL_VERTICAL_SENSITIVITY]: {
|
||||
onChange: () => {
|
||||
const value = getStreamPref(StreamPref.NATIVE_MKB_SCROLL_VERTICAL_SENSITIVITY);
|
||||
NativeMkbHandler.getInstance()?.setVerticalScrollMultiplier(value / 100);
|
||||
},
|
||||
},
|
||||
[StreamPref.VIDEO_PLAYER_TYPE]: {
|
||||
onChange: () => {
|
||||
onChangeVideoPlayerType();
|
||||
|
||||
if (STATES.isPlaying) {
|
||||
updateVideoPlayer();
|
||||
}
|
||||
},
|
||||
alwaysTriggerOnChange: true,
|
||||
},
|
||||
[StreamPref.VIDEO_POWER_PREFERENCE]: {
|
||||
onChange: () => {
|
||||
const streamPlayer = STATES.currentStream.streamPlayer;
|
||||
if (!streamPlayer) {
|
||||
return;
|
||||
}
|
||||
|
||||
streamPlayer.reloadPlayer();
|
||||
updateVideoPlayer();
|
||||
},
|
||||
},
|
||||
[StreamPref.VIDEO_PROCESSING]: {
|
||||
onChange: updateVideoPlayer,
|
||||
},
|
||||
[StreamPref.VIDEO_SHARPNESS]: {
|
||||
onChange: updateVideoPlayer,
|
||||
},
|
||||
[StreamPref.VIDEO_MAX_FPS]: {
|
||||
onChange: () => {
|
||||
const value = getStreamPref(StreamPref.VIDEO_MAX_FPS);
|
||||
limitVideoPlayerFps(value);
|
||||
},
|
||||
},
|
||||
[StreamPref.VIDEO_RATIO]: {
|
||||
onChange: updateVideoPlayer,
|
||||
},
|
||||
[StreamPref.VIDEO_BRIGHTNESS]: {
|
||||
onChange: updateVideoPlayer,
|
||||
},
|
||||
[StreamPref.VIDEO_CONTRAST]: {
|
||||
onChange: updateVideoPlayer,
|
||||
},
|
||||
[StreamPref.VIDEO_SATURATION]: {
|
||||
onChange: updateVideoPlayer,
|
||||
},
|
||||
[StreamPref.VIDEO_POSITION]: {
|
||||
onChange: updateVideoPlayer,
|
||||
},
|
||||
[StreamPref.AUDIO_VOLUME]: {
|
||||
onChange: () => {
|
||||
const value = getStreamPref(StreamPref.AUDIO_VOLUME);
|
||||
SoundShortcut.setGainNodeVolume(value);
|
||||
},
|
||||
},
|
||||
|
||||
[StreamPref.STATS_ITEMS]: {
|
||||
onChange: StreamStats.refreshStyles,
|
||||
},
|
||||
[StreamPref.STATS_QUICK_GLANCE_ENABLED]: {
|
||||
onChange: () => {
|
||||
const value = getStreamPref(StreamPref.STATS_QUICK_GLANCE_ENABLED);
|
||||
const streamStats = StreamStats.getInstance();
|
||||
value ? streamStats.quickGlanceSetup() : streamStats.quickGlanceStop();
|
||||
},
|
||||
},
|
||||
[StreamPref.STATS_POSITION]: {
|
||||
onChange: StreamStats.refreshStyles,
|
||||
},
|
||||
[StreamPref.STATS_TEXT_SIZE]: {
|
||||
onChange: StreamStats.refreshStyles,
|
||||
},
|
||||
[StreamPref.STATS_OPACITY_ALL]: {
|
||||
onChange: StreamStats.refreshStyles,
|
||||
},
|
||||
[StreamPref.STATS_OPACITY_BACKGROUND]: {
|
||||
onChange: StreamStats.refreshStyles,
|
||||
},
|
||||
[StreamPref.STATS_CONDITIONAL_FORMATTING]: {
|
||||
onChange: StreamStats.refreshStyles,
|
||||
},
|
||||
|
||||
[StreamPref.MKB_P1_MAPPING_PRESET_ID]: {
|
||||
onChange: StreamSettings.refreshMkbSettings,
|
||||
},
|
||||
|
||||
[StreamPref.MKB_P1_SLOT]: {
|
||||
onChange: () => {
|
||||
EmulatedMkbHandler.getInstance()?.resetXcloudGamepads();
|
||||
},
|
||||
},
|
||||
|
||||
[StreamPref.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID]: {
|
||||
onChange: StreamSettings.refreshKeyboardShortcuts,
|
||||
},
|
||||
};
|
||||
|
||||
constructor() {
|
||||
// Trigger onChange event when a setting value is modified
|
||||
BxEventBus.Stream.on('setting.changed', data => {
|
||||
if (isStreamPref(data.settingKey)) {
|
||||
this.updateStreamElement(data.settingKey);
|
||||
}
|
||||
});
|
||||
|
||||
BxEventBus.Stream.on('gameSettings.switched', ({ id }) => {
|
||||
this.switchGameSettings(id);
|
||||
});
|
||||
|
||||
this.renderStreamSettingsSelection();
|
||||
}
|
||||
|
||||
private updateStreamElement(key: StreamPref, onChanges?: Set<SettingType['onChange']>) {
|
||||
const info = this.SETTINGS[key];
|
||||
|
||||
// Add event
|
||||
if (info.onChange && (STATES.isPlaying || info.alwaysTriggerOnChange)) {
|
||||
if (onChanges) {
|
||||
// Save to a Set()
|
||||
onChanges.add(info.onChange);
|
||||
} else {
|
||||
// Trigger onChange()
|
||||
info.onChange();
|
||||
}
|
||||
}
|
||||
|
||||
// Update element
|
||||
const $elm = info.$element;
|
||||
if (!$elm) {
|
||||
return;
|
||||
}
|
||||
|
||||
const value = getGamePref(this.targetGameId, key, true)!;
|
||||
|
||||
if ('setValue' in $elm) {
|
||||
($elm as any).setValue(value);
|
||||
} else {
|
||||
($elm as HTMLInputElement).value = value.toString();
|
||||
}
|
||||
|
||||
this.updateDataset($elm, key as StreamPref);
|
||||
}
|
||||
|
||||
private switchGameSettings(id: number) {
|
||||
setGameIdPref(id);
|
||||
|
||||
// Don't re-apply settings if the game is the same
|
||||
if (this.targetGameId === id) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Re-apply all stream settings
|
||||
const onChanges: Set<SettingType['onChange']> = new Set();
|
||||
const oldGameId = this.targetGameId;
|
||||
this.targetGameId = id;
|
||||
|
||||
let key: AnyPref;
|
||||
for (key in this.SETTINGS) {
|
||||
if (!isStreamPref(key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const oldValue = getGamePref(oldGameId, key, true, true);
|
||||
const newValue = getGamePref(this.targetGameId, key, true, true);
|
||||
|
||||
if (oldValue === newValue) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Only apply Stream settings
|
||||
this.updateStreamElement(key, onChanges);
|
||||
}
|
||||
|
||||
// BxLogger.warning('Settings Manager', onChanges);
|
||||
onChanges.forEach(onChange => {
|
||||
onChange && onChange();
|
||||
});
|
||||
|
||||
// Toggle tips if not playing anything
|
||||
this.$tips.classList.toggle('bx-gone', id < 0);
|
||||
}
|
||||
|
||||
setElement(pref: AnyPref, $elm: HTMLElement) {
|
||||
// Set empty object
|
||||
if (!this.SETTINGS[pref]) {
|
||||
this.SETTINGS[pref] = {};
|
||||
}
|
||||
|
||||
this.updateDataset($elm, pref as StreamPref);
|
||||
this.SETTINGS[pref].$element = $elm;
|
||||
}
|
||||
|
||||
getElement(pref: AnyPref, params?: any) {
|
||||
// Set empty object
|
||||
if (!this.SETTINGS[pref]) {
|
||||
this.SETTINGS[pref] = {};
|
||||
}
|
||||
|
||||
let $elm = this.SETTINGS[pref].$element;
|
||||
|
||||
if (!$elm) {
|
||||
// Render element
|
||||
$elm = SettingElement.fromPref(pref, null, params)!;
|
||||
this.SETTINGS[pref].$element = $elm;
|
||||
}
|
||||
|
||||
this.updateDataset($elm, pref as StreamPref);
|
||||
return $elm;
|
||||
}
|
||||
|
||||
hasElement(pref: AnyPref) {
|
||||
return !!this.SETTINGS[pref]?.$element;
|
||||
}
|
||||
|
||||
private updateDataset($elm: HTMLElement, pref: StreamPref) {
|
||||
if (this.targetGameId === this.playingGameId && hasGamePref(this.playingGameId, pref)) {
|
||||
$elm.dataset.override = 'true';
|
||||
} else {
|
||||
delete $elm.dataset['override'];
|
||||
}
|
||||
}
|
||||
|
||||
private renderStreamSettingsSelection() {
|
||||
this.$tips = CE('p', { class: 'bx-gone' }, `⇐ Q ⟶: ${t('reset-highlighted-setting')}`);
|
||||
|
||||
const $select = BxSelectElement.create(CE('select', false,
|
||||
CE('optgroup', { label: t('settings-for') },
|
||||
CE('option', { value: -1 }, t('all-games')),
|
||||
),
|
||||
), true);
|
||||
$select.addEventListener('input', e => {
|
||||
const id = parseInt($select.value);
|
||||
// $btn.disabled = id < 0;
|
||||
BxEventBus.Stream.emit('gameSettings.switched', { id });
|
||||
});
|
||||
|
||||
this.$streamSettingsSelection = CE('div', {
|
||||
class: 'bx-stream-settings-selection bx-gone',
|
||||
_nearby: { orientation: 'vertical' },
|
||||
},
|
||||
CE('div', false, $select ),
|
||||
this.$tips,
|
||||
);
|
||||
|
||||
BxEventBus.Stream.on('xboxTitleId.changed', async ({ id }) => {
|
||||
this.playingGameId = id;
|
||||
setGameIdPref(id);
|
||||
const $optGroup = $select.querySelector('optgroup')!;
|
||||
|
||||
// Remove every options except the first one (All games)
|
||||
while ($optGroup.childElementCount > 1) {
|
||||
$optGroup.lastElementChild?.remove();
|
||||
}
|
||||
|
||||
// Add current game to the selection
|
||||
if (id >= 0) {
|
||||
const title = id === 0 ? 'Xbox' : await XboxApi.getProductTitle(id);
|
||||
$optGroup.appendChild(CE('option', {
|
||||
value: id,
|
||||
}, title));
|
||||
|
||||
$select.value = id.toString();
|
||||
} else {
|
||||
$select.value = '-1';
|
||||
}
|
||||
|
||||
BxEventBus.Stream.emit('gameSettings.switched', { id });
|
||||
});
|
||||
}
|
||||
|
||||
getStreamSettingsSelection() {
|
||||
return this.$streamSettingsSelection;
|
||||
}
|
||||
|
||||
getTargetGameId() {
|
||||
return this.targetGameId;
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { StreamPref } from "@/enums/pref-keys";
|
||||
import { limitVideoPlayerFps } from "../stream/stream-settings-utils";
|
||||
import { BxEventBus } from "@/utils/bx-event-bus";
|
||||
import { getStreamPref } from "@/utils/pref-utils";
|
||||
|
||||
export class RendererShortcut {
|
||||
static toggleVisibility() {
|
||||
@ -15,7 +15,7 @@ export class RendererShortcut {
|
||||
const isVisible = !$mediaContainer.classList.contains('bx-gone');
|
||||
|
||||
// Switch FPS
|
||||
limitVideoPlayerFps(isVisible ? getPref(PrefKey.VIDEO_MAX_FPS) : 0);
|
||||
limitVideoPlayerFps(isVisible ? getStreamPref(StreamPref.VIDEO_MAX_FPS) : 0);
|
||||
BxEventBus.Stream.emit('video.visibility.changed', { isVisible });
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { GlobalPref } from "@/enums/pref-keys";
|
||||
import { ShortcutAction } from "@/enums/shortcut-actions";
|
||||
import { AppInterface, STATES } from "@/utils/global";
|
||||
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { getGlobalPref } from "@/utils/pref-utils";
|
||||
import { t } from "@/utils/translation";
|
||||
|
||||
type ShortcutActions = {
|
||||
@ -46,7 +46,7 @@ export const SHORTCUT_ACTIONS: ShortcutActions = {
|
||||
|
||||
[ShortcutAction.STREAM_SOUND_TOGGLE]: [t('sound'), t('toggle')],
|
||||
|
||||
...(getPref(PrefKey.AUDIO_VOLUME_CONTROL_ENABLED) ? {
|
||||
...(getGlobalPref(GlobalPref.AUDIO_VOLUME_CONTROL_ENABLED) ? {
|
||||
[ShortcutAction.STREAM_VOLUME_INC]: [t('volume'), t('increase')],
|
||||
[ShortcutAction.STREAM_VOLUME_DEC]: [t('volume'), t('decrease')],
|
||||
} : {}),
|
||||
|
@ -2,9 +2,10 @@ import { t } from "@utils/translation";
|
||||
import { STATES } from "@utils/global";
|
||||
import { Toast } from "@utils/toast";
|
||||
import { ceilToNearest, floorToNearest } from "@/utils/utils";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref, setPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { GlobalPref, StreamPref } from "@/enums/pref-keys";
|
||||
import { getGlobalPref } from "@/utils/pref-utils";
|
||||
import { BxEventBus } from "@/utils/bx-event-bus";
|
||||
import { getStreamPref, setStreamPref } from "@/utils/pref-utils";
|
||||
|
||||
export enum SpeakerState {
|
||||
ENABLED,
|
||||
@ -13,11 +14,11 @@ export enum SpeakerState {
|
||||
|
||||
export class SoundShortcut {
|
||||
static adjustGainNodeVolume(amount: number): number {
|
||||
if (!getPref(PrefKey.AUDIO_VOLUME_CONTROL_ENABLED)) {
|
||||
if (!getGlobalPref(GlobalPref.AUDIO_VOLUME_CONTROL_ENABLED)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const currentValue = getPref(PrefKey.AUDIO_VOLUME);
|
||||
const currentValue = getStreamPref(StreamPref.AUDIO_VOLUME);
|
||||
let nearestValue: number;
|
||||
|
||||
if (amount > 0) { // Increase
|
||||
@ -33,7 +34,7 @@ export class SoundShortcut {
|
||||
newValue = currentValue + amount;
|
||||
}
|
||||
|
||||
newValue = setPref(PrefKey.AUDIO_VOLUME, newValue, true);
|
||||
newValue = setStreamPref(StreamPref.AUDIO_VOLUME, newValue, 'direct');
|
||||
SoundShortcut.setGainNodeVolume(newValue);
|
||||
|
||||
// Show toast
|
||||
@ -47,14 +48,14 @@ export class SoundShortcut {
|
||||
}
|
||||
|
||||
static muteUnmute() {
|
||||
if (getPref(PrefKey.AUDIO_VOLUME_CONTROL_ENABLED) && STATES.currentStream.audioGainNode) {
|
||||
if (getGlobalPref(GlobalPref.AUDIO_VOLUME_CONTROL_ENABLED) && STATES.currentStream.audioGainNode) {
|
||||
const gainValue = STATES.currentStream.audioGainNode.gain.value;
|
||||
const settingValue = getPref(PrefKey.AUDIO_VOLUME);
|
||||
const settingValue = getStreamPref(StreamPref.AUDIO_VOLUME);
|
||||
|
||||
let targetValue: number;
|
||||
if (settingValue === 0) { // settingValue is 0 => set to 100
|
||||
targetValue = 100;
|
||||
setPref(PrefKey.AUDIO_VOLUME, targetValue, true);
|
||||
setStreamPref(StreamPref.AUDIO_VOLUME, targetValue, 'direct');
|
||||
} else if (gainValue === 0) { // is being muted => set to settingValue
|
||||
targetValue = settingValue;
|
||||
} else { // not being muted => mute
|
||||
|
@ -4,18 +4,12 @@ import { CE } from "@/utils/html";
|
||||
import { WebGL2Player } from "./player/webgl2-player";
|
||||
import { ScreenshotManager } from "@/utils/screenshot-manager";
|
||||
import { STATES } from "@/utils/global";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { GlobalPref, StreamPref } from "@/enums/pref-keys";
|
||||
import { getGlobalPref } from "@/utils/pref-utils";
|
||||
import { BX_FLAGS } from "@/utils/bx-flags";
|
||||
import { StreamPlayerType, StreamVideoProcessing, VideoPosition } from "@/enums/pref-values";
|
||||
import { getStreamPref } from "@/utils/pref-utils";
|
||||
|
||||
export type StreamPlayerOptions = Partial<{
|
||||
processing: string,
|
||||
sharpness: number,
|
||||
saturation: number,
|
||||
contrast: number,
|
||||
brightness: number,
|
||||
}>;
|
||||
|
||||
export class StreamPlayer {
|
||||
private $video: HTMLVideoElement;
|
||||
@ -98,7 +92,7 @@ export class StreamPlayer {
|
||||
}
|
||||
|
||||
private resizePlayer() {
|
||||
const PREF_RATIO = getPref(PrefKey.VIDEO_RATIO);
|
||||
const PREF_RATIO = getStreamPref(StreamPref.VIDEO_RATIO);
|
||||
const $video = this.$video;
|
||||
const isNativeTouchGame = STATES.currentStream.titleInfo?.details.hasNativeTouchSupport;
|
||||
|
||||
@ -142,7 +136,7 @@ export class StreamPlayer {
|
||||
|
||||
// Set position
|
||||
const $parent = $video.parentElement!;
|
||||
const position = getPref(PrefKey.VIDEO_POSITION);
|
||||
const position = getStreamPref(StreamPref.VIDEO_POSITION);
|
||||
$parent.style.removeProperty('padding-top');
|
||||
|
||||
$parent.dataset.position = position;
|
||||
@ -269,7 +263,7 @@ export class StreamPlayer {
|
||||
}
|
||||
|
||||
// Apply video filters to screenshots
|
||||
if (isFullVersion() && getPref(PrefKey.SCREENSHOT_APPLY_FILTERS)) {
|
||||
if (isFullVersion() && getGlobalPref(GlobalPref.SCREENSHOT_APPLY_FILTERS)) {
|
||||
ScreenshotManager.getInstance().updateCanvasFilters(filters);
|
||||
}
|
||||
|
||||
|
@ -1,24 +1,24 @@
|
||||
import { STATES } from "@utils/global";
|
||||
import { UserAgent } from "@utils/user-agent";
|
||||
import type { StreamPlayerOptions } from "../stream-player";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref, setPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { StreamPref } from "@/enums/pref-keys";
|
||||
import { StreamVideoProcessing, StreamPlayerType } from "@/enums/pref-values";
|
||||
import { escapeCssSelector } from "@/utils/html";
|
||||
import { getStreamPref, setStreamPref } from "@/utils/pref-utils";
|
||||
import { SettingsManager } from "../settings-manager";
|
||||
|
||||
export function onChangeVideoPlayerType() {
|
||||
const playerType = getPref(PrefKey.VIDEO_PLAYER_TYPE);
|
||||
const $videoProcessing = document.getElementById(`bx_setting_${escapeCssSelector(PrefKey.VIDEO_PROCESSING)}`) as HTMLSelectElement;
|
||||
const $videoSharpness = document.getElementById(`bx_setting_${escapeCssSelector(PrefKey.VIDEO_SHARPNESS)}`) as HTMLElement;
|
||||
const $videoPowerPreference = document.getElementById(`bx_setting_${escapeCssSelector(PrefKey.VIDEO_POWER_PREFERENCE)}`) as HTMLElement;
|
||||
const $videoMaxFps = document.getElementById(`bx_setting_${escapeCssSelector(PrefKey.VIDEO_MAX_FPS)}`) as HTMLElement;
|
||||
|
||||
if (!$videoProcessing) {
|
||||
const playerType = getStreamPref(StreamPref.VIDEO_PLAYER_TYPE);
|
||||
const settingsManager = SettingsManager.getInstance();
|
||||
if (!settingsManager.hasElement(StreamPref.VIDEO_PROCESSING)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let isDisabled = false;
|
||||
|
||||
const $videoProcessing = settingsManager.getElement(StreamPref.VIDEO_PROCESSING) as HTMLSelectElement;
|
||||
const $videoSharpness = settingsManager.getElement(StreamPref.VIDEO_SHARPNESS);
|
||||
const $videoPowerPreference = settingsManager.getElement(StreamPref.VIDEO_POWER_PREFERENCE);
|
||||
const $videoMaxFps = settingsManager.getElement(StreamPref.VIDEO_MAX_FPS);
|
||||
|
||||
const $optCas = $videoProcessing.querySelector<HTMLOptionElement>(`option[value=${StreamVideoProcessing.CAS}]`);
|
||||
|
||||
if (playerType === StreamPlayerType.WEBGL2) {
|
||||
@ -26,7 +26,7 @@ export function onChangeVideoPlayerType() {
|
||||
} else {
|
||||
// Only allow USM when player type is Video
|
||||
$videoProcessing.value = StreamVideoProcessing.USM;
|
||||
setPref(PrefKey.VIDEO_PROCESSING, StreamVideoProcessing.USM);
|
||||
setStreamPref(StreamPref.VIDEO_PROCESSING, StreamVideoProcessing.USM, 'direct');
|
||||
|
||||
$optCas && ($optCas.disabled = true);
|
||||
|
||||
@ -41,8 +41,6 @@ export function onChangeVideoPlayerType() {
|
||||
// Hide Power Preference setting if renderer isn't WebGL2
|
||||
$videoPowerPreference.closest('.bx-settings-row')!.classList.toggle('bx-gone', playerType !== StreamPlayerType.WEBGL2);
|
||||
$videoMaxFps.closest('.bx-settings-row')!.classList.toggle('bx-gone', playerType !== StreamPlayerType.WEBGL2);
|
||||
|
||||
updateVideoPlayer();
|
||||
}
|
||||
|
||||
|
||||
@ -58,17 +56,17 @@ export function updateVideoPlayer() {
|
||||
return;
|
||||
}
|
||||
|
||||
limitVideoPlayerFps(getPref(PrefKey.VIDEO_MAX_FPS));
|
||||
limitVideoPlayerFps(getStreamPref(StreamPref.VIDEO_MAX_FPS));
|
||||
|
||||
const options = {
|
||||
processing: getPref(PrefKey.VIDEO_PROCESSING),
|
||||
sharpness: getPref(PrefKey.VIDEO_SHARPNESS),
|
||||
saturation: getPref(PrefKey.VIDEO_SATURATION),
|
||||
contrast: getPref(PrefKey.VIDEO_CONTRAST),
|
||||
brightness: getPref(PrefKey.VIDEO_BRIGHTNESS),
|
||||
processing: getStreamPref(StreamPref.VIDEO_PROCESSING),
|
||||
sharpness: getStreamPref(StreamPref.VIDEO_SHARPNESS),
|
||||
saturation: getStreamPref(StreamPref.VIDEO_SATURATION),
|
||||
contrast: getStreamPref(StreamPref.VIDEO_CONTRAST),
|
||||
brightness: getStreamPref(StreamPref.VIDEO_BRIGHTNESS),
|
||||
} satisfies StreamPlayerOptions;
|
||||
|
||||
streamPlayer.setPlayerType(getPref(PrefKey.VIDEO_PLAYER_TYPE));
|
||||
streamPlayer.setPlayerType(getStreamPref(StreamPref.VIDEO_PLAYER_TYPE));
|
||||
streamPlayer.updateOptions(options);
|
||||
streamPlayer.refreshPlayer();
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { CE } from "@utils/html"
|
||||
import { t } from "@utils/translation"
|
||||
import { STATES } from "@utils/global"
|
||||
import { PrefKey } from "@/enums/pref-keys"
|
||||
import { getPref } from "@/utils/settings-storages/global-settings-storage"
|
||||
import { StreamStatsCollector, type StreamStatGrade } from "@/utils/stream-stats-collector"
|
||||
import { StreamPref } from "@/enums/pref-keys"
|
||||
import { StreamStatsCollector } from "@/utils/stream-stats-collector"
|
||||
import { BxLogger } from "@/utils/bx-logger"
|
||||
import { StreamStat } from "@/enums/pref-values"
|
||||
import { BxEventBus } from "@/utils/bx-event-bus"
|
||||
import { getStreamPref } from "@/utils/pref-utils";
|
||||
|
||||
|
||||
export class StreamStats {
|
||||
@ -164,7 +164,7 @@ export class StreamStats {
|
||||
return;
|
||||
}
|
||||
|
||||
const PREF_STATS_CONDITIONAL_FORMATTING = getPref(PrefKey.STATS_CONDITIONAL_FORMATTING);
|
||||
const PREF_STATS_CONDITIONAL_FORMATTING = getStreamPref(StreamPref.STATS_CONDITIONAL_FORMATTING);
|
||||
let grade: StreamStatGrade = '';
|
||||
|
||||
// Collect stats
|
||||
@ -192,12 +192,12 @@ export class StreamStats {
|
||||
}
|
||||
|
||||
refreshStyles() {
|
||||
const PREF_ITEMS = getPref(PrefKey.STATS_ITEMS);
|
||||
const PREF_OPACITY_BG = getPref(PrefKey.STATS_OPACITY_BACKGROUND);
|
||||
const PREF_ITEMS = getStreamPref(StreamPref.STATS_ITEMS);
|
||||
const PREF_OPACITY_BG = getStreamPref(StreamPref.STATS_OPACITY_BACKGROUND);
|
||||
|
||||
const $container = this.$container;
|
||||
$container.dataset.stats = '[' + PREF_ITEMS.join('][') + ']';
|
||||
$container.dataset.position = getPref(PrefKey.STATS_POSITION);
|
||||
$container.dataset.position = getStreamPref(StreamPref.STATS_POSITION);
|
||||
|
||||
if (PREF_OPACITY_BG === 0) {
|
||||
$container.style.removeProperty('background-color');
|
||||
@ -207,12 +207,12 @@ export class StreamStats {
|
||||
$container.style.backgroundColor = `rgba(0, 0, 0, ${PREF_OPACITY_BG}%)`;
|
||||
}
|
||||
|
||||
$container.style.opacity = getPref(PrefKey.STATS_OPACITY_ALL) + '%';
|
||||
$container.style.fontSize = getPref(PrefKey.STATS_TEXT_SIZE);
|
||||
$container.style.opacity = getStreamPref(StreamPref.STATS_OPACITY_ALL) + '%';
|
||||
$container.style.fontSize = getStreamPref(StreamPref.STATS_TEXT_SIZE);
|
||||
}
|
||||
|
||||
hideSettingsUi() {
|
||||
if (this.isGlancing() && !getPref(PrefKey.STATS_QUICK_GLANCE_ENABLED)) {
|
||||
if (this.isGlancing() && !getStreamPref(StreamPref.STATS_QUICK_GLANCE_ENABLED)) {
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
@ -240,8 +240,8 @@ export class StreamStats {
|
||||
|
||||
static setupEvents() {
|
||||
BxEventBus.Stream.on('state.playing', () => {
|
||||
const PREF_STATS_QUICK_GLANCE = getPref(PrefKey.STATS_QUICK_GLANCE_ENABLED);
|
||||
const PREF_STATS_SHOW_WHEN_PLAYING = getPref(PrefKey.STATS_SHOW_WHEN_PLAYING);
|
||||
const PREF_STATS_QUICK_GLANCE = getStreamPref(StreamPref.STATS_QUICK_GLANCE_ENABLED);
|
||||
const PREF_STATS_SHOW_WHEN_PLAYING = getStreamPref(StreamPref.STATS_SHOW_WHEN_PLAYING);
|
||||
|
||||
const streamStats = StreamStats.getInstance();
|
||||
|
||||
|
@ -4,8 +4,8 @@ import { BxEvent } from "@utils/bx-event";
|
||||
import { NATIVE_FETCH } from "@utils/bx-flags";
|
||||
import { t } from "@utils/translation";
|
||||
import { BxLogger } from "@utils/bx-logger";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { GlobalPref } from "@/enums/pref-keys";
|
||||
import { getGlobalPref } from "@/utils/pref-utils";
|
||||
import { TouchControllerStyleCustom, TouchControllerStyleStandard } from "@/enums/pref-values";
|
||||
import { GhPagesUtils } from "@/utils/gh-pages";
|
||||
import { BxEventBus } from "@/utils/bx-event-bus";
|
||||
@ -289,8 +289,8 @@ export class TouchController {
|
||||
|
||||
TouchController.#$style = $style;
|
||||
|
||||
const PREF_STYLE_STANDARD = getPref(PrefKey.TOUCH_CONTROLLER_STYLE_STANDARD);
|
||||
const PREF_STYLE_CUSTOM = getPref(PrefKey.TOUCH_CONTROLLER_STYLE_CUSTOM);
|
||||
const PREF_STYLE_STANDARD = getGlobalPref(GlobalPref.TOUCH_CONTROLLER_STYLE_STANDARD);
|
||||
const PREF_STYLE_CUSTOM = getGlobalPref(GlobalPref.TOUCH_CONTROLLER_STYLE_CUSTOM);
|
||||
|
||||
BxEventBus.Stream.on('dataChannelCreated', payload => {
|
||||
const { dataChannel } = payload;
|
||||
|
@ -5,8 +5,8 @@ import { t } from "@/utils/translation";
|
||||
import { GamepadKey, GamepadKeyName } from "@/enums/gamepad";
|
||||
import { ButtonStyle, CE, createButton, createSettingRow } from "@/utils/html";
|
||||
import { BxSelectElement } from "@/web-components/bx-select";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { GlobalPref } from "@/enums/pref-keys";
|
||||
import { getGlobalPref } from "@/utils/pref-utils";
|
||||
import { BxEvent } from "@/utils/bx-event";
|
||||
import { deepClone } from "@/utils/global";
|
||||
import { StreamSettings } from "@/utils/stream-settings";
|
||||
@ -58,7 +58,7 @@ export class ControllerCustomizationsManagerDialog extends BaseProfileManagerDia
|
||||
}
|
||||
|
||||
private render() {
|
||||
const isControllerFriendly = getPref(PrefKey.UI_CONTROLLER_FRIENDLY);
|
||||
const isControllerFriendly = getGlobalPref(GlobalPref.UI_CONTROLLER_FRIENDLY);
|
||||
const $rows = CE('div', { class: 'bx-buttons-grid' });
|
||||
|
||||
const $baseSelect = CE('select', { class: 'bx-full-width' },
|
||||
@ -117,7 +117,7 @@ export class ControllerCustomizationsManagerDialog extends BaseProfileManagerDia
|
||||
}
|
||||
|
||||
// Map nearby elenemts for controller-friendly UI
|
||||
if (getPref(PrefKey.UI_CONTROLLER_FRIENDLY)) {
|
||||
if (getGlobalPref(GlobalPref.UI_CONTROLLER_FRIENDLY)) {
|
||||
for (let i = 0; i < this.selectsOrder.length; i++) {
|
||||
const $select = this.selectsMap[this.selectsOrder[i] as unknown as GamepadKey] as NavigationElement;
|
||||
const directions = {
|
||||
@ -257,7 +257,7 @@ export class ControllerCustomizationsManagerDialog extends BaseProfileManagerDia
|
||||
$label.classList.add('bx-horizontal-shaking');
|
||||
|
||||
// Focus select
|
||||
if (getPref(PrefKey.UI_CONTROLLER_FRIENDLY)) {
|
||||
if (getGlobalPref(GlobalPref.UI_CONTROLLER_FRIENDLY)) {
|
||||
this.dialogManager.focus($select);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import { t } from "@/utils/translation";
|
||||
import { MkbMappingPresetsTable } from "@/utils/local-db/mkb-mapping-presets-table";
|
||||
import { GamepadKey, GamepadKeyName } from "@/enums/gamepad";
|
||||
import { CE, createSettingRow } from "@/utils/html";
|
||||
import { MouseMapTo, type KeyCode } from "@/enums/mkb";
|
||||
import { MouseMapTo } from "@/enums/mkb";
|
||||
import { BxKeyBindingButton, BxKeyBindingButtonFlag } from "@/web-components/bx-key-binding-button";
|
||||
import { StreamSettings } from "@/utils/stream-settings";
|
||||
import { BxNumberStepper } from "@/web-components/bx-number-stepper";
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { ButtonStyle, CE, createButton } from "@/utils/html";
|
||||
import { NavigationDialog, type NavigationElement } from "./navigation-dialog";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { GlobalPref } from "@/enums/pref-keys";
|
||||
import { BxIcon } from "@/utils/bx-icon";
|
||||
import { getPref, setPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { getGlobalPref, setGlobalPref } from "@/utils/pref-utils";
|
||||
import { t } from "@/utils/translation";
|
||||
import { RemotePlayConsoleState, RemotePlayManager } from "@/modules/remote-play-manager";
|
||||
import { BxSelectElement } from "@/web-components/bx-select";
|
||||
@ -40,7 +40,7 @@ export class RemotePlayDialog extends NavigationDialog {
|
||||
|
||||
const $settingNote = CE('p', {});
|
||||
|
||||
const currentResolution = getPref(PrefKey.REMOTE_PLAY_STREAM_RESOLUTION);
|
||||
const currentResolution = getGlobalPref(GlobalPref.REMOTE_PLAY_STREAM_RESOLUTION);
|
||||
let $resolutions : HTMLSelectElement | NavigationElement = CE('select', false,
|
||||
CE('option', { value: StreamResolution.DIM_720P }, '720p'),
|
||||
CE('option', { value: StreamResolution.DIM_1080P }, '1080p'),
|
||||
@ -52,7 +52,7 @@ export class RemotePlayDialog extends NavigationDialog {
|
||||
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_STREAM_RESOLUTION, value);
|
||||
setGlobalPref(GlobalPref.REMOTE_PLAY_STREAM_RESOLUTION, value, 'ui');
|
||||
});
|
||||
|
||||
($resolutions as any).value = currentResolution;
|
||||
|
@ -1,14 +1,12 @@
|
||||
import { isFullVersion } from "@macros/build" with { type: "macro" };
|
||||
|
||||
import { limitVideoPlayerFps, onChangeVideoPlayerType, updateVideoPlayer } from "@/modules/stream/stream-settings-utils";
|
||||
import { onChangeVideoPlayerType } from "@/modules/stream/stream-settings-utils";
|
||||
import { ButtonStyle, calculateSelectBoxes, CE, createButton, createSettingRow, createSvgIcon, escapeCssSelector, type BxButtonOptions } from "@/utils/html";
|
||||
import { NavigationDialog, NavigationDirection } from "./navigation-dialog";
|
||||
import { SoundShortcut } from "@/modules/shortcuts/sound-shortcut";
|
||||
import { StreamStats } from "@/modules/stream/stream-stats";
|
||||
import { TouchController } from "@/modules/touch-controller";
|
||||
import { BxEvent } from "@/utils/bx-event";
|
||||
import { BxIcon, type BxIconRaw } from "@/utils/bx-icon";
|
||||
import { STATES, AppInterface, deepClone, SCRIPT_VERSION, STORAGE, SCRIPT_VARIANT } from "@/utils/global";
|
||||
import { STATES, AppInterface, deepClone, SCRIPT_VERSION, SCRIPT_VARIANT } from "@/utils/global";
|
||||
import { t, Translations } from "@/utils/translation";
|
||||
import { BxSelectElement } from "@/web-components/bx-select";
|
||||
import { setNearby } from "@/utils/navigation-utils";
|
||||
@ -17,8 +15,7 @@ import { UserAgentProfile } from "@/enums/user-agent";
|
||||
import { UserAgent } from "@/utils/user-agent";
|
||||
import { BX_FLAGS } from "@/utils/bx-flags";
|
||||
import { clearAllData, copyToClipboard } from "@/utils/utils";
|
||||
import { PrefKey, StorageKey } from "@/enums/pref-keys";
|
||||
import { getPref, getPrefDefinition, setPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { GlobalPref, StorageKey, StreamPref, type AnyPref } from "@/enums/pref-keys";
|
||||
import { SettingElement } from "@/utils/setting-element";
|
||||
import type { SettingDefinition, SuggestedSettingProfile } from "@/types/setting-definition";
|
||||
import { FullscreenText } from "../fullscreen-text";
|
||||
@ -27,14 +24,14 @@ import { GamepadKey } from "@/enums/gamepad";
|
||||
import { NativeMkbHandler } from "@/modules/mkb/native-mkb-handler";
|
||||
import { ControllerExtraSettings } from "./settings/controller-extra";
|
||||
import { SuggestionsSetting } from "./settings/suggestions";
|
||||
import { StreamSettings } from "@/utils/stream-settings";
|
||||
import { MkbExtraSettings } from "./settings/mkb-extra";
|
||||
import { BxExposed } from "@/utils/bx-exposed";
|
||||
import { BxEventBus } from "@/utils/bx-event-bus";
|
||||
import { getGlobalPref, getPrefInfo, getStreamPref, isStreamPref, setGlobalPref, STORAGE } from "@/utils/pref-utils";
|
||||
import { SettingsManager } from "@/modules/settings-manager";
|
||||
|
||||
|
||||
type SettingTabSectionItem = Partial<{
|
||||
pref: PrefKey;
|
||||
pref: AnyPref;
|
||||
multiLines: boolean;
|
||||
label: string;
|
||||
note: string | (() => HTMLElement) | HTMLElement;
|
||||
@ -43,7 +40,7 @@ type SettingTabSectionItem = Partial<{
|
||||
options: { [key: string]: string };
|
||||
unsupported: boolean;
|
||||
unsupportedNote: string;
|
||||
onChange: (e: any, value: number) => void;
|
||||
// onChange: (e: any, value: number) => void;
|
||||
onCreated: (setting: SettingTabSectionItem, $control: any) => void;
|
||||
params: any;
|
||||
requiredVariants?: BuildVariant | Array<BuildVariant>;
|
||||
@ -59,17 +56,15 @@ type SettingTabSection = {
|
||||
unsupportedNote?: HTMLElement | string | Text | null;
|
||||
helpUrl?: string;
|
||||
content?: HTMLElement;
|
||||
lazyContent?: boolean | (() => HTMLElement);
|
||||
items?: Array<SettingTabSectionItem | PrefKey | (($parent: HTMLElement) => void) | false>;
|
||||
items?: Array<SettingTabSectionItem | AnyPref | (($parent: HTMLElement) => void) | false>;
|
||||
requiredVariants?: BuildVariant | Array<BuildVariant>;
|
||||
};
|
||||
|
||||
type SettingTab = {
|
||||
icon: BxIconRaw;
|
||||
group: SettingTabGroup,
|
||||
items: Array<SettingTabSection | HTMLElement | false> | (() => Array<SettingTabSection | false>);
|
||||
items: Array<SettingTabSection | HTMLElement | false>;
|
||||
requiredVariants?: BuildVariant | Array<BuildVariant>;
|
||||
lazyContent?: boolean;
|
||||
};
|
||||
|
||||
type SettingTabGroup = 'global' | 'stream' | 'controller' | 'mkb' | 'stats';
|
||||
@ -87,17 +82,20 @@ export class SettingsDialog extends NavigationDialog {
|
||||
private $btnGlobalReload!: HTMLButtonElement;
|
||||
private $noteGlobalReload!: HTMLElement;
|
||||
private $btnSuggestion!: HTMLDivElement;
|
||||
private $streamSettingsSelection!: HTMLElement;
|
||||
|
||||
private renderFullSettings: boolean;
|
||||
protected boundOnContextMenu: any;
|
||||
|
||||
protected suggestedSettings: Record<SuggestedSettingProfile, PartialRecord<PrefKey, any>> = {
|
||||
protected suggestedSettings: Record<SuggestedSettingProfile, PartialRecord<AnyPref, any>> = {
|
||||
recommended: {},
|
||||
default: {},
|
||||
lowest: {},
|
||||
highest: {},
|
||||
};
|
||||
protected suggestedSettingLabels: PartialRecord<PrefKey, string> = {};
|
||||
protected settingElements: PartialRecord<PrefKey, HTMLElement> = {};
|
||||
protected settingLabels: PartialRecord<AnyPref, string> = {};
|
||||
|
||||
protected settingsManager: SettingsManager;
|
||||
|
||||
private readonly TAB_GLOBAL_ITEMS: Array<SettingTabSection | false> = [{
|
||||
group: 'general',
|
||||
@ -106,7 +104,7 @@ export class SettingsDialog extends NavigationDialog {
|
||||
items: [
|
||||
// Top buttons
|
||||
($parent) => {
|
||||
const PREF_LATEST_VERSION = getPref(PrefKey.VERSION_LATEST);
|
||||
const PREF_LATEST_VERSION = getGlobalPref(GlobalPref.VERSION_LATEST);
|
||||
const topButtons = [];
|
||||
|
||||
// "New version available" button
|
||||
@ -188,57 +186,57 @@ export class SettingsDialog extends NavigationDialog {
|
||||
},
|
||||
|
||||
{
|
||||
pref: PrefKey.SCRIPT_LOCALE,
|
||||
pref: GlobalPref.SCRIPT_LOCALE,
|
||||
multiLines: true,
|
||||
},
|
||||
PrefKey.SERVER_BYPASS_RESTRICTION,
|
||||
PrefKey.UI_CONTROLLER_FRIENDLY,
|
||||
PrefKey.REMOTE_PLAY_ENABLED,
|
||||
GlobalPref.SERVER_BYPASS_RESTRICTION,
|
||||
GlobalPref.UI_CONTROLLER_FRIENDLY,
|
||||
GlobalPref.REMOTE_PLAY_ENABLED,
|
||||
],
|
||||
}, {
|
||||
group: 'server',
|
||||
label: t('server'),
|
||||
items: [
|
||||
{
|
||||
pref: PrefKey.SERVER_REGION,
|
||||
pref: GlobalPref.SERVER_REGION,
|
||||
multiLines: true,
|
||||
},
|
||||
{
|
||||
pref: PrefKey.STREAM_PREFERRED_LOCALE,
|
||||
pref: GlobalPref.STREAM_PREFERRED_LOCALE,
|
||||
multiLines: true,
|
||||
},
|
||||
PrefKey.SERVER_PREFER_IPV6,
|
||||
GlobalPref.SERVER_PREFER_IPV6,
|
||||
],
|
||||
}, {
|
||||
group: 'stream',
|
||||
label: t('stream'),
|
||||
items: [
|
||||
PrefKey.STREAM_RESOLUTION,
|
||||
PrefKey.STREAM_CODEC_PROFILE,
|
||||
PrefKey.STREAM_MAX_VIDEO_BITRATE,
|
||||
GlobalPref.STREAM_RESOLUTION,
|
||||
GlobalPref.STREAM_CODEC_PROFILE,
|
||||
GlobalPref.STREAM_MAX_VIDEO_BITRATE,
|
||||
|
||||
PrefKey.AUDIO_VOLUME_CONTROL_ENABLED,
|
||||
GlobalPref.AUDIO_VOLUME_CONTROL_ENABLED,
|
||||
|
||||
PrefKey.SCREENSHOT_APPLY_FILTERS,
|
||||
GlobalPref.SCREENSHOT_APPLY_FILTERS,
|
||||
|
||||
PrefKey.AUDIO_MIC_ON_PLAYING,
|
||||
PrefKey.GAME_FORTNITE_FORCE_CONSOLE,
|
||||
PrefKey.STREAM_COMBINE_SOURCES,
|
||||
GlobalPref.AUDIO_MIC_ON_PLAYING,
|
||||
GlobalPref.GAME_FORTNITE_FORCE_CONSOLE,
|
||||
GlobalPref.STREAM_COMBINE_SOURCES,
|
||||
],
|
||||
}, {
|
||||
requiredVariants: 'full',
|
||||
group: 'mkb',
|
||||
label: t('mouse-and-keyboard'),
|
||||
items: [
|
||||
PrefKey.NATIVE_MKB_MODE,
|
||||
GlobalPref.NATIVE_MKB_MODE,
|
||||
{
|
||||
pref: PrefKey.NATIVE_MKB_FORCED_GAMES,
|
||||
pref: GlobalPref.NATIVE_MKB_FORCED_GAMES,
|
||||
multiLines: true,
|
||||
note: CE('a', { href: 'https://github.com/redphx/better-xcloud/discussions/574', target: '_blank' }, t('unofficial-game-list')),
|
||||
},
|
||||
|
||||
PrefKey.MKB_ENABLED,
|
||||
PrefKey.MKB_HIDE_IDLE_CURSOR,
|
||||
GlobalPref.MKB_ENABLED,
|
||||
GlobalPref.MKB_HIDE_IDLE_CURSOR,
|
||||
],
|
||||
|
||||
// Unsupported
|
||||
@ -255,13 +253,13 @@ export class SettingsDialog extends NavigationDialog {
|
||||
label: t('touch-controller'),
|
||||
items: [
|
||||
{
|
||||
pref: PrefKey.TOUCH_CONTROLLER_MODE,
|
||||
pref: GlobalPref.TOUCH_CONTROLLER_MODE,
|
||||
note: CE('a', { href: 'https://github.com/redphx/better-xcloud/discussions/241', target: '_blank' }, t('unofficial-game-list')),
|
||||
},
|
||||
PrefKey.TOUCH_CONTROLLER_AUTO_OFF,
|
||||
PrefKey.TOUCH_CONTROLLER_DEFAULT_OPACITY,
|
||||
PrefKey.TOUCH_CONTROLLER_STYLE_STANDARD,
|
||||
PrefKey.TOUCH_CONTROLLER_STYLE_CUSTOM,
|
||||
GlobalPref.TOUCH_CONTROLLER_AUTO_OFF,
|
||||
GlobalPref.TOUCH_CONTROLLER_DEFAULT_OPACITY,
|
||||
GlobalPref.TOUCH_CONTROLLER_STYLE_STANDARD,
|
||||
GlobalPref.TOUCH_CONTROLLER_STYLE_CUSTOM,
|
||||
],
|
||||
|
||||
// Unsupported
|
||||
@ -273,22 +271,22 @@ export class SettingsDialog extends NavigationDialog {
|
||||
group: 'ui',
|
||||
label: t('ui'),
|
||||
items: [
|
||||
PrefKey.UI_LAYOUT,
|
||||
PrefKey.UI_IMAGE_QUALITY,
|
||||
PrefKey.UI_GAME_CARD_SHOW_WAIT_TIME,
|
||||
PrefKey.UI_CONTROLLER_SHOW_STATUS,
|
||||
PrefKey.UI_SIMPLIFY_STREAM_MENU,
|
||||
PrefKey.UI_SKIP_SPLASH_VIDEO,
|
||||
!AppInterface && PrefKey.UI_SCROLLBAR_HIDE,
|
||||
PrefKey.UI_HIDE_SYSTEM_MENU_ICON,
|
||||
PrefKey.UI_DISABLE_FEEDBACK_DIALOG,
|
||||
PrefKey.UI_REDUCE_ANIMATIONS,
|
||||
GlobalPref.UI_LAYOUT,
|
||||
GlobalPref.UI_IMAGE_QUALITY,
|
||||
GlobalPref.UI_GAME_CARD_SHOW_WAIT_TIME,
|
||||
GlobalPref.UI_CONTROLLER_SHOW_STATUS,
|
||||
GlobalPref.UI_SIMPLIFY_STREAM_MENU,
|
||||
GlobalPref.UI_SKIP_SPLASH_VIDEO,
|
||||
!AppInterface && GlobalPref.UI_SCROLLBAR_HIDE,
|
||||
GlobalPref.UI_HIDE_SYSTEM_MENU_ICON,
|
||||
GlobalPref.UI_DISABLE_FEEDBACK_DIALOG,
|
||||
GlobalPref.UI_REDUCE_ANIMATIONS,
|
||||
{
|
||||
pref: PrefKey.UI_HIDE_SECTIONS,
|
||||
pref: GlobalPref.UI_HIDE_SECTIONS,
|
||||
multiLines: true,
|
||||
},
|
||||
{
|
||||
pref: PrefKey.BLOCK_FEATURES,
|
||||
pref: GlobalPref.BLOCK_FEATURES,
|
||||
multiLines: true,
|
||||
},
|
||||
],
|
||||
@ -297,28 +295,28 @@ export class SettingsDialog extends NavigationDialog {
|
||||
group: 'game-bar',
|
||||
label: t('game-bar'),
|
||||
items: [
|
||||
PrefKey.GAME_BAR_POSITION,
|
||||
GlobalPref.GAME_BAR_POSITION,
|
||||
],
|
||||
}, {
|
||||
group: 'loading-screen',
|
||||
label: t('loading-screen'),
|
||||
items: [
|
||||
PrefKey.LOADING_SCREEN_GAME_ART,
|
||||
PrefKey.LOADING_SCREEN_SHOW_WAIT_TIME,
|
||||
PrefKey.LOADING_SCREEN_ROCKET,
|
||||
GlobalPref.LOADING_SCREEN_GAME_ART,
|
||||
GlobalPref.LOADING_SCREEN_SHOW_WAIT_TIME,
|
||||
GlobalPref.LOADING_SCREEN_ROCKET,
|
||||
],
|
||||
}, {
|
||||
group: 'other',
|
||||
label: t('other'),
|
||||
items: [
|
||||
PrefKey.BLOCK_TRACKING,
|
||||
GlobalPref.BLOCK_TRACKING,
|
||||
],
|
||||
}, isFullVersion() && {
|
||||
group: 'advanced',
|
||||
label: t('advanced'),
|
||||
items: [
|
||||
{
|
||||
pref: PrefKey.USER_AGENT_PROFILE,
|
||||
pref: GlobalPref.USER_AGENT_PROFILE,
|
||||
multiLines: true,
|
||||
onCreated: (setting, $control) => {
|
||||
const defaultUserAgent = window.navigator.orgUserAgent || window.navigator.userAgent;
|
||||
@ -429,20 +427,17 @@ export class SettingsDialog extends NavigationDialog {
|
||||
label: t('audio'),
|
||||
helpUrl: 'https://better-xcloud.github.io/ingame-features/#audio',
|
||||
items: [{
|
||||
pref: PrefKey.AUDIO_VOLUME,
|
||||
onChange: (e: any, value: number) => {
|
||||
SoundShortcut.setGainNodeVolume(value);
|
||||
},
|
||||
pref: StreamPref.AUDIO_VOLUME,
|
||||
params: {
|
||||
disabled: !getPref(PrefKey.AUDIO_VOLUME_CONTROL_ENABLED),
|
||||
disabled: !getGlobalPref(GlobalPref.AUDIO_VOLUME_CONTROL_ENABLED),
|
||||
},
|
||||
onCreated: (setting: SettingTabSectionItem, $elm: HTMLElement) => {
|
||||
const $range = $elm.querySelector<HTMLInputElement>('input[type=range')!;
|
||||
|
||||
BxEventBus.Script.on('setting.changed', payload => {
|
||||
const { storageKey, settingKey, settingValue } = payload;
|
||||
if (storageKey === StorageKey.GLOBAL && settingKey === PrefKey.AUDIO_VOLUME) {
|
||||
$range.value = settingValue;
|
||||
BxEventBus.Stream.on('setting.changed', payload => {
|
||||
const { settingKey } = payload;
|
||||
if (settingKey === StreamPref.AUDIO_VOLUME) {
|
||||
$range.value = getStreamPref(settingKey).toString();
|
||||
BxEvent.dispatch($range, 'input', { ignoreOnChange: true });
|
||||
}
|
||||
});
|
||||
@ -452,47 +447,18 @@ export class SettingsDialog extends NavigationDialog {
|
||||
group: 'video',
|
||||
label: t('video'),
|
||||
helpUrl: 'https://better-xcloud.github.io/ingame-features/#video',
|
||||
items: [{
|
||||
pref: PrefKey.VIDEO_PLAYER_TYPE,
|
||||
onChange: onChangeVideoPlayerType,
|
||||
}, {
|
||||
pref: PrefKey.VIDEO_MAX_FPS,
|
||||
onChange: e => {
|
||||
limitVideoPlayerFps(parseInt(e.target.value));
|
||||
},
|
||||
}, {
|
||||
pref: PrefKey.VIDEO_POWER_PREFERENCE,
|
||||
onChange: () => {
|
||||
const streamPlayer = STATES.currentStream.streamPlayer;
|
||||
if (!streamPlayer) {
|
||||
return;
|
||||
}
|
||||
|
||||
streamPlayer.reloadPlayer();
|
||||
updateVideoPlayer();
|
||||
},
|
||||
}, {
|
||||
pref: PrefKey.VIDEO_PROCESSING,
|
||||
onChange: updateVideoPlayer,
|
||||
}, {
|
||||
pref: PrefKey.VIDEO_RATIO,
|
||||
onChange: updateVideoPlayer,
|
||||
}, {
|
||||
pref: PrefKey.VIDEO_POSITION,
|
||||
onChange: updateVideoPlayer,
|
||||
}, {
|
||||
pref: PrefKey.VIDEO_SHARPNESS,
|
||||
onChange: updateVideoPlayer,
|
||||
}, {
|
||||
pref: PrefKey.VIDEO_SATURATION,
|
||||
onChange: updateVideoPlayer,
|
||||
}, {
|
||||
pref: PrefKey.VIDEO_CONTRAST,
|
||||
onChange: updateVideoPlayer,
|
||||
}, {
|
||||
pref: PrefKey.VIDEO_BRIGHTNESS,
|
||||
onChange: updateVideoPlayer,
|
||||
}],
|
||||
items: [
|
||||
StreamPref.VIDEO_PLAYER_TYPE,
|
||||
StreamPref.VIDEO_MAX_FPS,
|
||||
StreamPref.VIDEO_POWER_PREFERENCE,
|
||||
StreamPref.VIDEO_PROCESSING,
|
||||
StreamPref.VIDEO_RATIO,
|
||||
StreamPref.VIDEO_POSITION,
|
||||
StreamPref.VIDEO_SHARPNESS,
|
||||
StreamPref.VIDEO_SATURATION,
|
||||
StreamPref.VIDEO_CONTRAST,
|
||||
StreamPref.VIDEO_BRIGHTNESS,
|
||||
],
|
||||
}];
|
||||
|
||||
private readonly TAB_CONTROLLER_ITEMS: Array<SettingTabSection | HTMLElement | false> = isFullVersion() ? [{
|
||||
@ -500,15 +466,12 @@ export class SettingsDialog extends NavigationDialog {
|
||||
label: t('controller'),
|
||||
helpUrl: 'https://better-xcloud.github.io/ingame-features/#controller',
|
||||
items: [
|
||||
{
|
||||
pref: PrefKey.LOCAL_CO_OP_ENABLED,
|
||||
onChange: () => { BxExposed.toggleLocalCoOp(getPref(PrefKey.LOCAL_CO_OP_ENABLED)); },
|
||||
}, {
|
||||
pref: PrefKey.CONTROLLER_POLLING_RATE,
|
||||
onChange: () => StreamSettings.refreshControllerSettings(),
|
||||
}, ($parent => {
|
||||
$parent.appendChild(ControllerExtraSettings.renderSettings.apply(this));
|
||||
})],
|
||||
StreamPref.LOCAL_CO_OP_ENABLED,
|
||||
StreamPref.CONTROLLER_POLLING_RATE,
|
||||
($parent => {
|
||||
$parent.appendChild(ControllerExtraSettings.renderSettings.apply(this));
|
||||
}),
|
||||
],
|
||||
},
|
||||
|
||||
STATES.userAgent.capabilities.touch && {
|
||||
@ -569,18 +532,16 @@ export class SettingsDialog extends NavigationDialog {
|
||||
group: 'device',
|
||||
label: t('device'),
|
||||
items: [{
|
||||
pref: PrefKey.DEVICE_VIBRATION_MODE,
|
||||
pref: StreamPref.DEVICE_VIBRATION_MODE,
|
||||
multiLines: true,
|
||||
unsupported: !STATES.browser.capabilities.deviceVibration,
|
||||
onChange: () => StreamSettings.refreshControllerSettings(),
|
||||
}, {
|
||||
pref: PrefKey.DEVICE_VIBRATION_INTENSITY,
|
||||
pref: StreamPref.DEVICE_VIBRATION_INTENSITY,
|
||||
unsupported: !STATES.browser.capabilities.deviceVibration,
|
||||
onChange: () => StreamSettings.refreshControllerSettings(),
|
||||
}],
|
||||
}] : [];
|
||||
|
||||
private readonly TAB_MKB_ITEMS: (() => Array<SettingTabSection | false>) = isFullVersion() ? () => [
|
||||
private readonly TAB_MKB_ITEMS: Array<SettingTabSection | false> = isFullVersion() ? [
|
||||
{
|
||||
requiredVariants: 'full',
|
||||
group: 'mkb',
|
||||
@ -597,50 +558,25 @@ export class SettingsDialog extends NavigationDialog {
|
||||
requiredVariants: 'full',
|
||||
group: 'native-mkb',
|
||||
label: t('native-mkb'),
|
||||
items: isFullVersion() ? [{
|
||||
pref: PrefKey.NATIVE_MKB_SCROLL_VERTICAL_SENSITIVITY,
|
||||
onChange: (e: any, value: number) => {
|
||||
NativeMkbHandler.getInstance()?.setVerticalScrollMultiplier(value / 100);
|
||||
},
|
||||
}, {
|
||||
pref: PrefKey.NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY,
|
||||
onChange: (e: any, value: number) => {
|
||||
NativeMkbHandler.getInstance()?.setHorizontalScrollMultiplier(value / 100);
|
||||
},
|
||||
}] : [],
|
||||
}] : () => [];
|
||||
items: [
|
||||
StreamPref.NATIVE_MKB_SCROLL_VERTICAL_SENSITIVITY,
|
||||
StreamPref.NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY,
|
||||
],
|
||||
}] : [];
|
||||
|
||||
private readonly TAB_STATS_ITEMS: Array<SettingTabSection | false> = [{
|
||||
group: 'stats',
|
||||
label: t('stream-stats'),
|
||||
helpUrl: 'https://better-xcloud.github.io/stream-stats/',
|
||||
items: [{
|
||||
pref: PrefKey.STATS_SHOW_WHEN_PLAYING,
|
||||
}, {
|
||||
pref: PrefKey.STATS_QUICK_GLANCE_ENABLED,
|
||||
onChange: (e: InputEvent) => {
|
||||
const streamStats = StreamStats.getInstance();
|
||||
(e.target! as HTMLInputElement).checked ? streamStats.quickGlanceSetup() : streamStats.quickGlanceStop();
|
||||
},
|
||||
}, {
|
||||
pref: PrefKey.STATS_ITEMS,
|
||||
onChange: StreamStats.refreshStyles,
|
||||
}, {
|
||||
pref: PrefKey.STATS_POSITION,
|
||||
onChange: StreamStats.refreshStyles,
|
||||
}, {
|
||||
pref: PrefKey.STATS_TEXT_SIZE,
|
||||
onChange: StreamStats.refreshStyles,
|
||||
}, {
|
||||
pref: PrefKey.STATS_OPACITY_ALL,
|
||||
onChange: StreamStats.refreshStyles,
|
||||
}, {
|
||||
pref: PrefKey.STATS_OPACITY_BACKGROUND,
|
||||
onChange: StreamStats.refreshStyles,
|
||||
}, {
|
||||
pref: PrefKey.STATS_CONDITIONAL_FORMATTING,
|
||||
onChange: StreamStats.refreshStyles,
|
||||
},
|
||||
items: [
|
||||
StreamPref.STATS_SHOW_WHEN_PLAYING,
|
||||
StreamPref.STATS_QUICK_GLANCE_ENABLED,
|
||||
StreamPref.STATS_ITEMS,
|
||||
StreamPref.STATS_POSITION,
|
||||
StreamPref.STATS_TEXT_SIZE,
|
||||
StreamPref.STATS_OPACITY_ALL,
|
||||
StreamPref.STATS_OPACITY_BACKGROUND,
|
||||
StreamPref.STATS_CONDITIONAL_FORMATTING,
|
||||
],
|
||||
}];
|
||||
|
||||
@ -668,7 +604,6 @@ export class SettingsDialog extends NavigationDialog {
|
||||
group: 'mkb',
|
||||
icon: BxIcon.NATIVE_MKB,
|
||||
items: this.TAB_MKB_ITEMS,
|
||||
lazyContent: true,
|
||||
requiredVariants: 'full',
|
||||
},
|
||||
|
||||
@ -683,6 +618,8 @@ export class SettingsDialog extends NavigationDialog {
|
||||
super();
|
||||
BxLogger.info(this.LOG_TAG, 'constructor()');
|
||||
|
||||
this.boundOnContextMenu = this.onContextMenu.bind(this);
|
||||
this.settingsManager = SettingsManager.getInstance();
|
||||
this.renderFullSettings = STATES.supportedRegion && STATES.isSignedIn;
|
||||
this.setupDialog();
|
||||
|
||||
@ -696,13 +633,17 @@ export class SettingsDialog extends NavigationDialog {
|
||||
}
|
||||
|
||||
// Trigger event
|
||||
const $selectUserAgent = document.querySelector<HTMLSelectElement>(`#bx_setting_${escapeCssSelector(PrefKey.USER_AGENT_PROFILE)}`);
|
||||
const $selectUserAgent = document.querySelector<HTMLSelectElement>(`#bx_setting_${escapeCssSelector(GlobalPref.USER_AGENT_PROFILE)}`);
|
||||
if ($selectUserAgent) {
|
||||
$selectUserAgent.disabled = true;
|
||||
BxEvent.dispatch($selectUserAgent, 'input', {});
|
||||
$selectUserAgent.disabled = false;
|
||||
}
|
||||
});
|
||||
|
||||
BxEventBus.Stream.on('gameSettings.switched', ({ id }) => {
|
||||
this.$tabContents.dataset.gameId = id.toString();
|
||||
});
|
||||
}
|
||||
|
||||
getDialog(): NavigationDialog {
|
||||
@ -742,21 +683,6 @@ export class SettingsDialog extends NavigationDialog {
|
||||
private onTabClicked = (e: Event) => {
|
||||
const $svg = (e.target as SVGElement).closest('svg')!;
|
||||
|
||||
// Render tab content lazily
|
||||
if (!!$svg.dataset.lazy) {
|
||||
// Remove attribute
|
||||
delete $svg.dataset.lazy;
|
||||
// Render data
|
||||
const settingTab = this.SETTINGS_UI[$svg.dataset.group as SettingTabGroup];
|
||||
if (!settingTab) {
|
||||
return;
|
||||
}
|
||||
|
||||
const items = (settingTab.items as Function)();
|
||||
const $tabContent = this.renderSettingsSection.call(this, settingTab, items);
|
||||
this.$tabContents.appendChild($tabContent);
|
||||
}
|
||||
|
||||
// Switch tab
|
||||
let $child: HTMLElement;
|
||||
const children = Array.from(this.$tabContents.children) as HTMLElement[];
|
||||
@ -767,12 +693,15 @@ export class SettingsDialog extends NavigationDialog {
|
||||
|
||||
// Calculate size of controller-friendly select boxes
|
||||
calculateSelectBoxes($child as HTMLElement);
|
||||
} else {
|
||||
} else if ($child.dataset.tabGroup) {
|
||||
// Hide tab content
|
||||
$child.classList.add('bx-gone');
|
||||
}
|
||||
}
|
||||
|
||||
// Toggle stream settings selection
|
||||
this.$streamSettingsSelection.classList.toggle('bx-gone', $svg.dataset.group === 'global');
|
||||
|
||||
// Highlight current tab button
|
||||
for (const $child of Array.from(this.$tabs.children)) {
|
||||
$child.classList.remove('bx-active');
|
||||
@ -785,10 +714,8 @@ export class SettingsDialog extends NavigationDialog {
|
||||
const $svg = createSvgIcon(settingTab.icon as any);
|
||||
$svg.dataset.group = settingTab.group;
|
||||
$svg.tabIndex = 0;
|
||||
settingTab.lazyContent && ($svg.dataset.lazy = settingTab.lazyContent.toString());
|
||||
|
||||
$svg.addEventListener('click', this.onTabClicked);
|
||||
|
||||
return $svg;
|
||||
}
|
||||
|
||||
@ -803,8 +730,14 @@ export class SettingsDialog extends NavigationDialog {
|
||||
this.$btnGlobalReload.classList.add('bx-danger');
|
||||
}
|
||||
|
||||
private onContextMenu(e: Event) {
|
||||
e.preventDefault();
|
||||
const $elm = e.target;
|
||||
$elm instanceof HTMLElement && this.resetHighlightedSetting($elm);
|
||||
}
|
||||
|
||||
private renderServerSetting(setting: SettingTabSectionItem): HTMLElement {
|
||||
let selectedValue = getPref(PrefKey.SERVER_REGION);
|
||||
let selectedValue = getGlobalPref(GlobalPref.SERVER_REGION);
|
||||
|
||||
const continents: Record<ServerContinent, {
|
||||
label: string,
|
||||
@ -837,7 +770,7 @@ export class SettingsDialog extends NavigationDialog {
|
||||
$control.name = $control.id;
|
||||
|
||||
$control.addEventListener('input', (e: Event) => {
|
||||
setPref(setting.pref!, (e.target as HTMLSelectElement).value);
|
||||
setGlobalPref(setting.pref! as GlobalPref, (e.target as HTMLSelectElement).value, 'ui');
|
||||
this.onGlobalSettingChanged(e);
|
||||
});
|
||||
|
||||
@ -889,13 +822,14 @@ export class SettingsDialog extends NavigationDialog {
|
||||
}
|
||||
|
||||
private renderSettingRow(settingTab: SettingTab, $tabContent: HTMLElement, settingTabContent: SettingTabSection, setting: SettingTabSectionItem | string) {
|
||||
// Convert pref key to object
|
||||
if (typeof setting === 'string') {
|
||||
setting = {
|
||||
pref: setting as PrefKey,
|
||||
pref: setting as AnyPref,
|
||||
} satisfies SettingTabSectionItem;
|
||||
}
|
||||
|
||||
const pref = setting.pref;
|
||||
const pref = setting.pref!;
|
||||
|
||||
let $control;
|
||||
if (setting.content) {
|
||||
@ -905,13 +839,13 @@ export class SettingsDialog extends NavigationDialog {
|
||||
$control = setting.content;
|
||||
}
|
||||
} else if (!setting.unsupported) {
|
||||
if (pref === PrefKey.SERVER_REGION) {
|
||||
if (pref === GlobalPref.SERVER_REGION) {
|
||||
$control = this.renderServerSetting(setting);
|
||||
} else if (pref === PrefKey.SCRIPT_LOCALE) {
|
||||
$control = SettingElement.fromPref(pref, STORAGE.Global, async (e: Event) => {
|
||||
} else if (pref === GlobalPref.SCRIPT_LOCALE) {
|
||||
$control = SettingElement.fromPref(pref, async (e: Event) => {
|
||||
const newLocale = (e.target as HTMLSelectElement).value;
|
||||
|
||||
if (getPref(PrefKey.UI_CONTROLLER_FRIENDLY)) {
|
||||
if (getGlobalPref(GlobalPref.UI_CONTROLLER_FRIENDLY)) {
|
||||
let timeoutId = (e.target as any).timeoutId;
|
||||
timeoutId && window.clearTimeout(timeoutId);
|
||||
(e.target as any).timeoutId = window.setTimeout(() => {
|
||||
@ -926,8 +860,8 @@ export class SettingsDialog extends NavigationDialog {
|
||||
|
||||
this.onGlobalSettingChanged(e);
|
||||
});
|
||||
} else if (pref === PrefKey.USER_AGENT_PROFILE) {
|
||||
$control = SettingElement.fromPref(PrefKey.USER_AGENT_PROFILE, STORAGE.Global, (e: Event) => {
|
||||
} else if (pref === GlobalPref.USER_AGENT_PROFILE) {
|
||||
$control = SettingElement.fromPref(GlobalPref.USER_AGENT_PROFILE, (e: Event) => {
|
||||
const $target = e.target as HTMLSelectElement;
|
||||
const value = $target.value as UserAgentProfile;
|
||||
let isCustom = value === UserAgentProfile.CUSTOM;
|
||||
@ -943,25 +877,21 @@ export class SettingsDialog extends NavigationDialog {
|
||||
!(e.target as HTMLInputElement).disabled && this.onGlobalSettingChanged(e);
|
||||
});
|
||||
} else {
|
||||
let onChange = setting.onChange;
|
||||
if (!onChange && settingTab.group === 'global') {
|
||||
onChange = this.onGlobalSettingChanged;
|
||||
$control = this.settingsManager.getElement(pref, setting.params);
|
||||
if (settingTab.group === 'global') {
|
||||
$control.addEventListener('input', this.onGlobalSettingChanged);
|
||||
}
|
||||
|
||||
$control = SettingElement.fromPref(pref as PrefKey, STORAGE.Global, onChange, setting.params);
|
||||
}
|
||||
|
||||
// Replace <select> with controller-friendly one
|
||||
if ($control instanceof HTMLSelectElement) {
|
||||
$control = BxSelectElement.create($control);
|
||||
}
|
||||
|
||||
pref && (this.settingElements[pref] = $control);
|
||||
}
|
||||
|
||||
let prefDefinition: SettingDefinition | null = null;
|
||||
if (pref) {
|
||||
prefDefinition = getPrefDefinition(pref);
|
||||
prefDefinition = getPrefInfo(pref).definition;
|
||||
}
|
||||
|
||||
if (prefDefinition && !this.isSupportedVariant(prefDefinition.requiredVariants)) {
|
||||
@ -1010,6 +940,8 @@ export class SettingsDialog extends NavigationDialog {
|
||||
$note,
|
||||
multiLines: setting.multiLines,
|
||||
icon: prefDefinition?.labelIcon,
|
||||
onContextMenu: this.boundOnContextMenu,
|
||||
pref: pref,
|
||||
});
|
||||
if (pref) {
|
||||
$row.htmlFor = `bx_setting_${escapeCssSelector(pref)}`;
|
||||
@ -1023,7 +955,9 @@ export class SettingsDialog extends NavigationDialog {
|
||||
private renderSettingsSection(settingTab: SettingTab, sections: Array<SettingTabSection | HTMLElement | false>): HTMLElement {
|
||||
const $tabContent = CE('div', {
|
||||
class: 'bx-gone',
|
||||
'data-tab-group': settingTab.group,
|
||||
_dataset: {
|
||||
tabGroup: settingTab.group,
|
||||
},
|
||||
});
|
||||
|
||||
for (const section of sections) {
|
||||
@ -1168,21 +1102,31 @@ export class SettingsDialog extends NavigationDialog {
|
||||
),
|
||||
),
|
||||
|
||||
$tabContents = CE('div', {
|
||||
class: 'bx-settings-tab-contents',
|
||||
_nearby: {
|
||||
orientation: 'vertical',
|
||||
focus: () => this.jumpToSettingGroup('next'),
|
||||
loop: direction => {
|
||||
if (direction === NavigationDirection.UP || direction === NavigationDirection.DOWN) {
|
||||
this.focusVisibleSetting(direction === NavigationDirection.UP ? 'last' : 'first');
|
||||
return true;
|
||||
}
|
||||
CE('div', {
|
||||
class: 'bx-settings-tab-contents',
|
||||
_nearby: {
|
||||
orientation: 'vertical',
|
||||
loop: direction => {
|
||||
if (direction === NavigationDirection.UP || direction === NavigationDirection.DOWN) {
|
||||
this.focusVisibleSetting(direction === NavigationDirection.UP ? 'last' : 'first');
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
return false;
|
||||
},
|
||||
}
|
||||
},
|
||||
}),
|
||||
// Render global/per-game settings selection
|
||||
this.$streamSettingsSelection = SettingsManager.getInstance().getStreamSettingsSelection(),
|
||||
|
||||
$tabContents = CE('div', {
|
||||
class: 'bx-settings-tab-content',
|
||||
_nearby: {
|
||||
orientation: 'vertical',
|
||||
focus: () => this.jumpToSettingGroup('next'),
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
this.$container = $container;
|
||||
@ -1198,6 +1142,7 @@ export class SettingsDialog extends NavigationDialog {
|
||||
}
|
||||
});
|
||||
|
||||
// Render tab contents
|
||||
let settingTabGroup: keyof typeof this.SETTINGS_UI
|
||||
for (settingTabGroup in this.SETTINGS_UI) {
|
||||
const settingTab = this.SETTINGS_UI[settingTabGroup];
|
||||
@ -1219,11 +1164,6 @@ export class SettingsDialog extends NavigationDialog {
|
||||
const $svg = this.renderTab(settingTab);
|
||||
$tabs.appendChild($svg);
|
||||
|
||||
// Don't render lazy tab content
|
||||
if (typeof settingTab.items === 'function') {
|
||||
continue;
|
||||
}
|
||||
|
||||
const $tabContent = this.renderSettingsSection.call(this, settingTab, settingTab.items);
|
||||
$tabContents.appendChild($tabContent);
|
||||
}
|
||||
@ -1344,6 +1284,44 @@ export class SettingsDialog extends NavigationDialog {
|
||||
return false;
|
||||
}
|
||||
|
||||
private resetHighlightedSetting($elm?: HTMLElement) {
|
||||
const targetGameId = SettingsManager.getInstance().getTargetGameId();
|
||||
if (targetGameId < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$elm) {
|
||||
// Get focusing element
|
||||
$elm = document.activeElement instanceof HTMLElement ? document.activeElement : undefined;
|
||||
}
|
||||
|
||||
const $row = $elm?.closest('div[data-tab-group] > .bx-settings-row');
|
||||
if (!$row) {
|
||||
return;
|
||||
}
|
||||
|
||||
const pref = ($row as any).prefKey;
|
||||
if (!pref) {
|
||||
alert('Pref not found: ' + $row.id);
|
||||
}
|
||||
|
||||
if (!isStreamPref(pref)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete settings
|
||||
const gameSettings = STORAGE.Stream.getGameSettings(targetGameId);
|
||||
const deleted = gameSettings?.deleteSetting(pref);
|
||||
if (deleted) {
|
||||
BxEventBus.Stream.emit('setting.changed', {
|
||||
storageKey: `${StorageKey.STREAM}.${targetGameId}`,
|
||||
settingKey: pref,
|
||||
});
|
||||
}
|
||||
|
||||
return deleted;
|
||||
}
|
||||
|
||||
handleKeyPress(key: string): boolean {
|
||||
let handled = true;
|
||||
switch (key) {
|
||||
@ -1362,6 +1340,9 @@ export class SettingsDialog extends NavigationDialog {
|
||||
case 'PageDown':
|
||||
this.jumpToSettingGroup('next');
|
||||
break;
|
||||
case 'KeyQ':
|
||||
this.resetHighlightedSetting();
|
||||
break;
|
||||
default:
|
||||
handled = false;
|
||||
break;
|
||||
@ -1394,6 +1375,9 @@ export class SettingsDialog extends NavigationDialog {
|
||||
case GamepadKey.RT:
|
||||
this.jumpToSettingGroup('next');
|
||||
break;
|
||||
case GamepadKey.X:
|
||||
this.resetHighlightedSetting();
|
||||
break;
|
||||
default:
|
||||
handled = false;
|
||||
break;
|
||||
|
@ -1,16 +1,17 @@
|
||||
import { BxEvent } from "@/utils/bx-event";
|
||||
import { getUniqueGamepadNames } from "@/utils/gamepad";
|
||||
import { getUniqueGamepadNames, simplifyGamepadName } from "@/utils/gamepad";
|
||||
import { CE, removeChildElements, createButton, ButtonStyle, createSettingRow, renderPresetsList, calculateSelectBoxes } from "@/utils/html";
|
||||
import { t } from "@/utils/translation";
|
||||
import { BxSelectElement } from "@/web-components/bx-select";
|
||||
import { ControllerShortcutsManagerDialog } from "../profile-manger/controller-shortcuts-manager-dialog";
|
||||
import type { SettingsDialog } from "../settings-dialog";
|
||||
import { ControllerShortcutsTable } from "@/utils/local-db/controller-shortcuts-table";
|
||||
import { ControllerSettingsTable } from "@/utils/local-db/controller-settings-table";
|
||||
import { StreamSettings } from "@/utils/stream-settings";
|
||||
import { ControllerCustomizationsTable } from "@/utils/local-db/controller-customizations-table";
|
||||
import { ControllerCustomizationsManagerDialog } from "../profile-manger/controller-customizations-manager-dialog";
|
||||
import { BxIcon } from "@/utils/bx-icon";
|
||||
import { getStreamPref, setStreamPref, STORAGE } from "@/utils/pref-utils";
|
||||
import { StreamPref } from "@/enums/pref-keys";
|
||||
|
||||
export class ControllerExtraSettings extends HTMLElement {
|
||||
currentControllerId!: string;
|
||||
@ -26,16 +27,23 @@ export class ControllerExtraSettings extends HTMLElement {
|
||||
getCurrentControllerId!: typeof ControllerExtraSettings['getCurrentControllerId'];
|
||||
saveSettings!: typeof ControllerExtraSettings['saveSettings'];
|
||||
updateCustomizationSummary!: typeof ControllerExtraSettings['updateCustomizationSummary'];
|
||||
setValue!: typeof ControllerExtraSettings['setValue'];
|
||||
|
||||
static renderSettings(this: SettingsDialog): HTMLElement {
|
||||
const $container = CE('label', {
|
||||
class: 'bx-settings-row bx-controller-extra-settings',
|
||||
}) as unknown as ControllerExtraSettings;
|
||||
|
||||
// Setting up for Settings Manager
|
||||
($container as any).prefKey = StreamPref.CONTROLLER_SETTINGS;
|
||||
$container.addEventListener('contextmenu', this.boundOnContextMenu);
|
||||
this.settingsManager.setElement(StreamPref.CONTROLLER_SETTINGS, $container);
|
||||
|
||||
$container.updateLayout = ControllerExtraSettings.updateLayout.bind($container);
|
||||
$container.switchController = ControllerExtraSettings.switchController.bind($container);
|
||||
$container.getCurrentControllerId = ControllerExtraSettings.getCurrentControllerId.bind($container);
|
||||
$container.saveSettings = ControllerExtraSettings.saveSettings.bind($container);
|
||||
$container.setValue = ControllerExtraSettings.setValue.bind($container);
|
||||
|
||||
const $selectControllers = BxSelectElement.create(CE('select', {
|
||||
class: 'bx-full-width',
|
||||
@ -80,9 +88,7 @@ export class ControllerExtraSettings extends HTMLElement {
|
||||
}),
|
||||
}),
|
||||
),
|
||||
{
|
||||
multiLines: true,
|
||||
},
|
||||
{ multiLines: true },
|
||||
);
|
||||
$rowCustomization.appendChild(
|
||||
$container.$summaryCustomization = CE('div'),
|
||||
@ -162,7 +168,7 @@ export class ControllerExtraSettings extends HTMLElement {
|
||||
|
||||
// Render controller list
|
||||
for (const name of this.controllerIds) {
|
||||
const $option = CE('option', { value: name }, name);
|
||||
const $option = CE('option', { value: name }, simplifyGamepadName(name));
|
||||
$fragment.appendChild($option);
|
||||
}
|
||||
|
||||
@ -191,14 +197,8 @@ export class ControllerExtraSettings extends HTMLElement {
|
||||
return;
|
||||
}
|
||||
|
||||
const controllerSettings = await ControllerSettingsTable.getInstance().getControllerData(this.currentControllerId);
|
||||
|
||||
// Update UI
|
||||
this.$selectShortcuts.value = controllerSettings.shortcutPresetId.toString();
|
||||
this.$selectCustomization.value = controllerSettings.customizationPresetId.toString();
|
||||
|
||||
// Update summary
|
||||
ControllerExtraSettings.updateCustomizationSummary.call(this);
|
||||
const controllerSetting = STORAGE.Stream.getControllerSetting(this.currentControllerId);
|
||||
ControllerExtraSettings.updateElements.call(this, controllerSetting);
|
||||
}
|
||||
|
||||
private static getCurrentControllerId(this: ControllerExtraSettings) {
|
||||
@ -228,16 +228,30 @@ export class ControllerExtraSettings extends HTMLElement {
|
||||
return;
|
||||
}
|
||||
|
||||
const data: ControllerSettingsRecord = {
|
||||
id: this.currentControllerId,
|
||||
data: {
|
||||
shortcutPresetId: parseInt(this.$selectShortcuts.value),
|
||||
customizationPresetId: parseInt(this.$selectCustomization.value),
|
||||
},
|
||||
const controllerSettings = getStreamPref(StreamPref.CONTROLLER_SETTINGS);
|
||||
controllerSettings[this.currentControllerId] = {
|
||||
shortcutPresetId: parseInt(this.$selectShortcuts.value),
|
||||
customizationPresetId: parseInt(this.$selectCustomization.value),
|
||||
};
|
||||
|
||||
await ControllerSettingsTable.getInstance().put(data);
|
||||
|
||||
setStreamPref(StreamPref.CONTROLLER_SETTINGS, controllerSettings, 'ui');
|
||||
StreamSettings.refreshControllerSettings();
|
||||
}
|
||||
|
||||
private static setValue(this: ControllerExtraSettings, value: ControllerSettings) {
|
||||
ControllerExtraSettings.updateElements.call(this, value[this.currentControllerId]);
|
||||
}
|
||||
|
||||
private static updateElements(this: ControllerExtraSettings, controllerSetting: ControllerSetting) {
|
||||
if (!controllerSetting) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update UI
|
||||
this.$selectShortcuts.value = controllerSetting.shortcutPresetId.toString();
|
||||
this.$selectCustomization.value = controllerSetting.customizationPresetId.toString();
|
||||
|
||||
// Update summary
|
||||
ControllerExtraSettings.updateCustomizationSummary.call(this);
|
||||
}
|
||||
}
|
||||
|
@ -3,15 +3,11 @@ import type { SettingsDialog } from "../settings-dialog";
|
||||
import { MkbMappingPresetsTable } from "@/utils/local-db/mkb-mapping-presets-table";
|
||||
import { BxSelectElement } from "@/web-components/bx-select";
|
||||
import { t } from "@/utils/translation";
|
||||
import { getPref, setPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { StreamSettings } from "@/utils/stream-settings";
|
||||
import { getGlobalPref, getStreamPref, setStreamPref } from "@/utils/pref-utils";
|
||||
import { GlobalPref, StreamPref } from "@/enums/pref-keys";
|
||||
import { MkbMappingManagerDialog } from "../profile-manger/mkb-mapping-manager-dialog";
|
||||
import { KeyboardShortcutsManagerDialog } from "../profile-manger/keyboard-shortcuts-manager-dialog";
|
||||
import { KeyboardShortcutsTable } from "@/utils/local-db/keyboard-shortcuts-table";
|
||||
import { SettingElement } from "@/utils/setting-element";
|
||||
import { STORAGE } from "@/utils/global";
|
||||
import { EmulatedMkbHandler } from "@/modules/mkb/mkb-handler";
|
||||
import { BxIcon } from "@/utils/bx-icon";
|
||||
|
||||
export class MkbExtraSettings extends HTMLElement {
|
||||
@ -44,7 +40,7 @@ export class MkbExtraSettings extends HTMLElement {
|
||||
}));
|
||||
|
||||
$container.append(
|
||||
...(getPref(PrefKey.MKB_ENABLED) ? [
|
||||
...(getGlobalPref(GlobalPref.MKB_ENABLED) ? [
|
||||
createSettingRow(
|
||||
t('virtual-controller'),
|
||||
CE('div', {
|
||||
@ -63,14 +59,20 @@ export class MkbExtraSettings extends HTMLElement {
|
||||
}),
|
||||
}),
|
||||
),
|
||||
{ multiLines: true },
|
||||
{
|
||||
multiLines: true,
|
||||
onContextMenu: this.boundOnContextMenu,
|
||||
pref: StreamPref.MKB_P1_MAPPING_PRESET_ID,
|
||||
},
|
||||
),
|
||||
|
||||
createSettingRow(
|
||||
t('virtual-controller-slot'),
|
||||
SettingElement.fromPref(PrefKey.MKB_P1_SLOT, STORAGE.Global, () => {
|
||||
EmulatedMkbHandler.getInstance()?.resetXcloudGamepads();
|
||||
}),
|
||||
this.settingsManager.getElement(StreamPref.MKB_P1_SLOT),
|
||||
{
|
||||
onContextMenu: this.boundOnContextMenu,
|
||||
pref: StreamPref.MKB_P1_SLOT,
|
||||
},
|
||||
),
|
||||
] : []),
|
||||
|
||||
@ -92,13 +94,20 @@ export class MkbExtraSettings extends HTMLElement {
|
||||
}),
|
||||
}),
|
||||
),
|
||||
{ multiLines: true },
|
||||
{
|
||||
multiLines: true,
|
||||
onContextMenu: this.boundOnContextMenu,
|
||||
pref: StreamPref.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID,
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
$container.$mappingPresets = $mappingPresets;
|
||||
$container.$shortcutsPresets = $shortcutsPresets;
|
||||
|
||||
this.settingsManager.setElement(StreamPref.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID, $shortcutsPresets);
|
||||
this.settingsManager.setElement(StreamPref.MKB_P1_MAPPING_PRESET_ID, $mappingPresets);
|
||||
|
||||
$container.updateLayout();
|
||||
// Refresh layout when parent dialog is shown
|
||||
this.onMountedCallbacks.push(() => {
|
||||
@ -111,24 +120,20 @@ export class MkbExtraSettings extends HTMLElement {
|
||||
private static async updateLayout(this: MkbExtraSettings) {
|
||||
// Render shortcut presets
|
||||
const mappingPresets = await MkbMappingPresetsTable.getInstance().getPresets();
|
||||
renderPresetsList(this.$mappingPresets, mappingPresets, getPref(PrefKey.MKB_P1_MAPPING_PRESET_ID));
|
||||
renderPresetsList(this.$mappingPresets, mappingPresets, getStreamPref(StreamPref.MKB_P1_MAPPING_PRESET_ID));
|
||||
|
||||
// Render shortcut presets
|
||||
const shortcutsPresets = await KeyboardShortcutsTable.getInstance().getPresets();
|
||||
renderPresetsList(this.$shortcutsPresets, shortcutsPresets, getPref(PrefKey.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID), { addOffValue: true });
|
||||
renderPresetsList(this.$shortcutsPresets, shortcutsPresets, getStreamPref(StreamPref.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID), { addOffValue: true });
|
||||
}
|
||||
|
||||
private static async saveMkbSettings(this: MkbExtraSettings) {
|
||||
const presetId = parseInt(this.$mappingPresets.value);
|
||||
setPref(PrefKey.MKB_P1_MAPPING_PRESET_ID, presetId);
|
||||
|
||||
StreamSettings.refreshMkbSettings();
|
||||
setStreamPref(StreamPref.MKB_P1_MAPPING_PRESET_ID, presetId, 'ui');
|
||||
}
|
||||
|
||||
private static async saveShortcutsSettings(this: MkbExtraSettings) {
|
||||
const presetId = parseInt(this.$shortcutsPresets.value);
|
||||
setPref(PrefKey.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID, presetId);
|
||||
|
||||
StreamSettings.refreshKeyboardShortcuts();
|
||||
setStreamPref(StreamPref.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID, presetId, 'ui');
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { GlobalPref, StreamPref, type AnyPref } from "@/enums/pref-keys";
|
||||
import { BxEvent } from "@/utils/bx-event";
|
||||
import { BX_FLAGS, NATIVE_FETCH, type BxFlags } from "@/utils/bx-flags";
|
||||
import { STORAGE } from "@/utils/global";
|
||||
import { BX_FLAGS, NATIVE_FETCH } from "@/utils/bx-flags";
|
||||
import { CE, removeChildElements, createButton, ButtonStyle, escapeCssSelector } from "@/utils/html";
|
||||
import type { BxHtmlSettingElement } from "@/utils/setting-element";
|
||||
import { getPref, setPref, getPrefDefinition } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { t } from "@/utils/translation";
|
||||
import { BxSelectElement } from "@/web-components/bx-select";
|
||||
import type { SettingsDialog } from "../settings-dialog";
|
||||
import type { RecommendedSettings, SuggestedSettingProfile } from "@/types/setting-definition";
|
||||
import { DeviceVibrationMode, TouchControllerMode } from "@/enums/pref-values";
|
||||
import { GhPagesUtils } from "@/utils/gh-pages";
|
||||
import { STORAGE, getPrefInfo, setPref } from "@/utils/pref-utils";
|
||||
import { SettingsManager } from "@/modules/settings-manager";
|
||||
|
||||
export class SuggestionsSetting {
|
||||
static async renderSuggestions(this: SettingsDialog, e: Event) {
|
||||
@ -38,16 +38,16 @@ export class SuggestionsSetting {
|
||||
}
|
||||
|
||||
for (const setting of settingTabContent.items) {
|
||||
let prefKey: PrefKey | undefined;
|
||||
let prefKey: AnyPref | undefined;
|
||||
|
||||
if (typeof setting === 'string') {
|
||||
prefKey = setting;
|
||||
} else if (typeof setting === 'object') {
|
||||
prefKey = setting.pref as PrefKey;
|
||||
prefKey = setting.pref as GlobalPref;
|
||||
}
|
||||
|
||||
if (prefKey) {
|
||||
this.suggestedSettingLabels[prefKey] = settingTabContent.label;
|
||||
this.settingLabels[prefKey] = settingTabContent.label;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -76,15 +76,15 @@ export class SuggestionsSetting {
|
||||
const deviceType = BX_FLAGS.DeviceInfo.deviceType;
|
||||
if (deviceType === 'android-handheld') {
|
||||
// Disable touch
|
||||
SuggestionsSetting.addDefaultSuggestedSetting.call(this, PrefKey.TOUCH_CONTROLLER_MODE, TouchControllerMode.OFF);
|
||||
SuggestionsSetting.addDefaultSuggestedSetting.call(this, GlobalPref.TOUCH_CONTROLLER_MODE, TouchControllerMode.OFF);
|
||||
// Enable device vibration
|
||||
SuggestionsSetting.addDefaultSuggestedSetting.call(this, PrefKey.DEVICE_VIBRATION_MODE, DeviceVibrationMode.ON);
|
||||
SuggestionsSetting.addDefaultSuggestedSetting.call(this, StreamPref.DEVICE_VIBRATION_MODE, DeviceVibrationMode.ON);
|
||||
} else if (deviceType === 'android') {
|
||||
// Enable device vibration
|
||||
SuggestionsSetting.addDefaultSuggestedSetting.call(this, PrefKey.DEVICE_VIBRATION_MODE, DeviceVibrationMode.AUTO);
|
||||
SuggestionsSetting.addDefaultSuggestedSetting.call(this, StreamPref.DEVICE_VIBRATION_MODE, DeviceVibrationMode.AUTO);
|
||||
} else if (deviceType === 'android-tv') {
|
||||
// Disable touch
|
||||
SuggestionsSetting.addDefaultSuggestedSetting.call(this, PrefKey.TOUCH_CONTROLLER_MODE, TouchControllerMode.OFF);
|
||||
SuggestionsSetting.addDefaultSuggestedSetting.call(this, GlobalPref.TOUCH_CONTROLLER_MODE, TouchControllerMode.OFF);
|
||||
}
|
||||
|
||||
// Set value for Default profile
|
||||
@ -116,10 +116,17 @@ export class SuggestionsSetting {
|
||||
note && fragment.appendChild(CE('div', { class: 'bx-suggest-note' }, note));
|
||||
|
||||
const settings = this.suggestedSettings[profile];
|
||||
let prefKey: PrefKey;
|
||||
for (prefKey in settings) {
|
||||
for (const key in settings) {
|
||||
const { storage, definition } = getPrefInfo(key as AnyPref);
|
||||
|
||||
let prefKey;
|
||||
if (storage === STORAGE.Stream) {
|
||||
prefKey = key as StreamPref;
|
||||
} else {
|
||||
prefKey = key as GlobalPref;
|
||||
}
|
||||
|
||||
let suggestedValue;
|
||||
const definition = getPrefDefinition(prefKey);
|
||||
if (definition && definition.transformValue) {
|
||||
suggestedValue = definition.transformValue.get.call(definition, settings[prefKey]);
|
||||
} else {
|
||||
@ -127,8 +134,9 @@ export class SuggestionsSetting {
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
const currentValue = getPref(prefKey, false);
|
||||
const currentValueText = STORAGE.Global.getValueText(prefKey, currentValue);
|
||||
const currentValue = storage.getSetting(prefKey, false);
|
||||
// @ts-ignore
|
||||
const currentValueText = storage.getValueText(prefKey, currentValue);
|
||||
const isSameValue = currentValue === suggestedValue;
|
||||
|
||||
let $child: HTMLElement;
|
||||
@ -137,12 +145,14 @@ export class SuggestionsSetting {
|
||||
// No changes
|
||||
$value = currentValueText;
|
||||
} else {
|
||||
const suggestedValueText = STORAGE.Global.getValueText(prefKey, suggestedValue);
|
||||
// @ts-ignore
|
||||
const suggestedValueText = storage.getValueText(prefKey, suggestedValue);
|
||||
$value = currentValueText + ' ➔ ' + suggestedValueText;
|
||||
}
|
||||
|
||||
let $checkbox: HTMLInputElement;
|
||||
const breadcrumb = this.suggestedSettingLabels[prefKey] + ' ❯ ' + STORAGE.Global.getLabel(prefKey);
|
||||
// @ts-ignore
|
||||
const breadcrumb = this.settingLabels[prefKey] + ' ❯ ' + storage.getLabel(prefKey);
|
||||
const id = escapeCssSelector(`bx_suggest_${prefKey}`);
|
||||
|
||||
$child = CE('div', {
|
||||
@ -183,7 +193,8 @@ export class SuggestionsSetting {
|
||||
const profile = $select.value as SuggestedSettingProfile;
|
||||
const settings = this.suggestedSettings[profile];
|
||||
|
||||
let prefKey: PrefKey;
|
||||
let prefKey: AnyPref;
|
||||
const settingsManager = SettingsManager.getInstance();
|
||||
for (prefKey in settings) {
|
||||
let suggestedValue = settings[prefKey];
|
||||
|
||||
@ -192,17 +203,17 @@ export class SuggestionsSetting {
|
||||
continue;
|
||||
}
|
||||
|
||||
const $control = this.settingElements[prefKey] as HTMLElement;
|
||||
const $control = settingsManager.getElement(prefKey);
|
||||
|
||||
// Set value directly if the control element is not available
|
||||
if (!$control) {
|
||||
setPref(prefKey, suggestedValue);
|
||||
setPref(prefKey, suggestedValue, 'direct');
|
||||
continue;
|
||||
}
|
||||
|
||||
// Transform value
|
||||
const settingDefinition = getPrefDefinition(prefKey);
|
||||
if (settingDefinition.transformValue) {
|
||||
const { definition: settingDefinition } = getPrefInfo(prefKey);
|
||||
if (settingDefinition?.transformValue) {
|
||||
suggestedValue = settingDefinition.transformValue.get.call(settingDefinition, suggestedValue);
|
||||
}
|
||||
|
||||
@ -274,7 +285,7 @@ export class SuggestionsSetting {
|
||||
const url = GhPagesUtils.getUrl(`devices/${brand}/${board}-${model}.json`);
|
||||
const response = await NATIVE_FETCH(url);
|
||||
const json = (await response.json()) as RecommendedSettings;
|
||||
const recommended: PartialRecord<PrefKey, any> = {};
|
||||
const recommended: PartialRecord<GlobalPref, any> = {};
|
||||
|
||||
// Only supports schema version 2
|
||||
if (json.schema_version !== 2) {
|
||||
@ -311,7 +322,7 @@ export class SuggestionsSetting {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static addDefaultSuggestedSetting(this: SettingsDialog, prefKey: PrefKey, value: any) {
|
||||
private static addDefaultSuggestedSetting(this: SettingsDialog, prefKey: AnyPref, value: any) {
|
||||
let key: keyof typeof this.suggestedSettings;
|
||||
for (key in this.suggestedSettings) {
|
||||
if (key !== 'default' && !(prefKey in this.suggestedSettings)) {
|
||||
@ -327,10 +338,10 @@ export class SuggestionsSetting {
|
||||
continue;
|
||||
}
|
||||
|
||||
let prefKey: PrefKey;
|
||||
let prefKey: AnyPref;
|
||||
for (prefKey in this.suggestedSettings[key]) {
|
||||
if (!(prefKey in this.suggestedSettings.default)) {
|
||||
this.suggestedSettings.default[prefKey] = getPrefDefinition(prefKey).default;
|
||||
this.suggestedSettings.default[prefKey] = getPrefInfo(prefKey).definition.default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,9 @@ import { SettingsDialog } from "./dialog/settings-dialog";
|
||||
import { TrueAchievements } from "@/utils/true-achievements";
|
||||
import { BxIcon } from "@/utils/bx-icon";
|
||||
import { BxEventBus } from "@/utils/bx-event-bus";
|
||||
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { getGlobalPref } from "@/utils/pref-utils";
|
||||
import { UiLayout } from "@/enums/pref-values";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { GlobalPref } from "@/enums/pref-keys";
|
||||
|
||||
export enum GuideMenuTab {
|
||||
HOME = 'home',
|
||||
@ -116,7 +116,7 @@ export class GuideMenu {
|
||||
});
|
||||
|
||||
// Set TV tag
|
||||
if (STATES.userAgent.isTv || getPref(PrefKey.UI_LAYOUT) === UiLayout.TV) {
|
||||
if (STATES.userAgent.isTv || getGlobalPref(GlobalPref.UI_LAYOUT) === UiLayout.TV) {
|
||||
document.body.dataset.bxMediaType = 'tv';
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,8 @@ import { getPreferredServerRegion } from "@utils/region";
|
||||
import { RemotePlayManager } from "@/modules/remote-play-manager";
|
||||
import { t } from "@utils/translation";
|
||||
import { SettingsDialog } from "./dialog/settings-dialog";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { GlobalPref } from "@/enums/pref-keys";
|
||||
import { getGlobalPref } from "@/utils/pref-utils";
|
||||
import { BxLogger } from "@/utils/bx-logger";
|
||||
|
||||
export class HeaderSection {
|
||||
@ -46,7 +46,7 @@ export class HeaderSection {
|
||||
});
|
||||
|
||||
this.$buttonsWrapper = CE('div', false,
|
||||
getPref(PrefKey.REMOTE_PLAY_ENABLED) ? this.$btnRemotePlay : null,
|
||||
getGlobalPref(GlobalPref.REMOTE_PLAY_ENABLED) ? this.$btnRemotePlay : null,
|
||||
this.$btnSettings,
|
||||
);
|
||||
}
|
||||
@ -56,7 +56,7 @@ export class HeaderSection {
|
||||
return;
|
||||
}
|
||||
|
||||
const PREF_LATEST_VERSION = getPref(PrefKey.VERSION_LATEST);
|
||||
const PREF_LATEST_VERSION = getGlobalPref(GlobalPref.VERSION_LATEST);
|
||||
|
||||
// Setup Settings button
|
||||
const $btnSettings = this.$btnSettings;
|
||||
|
8
src/types/db.d.ts
vendored
8
src/types/db.d.ts
vendored
@ -2,11 +2,3 @@ interface BaseRecord {
|
||||
id: any;
|
||||
data: any;
|
||||
};
|
||||
|
||||
interface ControllerSettingsRecord extends BaseRecord {
|
||||
id: string;
|
||||
data: {
|
||||
shortcutPresetId: number;
|
||||
customizationPresetId: number;
|
||||
};
|
||||
};
|
||||
|
2
src/types/global.d.ts
vendored
2
src/types/global.d.ts
vendored
@ -1,6 +1,6 @@
|
||||
import type { BxExposed } from "@/utils/bx-exposed";
|
||||
import type { AllPresets, ControllerShortcutPresetRecord } from "./presets";
|
||||
import type { PrefKey } from "@/enums/pref-keys";
|
||||
import type { GlobalPref } from "@/enums/pref-keys";
|
||||
import type { StreamSettings, type StreamSettingsData } from "@/utils/stream-settings";
|
||||
import type { BxEvent } from "@/utils/bx-event";
|
||||
import type { BxEventBus } from "@/utils/bx-event-bus";
|
||||
|
26
src/types/index.d.ts
vendored
26
src/types/index.d.ts
vendored
@ -52,7 +52,8 @@ type BxStates = {
|
||||
currentStream: Partial<{
|
||||
titleSlug: string;
|
||||
titleInfo: XcloudTitleInfo;
|
||||
xboxTitleId: number;
|
||||
xboxTitleId: number | null;
|
||||
gameSpecificSettings: boolean;
|
||||
|
||||
streamPlayer: StreamPlayer | null;
|
||||
|
||||
@ -213,3 +214,26 @@ type XcloudGamepad = {
|
||||
RightStickAxes?: any;
|
||||
Share?: any;
|
||||
};
|
||||
|
||||
type BxFlags = {
|
||||
Debug: boolean;
|
||||
|
||||
CheckForUpdate: boolean;
|
||||
EnableXcloudLogging: boolean;
|
||||
SafariWorkaround: boolean;
|
||||
|
||||
ForceNativeMkbTitles: string[];
|
||||
FeatureGates: { [key: string]: boolean } | null,
|
||||
|
||||
DeviceInfo: {
|
||||
deviceType: 'android' | 'android-tv' | 'android-handheld' | 'webos' | 'unknown',
|
||||
userAgent?: string,
|
||||
|
||||
androidInfo?: {
|
||||
manufacturer: string,
|
||||
brand: string,
|
||||
board: string,
|
||||
model: string,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
140
src/types/mkb.d.ts
vendored
Normal file
140
src/types/mkb.d.ts
vendored
Normal file
@ -0,0 +1,140 @@
|
||||
type NativeMouseData = {
|
||||
X: number,
|
||||
Y: number,
|
||||
Buttons: number,
|
||||
WheelX: number,
|
||||
WheelY: number,
|
||||
Type?: 0, // 0: Relative, 1: Absolute
|
||||
}
|
||||
|
||||
|
||||
type XcloudInputChannel = {
|
||||
sendGamepadInput: (timestamp: number, gamepads: XcloudGamepad[]) => void;
|
||||
queueMouseInput: (data: NativeMouseData) => void;
|
||||
}
|
||||
|
||||
|
||||
type KeyCode =
|
||||
| 'Backspace'
|
||||
| 'Tab'
|
||||
| 'Enter'
|
||||
| 'ShiftLeft'
|
||||
| 'ShiftRight'
|
||||
| 'ControlLeft'
|
||||
| 'ControlRight'
|
||||
| 'AltLeft'
|
||||
| 'AltRight'
|
||||
| 'Pause'
|
||||
| 'CapsLock'
|
||||
| 'Escape'
|
||||
| 'Space'
|
||||
| 'PageUp'
|
||||
| 'PageDown'
|
||||
| 'End'
|
||||
| 'Home'
|
||||
| 'ArrowLeft'
|
||||
| 'ArrowUp'
|
||||
| 'ArrowRight'
|
||||
| 'ArrowDown'
|
||||
| 'PrintScreen'
|
||||
| 'Insert'
|
||||
| 'Delete'
|
||||
| 'Digit0'
|
||||
| 'Digit1'
|
||||
| 'Digit2'
|
||||
| 'Digit3'
|
||||
| 'Digit4'
|
||||
| 'Digit5'
|
||||
| 'Digit6'
|
||||
| 'Digit7'
|
||||
| 'Digit8'
|
||||
| 'Digit9'
|
||||
| 'KeyA'
|
||||
| 'KeyB'
|
||||
| 'KeyC'
|
||||
| 'KeyD'
|
||||
| 'KeyE'
|
||||
| 'KeyF'
|
||||
| 'KeyG'
|
||||
| 'KeyH'
|
||||
| 'KeyI'
|
||||
| 'KeyJ'
|
||||
| 'KeyK'
|
||||
| 'KeyL'
|
||||
| 'KeyM'
|
||||
| 'KeyN'
|
||||
| 'KeyO'
|
||||
| 'KeyP'
|
||||
| 'KeyQ'
|
||||
| 'KeyR'
|
||||
| 'KeyS'
|
||||
| 'KeyT'
|
||||
| 'KeyU'
|
||||
| 'KeyV'
|
||||
| 'KeyW'
|
||||
| 'KeyX'
|
||||
| 'KeyY'
|
||||
| 'KeyZ'
|
||||
| 'MetaLeft'
|
||||
| 'MetaRight'
|
||||
| 'ContextMenu'
|
||||
| 'F1'
|
||||
| 'F2'
|
||||
| 'F3'
|
||||
| 'F4'
|
||||
| 'F5'
|
||||
| 'F6'
|
||||
| 'F7'
|
||||
| 'F8'
|
||||
| 'F9'
|
||||
| 'F10'
|
||||
| 'F11'
|
||||
| 'F12'
|
||||
| 'NumLock'
|
||||
| 'ScrollLock'
|
||||
| 'AudioVolumeMute'
|
||||
| 'AudioVolumeDown'
|
||||
| 'AudioVolumeUp'
|
||||
| 'MediaTrackNext'
|
||||
| 'MediaTrackPrevious'
|
||||
| 'MediaStop'
|
||||
| 'MediaPlayPause'
|
||||
| 'LaunchMail'
|
||||
| 'LaunchMediaPlayer'
|
||||
| 'LaunchApplication1'
|
||||
| 'LaunchApplication2'
|
||||
| 'Semicolon'
|
||||
| 'Equal'
|
||||
| 'Comma'
|
||||
| 'Minus'
|
||||
| 'Period'
|
||||
| 'Slash'
|
||||
| 'Backquote'
|
||||
| 'BracketLeft'
|
||||
| 'Backslash'
|
||||
| 'BracketRight'
|
||||
| 'Quote'
|
||||
| 'Numpad0'
|
||||
| 'Numpad1'
|
||||
| 'Numpad2'
|
||||
| 'Numpad3'
|
||||
| 'Numpad4'
|
||||
| 'Numpad5'
|
||||
| 'Numpad6'
|
||||
| 'Numpad7'
|
||||
| 'Numpad8'
|
||||
| 'Numpad9'
|
||||
| 'NumpadMultiply'
|
||||
| 'NumpadAdd'
|
||||
| 'NumpadSubtract'
|
||||
| 'NumpadDecimal'
|
||||
| 'NumpadDivide';
|
||||
|
||||
type KeyCodeExcludeModifiers = Exclude<KeyCode,
|
||||
'ShiftLeft'
|
||||
| 'ShiftRight'
|
||||
| 'ControlLeft'
|
||||
| 'ControlRight'
|
||||
| 'AltLeft'
|
||||
| 'AltRight'
|
||||
>
|
8
src/types/network.d.ts
vendored
Executable file
8
src/types/network.d.ts
vendored
Executable file
@ -0,0 +1,8 @@
|
||||
type RemotePlayConsoleAddresses = {
|
||||
[key: string]: number[],
|
||||
}
|
||||
|
||||
type ForceNativeMkbResponse = {
|
||||
$schemaVersion: number;
|
||||
data: { [key: string]: string };
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
export type RemotePlayConsoleAddresses = {
|
||||
[key: string]: number[],
|
||||
}
|
13
src/types/preferences.d.ts
vendored
13
src/types/preferences.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
export type PreferenceSetting = {
|
||||
type PreferenceSetting = {
|
||||
default: any;
|
||||
optionsGroup?: string;
|
||||
options?: { [index: string]: string };
|
||||
@ -17,4 +17,13 @@ export type PreferenceSetting = {
|
||||
label?: string;
|
||||
};
|
||||
|
||||
export type PreferenceSettings = { [index in PrefKey]: PreferenceSetting };
|
||||
type PreferenceSettings = { [index in PrefKey]: PreferenceSetting };
|
||||
|
||||
type StreamPreferredLocale = 'default' | string;
|
||||
|
||||
type ControllerSetting = {
|
||||
shortcutPresetId: number;
|
||||
customizationPresetId: number;
|
||||
}
|
||||
|
||||
type ControllerSettings = Record<string, ControllerSetting>;
|
||||
|
1
src/types/prefs.d.ts
vendored
1
src/types/prefs.d.ts
vendored
@ -1 +0,0 @@
|
||||
type StreamPreferredLocale = 'default' | string;
|
28
src/types/setting-definition.d.ts
vendored
28
src/types/setting-definition.d.ts
vendored
@ -1,8 +1,8 @@
|
||||
import type { PrefKey } from "@/enums/pref-keys";
|
||||
import type { AnyPref, AnySettingsStorage, GlobalPref, StreamPref } from "@/enums/pref-keys";
|
||||
import type { SettingElementType } from "@/utils/setting-element";
|
||||
|
||||
export type SuggestedSettingProfile = 'recommended' | 'lowest' | 'highest' | 'default';
|
||||
export type RecommendedSettings = {
|
||||
type SuggestedSettingProfile = 'recommended' | 'lowest' | 'highest' | 'default';
|
||||
type RecommendedSettings = {
|
||||
schema_version: 2,
|
||||
device_name: string,
|
||||
device_type: 'android' | 'android-tv' | 'android-handheld' | 'webos',
|
||||
@ -10,11 +10,12 @@ export type RecommendedSettings = {
|
||||
app: any,
|
||||
script: {
|
||||
_base?: 'lowest' | 'highest',
|
||||
} & PartialRecord<PrefKey, any>,
|
||||
} & PartialRecord<GlobalPref, any>,
|
||||
},
|
||||
};
|
||||
|
||||
export type SettingAction = 'get' | 'set';
|
||||
type SettingAction = 'get' | 'set';
|
||||
type SettingActionOrigin = 'direct' | 'ui';
|
||||
|
||||
interface BaseSettingDefinition {
|
||||
default: any;
|
||||
@ -56,15 +57,22 @@ interface NumberStepperSettingDefinition extends BaseSettingDefinition {
|
||||
};
|
||||
}
|
||||
|
||||
export type SettingDefinition = BaseSettingDefinition | OptionsSettingDefinition | MultipleOptionsSettingDefinition | NumberStepperSettingDefinition;
|
||||
type SettingDefinition = BaseSettingDefinition | OptionsSettingDefinition | MultipleOptionsSettingDefinition | NumberStepperSettingDefinition;
|
||||
type PrefInfo = {
|
||||
storage: AnySettingsStorage,
|
||||
definition: SettingDefinition,
|
||||
// value: unknown,
|
||||
};
|
||||
|
||||
export type SettingDefinitions = { [index in PrefKey]: SettingDefinition };
|
||||
type SettingDefinitions<T extends AnyPref> = {
|
||||
[key in T]: SettingDefinition;
|
||||
};
|
||||
|
||||
export type MultipleOptionsParams = Partial<{
|
||||
type MultipleOptionsParams = Partial<{
|
||||
size?: number;
|
||||
}>
|
||||
|
||||
export type NumberStepperParams = Partial<{
|
||||
type NumberStepperParams = Partial<{
|
||||
steps: number;
|
||||
|
||||
suffix: string;
|
||||
@ -78,7 +86,7 @@ export type NumberStepperParams = Partial<{
|
||||
reverse: boolean;
|
||||
}>
|
||||
|
||||
export type DualNumberStepperParams = {
|
||||
type DualNumberStepperParams = {
|
||||
min: number;
|
||||
minDiff: number;
|
||||
max: number;
|
||||
|
3
src/types/stream-stats.d.ts
vendored
3
src/types/stream-stats.d.ts
vendored
@ -18,3 +18,6 @@ type RTCBasicStat = {
|
||||
totalDecodeTime: number,
|
||||
type: string,
|
||||
}
|
||||
|
||||
|
||||
type StreamStatGrade = '' | 'bad' | 'ok' | 'good';
|
||||
|
7
src/types/stream.d.ts
vendored
Normal file
7
src/types/stream.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
type StreamPlayerOptions = Partial<{
|
||||
processing: string,
|
||||
sharpness: number,
|
||||
saturation: number,
|
||||
contrast: number,
|
||||
brightness: number,
|
||||
}>;
|
@ -1,4 +1,4 @@
|
||||
import type { PrefKey, StorageKey } from "@/enums/pref-keys";
|
||||
import type { GlobalPref, StorageKey, StreamPref } from "@/enums/pref-keys";
|
||||
import { BX_FLAGS } from "./bx-flags";
|
||||
import { BxLogger } from "./bx-logger";
|
||||
import { AppInterface } from "./global";
|
||||
@ -11,19 +11,16 @@ type ScriptEvents = {
|
||||
'xcloud.server.ready': {};
|
||||
'xcloud.server.unavailable': {};
|
||||
|
||||
'dialog.shown': {},
|
||||
'dialog.dismissed': {},
|
||||
'dialog.shown': {};
|
||||
'dialog.dismissed': {};
|
||||
|
||||
'titleInfo.ready': {};
|
||||
'setting.changed': {
|
||||
storageKey: StorageKey;
|
||||
settingKey: PrefKey;
|
||||
settingValue: any;
|
||||
};
|
||||
|
||||
'mkb.setting.updated': {};
|
||||
'keyboardShortcuts.updated': {};
|
||||
'deviceVibration.updated': {};
|
||||
'setting.changed': {
|
||||
storageKey: Omit<StorageKey, StorageKey.STREAM>;
|
||||
settingKey: GlobalPref;
|
||||
// settingValue: any;
|
||||
};
|
||||
|
||||
// GH pages
|
||||
'list.forcedNativeMkb.updated': {
|
||||
@ -33,7 +30,7 @@ type ScriptEvents = {
|
||||
};
|
||||
|
||||
'list.localCoOp.updated': {
|
||||
ids: Set<string>,
|
||||
ids: Set<string>;
|
||||
};
|
||||
};
|
||||
|
||||
@ -44,11 +41,27 @@ type StreamEvents = {
|
||||
'state.stopped': {};
|
||||
'state.error': {};
|
||||
|
||||
'gameBar.activated': {},
|
||||
'speaker.state.changed': { state: SpeakerState },
|
||||
'video.visibility.changed': { isVisible: boolean },
|
||||
'xboxTitleId.changed': {
|
||||
id: number;
|
||||
};
|
||||
'gameSettings.switched': {
|
||||
id: number;
|
||||
};
|
||||
'setting.changed': {
|
||||
storageKey: StorageKey.STREAM | `${StorageKey.STREAM}.${number}`;
|
||||
settingKey: StreamPref;
|
||||
// settingValue: any;
|
||||
};
|
||||
|
||||
'mkb.setting.updated': {};
|
||||
'keyboardShortcuts.updated': {};
|
||||
'deviceVibration.updated': {};
|
||||
|
||||
'gameBar.activated': {};
|
||||
'speaker.state.changed': { state: SpeakerState };
|
||||
'video.visibility.changed': { isVisible: boolean };
|
||||
// Inside patch
|
||||
'microphone.state.changed': { state: MicrophoneState },
|
||||
'microphone.state.changed': { state: MicrophoneState };
|
||||
|
||||
dataChannelCreated: { dataChannel: RTCDataChannel };
|
||||
};
|
||||
@ -136,7 +149,7 @@ export class BxEventBus<TEvents extends Record<string, any>> {
|
||||
}
|
||||
}
|
||||
|
||||
BX_FLAGS.Debug && BxLogger.warning('EventBus', 'emit', event, payload);
|
||||
BX_FLAGS.Debug && BxLogger.warning('EventBus', 'emit', `${this.group}.${event as string}`, payload);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,14 +5,14 @@ import { deepClone, STATES } from "@utils/global";
|
||||
import { BxLogger } from "./bx-logger";
|
||||
import { BX_FLAGS } from "./bx-flags";
|
||||
import { NavigationDialogManager } from "@/modules/ui/dialog/navigation-dialog";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "./settings-storages/global-settings-storage";
|
||||
import { GlobalPref } from "@/enums/pref-keys";
|
||||
import { GamePassCloudGallery } from "@/enums/game-pass-gallery";
|
||||
import { TouchController } from "@/modules/touch-controller";
|
||||
import { NativeMkbMode, TouchControllerMode } from "@/enums/pref-values";
|
||||
import { Patcher, type PatchPage } from "@/modules/patcher/patcher";
|
||||
import { BxEventBus } from "./bx-event-bus";
|
||||
import { FeatureGates } from "./feature-gates";
|
||||
import { getGlobalPref } from "./pref-utils";
|
||||
import { LocalCoOpManager } from "./local-co-op-manager";
|
||||
|
||||
export enum SupportedInputType {
|
||||
@ -107,17 +107,17 @@ export const BxExposed = {
|
||||
}
|
||||
|
||||
// Remove native MKB support on mobile browsers or by user's choice
|
||||
if (getPref(PrefKey.NATIVE_MKB_MODE) === NativeMkbMode.OFF) {
|
||||
if (getGlobalPref(GlobalPref.NATIVE_MKB_MODE) === NativeMkbMode.OFF) {
|
||||
supportedInputTypes = supportedInputTypes.filter(i => i !== SupportedInputType.MKB);
|
||||
}
|
||||
|
||||
titleInfo.details.hasMkbSupport = supportedInputTypes.includes(SupportedInputType.MKB);
|
||||
|
||||
if (STATES.userAgent.capabilities.touch) {
|
||||
let touchControllerAvailability = getPref(PrefKey.TOUCH_CONTROLLER_MODE);
|
||||
let touchControllerAvailability = getGlobalPref(GlobalPref.TOUCH_CONTROLLER_MODE);
|
||||
|
||||
// Disable touch control when gamepad found
|
||||
if (touchControllerAvailability !== TouchControllerMode.OFF && getPref(PrefKey.TOUCH_CONTROLLER_AUTO_OFF)) {
|
||||
if (touchControllerAvailability !== TouchControllerMode.OFF && getGlobalPref(GlobalPref.TOUCH_CONTROLLER_AUTO_OFF)) {
|
||||
const gamepads = window.navigator.getGamepads();
|
||||
let gamepadFound = false;
|
||||
|
||||
|
@ -1,28 +1,5 @@
|
||||
import { BxLogger } from "./bx-logger";
|
||||
|
||||
export type BxFlags = {
|
||||
Debug: boolean;
|
||||
|
||||
CheckForUpdate: boolean;
|
||||
EnableXcloudLogging: boolean;
|
||||
SafariWorkaround: boolean;
|
||||
|
||||
ForceNativeMkbTitles: string[];
|
||||
FeatureGates: { [key: string]: boolean } | null,
|
||||
|
||||
DeviceInfo: {
|
||||
deviceType: 'android' | 'android-tv' | 'android-handheld' | 'webos' | 'unknown',
|
||||
userAgent?: string,
|
||||
|
||||
androidInfo?: {
|
||||
manufacturer: string,
|
||||
brand: string,
|
||||
board: string,
|
||||
model: string,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Setup flags
|
||||
const DEFAULT_FLAGS: BxFlags = {
|
||||
Debug: false,
|
||||
|
@ -9,6 +9,7 @@ import iconCursorText from "@assets/svg/cursor-text.svg" with { type: "text" };
|
||||
import iconDisplay from "@assets/svg/display.svg" with { type: "text" };
|
||||
import iconEye from "@assets/svg/eye.svg" with { type: "text" };
|
||||
import iconEyeSlash from "@assets/svg/eye-slash.svg" with { type: "text" };
|
||||
// import iconGlobalRestore from "@assets/svg/global-restore.svg" with { type: "text" };
|
||||
import iconHome from "@assets/svg/home.svg" with { type: "text" };
|
||||
import iconLocalCoOp from "@assets/svg/local-co-op.svg" with { type: "text" };
|
||||
import iconNativeMkb from "@assets/svg/native-mkb.svg" with { type: "text" };
|
||||
@ -52,6 +53,7 @@ export const BxIcon = {
|
||||
DISPLAY: iconDisplay,
|
||||
EYE: iconEye,
|
||||
EYE_SLASH: iconEyeSlash,
|
||||
// GLOBAL_RESTORE: iconGlobalRestore,
|
||||
HOME: iconHome,
|
||||
LOCAL_CO_OP: iconLocalCoOp,
|
||||
NATIVE_MKB: iconNativeMkb,
|
||||
|
@ -1,15 +1,15 @@
|
||||
import { CE } from "@utils/html";
|
||||
import { compressCss, isLiteVersion, renderStylus } from "@macros/build" with { type: "macro" };
|
||||
import { BlockFeature, UiSection } from "@/enums/pref-values";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "./settings-storages/global-settings-storage";
|
||||
import { GlobalPref } from "@/enums/pref-keys";
|
||||
import { getGlobalPref } from "./pref-utils";
|
||||
|
||||
|
||||
export function addCss() {
|
||||
const STYLUS_CSS = renderStylus() as unknown as string;
|
||||
let css = STYLUS_CSS;
|
||||
|
||||
const PREF_HIDE_SECTIONS = getPref(PrefKey.UI_HIDE_SECTIONS);
|
||||
const PREF_HIDE_SECTIONS = getGlobalPref(GlobalPref.UI_HIDE_SECTIONS);
|
||||
const selectorToHide = [];
|
||||
|
||||
if (isLiteVersion()) {
|
||||
@ -24,7 +24,7 @@ export function addCss() {
|
||||
}
|
||||
|
||||
// Hide BYOG section
|
||||
if (getPref(PrefKey.BLOCK_FEATURES).includes(BlockFeature.BYOG)) {
|
||||
if (getGlobalPref(GlobalPref.BLOCK_FEATURES).includes(BlockFeature.BYOG)) {
|
||||
selectorToHide.push('#BodyContent > div[class*=ByogRow-module__container___]');
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ export function addCss() {
|
||||
}
|
||||
|
||||
// Hide "Start a party" button in the Guide menu
|
||||
if (getPref(PrefKey.BLOCK_FEATURES).includes(BlockFeature.FRIENDS)) {
|
||||
if (getGlobalPref(GlobalPref.BLOCK_FEATURES).includes(BlockFeature.FRIENDS)) {
|
||||
selectorToHide.push('#gamepass-dialog-root div[class^=AchievementsPreview-module__container] + button[class*=HomeLandingPage-module__button]');
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ export function addCss() {
|
||||
}
|
||||
|
||||
// Reduce animations
|
||||
if (getPref(PrefKey.UI_REDUCE_ANIMATIONS)) {
|
||||
if (getGlobalPref(GlobalPref.UI_REDUCE_ANIMATIONS)) {
|
||||
css += compressCss(`
|
||||
div[class*=GameCard-module__gameTitleInnerWrapper],
|
||||
div[class*=GameCard-module__card],
|
||||
@ -65,7 +65,7 @@ div[class*=ScrollArrows-module] {
|
||||
}
|
||||
|
||||
// Hide the top-left dots icon while playing
|
||||
if (getPref(PrefKey.UI_HIDE_SYSTEM_MENU_ICON)) {
|
||||
if (getGlobalPref(GlobalPref.UI_HIDE_SYSTEM_MENU_ICON)) {
|
||||
css += compressCss(`
|
||||
div[class*=Grip-module__container] {
|
||||
visibility: hidden;
|
||||
@ -98,7 +98,7 @@ div[class*=StreamMenu-module__menu] {
|
||||
`);
|
||||
|
||||
// Simplify Stream's menu
|
||||
if (getPref(PrefKey.UI_SIMPLIFY_STREAM_MENU)) {
|
||||
if (getGlobalPref(GlobalPref.UI_SIMPLIFY_STREAM_MENU)) {
|
||||
css += compressCss(`
|
||||
div[class*=Menu-module__scrollable] {
|
||||
--bxStreamMenuItemSize: 80px;
|
||||
@ -158,7 +158,7 @@ body:not([data-media-type=tv]) div[class*=MenuItem-module__label] {
|
||||
}
|
||||
|
||||
// Hide scrollbar
|
||||
if (getPref(PrefKey.UI_SCROLLBAR_HIDE)) {
|
||||
if (getGlobalPref(GlobalPref.UI_SCROLLBAR_HIDE)) {
|
||||
css += compressCss(`
|
||||
html {
|
||||
scrollbar-width: none;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { GlobalPref } from "@/enums/pref-keys";
|
||||
import { BX_FLAGS } from "./bx-flags";
|
||||
import { getPref } from "./settings-storages/global-settings-storage";
|
||||
import { BlockFeature, NativeMkbMode } from "@/enums/pref-values";
|
||||
import { getGlobalPref } from "./pref-utils";
|
||||
|
||||
export let FeatureGates: { [key: string]: boolean } = {
|
||||
PwaPrompt: false,
|
||||
@ -12,13 +12,13 @@ export let FeatureGates: { [key: string]: boolean } = {
|
||||
};
|
||||
|
||||
// Enable Native Mouse & Keyboard
|
||||
const nativeMkbMode = getPref(PrefKey.NATIVE_MKB_MODE);
|
||||
const nativeMkbMode = getGlobalPref(GlobalPref.NATIVE_MKB_MODE);
|
||||
if (nativeMkbMode !== NativeMkbMode.DEFAULT) {
|
||||
FeatureGates.EnableMouseAndKeyboard = nativeMkbMode === NativeMkbMode.ON;
|
||||
}
|
||||
|
||||
// Disable chat feature
|
||||
const blockFeatures = getPref(PrefKey.BLOCK_FEATURES);
|
||||
const blockFeatures = getGlobalPref(GlobalPref.BLOCK_FEATURES);
|
||||
if (blockFeatures.includes(BlockFeature.CHAT)) {
|
||||
FeatureGates.EnableGuideChatTab = false;
|
||||
}
|
||||
|
@ -2,35 +2,27 @@ import { VIRTUAL_GAMEPAD_ID } from "@modules/mkb/mkb-handler";
|
||||
import { t } from "@utils/translation";
|
||||
import { Toast } from "@utils/toast";
|
||||
import { BxLogger } from "@utils/bx-logger";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "./settings-storages/global-settings-storage";
|
||||
import { GamepadKey, GamepadKeyName } from "@/enums/gamepad";
|
||||
import { getStreamPref } from "@/utils/pref-utils";
|
||||
import { StreamPref } from "@/enums/pref-keys";
|
||||
|
||||
export type NativeMouseData = {
|
||||
X: number,
|
||||
Y: number,
|
||||
Buttons: number,
|
||||
WheelX: number,
|
||||
WheelY: number,
|
||||
Type?: 0, // 0: Relative, 1: Absolute
|
||||
}
|
||||
|
||||
export type XcloudInputChannel = {
|
||||
sendGamepadInput: (timestamp: number, gamepads: XcloudGamepad[]) => void;
|
||||
queueMouseInput: (data: NativeMouseData) => void;
|
||||
}
|
||||
|
||||
// Show a toast when connecting/disconecting controller
|
||||
export function showGamepadToast(gamepad: Gamepad) {
|
||||
// Don't show Toast for virtual controller
|
||||
// Don't show toast for virtual controller
|
||||
if (gamepad.id === VIRTUAL_GAMEPAD_ID) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't show toast when toggling local co-op feature
|
||||
if ((gamepad as any)._noToast) {
|
||||
return;
|
||||
}
|
||||
|
||||
BxLogger.info('Gamepad', gamepad);
|
||||
let text = '🎮';
|
||||
|
||||
if (getPref(PrefKey.LOCAL_CO_OP_ENABLED)) {
|
||||
if (getStreamPref(StreamPref.LOCAL_CO_OP_ENABLED)) {
|
||||
text += ` #${gamepad.index + 1}`;
|
||||
}
|
||||
|
||||
@ -49,6 +41,10 @@ export function showGamepadToast(gamepad: Gamepad) {
|
||||
Toast.show(text, status, { instant: false });
|
||||
}
|
||||
|
||||
export function simplifyGamepadName(name: string) {
|
||||
return name.replace(/\s+\(.*Vendor: ([0-9a-f]{4}) Product: ([0-9a-f]{4})\)$/, ' ($1-$2)');
|
||||
}
|
||||
|
||||
export function getUniqueGamepadNames() {
|
||||
const gamepads = window.navigator.getGamepads();
|
||||
const names: string[] = [];
|
||||
|
@ -4,11 +4,6 @@ import { BxLogger } from "./bx-logger";
|
||||
import { BxEventBus } from "./bx-event-bus";
|
||||
|
||||
|
||||
export type ForceNativeMkbResponse = {
|
||||
$schemaVersion: number;
|
||||
data: { [key: string]: string };
|
||||
}
|
||||
|
||||
export class GhPagesUtils {
|
||||
static fetchLatestCommit() {
|
||||
const url = 'https://api.github.com/repos/redphx/better-xcloud/branches/gh-pages';
|
||||
|
@ -1,4 +1,3 @@
|
||||
import type { BaseSettingsStore } from "./settings-storages/base-settings-storage";
|
||||
import { UserAgent } from "./user-agent";
|
||||
|
||||
export const SCRIPT_VERSION = Bun.env.SCRIPT_VERSION!;
|
||||
@ -47,8 +46,6 @@ export const STATES: BxStates = {
|
||||
pointerServerPort: 9269,
|
||||
};
|
||||
|
||||
export const STORAGE: { [key: string]: BaseSettingsStore } = {};
|
||||
|
||||
export function deepClone(obj: any): typeof obj | {} {
|
||||
if (!obj) {
|
||||
return {};
|
||||
|
@ -4,6 +4,7 @@ import type { NavigationNearbyElements } from "@/modules/ui/dialog/navigation-di
|
||||
import type { PresetRecord, AllPresets } from "@/types/presets";
|
||||
import { t } from "./translation";
|
||||
import type { BxSelectElement } from "@/web-components/bx-select";
|
||||
import type { AnyPref } from "@/enums/pref-keys";
|
||||
|
||||
export enum ButtonStyle {
|
||||
PRIMARY = 1,
|
||||
@ -57,6 +58,8 @@ export type SettingsRowOptions = Partial<{
|
||||
icon: BxIconRaw,
|
||||
multiLines: boolean;
|
||||
$note: HTMLElement;
|
||||
onContextMenu: (e?: Event) => {};
|
||||
pref: AnyPref,
|
||||
}>;
|
||||
|
||||
// Quickly create a tree of elements without having to use innerHTML
|
||||
@ -206,10 +209,12 @@ export function createButton<T=HTMLButtonElement>(options: BxButtonOptions): T {
|
||||
return $btn as T;
|
||||
}
|
||||
|
||||
export function createSettingRow(label: string, $control: HTMLElement | false | undefined, options: SettingsRowOptions={}) {
|
||||
export function createSettingRow(label: string, $control: HTMLElement | false | null | undefined, options: SettingsRowOptions={}) {
|
||||
let $label: HTMLElement;
|
||||
|
||||
const $row = CE('label', { class: 'bx-settings-row' },
|
||||
const $row = CE('label', {
|
||||
class: 'bx-settings-row',
|
||||
},
|
||||
$label = CE('span', { class: 'bx-settings-label' },
|
||||
options.icon && createSvgIcon(options.icon),
|
||||
label,
|
||||
@ -218,6 +223,14 @@ export function createSettingRow(label: string, $control: HTMLElement | false |
|
||||
$control,
|
||||
);
|
||||
|
||||
if (options.pref) {
|
||||
($row as any).prefKey = options.pref;
|
||||
}
|
||||
|
||||
if (options.onContextMenu) {
|
||||
$row.addEventListener('contextmenu', options.onContextMenu);
|
||||
}
|
||||
|
||||
// Make link inside <label> focusable
|
||||
const $link = $label.querySelector('a');
|
||||
if ($link) {
|
||||
|
@ -1,40 +0,0 @@
|
||||
import { BaseLocalTable } from "./base-table";
|
||||
import { LocalDb } from "./local-db";
|
||||
import { ControllerShortcutDefaultId } from "./controller-shortcuts-table";
|
||||
import { deepClone } from "../global";
|
||||
import { ControllerCustomizationDefaultPresetId } from "./controller-customizations-table";
|
||||
|
||||
export class ControllerSettingsTable extends BaseLocalTable<ControllerSettingsRecord> {
|
||||
private static instance: ControllerSettingsTable;
|
||||
public static getInstance = () => ControllerSettingsTable.instance ?? (ControllerSettingsTable.instance = new ControllerSettingsTable(LocalDb.TABLE_CONTROLLER_SETTINGS));
|
||||
|
||||
static readonly DEFAULT_DATA: ControllerSettingsRecord['data'] = {
|
||||
shortcutPresetId: ControllerShortcutDefaultId.DEFAULT,
|
||||
customizationPresetId: ControllerCustomizationDefaultPresetId.DEFAULT,
|
||||
};
|
||||
|
||||
async getControllerData(id: string): Promise<ControllerSettingsRecord['data']> {
|
||||
const setting = await this.get(id);
|
||||
if (!setting) {
|
||||
return deepClone(ControllerSettingsTable.DEFAULT_DATA);
|
||||
}
|
||||
|
||||
return setting.data;
|
||||
}
|
||||
|
||||
async getControllersData() {
|
||||
const all = await this.getAll();
|
||||
const results: { [key: string]: ControllerSettingsRecord['data'] } = {};
|
||||
|
||||
for (const key in all) {
|
||||
if (!all[key]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const settings = Object.assign(all[key].data, ControllerSettingsTable.DEFAULT_DATA);
|
||||
results[key] = settings;
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
@ -2,15 +2,15 @@ import { BxEvent } from "@utils/bx-event";
|
||||
import { STATES } from "@utils/global";
|
||||
import { BxLogger } from "@utils/bx-logger";
|
||||
import { patchSdpBitrate, setCodecPreferences } from "./sdp";
|
||||
import { StreamPlayer, type StreamPlayerOptions } from "@/modules/stream-player";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref, getPrefDefinition } from "./settings-storages/global-settings-storage";
|
||||
import { StreamPlayer } from "@/modules/stream-player";
|
||||
import { GlobalPref, StreamPref } from "@/enums/pref-keys";
|
||||
import { CodecProfile } from "@/enums/pref-values";
|
||||
import type { SettingDefinition } from "@/types/setting-definition";
|
||||
import { BxEventBus } from "./bx-event-bus";
|
||||
import { getGlobalPref, getGlobalPrefDefinition, getStreamPref } from "@/utils/pref-utils";
|
||||
|
||||
export function patchVideoApi() {
|
||||
const PREF_SKIP_SPLASH_VIDEO = getPref(PrefKey.UI_SKIP_SPLASH_VIDEO);
|
||||
const PREF_SKIP_SPLASH_VIDEO = getGlobalPref(GlobalPref.UI_SKIP_SPLASH_VIDEO);
|
||||
|
||||
// Show video player when it's ready
|
||||
const showFunc = function(this: HTMLVideoElement) {
|
||||
@ -20,13 +20,13 @@ export function patchVideoApi() {
|
||||
}
|
||||
|
||||
const playerOptions = {
|
||||
processing: getPref(PrefKey.VIDEO_PROCESSING),
|
||||
sharpness: getPref(PrefKey.VIDEO_SHARPNESS),
|
||||
saturation: getPref(PrefKey.VIDEO_SATURATION),
|
||||
contrast: getPref(PrefKey.VIDEO_CONTRAST),
|
||||
brightness: getPref(PrefKey.VIDEO_BRIGHTNESS),
|
||||
processing: getStreamPref(StreamPref.VIDEO_PROCESSING),
|
||||
sharpness: getStreamPref(StreamPref.VIDEO_SHARPNESS),
|
||||
saturation: getStreamPref(StreamPref.VIDEO_SATURATION),
|
||||
contrast: getStreamPref(StreamPref.VIDEO_CONTRAST),
|
||||
brightness: getStreamPref(StreamPref.VIDEO_BRIGHTNESS),
|
||||
} satisfies StreamPlayerOptions;
|
||||
STATES.currentStream.streamPlayer = new StreamPlayer(this, getPref(PrefKey.VIDEO_PLAYER_TYPE), playerOptions);
|
||||
STATES.currentStream.streamPlayer = new StreamPlayer(this, getStreamPref(StreamPref.VIDEO_PLAYER_TYPE), playerOptions);
|
||||
|
||||
BxEventBus.Stream.emit('state.playing', {
|
||||
$video: this,
|
||||
@ -60,7 +60,7 @@ export function patchVideoApi() {
|
||||
|
||||
|
||||
export function patchRtcCodecs() {
|
||||
const codecProfile = getPref(PrefKey.STREAM_CODEC_PROFILE);
|
||||
const codecProfile = getGlobalPref(GlobalPref.STREAM_CODEC_PROFILE);
|
||||
if (codecProfile === 'default') {
|
||||
return;
|
||||
}
|
||||
@ -80,9 +80,9 @@ export function patchRtcPeerConnection() {
|
||||
return dataChannel;
|
||||
}
|
||||
|
||||
const maxVideoBitrateDef = getPrefDefinition(PrefKey.STREAM_MAX_VIDEO_BITRATE) as Extract<SettingDefinition, { min: number }>;
|
||||
const maxVideoBitrate = getPref(PrefKey.STREAM_MAX_VIDEO_BITRATE);
|
||||
const codec = getPref(PrefKey.STREAM_CODEC_PROFILE);
|
||||
const maxVideoBitrateDef = getGlobalPrefDefinition(GlobalPref.STREAM_MAX_VIDEO_BITRATE) as Extract<SettingDefinition, { min: number }>;
|
||||
const maxVideoBitrate = getGlobalPref(GlobalPref.STREAM_MAX_VIDEO_BITRATE);
|
||||
const codec = getGlobalPref(GlobalPref.STREAM_CODEC_PROFILE);
|
||||
|
||||
if (codec !== CodecProfile.DEFAULT || maxVideoBitrate < maxVideoBitrateDef.max) {
|
||||
const nativeSetLocalDescription = RTCPeerConnection.prototype.setLocalDescription;
|
||||
@ -113,8 +113,8 @@ export function patchRtcPeerConnection() {
|
||||
STATES.currentStream.peerConnection = conn;
|
||||
|
||||
conn.addEventListener('connectionstatechange', e => {
|
||||
BxLogger.info('connectionstatechange', conn.connectionState);
|
||||
});
|
||||
BxLogger.info('connectionstatechange', conn.connectionState);
|
||||
});
|
||||
return conn;
|
||||
}
|
||||
}
|
||||
@ -134,7 +134,7 @@ export function patchAudioContext() {
|
||||
|
||||
ctx.createGain = function() {
|
||||
const gainNode = nativeCreateGain.apply(this);
|
||||
gainNode.gain.value = getPref(PrefKey.AUDIO_VOLUME) / 100;
|
||||
gainNode.gain.value = getStreamPref(StreamPref.AUDIO_VOLUME) / 100;
|
||||
|
||||
STATES.currentStream.audioGainNode = gainNode;
|
||||
return gainNode;
|
||||
|
@ -8,11 +8,10 @@ import { FeatureGates } from "./feature-gates";
|
||||
import { BxLogger } from "./bx-logger";
|
||||
import { XhomeInterceptor } from "./xhome-interceptor";
|
||||
import { XcloudInterceptor } from "./xcloud-interceptor";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "./settings-storages/global-settings-storage";
|
||||
import type { RemotePlayConsoleAddresses } from "@/types/network";
|
||||
import { GlobalPref } from "@/enums/pref-keys";
|
||||
import { BlockFeature, StreamResolution } from "@/enums/pref-values";
|
||||
import { blockAllNotifications } from "./utils";
|
||||
import { getGlobalPref } from "./pref-utils";
|
||||
|
||||
type RequestType = 'xcloud' | 'xhome';
|
||||
|
||||
@ -107,7 +106,7 @@ export async function patchIceCandidates(request: Request, consoleAddrs?: Remote
|
||||
}
|
||||
|
||||
const options = {
|
||||
preferIpv6Server: getPref(PrefKey.SERVER_PREFER_IPV6),
|
||||
preferIpv6Server: getGlobalPref(GlobalPref.SERVER_PREFER_IPV6),
|
||||
consoleAddrs: consoleAddrs,
|
||||
};
|
||||
|
||||
@ -125,7 +124,7 @@ export async function patchIceCandidates(request: Request, consoleAddrs?: Remote
|
||||
|
||||
export function interceptHttpRequests() {
|
||||
let BLOCKED_URLS: string[] = [];
|
||||
if (getPref(PrefKey.BLOCK_TRACKING)) {
|
||||
if (getGlobalPref(GlobalPref.BLOCK_TRACKING)) {
|
||||
// Clear Applications Insight buffers
|
||||
clearAllLogs();
|
||||
|
||||
@ -141,7 +140,7 @@ export function interceptHttpRequests() {
|
||||
|
||||
// 'https://notificationinbox.xboxlive.com',
|
||||
// 'https://accounts.xboxlive.com/family/memberXuid',
|
||||
const blockFeatures = getPref(PrefKey.BLOCK_FEATURES);
|
||||
const blockFeatures = getGlobalPref(GlobalPref.BLOCK_FEATURES);
|
||||
if (blockFeatures.includes(BlockFeature.CHAT)) {
|
||||
BLOCKED_URLS.push(
|
||||
'https://xblmessaging.xboxlive.com/network/xbox/users/me/inbox',
|
||||
|
60
src/utils/pref-utils.ts
Normal file
60
src/utils/pref-utils.ts
Normal file
@ -0,0 +1,60 @@
|
||||
import { ALL_PREFS, GlobalPref, StreamPref, type AnyPref } from "@/enums/pref-keys";
|
||||
import type { PrefInfo, SettingActionOrigin } from "@/types/setting-definition";
|
||||
import { GlobalSettingsStorage } from "./settings-storages/global-settings-storage";
|
||||
import { StreamSettingsStorage } from "./settings-storages/stream-settings-storage";
|
||||
|
||||
export const STORAGE = {
|
||||
Global: new GlobalSettingsStorage(),
|
||||
Stream: new StreamSettingsStorage(),
|
||||
};
|
||||
|
||||
const streamSettingsStorage = STORAGE.Stream;
|
||||
export const getStreamPrefDefinition = streamSettingsStorage.getDefinition.bind(streamSettingsStorage);
|
||||
export const getStreamPref = streamSettingsStorage.getSetting.bind(streamSettingsStorage);
|
||||
export const setStreamPref = streamSettingsStorage.setSetting.bind(streamSettingsStorage);
|
||||
export const getGamePref = streamSettingsStorage.getSettingByGame.bind(streamSettingsStorage);
|
||||
export const setGamePref = streamSettingsStorage.setSettingByGame.bind(streamSettingsStorage);
|
||||
export const setGameIdPref = streamSettingsStorage.setGameId.bind(streamSettingsStorage);
|
||||
export const hasGamePref = streamSettingsStorage.hasGameSetting.bind(streamSettingsStorage);
|
||||
STORAGE.Stream = streamSettingsStorage;
|
||||
|
||||
const globalSettingsStorage = STORAGE.Global;
|
||||
export const getGlobalPrefDefinition = globalSettingsStorage.getDefinition.bind(globalSettingsStorage);
|
||||
export const getGlobalPref = globalSettingsStorage.getSetting.bind(globalSettingsStorage);
|
||||
export const setGlobalPref = globalSettingsStorage.setSetting.bind(globalSettingsStorage);
|
||||
|
||||
|
||||
export function isGlobalPref(prefKey: AnyPref): prefKey is GlobalPref {
|
||||
return ALL_PREFS.global.includes(prefKey as GlobalPref);
|
||||
}
|
||||
|
||||
export function isStreamPref(prefKey: AnyPref): prefKey is StreamPref {
|
||||
return ALL_PREFS.stream.includes(prefKey as StreamPref);
|
||||
}
|
||||
|
||||
export function getPrefInfo(prefKey: AnyPref): PrefInfo {
|
||||
if (isGlobalPref(prefKey)) {
|
||||
return {
|
||||
storage: STORAGE.Global,
|
||||
definition: getGlobalPrefDefinition(prefKey as GlobalPref),
|
||||
// value: getGlobalPref(prefKey as GlobalPref),
|
||||
}
|
||||
} else if (isStreamPref(prefKey)) {
|
||||
return {
|
||||
storage: STORAGE.Stream,
|
||||
definition: getStreamPrefDefinition(prefKey as StreamPref),
|
||||
// value: getStreamPref(prefKey as StreamPref),
|
||||
}
|
||||
}
|
||||
|
||||
alert('Missing pref definition: ' + prefKey);
|
||||
return {} as PrefInfo;
|
||||
}
|
||||
|
||||
export function setPref(prefKey: AnyPref, value: any, origin: SettingActionOrigin) {
|
||||
if (isGlobalPref(prefKey)) {
|
||||
setGlobalPref(prefKey as GlobalPref, value, origin);
|
||||
} else if (isStreamPref(prefKey)) {
|
||||
setStreamPref(prefKey as StreamPref, value, origin);
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
import { STATES } from "@utils/global";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "./settings-storages/global-settings-storage";
|
||||
import { GlobalPref } from "@/enums/pref-keys";
|
||||
import { getGlobalPref } from "./pref-utils";
|
||||
|
||||
|
||||
export function getPreferredServerRegion(shortName = false): string | null {
|
||||
let preferredRegion = getPref(PrefKey.SERVER_REGION);
|
||||
let preferredRegion = getGlobalPref(GlobalPref.SERVER_REGION);
|
||||
const serverRegions = STATES.serverRegions;
|
||||
|
||||
// Return preferred region
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { AppInterface, STATES } from "./global";
|
||||
import { CE } from "./html";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "./settings-storages/global-settings-storage";
|
||||
import { GlobalPref } from "@/enums/pref-keys";
|
||||
import { BxLogger } from "./bx-logger";
|
||||
import { StreamPlayerType } from "@/enums/pref-values";
|
||||
import { getGlobalPref } from "@/utils/pref-utils";
|
||||
|
||||
|
||||
export class ScreenshotManager {
|
||||
@ -49,7 +49,7 @@ export class ScreenshotManager {
|
||||
}
|
||||
|
||||
let $player;
|
||||
if (getPref(PrefKey.SCREENSHOT_APPLY_FILTERS)) {
|
||||
if (getGlobalPref(GlobalPref.SCREENSHOT_APPLY_FILTERS)) {
|
||||
$player = streamPlayer.getPlayerElement();
|
||||
} else {
|
||||
$player = streamPlayer.getPlayerElement(StreamPlayerType.VIDEO);
|
||||
|
@ -1,10 +1,10 @@
|
||||
import type { PreferenceSetting } from "@/types/preferences";
|
||||
import { CE, escapeCssSelector } from "@utils/html";
|
||||
import type { PrefKey } from "@/enums/pref-keys";
|
||||
import type { BaseSettingsStore } from "./settings-storages/base-settings-storage";
|
||||
import type { AnyPref } from "@/enums/pref-keys";
|
||||
import { type BaseSettingDefinition, type MultipleOptionsParams, type NumberStepperParams } from "@/types/setting-definition";
|
||||
import { BxEvent } from "./bx-event";
|
||||
import { BxNumberStepper } from "@/web-components/bx-number-stepper";
|
||||
import { getPrefInfo, isGlobalPref, setGlobalPref, setGamePref } from "./pref-utils";
|
||||
import { SettingsManager } from "@/modules/settings-manager";
|
||||
|
||||
export enum SettingElementType {
|
||||
OPTIONS = 'options',
|
||||
@ -107,6 +107,20 @@ export class SettingElement {
|
||||
!(e as any).ignoreOnChange && onChange(e, values);
|
||||
});
|
||||
|
||||
Object.defineProperty($control, 'value', {
|
||||
get() {
|
||||
return Array.from($control.options)
|
||||
.filter(option => option.selected)
|
||||
.map(option => option.value);
|
||||
},
|
||||
set(value) {
|
||||
const values = value.split(',');
|
||||
Array.from($control.options).forEach(option => {
|
||||
option.selected = values.includes(option.value);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return $control;
|
||||
}
|
||||
|
||||
@ -154,10 +168,14 @@ export class SettingElement {
|
||||
return $control;
|
||||
}
|
||||
|
||||
static fromPref(key: PrefKey, storage: BaseSettingsStore, onChange: any, overrideParams={}) {
|
||||
const definition = storage.getDefinition(key);
|
||||
static fromPref(key: AnyPref, onChange?: ((e: Event, value: any) => void) | null | undefined, overrideParams={}) {
|
||||
const { definition, storage } = getPrefInfo(key);
|
||||
if (!definition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
let currentValue = storage.getSetting(key);
|
||||
let currentValue = storage.getSetting(key) as any;
|
||||
|
||||
let type;
|
||||
if ('options' in definition) {
|
||||
@ -179,8 +197,14 @@ export class SettingElement {
|
||||
currentValue = definition.default;
|
||||
}
|
||||
|
||||
const $control = SettingElement.render(type!, key as string, definition, currentValue, (e: any, value: any) => {
|
||||
storage.setSetting(key, value);
|
||||
const $control = SettingElement.render(type!, key as string, definition, currentValue, (e: Event, value: any) => {
|
||||
if (isGlobalPref(key)) {
|
||||
setGlobalPref(key, value, 'ui');
|
||||
} else {
|
||||
const id = SettingsManager.getInstance().getTargetGameId();
|
||||
setGamePref(id, key, value, 'ui');
|
||||
}
|
||||
|
||||
onChange && onChange(e, value);
|
||||
}, params);
|
||||
|
||||
|
@ -1,23 +1,22 @@
|
||||
import type { PrefKey, PrefTypeMap, StorageKey } from "@/enums/pref-keys";
|
||||
import type { NumberStepperParams, SettingAction, SettingDefinitions } from "@/types/setting-definition";
|
||||
import type { AnyPref, PrefTypeMap, StorageKey } from "@/enums/pref-keys";
|
||||
import type { NumberStepperParams, SettingAction, SettingActionOrigin, SettingDefinition, SettingDefinitions } from "@/types/setting-definition";
|
||||
import { t } from "../translation";
|
||||
import { SCRIPT_VARIANT } from "../global";
|
||||
import { deepClone, SCRIPT_VARIANT } from "../global";
|
||||
import { BxEventBus } from "../bx-event-bus";
|
||||
import { isStreamPref } from "../pref-utils";
|
||||
import { isPlainObject } from "../utils";
|
||||
|
||||
export class BaseSettingsStore {
|
||||
export class BaseSettingsStorage<T extends AnyPref> {
|
||||
private storage: Storage;
|
||||
private storageKey: StorageKey;
|
||||
private storageKey: StorageKey | StorageKey.STREAM | `${StorageKey.STREAM}.${number}`;
|
||||
private _settings: object | null;
|
||||
private definitions: SettingDefinitions;
|
||||
private definitions: SettingDefinitions<T>;
|
||||
|
||||
constructor(storageKey: StorageKey, definitions: SettingDefinitions) {
|
||||
constructor(storageKey: typeof this.storageKey, definitions:SettingDefinitions<T>) {
|
||||
this.storage = window.localStorage;
|
||||
this.storageKey = storageKey;
|
||||
|
||||
let settingId: keyof typeof definitions
|
||||
for (settingId in definitions) {
|
||||
const setting = definitions[settingId];
|
||||
|
||||
for (const [_, setting] of Object.entries(definitions) as [T, SettingDefinition][]) {
|
||||
// Convert requiredVariants to array
|
||||
if (typeof setting.requiredVariants === 'string') {
|
||||
setting.requiredVariants = [setting.requiredVariants];
|
||||
@ -45,59 +44,69 @@ export class BaseSettingsStore {
|
||||
|
||||
// Validate setting values
|
||||
for (const key in settings) {
|
||||
settings[key] = this.validateValue('get', key as PrefKey, settings[key]);
|
||||
settings[key] = this.validateValue('get', key as T, settings[key]);
|
||||
}
|
||||
|
||||
this._settings = settings;
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
getDefinition(key: PrefKey) {
|
||||
getDefinition(key: T) {
|
||||
if (!this.definitions[key]) {
|
||||
const error = 'Request invalid definition: ' + key;
|
||||
alert(error);
|
||||
throw Error(error);
|
||||
alert('Request invalid definition: ' + key);
|
||||
return {} as SettingDefinition;
|
||||
}
|
||||
|
||||
return this.definitions[key];
|
||||
}
|
||||
|
||||
getSetting<T extends keyof PrefTypeMap>(key: T, checkUnsupported = true): PrefTypeMap[T] {
|
||||
const definition = this.definitions[key];
|
||||
hasSetting<K extends keyof PrefTypeMap<K>>(key: K): boolean {
|
||||
return key in this.settings;
|
||||
}
|
||||
|
||||
getSetting<K extends keyof PrefTypeMap<K>>(key: K, checkUnsupported = true): PrefTypeMap<K>[K] {
|
||||
const definition = this.definitions[key] as SettingDefinition;
|
||||
|
||||
// Return default value if build variant is different
|
||||
if (definition.requiredVariants && !definition.requiredVariants.includes(SCRIPT_VARIANT)) {
|
||||
return definition.default as PrefTypeMap[T];
|
||||
return (isPlainObject(definition.default) ? deepClone(definition.default) : definition.default) as PrefTypeMap<K>[K];
|
||||
}
|
||||
|
||||
// Return default value if the feature is not supported
|
||||
if (checkUnsupported && definition.unsupported) {
|
||||
if ('unsupportedValue' in definition) {
|
||||
return definition.unsupportedValue as PrefTypeMap[T];
|
||||
return definition.unsupportedValue as PrefTypeMap<K>[K];
|
||||
} else {
|
||||
return definition.default as PrefTypeMap[T];
|
||||
return (isPlainObject(definition.default) ? deepClone(definition.default) : definition.default) as PrefTypeMap<K>[K];
|
||||
}
|
||||
}
|
||||
|
||||
if (!(key in this.settings)) {
|
||||
this.settings[key] = this.validateValue('get', key, null);
|
||||
this.settings[key] = this.validateValue('get', key as any, null);
|
||||
}
|
||||
|
||||
return this.settings[key] as PrefTypeMap[T];
|
||||
return (isPlainObject(this.settings[key]) ? deepClone(this.settings[key]) : this.settings[key]) as PrefTypeMap<K>[K];
|
||||
}
|
||||
|
||||
setSetting<T=any>(key: PrefKey, value: T, emitEvent = false) {
|
||||
setSetting<V=any>(key: T, value: V, origin: SettingActionOrigin) {
|
||||
value = this.validateValue('set', key, value);
|
||||
|
||||
this.settings[key] = this.validateValue('get', key, value);
|
||||
this.saveSettings();
|
||||
|
||||
emitEvent && BxEventBus.Script.emit('setting.changed', {
|
||||
storageKey: this.storageKey,
|
||||
settingKey: key,
|
||||
settingValue: value,
|
||||
});
|
||||
if (origin === 'ui') {
|
||||
if (isStreamPref(key)) {
|
||||
BxEventBus.Stream.emit('setting.changed', {
|
||||
storageKey: this.storageKey as any,
|
||||
settingKey: key,
|
||||
});
|
||||
} else {
|
||||
BxEventBus.Script.emit('setting.changed', {
|
||||
storageKey: this.storageKey,
|
||||
settingKey: key,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
@ -106,8 +115,8 @@ export class BaseSettingsStore {
|
||||
this.storage.setItem(this.storageKey, JSON.stringify(this.settings));
|
||||
}
|
||||
|
||||
private validateValue(action: SettingAction, key: PrefKey, value: any) {
|
||||
const def = this.definitions[key];
|
||||
private validateValue(action: SettingAction, key: T, value: any) {
|
||||
const def = this.definitions[key] as SettingDefinition;
|
||||
if (!def) {
|
||||
return value;
|
||||
}
|
||||
@ -154,12 +163,12 @@ export class BaseSettingsStore {
|
||||
return value;
|
||||
}
|
||||
|
||||
getLabel(key: PrefKey): string {
|
||||
return this.definitions[key].label || key;
|
||||
getLabel(key: T): string {
|
||||
return (this.definitions[key] as SettingDefinition).label || key;
|
||||
}
|
||||
|
||||
getValueText(key: PrefKey, value: any): string {
|
||||
const definition = this.definitions[key];
|
||||
getValueText(key: T, value: any): string {
|
||||
const definition = this.definitions[key] as SettingDefinition;
|
||||
if ('min' in definition) {
|
||||
const params = (definition as any).params as NumberStepperParams;
|
||||
if (params.customTextValue) {
|
||||
|
20
src/utils/settings-storages/game-settings-storage.ts
Normal file
20
src/utils/settings-storages/game-settings-storage.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { StorageKey, type StreamPref } from "@/enums/pref-keys";
|
||||
import { BaseSettingsStorage } from "./base-settings-storage";
|
||||
import { StreamSettingsStorage } from "./stream-settings-storage";
|
||||
|
||||
export class GameSettingsStorage extends BaseSettingsStorage<StreamPref> {
|
||||
constructor(id: number) {
|
||||
super(`${StorageKey.STREAM}.${id}`, StreamSettingsStorage.DEFINITIONS);
|
||||
}
|
||||
|
||||
deleteSetting(pref: StreamPref) {
|
||||
if (this.hasSetting(pref)) {
|
||||
delete this.settings[pref];
|
||||
this.saveSettings();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,16 +1,14 @@
|
||||
import { BypassServers } from "@/enums/bypass-servers";
|
||||
import { PrefKey, StorageKey } from "@/enums/pref-keys";
|
||||
import { GlobalPref, StorageKey, type GlobalPrefTypeMap } from "@/enums/pref-keys";
|
||||
import { UserAgentProfile } from "@/enums/user-agent";
|
||||
import { type SettingDefinition, type SettingDefinitions } from "@/types/setting-definition";
|
||||
import { type SettingDefinition } from "@/types/setting-definition";
|
||||
import { BX_FLAGS } from "../bx-flags";
|
||||
import { STATES, AppInterface, STORAGE } from "../global";
|
||||
import { STATES, AppInterface } from "../global";
|
||||
import { CE } from "../html";
|
||||
import { t, SUPPORTED_LANGUAGES } from "../translation";
|
||||
import { UserAgent } from "../user-agent";
|
||||
import { BaseSettingsStore as BaseSettingsStorage } from "./base-settings-storage";
|
||||
import { CodecProfile, StreamResolution, TouchControllerMode, TouchControllerStyleStandard, TouchControllerStyleCustom, GameBarPosition, DeviceVibrationMode, NativeMkbMode, UiLayout, UiSection, StreamPlayerType, StreamVideoProcessing, VideoRatio, StreamStat, VideoPosition, BlockFeature, StreamStatPosition, VideoPowerPreference } from "@/enums/pref-values";
|
||||
import { MkbMappingDefaultPresetId } from "../local-db/mkb-mapping-presets-table";
|
||||
import { KeyboardShortcutDefaultId } from "../local-db/keyboard-shortcuts-table";
|
||||
import { BaseSettingsStorage } from "./base-settings-storage";
|
||||
import { CodecProfile, StreamResolution, TouchControllerMode, TouchControllerStyleStandard, TouchControllerStyleCustom, GameBarPosition, NativeMkbMode, UiLayout, UiSection, BlockFeature } from "@/enums/pref-values";
|
||||
import { GhPagesUtils } from "../gh-pages";
|
||||
import { BxEventBus } from "../bx-event-bus";
|
||||
import { BxIcon } from "../bx-icon";
|
||||
@ -72,28 +70,28 @@ function getSupportedCodecProfiles() {
|
||||
return options;
|
||||
}
|
||||
|
||||
export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
private static readonly DEFINITIONS = {
|
||||
[PrefKey.VERSION_LAST_CHECK]: {
|
||||
export class GlobalSettingsStorage extends BaseSettingsStorage<GlobalPref> {
|
||||
private static readonly DEFINITIONS: Record<keyof GlobalPrefTypeMap, SettingDefinition> = {
|
||||
[GlobalPref.VERSION_LAST_CHECK]: {
|
||||
default: 0,
|
||||
},
|
||||
[PrefKey.VERSION_LATEST]: {
|
||||
[GlobalPref.VERSION_LATEST]: {
|
||||
default: '',
|
||||
},
|
||||
[PrefKey.VERSION_CURRENT]: {
|
||||
[GlobalPref.VERSION_CURRENT]: {
|
||||
default: '',
|
||||
},
|
||||
[PrefKey.SCRIPT_LOCALE]: {
|
||||
[GlobalPref.SCRIPT_LOCALE]: {
|
||||
label: t('language'),
|
||||
default: localStorage.getItem(StorageKey.LOCALE) || 'en-US',
|
||||
options: SUPPORTED_LANGUAGES,
|
||||
},
|
||||
[PrefKey.SERVER_REGION]: {
|
||||
[GlobalPref.SERVER_REGION]: {
|
||||
label: t('region'),
|
||||
note: CE('a', { target: '_blank', href: 'https://umap.openstreetmap.fr/en/map/xbox-cloud-gaming-servers_1135022' }, t('server-locations')),
|
||||
default: 'default',
|
||||
},
|
||||
[PrefKey.SERVER_BYPASS_RESTRICTION]: {
|
||||
[GlobalPref.SERVER_BYPASS_RESTRICTION]: {
|
||||
label: t('bypass-region-restriction'),
|
||||
note: '⚠️ ' + t('use-this-at-your-own-risk'),
|
||||
default: 'off',
|
||||
@ -103,7 +101,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
}, BypassServers),
|
||||
},
|
||||
|
||||
[PrefKey.STREAM_PREFERRED_LOCALE]: {
|
||||
[GlobalPref.STREAM_PREFERRED_LOCALE]: {
|
||||
label: t('preferred-game-language'),
|
||||
default: 'default',
|
||||
options: {
|
||||
@ -140,7 +138,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
'zh-TW': '中文 (繁體)',
|
||||
},
|
||||
},
|
||||
[PrefKey.STREAM_RESOLUTION]: {
|
||||
[GlobalPref.STREAM_RESOLUTION]: {
|
||||
label: t('target-resolution'),
|
||||
default: 'auto',
|
||||
options: {
|
||||
@ -155,7 +153,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.STREAM_CODEC_PROFILE]: {
|
||||
[GlobalPref.STREAM_CODEC_PROFILE]: {
|
||||
label: t('visual-quality'),
|
||||
default: CodecProfile.DEFAULT,
|
||||
options: getSupportedCodecProfiles(),
|
||||
@ -174,26 +172,26 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
};
|
||||
},
|
||||
},
|
||||
[PrefKey.SERVER_PREFER_IPV6]: {
|
||||
[GlobalPref.SERVER_PREFER_IPV6]: {
|
||||
label: t('prefer-ipv6-server'),
|
||||
default: false,
|
||||
},
|
||||
|
||||
[PrefKey.SCREENSHOT_APPLY_FILTERS]: {
|
||||
[GlobalPref.SCREENSHOT_APPLY_FILTERS]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('screenshot-apply-filters'),
|
||||
default: false,
|
||||
},
|
||||
|
||||
[PrefKey.UI_SKIP_SPLASH_VIDEO]: {
|
||||
[GlobalPref.UI_SKIP_SPLASH_VIDEO]: {
|
||||
label: t('skip-splash-video'),
|
||||
default: false,
|
||||
},
|
||||
[PrefKey.UI_HIDE_SYSTEM_MENU_ICON]: {
|
||||
label: t('hide-system-menu-icon'),
|
||||
[GlobalPref.UI_HIDE_SYSTEM_MENU_ICON]: {
|
||||
label: '⣿ ' + t('hide-system-menu-icon'),
|
||||
default: false,
|
||||
},
|
||||
[PrefKey.UI_IMAGE_QUALITY]: {
|
||||
[GlobalPref.UI_IMAGE_QUALITY]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('image-quality'),
|
||||
default: 90,
|
||||
@ -213,7 +211,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.STREAM_COMBINE_SOURCES]: {
|
||||
[GlobalPref.STREAM_COMBINE_SOURCES]: {
|
||||
requiredVariants: 'full',
|
||||
|
||||
label: t('combine-audio-video-streams'),
|
||||
@ -222,28 +220,28 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
note: t('combine-audio-video-streams-summary'),
|
||||
},
|
||||
|
||||
[PrefKey.TOUCH_CONTROLLER_MODE]: {
|
||||
[GlobalPref.TOUCH_CONTROLLER_MODE]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('tc-availability'),
|
||||
label: t('availability'),
|
||||
default: TouchControllerMode.ALL,
|
||||
options: {
|
||||
[TouchControllerMode.DEFAULT]: t('default'),
|
||||
[TouchControllerMode.OFF]: t('off'),
|
||||
[TouchControllerMode.ALL]: t('tc-all-games'),
|
||||
[TouchControllerMode.ALL]: t('all-games'),
|
||||
},
|
||||
|
||||
unsupported: !STATES.userAgent.capabilities.touch,
|
||||
unsupportedValue: TouchControllerMode.DEFAULT,
|
||||
},
|
||||
[PrefKey.TOUCH_CONTROLLER_AUTO_OFF]: {
|
||||
[GlobalPref.TOUCH_CONTROLLER_AUTO_OFF]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('tc-auto-off'),
|
||||
default: false,
|
||||
unsupported: !STATES.userAgent.capabilities.touch,
|
||||
},
|
||||
[PrefKey.TOUCH_CONTROLLER_DEFAULT_OPACITY]: {
|
||||
[GlobalPref.TOUCH_CONTROLLER_DEFAULT_OPACITY]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('tc-default-opacity'),
|
||||
label: t('default-opacity'),
|
||||
default: 100,
|
||||
min: 10,
|
||||
max: 100,
|
||||
@ -255,7 +253,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
},
|
||||
unsupported: !STATES.userAgent.capabilities.touch,
|
||||
},
|
||||
[PrefKey.TOUCH_CONTROLLER_STYLE_STANDARD]: {
|
||||
[GlobalPref.TOUCH_CONTROLLER_STYLE_STANDARD]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('tc-standard-layout-style'),
|
||||
default: TouchControllerStyleStandard.DEFAULT,
|
||||
@ -266,7 +264,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
},
|
||||
unsupported: !STATES.userAgent.capabilities.touch,
|
||||
},
|
||||
[PrefKey.TOUCH_CONTROLLER_STYLE_CUSTOM]: {
|
||||
[GlobalPref.TOUCH_CONTROLLER_STYLE_CUSTOM]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('tc-custom-layout-style'),
|
||||
default: TouchControllerStyleCustom.DEFAULT,
|
||||
@ -277,22 +275,22 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
unsupported: !STATES.userAgent.capabilities.touch,
|
||||
},
|
||||
|
||||
[PrefKey.UI_SIMPLIFY_STREAM_MENU]: {
|
||||
[GlobalPref.UI_SIMPLIFY_STREAM_MENU]: {
|
||||
label: t('simplify-stream-menu'),
|
||||
default: false,
|
||||
},
|
||||
[PrefKey.MKB_HIDE_IDLE_CURSOR]: {
|
||||
[GlobalPref.MKB_HIDE_IDLE_CURSOR]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('hide-idle-cursor'),
|
||||
default: false,
|
||||
},
|
||||
[PrefKey.UI_DISABLE_FEEDBACK_DIALOG]: {
|
||||
[GlobalPref.UI_DISABLE_FEEDBACK_DIALOG]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('disable-post-stream-feedback-dialog'),
|
||||
default: false,
|
||||
},
|
||||
|
||||
[PrefKey.STREAM_MAX_VIDEO_BITRATE]: {
|
||||
[GlobalPref.STREAM_MAX_VIDEO_BITRATE]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('bitrate-video-maximum'),
|
||||
note: '⚠️ ' + t('unexpected-behavior'),
|
||||
@ -326,7 +324,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.GAME_BAR_POSITION]: {
|
||||
[GlobalPref.GAME_BAR_POSITION]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('position'),
|
||||
default: GameBarPosition.BOTTOM_LEFT,
|
||||
@ -337,74 +335,12 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.LOCAL_CO_OP_ENABLED]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('enable-local-co-op-support'),
|
||||
labelIcon: BxIcon.LOCAL_CO_OP,
|
||||
default: false,
|
||||
note: () => CE('div', false,
|
||||
CE('a', {
|
||||
href: 'https://github.com/redphx/better-xcloud/discussions/275',
|
||||
target: '_blank',
|
||||
}, t('enable-local-co-op-support-note')),
|
||||
CE('br'),
|
||||
'⚠️ ' + t('unexpected-behavior'),
|
||||
),
|
||||
},
|
||||
|
||||
[PrefKey.UI_CONTROLLER_SHOW_STATUS]: {
|
||||
[GlobalPref.UI_CONTROLLER_SHOW_STATUS]: {
|
||||
label: t('show-controller-connection-status'),
|
||||
default: true,
|
||||
},
|
||||
|
||||
[PrefKey.DEVICE_VIBRATION_MODE]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('device-vibration'),
|
||||
default: DeviceVibrationMode.OFF,
|
||||
options: {
|
||||
[DeviceVibrationMode.OFF]: t('off'),
|
||||
[DeviceVibrationMode.ON]: t('on'),
|
||||
[DeviceVibrationMode.AUTO]: t('device-vibration-not-using-gamepad'),
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.DEVICE_VIBRATION_INTENSITY]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('vibration-intensity'),
|
||||
default: 50,
|
||||
min: 10,
|
||||
max: 100,
|
||||
params: {
|
||||
steps: 10,
|
||||
suffix: '%',
|
||||
exactTicks: 20,
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.CONTROLLER_POLLING_RATE]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('polling-rate'),
|
||||
default: 4,
|
||||
min: 4,
|
||||
max: 60,
|
||||
params: {
|
||||
steps: 4,
|
||||
exactTicks: 20,
|
||||
reverse: true,
|
||||
customTextValue(value: any) {
|
||||
value = parseInt(value);
|
||||
|
||||
let text = +(1000 / value).toFixed(2) + ' Hz';
|
||||
if (value === 4) {
|
||||
text = `${text} (${t('default')})`;
|
||||
}
|
||||
|
||||
return text;
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.MKB_ENABLED]: {
|
||||
[GlobalPref.MKB_ENABLED]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('enable-mkb'),
|
||||
default: false,
|
||||
@ -427,7 +363,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.NATIVE_MKB_MODE]: {
|
||||
[GlobalPref.NATIVE_MKB_MODE]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('native-mkb'),
|
||||
default: NativeMkbMode.DEFAULT,
|
||||
@ -449,7 +385,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.NATIVE_MKB_FORCED_GAMES]: {
|
||||
[GlobalPref.NATIVE_MKB_FORCED_GAMES]: {
|
||||
label: t('force-native-mkb-games'),
|
||||
default: [],
|
||||
unsupported: !AppInterface && UserAgent.isMobile(),
|
||||
@ -467,98 +403,21 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('horizontal-scroll-sensitivity'),
|
||||
default: 0,
|
||||
min: 0,
|
||||
max: 100 * 100,
|
||||
params: {
|
||||
steps: 10,
|
||||
exactTicks: 20 * 100,
|
||||
customTextValue: (value: any) => {
|
||||
if (!value) {
|
||||
return t('default');
|
||||
}
|
||||
|
||||
return (value / 100).toFixed(1) + 'x';
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.NATIVE_MKB_SCROLL_VERTICAL_SENSITIVITY]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('vertical-scroll-sensitivity'),
|
||||
default: 0,
|
||||
min: 0,
|
||||
max: 100 * 100,
|
||||
params: {
|
||||
steps: 10,
|
||||
exactTicks: 20 * 100,
|
||||
customTextValue: (value: any) => {
|
||||
if (!value) {
|
||||
return t('default');
|
||||
}
|
||||
|
||||
return (value / 100).toFixed(1) + 'x';
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.MKB_P1_MAPPING_PRESET_ID]: {
|
||||
requiredVariants: 'full',
|
||||
default: MkbMappingDefaultPresetId.DEFAULT,
|
||||
},
|
||||
|
||||
[PrefKey.MKB_P1_SLOT]: {
|
||||
requiredVariants: 'full',
|
||||
default: 1,
|
||||
min: 1,
|
||||
max: 4,
|
||||
params: {
|
||||
hideSlider: true,
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.MKB_P2_MAPPING_PRESET_ID]: {
|
||||
requiredVariants: 'full',
|
||||
default: MkbMappingDefaultPresetId.OFF,
|
||||
},
|
||||
|
||||
[PrefKey.MKB_P2_SLOT]: {
|
||||
requiredVariants: 'full',
|
||||
default: 0,
|
||||
min: 0,
|
||||
max: 4,
|
||||
params: {
|
||||
hideSlider: true,
|
||||
customTextValue(value) {
|
||||
value = parseInt(value);
|
||||
return (value === 0) ? t('off') : value.toString();
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID]: {
|
||||
requiredVariants: 'full',
|
||||
default: KeyboardShortcutDefaultId.DEFAULT,
|
||||
},
|
||||
|
||||
[PrefKey.UI_REDUCE_ANIMATIONS]: {
|
||||
[GlobalPref.UI_REDUCE_ANIMATIONS]: {
|
||||
label: t('reduce-animations'),
|
||||
default: false,
|
||||
},
|
||||
|
||||
[PrefKey.LOADING_SCREEN_GAME_ART]: {
|
||||
[GlobalPref.LOADING_SCREEN_GAME_ART]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('show-game-art'),
|
||||
default: true,
|
||||
},
|
||||
[PrefKey.LOADING_SCREEN_SHOW_WAIT_TIME]: {
|
||||
[GlobalPref.LOADING_SCREEN_SHOW_WAIT_TIME]: {
|
||||
label: t('show-wait-time'),
|
||||
default: true,
|
||||
},
|
||||
[PrefKey.LOADING_SCREEN_ROCKET]: {
|
||||
[GlobalPref.LOADING_SCREEN_ROCKET]: {
|
||||
label: t('rocket-animation'),
|
||||
default: 'show',
|
||||
options: {
|
||||
@ -568,12 +427,12 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.UI_CONTROLLER_FRIENDLY]: {
|
||||
[GlobalPref.UI_CONTROLLER_FRIENDLY]: {
|
||||
label: t('controller-friendly-ui'),
|
||||
default: BX_FLAGS.DeviceInfo.deviceType !== 'unknown',
|
||||
},
|
||||
|
||||
[PrefKey.UI_LAYOUT]: {
|
||||
[GlobalPref.UI_LAYOUT]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('layout'),
|
||||
default: UiLayout.DEFAULT,
|
||||
@ -584,12 +443,12 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.UI_SCROLLBAR_HIDE]: {
|
||||
[GlobalPref.UI_SCROLLBAR_HIDE]: {
|
||||
label: t('hide-scrollbar'),
|
||||
default: false,
|
||||
},
|
||||
|
||||
[PrefKey.UI_HIDE_SECTIONS]: {
|
||||
[GlobalPref.UI_HIDE_SECTIONS]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('hide-sections'),
|
||||
default: [],
|
||||
@ -607,17 +466,17 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.UI_GAME_CARD_SHOW_WAIT_TIME]: {
|
||||
[GlobalPref.UI_GAME_CARD_SHOW_WAIT_TIME]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('show-wait-time-in-game-card'),
|
||||
default: true,
|
||||
},
|
||||
|
||||
[PrefKey.BLOCK_TRACKING]: {
|
||||
[GlobalPref.BLOCK_TRACKING]: {
|
||||
label: t('disable-xcloud-analytics'),
|
||||
default: false,
|
||||
},
|
||||
[PrefKey.BLOCK_FEATURES]: {
|
||||
[GlobalPref.BLOCK_FEATURES]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('disable-features'),
|
||||
default: [],
|
||||
@ -631,7 +490,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
},
|
||||
|
||||
|
||||
[PrefKey.USER_AGENT_PROFILE]: {
|
||||
[GlobalPref.USER_AGENT_PROFILE]: {
|
||||
label: t('user-agent-profile'),
|
||||
note: '⚠️ ' + t('unexpected-behavior'),
|
||||
default: (BX_FLAGS.DeviceInfo.deviceType === 'android-tv' || BX_FLAGS.DeviceInfo.deviceType === 'webos') ? UserAgentProfile.VR_OCULUS : 'default',
|
||||
@ -645,246 +504,24 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
[UserAgentProfile.CUSTOM]: t('custom'),
|
||||
},
|
||||
},
|
||||
[PrefKey.VIDEO_PLAYER_TYPE]: {
|
||||
label: t('renderer'),
|
||||
default: StreamPlayerType.VIDEO,
|
||||
options: {
|
||||
[StreamPlayerType.VIDEO]: t('default'),
|
||||
[StreamPlayerType.WEBGL2]: t('webgl2'),
|
||||
},
|
||||
suggest: {
|
||||
lowest: StreamPlayerType.VIDEO,
|
||||
highest: StreamPlayerType.WEBGL2,
|
||||
},
|
||||
},
|
||||
[PrefKey.VIDEO_PROCESSING]: {
|
||||
label: t('clarity-boost'),
|
||||
default: StreamVideoProcessing.USM,
|
||||
options: {
|
||||
[StreamVideoProcessing.USM]: t('unsharp-masking'),
|
||||
[StreamVideoProcessing.CAS]: t('amd-fidelity-cas'),
|
||||
},
|
||||
suggest: {
|
||||
lowest: StreamVideoProcessing.USM,
|
||||
highest: StreamVideoProcessing.CAS,
|
||||
},
|
||||
},
|
||||
[PrefKey.VIDEO_POWER_PREFERENCE]: {
|
||||
label: t('renderer-configuration'),
|
||||
default: VideoPowerPreference.DEFAULT,
|
||||
options: {
|
||||
[VideoPowerPreference.DEFAULT]: t('default'),
|
||||
[VideoPowerPreference.LOW_POWER]: t('battery-saving'),
|
||||
[VideoPowerPreference.HIGH_PERFORMANCE]: t('high-performance'),
|
||||
},
|
||||
suggest: {
|
||||
highest: 'low-power',
|
||||
},
|
||||
},
|
||||
[PrefKey.VIDEO_MAX_FPS]: {
|
||||
label: t('limit-fps'),
|
||||
default: 60,
|
||||
min: 10,
|
||||
max: 60,
|
||||
params: {
|
||||
steps: 10,
|
||||
exactTicks: 10,
|
||||
customTextValue: (value: any) => {
|
||||
value = parseInt(value);
|
||||
return value === 60 ? t('unlimited') : value + 'fps';
|
||||
},
|
||||
},
|
||||
},
|
||||
[PrefKey.VIDEO_SHARPNESS]: {
|
||||
label: t('sharpness'),
|
||||
default: 0,
|
||||
min: 0,
|
||||
max: 10,
|
||||
params: {
|
||||
exactTicks: 2,
|
||||
customTextValue: (value: any) => {
|
||||
value = parseInt(value);
|
||||
return value === 0 ? t('off') : value.toString();
|
||||
},
|
||||
},
|
||||
suggest: {
|
||||
lowest: 0,
|
||||
highest: 2,
|
||||
},
|
||||
},
|
||||
[PrefKey.VIDEO_RATIO]: {
|
||||
label: t('aspect-ratio'),
|
||||
note: STATES.browser.capabilities.touch ? t('aspect-ratio-note') : undefined,
|
||||
default: VideoRatio['16:9'],
|
||||
options: {
|
||||
[VideoRatio['16:9']]: `16:9 (${t('default')})`,
|
||||
[VideoRatio['18:9']]: '18:9',
|
||||
[VideoRatio['21:9']]: '21:9',
|
||||
[VideoRatio['16:10']]: '16:10',
|
||||
[VideoRatio['4:3']]: '4:3',
|
||||
|
||||
[VideoRatio.FILL]: t('stretch'),
|
||||
//'cover': 'Cover',
|
||||
},
|
||||
},
|
||||
[PrefKey.VIDEO_POSITION]: {
|
||||
label: t('position'),
|
||||
note: STATES.browser.capabilities.touch ? t('aspect-ratio-note') : undefined,
|
||||
default: VideoPosition.CENTER,
|
||||
options: {
|
||||
[VideoPosition.TOP]: t('top'),
|
||||
[VideoPosition.TOP_HALF]: t('top-half'),
|
||||
[VideoPosition.CENTER]: `${t('center')} (${t('default')})`,
|
||||
[VideoPosition.BOTTOM_HALF]: t('bottom-half'),
|
||||
[VideoPosition.BOTTOM]: t('bottom'),
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.VIDEO_SATURATION]: {
|
||||
label: t('saturation'),
|
||||
default: 100,
|
||||
min: 50,
|
||||
max: 150,
|
||||
params: {
|
||||
suffix: '%',
|
||||
ticks: 25,
|
||||
},
|
||||
},
|
||||
[PrefKey.VIDEO_CONTRAST]: {
|
||||
label: t('contrast'),
|
||||
default: 100,
|
||||
min: 50,
|
||||
max: 150,
|
||||
params: {
|
||||
suffix: '%',
|
||||
ticks: 25,
|
||||
},
|
||||
},
|
||||
[PrefKey.VIDEO_BRIGHTNESS]: {
|
||||
label: t('brightness'),
|
||||
default: 100,
|
||||
min: 50,
|
||||
max: 150,
|
||||
params: {
|
||||
suffix: '%',
|
||||
ticks: 25,
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.AUDIO_MIC_ON_PLAYING]: {
|
||||
[GlobalPref.AUDIO_MIC_ON_PLAYING]: {
|
||||
label: t('enable-mic-on-startup'),
|
||||
default: false,
|
||||
},
|
||||
[PrefKey.AUDIO_VOLUME_CONTROL_ENABLED]: {
|
||||
[GlobalPref.AUDIO_VOLUME_CONTROL_ENABLED]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('enable-volume-control'),
|
||||
default: false,
|
||||
},
|
||||
[PrefKey.AUDIO_VOLUME]: {
|
||||
label: t('volume'),
|
||||
default: 100,
|
||||
min: 0,
|
||||
max: 600,
|
||||
params: {
|
||||
steps: 10,
|
||||
suffix: '%',
|
||||
ticks: 100,
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.STATS_ITEMS]: {
|
||||
label: t('stats'),
|
||||
default: [StreamStat.PING, StreamStat.FPS, StreamStat.BITRATE, StreamStat.DECODE_TIME, StreamStat.PACKETS_LOST, StreamStat.FRAMES_LOST],
|
||||
multipleOptions: {
|
||||
[StreamStat.CLOCK]: t('clock'),
|
||||
[StreamStat.PLAYTIME]: t('playtime'),
|
||||
[StreamStat.BATTERY]: t('battery'),
|
||||
[StreamStat.PING]: t('stat-ping'),
|
||||
[StreamStat.JITTER]: t('jitter'),
|
||||
[StreamStat.FPS]: t('stat-fps'),
|
||||
[StreamStat.BITRATE]: t('stat-bitrate'),
|
||||
[StreamStat.DECODE_TIME]: t('stat-decode-time'),
|
||||
[StreamStat.PACKETS_LOST]: t('stat-packets-lost'),
|
||||
[StreamStat.FRAMES_LOST]: t('stat-frames-lost'),
|
||||
[StreamStat.DOWNLOAD]: t('downloaded'),
|
||||
[StreamStat.UPLOAD]: t('uploaded'),
|
||||
},
|
||||
params: {
|
||||
size: 0,
|
||||
},
|
||||
ready: setting => {
|
||||
// Remove Battery option in unsupported browser
|
||||
const multipleOptions = (setting as any).multipleOptions;
|
||||
if (!STATES.browser.capabilities.batteryApi) {
|
||||
delete multipleOptions[StreamStat.BATTERY];
|
||||
}
|
||||
|
||||
// Update texts
|
||||
for (const key in multipleOptions) {
|
||||
multipleOptions[key] = (key as string).toUpperCase() + ': ' + multipleOptions[key];
|
||||
}
|
||||
},
|
||||
},
|
||||
[PrefKey.STATS_SHOW_WHEN_PLAYING]: {
|
||||
label: t('show-stats-on-startup'),
|
||||
default: false,
|
||||
},
|
||||
[PrefKey.STATS_QUICK_GLANCE_ENABLED]: {
|
||||
label: '👀 ' + t('enable-quick-glance-mode'),
|
||||
default: true,
|
||||
},
|
||||
[PrefKey.STATS_POSITION]: {
|
||||
label: t('position'),
|
||||
default: StreamStatPosition.TOP_RIGHT,
|
||||
options: {
|
||||
[StreamStatPosition.TOP_LEFT]: t('top-left'),
|
||||
[StreamStatPosition.TOP_CENTER]: t('top-center'),
|
||||
[StreamStatPosition.TOP_RIGHT]: t('top-right'),
|
||||
},
|
||||
},
|
||||
[PrefKey.STATS_TEXT_SIZE]: {
|
||||
label: t('text-size'),
|
||||
default: '0.9rem',
|
||||
options: {
|
||||
'0.9rem': t('small'),
|
||||
'1.0rem': t('normal'),
|
||||
'1.1rem': t('large'),
|
||||
},
|
||||
},
|
||||
[PrefKey.STATS_OPACITY_ALL]: {
|
||||
label: t('opacity'),
|
||||
default: 80,
|
||||
min: 50,
|
||||
max: 100,
|
||||
params: {
|
||||
steps: 10,
|
||||
suffix: '%',
|
||||
ticks: 10,
|
||||
},
|
||||
},
|
||||
[PrefKey.STATS_OPACITY_BACKGROUND]: {
|
||||
label: t('background-opacity'),
|
||||
default: 100,
|
||||
min: 0,
|
||||
max: 100,
|
||||
params: {
|
||||
steps: 10,
|
||||
suffix: '%',
|
||||
ticks: 10,
|
||||
},
|
||||
},
|
||||
[PrefKey.STATS_CONDITIONAL_FORMATTING]: {
|
||||
label: t('conditional-formatting'),
|
||||
default: false,
|
||||
},
|
||||
|
||||
[PrefKey.REMOTE_PLAY_ENABLED]: {
|
||||
[GlobalPref.REMOTE_PLAY_ENABLED]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('enable-remote-play-feature'),
|
||||
labelIcon: BxIcon.REMOTE_PLAY,
|
||||
default: false,
|
||||
},
|
||||
|
||||
[PrefKey.REMOTE_PLAY_STREAM_RESOLUTION]: {
|
||||
[GlobalPref.REMOTE_PLAY_STREAM_RESOLUTION]: {
|
||||
requiredVariants: 'full',
|
||||
default: StreamResolution.DIM_1080P,
|
||||
options: {
|
||||
@ -894,22 +531,15 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
},
|
||||
},
|
||||
|
||||
[PrefKey.GAME_FORTNITE_FORCE_CONSOLE]: {
|
||||
[GlobalPref.GAME_FORTNITE_FORCE_CONSOLE]: {
|
||||
requiredVariants: 'full',
|
||||
label: '🎮 ' + t('fortnite-force-console-version'),
|
||||
default: false,
|
||||
note: t('fortnite-allow-stw-mode'),
|
||||
},
|
||||
} satisfies SettingDefinitions;
|
||||
};
|
||||
|
||||
constructor() {
|
||||
super(StorageKey.GLOBAL, GlobalSettingsStorage.DEFINITIONS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const globalSettings = new GlobalSettingsStorage();
|
||||
export const getPrefDefinition = globalSettings.getDefinition.bind(globalSettings);
|
||||
export const getPref = globalSettings.getSetting.bind(globalSettings);
|
||||
export const setPref = globalSettings.setSetting.bind(globalSettings);
|
||||
STORAGE.Global = globalSettings;
|
||||
|
465
src/utils/settings-storages/stream-settings-storage.ts
Normal file
465
src/utils/settings-storages/stream-settings-storage.ts
Normal file
@ -0,0 +1,465 @@
|
||||
import { StreamPref, StorageKey, type StreamPrefTypeMap, type PrefTypeMap } from "@/enums/pref-keys";
|
||||
import { DeviceVibrationMode, StreamPlayerType, StreamVideoProcessing, VideoPowerPreference, VideoRatio, VideoPosition, StreamStat, StreamStatPosition } from "@/enums/pref-values";
|
||||
import { STATES } from "../global";
|
||||
import { KeyboardShortcutDefaultId } from "../local-db/keyboard-shortcuts-table";
|
||||
import { MkbMappingDefaultPresetId } from "../local-db/mkb-mapping-presets-table";
|
||||
import { t } from "../translation";
|
||||
import { BaseSettingsStorage } from "./base-settings-storage";
|
||||
import { CE } from "../html";
|
||||
import type { SettingActionOrigin, SettingDefinition } from "@/types/setting-definition";
|
||||
import { BxIcon } from "../bx-icon";
|
||||
import { GameSettingsStorage } from "./game-settings-storage";
|
||||
import { BxLogger } from "../bx-logger";
|
||||
import { ControllerCustomizationDefaultPresetId } from "../local-db/controller-customizations-table";
|
||||
import { ControllerShortcutDefaultId } from "../local-db/controller-shortcuts-table";
|
||||
|
||||
|
||||
export class StreamSettingsStorage extends BaseSettingsStorage<StreamPref> {
|
||||
static readonly DEFINITIONS: Record<keyof StreamPrefTypeMap, SettingDefinition> = {
|
||||
[StreamPref.DEVICE_VIBRATION_MODE]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('device-vibration'),
|
||||
default: DeviceVibrationMode.OFF,
|
||||
options: {
|
||||
[DeviceVibrationMode.OFF]: t('off'),
|
||||
[DeviceVibrationMode.ON]: t('on'),
|
||||
[DeviceVibrationMode.AUTO]: t('device-vibration-not-using-gamepad'),
|
||||
},
|
||||
},
|
||||
|
||||
[StreamPref.DEVICE_VIBRATION_INTENSITY]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('vibration-intensity'),
|
||||
default: 50,
|
||||
min: 10,
|
||||
max: 100,
|
||||
params: {
|
||||
steps: 10,
|
||||
suffix: '%',
|
||||
exactTicks: 20,
|
||||
},
|
||||
},
|
||||
|
||||
[StreamPref.CONTROLLER_POLLING_RATE]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('polling-rate'),
|
||||
default: 4,
|
||||
min: 4,
|
||||
max: 60,
|
||||
params: {
|
||||
steps: 4,
|
||||
exactTicks: 20,
|
||||
reverse: true,
|
||||
customTextValue(value: any) {
|
||||
value = parseInt(value);
|
||||
|
||||
let text = +(1000 / value).toFixed(2) + ' Hz';
|
||||
if (value === 4) {
|
||||
text = `${text} (${t('default')})`;
|
||||
}
|
||||
|
||||
return text;
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
[StreamPref.CONTROLLER_SETTINGS]: {
|
||||
default: {},
|
||||
},
|
||||
|
||||
[StreamPref.NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('horizontal-scroll-sensitivity'),
|
||||
default: 0,
|
||||
min: 0,
|
||||
max: 100 * 100,
|
||||
params: {
|
||||
steps: 10,
|
||||
exactTicks: 20 * 100,
|
||||
customTextValue: (value: any) => {
|
||||
if (!value) {
|
||||
return t('default');
|
||||
}
|
||||
|
||||
return (value / 100).toFixed(1) + 'x';
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
[StreamPref.NATIVE_MKB_SCROLL_VERTICAL_SENSITIVITY]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('vertical-scroll-sensitivity'),
|
||||
default: 0,
|
||||
min: 0,
|
||||
max: 100 * 100,
|
||||
params: {
|
||||
steps: 10,
|
||||
exactTicks: 20 * 100,
|
||||
customTextValue: (value: any) => {
|
||||
if (!value) {
|
||||
return t('default');
|
||||
}
|
||||
|
||||
return (value / 100).toFixed(1) + 'x';
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
[StreamPref.MKB_P1_MAPPING_PRESET_ID]: {
|
||||
requiredVariants: 'full',
|
||||
default: MkbMappingDefaultPresetId.DEFAULT,
|
||||
},
|
||||
|
||||
[StreamPref.MKB_P1_SLOT]: {
|
||||
requiredVariants: 'full',
|
||||
default: 1,
|
||||
min: 1,
|
||||
max: 4,
|
||||
params: {
|
||||
hideSlider: true,
|
||||
},
|
||||
},
|
||||
|
||||
[StreamPref.MKB_P2_MAPPING_PRESET_ID]: {
|
||||
requiredVariants: 'full',
|
||||
default: MkbMappingDefaultPresetId.OFF,
|
||||
},
|
||||
|
||||
[StreamPref.MKB_P2_SLOT]: {
|
||||
requiredVariants: 'full',
|
||||
default: 0,
|
||||
min: 0,
|
||||
max: 4,
|
||||
params: {
|
||||
hideSlider: true,
|
||||
customTextValue(value) {
|
||||
value = parseInt(value);
|
||||
return (value === 0) ? t('off') : value.toString();
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
[StreamPref.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID]: {
|
||||
requiredVariants: 'full',
|
||||
default: KeyboardShortcutDefaultId.DEFAULT,
|
||||
},
|
||||
|
||||
[StreamPref.VIDEO_PLAYER_TYPE]: {
|
||||
label: t('renderer'),
|
||||
default: StreamPlayerType.VIDEO,
|
||||
options: {
|
||||
[StreamPlayerType.VIDEO]: t('default'),
|
||||
[StreamPlayerType.WEBGL2]: t('webgl2'),
|
||||
},
|
||||
suggest: {
|
||||
lowest: StreamPlayerType.VIDEO,
|
||||
highest: StreamPlayerType.WEBGL2,
|
||||
},
|
||||
},
|
||||
[StreamPref.VIDEO_PROCESSING]: {
|
||||
label: t('clarity-boost'),
|
||||
default: StreamVideoProcessing.USM,
|
||||
options: {
|
||||
[StreamVideoProcessing.USM]: t('unsharp-masking'),
|
||||
[StreamVideoProcessing.CAS]: t('amd-fidelity-cas'),
|
||||
},
|
||||
suggest: {
|
||||
lowest: StreamVideoProcessing.USM,
|
||||
highest: StreamVideoProcessing.CAS,
|
||||
},
|
||||
},
|
||||
[StreamPref.VIDEO_POWER_PREFERENCE]: {
|
||||
label: t('renderer-configuration'),
|
||||
default: VideoPowerPreference.DEFAULT,
|
||||
options: {
|
||||
[VideoPowerPreference.DEFAULT]: t('default'),
|
||||
[VideoPowerPreference.LOW_POWER]: t('battery-saving'),
|
||||
[VideoPowerPreference.HIGH_PERFORMANCE]: t('high-performance'),
|
||||
},
|
||||
suggest: {
|
||||
highest: 'low-power',
|
||||
},
|
||||
},
|
||||
[StreamPref.VIDEO_MAX_FPS]: {
|
||||
label: t('limit-fps'),
|
||||
default: 60,
|
||||
min: 10,
|
||||
max: 60,
|
||||
params: {
|
||||
steps: 10,
|
||||
exactTicks: 10,
|
||||
customTextValue: (value: any) => {
|
||||
value = parseInt(value);
|
||||
return value === 60 ? t('unlimited') : value + 'fps';
|
||||
},
|
||||
},
|
||||
},
|
||||
[StreamPref.VIDEO_SHARPNESS]: {
|
||||
label: t('sharpness'),
|
||||
default: 0,
|
||||
min: 0,
|
||||
max: 10,
|
||||
params: {
|
||||
exactTicks: 2,
|
||||
customTextValue: (value: any) => {
|
||||
value = parseInt(value);
|
||||
return value === 0 ? t('off') : value.toString();
|
||||
},
|
||||
},
|
||||
suggest: {
|
||||
lowest: 0,
|
||||
highest: 2,
|
||||
},
|
||||
},
|
||||
[StreamPref.VIDEO_RATIO]: {
|
||||
label: t('aspect-ratio'),
|
||||
note: STATES.browser.capabilities.touch ? t('aspect-ratio-note') : undefined,
|
||||
default: VideoRatio['16:9'],
|
||||
options: {
|
||||
[VideoRatio['16:9']]: `16:9 (${t('default')})`,
|
||||
[VideoRatio['18:9']]: '18:9',
|
||||
[VideoRatio['21:9']]: '21:9',
|
||||
[VideoRatio['16:10']]: '16:10',
|
||||
[VideoRatio['4:3']]: '4:3',
|
||||
|
||||
[VideoRatio.FILL]: t('stretch'),
|
||||
//'cover': 'Cover',
|
||||
},
|
||||
},
|
||||
[StreamPref.VIDEO_POSITION]: {
|
||||
label: t('position'),
|
||||
note: STATES.browser.capabilities.touch ? t('aspect-ratio-note') : undefined,
|
||||
default: VideoPosition.CENTER,
|
||||
options: {
|
||||
[VideoPosition.TOP]: t('top'),
|
||||
[VideoPosition.TOP_HALF]: t('top-half'),
|
||||
[VideoPosition.CENTER]: `${t('center')} (${t('default')})`,
|
||||
[VideoPosition.BOTTOM_HALF]: t('bottom-half'),
|
||||
[VideoPosition.BOTTOM]: t('bottom'),
|
||||
},
|
||||
},
|
||||
|
||||
[StreamPref.VIDEO_SATURATION]: {
|
||||
label: t('saturation'),
|
||||
default: 100,
|
||||
min: 50,
|
||||
max: 150,
|
||||
params: {
|
||||
suffix: '%',
|
||||
ticks: 25,
|
||||
},
|
||||
},
|
||||
[StreamPref.VIDEO_CONTRAST]: {
|
||||
label: t('contrast'),
|
||||
default: 100,
|
||||
min: 50,
|
||||
max: 150,
|
||||
params: {
|
||||
suffix: '%',
|
||||
ticks: 25,
|
||||
},
|
||||
},
|
||||
[StreamPref.VIDEO_BRIGHTNESS]: {
|
||||
label: t('brightness'),
|
||||
default: 100,
|
||||
min: 50,
|
||||
max: 150,
|
||||
params: {
|
||||
suffix: '%',
|
||||
ticks: 25,
|
||||
},
|
||||
},
|
||||
|
||||
[StreamPref.AUDIO_VOLUME]: {
|
||||
label: t('volume'),
|
||||
default: 100,
|
||||
min: 0,
|
||||
max: 600,
|
||||
params: {
|
||||
steps: 10,
|
||||
suffix: '%',
|
||||
ticks: 100,
|
||||
},
|
||||
},
|
||||
|
||||
[StreamPref.STATS_ITEMS]: {
|
||||
label: t('stats'),
|
||||
default: [StreamStat.PING, StreamStat.FPS, StreamStat.BITRATE, StreamStat.DECODE_TIME, StreamStat.PACKETS_LOST, StreamStat.FRAMES_LOST],
|
||||
multipleOptions: {
|
||||
[StreamStat.CLOCK]: t('clock'),
|
||||
[StreamStat.PLAYTIME]: t('playtime'),
|
||||
[StreamStat.BATTERY]: t('battery'),
|
||||
[StreamStat.PING]: t('stat-ping'),
|
||||
[StreamStat.JITTER]: t('jitter'),
|
||||
[StreamStat.FPS]: t('stat-fps'),
|
||||
[StreamStat.BITRATE]: t('stat-bitrate'),
|
||||
[StreamStat.DECODE_TIME]: t('stat-decode-time'),
|
||||
[StreamStat.PACKETS_LOST]: t('stat-packets-lost'),
|
||||
[StreamStat.FRAMES_LOST]: t('stat-frames-lost'),
|
||||
[StreamStat.DOWNLOAD]: t('downloaded'),
|
||||
[StreamStat.UPLOAD]: t('uploaded'),
|
||||
},
|
||||
params: {
|
||||
size: 0,
|
||||
},
|
||||
ready: setting => {
|
||||
// Remove Battery option in unsupported browser
|
||||
const multipleOptions = (setting as any).multipleOptions;
|
||||
if (!STATES.browser.capabilities.batteryApi) {
|
||||
delete multipleOptions[StreamStat.BATTERY];
|
||||
}
|
||||
|
||||
// Update texts
|
||||
for (const key in multipleOptions) {
|
||||
multipleOptions[key] = (key as string).toUpperCase() + ': ' + multipleOptions[key];
|
||||
}
|
||||
},
|
||||
},
|
||||
[StreamPref.STATS_SHOW_WHEN_PLAYING]: {
|
||||
label: t('show-stats-on-startup'),
|
||||
default: false,
|
||||
},
|
||||
[StreamPref.STATS_QUICK_GLANCE_ENABLED]: {
|
||||
label: '👀 ' + t('enable-quick-glance-mode'),
|
||||
default: true,
|
||||
},
|
||||
[StreamPref.STATS_POSITION]: {
|
||||
label: t('position'),
|
||||
default: StreamStatPosition.TOP_RIGHT,
|
||||
options: {
|
||||
[StreamStatPosition.TOP_LEFT]: t('top-left'),
|
||||
[StreamStatPosition.TOP_CENTER]: t('top-center'),
|
||||
[StreamStatPosition.TOP_RIGHT]: t('top-right'),
|
||||
},
|
||||
},
|
||||
[StreamPref.STATS_TEXT_SIZE]: {
|
||||
label: t('text-size'),
|
||||
default: '0.9rem',
|
||||
options: {
|
||||
'0.9rem': t('small'),
|
||||
'1.0rem': t('normal'),
|
||||
'1.1rem': t('large'),
|
||||
},
|
||||
},
|
||||
[StreamPref.STATS_OPACITY_ALL]: {
|
||||
label: t('opacity'),
|
||||
default: 80,
|
||||
min: 50,
|
||||
max: 100,
|
||||
params: {
|
||||
steps: 10,
|
||||
suffix: '%',
|
||||
ticks: 10,
|
||||
},
|
||||
},
|
||||
[StreamPref.STATS_OPACITY_BACKGROUND]: {
|
||||
label: t('background-opacity'),
|
||||
default: 100,
|
||||
min: 0,
|
||||
max: 100,
|
||||
params: {
|
||||
steps: 10,
|
||||
suffix: '%',
|
||||
ticks: 10,
|
||||
},
|
||||
},
|
||||
[StreamPref.STATS_CONDITIONAL_FORMATTING]: {
|
||||
label: t('conditional-formatting'),
|
||||
default: false,
|
||||
},
|
||||
|
||||
[StreamPref.LOCAL_CO_OP_ENABLED]: {
|
||||
requiredVariants: 'full',
|
||||
label: t('enable-local-co-op-support'),
|
||||
labelIcon: BxIcon.LOCAL_CO_OP,
|
||||
default: false,
|
||||
note: () => CE('div', false,
|
||||
CE('a', {
|
||||
href: 'https://github.com/redphx/better-xcloud/discussions/275',
|
||||
target: '_blank',
|
||||
}, t('enable-local-co-op-support-note')),
|
||||
CE('br'),
|
||||
'⚠️ ' + t('unexpected-behavior'),
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
private gameSettings: {[key: number]: GameSettingsStorage} = {};
|
||||
private xboxTitleId: number = -1;
|
||||
|
||||
constructor() {
|
||||
super(StorageKey.STREAM, StreamSettingsStorage.DEFINITIONS);
|
||||
}
|
||||
|
||||
setGameId(id: number) {
|
||||
this.xboxTitleId = id;
|
||||
}
|
||||
|
||||
getGameSettings(id: number) {
|
||||
if (id > -1) {
|
||||
if (!this.gameSettings[id]) {
|
||||
this.gameSettings[id] = new GameSettingsStorage(id);
|
||||
}
|
||||
|
||||
return this.gameSettings[id];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
getSetting<K extends keyof PrefTypeMap<K>>(key: K, checkUnsupported?: boolean): PrefTypeMap<K>[K] {
|
||||
return this.getSettingByGame(this.xboxTitleId, key, true, checkUnsupported)!;
|
||||
}
|
||||
|
||||
getSettingByGame<K extends keyof PrefTypeMap<K>>(id: number, key: K, returnBaseValue: boolean=true, checkUnsupported?: boolean): PrefTypeMap<K>[K] | undefined {
|
||||
const gameSettings = this.getGameSettings(id);
|
||||
if (gameSettings?.hasSetting(key)) {
|
||||
return gameSettings.getSetting(key, checkUnsupported);
|
||||
}
|
||||
|
||||
if (returnBaseValue) {
|
||||
return super.getSetting(key, checkUnsupported);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
setSetting<V = any>(key: StreamPref, value: V, origin: SettingActionOrigin): V {
|
||||
return this.setSettingByGame(this.xboxTitleId, key, value, origin);
|
||||
}
|
||||
|
||||
setSettingByGame<V = any>(id: number, key: StreamPref, value: V, origin: SettingActionOrigin): V {
|
||||
const gameSettings = this.getGameSettings(id);
|
||||
if (gameSettings) {
|
||||
BxLogger.info('setSettingByGame', id, key, value);
|
||||
return gameSettings.setSetting(key, value, origin);
|
||||
}
|
||||
|
||||
BxLogger.info('setSettingByGame', id, key, value);
|
||||
return super.setSetting(key, value, origin);
|
||||
}
|
||||
|
||||
hasGameSetting(id: number, key: StreamPref): boolean {
|
||||
const gameSettings = this.getGameSettings(id);
|
||||
return !!(gameSettings && gameSettings.hasSetting(key));
|
||||
}
|
||||
|
||||
getControllerSetting(gamepadId: string): ControllerSetting {
|
||||
const controllerSettings = this.getSetting(StreamPref.CONTROLLER_SETTINGS);
|
||||
let controllerSetting = controllerSettings[gamepadId];
|
||||
if (!controllerSetting) {
|
||||
controllerSetting = {} as ControllerSetting;
|
||||
}
|
||||
|
||||
// Set missing settings
|
||||
if (!controllerSetting.hasOwnProperty('shortcutPresetId')) {
|
||||
controllerSetting.shortcutPresetId = ControllerShortcutDefaultId.DEFAULT;
|
||||
}
|
||||
|
||||
if (!controllerSetting.hasOwnProperty('customizationPresetId')) {
|
||||
controllerSetting.customizationPresetId = ControllerCustomizationDefaultPresetId.DEFAULT;
|
||||
}
|
||||
|
||||
return controllerSetting;
|
||||
}
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
import { PrefKey, type PrefTypeMap } from "@/enums/pref-keys";
|
||||
import { ControllerSettingsTable } from "./local-db/controller-settings-table";
|
||||
import { GlobalPref, StreamPref } from "@/enums/pref-keys";
|
||||
import { ControllerShortcutsTable } from "./local-db/controller-shortcuts-table";
|
||||
import { getPref, setPref } from "./settings-storages/global-settings-storage";
|
||||
import type { ControllerCustomizationConvertedPresetData, ControllerCustomizationPresetData, ControllerShortcutPresetRecord, KeyboardShortcutConvertedPresetData, MkbConvertedPresetData } from "@/types/presets";
|
||||
import { STATES } from "./global";
|
||||
import { DeviceVibrationMode } from "@/enums/pref-values";
|
||||
@ -15,10 +13,11 @@ import { ShortcutAction } from "@/enums/shortcut-actions";
|
||||
import { KeyHelper } from "@/modules/mkb/key-helper";
|
||||
import { BxEventBus } from "./bx-event-bus";
|
||||
import { ControllerCustomizationsTable } from "./local-db/controller-customizations-table";
|
||||
import { getStreamPref, setStreamPref, STORAGE } from "@/utils/pref-utils";
|
||||
|
||||
|
||||
export type StreamSettingsData = {
|
||||
settings: PartialRecord<PrefKey, any>;
|
||||
settings: PartialRecord<GlobalPref, any>;
|
||||
xCloudPollingMode: 'none' | 'callbacks' | 'navigation' | 'all';
|
||||
|
||||
deviceVibrationIntensity: number;
|
||||
@ -51,15 +50,10 @@ export class StreamSettings {
|
||||
keyboardShortcuts: {},
|
||||
};
|
||||
|
||||
static getPref<T extends keyof PrefTypeMap>(key: T) {
|
||||
return getPref<T>(key);
|
||||
}
|
||||
|
||||
static async refreshControllerSettings() {
|
||||
const settings = StreamSettings.settings;
|
||||
const controllers: StreamSettingsData['controllers'] = {};
|
||||
|
||||
const settingsTable = ControllerSettingsTable.getInstance();
|
||||
const shortcutsTable = ControllerShortcutsTable.getInstance();
|
||||
const mappingTable = ControllerCustomizationsTable.getInstance();
|
||||
|
||||
@ -74,14 +68,14 @@ export class StreamSettings {
|
||||
continue;
|
||||
}
|
||||
|
||||
const settingsData = await settingsTable.getControllerData(gamepad.id);
|
||||
const controllerSetting = STORAGE.Stream.getControllerSetting(gamepad.id);
|
||||
|
||||
// Shortcuts
|
||||
const shortcutsPreset = await shortcutsTable.getPreset(settingsData.shortcutPresetId);
|
||||
const shortcutsPreset = await shortcutsTable.getPreset(controllerSetting.shortcutPresetId);
|
||||
const shortcutsMapping = !shortcutsPreset ? null : shortcutsPreset.data.mapping;
|
||||
|
||||
// Mapping
|
||||
const customizationPreset = await mappingTable.getPreset(settingsData.customizationPresetId);
|
||||
const customizationPreset = await mappingTable.getPreset(controllerSetting.customizationPresetId);
|
||||
const customizationData = StreamSettings.convertControllerCustomization(customizationPreset?.data);
|
||||
|
||||
controllers[gamepad.id] = {
|
||||
@ -92,7 +86,7 @@ export class StreamSettings {
|
||||
settings.controllers = controllers;
|
||||
|
||||
// Controller polling rate
|
||||
settings.controllerPollingRate = StreamSettings.getPref(PrefKey.CONTROLLER_POLLING_RATE);
|
||||
settings.controllerPollingRate = getStreamPref(StreamPref.CONTROLLER_POLLING_RATE);
|
||||
// Device vibration
|
||||
await StreamSettings.refreshDeviceVibration();
|
||||
}
|
||||
@ -150,23 +144,23 @@ export class StreamSettings {
|
||||
return;
|
||||
}
|
||||
|
||||
const mode = StreamSettings.getPref(PrefKey.DEVICE_VIBRATION_MODE);
|
||||
const mode = getStreamPref(StreamPref.DEVICE_VIBRATION_MODE);
|
||||
let intensity = 0; // Disable
|
||||
|
||||
// Enable when no controllers are detected in Auto mode
|
||||
if (mode === DeviceVibrationMode.ON || (mode === DeviceVibrationMode.AUTO && !hasGamepad())) {
|
||||
// Set intensity
|
||||
intensity = StreamSettings.getPref(PrefKey.DEVICE_VIBRATION_INTENSITY) / 100;
|
||||
intensity = getStreamPref(StreamPref.DEVICE_VIBRATION_INTENSITY) / 100;
|
||||
}
|
||||
|
||||
StreamSettings.settings.deviceVibrationIntensity = intensity;
|
||||
BxEventBus.Script.emit('deviceVibration.updated', {});
|
||||
BxEventBus.Stream.emit('deviceVibration.updated', {});
|
||||
}
|
||||
|
||||
static async refreshMkbSettings() {
|
||||
const settings = StreamSettings.settings;
|
||||
|
||||
let presetId = StreamSettings.getPref(PrefKey.MKB_P1_MAPPING_PRESET_ID);
|
||||
let presetId = getStreamPref(StreamPref.MKB_P1_MAPPING_PRESET_ID);
|
||||
const orgPreset = (await MkbMappingPresetsTable.getInstance().getPreset(presetId))!;
|
||||
const orgPresetData = orgPreset.data;
|
||||
|
||||
@ -197,19 +191,19 @@ export class StreamSettings {
|
||||
|
||||
settings.mkbPreset = converted;
|
||||
|
||||
setPref(PrefKey.MKB_P1_MAPPING_PRESET_ID, orgPreset.id);
|
||||
BxEventBus.Script.emit('mkb.setting.updated', {});
|
||||
setStreamPref(StreamPref.MKB_P1_MAPPING_PRESET_ID, orgPreset.id, 'direct');
|
||||
BxEventBus.Stream.emit('mkb.setting.updated', {});
|
||||
}
|
||||
|
||||
static async refreshKeyboardShortcuts() {
|
||||
const settings = StreamSettings.settings;
|
||||
|
||||
let presetId = StreamSettings.getPref(PrefKey.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID);
|
||||
let presetId = getStreamPref(StreamPref.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID);
|
||||
if (presetId === KeyboardShortcutDefaultId.OFF) {
|
||||
settings.keyboardShortcuts = null;
|
||||
|
||||
setPref(PrefKey.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID, presetId);
|
||||
BxEventBus.Script.emit('keyboardShortcuts.updated', {});
|
||||
setStreamPref(StreamPref.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID, presetId, 'direct');
|
||||
BxEventBus.Stream.emit('keyboardShortcuts.updated', {});
|
||||
return;
|
||||
}
|
||||
|
||||
@ -228,8 +222,8 @@ export class StreamSettings {
|
||||
|
||||
settings.keyboardShortcuts = converted;
|
||||
|
||||
setPref(PrefKey.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID, orgPreset.id);
|
||||
BxEventBus.Script.emit('keyboardShortcuts.updated', {});
|
||||
setStreamPref(StreamPref.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID, orgPreset.id, 'direct');
|
||||
BxEventBus.Stream.emit('keyboardShortcuts.updated', {});
|
||||
}
|
||||
|
||||
static async refreshAllSettings() {
|
||||
|
@ -1,12 +1,11 @@
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { StreamPref } from "@/enums/pref-keys";
|
||||
import { STATES } from "./global";
|
||||
import { humanFileSize, secondsToHm } from "./html";
|
||||
import { getPref } from "./settings-storages/global-settings-storage";
|
||||
import { BxLogger } from "./bx-logger";
|
||||
import { StreamStat } from "@/enums/pref-values";
|
||||
import { BxEventBus } from "./bx-event-bus";
|
||||
import { getStreamPref } from "@/utils/pref-utils";
|
||||
|
||||
export type StreamStatGrade = '' | 'bad' | 'ok' | 'good';
|
||||
|
||||
type CurrentStats = {
|
||||
[StreamStat.PING]: {
|
||||
@ -111,7 +110,7 @@ export class StreamStatsCollector {
|
||||
[StreamStat.FPS]: {
|
||||
current: 0,
|
||||
toString() {
|
||||
const maxFps = getPref(PrefKey.VIDEO_MAX_FPS);
|
||||
const maxFps = getStreamPref(StreamPref.VIDEO_MAX_FPS);
|
||||
return maxFps < 60 ? `${maxFps}/${this.current}`.padStart(5) : this.current.toString();
|
||||
},
|
||||
},
|
||||
|
@ -32,6 +32,7 @@ const Texts = {
|
||||
"activated": "Activated",
|
||||
"active": "Active",
|
||||
"advanced": "Advanced",
|
||||
"all-games": "All games",
|
||||
"always-off": "Always off",
|
||||
"always-on": "Always on",
|
||||
"amd-fidelity-cas": "AMD FidelityFX CAS",
|
||||
@ -41,6 +42,7 @@ const Texts = {
|
||||
"aspect-ratio-note": "Don't use with native touch games",
|
||||
"audio": "Audio",
|
||||
"auto": "Auto",
|
||||
"availability": "Availability",
|
||||
"back-to-home": "Back to home",
|
||||
"back-to-home-confirm": "Do you want to go back to the home page (without disconnecting)?",
|
||||
"background-opacity": "Background opacity",
|
||||
@ -99,6 +101,7 @@ const Texts = {
|
||||
"deadzone-counterweight": "Deadzone counterweight",
|
||||
"decrease": "Decrease",
|
||||
"default": "Default",
|
||||
"default-opacity": "Default opacity",
|
||||
"default-preset-note": "You can't modify default presets. Create a new one to customize it.",
|
||||
"delete": "Delete",
|
||||
"detect-controller-button": "Detect controller button",
|
||||
@ -288,6 +291,7 @@ const Texts = {
|
||||
"rename": "Rename",
|
||||
"renderer": "Renderer",
|
||||
"renderer-configuration": "Renderer configuration",
|
||||
"reset-highlighted-setting": "Reset highlighted setting",
|
||||
"right-click-to-unbind": "Right-click on a key to unbind it",
|
||||
"right-stick": "Right stick",
|
||||
"right-stick-deadzone": "Right stick deadzone",
|
||||
@ -311,6 +315,7 @@ const Texts = {
|
||||
"server": "Server",
|
||||
"server-locations": "Server locations",
|
||||
"settings": "Settings",
|
||||
"settings-for": "Settings for",
|
||||
"settings-reload": "Reload page to reflect changes",
|
||||
"settings-reload-note": "Settings in this tab only go into effect on the next page load",
|
||||
"settings-reloading": "Reloading...",
|
||||
@ -352,12 +357,9 @@ const Texts = {
|
||||
"swap-buttons": "Swap buttons",
|
||||
"take-screenshot": "Take screenshot",
|
||||
"target-resolution": "Target resolution",
|
||||
"tc-all-games": "All games",
|
||||
"tc-all-white": "All white",
|
||||
"tc-auto-off": "Off when controller found",
|
||||
"tc-availability": "Availability",
|
||||
"tc-custom-layout-style": "Custom layout's button style",
|
||||
"tc-default-opacity": "Default opacity",
|
||||
"tc-muted-colors": "Muted colors",
|
||||
"tc-standard-layout-style": "Standard layout's button style",
|
||||
"text-size": "Text size",
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { AppInterface, SCRIPT_VERSION } from "@utils/global";
|
||||
import { AppInterface, SCRIPT_VERSION, } from "@utils/global";
|
||||
import { UserAgent } from "@utils/user-agent";
|
||||
import { t, Translations } from "./translation";
|
||||
import { Toast } from "./toast";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref, setPref } from "./settings-storages/global-settings-storage";
|
||||
import { GlobalPref } from "@/enums/pref-keys";
|
||||
import { LocalDb } from "./local-db/local-db";
|
||||
import { BlockFeature } from "@/enums/pref-values";
|
||||
import { getGlobalPref, setGlobalPref } from "@/utils/pref-utils";
|
||||
|
||||
/**
|
||||
* Check for update
|
||||
@ -18,8 +18,8 @@ export function checkForUpdate() {
|
||||
|
||||
const CHECK_INTERVAL_SECONDS = 2 * 3600; // check every 2 hours
|
||||
|
||||
const currentVersion = getPref(PrefKey.VERSION_CURRENT);
|
||||
const lastCheck = getPref(PrefKey.VERSION_LAST_CHECK);
|
||||
const currentVersion = getGlobalPref(GlobalPref.VERSION_CURRENT);
|
||||
const lastCheck = getGlobalPref(GlobalPref.VERSION_LAST_CHECK);
|
||||
const now = Math.round((+new Date) / 1000);
|
||||
|
||||
if (currentVersion === SCRIPT_VERSION && now - lastCheck < CHECK_INTERVAL_SECONDS) {
|
||||
@ -27,13 +27,13 @@ export function checkForUpdate() {
|
||||
}
|
||||
|
||||
// Start checking
|
||||
setPref(PrefKey.VERSION_LAST_CHECK, now);
|
||||
setGlobalPref(GlobalPref.VERSION_LAST_CHECK, now, 'direct');
|
||||
fetch('https://api.github.com/repos/redphx/better-xcloud/releases/latest')
|
||||
.then(response => response.json())
|
||||
.then(json => {
|
||||
// Store the latest version
|
||||
setPref(PrefKey.VERSION_LATEST, json.tag_name.substring(1));
|
||||
setPref(PrefKey.VERSION_CURRENT, SCRIPT_VERSION);
|
||||
setGlobalPref(GlobalPref.VERSION_LATEST, json.tag_name.substring(1), 'direct');
|
||||
setGlobalPref(GlobalPref.VERSION_CURRENT, SCRIPT_VERSION, 'direct');
|
||||
});
|
||||
|
||||
// Update translations
|
||||
@ -155,13 +155,13 @@ export function clearAllData() {
|
||||
}
|
||||
|
||||
export function blockAllNotifications() {
|
||||
const blockFeatures = getPref(PrefKey.BLOCK_FEATURES);
|
||||
const blockFeatures = getGlobalPref(GlobalPref.BLOCK_FEATURES);
|
||||
const blockAll = [BlockFeature.FRIENDS, BlockFeature.NOTIFICATIONS_ACHIEVEMENTS, BlockFeature.NOTIFICATIONS_INVITES].every(value => blockFeatures.includes(value));
|
||||
return blockAll;
|
||||
}
|
||||
|
||||
export function blockSomeNotifications() {
|
||||
const blockFeatures = getPref(PrefKey.BLOCK_FEATURES);
|
||||
const blockFeatures = getGlobalPref(GlobalPref.BLOCK_FEATURES);
|
||||
if (blockAllNotifications()) {
|
||||
return false;
|
||||
}
|
||||
@ -169,3 +169,11 @@ export function blockSomeNotifications() {
|
||||
const blockSome = [BlockFeature.FRIENDS, BlockFeature.NOTIFICATIONS_ACHIEVEMENTS, BlockFeature.NOTIFICATIONS_INVITES].some(value => blockFeatures.includes(value));
|
||||
return blockSome;
|
||||
}
|
||||
|
||||
export function isPlainObject(input: any) {
|
||||
return (
|
||||
typeof input === 'object' &&
|
||||
input !== null &&
|
||||
input.constructor === Object
|
||||
);
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ import { STATES } from "./global";
|
||||
import { generateMsDeviceInfo, getOsNameFromResolution, patchIceCandidates } from "./network";
|
||||
import { getPreferredServerRegion } from "./region";
|
||||
import { BypassServerIps } from "@/enums/bypass-servers";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "./settings-storages/global-settings-storage";
|
||||
import { GlobalPref } from "@/enums/pref-keys";
|
||||
import { NativeMkbMode, TouchControllerMode } from "@/enums/pref-values";
|
||||
import { BxEventBus } from "./bx-event-bus";
|
||||
import { getGlobalPref } from "./pref-utils";
|
||||
|
||||
export class XcloudInterceptor {
|
||||
private static readonly SERVER_EXTRA_INFO: Record<string, [string, ServerContinent]> = {
|
||||
@ -43,7 +43,7 @@ export class XcloudInterceptor {
|
||||
};
|
||||
|
||||
private static async handleLogin(request: RequestInfo | URL, init?: RequestInit) {
|
||||
const bypassServer = getPref(PrefKey.SERVER_BYPASS_RESTRICTION);
|
||||
const bypassServer = getGlobalPref(GlobalPref.SERVER_BYPASS_RESTRICTION);
|
||||
if (bypassServer !== 'off') {
|
||||
const ip = BypassServerIps[bypassServer as keyof typeof BypassServerIps];
|
||||
ip && (request as Request).headers.set('X-Forwarded-For', ip);
|
||||
@ -112,8 +112,8 @@ export class XcloudInterceptor {
|
||||
private static async handlePlay(request: RequestInfo | URL, init?: RequestInit) {
|
||||
BxEventBus.Stream.emit('state.loading', {});
|
||||
|
||||
const PREF_STREAM_TARGET_RESOLUTION = getPref(PrefKey.STREAM_RESOLUTION);
|
||||
const PREF_STREAM_PREFERRED_LOCALE = getPref(PrefKey.STREAM_PREFERRED_LOCALE);
|
||||
const PREF_STREAM_TARGET_RESOLUTION = getGlobalPref(GlobalPref.STREAM_RESOLUTION);
|
||||
const PREF_STREAM_PREFERRED_LOCALE = getGlobalPref(GlobalPref.STREAM_PREFERRED_LOCALE);
|
||||
|
||||
const url = (typeof request === 'string') ? request : (request as Request).url;
|
||||
const parsedUrl = new URL(url);
|
||||
@ -159,7 +159,7 @@ export class XcloudInterceptor {
|
||||
private static async handleWaitTime(request: RequestInfo | URL, init?: RequestInit) {
|
||||
const response = await NATIVE_FETCH(request, init);
|
||||
|
||||
if (getPref(PrefKey.LOADING_SCREEN_SHOW_WAIT_TIME)) {
|
||||
if (getGlobalPref(GlobalPref.LOADING_SCREEN_SHOW_WAIT_TIME)) {
|
||||
const json = await response.clone().json();
|
||||
if (json.estimatedAllocationTimeInSeconds > 0) {
|
||||
// Setup wait time overlay
|
||||
@ -176,7 +176,7 @@ export class XcloudInterceptor {
|
||||
}
|
||||
|
||||
// Touch controller for all games
|
||||
if (isFullVersion() && getPref(PrefKey.TOUCH_CONTROLLER_MODE) === TouchControllerMode.ALL) {
|
||||
if (isFullVersion() && getGlobalPref(GlobalPref.TOUCH_CONTROLLER_MODE) === TouchControllerMode.ALL) {
|
||||
const titleInfo = STATES.currentStream.titleInfo;
|
||||
if (titleInfo?.details.hasTouchSupport) {
|
||||
TouchController.disable();
|
||||
@ -202,11 +202,11 @@ export class XcloudInterceptor {
|
||||
|
||||
let overrideMkb: boolean | null = null;
|
||||
|
||||
if (getPref(PrefKey.NATIVE_MKB_MODE) === NativeMkbMode.ON || (STATES.currentStream.titleInfo && BX_FLAGS.ForceNativeMkbTitles?.includes(STATES.currentStream.titleInfo.details.productId))) {
|
||||
if (getGlobalPref(GlobalPref.NATIVE_MKB_MODE) === NativeMkbMode.ON || (STATES.currentStream.titleInfo && BX_FLAGS.ForceNativeMkbTitles?.includes(STATES.currentStream.titleInfo.details.productId))) {
|
||||
overrideMkb = true;
|
||||
}
|
||||
|
||||
if (getPref(PrefKey.NATIVE_MKB_MODE) === NativeMkbMode.OFF) {
|
||||
if (getGlobalPref(GlobalPref.NATIVE_MKB_MODE) === NativeMkbMode.OFF) {
|
||||
overrideMkb = false;
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ export class XcloudInterceptor {
|
||||
}
|
||||
|
||||
// Enable mic
|
||||
if (getPref(PrefKey.AUDIO_MIC_ON_PLAYING)) {
|
||||
if (getGlobalPref(GlobalPref.AUDIO_MIC_ON_PLAYING)) {
|
||||
overrides.audioConfiguration = overrides.audioConfiguration || {};
|
||||
overrides.audioConfiguration.enableMicrophone = true;
|
||||
}
|
||||
|
@ -4,12 +4,11 @@ import { SupportedInputType } from "./bx-exposed";
|
||||
import { NATIVE_FETCH } from "./bx-flags";
|
||||
import { STATES } from "./global";
|
||||
import { generateMsDeviceInfo, getOsNameFromResolution, patchIceCandidates } from "./network";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "./settings-storages/global-settings-storage";
|
||||
import type { RemotePlayConsoleAddresses } from "@/types/network";
|
||||
import { GlobalPref } from "@/enums/pref-keys";
|
||||
import { RemotePlayManager } from "@/modules/remote-play-manager";
|
||||
import { TouchControllerMode } from "@/enums/pref-values";
|
||||
import { BxEventBus } from "./bx-event-bus";
|
||||
import { getGlobalPref } from "./pref-utils";
|
||||
|
||||
export class XhomeInterceptor {
|
||||
private static consoleAddrs: RemotePlayConsoleAddresses = {};
|
||||
@ -71,7 +70,7 @@ export class XhomeInterceptor {
|
||||
private static async handleInputConfigs(request: Request | URL, opts: { [index: string]: any }) {
|
||||
const response = await NATIVE_FETCH(request);
|
||||
|
||||
if (getPref(PrefKey.TOUCH_CONTROLLER_MODE) !== TouchControllerMode.ALL) {
|
||||
if (getGlobalPref(GlobalPref.TOUCH_CONTROLLER_MODE) !== TouchControllerMode.ALL) {
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -152,7 +151,7 @@ export class XhomeInterceptor {
|
||||
headers.authorization = `Bearer ${RemotePlayManager.getInstance()!.getXhomeToken()}`;
|
||||
|
||||
// Patch resolution
|
||||
const osName = getOsNameFromResolution(getPref(PrefKey.REMOTE_PLAY_STREAM_RESOLUTION));
|
||||
const osName = getOsNameFromResolution(getGlobalPref(GlobalPref.REMOTE_PLAY_STREAM_RESOLUTION));
|
||||
headers['x-ms-device-info'] = JSON.stringify(generateMsDeviceInfo(osName));
|
||||
|
||||
const opts: Record<string, any> = {
|
||||
|
@ -156,6 +156,15 @@ export class BxNumberStepper extends HTMLInputElement implements BxHtmlSettingEl
|
||||
set(value) { BxNumberStepper.setValue.call(self, value); },
|
||||
});
|
||||
|
||||
Object.defineProperty(self, 'disabled', {
|
||||
get() { return $range.disabled; },
|
||||
set(value) {
|
||||
$btnDec.disabled = value;
|
||||
$btnInc.disabled = value;
|
||||
$range.disabled = value;
|
||||
},
|
||||
});
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { GlobalPref } from "@/enums/pref-keys";
|
||||
import type { NavigationElement } from "@/modules/ui/dialog/navigation-dialog";
|
||||
import { BxEvent } from "@/utils/bx-event";
|
||||
import { setNearby } from "@/utils/navigation-utils";
|
||||
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { getGlobalPref } from "@/utils/pref-utils";
|
||||
import { ButtonStyle, CE, clearDataSet, createButton } from "@utils/html";
|
||||
|
||||
export class BxSelectElement extends HTMLSelectElement {
|
||||
@ -20,7 +20,7 @@ export class BxSelectElement extends HTMLSelectElement {
|
||||
private $checkBox!: HTMLInputElement;
|
||||
|
||||
static create($select: HTMLSelectElement, forceFriendly=false): BxSelectElement {
|
||||
const isControllerFriendly = forceFriendly || getPref(PrefKey.UI_CONTROLLER_FRIENDLY);
|
||||
const isControllerFriendly = forceFriendly || getGlobalPref(GlobalPref.UI_CONTROLLER_FRIENDLY);
|
||||
|
||||
// Return normal <select> if it's non-controller friendly <select multiple>
|
||||
if ($select.multiple && !isControllerFriendly) {
|
||||
@ -281,8 +281,8 @@ export class BxSelectElement extends HTMLSelectElement {
|
||||
|
||||
// Disable buttons when there is only one option or fewer
|
||||
const disableButtons = optionsList.length <= 1;
|
||||
$btnPrev?.classList.toggle('bx-inactive', disableButtons);
|
||||
$btnNext?.classList.toggle('bx-inactive', disableButtons);
|
||||
$btnPrev?.classList.toggle('bx-gone', disableButtons);
|
||||
$btnNext?.classList.toggle('bx-gone', disableButtons);
|
||||
|
||||
// Update indicators
|
||||
for (let i = 0; i < optionsList.length; i++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user