Fix forcing native MKB not working when mode = "default"

This commit is contained in:
redphx 2024-12-07 07:46:13 +07:00
parent fe98a1165f
commit 1ca2b771e7
7 changed files with 26 additions and 13 deletions

View File

@ -1514,6 +1514,9 @@ class GlobalSettingsStorage extends BaseSettingsStore {
if (!setting.unsupported) setting.multipleOptions = GhPagesUtils.getNativeMkbCustomList(!0), window.addEventListener(BxEvent.GH_PAGES_FORCE_NATIVE_MKB_UPDATED, (e) => { if (!setting.unsupported) setting.multipleOptions = GhPagesUtils.getNativeMkbCustomList(!0), window.addEventListener(BxEvent.GH_PAGES_FORCE_NATIVE_MKB_UPDATED, (e) => {
setting.multipleOptions = GhPagesUtils.getNativeMkbCustomList(); setting.multipleOptions = GhPagesUtils.getNativeMkbCustomList();
}); });
},
params: {
size: 6
} }
}, },
"nativeMkb.scroll.sensitivityX": { "nativeMkb.scroll.sensitivityX": {
@ -3741,7 +3744,7 @@ class SettingElement {
let $control = CE("select", { let $control = CE("select", {
multiple: !0, multiple: !0,
tabindex: 0 tabindex: 0
}), size = params.size ? params.size : Object.keys(setting.multipleOptions).length; }), totalOptions = Object.keys(setting.multipleOptions).length, size = params.size ? Math.min(params.size, totalOptions) : totalOptions;
$control.setAttribute("size", size.toString()); $control.setAttribute("size", size.toString());
for (let value in setting.multipleOptions) { for (let value in setting.multipleOptions) {
let label = setting.multipleOptions[value], $option = CE("option", { value }, label); let label = setting.multipleOptions[value], $option = CE("option", { value }, label);
@ -4078,7 +4081,8 @@ class SettingsDialog extends NavigationDialog {
"nativeMkb.mode", "nativeMkb.mode",
{ {
pref: "nativeMkb.forcedGames", pref: "nativeMkb.forcedGames",
multiLines: !0 multiLines: !0,
note: CE("a", { href: "https://github.com/redphx/better-xcloud/discussions/574", target: "_blank" }, t("unofficial-game-list"))
}, },
"mkb.enabled", "mkb.enabled",
"mkb.cursor.hideIdle" "mkb.cursor.hideIdle"
@ -6445,7 +6449,7 @@ window.addEventListener("pagehide", (e) => {
BxEvent.dispatch(window, BxEvent.STREAM_STOPPED); BxEvent.dispatch(window, BxEvent.STREAM_STOPPED);
}); });
function main() { function main() {
if (GhPagesUtils.fetchLatestCommit(), getPref("nativeMkb.mode") === "on") { if (GhPagesUtils.fetchLatestCommit(), getPref("nativeMkb.mode") !== "off") {
let customList = getPref("nativeMkb.forcedGames"); let customList = getPref("nativeMkb.forcedGames");
BX_FLAGS.ForceNativeMkbTitles.push(...customList); BX_FLAGS.ForceNativeMkbTitles.push(...customList);
} }

View File

@ -1589,6 +1589,9 @@ class GlobalSettingsStorage extends BaseSettingsStore {
if (!setting.unsupported) setting.multipleOptions = GhPagesUtils.getNativeMkbCustomList(!0), window.addEventListener(BxEvent.GH_PAGES_FORCE_NATIVE_MKB_UPDATED, (e) => { if (!setting.unsupported) setting.multipleOptions = GhPagesUtils.getNativeMkbCustomList(!0), window.addEventListener(BxEvent.GH_PAGES_FORCE_NATIVE_MKB_UPDATED, (e) => {
setting.multipleOptions = GhPagesUtils.getNativeMkbCustomList(); setting.multipleOptions = GhPagesUtils.getNativeMkbCustomList();
}); });
},
params: {
size: 6
} }
}, },
"nativeMkb.scroll.sensitivityX": { "nativeMkb.scroll.sensitivityX": {
@ -4871,7 +4874,7 @@ class SettingElement {
let $control = CE("select", { let $control = CE("select", {
multiple: !0, multiple: !0,
tabindex: 0 tabindex: 0
}), size = params.size ? params.size : Object.keys(setting.multipleOptions).length; }), totalOptions = Object.keys(setting.multipleOptions).length, size = params.size ? Math.min(params.size, totalOptions) : totalOptions;
$control.setAttribute("size", size.toString()); $control.setAttribute("size", size.toString());
for (let value in setting.multipleOptions) { for (let value in setting.multipleOptions) {
let label = setting.multipleOptions[value], $option = CE("option", { value }, label); let label = setting.multipleOptions[value], $option = CE("option", { value }, label);
@ -5928,7 +5931,8 @@ class SettingsDialog extends NavigationDialog {
"nativeMkb.mode", "nativeMkb.mode",
{ {
pref: "nativeMkb.forcedGames", pref: "nativeMkb.forcedGames",
multiLines: !0 multiLines: !0,
note: CE("a", { href: "https://github.com/redphx/better-xcloud/discussions/574", target: "_blank" }, t("unofficial-game-list"))
}, },
"mkb.enabled", "mkb.enabled",
"mkb.cursor.hideIdle" "mkb.cursor.hideIdle"
@ -9303,7 +9307,7 @@ window.addEventListener(BxEvent.CAPTURE_SCREENSHOT, (e) => {
ScreenshotManager.getInstance().takeScreenshot(); ScreenshotManager.getInstance().takeScreenshot();
}); });
function main() { function main() {
if (GhPagesUtils.fetchLatestCommit(), getPref("nativeMkb.mode") === "on") { if (GhPagesUtils.fetchLatestCommit(), getPref("nativeMkb.mode") !== "off") {
let customList = getPref("nativeMkb.forcedGames"); let customList = getPref("nativeMkb.forcedGames");
BX_FLAGS.ForceNativeMkbTitles.push(...customList); BX_FLAGS.ForceNativeMkbTitles.push(...customList);
} }

View File

@ -47,7 +47,7 @@ export const enum PrefKey {
CONTROLLER_POLLING_RATE = 'controller.pollingRate', CONTROLLER_POLLING_RATE = 'controller.pollingRate',
NATIVE_MKB_MODE = 'nativeMkb.mode', NATIVE_MKB_MODE = 'nativeMkb.mode',
FORCE_NATIVE_MKB_GAMES = 'nativeMkb.forcedGames', NATIVE_MKB_FORCED_GAMES = 'nativeMkb.forcedGames',
NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY = 'nativeMkb.scroll.sensitivityX', NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY = 'nativeMkb.scroll.sensitivityX',
NATIVE_MKB_SCROLL_VERTICAL_SENSITIVITY = 'nativeMkb.scroll.sensitivityY', NATIVE_MKB_SCROLL_VERTICAL_SENSITIVITY = 'nativeMkb.scroll.sensitivityY',

View File

@ -353,8 +353,8 @@ isFullVersion() && window.addEventListener(BxEvent.CAPTURE_SCREENSHOT, e => {
function main() { function main() {
GhPagesUtils.fetchLatestCommit(); GhPagesUtils.fetchLatestCommit();
if (getPref<NativeMkbMode>(PrefKey.NATIVE_MKB_MODE) === NativeMkbMode.ON) { if (getPref<NativeMkbMode>(PrefKey.NATIVE_MKB_MODE) !== NativeMkbMode.OFF) {
const customList = getPref<string[]>(PrefKey.FORCE_NATIVE_MKB_GAMES); const customList = getPref<string[]>(PrefKey.NATIVE_MKB_FORCED_GAMES);
BX_FLAGS.ForceNativeMkbTitles.push(...customList); BX_FLAGS.ForceNativeMkbTitles.push(...customList);
} }

View File

@ -231,8 +231,9 @@ export class SettingsDialog extends NavigationDialog {
items: [ items: [
PrefKey.NATIVE_MKB_MODE, PrefKey.NATIVE_MKB_MODE,
{ {
pref: PrefKey.FORCE_NATIVE_MKB_GAMES, pref: PrefKey.NATIVE_MKB_FORCED_GAMES,
multiLines: true, 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_ENABLED,

View File

@ -68,10 +68,11 @@ export class SettingElement {
tabindex: 0, tabindex: 0,
}); });
const size = params.size ? params.size : Object.keys(setting.multipleOptions!).length; const totalOptions = Object.keys(setting.multipleOptions!).length;
const size = params.size ? Math.min(params.size, totalOptions) : totalOptions;
$control.setAttribute('size', size.toString()); $control.setAttribute('size', size.toString());
for (let value in setting.multipleOptions) { for (const value in setting.multipleOptions) {
const label = setting.multipleOptions[value]; const label = setting.multipleOptions[value];
const $option = CE<HTMLOptionElement>('option', {value: value}, label) as HTMLOptionElement; const $option = CE<HTMLOptionElement>('option', {value: value}, label) as HTMLOptionElement;

View File

@ -424,7 +424,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
}, },
[PrefKey.FORCE_NATIVE_MKB_GAMES]: { [PrefKey.NATIVE_MKB_FORCED_GAMES]: {
label: t('force-native-mkb-games'), label: t('force-native-mkb-games'),
default: [], default: [],
unsupported: !AppInterface && UserAgent.isMobile(), unsupported: !AppInterface && UserAgent.isMobile(),
@ -437,6 +437,9 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}); });
} }
}, },
params: {
size: 6,
},
}, },
[PrefKey.NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY]: { [PrefKey.NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY]: {