Skip to content

Commit a26d436

Browse files
committed
Merge branch 'multiversion/dev' into feature/splitscreen
2 parents 7e78872 + f9e38f9 commit a26d436

17 files changed

+168
-58
lines changed

docs/developers/_meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"getting-started.mdx": "Getting Started",
23
"controlify-entrypoint.mdx": "Controlify Entrypoint",
34
"bindings-api.mdx": "Bindings API",
45
"screen-operation-api.mdx": "Screen Operation API"

docs/developers/bindings-api.mdx

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@ _Learn how to register new controller bindings._
77
## Registering a custom input binding
88

99
<Callout variant="info">
10-
You should register bindings inside of the Controlify init entrypoint. Read more in [Controlify Entrypoint](controlify-entrypoint#using-the-entrypoint).
10+
You should register bindings inside of the Controlify init entrypoint.
11+
Read more in [Controlify Entrypoint](controlify-entrypoint#using-the-entrypoint).
1112
</Callout>
1213

13-
Controlify allows users to configure different buttons on their controllers to actions in-game. You may want your own mod's actions to be able to be invoked from the controller too.
14+
Controlify allows users to configure different buttons on their controllers to actions in-game.
15+
You may want your own mod's actions to be able to be invoked from the controller too.
1416

1517
To register a controller binding, you must use the `ControllerBindingsApi.`
1618

1719
```java
1820
private BindingSupplier action1Binding;
1921

2022
@Override
21-
public void onControlifyInit(InitContext ctx) {
23+
public void onControlifyPreInit(PreInitContext ctx) {
2224
action1Binding = ctx.bindings().registerBinding(
2325
builder -> builder
2426
.id("mymod", "action1") // the id of the binding, this should be unique to your mod
@@ -29,24 +31,32 @@ public void onControlifyInit(InitContext ctx) {
2931
}
3032
```
3133

32-
To add a name and description to the binding, you need to define the language keys `controlify.binding.<namespace>.<path>` and `controlify.binding.<namespace>.<path>.desc` respectively, alternatively, you can set `.name(Component)` and `.description(Component)`
34+
To add a name and description to the binding, you need to define the language keys
35+
`controlify.binding.<namespace>.<path>` and `controlify.binding.<namespace>.<path>.desc`
36+
respectively, alternatively, you can set `.name(Component)` and `.description(Component)`.
3337

34-
Registering the binding provides you with a `BindingSupplier`, where you can then access the binding with `action1Binding.on(controller);`
38+
Registering the binding provides you with a `BindingSupplier`, where you can then access the
39+
binding with `action1Binding.on(controller);`
3540

36-
Controlify automatically converts your existed modded `KeyMapping`s to controller bindings, but relying on this behaviour if you are going to explicitly support Controlify is not recommended. You can stop this conversion with the following...
41+
Controlify automatically converts your existed modded `KeyMapping`s to controller bindings,
42+
but relying on this behaviour if you are going to explicitly support Controlify is not recommended.
43+
You can stop this conversion with the following...
3744

3845
```java
3946
@Override
40-
public void onControlifyInit(InitContext ctx) {
47+
public void onControlifyPreInit(PreInitContext ctx) {
4148
ctx.bindings().exclude(MyMod.myKeyMapping);
4249
}
4350
```
4451

4552
## Defining a default binding
4653

47-
You may have noticed that in the above code, we did not define a default binding, such as the A button. This is because default bindings are data-driven and defined by resource packs. If you want to define a default binding, you can do so by creating a JSON file in your mod's resources.
54+
You may have noticed that in the above code, we did not define a default binding, such as the A button.
55+
This is because default bindings are data-driven and defined by resource packs.
56+
If you want to define a default binding, you can do so by creating a JSON file in your mod's resources.
4857

49-
```json
58+
<CodeTabs>
59+
```json !!tabs (Default for all controllers) assets/controlify/controllers/default_bind/default.json
5060
{
5161
"defaults": {
5262
"mymod:action1": {
@@ -55,14 +65,18 @@ You may have noticed that in the above code, we did not define a default binding
5565
}
5666
}
5767
```
68+
</CodeTabs>
5869

59-
This will set the default binding for `mymod:action1` to the south face button on all controllers. You can also define defaults for specific controller namespaces by creating a file in `assets/<namespace>/controllers/default_bind/<path>.json`.
70+
This will set the default binding for `mymod:action1` to the south face button on all controllers.
71+
You can also define defaults for specific controller namespaces by creating a file in
72+
`assets/<namespace>/controllers/default_bind/<path>.json`.
6073

6174
For more information on how to define default bindings, see the [Default Binds](../resource-packs/default-binds) page.
6275

6376
## Using the binding
6477

65-
Once you have access to a binding through `bindingSupplier.on(controller)`, you can access many properties of the binding:
78+
Once you have access to a binding through `bindingSupplier.on(controller)`,
79+
you can access many properties of the binding:
6680

6781
| Property | Description |
6882
|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
@@ -76,10 +90,12 @@ Once you have access to a binding through `bindingSupplier.on(controller)`, you
7690
| `justTapped()` | Returns if the binding was just tapped this tick, if it returns true, the state is consumed and will return false for the remaining tick. |
7791
| `guiPressed().get()` | Returns true if the binding is pressed this tick in the GUI context. |
7892

79-
There are more properties available inside of `InputBinding` which you can look at in the sources, but the above are the most notable that you will use the most.
93+
There are more properties available inside of `InputBinding` which you can look at in the sources,
94+
but the above are the most notable that you will use the most.
8095

8196
## Rendering binding glyphs
8297

8398
There is nothing special about rendering glyphs for controller bindings, as Controlify utilises custom fonts.
8499

85-
This means you can use the glyphs within localised text, or just render it with `graphics.drawString(myBinding.inputGlyph(), x, y, -1);`
100+
This means you can use the glyphs within localised text, or just render it with
101+
`graphics.drawString(myBinding.inputGlyph(), x, y, -1);`

docs/developers/controlify-entrypoint.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Controlify provides a Fabric entrypoint to hook into important lifecycle stages
99
## Registering the entrypoint
1010

1111
- On Fabric, you register an entrypoint like any other, by adding an entry to your `fabric.mod.json` file under the `entrypoints` section.
12-
- On NeoForge, you register an entrypoint using a Java service provider interface (SPI) in your `META-INF/services` directory.
12+
- On NeoForge (or Fabric), you register an entrypoint using a Java service provider interface (SPI) in your `META-INF/services` directory.
1313

1414
<CodeTabs>
1515
```json !!tabs (Fabric) fabric.mod.json
@@ -22,8 +22,8 @@ Controlify provides a Fabric entrypoint to hook into important lifecycle stages
2222
}
2323
```
2424

25-
```txt !!tabs (NeoForge) META-INF/services/dev.isxander.controlify.api.entrypoint.ControlifyEntrypoint
26-
com.example.mymod.ControlifyEntrypoint
25+
```txt !!tabs (NeoForge/Universal) META-INF/services/dev.isxander.controlify.api.entrypoint.ControlifyEntrypoint
26+
com.example.mymod.MyControlifyEntrypoint
2727
```
2828
</CodeTabs>
2929

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
title: Getting Started
3+
---
4+
5+
_Learn how to depend on Controlify._
6+
7+
## Adding Controlify to your gradle project
8+
9+
Recent versions of Controlify are available on [Maven Central](https://central.sonatype.com/artifact/dev.isxander/controlify/versions).
10+
Versions older than 2.5.1 are available through `https://maven.isxander.dev/releases/`.
11+
12+
The artifact you need to depend on is `dev.isxander:controlify`.
13+
An example of a version would be `3.0.0+1.21.11-fabric`.
14+
15+
Depend on Controlify like you would any other mod.
16+
17+
On Fabric (`>=26.1`): `implementation`
18+
On Fabric (`<26.1`): `modImplementation`
19+
On NeoForge: `implementation`
20+
21+
## Adding dependency to your mod manifest
22+
23+
Because it is likely your mod should not have a hard dependency on Controlify,
24+
you should not add Controlify to the `"depends":` section of your `fabric.mod.json`.
25+
26+
Instead, you should add Controlify to the `"breaks":` section. Cause the game to crash when the
27+
Controlify version is less than the minimum version your mod supports.
28+
This way, if a user has an incompatible version of Controlify, they will crash, but won't
29+
crash if they don't have Controlify at all.
30+
31+
For example, if you use a feature added in Controlify 2.5.0, you can add this to your `fabric.mod.json`:
32+
33+
```json
34+
"breaks": {
35+
"controlify": "<2.5.0"
36+
}
37+
```

docs/resource-packs/custom-controller-identification.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Custom Controller Identification
33
---
44

5-
# What is it?
5+
## What is it?
66

77
Controlify allows you to create custom definitions for your controller.
88

@@ -12,7 +12,7 @@ Creating a custom definition allows you to define a **specific name** for your c
1212
an [**input glyph set**](input-glyphs),
1313
and [**special mappings**](input-mappings) for controllers like flight-sticks.
1414

15-
# Creating the definition
15+
## Creating the definition
1616

1717
In your resource pack, create the file `/assets/controlify/controllers/controller_identification.json5`.
1818
Unlike most resources in Minecraft, this file is **additive** and **does not overwrite** the base definitions
@@ -48,21 +48,21 @@ pack, to prevent conflicts with other resource packs.
4848
devices have their own PID. In the case of a Switch Pro Controller, Nintendo's VID is `0x57e` and the
4949
controller's PID is `0x2009`. This is defined as a json array: `[0x57e, 0x2009]`.
5050

51-
## Finding your controller's VID and PID
51+
### Finding your controller's VID and PID
5252

5353
Even without a custom definition, Controlify will still attempt to load your controller.
5454
When it does so, it adds the VID and PID information into a *debug dump* that you can retrieve from the
5555
**Global Settings** of Controlify. Inside, you will find the information you need.
5656

57-
# Done!
57+
## Done!
5858

5959
You have now successfully created a custom controller definition!
6060
Restart the game to see that your controller is now using your custom name!
6161

6262
If you'd like to customise your custom controller further with features mentioned at the start of this page,
6363
check the sidebar for pages on how to do so.
6464

65-
# Adding to built-in namespaces
65+
## Adding to built-in namespaces
6666

6767
Your resource pack can extend these definitions and add additional VID and PIDs to them. Exclude the `"name"` property
6868
for the definition for Controlify to use the built-in name.

docs/resource-packs/default-binds.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
title: Default Binds
33
---
44

5-
# What is it?
5+
## What is it?
66

77
The default binding of the `Controls` found in controller settings is completely data-driven.
88
You can override the defaults for all controllers or specific controller namespaces.
99

1010
For example, by default, the `Jump` action is bound to the south face button on all controllers.
1111
This is 'A' on Xbox, or 'Cross' on PlayStation. This is defined within the built-in mod resource pack.
1212

13-
# Creating the definition
13+
## Creating the definition
1414

1515
Below is an example that sets 'Jump' to the south button, 'Walk Forward' to pushing the left stick upwards, and unbinding the 'Open Inventory' action.
1616
```json

docs/resource-packs/guides.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Guides
33
---
44

5-
# What are guides?
5+
## What are guides?
66

77
Guides are a feature of Controlify that shows hints to the player about what buttons to press to perform certain actions.
88

@@ -13,7 +13,7 @@ Since version `2.3.0`, guides are data-driven, meaning you can override the defa
1313
<Asset className={"rounded-sm"} width={1020 / 2} location="controlify:images/container_guide" />
1414
</div>
1515

16-
# Concepts
16+
## Concepts
1717

1818
There are three main concepts you need to understand to create your own guides.
1919

@@ -30,7 +30,7 @@ There are three main concepts you need to understand to create your own guides.
3030
- `controlify:container` is a domain that has facts and rules for when the player is in a container GUI, like the inventory or a chest.
3131
- For example, you wouldn't have a rule for `controlify:on_ground` in the `controlify:container` domain, since it's irrelevant in a container GUI.
3232

33-
# Creating custom rules
33+
## Creating custom rules
3434

3535
Controlify only allows resource packs to add and override _rules_, not _facts_ or _domains_.
3636

@@ -66,7 +66,7 @@ A rule can be displayed either on the `left` or `right` side of the screen, this
6666
Because `"override": false`, this resource pack will not override the default rules, but instead add an additional rule.
6767
If you want to override the default rules, or any resource pack below yours, set `"override": true`.
6868

69-
## Stacking rules
69+
### Stacking rules
7070

7171
You can stack multiple rules for the same binding, the first rule that succeeds will be applied, the rest will be ignored.
7272
However, if the rules have different locations (e.g. `left` and `right`), they will both be applied.
@@ -101,13 +101,13 @@ and the second rule will apply when the player is on the ground.
101101
Even when the player is in water and touching the ground, only the first rule will apply,
102102
because it is the first rule that matches its conditions.
103103

104-
# Facts
104+
## Facts
105105

106106
Controlify has a set of built-in facts that you can use in your rules.
107107

108108
Below is a list of the built-in facts for each domain.
109109

110-
## Common facts
110+
### Common facts
111111

112112
These facts are available in all domains.
113113

@@ -119,7 +119,7 @@ These facts are available in all domains.
119119
| `controlify:verbosity_minimal` | When the guide verbosity is set to minimal. |
120120

121121

122-
## `controlify:in_game`
122+
### `controlify:in_game`
123123

124124
| ID | Description |
125125
|-----------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|
@@ -152,7 +152,7 @@ These facts are available in all domains.
152152
| `controlify:has_item_in_offhand` | When the player has an item in their offhand. |
153153
| `controlify:has_multiple_items_in_hand` | When the player is holding an item stack with a count greater than one. |
154154

155-
## `controlify:container`
155+
### `controlify:container`
156156

157157
| ID | Description |
158158
|---------------------------------------|----------------------------------------------------------------------------------------------------------------------------|

docs/resource-packs/input-glyphs.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Input Glyphs
33
---
44

5-
# What is it?
5+
## What is it?
66

77
Input glyphs are the icons that represent the buttons on your controller.
88
Controlify has many built-in glyph sets for common controllers, but you can also create your own.
@@ -14,9 +14,9 @@ Controlify has many built-in glyph sets for common controllers, but you can also
1414
These glyphs are actually their own font, and you create them the same way as any other font in a resource pack.
1515
All you need to turn it into a controller glyph set is one extra file in the resource pack to link it together.
1616

17-
# Creating a custom glyph set
17+
## Creating a custom glyph set
1818

19-
## 1. Create the font file
19+
### 1. Create the font file
2020

2121
<Callout>
2222
**Refer to the [Minecraft Wiki](https://minecraft.wiki/w/Font#Providers) for information on creating fonts.**
@@ -46,7 +46,7 @@ create a font file in your resource pack, like `/assets/my_resource_pack/font/co
4646
}
4747
```
4848

49-
## 2. Create the texture file
49+
### 2. Create the texture file
5050

5151
As per the `"file"` entry in your font file, create a texture file in your resource pack.
5252
**Make sure to place it in the `textures` folder.**
@@ -57,7 +57,7 @@ In this case, `assets/my_resource_pack/textures/font/controller/switch.png`.
5757
<Asset className={"rounded-sm"} width={1020 / 2} location="controlify:images/button-glyph-atlas" />
5858
</div>
5959

60-
## 3. Create the glyph font mapping
60+
### 3. Create the glyph font mapping
6161

6262
Finally, create a file that links the [controller inputs](../reference/builtin-inputs) to the characters you
6363
defined in the font file.
@@ -83,10 +83,10 @@ Create a file in your resource pack, like `/assets/my_resource_pack/controllers/
8383
}
8484
```
8585

86-
## 4. Done!
86+
### 4. Done!
8787

8888
You have now successfully created a custom glyph set for your controller! Test it out in game!
8989

90-
# Overriding existing glyph sets
90+
## Overriding existing glyph sets
9191

9292
To override an existing built-in glyph set, just follow the same steps as above, but use the same namespace as the built-in one.

docs/resource-packs/keyboard-layouts.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ Available actions
8787
- `copy_all`, `paste`
8888
- `previous_layout`
8989

90-
Display names are translatable via `controlify.keyboard.special.<name>`, e.g. `controlify.keyboard.special.enter`.
90+
Display names are translatable via `controlify.keyboard.special.<name>`,
91+
e.g. `controlify.keyboard.special.enter`.
9192

9293
#### Change layout
9394
A KeyFunction that switches to another layout by id. It can be specified as:

src/main/java/dev/isxander/controlify/Controlify.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
import dev.isxander.controlify.api.bind.ControlifyBindApi;
66
import dev.isxander.controlify.api.entrypoint.InitContext;
77
import dev.isxander.controlify.api.entrypoint.PreInitContext;
8-
import dev.isxander.controlify.api.guide.ContainerCtx;
9-
import dev.isxander.controlify.api.guide.GuideDomainRegistries;
10-
import dev.isxander.controlify.api.guide.GuideDomainRegistry;
11-
import dev.isxander.controlify.api.guide.InGameCtx;
8+
import dev.isxander.controlify.api.guide.*;
129
import dev.isxander.controlify.bindings.BindContext;
1310
import dev.isxander.controlify.bindings.ControlifyBindApiImpl;
1411
import dev.isxander.controlify.bindings.ControlifyBindings;
@@ -30,6 +27,7 @@
3027
import dev.isxander.controlify.driver.steamdeck.SteamDeckMode;
3128
import dev.isxander.controlify.driver.steamdeck.SteamDeckUtil;
3229
import dev.isxander.controlify.font.InputFontMapper;
30+
import dev.isxander.controlify.gui.guide.GuideDomain;
3331
import dev.isxander.controlify.gui.guide.GuideDomains;
3432
import dev.isxander.controlify.gui.screen.*;
3533
import dev.isxander.controlify.debug.DebugProperties;
@@ -197,6 +195,13 @@ public GuideDomainRegistry<InGameCtx> inGame() {
197195
public GuideDomainRegistry<ContainerCtx> container() {
198196
return GuideDomains.CONTAINER;
199197
}
198+
199+
@Override
200+
public <T extends FactCtx> GuideDomainRegistry<T> registerCustom(GuideDomain<T> domain) {
201+
GuideDomains.CUSTOM_DOMAINS.put(domain.id(), domain);
202+
PlatformClientUtil.registerAssetReloadListener(domain);
203+
return domain;
204+
}
200205
};
201206
}
202207
});

0 commit comments

Comments
 (0)