diff options
author | syeyoung <cyong06@naver.com> | 2020-12-24 12:51:33 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2020-12-24 12:51:33 +0900 |
commit | 84011d2cc383aec605b13c2cfaa31e68d1af5604 (patch) | |
tree | 75613bf6263c28ffd3b91555d073bfbbdfe6aea2 /src/main/java/kr/syeyoung/dungeonsguide | |
parent | 9d82a605330cb1993a0518f6168d01e7df411ad5 (diff) | |
download | Skyblock-Dungeons-Guide-84011d2cc383aec605b13c2cfaa31e68d1af5604.tar.gz Skyblock-Dungeons-Guide-84011d2cc383aec605b13c2cfaa31e68d1af5604.tar.bz2 Skyblock-Dungeons-Guide-84011d2cc383aec605b13c2cfaa31e68d1af5604.zip |
configuration
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide')
4 files changed, 61 insertions, 25 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/Config.java b/src/main/java/kr/syeyoung/dungeonsguide/Config.java index adbb2da4..03bd2396 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/Config.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/Config.java @@ -1,6 +1,7 @@ package kr.syeyoung.dungeonsguide; import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; public class Config { public static Configuration configuration; @@ -28,18 +29,20 @@ public class Config { configuration.load(); // Read props from config - DEBUG = configuration.get(Config.CATEGORY_ADVANCED, "debug","false", "Enable debug mode").getBoolean(); // Comment - - solver_riddle = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "riddle", "true", "Riddle puzzle solver").getBoolean(); - solver_kahoot = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "kahoot", "true", "Omnicrescent puzzle solver").getBoolean(); - solver_teleport = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "teleport", "true", "Teleport puzzle solver").getBoolean(); - solver_creeper = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "creeper", "true", "Creeper puzzle solver (Advanced)").getBoolean(); - solver_blaze = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "blaze", "true", "Blaze puzzle solver").getBoolean(); - solver_tictactoe = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "tictactoe", "true", "Tictactoe puzzle solver (Advanced)").getBoolean(); - solver_icepath = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "icepath", "true", "Icepath puzzle solver (Advanced)").getBoolean(); - solver_icesilverfish = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "silverfish", "true", "Silverfish puzzle solver (Advanced)").getBoolean(); - solver_waterpuzzle = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "water", "true", "Water puzzle solver (Advanced)").getBoolean(); - solver_box = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "box", "true", "Box puzzle solver (Advanced)").getBoolean(); + solver_riddle = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "riddle", "true", "Riddle puzzle solver", Property.Type.BOOLEAN).getBoolean(); + solver_kahoot = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "kahoot", "true", "Omnicrescent puzzle solver", Property.Type.BOOLEAN).getBoolean(); + solver_teleport = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "teleport", "true", "Teleport puzzle solver", Property.Type.BOOLEAN).getBoolean(); + solver_creeper = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "creeper", "true", "Creeper puzzle solver", Property.Type.BOOLEAN).getBoolean(); + solver_blaze = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "blaze", "true", "Blaze puzzle solver", Property.Type.BOOLEAN).getBoolean(); + solver_tictactoe = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "tictactoe", "true", "Tictactoe puzzle solver", Property.Type.BOOLEAN).getBoolean(); + solver_icepath = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "icepath", "true", "Icepath puzzle solver", Property.Type.BOOLEAN).getBoolean(); + solver_icesilverfish = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "silverfish", "true", "Silverfish puzzle solver", Property.Type.BOOLEAN).getBoolean(); + solver_waterpuzzle = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "water", "true", "Water puzzle solver", Property.Type.BOOLEAN).getBoolean(); + solver_box = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "box", "true", "Box puzzle solver", Property.Type.BOOLEAN).getBoolean(); + + + + DEBUG = configuration.get(Config.CATEGORY_ADVANCED, "debug","false", "Enable debug mode", Property.Type.BOOLEAN).getBoolean(); // Comment } catch (Exception e) { // Failed reading/writing, just continue } finally { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/CategoryEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/config/CategoryEditPane.java index 6c50196d..95079857 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/CategoryEditPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/CategoryEditPane.java @@ -5,10 +5,9 @@ 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.MButton; -import kr.syeyoung.dungeonsguide.roomedit.elements.MParameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.MValue; +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; @@ -23,7 +22,8 @@ public class CategoryEditPane extends MPanel implements DynamicEditor { private ConfigCategory category; private MButton save; - private Map<String, MValue> parameters = new HashMap<String, MValue>(); + private Map<String, Parameter> parameters = new HashMap<String, Parameter>(); + private List<MLabelAndElement> le = new ArrayList<MLabelAndElement>(); public CategoryEditPane(ConfigCategory category) { this.category = category; @@ -53,9 +53,9 @@ public class CategoryEditPane extends MPanel implements DynamicEditor { save.setOnActionPerformed(new Runnable() { @Override public void run() { - for (Map.Entry<String,MValue> parameter:parameters.entrySet()) { - if (parameter.getValue().getData() != null) - category.get(parameter.getKey()).setValue(parameter.getValue().getData().toString()); + for (Map.Entry<String,Parameter> parameter:parameters.entrySet()) { + if (parameter.getValue() != null) + category.get(parameter.getKey()).setValue(String.valueOf(parameter.getValue().getNewData())); } Config.syncConfig(false); } @@ -64,10 +64,42 @@ public class CategoryEditPane extends MPanel implements DynamicEditor { { for (Map.Entry<String, Property> en : category.entrySet()) { ValueEditCreator vec = ValueEditRegistry.getValueEditMap(typeToclass(en.getValue().getType())); + final Parameter parameter; + vec.createDefaultValue(parameter = new Parameter(en.getValue().comment, getValue(en.getValue()), getValue(en.getValue()))); + + MPanel element = null; + if (en.getValue().getType() == Property.Type.STRING) { + element = new MTextField() { + @Override + public void edit(String str) { + parameter.setNewData(str); + } + }; + ((MTextField)element).setText(en.getValue().getString()); + } else if (en.getValue().getType() == Property.Type.INTEGER) { + element = new MIntegerSelectionButton(en.getValue().getInt()); + final MPanel finalElement = element; + ((MIntegerSelectionButton)element).setOnUpdate(new Runnable() { + @Override + public void run() { + parameter.setNewData(((MIntegerSelectionButton) finalElement).getData()); + } + }); + }else if (en.getValue().getType() == Property.Type.BOOLEAN) { + element = new MStringSelectionButton(Arrays.asList(new String[] {"on", "off"}), en.getValue().getBoolean() ? "on":"off"); + final MPanel finalElement1 = element; + ((MStringSelectionButton)element).setOnUpdate(new Runnable() { + @Override + public void run() { + parameter.setNewData(((MStringSelectionButton) finalElement1).getSelected().equals("on") ? true : false); + } + }); + } - MValue mParameter = new MValue(getValue(en.getValue()), Collections.emptyList()); - mParameter.setBounds(new Rectangle(0,0,bounds.width,20)); - parameters.put(en.getKey(), mParameter); + MLabelAndElement labelAndElement = new MLabelAndElement(en.getValue().comment, element); + labelAndElement.setBounds(new Rectangle(0,0,bounds.width,20)); + parameters.put(en.getKey(), parameter); + le.add(labelAndElement); } } } @@ -108,7 +140,7 @@ public class CategoryEditPane extends MPanel implements DynamicEditor { @Override public List<MPanel> getChildComponents() { - ArrayList<MPanel> panels = new ArrayList<MPanel>(parameters.values()); + ArrayList<MPanel> panels = new ArrayList<MPanel>(le); panels.add(save); return panels; } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java index 866951ab..18aeef41 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java @@ -39,11 +39,11 @@ public class MButton extends MPanel { Gui.drawRect(0,0,bounds.width, bounds.height, bg.getRGB()); FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; - int width = renderer.getStringWidth(text); + int width = renderer.getStringWidth(getText()); int x = (bounds.width - width) / 2; int y = (bounds.height - renderer.FONT_HEIGHT) / 2; - renderer.drawString(text, x,y, foreground.getRGB()); + renderer.drawString(getText(), x,y, foreground.getRGB()); } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MIntegerSelectionButton.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MIntegerSelectionButton.java index 9ba6350a..fc5ef5c0 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MIntegerSelectionButton.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MIntegerSelectionButton.java @@ -31,6 +31,7 @@ public class MIntegerSelectionButton extends MPanel { public void edit(String str) { try { data = Integer.parseInt(str); + onUpdate.run(); } catch (Exception e) {} } }; updateSelected(); add(selected); |