aboutsummaryrefslogtreecommitdiff
path: root/features/soopyGui/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'features/soopyGui/index.js')
-rw-r--r--features/soopyGui/index.js92
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)