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