diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-05-29 12:06:18 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-05-29 12:06:18 +0800 |
commit | 9ec9aa2d495df5a6c48b8edbd5fe31052d20b37b (patch) | |
tree | aa20f5314241d517b0a50b123926077685fb700e /features/soopyGui/index.js | |
parent | a6593709b0e1e99e241b6c163fe66623685b6efc (diff) | |
parent | 51cdd4ca4ea64e1a9a67b99c274693a54f7f535d (diff) | |
download | SoopyV2-9ec9aa2d495df5a6c48b8edbd5fe31052d20b37b.tar.gz SoopyV2-9ec9aa2d495df5a6c48b8edbd5fe31052d20b37b.tar.bz2 SoopyV2-9ec9aa2d495df5a6c48b8edbd5fe31052d20b37b.zip |
Merge branch 'master' of https://github.com/Soopyboo32/SoopyV2
Diffstat (limited to 'features/soopyGui/index.js')
-rw-r--r-- | features/soopyGui/index.js | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/features/soopyGui/index.js b/features/soopyGui/index.js index 4c8f571..32ac1a7 100644 --- a/features/soopyGui/index.js +++ b/features/soopyGui/index.js @@ -29,7 +29,7 @@ class SoopyGui extends Feature { this.activeCategory = undefined } - onEnable(){ + onEnable() { this.gui = new SoopyGui2() // this.gui.isDebugEnabled = true @@ -39,23 +39,23 @@ class SoopyGui extends Feature { this.mainWindowElement = new SoopyBoxElement().setLocation(0.25, 0.2, 0.5, 0.6) - this.mainWindowElement.addEvent(new SoopyOpenGuiEvent().setHandler(()=>{this.goToPageNum(0, false)})) + this.mainWindowElement.addEvent(new SoopyOpenGuiEvent().setHandler(() => { this.goToPageNum(0, false) })) //############################################################################################### // Category Page //############################################################################################### this.categoryPage = new SoopyGuiElement().setLocation(0, 0, 1, 1) - + let title = new SoopyTextElement().setText("§0SoopyV2!").setMaxTextScale(3).setLocation(0.1, 0.05, 0.5, 0.1) this.categoryPage.addChild(title) let discordButton = new ButtonWithArrow().setText("§0Discord").setLocation(0.7, 0.05, 0.25, 0.1) - discordButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ + discordButton.addEvent(new SoopyMouseClickEvent().setHandler(() => { java.awt.Desktop.getDesktop().browse( new java.net.URI("https://discord.gg/dfSMq96RSN") - ); - })) + ); + })) this.categoryPage.addChild(discordButton) this.buttonListElm = new SoopyGuiElement().setLocation(0.1, 0.2, 0.8, 0.8).setScrollable(true) @@ -64,11 +64,11 @@ class SoopyGui extends Feature { //############################################################################################### // Back button for all second pages //############################################################################################### - + this.backButton = new TextWithArrow().setText("§0Back").setLocation(0.01, -0.2, 0.1, 0.1).setDirectionRight(false) - let backButtonEvent = new SoopyMouseClickEvent().setHandler(()=>{this.clickedBackButton()}) + let backButtonEvent = new SoopyMouseClickEvent().setHandler(() => { this.clickedBackButton() }) this.backButton.addEvent(backButtonEvent) - + this.mainWindowElement.addChild(this.categoryPage) this.sidebarPage = new SoopyBoxElement().setLocation(0.3, 0.2, 0.3, 0.6) @@ -76,43 +76,43 @@ class SoopyGui extends Feature { this.gui.element.addChild(this.sidebarPage) this.gui.element.addChild(this.mainWindowElement) - + this.mainWindowElement.addChild(this.backButton) this.updateButtons() } - openCommand(page){ + openCommand(page) { this.gui.open() - if(page){ - this.getPages().forEach(p=>{ - if(p.name.replace(/ /g, "_").toLowerCase() === page.toLowerCase()){ + if (page) { + this.getPages().forEach(p => { + if (p.name.replace(/ /g, "_").toLowerCase() === page.toLowerCase()) { this.clickedOpen(p, false) } }) } } - getPages(){ + getPages() { return categoryManager.arr } - updateButtons(){ - if(!this.buttonListElm) return; + updateButtons() { + if (!this.buttonListElm) return; this.buttonListElm.children = [] - 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.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) }) } - clickedOpen(category, anim=true){ - if(!this.lastClickedOpen)this.lastClickedOpen = 0 - if(Date.now()-this.lastClickedOpen < 100) return //Stopping infinite loop where button getting reset causes click event to get fired again + clickedOpen(category, anim = true) { + if (!this.lastClickedOpen) this.lastClickedOpen = 0 + if (Date.now() - this.lastClickedOpen < 100) return //Stopping infinite loop where button getting reset causes click event to get fired again this.lastClickedOpen = Date.now() let theParent = this.mainWindowElement.innerObjectPaddingThing || this.mainWindowElement @@ -124,7 +124,7 @@ class SoopyGui extends Feature { this.activePages = category.pages this.currCategory = category - Object.values(this.activePages).forEach(p=>{ + Object.values(this.activePages).forEach(p => { this.mainWindowElement.addChild(p) }) @@ -133,7 +133,7 @@ class SoopyGui extends Feature { this.goToPageNum(1, anim) } - onDisable(){ + onDisable() { this.gui.delete() this.gui = undefined @@ -145,50 +145,50 @@ class SoopyGui extends Feature { this.lastClickedOpen = undefined } - clickedBackButton(){ - this.goToPageNum(this.currentPage-1) + clickedBackButton() { + this.goToPageNum(this.currentPage - 1) } - goToPage(page, animate=true){ + goToPage(page, animate = true) { let pageNum = page._soopyAddonsPageId - - if(pageNum == this.currentPage){ + + if (pageNum == this.currentPage) { return } this.currentPage = pageNum - this.getPages().forEach((p)=>{ - Object.values(p.pages).forEach((e, i)=>{ - e.location.location.x.set(i-pageNum+1, animate?500:0) + this.getPages().forEach((p) => { + Object.values(p.pages).forEach((e, i) => { + e.location.location.x.set(i - pageNum + 1, animate ? 500 : 0) }) }) - this.categoryPage.location.location.x.set(-pageNum, animate?500:0) + this.categoryPage.location.location.x.set(-pageNum, animate ? 500 : 0) - this.backButton.location.location.y.set((pageNum === 0 || !this.currCategory.showBackButton)?-0.2:0, animate?500:0) + this.backButton.location.location.y.set((pageNum === 0 || !this.currCategory.showBackButton) ? -0.2 : 0, animate ? 500 : 0) } - goToPageNum(pageNum, animate=true){ - if(pageNum<0) return; + goToPageNum(pageNum, animate = true) { + if (pageNum < 0) return; this.currentPage = pageNum - if(pageNum===0){ + if (pageNum === 0) { this.currCategory = undefined this.closeSidebarPage() this.updateButtons() } - this.getPages().forEach((p)=>{ - Object.values(p.pages).forEach((e, i)=>{ - e.location.location.x.set(i-pageNum+1, animate?500:0) + this.getPages().forEach((p) => { + Object.values(p.pages).forEach((e, i) => { + e.location.location.x.set(i - pageNum + 1, animate ? 500 : 0) }) }) - this.categoryPage.location.location.x.set(-pageNum, animate?500:0) + this.categoryPage.location.location.x.set(-pageNum, animate ? 500 : 0) - this.backButton.location.location.y.set((pageNum === 0 || !this.currCategory.showBackButton)?-0.2:0, animate?500:0) + this.backButton.location.location.y.set((pageNum === 0 || !this.currCategory.showBackButton) ? -0.2 : 0, animate ? 500 : 0) - if(this.currCategory) this.currCategory.onOpenPage(pageNum) + if (this.currCategory) this.currCategory.onOpenPage(pageNum) } - openSidebarPage(child){ + openSidebarPage(child) { this.sidebarPage.location.location.x.set(0.625, 500) this.mainWindowElement.location.location.x.set(0.075, 500) @@ -197,7 +197,7 @@ class SoopyGui extends Feature { this.sidebarPage.addChild(child) } - closeSidebarPage(){ + closeSidebarPage() { this.sidebarPage.location.location.x.set(0.3, 500) this.mainWindowElement.location.location.x.set(0.25, 500) |