mirror of
https://github.com/TeamMidnightDust/MidnightLib.git
synced 2025-12-16 17:25:09 +01:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2db6b33d30 | ||
|
|
c881db8be4 | ||
|
|
79eb8936ff |
@@ -13,9 +13,10 @@ import java.util.List;
|
|||||||
|
|
||||||
public class MidnightConfigExample extends MidnightConfig {
|
public class MidnightConfigExample extends MidnightConfig {
|
||||||
|
|
||||||
@Comment public static Comment text1; // Comments are rendered like an option without a button and are excluded from the config file
|
@Comment(category = "text") public static Comment text1; // Comments are rendered like an option without a button and are excluded from the config file
|
||||||
@Comment(centered = true) public static Comment text2; // Centered comments are the same as normal ones - just centered!
|
@Comment(category = "text", centered = true) public static Comment text2; // Centered comments are the same as normal ones - just centered!
|
||||||
@Entry public static boolean showInfo = true; // Example for a boolean option
|
@Comment(category = "text") public static Comment spacer1; // Comments containing the word "spacer" will just appear as a blank line
|
||||||
|
@Entry(category = "text") public static boolean showInfo = true; // Example for a boolean option
|
||||||
@Entry(category = "text") public static String name = "Hello World!"; // Example for a string option, which is in a category!
|
@Entry(category = "text") public static String name = "Hello World!"; // Example for a string option, which is in a category!
|
||||||
@Entry(category = "text") public static TestEnum testEnum = TestEnum.FABRIC; // Example for an enum option
|
@Entry(category = "text") public static TestEnum testEnum = TestEnum.FABRIC; // Example for an enum option
|
||||||
public enum TestEnum { // Enums allow the user to cycle through predefined options
|
public enum TestEnum { // Enums allow the user to cycle through predefined options
|
||||||
@@ -25,7 +26,7 @@ public class MidnightConfigExample extends MidnightConfig {
|
|||||||
@Entry(category = "numbers") public static double world = 1.4D; // Example for a double option
|
@Entry(category = "numbers") public static double world = 1.4D; // Example for a double option
|
||||||
@Entry(category = "numbers", min=69,max=420) public static int hello = 420; // - The entered number has to be larger than 69 and smaller than 420
|
@Entry(category = "numbers", min=69,max=420) public static int hello = 420; // - The entered number has to be larger than 69 and smaller than 420
|
||||||
@Entry(category = "text", width = 7, min = 7, isColor = true, name = "I am a color!") public static String titleColor = "#ffffff"; // The isColor property adds a preview box for a hexadecimal color
|
@Entry(category = "text", width = 7, min = 7, isColor = true, name = "I am a color!") public static String titleColor = "#ffffff"; // The isColor property adds a preview box for a hexadecimal color
|
||||||
@Entry(category = "sliders", name = "I am an array list!") public static List<String> arrayList = Lists.newArrayList("String1", "String2"); // Array String Lists are also supported
|
@Entry(category = "text", name = "I am an array list!") public static List<String> arrayList = Lists.newArrayList("String1", "String2"); // Array String Lists are also supported
|
||||||
@Entry(category = "sliders", name = "I am an int slider.",isSlider = true, min = 0, max = 100) public static int intSlider = 35; // Int fields can also be displayed as a Slider
|
@Entry(category = "sliders", name = "I am an int slider.",isSlider = true, min = 0, max = 100) public static int intSlider = 35; // Int fields can also be displayed as a Slider
|
||||||
@Entry(category = "sliders", name = "I am a float slider!", isSlider = true, min = 0f, max = 1f, precision = 1000) public static float floatSlider = 0.24f; // And so can floats! Precision defines the amount of decimal places
|
@Entry(category = "sliders", name = "I am a float slider!", isSlider = true, min = 0f, max = 1f, precision = 1000) public static float floatSlider = 0.24f; // And so can floats! Precision defines the amount of decimal places
|
||||||
// The name field can be used to specify a custom translation string or plain text
|
// The name field can be used to specify a custom translation string or plain text
|
||||||
|
|||||||
@@ -202,8 +202,9 @@ public abstract class MidnightConfig {
|
|||||||
public final String modid;
|
public final String modid;
|
||||||
public MidnightConfigListWidget list;
|
public MidnightConfigListWidget list;
|
||||||
public boolean reload = false;
|
public boolean reload = false;
|
||||||
public TabManager tabManager = new TabManager(a -> refresh(), a -> refresh());
|
public TabManager tabManager = new TabManager(a -> {}, a -> {});
|
||||||
public Tab prevTab;
|
public Tab prevTab;
|
||||||
|
public TabNavigationWidget tabNavigation;
|
||||||
public ButtonWidget done;
|
public ButtonWidget done;
|
||||||
|
|
||||||
// Real Time config update //
|
// Real Time config update //
|
||||||
@@ -242,6 +243,11 @@ public abstract class MidnightConfig {
|
|||||||
} catch (IllegalAccessException ignored) {}
|
} catch (IllegalAccessException ignored) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||||
|
if (this.tabNavigation.trySwitchTabsWithKey(keyCode)) return true;
|
||||||
|
return super.keyPressed(keyCode, scanCode, modifiers);
|
||||||
|
}
|
||||||
public Tooltip getTooltip(EntryInfo info) {
|
public Tooltip getTooltip(EntryInfo info) {
|
||||||
return Tooltip.of(info.error != null ? info.error : I18n.hasTranslation(translationPrefix+info.field.getName()+".tooltip") ? Text.translatable(translationPrefix+info.field.getName()+".tooltip") : Text.empty());
|
return Tooltip.of(info.error != null ? info.error : I18n.hasTranslation(translationPrefix+info.field.getName()+".tooltip") ? Text.translatable(translationPrefix+info.field.getName()+".tooltip") : Text.empty());
|
||||||
}
|
}
|
||||||
@@ -270,7 +276,7 @@ public abstract class MidnightConfig {
|
|||||||
} else e.tab = tabs.get(name);
|
} else e.tab = tabs.get(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TabNavigationWidget tabNavigation = TabNavigationWidget.builder(tabManager, this.width).tabs(tabs.values().toArray(new Tab[0])).build();
|
tabNavigation = TabNavigationWidget.builder(tabManager, this.width).tabs(tabs.values().toArray(new Tab[0])).build();
|
||||||
if (tabs.size() > 1) this.addDrawableChild(tabNavigation);
|
if (tabs.size() > 1) this.addDrawableChild(tabNavigation);
|
||||||
if (!reload) tabNavigation.selectTab(0, false);
|
if (!reload) tabNavigation.selectTab(0, false);
|
||||||
tabNavigation.init();
|
tabNavigation.init();
|
||||||
@@ -280,10 +286,6 @@ public abstract class MidnightConfig {
|
|||||||
loadValues();
|
loadValues();
|
||||||
Objects.requireNonNull(client).setScreen(parent);
|
Objects.requireNonNull(client).setScreen(parent);
|
||||||
}).dimensions(this.width / 2 - 154, this.height - 28, 150, 20).build());
|
}).dimensions(this.width / 2 - 154, this.height - 28, 150, 20).build());
|
||||||
|
|
||||||
this.list = new MidnightConfigListWidget(this.client, this.width, this.height, 32, this.height - 32, 25);
|
|
||||||
if (this.client != null && this.client.world != null) this.list.setRenderBackground(false);
|
|
||||||
this.addSelectableChild(this.list);
|
|
||||||
done = this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (button) -> {
|
done = this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (button) -> {
|
||||||
for (EntryInfo info : entries)
|
for (EntryInfo info : entries)
|
||||||
if (info.id.equals(modid)) {
|
if (info.id.equals(modid)) {
|
||||||
@@ -294,6 +296,11 @@ public abstract class MidnightConfig {
|
|||||||
write(modid);
|
write(modid);
|
||||||
Objects.requireNonNull(client).setScreen(parent);
|
Objects.requireNonNull(client).setScreen(parent);
|
||||||
}).dimensions(this.width / 2 + 4, this.height - 28, 150, 20).build());
|
}).dimensions(this.width / 2 + 4, this.height - 28, 150, 20).build());
|
||||||
|
|
||||||
|
this.list = new MidnightConfigListWidget(this.client, this.width, this.height, 32, this.height - 32, 25);
|
||||||
|
if (this.client != null && this.client.world != null) this.list.setRenderBackground(false);
|
||||||
|
this.addSelectableChild(this.list);
|
||||||
|
|
||||||
fillList();
|
fillList();
|
||||||
}
|
}
|
||||||
public void fillList() {
|
public void fillList() {
|
||||||
|
|||||||
@@ -30,6 +30,11 @@
|
|||||||
"eu.midnightdust.lib.config.AutoModMenu"
|
"eu.midnightdust.lib.config.AutoModMenu"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"depends": {
|
||||||
|
"fabric-models-v0": "*",
|
||||||
|
"fabric-resource-loader-v0": "*",
|
||||||
|
"minecraft": ">=1.19.4-rc.1"
|
||||||
|
},
|
||||||
|
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"midnightlib.mixins.json"
|
"midnightlib.mixins.json"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ yarn_mappings=1.19.4-pre4+build.1
|
|||||||
enabled_platforms=fabric
|
enabled_platforms=fabric
|
||||||
|
|
||||||
archives_base_name=midnightlib
|
archives_base_name=midnightlib
|
||||||
mod_version=1.2.0
|
mod_version=1.2.1
|
||||||
maven_group=eu.midnightdust
|
maven_group=eu.midnightdust
|
||||||
|
|
||||||
fabric_loader_version=0.14.17
|
fabric_loader_version=0.14.17
|
||||||
|
|||||||
Reference in New Issue
Block a user