aboutsummaryrefslogtreecommitdiff
path: root/features/soopyGui
diff options
context:
space:
mode:
authorSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-02-04 16:10:29 +0800
committerSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-02-04 16:10:29 +0800
commit7882632751f1132e67dcee92389e82317b8db123 (patch)
tree833899d85393b046304ffb2f5db50e52ddddd005 /features/soopyGui
parentf724d7e9f5ec6d5e2f004a240f5117a41a752dc8 (diff)
downloadSoopyV2-7882632751f1132e67dcee92389e82317b8db123.tar.gz
SoopyV2-7882632751f1132e67dcee92389e82317b8db123.tar.bz2
SoopyV2-7882632751f1132e67dcee92389e82317b8db123.zip
maby fix buttons like settings not showing up in /soopyv2 menu
Diffstat (limited to 'features/soopyGui')
-rw-r--r--features/soopyGui/GuiPage.js13
-rw-r--r--features/soopyGui/categoryManager.js37
-rw-r--r--features/soopyGui/index.js34
3 files changed, 48 insertions, 36 deletions
diff --git a/features/soopyGui/GuiPage.js b/features/soopyGui/GuiPage.js
index 1ae10fe..812c831 100644
--- a/features/soopyGui/GuiPage.js
+++ b/features/soopyGui/GuiPage.js
@@ -1,4 +1,5 @@
import SoopyGuiElement from '../../../guimanager/GuiElement/SoopyGuiElement.js';
+import categoryManager from './categoryManager.js';
class GuiPage{
constructor(priority){
@@ -12,10 +13,6 @@ class GuiPage{
}
this.soopyGui = global.soopyv2featuremanagerthing.features["soopyGui"].class;
-
- if(this.finalisedLoading){
- this.finaliseLoading()
- }
}).start()
this.name = ""
@@ -26,11 +23,7 @@ class GuiPage{
}
finaliseLoading(){
- if(!this.soopyGui){
- this.finalisedLoading = true
- return
- }
- this.soopyGui.addCategory(this);
+ categoryManager.addCategory(this);
}
newPage(){
@@ -56,7 +49,7 @@ class GuiPage{
}
delete(){
- this.soopyGui.deleteCategory(this);
+ categoryManager.deleteCategory(this)
}
//Override me :D
diff --git a/features/soopyGui/categoryManager.js b/features/soopyGui/categoryManager.js
new file mode 100644
index 0000000..6709ff4
--- /dev/null
+++ b/features/soopyGui/categoryManager.js
@@ -0,0 +1,37 @@
+class CategoryManager {
+ constructor(){
+ this.categorys = {}
+
+ this.arr = []
+ }
+
+ addCategory(category){
+ // this.pages = this.pages.filter(a=>a.name!==category.name)
+
+ this.categorys[category.name] = (category)
+ this.update()
+ }
+
+ deleteCategory(category){
+ delete this.categorys[category.name]
+ this.update()
+ }
+
+ update(){
+
+ this.arr = Object.values(this.categorys).sort((a, b)=>{
+ return b.priority - a.priority
+ })
+ }
+}
+
+
+if(!global.soopyv2CategoryManager){
+ global.soopyv2CategoryManager = new CategoryManager()
+
+ register("gameUnload", ()=>{
+ global.soopyv2CategoryManager = undefined
+ })
+}
+
+export default global.soopyv2CategoryManager \ No newline at end of file
diff --git a/features/soopyGui/index.js b/features/soopyGui/index.js
index 45e97a6..13a8813 100644
--- a/features/soopyGui/index.js
+++ b/features/soopyGui/index.js
@@ -9,6 +9,7 @@ import ButtonWithArrow from "../../../guimanager/GuiElement/ButtonWithArrow";
import SoopyMouseClickEvent from "../../../guimanager/EventListener/SoopyMouseClickEvent";
import SoopyOpenGuiEvent from "../../../guimanager/EventListener/SoopyOpenGuiEvent";
import SoopyGui2 from "../../../guimanager/SoopyGui";
+import categoryManager from "./categoryManager";
class SoopyGui extends Feature {
@@ -17,7 +18,6 @@ class SoopyGui extends Feature {
this.gui = undefined
- this.pages = []
this.currentPage = 0
this.backButton = undefined
@@ -78,7 +78,7 @@ class SoopyGui extends Feature {
this.gui.open()
if(page){
- this.pages.forEach(p=>{
+ this.getPages().forEach(p=>{
if(p.name.replace(/ /g, "_").toLowerCase() === page.toLowerCase()){
this.clickedOpen(p, false)
}
@@ -86,20 +86,8 @@ class SoopyGui extends Feature {
}
}
- addCategory(category){
- // this.pages = this.pages.filter(a=>a.name!==category.name)
-
- this.pages.push(category)
- this.sortPages()
-
- this.updateButtons()
- }
-
- deleteCategory(category){
- this.pages = this.pages.filter(a=>a!==category)
- this.sortPages()
-
- this.updateButtons()
+ getPages(){
+ return categoryManager.arr
}
updateButtons(){
@@ -107,7 +95,7 @@ class SoopyGui extends Feature {
this.buttonListElm.children = []
- this.pages.forEach((p, i)=>{
+ this.getPages().forEach((p, i)=>{
let settingsButton = new ButtonWithArrow().setText("ยง0" + p.name).setLocation(0, 0.225*i, 1, 0.2)
settingsButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{this.clickedOpen(p)}))
this.buttonListElm.addChild(settingsButton)
@@ -137,18 +125,11 @@ class SoopyGui extends Feature {
category.onOpen()
}
- sortPages(){
- this.pages = this.pages.sort((a, b)=>{
- return b.priority - a.priority
- })
- }
-
onDisable(){
this.gui.delete()
this.gui = undefined
- this.pages = []
this.currentPage = 0
this.backButton = undefined
this.activePages = []
@@ -169,7 +150,7 @@ class SoopyGui extends Feature {
this.currentPage = pageNum
- this.pages.forEach((p)=>{
+ this.getPages().forEach((p)=>{
Object.values(p.pages).forEach((e, i)=>{
e.location.location.x.set(i-pageNum+1, animate?500:0)
})
@@ -185,9 +166,10 @@ class SoopyGui extends Feature {
if(pageNum===0){
this.currCategory = undefined
this.closeSidebarPage()
+ this.updateButtons()
}
- this.pages.forEach((p)=>{
+ this.getPages().forEach((p)=>{
Object.values(p.pages).forEach((e, i)=>{
e.location.location.x.set(i-pageNum+1, animate?500:0)
})