aboutsummaryrefslogtreecommitdiff
path: root/features/soopyGui/categoryManager.js
blob: 6709ff4d18ce43873d75c28fee75f9500b85f8e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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