diff options
Diffstat (limited to 'features/settings/settingThings/settingBase.js')
-rw-r--r-- | features/settings/settingThings/settingBase.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/features/settings/settingThings/settingBase.js b/features/settings/settingThings/settingBase.js index 55dacc3..8093179 100644 --- a/features/settings/settingThings/settingBase.js +++ b/features/settings/settingThings/settingBase.js @@ -1,8 +1,12 @@ import SoopyContentChangeEvent from "../../../../guimanager/EventListener/SoopyContentChangeEvent"; +import SoopyMouseClickEvent from "../../../../guimanager/EventListener/SoopyMouseClickEvent"; +import BoxWithText from "../../../../guimanager/GuiElement/BoxWithText"; import BoxWithTextAndDescription from "../../../../guimanager/GuiElement/BoxWithTextAndDescription" import SoopyGuiElement from "../../../../guimanager/GuiElement/SoopyGuiElement"; import renderLibs from "../../../../guimanager/renderLibs"; +import helpDataLoader from "../helpDataLoader"; import settingsCommunicator from "../settingsCommunicator"; +import SoopyMarkdownElement from "../../../../guimanager/GuiElement/SoopyMarkdownElement"; class SettingBase { constructor(name, description, defaultVal, settingId, module){ @@ -21,6 +25,17 @@ class SettingBase { this.guiObject.addChild(this.settingObject) + this.helpButton = new BoxWithText().setText("ยง0?").setLocation(3, 3, 0.05, 0.5) + this.helpButton.location.location.setRelative(false, false) + + this.helpButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ + module.FeatureManager.features.soopyGui.class.openSidebarPage(new SoopyGuiElement().setLocation(0.05,0.05,0.9,0.9).setScrollable(true).addChild(new SoopyMarkdownElement().setLocation(0,0,1,1).setText("Loading..."))) + + this.getHelp(helpText=>{ + module.FeatureManager.features.soopyGui.class.openSidebarPage(new SoopyGuiElement().setLocation(0.05,0.05,0.9,0.9).setScrollable(true).addChild(new SoopyMarkdownElement().setLocation(0,0,1,1).setText(helpText))) + }) + })) + settingsCommunicator.addSetting(this.moduleId, settingId, this) if(!module.FeatureManager.featureSettingsData[this.moduleId]){ @@ -46,6 +61,20 @@ class SettingBase { this.initTime = Date.now() } + update(){ + if(this.hasHelp()){ + this.guiObject.addChild(this.helpButton) + } + } + + hasHelp(){ + return helpDataLoader.hasData(this.moduleId, this.settingId) + } + + getHelp(callback){ + helpDataLoader.getData(this.moduleId, this.settingId, callback) + } + getValue(){ return this.val; } |