-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/2.0-alpha.3'
- Loading branch information
Showing
23 changed files
with
187 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Adding Glass Config API | ||
|
||
You want to use GCAPI to handle your mod config? Great! | ||
|
||
You already have GCAPI in your workspace if you have [StationAPI](../../wiki/Setting-up-workspace). For the next steps, see [Using](Using.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Welcome to the Glass Config API wiki! | ||
|
||
[Adding GCAPI to your project](Adding.md) | ||
|
||
[Using GCAPI for your config](Using.md) | ||
|
||
[TODO for GCAPI](Todo.md) | ||
|
||
[Migrating from 1.0 to 2.0](Migration1.0.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
## Migrating from 1.0 to 2.0 | ||
|
||
Some breaking changes happened between these two versions, mostly for config factories, save/load listeners, and custom config entries. | ||
|
||
Anything that mixes into GCCore will likely no longer work, due to some invasive changes. | ||
|
||
NEW: | ||
- `ConfigEntry` | ||
- `reset(Ljava/lang/Object)V` | ||
- Used when resetting to a specified value. | ||
- `vanillaServerBehavior()V` | ||
- Called when joining a vanilla server. Make sure to check for the vanilla server annotations if you don't want to always do something on vanilla servers. | ||
- `@DefaultOnVanillaServer` | ||
- Resets the given field to default on joining a vanilla server. | ||
- `@ValueOnVanillaServer` | ||
- `stringValue`, `booleanValue` (`TriBoolean`), `intValue`, `floatValue`. | ||
- Fill one of these out, and it will be applied to the config field on joining a vanilla server. | ||
- Specifying an invalid value WILL result in a crash. | ||
- `TriBoolean` | ||
- Used in `@ValueOnVanillaServer`. | ||
- Has three states: `TRUE`, `FALSE`, `DEFAULT` (`null`). | ||
- `ConfigFactoryProvider` | ||
- `provideLoadTypeAdapterFactories(ImmutableMap.Builder)V` | ||
- An optional method for providing load type adapters. See `ExampleConfigEnumFactories` for an example. | ||
- `GeneratedConfig` | ||
- Implement this interface in your config classes to allow for picking the fields you want to load, and if you want the class itself to be loaded. | ||
|
||
CHANGED: | ||
- `GCCore` | ||
- Saving and loading got changed somewhat drastically. Reduced copy-paste code to almost nothing. | ||
- `ConfigFactoryProvider` | ||
- `provideLoadFactories` | ||
- Added a new parameter. The function is now `NonFunction`, and the new parameter is the default value, positioned after value. | ||
- `ConfigEntry` | ||
- `saveToField()V` is now used whenever saving the value stored to the config field. | ||
- `init(Screen,TextRenderer)V` no longer handles adding icons indicating server sync. | ||
- `PreConfigSavedListener` and `PostConfigLoadedListener` | ||
- A new `source` parameter was added. | ||
- See `EventStorage.EventSource` for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## Migrating from 2.0 to 3.0 | ||
|
||
A LOT of breaking changes happened between v2 and v3, the most important one being that GCAPI is now **part of StationAPI**, and proper config validation on load, along with in-game config editing for server admins. | ||
|
||
Most breaking changes are package changes, and annotation changes, with only one major change happening elsewhere for proper validation on load. | ||
|
||
- `@ConfigEntry` and `@ConfigCategory` now house all information about the field is on, removing the need for checking for 6 different annotations on load. | ||
- `@GConfig` had it's `primary` value removed, and instead replaced with `priority`. | ||
- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# TODO List | ||
Mostly for me. In rough order of priority weighted with estimated difficulty. | ||
|
||
1. Get people to actually use this and report issues and suggestions to me. | ||
2. Add the ability to easily and cleanly edit config fields programmatically. | ||
3. Add support for colours with an ingame colour picker. Adding an actual colour picker might be a pain the the arse. I have a couple of ideas on how to do this. | ||
4. Add field validation on game load. JSON files are not validated on load, currently. | ||
5. Add block and item selection support. Should be easy enough with StAPI registries. I currently cannot think of a good use for this config option yet, though. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
## Supported Types | ||
|
||
This is a limited list for now, but it's already easily doable by mods to add their own classes for use as config factories. | ||
|
||
The built-in factories are as follows: | ||
|
||
- java.lang.String | ||
- java.lang.Integer | ||
- java.lang.Float | ||
- java.lang.Boolean | ||
- java.lang.String[] | ||
- java.lang.Integer[] | ||
- java.lang.Float[] | ||
- [java.lang.Enum](Using.md#enums) | ||
|
||
Should this list ever fall out of date, see [DefaultFactoryProvider.java](../blob/master/src/main/java/net/glasslauncher/mods/api/gcapi/impl/config/factory/DefaultFactoryProvider.java). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
[Quick Usage](#quick-usage) | ||
[Categories](#categories) | ||
[Annotations](#annotations) | ||
[Multiplayer Syncing](#multiplayer-syncing) | ||
[Multiple Config Pages](#multiple-config-pages) | ||
[IMPORTANT NOTES](#important-notes) | ||
|
||
# Quick Usage | ||
|
||
1. Create an empty non-static class somewhere in your project. We will be using this later. | ||
2. Create an instantiated `public static final` field for your first config screen and annotate it with `@GConfig`, make sure the field's type is the class you just created. **Do not** put it inside your newly made class. (e.g. `public static final ExampleConfigClass config = new ExampleConfigClass()`) | ||
3. Fill out the required `value` and `visibleName` parameters on the [annotation](#Annotations). Value is the name of your config file. (e.g. `@GConfig(value = "config", visibleName = "My Config GUI")`) | ||
4. Go into your `fabric.mod.json` and add the snippet below inside your `entrypoints` section: | ||
``` | ||
"gcapi": [ | ||
"<path.to.the.class.containing.the.field.here>" | ||
] | ||
``` | ||
5. Now let's go back to the empty class you made earlier. | ||
6. Create some fields with the type you want ([Valid Types](Types)) and annotate them with `@ConfigName`, filling out the value parameter with what you'd like the user to see your option called in the config GUI. (e.g. `@ConfigName("My Config Field") public String myField = ""`) | ||
7. Done! You can use the field in your code, GCAPI will handle loading and syncing logic for you. | ||
|
||
# Categories | ||
To make a category, you will need to: | ||
1. Create a class that will represent your category and fill it with fields like normal, including the required [annotations](#Annotations). | ||
2. In the class where you want the category, add a `@ConfigCategory` annotation, and fill out the required value parameter. | ||
3. Done! You can have categories inside of categories if you so wish to. | ||
|
||
# Annotations | ||
| Annotation | Description | Required | | ||
|-----------------|----------------------------------------------------|:----------------------------------------------:| | ||
| @GConfig | Used by GCAPI to find your mod configs in a class. | <ul><li>- [x] (config class fields) </li></ul> | | ||
| @ConfigEntry | Holds all the metadata of a config entry. | <ul><li>- [x] (config fields) </li></ul> | | ||
| @ConfigCategory | Holds all the metadata of a config category. | <ul><li>- [x] (categories)</li></ul> | | ||
|
||
# Multiplayer Syncing | ||
Just set `multiplayerSynced` `ConfigEntry`/`ConfigCategory` annotation value to `false` on the field or categories you want synced with the server. | ||
|
||
# Multiple Config Pages | ||
Just add another `@GConfig` field, and if it's in a different class from the first one, add it's class to the `entrypoints` section in `fabric.mod.json` too. | ||
|
||
Buttons will be added at the top of the config page for your mod for navigating these. | ||
|
||
You are able to set a priority for these pages, with a lower number meaning it will appear sooner in the list. | ||
|
||
# Enums | ||
In 2.0.0, you can now use enums to create cycling config values. | ||
|
||
The catch is that you need to create your enum type, and provide a set of simple config factories. | ||
|
||
See [ExampleConfigEnum](../../src/test/java/net/modificationstation/sltest/gcapi/ExampleConfigEnum.java) and [ExampleConfigEnumFactories](../../src/test/java/net/modificationstation/sltest/gcapi/ExampleConfigEnumFactories.java) on how to do it. | ||
|
||
# Generated Configs | ||
In 2.0.0, you can now dynamically supply config categories and fields. | ||
|
||
Make your config category class, implement `GeneratedConfig`. | ||
|
||
# IMPORTANT NOTES | ||
|
||
- Use `GCAPI.reloadConfig` to manually set config values. This is to ensure mods are notified properly and can post-process things. | ||
- The config.json files are not sanitised or checked when loaded. This will be fixed in a later update once I figure out a good way to handle it. This is low on my list. | ||
- Servers are able to send whatever configs they want, so long as the config field on the client is MP syncable. The server doesn't even need to have the mod installed. This would require emulating GCAPI's config export code to do so, though. I'm not sure if I'll patch this. It seems like it would have its uses. |
5 changes: 0 additions & 5 deletions
5
...nfig-api-v3/src/main/java/net/modificationstation/stationapi/impl/config/NonFunction.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...pi/impl/config/example/ExampleConfig.java → ...onstation/sltest/gcapi/ExampleConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...config/example/ExampleConfigCategory.java → ...n/sltest/gcapi/ExampleConfigCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...fig/example/ExampleConfigCategoryTwo.java → ...ltest/gcapi/ExampleConfigCategoryTwo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...pl/config/example/ExampleConfigClass.java → ...tion/sltest/gcapi/ExampleConfigClass.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...mpl/config/example/ExampleConfigEnum.java → ...ation/sltest/gcapi/ExampleConfigEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...g/example/ExampleConfigEnumFactories.java → ...est/gcapi/ExampleConfigEnumFactories.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...g/example/ExampleEntryPointListeners.java → ...est/gcapi/ExampleEntryPointListeners.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...mpl/config/example/SecondConfigClass.java → ...ation/sltest/gcapi/SecondConfigClass.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...impl/config/example/ThirdConfigClass.java → ...tation/sltest/gcapi/ThirdConfigClass.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters