aboutsummaryrefslogtreecommitdiff
path: root/features/settings
diff options
context:
space:
mode:
Diffstat (limited to 'features/settings')
-rw-r--r--features/settings/helpDataLoader.js4
-rw-r--r--features/settings/index.js109
-rw-r--r--features/settings/locationSettingHolder.js23
-rw-r--r--features/settings/settingThings/imageLocation.js9
-rw-r--r--features/settings/settingThings/location.js9
5 files changed, 99 insertions, 55 deletions
diff --git a/features/settings/helpDataLoader.js b/features/settings/helpDataLoader.js
index aadbd93..3a2e8f5 100644
--- a/features/settings/helpDataLoader.js
+++ b/features/settings/helpDataLoader.js
@@ -41,6 +41,10 @@ class HelpDataLoader {
if(!global.helpDataLoader){
global.helpDataLoader = new HelpDataLoader();
+
+ register("gameUnload", ()=>{
+ global.helpDataLoader = undefined
+ })
}
export default global.helpDataLoader; \ No newline at end of file
diff --git a/features/settings/index.js b/features/settings/index.js
index 2ce076d..6888f8a 100644
--- a/features/settings/index.js
+++ b/features/settings/index.js
@@ -4,86 +4,101 @@ import Feature from "../../featureClass/class";
import SoopyGuiElement from "../../../guimanager/GuiElement/SoopyGuiElement";
import SoopyTextElement from "../../../guimanager/GuiElement/SoopyTextElement";
import SoopyBoxElement from "../../../guimanager/GuiElement/SoopyBoxElement";
-import TextWithArrow from "../../../guimanager/GuiElement/TextWithArrow";
-import ButtonWithArrow from "../../../guimanager/GuiElement/ButtonWithArrow";
import BoxWithToggleAndDescription from "../../../guimanager/GuiElement/BoxWithToggleAndDescription";
import ButtonWithArrowAndDescription from "../../../guimanager/GuiElement/ButtonWithArrowAndDescription";
import SoopyMouseClickEvent from "../../../guimanager/EventListener/SoopyMouseClickEvent";
import SoopyContentChangeEvent from "../../../guimanager/EventListener/SoopyContentChangeEvent";
-import SoopyOpenGuiEvent from "../../../guimanager/EventListener/SoopyOpenGuiEvent";
import settingsCommunicator from "./settingsCommunicator";
import GuiPage from "../soopyGui/GuiPage"
-import { SoopyRenderEvent } from "../../../guimanager";
+import { SoopyGui, SoopyRenderEvent } from "../../../guimanager";
import TextBox from "../../../guimanager/GuiElement/TextBox";
+import locationSettingHolder from "./locationSettingHolder";
class SettingsRenderer extends Feature {
constructor() {
super()
-
- this.gui = undefined
-
- this.pages = []
- this.currentPage = 0
- this.backButton = undefined
- this.settingsCategoryArea = undefined
- this.settingsTitle = undefined
- this.settingsArea = undefined
- this.modifyingFeature = false
- this.featureLoadedTextBox = undefined
-
- this.SettingPage = undefined
}
onEnable(){
-
this.SettingPage = new SettingPage()
+ this.EditLocationsPage = new EditLocationsPage()
this.SettingPage.FeatureManager = this.FeatureManager
- return;
+ this.registerStep(true, 1, ()=>{
+ if(!this.EditLocationsPage) return
+
+ if(this.EditLocationsPage.needsExitPage){
+ this.EditLocationsPage.goToPage(0, 500)
+ this.EditLocationsPage.needsExitPage = false
+ }
+ })
+
}
onDisable(){
+ this.EditLocationsPage = undefined
this.SettingPage = undefined
- return;
- this.gui.delete()
-
- this.pages = []
- this.currentPage = 0
- this.backButton = undefined
- this.settingsArea = undefined
- this.settingsTitle = undefined
- this.settingsCategoryArea = undefined
- this.modifyingFeature = false
- this.featureLoadedTextBox = undefined
}
+}
- clickedOpenSettings(){
+class EditLocationsPage extends GuiPage {
+
+ constructor(){
+ super(9)
+
+ this.name = "Edit GUI Locations"
+ this.needsExitPage = false
- this.goToPage(1)
- }
+ this.soopyGui = new SoopyGui()
+ this.soopyGui._renderBackground = ()=>{} //remove background darkening
- clickedBackButton(){
- this.goToPage(this.currentPage-1)
- }
- goToPage(pageNum, animate=true){
- pageNum = Math.max(0, Math.min(pageNum, this.pages.length-1))
- if(pageNum == this.currentPage){
- return
+ this.soopyGui.ctGui.registerDraw((mouseX, mouseY, partialTicks)=>{
+ this.renderGui(mouseX, mouseY)
+ this.soopyGui._render(mouseX, mouseY, partialTicks)
+ })
+ this.soopyGui.ctGui.registerClicked((mouseX, mouseY, button)=>{
+ this.clicked(mouseX, mouseY)
+ this.soopyGui._onClick(mouseX, mouseY, button)
+ })
+ this.soopyGui.ctGui.registerMouseReleased((mouseX, mouseY)=>{
+ this.released(mouseX, mouseY)
+ })
+
+ this.finaliseLoading()
+ }
+
+ renderGui(mouseX, mouseY){
+ for(let setting of locationSettingHolder.getData()){
+ if(setting.parent){
+ if(setting.parent.isEnabled()){
+ setting.renderGui(mouseX, mouseY)
+ }
+ }else{
+ setting.renderGui(mouseX, mouseY)
+ }
+ }
+ }
+
+ clicked(mouseX, mouseY){
+ for(let setting of locationSettingHolder.getData()){
+ if(setting.clicked(mouseX, mouseY)) return //dont allow the user to drag 2 locations at once
}
+ }
- this.currentPage = pageNum
+ released(mouseX, mouseY){
+ for(let setting of locationSettingHolder.getData()){
+ setting.released(mouseX, mouseY)
+ }
+ }
- this.pages.forEach((p, i)=>{
- p.forEach(e=>{
- e.location.location.x.set(i-pageNum, animate?1000:0)
- })
- })
+ onOpen(){
+ this.needsExitPage = true
- this.backButton.location.location.y.set(pageNum === 0?-0.2:0, animate?1000:0)
+ this.soopyGui.open()
}
}
diff --git a/features/settings/locationSettingHolder.js b/features/settings/locationSettingHolder.js
new file mode 100644
index 0000000..14256d3
--- /dev/null
+++ b/features/settings/locationSettingHolder.js
@@ -0,0 +1,23 @@
+class LocationSettingHolder {
+ constructor() {
+ this.data = [];
+ }
+
+ addLocationSetting(setting){
+ this.data.push(setting)
+ }
+
+ getData(){
+ return this.data
+ }
+}
+
+if(!global.LocationSettingHolder){
+ global.LocationSettingHolder = new LocationSettingHolder();
+
+ register("gameUnload", ()=>{
+ global.LocationSettingHolder = undefined
+ })
+}
+
+export default global.LocationSettingHolder; \ No newline at end of file
diff --git a/features/settings/settingThings/imageLocation.js b/features/settings/settingThings/imageLocation.js
index adb6725..c8f37ed 100644
--- a/features/settings/settingThings/imageLocation.js
+++ b/features/settings/settingThings/imageLocation.js
@@ -7,8 +7,7 @@ import ButtonWithArrow from "../../../../guimanager/GuiElement/ButtonWithArrow"
import SoopyMouseClickEvent from "../../../../guimanager/EventListener/SoopyMouseClickEvent"
import NumberTextBox from "../../../../guimanager/GuiElement/NumberTextBox"
import SoopyContentChangeEvent from "../../../../guimanager/EventListener/SoopyContentChangeEvent"
-
-let allLocations = []
+import locationSettingHolder from "../locationSettingHolder"
class ImageLocationSetting extends ButtonSetting {
constructor(name, description, settingId, module, defaultLocation, image, imageWBase, imageHBase){
@@ -123,7 +122,7 @@ class ImageLocationSetting extends ButtonSetting {
this.released(mouseX, mouseY)
})
- allLocations.push(this)
+ locationSettingHolder.addLocationSetting(this)
}
requires(toggleSetting){
@@ -174,7 +173,9 @@ class ImageLocationSetting extends ButtonSetting {
&& mouseY>this.y && mouseY<this.y+height*this.scale){
this.dragging = true;
this.dragOffset = [this.x-mouseX, this.y-mouseY]
+ return true
}
+ return false
}
released(mouseX, mouseY){
this.updateLocation(mouseX, mouseY)
@@ -201,7 +202,7 @@ class ImageLocationSetting extends ButtonSetting {
this.y = mouseY+this.dragOffset[1]
let snapPoints = []
- allLocations.forEach(loc=>{
+ locationSettingHolder.getData().forEach(loc=>{
if(loc === this) return;
snapPoints.push([loc.x, loc.y])
snapPoints.push([loc.x+loc.getWidth()*loc.scale, loc.y])
diff --git a/features/settings/settingThings/location.js b/features/settings/settingThings/location.js
index b158e03..b5a6f1c 100644
--- a/features/settings/settingThings/location.js
+++ b/features/settings/settingThings/location.js
@@ -7,8 +7,7 @@ import ButtonWithArrow from "../../../../guimanager/GuiElement/ButtonWithArrow"
import SoopyMouseClickEvent from "../../../../guimanager/EventListener/SoopyMouseClickEvent"
import NumberTextBox from "../../../../guimanager/GuiElement/NumberTextBox"
import SoopyContentChangeEvent from "../../../../guimanager/EventListener/SoopyContentChangeEvent"
-
-let allLocations = []
+import locationSettingHolder from "../locationSettingHolder"
class LocationSetting extends ButtonSetting {
constructor(name, description, settingId, module, defaultLocation){
@@ -124,7 +123,7 @@ class LocationSetting extends ButtonSetting {
this.released(mouseX, mouseY)
})
- allLocations.push(this)
+ locationSettingHolder.addLocationSetting(this)
}
requires(toggleSetting){
@@ -184,7 +183,9 @@ class LocationSetting extends ButtonSetting {
&& mouseY>this.y && mouseY<this.y+height*this.scale){
this.dragging = true;
this.dragOffset = [this.x-mouseX, this.y-mouseY]
+ return true
}
+ return false
}
released(mouseX, mouseY){
this.updateLocation(mouseX, mouseY)
@@ -207,7 +208,7 @@ class LocationSetting extends ButtonSetting {
this.y = mouseY+this.dragOffset[1]
let snapPoints = []
- allLocations.forEach(loc=>{
+ locationSettingHolder.getData().forEach(loc=>{
if(loc === this) return;
snapPoints.push([loc.x, loc.y])
snapPoints.push([loc.x+loc.getWidth()*loc.scale, loc.y])