forked from Clones/Controlify
refactor binding api (sorry enjarai)
This commit is contained in:
@ -0,0 +1,10 @@
|
||||
package dev.isxander.controlify.api.bind;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dev.isxander.controlify.gui.DrawSize;
|
||||
|
||||
public interface BindRenderer {
|
||||
DrawSize size();
|
||||
|
||||
void render(PoseStack poseStack, int x, int centerY);
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package dev.isxander.controlify.api.bind;
|
||||
|
||||
import dev.isxander.controlify.controller.Controller;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface BindingSupplier {
|
||||
ControllerBinding onController(Controller<?, ?> controller);
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package dev.isxander.controlify.api.bind;
|
||||
|
||||
import dev.isxander.controlify.api.ControlifyApi;
|
||||
import dev.isxander.controlify.bindings.BindingSupplier;
|
||||
import dev.isxander.controlify.bindings.ControllerBindings;
|
||||
import dev.isxander.controlify.bindings.GamepadBinds;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
|
@ -0,0 +1,37 @@
|
||||
package dev.isxander.controlify.api.bind;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
public interface ControllerBinding {
|
||||
float state();
|
||||
float prevState();
|
||||
|
||||
boolean held();
|
||||
boolean prevHeld();
|
||||
|
||||
boolean justPressed();
|
||||
boolean justReleased();
|
||||
|
||||
Component name();
|
||||
Component description();
|
||||
Component category();
|
||||
|
||||
ResourceLocation id();
|
||||
|
||||
KeyMappingOverride override();
|
||||
|
||||
void resetBind();
|
||||
boolean isUnbound();
|
||||
|
||||
BindRenderer renderer();
|
||||
|
||||
JsonObject toJson();
|
||||
|
||||
record KeyMappingOverride(KeyMapping keyMapping, BooleanSupplier toggleable) {
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package dev.isxander.controlify.api.bind;
|
||||
|
||||
import dev.isxander.controlify.bindings.ControllerBinding;
|
||||
import dev.isxander.controlify.bindings.ControllerBindingImpl;
|
||||
import dev.isxander.controlify.bindings.GamepadBinds;
|
||||
import dev.isxander.controlify.bindings.IBind;
|
||||
import dev.isxander.controlify.controller.Controller;
|
||||
@ -13,7 +13,7 @@ import java.util.function.BooleanSupplier;
|
||||
|
||||
public interface ControllerBindingBuilder<T extends ControllerState> {
|
||||
static <T extends ControllerState> ControllerBindingBuilder<T> create(Controller<T, ?> controller) {
|
||||
return new ControllerBinding.ControllerBindingBuilderImpl<>(controller);
|
||||
return new ControllerBindingImpl.ControllerBindingBuilderImpl<>(controller);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -92,5 +92,5 @@ public interface ControllerBindingBuilder<T extends ControllerState> {
|
||||
*/
|
||||
ControllerBindingBuilder<T> vanillaOverride(KeyMapping keyMapping);
|
||||
|
||||
ControllerBinding<T> build();
|
||||
ControllerBinding build();
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package dev.isxander.controlify.api.buttonguide;
|
||||
|
||||
import dev.isxander.controlify.bindings.ControllerBinding;
|
||||
import dev.isxander.controlify.api.bind.ControllerBinding;
|
||||
import dev.isxander.controlify.bindings.ControllerBindings;
|
||||
import dev.isxander.controlify.gui.ButtonGuideRenderer;
|
||||
import net.minecraft.client.gui.components.AbstractButton;
|
||||
@ -25,7 +25,7 @@ public final class ButtonGuideApi {
|
||||
*/
|
||||
public static <T extends AbstractButton> void addGuideToButton(
|
||||
T button,
|
||||
Function<ControllerBindings<?>, ControllerBinding<?>> binding,
|
||||
Function<ControllerBindings<?>, ControllerBinding> binding,
|
||||
ButtonRenderPosition position,
|
||||
ButtonGuidePredicate<T> renderPredicate) {
|
||||
ButtonGuideRenderer.registerBindingForButton(button, binding, position, renderPredicate);
|
||||
|
@ -1,6 +1,6 @@
|
||||
package dev.isxander.controlify.api.ingameguide;
|
||||
|
||||
import dev.isxander.controlify.bindings.ControllerBinding;
|
||||
import dev.isxander.controlify.api.bind.ControllerBinding;
|
||||
|
||||
/**
|
||||
* Allows you to register your own actions to the button guide.
|
||||
@ -16,7 +16,7 @@ public interface IngameGuideRegistry {
|
||||
* @param priority the priority of the action, used to sort the list.
|
||||
* @param supplier the supplier for the name of the action. can be empty to hide the action.
|
||||
*/
|
||||
void registerGuideAction(ControllerBinding<?> binding, ActionLocation location, ActionPriority priority, GuideActionNameSupplier supplier);
|
||||
void registerGuideAction(ControllerBinding binding, ActionLocation location, ActionPriority priority, GuideActionNameSupplier supplier);
|
||||
|
||||
/**
|
||||
* Registers a new action to the button guide.
|
||||
@ -25,5 +25,5 @@ public interface IngameGuideRegistry {
|
||||
* @param location the location of the action, left or right.
|
||||
* @param supplier the supplier for the name of the action. can be empty to hide the action.
|
||||
*/
|
||||
void registerGuideAction(ControllerBinding<?> binding, ActionLocation location, GuideActionNameSupplier supplier);
|
||||
void registerGuideAction(ControllerBinding binding, ActionLocation location, GuideActionNameSupplier supplier);
|
||||
}
|
||||
|
Reference in New Issue
Block a user