diff options
author | syeyoung <cyong06@naver.com> | 2020-12-27 00:11:20 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2020-12-27 00:11:20 +0900 |
commit | 1a9e56df1b9fba821b2c7019a3f47694d765e74f (patch) | |
tree | 0bdb8f43e771e6a004d12d344e8e59490fabf407 /src/main/java/kr/syeyoung/dungeonsguide/config | |
parent | 21abe2f9ea26f17f6d332ca7bf3f4b0f044aa77a (diff) | |
download | Skyblock-Dungeons-Guide-1a9e56df1b9fba821b2c7019a3f47694d765e74f.tar.gz Skyblock-Dungeons-Guide-1a9e56df1b9fba821b2c7019a3f47694d765e74f.tar.bz2 Skyblock-Dungeons-Guide-1a9e56df1b9fba821b2c7019a3f47694d765e74f.zip |
massive overhaul
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/config')
9 files changed, 155 insertions, 10 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/CategoryEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/config/CategoryEditPane.java index 95079857..0a0aea98 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/CategoryEditPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/CategoryEditPane.java @@ -1,18 +1,13 @@ package kr.syeyoung.dungeonsguide.config; -import kr.syeyoung.dungeonsguide.Config; -import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.roomedit.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; import kr.syeyoung.dungeonsguide.roomedit.elements.*; import kr.syeyoung.dungeonsguide.roomedit.panes.DynamicEditor; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditRegistry; import net.minecraftforge.common.config.ConfigCategory; import net.minecraftforge.common.config.Property; -import scala.actors.threadpool.Arrays; import java.awt.*; import java.util.*; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java b/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java new file mode 100644 index 00000000..aff6a02f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java @@ -0,0 +1,23 @@ +package kr.syeyoung.dungeonsguide.config; + +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStreamReader; + +public class Config { + public static JsonObject configuration; + + + public static void loadConfig(File f) throws FileNotFoundException { + configuration = (JsonObject) new JsonParser().parse(new InputStreamReader(new FileInputStream(f))); + + + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/GuiConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/GuiConfig.java index 5e5b8aac..e8bfc6bd 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/GuiConfig.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/GuiConfig.java @@ -1,10 +1,7 @@ package kr.syeyoung.dungeonsguide.config; -import kr.syeyoung.dungeonsguide.Config; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.roomedit.MPanel; import kr.syeyoung.dungeonsguide.roomedit.elements.MTabbedPane; -import kr.syeyoung.dungeonsguide.roomedit.panes.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; @@ -26,8 +23,8 @@ public class GuiConfig extends GuiScreen { mainPanel.add(tabbedPane); tabbedPane.setBackground2(new Color(17, 17, 17, 179)); - for (String cate:Config.configuration.getCategoryNames()) - tabbedPane.addTab(cate, new CategoryEditPane(Config.configuration.getCategory(cate))); +// for (String cate:Config.configuration.getCategoryNames()) +// tabbedPane.addTab(cate, new CategoryEditPane(Config.configuration.getCategory(cate))); this.tabbedPane = tabbedPane; } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCBoolean.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCBoolean.java new file mode 100644 index 00000000..ba4e44be --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCBoolean.java @@ -0,0 +1,21 @@ +package kr.syeyoung.dungeonsguide.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; + +public class TCBoolean implements TypeConverter<Boolean> { + @Override + public String getTypeString() { + return "boolean"; + } + + @Override + public Boolean deserialize(JsonElement element) { + return element.getAsBoolean(); + } + + @Override + public JsonElement serialize(Boolean element) { + return new JsonPrimitive(element); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCInteger.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCInteger.java new file mode 100644 index 00000000..3b5195de --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCInteger.java @@ -0,0 +1,21 @@ +package kr.syeyoung.dungeonsguide.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; + +public class TCInteger implements TypeConverter<Integer> { + @Override + public String getTypeString() { + return "integer"; + } + + @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/TCRectangle.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCRectangle.java new file mode 100644 index 00000000..2d571da7 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCRectangle.java @@ -0,0 +1,35 @@ +package kr.syeyoung.dungeonsguide.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; +import org.w3c.dom.css.Rect; + +import java.awt.*; + +public class TCRectangle implements TypeConverter<Rectangle> { + @Override + public String getTypeString() { + return "rect"; + } + + @Override + public Rectangle deserialize(JsonElement element) { + Rectangle rectangle = new Rectangle(); + rectangle.x = ((JsonObject)element).get("x").getAsInt(); + rectangle.y = ((JsonObject)element).get("y").getAsInt(); + rectangle.width = ((JsonObject)element).get("width").getAsInt(); + rectangle.height = ((JsonObject)element).get("height").getAsInt(); + return rectangle; + } + + @Override + public JsonElement serialize(Rectangle element) { + JsonObject object = new JsonObject(); + object.addProperty("x", element.x); + object.addProperty("y", element.y); + object.addProperty("width", element.width); + object.addProperty("height", element.height); + return object; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCString.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCString.java new file mode 100644 index 00000000..fa28c1b6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCString.java @@ -0,0 +1,21 @@ +package kr.syeyoung.dungeonsguide.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; + +public class TCString implements TypeConverter<String> { + @Override + public String getTypeString() { + return "string"; + } + + @Override + public String deserialize(JsonElement element) { + return element.getAsString(); + } + + @Override + public JsonElement serialize(String element) { + return new JsonPrimitive(element); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverter.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverter.java new file mode 100644 index 00000000..b5b69be0 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverter.java @@ -0,0 +1,11 @@ +package kr.syeyoung.dungeonsguide.config.types; + +import com.google.gson.JsonElement; + +public interface TypeConverter<T> { + String getTypeString(); + + T deserialize(JsonElement element); + + JsonElement serialize(T 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 new file mode 100644 index 00000000..82bfe3fc --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java @@ -0,0 +1,21 @@ +package kr.syeyoung.dungeonsguide.config.types; + +import kr.syeyoung.dungeonsguide.roomedit.Parameter; + +import java.util.HashMap; +import java.util.Map; + +public class TypeConverterRegistry { + private static Map<String, TypeConverter> typeConverterMap = new HashMap<String, TypeConverter>(); + + public static void register(TypeConverter typeConverter) { + typeConverterMap.put(typeConverter.getTypeString(), typeConverter); + } + + public static TypeConverter getTypeConverter(String type_string) { + return typeConverterMap.get(type_string); + } + public static <T> TypeConverter<T> getTypeConverter(String type_string, Class<T> t) { + return (TypeConverter<T>)typeConverterMap.get(type_string); + } +} |