From eae4f215143ef9ce659f73c7d4e3dac08e894cec Mon Sep 17 00:00:00 2001 From: syeyoung Date: Fri, 5 Feb 2021 23:06:06 +0900 Subject: mm --- .../dungeonsguide/config/types/AColor.java | 8 ++++++++ .../dungeonsguide/config/types/TCAColor.java | 22 +++++++++++++++----- .../dungeonsguide/config/types/TCTextStyle.java | 24 ++++++++++++++++++++++ .../config/types/TCTextStyleList.java | 23 +++++++++++++++++++++ .../config/types/TypeConverterRegistry.java | 2 ++ .../features/text/TextHUDFeature.java | 22 ++++++++++++++++++++ .../dungeonsguide/features/text/TextStyle.java | 12 +++++++++++ 7 files changed, 108 insertions(+), 5 deletions(-) create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/types/TCTextStyle.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/types/TCTextStyleList.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/text/TextStyle.java (limited to 'src/main/java/kr/syeyoung/dungeonsguide') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/AColor.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/AColor.java index 0015672e..bf1de6b5 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/AColor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/AColor.java @@ -1,8 +1,16 @@ package kr.syeyoung.dungeonsguide.config.types; +import lombok.Getter; +import lombok.Setter; + import java.awt.*; +@Getter +@Setter public class AColor extends Color { + private boolean chroma; + private float chromaSpeed; + public AColor(int r, int g, int b, int a) { super(r, g, b, a); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCAColor.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCAColor.java index 2b37b258..9f95e094 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCAColor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCAColor.java @@ -1,23 +1,35 @@ package kr.syeyoung.dungeonsguide.config.types; import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import java.awt.*; -public class TCAColor implements TypeConverter { +public class TCAColor implements TypeConverter { @Override public String getTypeString() { return "acolor"; } @Override - public Color deserialize(JsonElement element) { - return new AColor(element.getAsInt(), true); + public AColor deserialize(JsonElement element) { + if (element instanceof JsonPrimitive) + return new AColor(element.getAsInt(), true); + + JsonObject object = element.getAsJsonObject(); + AColor color = new AColor(object.get("color").getAsInt(), true); + color.setChroma(object.get("chroma").getAsBoolean()); + color.setChromaSpeed(object.get("chromaSpeed").getAsFloat()); + return color; } @Override - public JsonElement serialize(Color element) { - return new JsonPrimitive(element.getRGB()); + public JsonElement serialize(AColor element) { + JsonObject object = new JsonObject(); + object.addProperty("color", element.getRGB()); + object.addProperty("chroma", element.isChroma()); + object.addProperty("chromaSpeed", element.getChromaSpeed()); + return object; } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCTextStyle.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCTextStyle.java new file mode 100644 index 00000000..3e43d65b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCTextStyle.java @@ -0,0 +1,24 @@ +package kr.syeyoung.dungeonsguide.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; +import kr.syeyoung.dungeonsguide.features.text.TextStyle; + +import java.util.List; + +public class TCTextStyle implements TypeConverter { + @Override + public String getTypeString() { + return "textstyle"; + } + + @Override + public TextStyle deserialize(JsonElement element) { + return new Color(element.getAsInt()); + } + + @Override + public JsonElement serialize(TextStyle element) { + return new JsonPrimitive(element.getRGB()); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCTextStyleList.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCTextStyleList.java new file mode 100644 index 00000000..88a0aa66 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCTextStyleList.java @@ -0,0 +1,23 @@ +package kr.syeyoung.dungeonsguide.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; + +import java.util.List; + +public class TCTextStyleList implements TypeConverter { + @Override + public String getTypeString() { + return "list_textStyle"; + } + + @Override + public List deserialize(JsonElement element) { + return new Color(element.getAsInt()); + } + + @Override + public JsonElement serialize(List element) { + return new JsonPrimitive(element.getRGB()); + } +} 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 69f047a8..5e48b76c 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java @@ -27,5 +27,7 @@ public class TypeConverterRegistry { register(new TCColor()); register(new TCFloat()); register(new TCAColor()); + register(new TCTextStyleList()); + register(new TCTextStyle()); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java new file mode 100644 index 00000000..d2cf793d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java @@ -0,0 +1,22 @@ +package kr.syeyoung.dungeonsguide.features.text; + +import kr.syeyoung.dungeonsguide.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.features.GuiFeature; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public abstract class TextHUDFeature extends GuiFeature { + protected TextHUDFeature(String category, String name, String description, String key, boolean keepRatio, int width, int height) { + super(category, name, description, key, keepRatio, width, height); + this.parameters.put("textStyles", new FeatureParameter>("textStyles", "", "", new ArrayList(), "list_textstyle")); + } + + public abstract List getUsedTextStyle(); + + @Override + public void drawHUD(float partialTicks) { + + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextStyle.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextStyle.java new file mode 100644 index 00000000..74e3c66a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextStyle.java @@ -0,0 +1,12 @@ +package kr.syeyoung.dungeonsguide.features.text; + +import kr.syeyoung.dungeonsguide.config.types.AColor; +import lombok.Data; + +import java.awt.*; + +@Data +public class TextStyle { + private String groupName; + private AColor color; +} -- cgit