diff --git a/src/modules/ui/dialog/settings-dialog.ts b/src/modules/ui/dialog/settings-dialog.ts index db32e9c..d934593 100644 --- a/src/modules/ui/dialog/settings-dialog.ts +++ b/src/modules/ui/dialog/settings-dialog.ts @@ -37,6 +37,7 @@ type SettingTabContentItem = Partial<{ content: HTMLElement | (() => HTMLElement); options: {[key: string]: string}; unsupported: boolean; + unsupportedNote: string; onChange: (e: any, value: number) => void; onCreated: (setting: SettingTabContentItem, $control: any) => void; params: any; @@ -46,8 +47,8 @@ type SettingTabContentItem = Partial<{ type SettingTabContent = { group: 'general' | 'server' | 'stream' | 'game-bar' | 'co-op' | 'mkb' | 'touch-control' | 'loading-screen' | 'ui' | 'other' | 'advanced' | 'footer' | 'audio' | 'video' | 'controller' | 'native-mkb' | 'stats' | 'controller-shortcuts'; label?: string; - note?: string | Text | null; unsupported?: boolean; + unsupportedNote?: string | Text | null; helpUrl?: string; content?: any; items?: Array void) | false>; @@ -220,7 +221,7 @@ export class SettingsNavigationDialog extends NavigationDialog { requiredVariants: 'full', group: 'mkb', label: t('mouse-and-keyboard'), - note: !STATES.userAgent.capabilities.mkb ? CE('a', { + unsupportedNote: !STATES.userAgent.capabilities.mkb ? CE('a', { href: 'https://github.com/redphx/better-xcloud/issues/206#issuecomment-1920475657', target: '_blank', }, '⚠️ ' + t('browser-unsupported-feature')) : null, @@ -235,8 +236,8 @@ export class SettingsNavigationDialog extends NavigationDialog { requiredVariants: 'full', group: 'touch-control', label: t('touch-controller'), - note: !STATES.userAgent.capabilities.touch ? '⚠️ ' + t('device-unsupported-touch') : null, unsupported: !STATES.userAgent.capabilities.touch, + unsupportedNote: !STATES.userAgent.capabilities.touch ? '⚠️ ' + t('device-unsupported-touch') : null, items: [ PrefKey.STREAM_TOUCH_CONTROLLER, PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF, @@ -1138,6 +1139,7 @@ export class SettingsNavigationDialog extends NavigationDialog { let label = prefDefinition?.label || setting.label; let note = prefDefinition?.note || setting.note; + let unsupportedNote = prefDefinition?.unsupportedNote || setting.unsupportedNote; const experimental = prefDefinition?.experimental || setting.experimental; if (settingTabContent.label && setting.pref) { @@ -1157,6 +1159,13 @@ export class SettingsNavigationDialog extends NavigationDialog { } } + let $note; + if (unsupportedNote) { + $note = CE('div', {class: 'bx-settings-dialog-note'}, unsupportedNote); + } else if (note) { + $note = CE('div', {class: 'bx-settings-dialog-note'}, note); + } + let $label; const $row = CE('label', { @@ -1169,7 +1178,7 @@ export class SettingsNavigationDialog extends NavigationDialog { }, $label = CE('span', {class: 'bx-settings-label'}, label, - note ? CE('div', {class: 'bx-settings-dialog-note'}, note) : prefDefinition?.unsupported && CE('div', {class: 'bx-settings-dialog-note'}, t('browser-unsupported-feature')), + $note, ), !prefDefinition?.unsupported && $control, ); @@ -1340,8 +1349,8 @@ export class SettingsNavigationDialog extends NavigationDialog { } // Add note - if (settingTabContent.note) { - const $note = CE('b', {class: 'bx-note-unsupported'}, settingTabContent.note); + if (settingTabContent.unsupportedNote) { + const $note = CE('b', {class: 'bx-note-unsupported'}, settingTabContent.unsupportedNote); $tabContent.appendChild($note); } diff --git a/src/types/preferences.d.ts b/src/types/preferences.d.ts index 5a710b4..104c30b 100644 --- a/src/types/preferences.d.ts +++ b/src/types/preferences.d.ts @@ -3,7 +3,8 @@ export type PreferenceSetting = { optionsGroup?: string; options?: {[index: string]: string}; multipleOptions?: {[index: string]: string}; - unsupported?: string | boolean; + unsupported?: boolean; + unsupported_note?: string | HTMLElement; note?: string | HTMLElement; type?: SettingElementType; ready?: (setting: PreferenceSetting) => void; diff --git a/src/types/setting-definition.d.ts b/src/types/setting-definition.d.ts index c6cf57c..eb4bb58 100644 --- a/src/types/setting-definition.d.ts +++ b/src/types/setting-definition.d.ts @@ -20,7 +20,8 @@ export type SettingDefinition = { label: string; note: string | HTMLElement; experimental: boolean; - unsupported: string | boolean; + unsupported: boolean; + unsupportedNote: string | HTMLElement; suggest: PartialRecord, ready: (setting: SettingDefinition) => void; type: SettingElementType, diff --git a/src/utils/settings-storages/global-settings-storage.ts b/src/utils/settings-storages/global-settings-storage.ts index bd05ecc..1d1c508 100644 --- a/src/utils/settings-storages/global-settings-storage.ts +++ b/src/utils/settings-storages/global-settings-storage.ts @@ -182,7 +182,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage { if (keys.length <= 1) { // Unsupported setting.unsupported = true; - setting.note = '⚠️ ' + t('browser-unsupported-feature'); + setting.unsupportedNote = '⚠️ ' + t('browser-unsupported-feature'); } setting.suggest = { @@ -405,7 +405,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage { url = 'https://better-xcloud.github.io/mouse-and-keyboard/#disclaimer'; } - setting.note = CE('a', { + setting.unsupportedNote = CE('a', { href: url, target: '_blank', }, '⚠️ ' + note);