diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-09-17 19:39:05 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-09-17 19:39:05 +0800 |
commit | 431e4fc9d1657a50ebc34b8ac24f9bfaea06417f (patch) | |
tree | 5987bb14f38d2999c682970429f34b41eb3e5826 /src/features/settings/settingThings/textSetting.js | |
parent | e73f2efdf0f50aa775c540317394d46428e9704f (diff) | |
download | SoopyV2-431e4fc9d1657a50ebc34b8ac24f9bfaea06417f.tar.gz SoopyV2-431e4fc9d1657a50ebc34b8ac24f9bfaea06417f.tar.bz2 SoopyV2-431e4fc9d1657a50ebc34b8ac24f9bfaea06417f.zip |
Initial move to babel + change fetch to use async/await
Diffstat (limited to 'src/features/settings/settingThings/textSetting.js')
-rw-r--r-- | src/features/settings/settingThings/textSetting.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/features/settings/settingThings/textSetting.js b/src/features/settings/settingThings/textSetting.js new file mode 100644 index 0000000..edc0989 --- /dev/null +++ b/src/features/settings/settingThings/textSetting.js @@ -0,0 +1,41 @@ + +import SoopyContentChangeEvent from "../../../../guimanager/EventListener/SoopyContentChangeEvent"; +import TextBox from "../../../../guimanager/GuiElement/TextBox"; +import PasswordInput from "../../../../guimanager/GuiElement/PasswordInput" +import SettingBase from "./settingBase"; + +class TextSetting extends SettingBase { + constructor(name, description, defaultVal, settingId, module, placeholder, isSecret) { + super(name, description, defaultVal, settingId, module) + + this.textObject = (isSecret ? new PasswordInput() : new TextBox()).setLocation(0, 0.2, 0.9, 0.6).setText(this.getValue() || "").setPlaceholder(placeholder) + this.settingObject.addChild(this.textObject) + + this.settingObject.setLocation(0.6, 0, 0.4, 1) + this.guiObject.text.setLocation(0, 0, 0.6, 0.6) + this.guiObject.description.setLocation(0, 0.6, 0.55, 0.4) + + this.textObject.text.addEvent(new SoopyContentChangeEvent().setHandler((newVal, oldVal, resetFun) => { + this.setValue(newVal) + })) + + } + update() { + if (this.hasHelp()) { + this.guiObject.addChild(this.helpButton) + + this.guiObject.text.setLocation(0.075, 0, 0.6 - 0.075, 0.6) + } else { + this.guiObject.text.setLocation(0, 0, 0.6, 0.6) + } + } + setValue(newVal) { + super.setValue(newVal) + + this.textObject.setText(newVal) + + return this + } +} + +export default TextSetting
\ No newline at end of file |