YetAnotherConfigLib 3.2.1 for 1.20.2
Changes
Config API
- Added
ConfigClassHandler#save
andConfigClassHandler#load
and deprecatedConfigClassHandler#serializer
.- The serializer should now never be called directly.
- New load method tells serializer to load into a new instance of the config class. Only applied if the load was fully successful.
- Deprecated
ConfigSerializer#load
forConfigSerializer#loadSafely
.
- Added new parameter on
SerialEntry
, calledrequired
.- If set to true, and the entry is not found in the config, the config will be re-saved with the default value.
- If set to false, and the entry is not found in the config, the default value will be used, but the config will not be re-saved.
- Added new parameter on
SerialEntry
, callednullable
.- If set to false, and the entry is found in the config, but the value is null, the default value will be used, and the config will be re-saved.
Bug Fixes
- Fixed error when using the same image twice.
- Removed debug log from WEBP and GIF image loaders.
YetAnotherConfigLib 3.2 for 1.20.1 & 1.20.0
The artifact for this release is
dev.isxander.yacl:yet-another-config-lib-fabric:3.2.0+1.20
(assuming Fabric)
Config API V2
Starting this update, the previous config api is now deprecated.
The new API is much more modular, and is now fully API-safe.
What does it look like?
public class MyConfig {
public static final ConfigClassHandler<MyConfig> HANDLER = ConfigClassHandler.createBuilder(MyConfig.class)
.id(new ResourceLocation("my_mod", "my_config")) // unique ID for your config
.serializer(config -> GsonConfigSerializerBuilder.create(config)
.setPath(FabricLoader.getInstance().getConfigDir().resolve("my_config.json"))
.setJson5(true) // json5 support, with GSON!
.build())
.build();
@SerialEntry(comment = "optional comment!")
public boolean myOption = true;
public static void save() {
MyConfig.HANDLER.serializer().save();
}
public static void load() {
MyConfig.HANDLER.serializer().load();
}
}
As you can see from the above example, it's syntactically quite similar to the old API, but with a few key differences:
- The method of serialization has been separated from the class handler itself, allowing an API safe implementation without needing to override the class handler.
- Supports abstract serialization.
- Names make a lot more sense.
Auto-gen
The new API can now fully auto-generate your config into a YACL GUI with annotations. I have been very wary of this feature, since usually it can be very limiting, destroying most of the core values of the powerful YACL builder interface. However, I believe I've found a great modular way so that developers can extend the auto-gen feature with their own custom annotations, adding support for their own custom controllers!
public class MyConfig {
public static final ConfigClassHandler<MyConfig> HANDLER = ConfigClassHandler.createBuilder(MyConfig.class)
.id(new ResourceLocation("my_mod", "my_config")) // unique ID for your config
.serializer(config -> GsonConfigSerializerBuilder.create(config)
.setPath(FabricLoader.getInstance().getConfigDir().resolve("my_config.json"))
.setJson5(true) // json5 support, with GSON!
.build())
.build();
@AutoGen(category = "my_category", group = "my_group")
@Boolean(formatter = Boolean.Formatter.YES_NO, colored = true)
public boolean myOption = true;
public static Screen createScreen(Screen parent) {
return MyConfig.HANDLER.generateGui().generateScreen(parent);
}
}
Above is an example of auto-generating a BooleanController
. Notice how
the field does not require @SerialEntry
. These are completely separate,
and you can use both at the same time.
For the full range of auto-gen annotations, check the source!
Documentation for the new API is still a work in progress. For now, it's best
to look at the following class: dev.isxander.yacl3.test.AutogenConfigTest
(not available on the artifact).
Fix Sodium crash
This is bringing the off-branch hotfix 3.1.1 to the main branch.
Dropdown controllers
Crendgrim has PRed a dropdown controller! Which is in this release!
This adds two new controller builders, DropdownStringControllerBuilder
and ItemControllerBuilder
.
The latter renders the item in the dropdown, and suggests only the items.
YetAnotherConfigLib 3.2 for 1.20.2
The artifact for this release is
dev.isxander.yacl:yet-another-config-lib-fabric:3.2.0+1.20.2
(assuming Fabric)
Config API V2
Starting this update, the previous config api is now deprecated.
The new API is much more modular, and is now fully API-safe.
What does it look like?
public class MyConfig {
public static final ConfigClassHandler<MyConfig> HANDLER = ConfigClassHandler.createBuilder(MyConfig.class)
.id(new ResourceLocation("my_mod", "my_config")) // unique ID for your config
.serializer(config -> GsonConfigSerializerBuilder.create(config)
.setPath(FabricLoader.getInstance().getConfigDir().resolve("my_config.json"))
.setJson5(true) // json5 support, with GSON!
.build())
.build();
@SerialEntry(comment = "optional comment!")
public boolean myOption = true;
public static void save() {
MyConfig.HANDLER.serializer().save();
}
public static void load() {
MyConfig.HANDLER.serializer().load();
}
}
As you can see from the above example, it's syntactically quite similar to the old API, but with a few key differences:
- The method of serialization has been separated from the class handler itself, allowing an API safe implementation without needing to override the class handler.
- Supports abstract serialization.
- Names make a lot more sense.
Auto-gen
The new API can now fully auto-generate your config into a YACL GUI with annotations. I have been very wary of this feature, since usually it can be very limiting, destroying most of the core values of the powerful YACL builder interface. However, I believe I've found a great modular way so that developers can extend the auto-gen feature with their own custom annotations, adding support for their own custom controllers!
public class MyConfig {
public static final ConfigClassHandler<MyConfig> HANDLER = ConfigClassHandler.createBuilder(MyConfig.class)
.id(new ResourceLocation("my_mod", "my_config")) // unique ID for your config
.serializer(config -> GsonConfigSerializerBuilder.create(config)
.setPath(FabricLoader.getInstance().getConfigDir().resolve("my_config.json"))
.setJson5(true) // json5 support, with GSON!
.build())
.build();
@AutoGen(category = "my_category", group = "my_group")
@Boolean(formatter = Boolean.Formatter.YES_NO, colored = true)
public boolean myOption = true;
public static Screen createScreen(Screen parent) {
return MyConfig.HANDLER.generateGui().generateScreen(parent);
}
}
Above is an example of auto-generating a BooleanController
. Notice how
the field does not require @SerialEntry
. These are completely separate,
and you can use both at the same time.
For the full range of auto-gen annotations, check the source!
Documentation for the new API is still a work in progress. For now, it's best
to look at the following class: dev.isxander.yacl3.test.AutogenConfigTest
(not available on the artifact).
Fix Sodium crash
This is bringing the off-branch hotfix 3.1.1 to the main branch.
Dropdown controllers
Crendgrim has PRed a dropdown controller! Which is in this release!
This adds two new controller builders, DropdownStringControllerBuilder
and ItemControllerBuilder
.
The latter renders the item in the dropdown, and suggests only the items.
YetAnotherConfigLib v3.1.1 for 1.19.4
Rewrote gui-scope ImageRenderer
API
The ImageRenderer
API has been rewritten internally to use a dual-thread
initialization. Before, GL calls were made on a separate thread, which silently
threw errors. Sodium 0.5 introduced an option called No Error Context
, which turned
these warnings into complete JVM crashes.
Because of this, this rewrite was unavailable.
In the process of a huge YACL update, this commit was buried under a lot more changes that are not ready for production yet, so I decided to branch from 3.1.0 and cherrypick this commit to fix the issue.
Does it affect me as a developer?
Most likely not, declaring images through OptionDescription.Builder
is unaffected as that
is part of the safe API. However, if you use the ImageRenderer
directly to create your own
custom renderers, you will have to update your code to use the new API.
Does it affect me as a user?
Most likely, yes. Zoomify and a few other popular mods use the ImageRenderer
API directly,
these mods will need updating, and will fail to load the images or even crash if they are not updated.
YetAnotherConfigLib v3.1.1 for 1.20.1
Rewrote gui-scope ImageRenderer
API
The ImageRenderer
API has been rewritten internally to use a dual-thread
initialization. Before, GL calls were made on a separate thread, which silently
threw errors. Sodium 0.5 introduced an option called No Error Context
, which turned
these warnings into complete JVM crashes.
Because of this, this rewrite was unavailable.
In the process of a huge YACL update, this commit was buried under a lot more changes that are not ready for production yet, so I decided to branch from 3.1.0 and cherrypick this commit to fix the issue.
Does it affect me as a developer?
Most likely not, declaring images through OptionDescription.Builder
is unaffected as that
is part of the safe API. However, if you use the ImageRenderer
directly to create your own
custom renderers, you will have to update your code to use the new API.
Does it affect me as a user?
Most likely, yes. Zoomify and a few other popular mods use the ImageRenderer
API directly,
these mods will need updating, and will fail to load the images or even crash if they are not updated.
YetAnotherConfigLib 3.1.0 for 1.20
API Changes
ListOption
changes
A PR by Crendgrim - thanks a lot!
- Allow to specify size limits for option lists.
- This allows to set a minimum and maximum length for the option list with the
minimumNumberOfEntries
andmaximumNumberOfEntries
builder methods.
- This allows to set a minimum and maximum length for the option list with the
- Allow "reversed" lists that add new options at their end.
- List options until now always grew at the top. This patch allows you to manipulate this behaviour with the
insertEntriesAtEnd
builder method.
- List options until now always grew at the top. This patch allows you to manipulate this behaviour with the
ImageRenderer
changes
Added a tick()
method to image renderers that allows to update the image in a regular interval.
Bug Fixes
- Fixed a bug where image renderers were rendered twice per frame.
- Updated the ImageIO dependency to fix sometimes buggy animated WebP rendering.
- Fixed the name of the list being rendered on every entry of said list.
Language Updates
- Added Tatar translation (by Amirhan-Taipovjan-Greatest-I)
YetAnotherConfigLib 3.1.0 for 1.19.4
API Changes
ListOption
changes
A PR by Crendgrim - thanks a lot!
- Allow to specify size limits for option lists.
- This allows to set a minimum and maximum length for the option list with the
minimumNumberOfEntries
andmaximumNumberOfEntries
builder methods.
- This allows to set a minimum and maximum length for the option list with the
- Allow "reversed" lists that add new options at their end.
- List options until now always grew at the top. This patch allows you to manipulate this behaviour with the
insertEntriesAtEnd
builder method.
- List options until now always grew at the top. This patch allows you to manipulate this behaviour with the
ImageRenderer
changes
Added a tick()
method to image renderers that allows to update the image in a regular interval.
Bug Fixes
- Fixed a bug where image renderers were rendered twice per frame.
- Updated the ImageIO dependency to fix sometimes buggy animated WebP rendering.
- Fixed the name of the list being rendered on every entry of said list.
Language Updates
- Added Tatar translation (by Amirhan-Taipovjan-Greatest-I)