From 578a7e1720c0c85b1023151172eb8e077f5bf126 Mon Sep 17 00:00:00 2001 From: Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> Date: Fri, 3 Jun 2022 15:41:40 +0800 Subject: + fix there being multiple of the same hud element in the edit gui locations button sometimes --- features/settings/locationSettingHolder.js | 20 ++++++++++++-------- features/settings/settingThings/location.js | 4 ++++ 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'features/settings') diff --git a/features/settings/locationSettingHolder.js b/features/settings/locationSettingHolder.js index 14256d3..af6f507 100644 --- a/features/settings/locationSettingHolder.js +++ b/features/settings/locationSettingHolder.js @@ -1,21 +1,25 @@ class LocationSettingHolder { constructor() { - this.data = []; + this.data = new Set(); } - addLocationSetting(setting){ - this.data.push(setting) + addLocationSetting(setting) { + this.data.add(setting) } - getData(){ - return this.data + removeLocationSetting(setting) { + this.data.delete(setting) + } + + getData() { + return [...this.data] } } -if(!global.LocationSettingHolder){ +if (!global.LocationSettingHolder) { global.LocationSettingHolder = new LocationSettingHolder(); - - register("gameUnload", ()=>{ + + register("gameUnload", () => { global.LocationSettingHolder = undefined }) } diff --git a/features/settings/settingThings/location.js b/features/settings/settingThings/location.js index 9cd13af..c9587eb 100644 --- a/features/settings/settingThings/location.js +++ b/features/settings/settingThings/location.js @@ -146,6 +146,10 @@ class LocationSetting extends ButtonSetting { return this } + delete() { + locationSettingHolder.removeLocationSetting(this) + } + _updateValue() { this.setValue([this.x, this.y, this.scale, this.shadowType]) if (this.onChange) this.onChange() -- cgit