From cb01114ea4427f764efbd58103a96643220491a2 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Sun, 3 Oct 2021 22:45:58 +0900 Subject: - Keybinds to dg settings --- .../dungeonsguide/config/guiconfig/MFeature.java | 2 +- .../config/guiconfig/MParameterEdit.java | 12 +++++-- .../dungeonsguide/config/types/TCKeybind.java | 39 ++++++++++++++++++++++ .../config/types/TypeConverterRegistry.java | 1 + 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/types/TCKeybind.java (limited to 'src/main/java/kr/syeyoung/dungeonsguide/config') 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 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 . + */ + +package kr.syeyoung.dungeonsguide.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; + +public class TCKeybind implements TypeConverter { + @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()); } } -- cgit