aboutsummaryrefslogtreecommitdiff
path: root/features/settings
diff options
context:
space:
mode:
authorSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-04-02 16:48:34 +0800
committerSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-04-02 16:48:34 +0800
commit76eb246b585318f1fd93b0492d6fdcb7b27be3ea (patch)
treee0623dfcd0c24f4280cca117c2355dc6ee99d2df /features/settings
parent3151ad980883a1969500a93a4f4504ac19e4c9a8 (diff)
downloadSoopyV2-76eb246b585318f1fd93b0492d6fdcb7b27be3ea.tar.gz
SoopyV2-76eb246b585318f1fd93b0492d6fdcb7b27be3ea.tar.bz2
SoopyV2-76eb246b585318f1fd93b0492d6fdcb7b27be3ea.zip
add searching to settings menu
Diffstat (limited to 'features/settings')
-rw-r--r--features/settings/index.js60
-rw-r--r--features/settings/settingThings/settingBase.js2
2 files changed, 53 insertions, 9 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] = {}