this repo has no description
1import { SettingsSection, Settings as SettingsType } from "@moonlight-mod/types/coreExtensions/settings"; 2 3export const Settings: SettingsType = { 4 ourSections: [], 5 sectionNames: [], 6 sectionMenuItems: {}, 7 8 addSection: (section, label, element, color = null, pos, notice) => { 9 const data: SettingsSection = { 10 section, 11 label, 12 color, 13 element, 14 pos: pos ?? -4, 15 notice: notice 16 }; 17 18 Settings.ourSections.push(data); 19 Settings.sectionNames.push(section); 20 return data; 21 }, 22 addSectionMenuItems(section, ...newItems) { 23 const data = Settings.ourSections.find((x) => x.section === section); 24 if (!data || !("element" in data)) throw new Error(`Could not find section "${section}"`); 25 (Settings.sectionMenuItems[section] ??= []).push(...newItems); 26 data._moonlight_submenu ??= () => Settings.sectionMenuItems[section]; 27 }, 28 29 addDivider: (pos = null) => { 30 Settings.ourSections.push({ 31 section: "DIVIDER", 32 pos: pos === null ? -4 : pos 33 }); 34 }, 35 36 addHeader: function (label, pos = null) { 37 Settings.ourSections.push({ 38 section: "HEADER", 39 label: label, 40 pos: pos === null ? -4 : pos 41 }); 42 }, 43 44 _mutateSections: (sections) => { 45 for (const section of Settings.ourSections) { 46 sections.splice(section.pos < 0 ? sections.length + section.pos : section.pos, 0, section); 47 } 48 49 return sections; 50 } 51}; 52 53export default Settings;