diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-04-02 16:48:34 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-04-02 16:48:34 +0800 |
commit | 76eb246b585318f1fd93b0492d6fdcb7b27be3ea (patch) | |
tree | e0623dfcd0c24f4280cca117c2355dc6ee99d2df | |
parent | 3151ad980883a1969500a93a4f4504ac19e4c9a8 (diff) | |
download | SoopyV2-76eb246b585318f1fd93b0492d6fdcb7b27be3ea.tar.gz SoopyV2-76eb246b585318f1fd93b0492d6fdcb7b27be3ea.tar.bz2 SoopyV2-76eb246b585318f1fd93b0492d6fdcb7b27be3ea.zip |
add searching to settings menu
-rw-r--r-- | features/settings/index.js | 60 | ||||
-rw-r--r-- | features/settings/settingThings/settingBase.js | 2 | ||||
-rw-r--r-- | index.js | 6 |
3 files changed, 58 insertions, 10 deletions
diff --git a/features/settings/index.js b/features/settings/index.js index 701da01..77309f5 100644 --- a/features/settings/index.js +++ b/features/settings/index.js @@ -14,6 +14,7 @@ import SoopyOpenGuiEvent from "../../../guimanager/EventListener/SoopyOpenGuiEve import settingsCommunicator from "./settingsCommunicator"; import GuiPage from "../soopyGui/GuiPage" import { SoopyRenderEvent } from "../../../guimanager"; +import TextBox from "../../../guimanager/GuiElement/TextBox"; class SettingsRenderer extends Feature { @@ -109,10 +110,16 @@ class SettingPage extends GuiPage { //############################################################################################### - - let settingsCategoryTitle = new SoopyTextElement().setText("§0Settings").setMaxTextScale(3).setLocation(0.1, 0.05, 0.8, 0.1) + let settingsCategoryTitle = new SoopyTextElement().setText("§0Settings").setMaxTextScale(3).setLocation(0.1, 0.05, 0.5, 0.1) this.pages[0].addChild(settingsCategoryTitle) + this.settingsCategorySearch = new TextBox().setPlaceholder("Search...").setLocation(0.6, 0.05, 0.3, 0.1) + this.pages[0].addChild(this.settingsCategorySearch) + + this.settingsCategorySearch.text.addEvent(new SoopyContentChangeEvent().setHandler(()=>{ + this.updateSettingCategories() + })) + this.settingsCategoryArea = new SoopyGuiElement().setLocation(0.1, 0.2, 0.8, 0.8).setScrollable(true) this.pages[0].addChild(this.settingsCategoryArea) @@ -139,26 +146,63 @@ class SettingPage extends GuiPage { } updateSettingCategories(){ + + let search = this.settingsCategorySearch.text.text + this.settingsCategoryArea.children = [] - let i = 0 + let height = 0 Object.keys(this.FeatureManager.featureMetas).sort((a, b)=>{return a.sortA-b.sortA}).forEach((f)=>{ + let meta = this.FeatureManager.featureMetas[f] + let showing = search.length === 0 + + if(!showing){ + showing = meta.name.toLowerCase().includes(search.toLowerCase()) || meta.description.toLowerCase().includes(search.toLowerCase()) + } + + if(!showing){ + settingsCommunicator.getModuleSettings(f).forEach(setting=>{ + + if(setting && (setting.name.toLowerCase().includes(search.toLowerCase()) || setting.description.toLowerCase().includes(search.toLowerCase()))){ + showing = true + } + }) + } + + if(!showing) return + let isHidden = meta.isHidden if(typeof isHidden === "string"){ isHidden = require("../" + f + "/" + isHidden).hidden(this.FeatureManager) } if(isHidden) return - let category = new ButtonWithArrowAndDescription().setText("&0" + meta.name).setDesc("&0" +meta.description).setLocation(0, 0.225*i, 1, 0.2) + let category = new ButtonWithArrowAndDescription().setText("&0" + meta.name).setDesc("&0" +meta.description).setLocation(0, height, 1, 0.2) category.addEvent(new SoopyMouseClickEvent().setHandler(()=>{this.clickedOpenCategory(f)})) this.settingsCategoryArea.addChild(category) - i++ + height+=0.225 + + + if(search.length > 0){ + settingsCommunicator.getModuleSettings(f).forEach(setting=>{ + + if(setting && (setting.name.toLowerCase().includes(search.toLowerCase()) || setting.description.toLowerCase().includes(search.toLowerCase()))){ + + setting.getGuiObject().location.location.y.set(height, 0) + this.settingsCategoryArea.addChild(setting.getGuiObject()) + + height += 0.045+setting.getGuiObject().location.size.y.get() + } + }) + } }) + + // this.FeatureManager.features = {}; enabled features } @@ -219,10 +263,10 @@ class SettingPage extends GuiPage { } settingsCommunicator.getModuleSettings(category).forEach(setting=>{ - setting.location.location.y.set(height, 0) - this.settingsArea.addChild(setting) + setting.getGuiObject().location.location.y.set(height, 0) + this.settingsArea.addChild(setting.getGuiObject()) - height += 0.045+setting.location.size.y.get() + height += 0.045+setting.getGuiObject().location.size.y.get() }) } diff --git a/features/settings/settingThings/settingBase.js b/features/settings/settingThings/settingBase.js index 02cfd9f..55dacc3 100644 --- a/features/settings/settingThings/settingBase.js +++ b/features/settings/settingThings/settingBase.js @@ -21,7 +21,7 @@ class SettingBase { this.guiObject.addChild(this.settingObject) - settingsCommunicator.addSetting(this.moduleId, settingId, this.getGuiObject()) + settingsCommunicator.addSetting(this.moduleId, settingId, this) if(!module.FeatureManager.featureSettingsData[this.moduleId]){ module.FeatureManager.featureSettingsData[this.moduleId] = {} @@ -29,6 +29,10 @@ if(FileLib.read("soopyAddonsData", "deletesoopyv1please.txt") === "true"){ ChatLib.command("ct reload", true) }).start() }else{ - new SoopyAddons() + let a = register("worldLoad", ()=>{ + new SoopyAddons() + ChatLib.chat("Loading soopyv2") + a.unregister() + }) } }
\ No newline at end of file |