forked from Clones/Controlify
➕ Allow ingame button guide to be placed at the bottom
This commit is contained in:
@ -19,6 +19,7 @@ public abstract class ControllerConfig {
|
||||
public String customName = null;
|
||||
|
||||
public boolean showIngameGuide = true;
|
||||
public boolean ingameGuideBottom = false;
|
||||
public boolean showScreenGuide = true;
|
||||
|
||||
public float chatKeyboardHeight = 0f;
|
||||
|
@ -35,8 +35,8 @@ public class InGameButtonGuide implements IngameGuideRegistry {
|
||||
private final List<GuideAction<IngameGuideContext>> leftGuides = new ArrayList<>();
|
||||
private final List<GuideAction<IngameGuideContext>> rightGuides = new ArrayList<>();
|
||||
|
||||
private final PositionedComponent<ColumnLayoutComponent<GuideActionRenderer<IngameGuideContext>>> leftLayout;
|
||||
private final PositionedComponent<ColumnLayoutComponent<GuideActionRenderer<IngameGuideContext>>> rightLayout;
|
||||
private PositionedComponent<ColumnLayoutComponent<GuideActionRenderer<IngameGuideContext>>> leftLayout;
|
||||
private PositionedComponent<ColumnLayoutComponent<GuideActionRenderer<IngameGuideContext>>> rightLayout;
|
||||
|
||||
public InGameButtonGuide(Controller<?, ?> controller, LocalPlayer localPlayer) {
|
||||
this.controller = controller;
|
||||
@ -48,6 +48,12 @@ public class InGameButtonGuide implements IngameGuideRegistry {
|
||||
Collections.sort(leftGuides);
|
||||
Collections.sort(rightGuides);
|
||||
|
||||
refreshLayout();
|
||||
}
|
||||
|
||||
public void refreshLayout() {
|
||||
boolean bottom = controller.config().ingameGuideBottom;
|
||||
|
||||
leftLayout = new PositionedComponent<>(
|
||||
ColumnLayoutComponent.<GuideActionRenderer<IngameGuideContext>>builder()
|
||||
.spacing(1)
|
||||
@ -55,9 +61,9 @@ public class InGameButtonGuide implements IngameGuideRegistry {
|
||||
.elementPosition(ColumnLayoutComponent.ElementPosition.LEFT)
|
||||
.elements(leftGuides.stream().map(guide -> new GuideActionRenderer<>(guide, false, true)).toList())
|
||||
.build(),
|
||||
AnchorPoint.TOP_LEFT,
|
||||
!bottom ? AnchorPoint.TOP_LEFT : AnchorPoint.BOTTOM_LEFT,
|
||||
0, 0,
|
||||
AnchorPoint.TOP_LEFT
|
||||
!bottom ? AnchorPoint.TOP_LEFT : AnchorPoint.BOTTOM_LEFT
|
||||
);
|
||||
|
||||
rightLayout = new PositionedComponent<>(
|
||||
@ -67,9 +73,9 @@ public class InGameButtonGuide implements IngameGuideRegistry {
|
||||
.elementPosition(ColumnLayoutComponent.ElementPosition.RIGHT)
|
||||
.elements(rightGuides.stream().map(guide -> new GuideActionRenderer<>(guide, true, true)).toList())
|
||||
.build(),
|
||||
AnchorPoint.TOP_RIGHT,
|
||||
!bottom ? AnchorPoint.TOP_RIGHT : AnchorPoint.BOTTOM_RIGHT,
|
||||
0, 0,
|
||||
AnchorPoint.TOP_RIGHT
|
||||
!bottom ? AnchorPoint.TOP_RIGHT : AnchorPoint.BOTTOM_RIGHT
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,9 @@ import dev.isxander.controlify.controller.ControllerConfig;
|
||||
import dev.isxander.controlify.controller.gamepad.GamepadController;
|
||||
import dev.isxander.controlify.controller.joystick.SingleJoystickController;
|
||||
import dev.isxander.controlify.controller.joystick.mapping.JoystickMapping;
|
||||
import dev.isxander.controlify.driver.SteamDeckDriver;
|
||||
import dev.isxander.controlify.gui.controllers.AbstractBindController;
|
||||
import dev.isxander.controlify.gui.guide.InGameButtonGuide;
|
||||
import dev.isxander.controlify.rumble.BasicRumbleEffect;
|
||||
import dev.isxander.controlify.rumble.RumbleSource;
|
||||
import dev.isxander.controlify.rumble.RumbleState;
|
||||
@ -155,6 +157,14 @@ public class ControllerConfigScreenFactory {
|
||||
.binding(def.showIngameGuide, () -> config.showIngameGuide, v -> config.showIngameGuide = v)
|
||||
.controller(TickBoxControllerBuilder::create)
|
||||
.build())
|
||||
.option(Option.<Boolean>createBuilder()
|
||||
.name(Component.translatable("controlify.gui.ingame_button_guide_position"))
|
||||
.description(OptionDescription.of(Component.translatable("controlify.gui.ingame_button_guide_position.tooltip")))
|
||||
.binding(def.ingameGuideBottom, () -> config.ingameGuideBottom, v -> config.ingameGuideBottom = v)
|
||||
.controller(opt -> BooleanControllerBuilder.create(opt)
|
||||
.valueFormatter(v -> Component.translatable(v ? "controlify.gui.format.bottom" : "controlify.gui.format.top")))
|
||||
.flag(mc -> Controlify.instance().inGameButtonGuide().ifPresent(InGameButtonGuide::refreshLayout))
|
||||
.build())
|
||||
.option(Option.<Boolean>createBuilder()
|
||||
.name(Component.translatable("controlify.gui.show_screen_guide"))
|
||||
.description(OptionDescription.createBuilder()
|
||||
|
Reference in New Issue
Block a user