forked from Clones/Controlify
controller hid identification + ps4 buttons
This commit is contained in:
@ -28,12 +28,10 @@ public enum Bind {
|
||||
|
||||
private final BiFunction<ControllerState, Controller, Boolean> state;
|
||||
private final String identifier;
|
||||
private final ResourceLocation textureLocation;
|
||||
|
||||
Bind(BiFunction<ControllerState, Controller, Boolean> state, String identifier) {
|
||||
this.state = state;
|
||||
this.identifier = identifier;
|
||||
this.textureLocation = new ResourceLocation("controlify", "textures/gui/buttons/xbox/" + identifier + ".png");
|
||||
}
|
||||
|
||||
Bind(Function<ControllerState, Boolean> state, String identifier) {
|
||||
@ -48,8 +46,8 @@ public enum Bind {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public ResourceLocation textureLocation() {
|
||||
return textureLocation;
|
||||
public ResourceLocation textureLocation(Controller controller) {
|
||||
return new ResourceLocation("controlify", "textures/gui/buttons/" + controller.config().theme.id(controller) + "/" + identifier + ".png");
|
||||
}
|
||||
|
||||
public static Bind fromIdentifier(String identifier) {
|
||||
|
@ -0,0 +1,28 @@
|
||||
package dev.isxander.controlify.bindings;
|
||||
|
||||
import dev.isxander.controlify.controller.Controller;
|
||||
import dev.isxander.yacl.api.NameableEnum;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public enum ControllerTheme implements NameableEnum {
|
||||
AUTO(c -> c.type().theme().id(c)),
|
||||
XBOX_ONE(c -> "xbox"),
|
||||
DUALSHOCK4(c -> "dualshock4");
|
||||
|
||||
private final Function<Controller, String> idGetter;
|
||||
|
||||
ControllerTheme(Function<Controller, String> idGetter) {
|
||||
this.idGetter = idGetter;
|
||||
}
|
||||
|
||||
public String id(Controller controller) {
|
||||
return idGetter.apply(controller);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return Component.translatable("controlify.controller_theme." + name().toLowerCase());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user