diff --git a/_logo files/Menu-LOD-BW.png b/_logo files/Menu-LOD-BW.png new file mode 100644 index 000000000..4557aceaf Binary files /dev/null and b/_logo files/Menu-LOD-BW.png differ diff --git a/_logo files/Menu-LOD-Button.png b/_logo files/Menu-LOD-Button.png new file mode 100644 index 000000000..5d87b06bd Binary files /dev/null and b/_logo files/Menu-LOD-Button.png differ diff --git a/_logo files/Menu-LOD.png b/_logo files/Menu-LOD.png new file mode 100644 index 000000000..b1b90af24 Binary files /dev/null and b/_logo files/Menu-LOD.png differ diff --git a/fabric/src/main/resources/assets/lod/lang/en_us.json b/common/src/main/resources/assets/lod/lang/en_us.json similarity index 100% rename from fabric/src/main/resources/assets/lod/lang/en_us.json rename to common/src/main/resources/assets/lod/lang/en_us.json diff --git a/common/src/main/resources/assets/lod/textures/gui/button.png b/common/src/main/resources/assets/lod/textures/gui/button.png new file mode 100644 index 000000000..5d87b06bd Binary files /dev/null and b/common/src/main/resources/assets/lod/textures/gui/button.png differ diff --git a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinOptionsScreen.java b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinOptionsScreen.java index fe06b0da1..292680408 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinOptionsScreen.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinOptionsScreen.java @@ -35,7 +35,7 @@ public class MixinOptionsScreen extends Screen { private void lodconfig$init(CallbackInfo ci) { this.addRenderableWidget(new TexturedButtonWidget( // Where the button is on the screen - this.width / 2 + 159, this.height / 6 - 12, + this.width / 2 - 180, this.height / 6 - 12, // Width and height of the button 20, 20, // Offset diff --git a/fabric/src/main/java/com/seibel/lod/fabric/wrappers/config/ConfigGui.java b/fabric/src/main/java/com/seibel/lod/fabric/wrappers/config/ConfigGui.java index d8bb418fb..2295c0edc 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/wrappers/config/ConfigGui.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/wrappers/config/ConfigGui.java @@ -52,31 +52,45 @@ import java.util.regex.Pattern; * Credits to Minenash, TeamMidnightDust & Motschen * * @author coolGi2007 - * @version 11-28-2021 + * @version 12-03-2021 */ @SuppressWarnings("unchecked") public abstract class ConfigGui { /* - Small wiki on how to use this config + Small wiki on how to use this config - Create a new class that extends this class - Every time you want to add a button put a @Entry before it and if you want it to be within a range then do @Entry(min = 0, max = 10) - MAKE SURE THE VARIABLE YOU ARE PUTTING IN IS A STATIC VARIABLE + Create a new class that extends this class + Every time you want to add a button put a @Entry before it and if you want it to be within a range then do @Entry(min = 0, max = 10) + MAKE SURE THE VARIABLE YOU ARE PUTTING IN IS A STATIC VARIABLE - If you want to make a config asking if you want coolness then do this + If you want to make a config asking if you want coolness then do this - public class Config extends ConfigGui { - @Entry - public static bool coolness = false; - } + public class Config extends ConfigGui { + @Entry + public static bool coolness = false; + } - If you want a comment then do this + If you want a comment then do this @Comment public static Comment text1; FOR THE CONFIG TO SHOW you need to have this somewhere in the main class ConfigGui.init(ModInfo.ID, Config.class); + + For putting nested classes do @ScreenEntry for example + + public class Config extends ConfigGui { + @Entry + public static bool coolness = false; + + public static NestedScreen nestedScreen = new NestedScreen(); + public static void NestedScreen() { + @Entry(min = 0, max = 100) + public static int howMuchCoolness = 0; + } + } + */ private static final Pattern INTEGER_ONLY = Pattern.compile("(-?[0-9]*)"); private static final Pattern DECIMAL_ONLY = Pattern.compile("-?([\\d]+\\.?[\\d]*|[\\d]*\\.?[\\d]+|\\.)"); @@ -109,10 +123,8 @@ public abstract class ConfigGui { for (Field field : config.getFields()) { EntryInfo info = new EntryInfo(); - if (field.isAnnotationPresent(Entry.class) || field.isAnnotationPresent(Comment.class)) - if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) initEntry(modid, field, info); - else if (field.isAnnotationPresent(ScreenEntry.class)) - if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) initScreen(modid, field, info); + if (field.isAnnotationPresent(Entry.class) || field.isAnnotationPresent(Comment.class) || field.isAnnotationPresent(ScreenEntry.class)) + if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) initClient(modid, field, info); if (field.isAnnotationPresent(Entry.class)) try { info.defaultValue = field.get(null); @@ -131,17 +143,21 @@ public abstract class ConfigGui { } } @Environment(EnvType.CLIENT) - private static void initEntry(String modid, Field field, EntryInfo info) { + private static void initClient(String modid, Field field, EntryInfo info) { Class type = field.getType(); Entry e = field.getAnnotation(Entry.class); + ScreenEntry s = field.getAnnotation(ScreenEntry.class); info.width = e != null ? e.width() : 0; info.field = field; info.id = modid; if (e != null) { - if (!e.name().equals("")) info.name = new TranslatableComponent(e.name()); - if (type == int.class) textField(info, Integer::parseInt, INTEGER_ONLY, e.min(), e.max(), true); - else if (type == double.class) textField(info, Double::parseDouble, DECIMAL_ONLY, e.min(), e.max(), false); + if (!e.name().equals("")) + info.name = new TranslatableComponent(e.name()); + if (type == int.class) + textField(info, Integer::parseInt, INTEGER_ONLY, e.min(), e.max(), true); + else if (type == double.class) + textField(info, Double::parseDouble, DECIMAL_ONLY, e.min(), e.max(), false); else if (type == String.class || type == List.class) { info.max = e.max() == Double.MAX_VALUE ? Integer.MAX_VALUE : (int) e.max(); textField(info, String::length, null, Math.min(e.min(), 0), Math.max(e.max(), 1), true); @@ -160,20 +176,15 @@ public abstract class ConfigGui { button.setMessage(func.apply(info.value)); }, func); } + } else if (s != null) { + if (!s.name().equals("")) info.name = new TranslatableComponent(s.name()); + Function func = value -> new TextComponent((Boolean) value ? "True" : "False").withStyle((Boolean) value ? ChatFormatting.GREEN : ChatFormatting.RED); + info.widget = new AbstractMap.SimpleEntry>(button -> { + button.setMessage(info.name); + }, func); } entries.add(info); } - @Environment(EnvType.CLIENT) - public static void initScreen(String modid, Field field, EntryInfo info) { -// entries.add(new Button(this.width / 2 - 100, this.height - 28, 200, 20, new TranslatableComponent(modid +".config.title"), (button) -> -// Objects.requireNonNull(minecraft).setScreen(ConfigGui.getScreen(this, modid)))); -// ButtonEntry.create( -// new Button(this.width / 2 - 100, this.height - 28, 200, 20, new TranslatableComponent(modid +".config.title"), (button) -> -// Objects.requireNonNull(minecraft).setScreen(ConfigGui.getScreen(this, modid))), -// new TranslatableComponent(modid +".config.title"), -// -// ); - } private static void textField(EntryInfo info, Function f, Pattern pattern, double min, double max, boolean cast) { boolean isNumber = pattern != null; @@ -442,6 +453,7 @@ public abstract class ConfigGui { @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface ScreenEntry { + String name() default ""; } // Where the @Comment is defined diff --git a/fabric/src/main/resources/assets/lod/textures/gui/button.png b/fabric/src/main/resources/assets/lod/textures/gui/button.png deleted file mode 100644 index 8c264bf9f..000000000 Binary files a/fabric/src/main/resources/assets/lod/textures/gui/button.png and /dev/null differ