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

@@ -47,7 +47,7 @@ export const enum PrefKey {
CONTROLLER_POLLING_RATE = 'controller.pollingRate',
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_VERTICAL_SENSITIVITY = 'nativeMkb.scroll.sensitivityY',

View File

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

View File

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

View File

@@ -68,10 +68,11 @@ export class SettingElement {
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());
for (let value in setting.multipleOptions) {
for (const value in setting.multipleOptions) {
const label = setting.multipleOptions[value];
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'),
default: [],
unsupported: !AppInterface && UserAgent.isMobile(),
@@ -437,6 +437,9 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
});
}
},
params: {
size: 6,
},
},
[PrefKey.NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY]: {