mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 23:57:19 +02:00
Refactor SettingDefinition
This commit is contained in:
parent
3f66c1298e
commit
7dfe61f4ca
@ -215,7 +215,6 @@ export class StreamUiHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('StreamUI', 'observing');
|
|
||||||
const observer = new MutationObserver(mutationList => {
|
const observer = new MutationObserver(mutationList => {
|
||||||
mutationList.forEach(item => {
|
mutationList.forEach(item => {
|
||||||
if (item.type !== 'childList') {
|
if (item.type !== 'childList') {
|
||||||
|
51
src/types/setting-definition.d.ts
vendored
51
src/types/setting-definition.d.ts
vendored
@ -1,19 +1,42 @@
|
|||||||
export type SettingDefinition = {
|
export type SettingDefinition = {
|
||||||
default: any;
|
default: any;
|
||||||
optionsGroup?: string;
|
} & Partial<{
|
||||||
options?: {[index: string]: string};
|
label: string;
|
||||||
multipleOptions?: {[index: string]: string};
|
note: string | HTMLElement;
|
||||||
unsupported?: string | boolean;
|
experimental: boolean;
|
||||||
note?: string | HTMLElement;
|
unsupported: string | boolean;
|
||||||
type?: SettingElementType;
|
ready: (setting: SettingDefinition) => void;
|
||||||
ready?: (setting: SettingDefinition) => void;
|
|
||||||
// migrate?: (this: Preferences, savedPrefs: any, value: any) => void;
|
// migrate?: (this: Preferences, savedPrefs: any, value: any) => void;
|
||||||
min?: number;
|
}> & (
|
||||||
max?: number;
|
{} | {
|
||||||
steps?: number;
|
options: {[index: string]: string};
|
||||||
experimental?: boolean;
|
optionsGroup?: string;
|
||||||
params?: any;
|
} | {
|
||||||
label?: string;
|
multipleOptions: {[index: string]: string};
|
||||||
};
|
params: MultipleOptionsParams;
|
||||||
|
} | {
|
||||||
|
type: SettingElementType.NUMBER_STEPPER;
|
||||||
|
min: number;
|
||||||
|
max: number;
|
||||||
|
params: NumberStepperParams;
|
||||||
|
|
||||||
|
steps?: number;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
export type SettingDefinitions = {[index in PrefKey]: SettingDefinition};
|
export type SettingDefinitions = {[index in PrefKey]: SettingDefinition};
|
||||||
|
|
||||||
|
export type MultipleOptionsParams = Partial<{
|
||||||
|
size?: number;
|
||||||
|
}>
|
||||||
|
|
||||||
|
export type NumberStepperParams = Partial<{
|
||||||
|
suffix: string;
|
||||||
|
disabled: boolean;
|
||||||
|
hideSlider: boolean;
|
||||||
|
|
||||||
|
ticks: number;
|
||||||
|
exactTicks: number;
|
||||||
|
|
||||||
|
customTextValue: (value: any) => string | null;
|
||||||
|
}>
|
||||||
|
@ -3,21 +3,7 @@ import { CE } from "@utils/html";
|
|||||||
import { setNearby } from "./navigation-utils";
|
import { setNearby } from "./navigation-utils";
|
||||||
import type { PrefKey } from "@/enums/pref-keys";
|
import type { PrefKey } from "@/enums/pref-keys";
|
||||||
import type { BaseSettingsStore } from "./settings-storages/base-settings-storage";
|
import type { BaseSettingsStore } from "./settings-storages/base-settings-storage";
|
||||||
|
import { type MultipleOptionsParams, type NumberStepperParams } from "@/types/setting-definition";
|
||||||
type MultipleOptionsParams = {
|
|
||||||
size?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
type NumberStepperParams = {
|
|
||||||
suffix?: string;
|
|
||||||
disabled?: boolean;
|
|
||||||
hideSlider?: boolean;
|
|
||||||
|
|
||||||
ticks?: number;
|
|
||||||
exactTicks?: number;
|
|
||||||
|
|
||||||
customTextValue?: (value: any) => string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum SettingElementType {
|
export enum SettingElementType {
|
||||||
OPTIONS = 'options',
|
OPTIONS = 'options',
|
||||||
@ -381,7 +367,11 @@ export class SettingElement {
|
|||||||
type = SettingElementType.CHECKBOX;
|
type = SettingElementType.CHECKBOX;
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = Object.assign(overrideParams, definition.params || {});
|
let params: any = {};
|
||||||
|
if ('params' in definition) {
|
||||||
|
params = Object.assign(overrideParams, definition.params || {});
|
||||||
|
}
|
||||||
|
|
||||||
if (params.disabled) {
|
if (params.disabled) {
|
||||||
currentValue = definition.default;
|
currentValue = definition.default;
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,14 @@ import { UiSection } from "@/enums/ui-sections";
|
|||||||
import { UserAgentProfile } from "@/enums/user-agent";
|
import { UserAgentProfile } from "@/enums/user-agent";
|
||||||
import { StreamStat } from "@/modules/stream/stream-stats";
|
import { StreamStat } from "@/modules/stream/stream-stats";
|
||||||
import type { PreferenceSetting } from "@/types/preferences";
|
import type { PreferenceSetting } from "@/types/preferences";
|
||||||
import type { SettingDefinitions } from "@/types/setting-definition";
|
import { type SettingDefinitions } from "@/types/setting-definition";
|
||||||
import { BX_FLAGS } from "../bx-flags";
|
import { BX_FLAGS } from "../bx-flags";
|
||||||
import { STATES, AppInterface, STORAGE } from "../global";
|
import { STATES, AppInterface, STORAGE } from "../global";
|
||||||
import { CE } from "../html";
|
import { CE } from "../html";
|
||||||
import { SettingElementType } from "../setting-element";
|
|
||||||
import { t, SUPPORTED_LANGUAGES } from "../translation";
|
import { t, SUPPORTED_LANGUAGES } from "../translation";
|
||||||
import { UserAgent } from "../user-agent";
|
import { UserAgent } from "../user-agent";
|
||||||
import { BaseSettingsStore as BaseSettingsStorage } from "./base-settings-storage";
|
import { BaseSettingsStore as BaseSettingsStorage } from "./base-settings-storage";
|
||||||
|
import { SettingElementType } from "../setting-element";
|
||||||
|
|
||||||
|
|
||||||
function getSupportedCodecProfiles() {
|
function getSupportedCodecProfiles() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user