aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/config
diff options
context:
space:
mode:
authorsyeyoung <cyoung06@naver.com>2021-10-03 22:45:58 +0900
committersyeyoung <cyoung06@naver.com>2021-10-03 22:45:58 +0900
commitcb01114ea4427f764efbd58103a96643220491a2 (patch)
tree33ac3fc77b5756b6f15ea830932c78d32ca2b5ec /src/main/java/kr/syeyoung/dungeonsguide/config
parent2a60380de52cce7a895e8200751e8e854178796a (diff)
downloadSkyblock-Dungeons-Guide-cb01114ea4427f764efbd58103a96643220491a2.tar.gz
Skyblock-Dungeons-Guide-cb01114ea4427f764efbd58103a96643220491a2.tar.bz2
Skyblock-Dungeons-Guide-cb01114ea4427f764efbd58103a96643220491a2.zip
- Keybinds to dg settings
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/config')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameterEdit.java12
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/types/TCKeybind.java39
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java1
4 files changed, 51 insertions, 3 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java
index 90acceb9..49f637a5 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java
@@ -71,7 +71,7 @@ public class MFeature extends MPanel {
}
if (abstractFeature.getParameters().size() != 0) {
MButton button = new MButton();
- button.setText("Edit");
+ button.setText("Settings");
button.setOnActionPerformed(new Runnable() {
@Override
public void run() {
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameterEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameterEdit.java
index b4b2a8e8..8ed0e028 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameterEdit.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameterEdit.java
@@ -89,7 +89,14 @@ public class MParameterEdit extends MPanel {
((MToggleButton)valueEdit).setOnToggle(() -> {
parameter.setValue(((MToggleButton) valueEdit).isEnabled());
});
- } else {
+ } else if (parameter.getValue_type().equals("keybind")) {
+ valueEdit = new MKeyEditButton();
+ ((MKeyEditButton)valueEdit).setKey((Integer) parameter.getValue());
+ ((MKeyEditButton)valueEdit).setOnKeyEdit(() -> {
+ parameter.setValue(((MKeyEditButton) valueEdit).getKey());
+ });
+ ((MKeyEditButton)valueEdit).setBorder(RenderUtils.blendTwoColors(0xFF141414,0x7702EE67));
+ }else {
valueEdit = new MLabel();
((MLabel)valueEdit).setText("????");
}
@@ -108,10 +115,11 @@ public class MParameterEdit extends MPanel {
add(valueEditHolder);
valueEditHolder.add(valueEdit);
}
- public MParameterEdit(AbstractFeature abstractFeature, FeatureParameter parameter, RootConfigPanel rootConfigPanel, MPanel valueEdit) {
+ public MParameterEdit(AbstractFeature abstractFeature, FeatureParameter parameter, RootConfigPanel rootConfigPanel, MPanel valueEdit, Predicate<FeatureParameter> isDisabled) {
this.abstractFeature = abstractFeature;
this.featureParameter = parameter;
this.rootConfigPanel = rootConfigPanel;
+ this.isDisabled = isDisabled;
valueEditHolder = new MPanel() {
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCKeybind.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCKeybind.java
new file mode 100644
index 00000000..4ae89395
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCKeybind.java
@@ -0,0 +1,39 @@
+/*
+ * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
+ * Copyright (C) 2021 cyoung06
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package kr.syeyoung.dungeonsguide.config.types;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonPrimitive;
+
+public class TCKeybind implements TypeConverter<Integer> {
+ @Override
+ public String getTypeString() {
+ return "keybind";
+ }
+
+ @Override
+ public Integer deserialize(JsonElement element) {
+ return element.getAsInt();
+ }
+
+ @Override
+ public JsonElement serialize(Integer element) {
+ return new JsonPrimitive(element);
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java
index d183cffb..abffd34a 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java
@@ -49,5 +49,6 @@ public class TypeConverterRegistry {
register(new TCTextStyleList());
register(new TCTextStyle());
register(new TCStringList());
+ register(new TCKeybind());
}
}