aboutsummaryrefslogtreecommitdiff
path: root/features/settings/settingThings/toggle.js
diff options
context:
space:
mode:
authorSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-05-29 14:14:06 +0800
committerSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-05-29 14:14:06 +0800
commitf3d0044dfe720e5e52d338ffc7f4efec7e780cb2 (patch)
tree4cecb863df5e703ca58cd943f3c54c0544b1498a /features/settings/settingThings/toggle.js
parentde27cdebfec9fafae6f686090039758d892196d7 (diff)
parent9ec9aa2d495df5a6c48b8edbd5fe31052d20b37b (diff)
downloadSoopyV2-f3d0044dfe720e5e52d338ffc7f4efec7e780cb2.tar.gz
SoopyV2-f3d0044dfe720e5e52d338ffc7f4efec7e780cb2.tar.bz2
SoopyV2-f3d0044dfe720e5e52d338ffc7f4efec7e780cb2.zip
Merge branch 'master' of https://github.com/Soopyboo32/SoopyV2
Diffstat (limited to 'features/settings/settingThings/toggle.js')
-rw-r--r--features/settings/settingThings/toggle.js24
1 files changed, 14 insertions, 10 deletions
diff --git a/features/settings/settingThings/toggle.js b/features/settings/settingThings/toggle.js
index d839b8f..200ac87 100644
--- a/features/settings/settingThings/toggle.js
+++ b/features/settings/settingThings/toggle.js
@@ -4,47 +4,51 @@ import Toggle from "../../../../guimanager/GuiElement/Toggle";
import SettingBase from "./settingBase";
class ToggleSetting extends SettingBase {
- constructor(name, description, defaultVal, settingId, module){
+ constructor(name, description, defaultVal, settingId, module) {
super(name, description, defaultVal, settingId, module)
+ this.onChange = undefined
+
this.toggleObject = new Toggle().setLocation(0, 0.3, 0.8, 0.4).setValue(this.getValue())
this.settingObject.addChild(this.toggleObject)
- this.toggleObject.addEvent(new SoopyContentChangeEvent().setHandler((newVal, oldVal, resetFun)=>{
+ this.toggleObject.addEvent(new SoopyContentChangeEvent().setHandler((newVal, oldVal, resetFun) => {
this.setValue(newVal)
}))
}
- setValue(newVal){
+ setValue(newVal) {
super.setValue(newVal)
this.toggleObject.setValue(newVal)
+ if (this.onChange) this.onChange()
+
return this
}
- requires(toggleSetting){
+ requires(toggleSetting) {
this.requiresO = toggleSetting
- toggleSetting.toggleObject.addEvent(new SoopyContentChangeEvent().setHandler((newVal, oldVal, resetFun)=>{
- if(newVal){
+ toggleSetting.toggleObject.addEvent(new SoopyContentChangeEvent().setHandler((newVal, oldVal, resetFun) => {
+ if (newVal) {
this.setValue(this.temp_val)
- this.toggleObject.triggerEvent(Enum.EVENT.CONTENT_CHANGE, [this.temp_val, false, ()=>{}])
+ this.toggleObject.triggerEvent(Enum.EVENT.CONTENT_CHANGE, [this.temp_val, false, () => { }])
this.guiObject.location.size.y.set(0.2, 500)
- }else{
+ } else {
this.temp_val = this.getValue()
this.setValue(false)
- this.toggleObject.triggerEvent(Enum.EVENT.CONTENT_CHANGE, [false, this.temp_val, ()=>{}])
+ this.toggleObject.triggerEvent(Enum.EVENT.CONTENT_CHANGE, [false, this.temp_val, () => { }])
this.guiObject.location.size.y.set(0, 500)
}
}))
let newVal = this.requiresO.getValue()
- if(!newVal){
+ if (!newVal) {
let temp_val = this.temp_val
this.setValue(false)
this.temp_val = temp_val