diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-09-17 23:47:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-17 23:47:59 +0800 |
commit | 364caae9b6e47b8d5e1bab950aebc5b35bc4baad (patch) | |
tree | e554b5859e0135b8f644986768306d5f3ee5683e /src/features/settings/settingsCommunicator.js | |
parent | eb8bc77bf2d790e97fe793eb96ad77e1b4d2bbbf (diff) | |
parent | 12f3a81cf12c6ffc24a7f2a0e8102dfba3fddf82 (diff) | |
download | SoopyV2-364caae9b6e47b8d5e1bab950aebc5b35bc4baad.tar.gz SoopyV2-364caae9b6e47b8d5e1bab950aebc5b35bc4baad.tar.bz2 SoopyV2-364caae9b6e47b8d5e1bab950aebc5b35bc4baad.zip |
Merge pull request #71 from Soopyboo32/Babel
Diffstat (limited to 'src/features/settings/settingsCommunicator.js')
-rw-r--r-- | src/features/settings/settingsCommunicator.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/features/settings/settingsCommunicator.js b/src/features/settings/settingsCommunicator.js new file mode 100644 index 0000000..053a7c1 --- /dev/null +++ b/src/features/settings/settingsCommunicator.js @@ -0,0 +1,35 @@ +//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] || []) + } +} + +if(!global.soopyv2SettingsCommunicator){ + global.soopyv2SettingsCommunicator = new SettingsCommunicator() + + register("gameUnload", ()=>{ + global.soopyv2SettingsCommunicator = undefined + }) +} + +export default global.soopyv2SettingsCommunicator
\ No newline at end of file |