forked from Clones/Controlify
compound joysticks, button guide in screens, improve API
This commit is contained in:
@ -0,0 +1,8 @@
|
||||
package dev.isxander.controlify.api.ingameguide;
|
||||
|
||||
/**
|
||||
* Whether the action should be on the left or right list.
|
||||
*/
|
||||
public enum ActionLocation {
|
||||
LEFT, RIGHT
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package dev.isxander.controlify.api.ingameguide;
|
||||
|
||||
/**
|
||||
* Defines how the action is sorted in the list. All default Controlify actions are {@link #NORMAL}.
|
||||
*/
|
||||
public enum ActionPriority {
|
||||
LOWEST,
|
||||
LOW,
|
||||
NORMAL,
|
||||
HIGH,
|
||||
HIGHEST
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package dev.isxander.controlify.api.ingameguide;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Supplies the text to display for a guide action based on the current context.
|
||||
* If return is empty, the action will not be displayed.
|
||||
* <p>
|
||||
* This is supplied once every tick.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface GuideActionNameSupplier {
|
||||
Optional<Component> supply(IngameGuideContext ctx);
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package dev.isxander.controlify.api.ingameguide;
|
||||
|
||||
import dev.isxander.controlify.controller.Controller;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
|
||||
public record IngameGuideContext(Minecraft client,
|
||||
LocalPlayer player,
|
||||
ClientLevel level,
|
||||
HitResult hitResult,
|
||||
Controller<?, ?> controller) {
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package dev.isxander.controlify.api.ingameguide;
|
||||
|
||||
import dev.isxander.controlify.bindings.ControllerBinding;
|
||||
|
||||
/**
|
||||
* Allows you to register your own actions to the button guide.
|
||||
* This should be called through {@link dev.isxander.controlify.api.event.ControlifyEvents#INGAME_GUIDE_REGISTRY} as
|
||||
* these should be called every time the guide is initialised.
|
||||
*/
|
||||
public interface IngameGuideRegistry {
|
||||
/**
|
||||
* Registers a new action to the button guide.
|
||||
*
|
||||
* @param binding the binding for the action, if unbound, the action is hidden.
|
||||
* @param location the location of the action, left or right.
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Registers a new action to the button guide.
|
||||
*
|
||||
* @param binding the binding for the action, if unbound, the action is hidden.
|
||||
* @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);
|
||||
}
|
Reference in New Issue
Block a user