Add docs to main branch

This commit is contained in:
JFronny 2021-08-30 14:38:03 +02:00
parent 9809602b7f
commit cf06621b2e
No known key found for this signature in database
GPG Key ID: BEC5ACBBD4EE17E5
18 changed files with 498 additions and 1 deletions

View File

@ -8,4 +8,4 @@ An example for the frex/canvas integration can be found [here](https://gitlab.co
You will just need to install Respackopts. A menu button will appear besides all supported resourcepacks.\
You can get the latest debug build [here](https://gitlab.com/jfmods/respackopts/-/jobs/artifacts/master/raw/latest.jar?job=build_test) and the latest stable build [here](https://modrinth.com/mod/respackopts)
## Resource pack authors
You can head to the [wiki](https://gitlab.com/jfmods/respackopts/-/wikis/home) for details.
You can head to the [wiki](https://gitlab.com/jfmods/respackopts/-/tree/master/docs) for details.

141
docs/MainConfig.md Normal file
View File

@ -0,0 +1,141 @@
# ResourcePackOpts Config.
### Location (ResourcePacks).
> `/assets/respackopts/conf.json`
### Location (DataPacks).
> `/data/respackopts/conf.json`
## What needs to be here.
```json
{
"id": "<PackID>",
"version": 5,
"capabilities": ["FileFilter", "DirFilter"],
"conf": {
// Your config options here
}
}
```
### Capabilities:
> **FileFilter:** (Default Enabled) <br> If stated will enable file filtering functionality.
> **DirFilter:** (Default Disabled) <br> If stated will enable folder filtering functionality.
> **DirFilterAdditive:** (Default Disabled) <br> If stated this will enable a compatibility fix for some mods that also modify resources.
## Adding a Toggle/Boolean
To add a boolean entry, add code like this: `"EntryName": <Default Option (true/false)>`
### Example:
```json
{
"id": "ExamplePack",
"version": 5,
"capabilities": ["FileFilter", "DirFilter"],
"conf": {
"SomeTexture": true,
"SomeOtherTexture": false
}
}
```
### Result:
![configExampleBolean](./img/ExamplePackBoolean.png "ConfigExampleBolean")
### See [Togglefiles](./ToggleFiles.md) to see the logic behind this
## Adding a Free Number Box
A number box follows the same principle as a boolean: `"entryName": DefaultNumber`
*please note any value can be put in here with no limit*
### Example:
```json
{
"id": "ExamplePack",
"version": 5,
"capabilities": ["FileFilter", "DirFilter"],
"conf": {
"SomeOption": 10
}
}
```
### Result:
![configExampleNumber](./img/ExamplePackNumber.png "ConfigExampleNumber")
## Adding a slider
A slider is slightly more complicated as a minimum and a maximum need to be defined. Sliders also only support whole numbers.
### Example:
```json
{
"id": "ExamplePack",
"version": 5,
"capabilities": ["FileFilter", "DirFilter"],
"conf": {
"SomeOption": {
"min": 0,
"default": 5,
"max": 10
}
}
}
```
### Result:
![configExampleSlider](./img/ExamplePackSlider.png)
## Select From a list
To allow users to select one entry from a list, you can use a json array with string entries. *Numbers/etc are not supported*
### Example:
```json
{
"id": "ExamplePack",
"version": 5,
"capabilities": ["FileFilter", "DirFilter"],
"conf": {
"SomeOption": [
"option_one",
"option_two",
"option_three"
]
}
}
```
### Result:
![configExampleEnum](./img/ExamplePackEnum.png)
## Make a category
### Example:
```json
{
"id": "ExamplePack",
"version": 5,
"capabilities": ["FileFilter", "DirFilter"],
"conf": {
"SomeCategory": {
"SomeBoleanOption": true,
"SomeNumberOption": 5,
"SomeSelectionOption": [
"option_one",
"option_two",
"option_three"
],
"SomeSliderOption": {
"min": 0,
"default": 5,
"max": 10
}
},
"SomeotherCategory": {
"SomeOtherBoleanOption": true,
"SomeOtherNumberOption": 5
}
}
}
```
### Result:
![configExampleCategory](./img/ExamplePackCategory.png)

View File

@ -0,0 +1,63 @@
# ResPackOpts Multi File Toggle (Multi Selction)
This Allows you to pick between multiple files (3 or more files) using similar logic to [Toggle Files](./ToggleFiles.md)
But this requires multiple `.rpo` files to achieve the desired goal.
You will need the `PackID` and `EntryName` from your `/assets/respackopts/conf.json` that you created earlier
if you have not, see [Main Config](./MainConfig.md) on how to do so.
<br>
You will need to navigate to the file you would like to toggle inside your resource, and create a `.rpo` file for it in the same folder(directory).
<br>
### Examples:
`texture.png` would be `texture.png.rpo`<br>
`SomeRecipe.json` would be `SomeRecipe.json.rpo`
<br>
### `.rpo` explaination :
You need a `.rpo` file per texture (except for the last one in your list) if you have 3 files to select beteen then you will need 2 `.rpo` files, If you have 4 files to select between then you will need 3 `.rpo` files and so on etc.....
### Layout:
This is your first `.rpo` with your first file
```json
{
"condition": "<your pack id>:<your entry>",
"fallback": "path/to/second.rpo"
}
```
***
This is your second `.rpo` with your second file
```json
{
"condition": "<your pack id>:<your entry>",
"fallback": "path/to/thirdfile.json/.png"
}
```
### Example:
```json
{
"condition": "ExamplePack:option_one",
"fallback": "path/to/secondfile.rpo"
}
```
```json
{
"condition": "ExamplePack:option_two",
"fallback": "path/to/thirdfile.json"
}
```

30
docs/README.md Normal file
View File

@ -0,0 +1,30 @@
# ResPackOpts Home
Here is everything you need to know about configuring your resource with respackopts.
### Downloads
- **Modrinth:** https://modrinth.com/mod/respackopts
- **CurseForge:** https://www.curseforge.com/minecraft/mc-mods/respackopts
### Dependencies
- [ClothConfigAPI](https://www.curseforge.com/minecraft/mc-mods/cloth-config/)
- [LibJF](https://modrinth.com/mod/libjf)
- [ModMenu](https://www.curseforge.com/minecraft/mc-mods/modmenu){Optional}
### Compatibility
- Canvas Shaders
- Resource Packs
- DataPacks
### Features
| Feature | Status |
| --------------------- | ------ |
| Bolean Based Toggle | ✅ |
| Bolean fallback files | ✅ |
| slider configs | ✅ |
| number input configuration | ✅ |
| If not,And,Or, Nor, Xor, Eq Operations | ✅ |
| Text file modification using [Starscript](https://github.com/MeteorDevelopment/starscript/wiki) | ✅ |
| Directory .rpo support | 🔄 |

31
docs/ToggleFiles.md Normal file
View File

@ -0,0 +1,31 @@
# ResPackOpts Toggle Files (Bolean Based logic)
This is a simple `IF` satment simply returning true/false to if the texture/file should be loaded into the pack.
(Turns the texture "on" or "off").
You will need the `PackID` and `EntryName` from your `/assets/respackopts/conf.json` that you created earlier
if you have not, see [Main Config](./MainConfig.md) on how to do so.
<br>
You will need to navigate to the file you would like to toggle inside your resource, and create a `.rpo` file for it in the same folder(directory).
<br>
### Examples:
`texture.png` would be `texture.png.rpo`<br>
`SomeRecipe.json` would be `SomeRecipe.json.rpo`
<br>
### Layout:
```json
{
"condition": "<your pack id>:<your entry>"
}
```
### Example:
```json
{
"condition": "ExamplePack:SomeTexture"
}
```
---
### See [Toggle Files With Fallback](./ToggleFilesWithFallback.md) to see how to swap textures out with each other (alternate Options)

View File

@ -0,0 +1,33 @@
# ResPackOpts Toggle Files With A Fallback Option (Alternate Files)
This is a simple `IF` satment simply returning true/false to if the texture/file should be loaded into the pack.
(Pick one file over another).
You will need the `PackID` and `EntryName` from your `/assets/respackopts/conf.json` that you created earlier
if you have not, see [Main Config](./MainConfig.md) on how to do so.
<br>
You will need to navigate to the file you would like to toggle inside your resource, and create a `.rpo` file for it in the same folder(directory).
<br>
### Examples:
`texture.png` would be `texture.png.rpo`<br>
`SomeRecipe.json` would be `SomeRecipe.json.rpo`
<br>
### Layout:
```json
{
"condition": "<your pack id>:<your entry>",
"fallback": "location/of/the/file"
}
```
### Example:
```json
{
"condition": "ExamplePack:Texture",
"fallback": "assets/respackopts/examplealternatefiles/SomeTexture.json"
}
```
---
### See [Toggle Files ](./ToggleFiles.md) to see how to just disable files.

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -0,0 +1,44 @@
# Adding entries
Entry names may only contain normal characters (a-z and uppercase). Anything else will still work but may cause unexpected behavior.
You may use the translations system of minecraft to localize names and display more characters.
# Adding translations/tooltips
To add translations, better names or tooltips, you need to supply a language file (`en_us.json` for example)
Normal translations for entries will be named `rpo.<your pack>.<entry>`
You can also add tooltips with `rpo.tooltip.<your pack>.<entry>`
# Adding an entry
## Toggle/Boolean
To add a boolean entry, add code like this: `"entryName": true` (You can also set it to `false`) inside your `conf` block
## Number box
A number box follows the same principle as a boolean: `"entryName": 10.8` is a possible entry.
## Slider
A slider is slightly more complicated as a minimum and a maximum need to be defined. Sliders also only support whole numbers.
Example:
```json
"entryName": {
"min": 15,
"default": 16,
"max": 20
}
```
A slider will only be shown if the value names inside the block are exactly the same, otherwise this will be treated as a category.
## Select from list
To allow users to select one entry from a list, you can use a json array with string entries. Numbers/etc are not supported.
Example:
```json
"entryName": [
"option_one",
"option_two",
"option_three"
]
```
## Categories
A category is a normal json object. It can contain entries of any type, including other categories.
Example:
```json
"entryName": {
"someEntry": true,
"someOtherEntry": 15
}
```
# Example
You can find an example pack configuration [here](https://gitlab.com/jfmods/respackopts/-/blob/master/run/resourcepacks/lumi/assets/respackopts/conf.json)

18
docs/old/canvas.md Normal file
View File

@ -0,0 +1,18 @@
# Canvas
To use respackopts in your shader, you can `#include respackopts:config_supplier`
This will import sanitized entries for all packs.
You may access them as `<id>_<entry>` or `<id>_<category>_<entry>`
Entries will be expressed as follows:
| Type | Type in shader |
--|--
| Boolean | Will either be `#define`d or not, use `#ifdef` |
| Numeric | Will be defined as a number you can use directly |
| Enum | First, a number entry will be `#define`d. You may check if a specific value is selected via `<id>_<entry>_<value>` which will be handled like booleans |
If respackopts is not present, the `#include` will not break the code,
though you may want to define default values yourself.
You can check whether the config supplier is properly imported through `#ifdef respackopts_loaded`
## V1 enums
In respackopts v1 shaders, enums values are expressed by their ints and need to be
compared to the value of the main entry.

44
docs/old/conditional.md Normal file
View File

@ -0,0 +1,44 @@
# Conditional Resources
Conditional resoures are the simplest use case of respackopts.
To add one, you will need to create an rpo file for your resource.
It needs to be titled by appending `.rpo` to the files name.
For example: If you want `/assets/minecraft/lang/en_us.json` to be configurable, you will need to create `/assets/minecraft/lang/en_us.json.rpo`
If you only want a simple condition, you can use the following template:
```json
{
"conditions": [
"<your pack id>:<your entry>"
]
}
```
You can simply copy the id from your conf.json. The entry will be the name of the entry for things directly under `conf`,
otherwise it will be `category.entry`. For nested categories, names will follow the same schema.
If you have an enum entry ("Select from list"), it will be `category.entry.option`
## Logic
You may also use logic to determine whether conditions are met.
This might look like the following example:
```json
"conditions": [
"example:option1",
{
"or": [
"example:option2",
"example:option3",
{
"and": [
"example:option4",
"example:option5"
]
}
]
}
]
```
The follwing conditions are supported:
| Name | Function |
--|--
| and | True if all subconditions are met |
| or | True if at least one subcondition is met |
| xor | True if an uneven number of subconditions is met |
| nor | True if none od the subconditions are met |
| eq | True if all of the subconditions have the same result |

29
docs/old/expand.md Normal file
View File

@ -0,0 +1,29 @@
You can use the `expansions` block in your .rpo to replace content with a value computed through executing a custom [starscript](https://github.com/MeteorDevelopment/starscript/wiki).\
All values are available in starscript like this: `<pack id>.<entry>`\
## Example:
en_us.json.rpo:
```
"expansions": {
"lights": "{lumi.subcategoryTest.enableLang}",
"mode": "{lumi.debugMode}",
"normal": "{lumi.numTest * lumi.subcategoryTest.numberInSub}",
"lumi": "model",
"regeneration": "Industrie"
}
```
en_us.json:
```
{
"rpo.lumi": "${lumi} ${lights}",
"rpo.lumi.tonemap": "Tonemap mode",
"rpo.tooltip.lumi.tonemap": "Tooltip test",
"rpo.lumi.pbr": "Enable PBR",
"rpo.lumi.debugMode": "Debug Mode",
"rpo.lumi.debugMode.normal": "${normal} Mode",
"rpo.lumi.waterVertexWavy": "Wavy water model",
"rpo.tooltip.lumi.subcategoryTest.sliderTest": "Yayyy"
}
```
# Explanation
The expansions block contains a key ("lights") and a script, which is executed when the file is loaded. All instances of the key (formatted as ${name} -> ${lights} in this example) will be replaced by the result of the script. Make sure to only use this feature on text files as unexpected results my occur otherwise

23
docs/old/fallbacks.md Normal file
View File

@ -0,0 +1,23 @@
# Fallback resources
You can select an option by providing a fallback in addition to conditions.
If the conditions are not met, fallbacks will be used. If the first callback can't be used,
A later one will be tried. If none can be used, the resource will be ignored.
## Example
```json
{
"conditions": [
{
"not": [
"example:useAlternate"
]
}
],
"fallbacks": [
"assets/minecraft/lang/en_us_alternate.json"
]
}
```
## Multiple alternatives
A fallback resource may provide their own conditions or fallbacks which will also be considered
and can be used to allow users to select one of multiple resources

25
docs/old/home.md Normal file
View File

@ -0,0 +1,25 @@
# Getting started
Before you can start using respackopts, you will need to create a respackopts conf file for your pack. This file will be located in `/assets/respackopts/conf.json` of your resource pack (or `/data/respackopts/conf.json` if you are creating a data pack). You will need to create the respackopts dir yourself. The basic layout is as follows:
```json
{
"id": "<An identifier for your resource pack>",
"version": 3,
"conf": {
// Your config screen
}
}
```
Please note that the id as well as any entry should be written in camelCase, while this is technically not required, I would still recommend it. You add entries by simply putting them inside the "conf" block. More details of what entries are supported may be found [here](https://gitlab.com/jfmods/respackopts/-/wikis/adding_entries) Once you have created your config screen, you will need to actually use the entries you defined. How that is done depends on where you will use them. Generally you can:
* [Enable/Disable certain resources](https://gitlab.com/jfmods/respackopts/-/wikis/conditional) (Example: toggleable texture)
* [Select one of multiple alternative resources](https://gitlab.com/jfmods/respackopts/-/wikis/fallbacks) (Example: select one of many texures)
* [Use values in canvas/frex shaders](https://gitlab.com/jfmods/respackopts/-/wikis/canvas)
* [Replace content in a file based on your config](https://gitlab.com/jfmods/respackopts/-/wikis/expand)
If you are interested in how respackopts works or what changed between versions, you can look [here](https://gitlab.com/jfmods/respackopts/-/wikis/how_it_works)
## Tricks
* Since vanilla minecraft ignores .rpo files, you can use them to load files only if rpo is present by using `"conditions": ["false"]` and a fallback texture (`"true"` is also a key that is always defined in conditional resources)

16
docs/old/how_it_works.md Normal file
View File

@ -0,0 +1,16 @@
# How it works
## Format changes
### V1 to V2
The way enums are expressed for canvas shaders was changed,
now values are no longer constant numbers but instead booleans expressing whether they are selected.
## A quick tour
In ResourcePackManagerMixin, the conf.json will be parsed and saved to a map in the main class.
Now, whenever a resource is accessed, the mixins under conditions/ will check if a .rpo file exists
for the current resource and parse it if that is the case.
If a resource is "hidden", openFile will throw a FileNotFoundException and containsFile will return false,
essentialy preventing the game from even knowing the resource exists.
## Canvas integration
Grondag implemented an API into frex to allow RPO to supply a custom shader file which other may include,
the code is generated by each individual entry class.