diff options
Diffstat (limited to 'features/settings/settingsCommunicator.js')
-rw-r--r-- | features/settings/settingsCommunicator.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/features/settings/settingsCommunicator.js b/features/settings/settingsCommunicator.js new file mode 100644 index 0000000..b54b1c1 --- /dev/null +++ b/features/settings/settingsCommunicator.js @@ -0,0 +1,29 @@ +//So features can add settings by adding to this class, then the gui will load data from this class +//this makes it so i can add settings before the settings gui is loaded +//and so that settings gui can still be dynamicly reloaded and not break things + +class SettingsCommunicator { + constructor(){ + this.settings = {} + } + + addSetting(module, settingID, settingObject){ + if(!this.settings[module]) this.settings[module] = {} + + this.settings[module][settingID] = settingObject + } + removeSetting(module, settingID){ + if(!this.settings[module]) return; + delete this.settings[module][settingID] + } + getSetting(module, settingID){ + return this.settings[module][settingID] + } + getModuleSettings(module){ + return Object.values(this.settings[module] || []) + } +} + +const settingsCommunicator = new SettingsCommunicator() + +export default settingsCommunicator
\ No newline at end of file |