Fix lot of bugs and update to 1.16.2.
@@ -31,7 +31,7 @@ configurations {
|
||||
dependencies {
|
||||
//to change the versions see the gradle.properties file
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
|
||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||
@@ -43,11 +43,11 @@ dependencies {
|
||||
|
||||
// Compatibility mods
|
||||
modImplementation "com.github.joaoh1:okzoomer:e13183c59b"
|
||||
modImplementation "me.shedaniel:RoughlyEnoughItems:4.5.5"
|
||||
modImplementation "me.shedaniel:RoughlyEnoughItems:5.2.3"
|
||||
|
||||
api project(":core")
|
||||
shadowInternal project(":core")
|
||||
shadow("org.aperlambda:lambdajcommon:1.8.0") {
|
||||
shadow("org.aperlambda:lambdajcommon:1.8.1") {
|
||||
// Minecraft already has all that google crap.
|
||||
exclude group: 'com.google.code.gson'
|
||||
exclude group: 'com.google.guava'
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
package me.lambdaurora.lambdacontrols.client;
|
||||
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import org.aperlambda.lambdacommon.utils.Nameable;
|
||||
@@ -21,7 +22,7 @@ import java.util.Optional;
|
||||
* Represents a controller type.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.4.0
|
||||
* @version 1.4.3
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public enum ControllerType implements Nameable
|
||||
@@ -29,9 +30,10 @@ public enum ControllerType implements Nameable
|
||||
DEFAULT(0),
|
||||
DUALSHOCK(1),
|
||||
SWITCH(2),
|
||||
XBOX(3),
|
||||
STEAM(4),
|
||||
OUYA(5);
|
||||
XBOX_360(3, new LiteralText("Xbox 360")),
|
||||
XBOX(4),
|
||||
STEAM(5),
|
||||
OUYA(6);
|
||||
|
||||
private final int id;
|
||||
private final Text text;
|
||||
@@ -39,7 +41,13 @@ public enum ControllerType implements Nameable
|
||||
ControllerType(int id)
|
||||
{
|
||||
this.id = id;
|
||||
this.text = new TranslatableText(this.getTranslationKey());
|
||||
this.text = new TranslatableText("lambdacontrols.controller_type." + this.getName());
|
||||
}
|
||||
|
||||
ControllerType(int id, @NotNull Text text)
|
||||
{
|
||||
this.id = id;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,16 +73,6 @@ public enum ControllerType implements Nameable
|
||||
return v[this.ordinal() + 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the translation key of this controller type.
|
||||
*
|
||||
* @return The translation key.
|
||||
*/
|
||||
public @NotNull String getTranslationKey()
|
||||
{
|
||||
return "lambdacontrols.controller_type." + this.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the translated text of this controller type.
|
||||
*
|
||||
|
||||
@@ -18,7 +18,9 @@ import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
||||
import me.lambdaurora.lambdacontrols.client.controller.Controller;
|
||||
import me.lambdaurora.lambdacontrols.client.controller.InputManager;
|
||||
import me.lambdaurora.lambdacontrols.client.gui.LambdaControlsHud;
|
||||
import me.lambdaurora.lambdacontrols.client.gui.RingScreen;
|
||||
import me.lambdaurora.lambdacontrols.client.gui.TouchscreenOverlay;
|
||||
import me.lambdaurora.lambdacontrols.client.ring.LambdaRing;
|
||||
import me.lambdaurora.spruceui.event.OpenScreenCallback;
|
||||
import me.lambdaurora.spruceui.hud.HudManager;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
@@ -35,11 +37,13 @@ import net.minecraft.util.Identifier;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Represents the LambdaControls client mod.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.3.2
|
||||
* @version 1.4.3
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class LambdaControlsClient extends LambdaControls implements ClientModInitializer
|
||||
@@ -53,11 +57,15 @@ public class LambdaControlsClient extends LambdaControls implements ClientModIni
|
||||
InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_KP_2, "key.categories.movement");
|
||||
public static final KeyBinding BINDING_LOOK_LEFT = InputManager.makeKeyBinding(new Identifier(LambdaControlsConstants.NAMESPACE, "look_left"),
|
||||
InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_KP_4, "key.categories.movement");
|
||||
public static final KeyBinding BINDING_RING = InputManager.makeKeyBinding(new Identifier(LambdaControlsConstants.NAMESPACE, "ring"),
|
||||
InputUtil.Type.MOUSE, GLFW.GLFW_MOUSE_BUTTON_5, "key.categories.misc");
|
||||
public static final Identifier CONTROLLER_BUTTONS = new Identifier(LambdaControlsConstants.NAMESPACE, "textures/gui/controller_buttons.png");
|
||||
public static final Identifier CONTROLLER_AXIS = new Identifier(LambdaControlsConstants.NAMESPACE, "textures/gui/controller_axis.png");
|
||||
public static final Identifier CURSOR_TEXTURE = new Identifier(LambdaControlsConstants.NAMESPACE, "textures/gui/cursor.png");
|
||||
public final static File MAPPINGS_FILE = new File("config/gamecontrollerdb.txt");
|
||||
public final LambdaControlsConfig config = new LambdaControlsConfig(this);
|
||||
public final LambdaInput input = new LambdaInput(this);
|
||||
public final LambdaRing ring = new LambdaRing();
|
||||
public final LambdaReacharound reacharound = new LambdaReacharound();
|
||||
private LambdaControlsHud hud;
|
||||
private ControlsMode previousControlsMode;
|
||||
@@ -70,6 +78,7 @@ public class LambdaControlsClient extends LambdaControls implements ClientModIni
|
||||
KeyBindingHelper.registerKeyBinding(BINDING_LOOK_RIGHT);
|
||||
KeyBindingHelper.registerKeyBinding(BINDING_LOOK_DOWN);
|
||||
KeyBindingHelper.registerKeyBinding(BINDING_LOOK_LEFT);
|
||||
//KeyBindingHelper.registerKeyBinding(BINDING_RING);
|
||||
|
||||
ClientSidePacketRegistry.INSTANCE.register(CONTROLS_MODE_CHANNEL, (context, attachedData) -> context.getTaskQueue()
|
||||
.execute(() -> ClientSidePacketRegistry.INSTANCE.sendToServer(CONTROLS_MODE_CHANNEL, this.makeControlsModeBuffer(this.config.getControlsMode()))));
|
||||
@@ -131,6 +140,10 @@ public class LambdaControlsClient extends LambdaControls implements ClientModIni
|
||||
this.input.onTick(client);
|
||||
if (this.config.getControlsMode() == ControlsMode.CONTROLLER && (client.isWindowFocused() || this.config.hasUnfocusedInput()))
|
||||
this.input.onControllerTick(client);
|
||||
|
||||
if (BINDING_RING.wasPressed()) {
|
||||
client.openScreen(new RingScreen());
|
||||
}
|
||||
}
|
||||
|
||||
public void onRender(MinecraftClient client)
|
||||
|
||||
@@ -36,6 +36,7 @@ public class LambdaControlsConfig
|
||||
// General
|
||||
private static final ControlsMode DEFAULT_CONTROLS_MODE = ControlsMode.DEFAULT;
|
||||
private static final boolean DEFAULT_AUTO_SWITCH_MODE = false;
|
||||
private static final boolean DEFAULT_DEBUG = false;
|
||||
// HUD
|
||||
private static final boolean DEFAULT_HUD_ENABLE = true;
|
||||
private static final HudSide DEFAULT_HUD_SIDE = HudSide.LEFT;
|
||||
@@ -172,6 +173,7 @@ public class LambdaControlsConfig
|
||||
// General
|
||||
this.setControlsMode(DEFAULT_CONTROLS_MODE);
|
||||
this.setAutoSwitchMode(DEFAULT_AUTO_SWITCH_MODE);
|
||||
this.setDebug(DEFAULT_DEBUG);
|
||||
// Gameplay
|
||||
this.setFastBlockPlacing(DEFAULT_FAST_BLOCK_INTERACTION);
|
||||
this.setFlyDrifting(DEFAULT_FLY_DRIFTING);
|
||||
@@ -236,6 +238,26 @@ public class LambdaControlsConfig
|
||||
this.config.set("auto_switch_mode", autoSwitchMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the mod has debug enabled or not.
|
||||
*
|
||||
* @return True if debug is enabled, else false.
|
||||
*/
|
||||
public boolean hasDebug()
|
||||
{
|
||||
return this.config.getOrElse("debug", DEFAULT_DEBUG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the mod has debug enabled or not.
|
||||
*
|
||||
* @param debug True if debug is enabled, else false.
|
||||
*/
|
||||
protected void setDebug(boolean debug)
|
||||
{
|
||||
this.config.set("debug", debug);
|
||||
}
|
||||
|
||||
/*
|
||||
HUD settings
|
||||
*/
|
||||
|
||||
@@ -32,7 +32,7 @@ import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerServerListWidget;
|
||||
import net.minecraft.client.gui.screen.pack.ResourcePackScreen;
|
||||
import net.minecraft.client.gui.screen.pack.PackScreen;
|
||||
import net.minecraft.client.gui.screen.world.WorldListWidget;
|
||||
import net.minecraft.client.gui.widget.AbstractPressableButtonWidget;
|
||||
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
|
||||
@@ -64,7 +64,7 @@ import static org.lwjgl.glfw.GLFW.*;
|
||||
* Represents the LambdaControls' input handler.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.4.0
|
||||
* @version 1.4.3
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class LambdaInput
|
||||
@@ -669,16 +669,16 @@ public class LambdaInput
|
||||
double powValue = Math.pow(value, 2.0);
|
||||
if (axis == GLFW_GAMEPAD_AXIS_RIGHT_Y) {
|
||||
if (state == 2) {
|
||||
this.targetPitch = -this.config.getRightYAxisSign() * (this.config.getRotationSpeed() * powValue) * 0.33D;
|
||||
this.targetPitch = -this.config.getRightYAxisSign() * (this.config.getRotationSpeed() * powValue) * 0.11D;
|
||||
} else if (state == 1) {
|
||||
this.targetPitch = this.config.getRightYAxisSign() * (this.config.getRotationSpeed() * powValue) * 0.33D;
|
||||
this.targetPitch = this.config.getRightYAxisSign() * (this.config.getRotationSpeed() * powValue) * 0.11D;
|
||||
}
|
||||
}
|
||||
if (axis == GLFW_GAMEPAD_AXIS_RIGHT_X) {
|
||||
if (state == 2) {
|
||||
this.targetYaw = -this.config.getRightXAxisSign() * (this.config.getRotationSpeed() * powValue) * 0.33D;
|
||||
this.targetYaw = -this.config.getRightXAxisSign() * (this.config.getRotationSpeed() * powValue) * 0.11D;
|
||||
} else if (state == 1) {
|
||||
this.targetYaw = this.config.getRightXAxisSign() * (this.config.getRotationSpeed() * powValue) * 0.33D;
|
||||
this.targetYaw = this.config.getRightXAxisSign() * (this.config.getRotationSpeed() * powValue) * 0.11D;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -700,7 +700,7 @@ public class LambdaInput
|
||||
|
||||
public static boolean isScreenInteractive(@NotNull Screen screen)
|
||||
{
|
||||
return !(screen instanceof AdvancementsScreen || screen instanceof HandledScreen || screen instanceof ResourcePackScreen || LambdaControlsCompat.requireMouseOnScreen(screen));
|
||||
return !(screen instanceof AdvancementsScreen || screen instanceof HandledScreen || screen instanceof PackScreen || LambdaControlsCompat.requireMouseOnScreen(screen));
|
||||
}
|
||||
|
||||
// Inspired from https://github.com/MrCrayfish/Controllable/blob/1.14.X/src/main/java/com/mrcrayfish/controllable/client/ControllerInput.java#L686.
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.lwjgl.glfw.GLFW;
|
||||
* Represents a compatibility handler for OkZoomer.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.3.0
|
||||
* @version 1.4.3
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class OkZoomerCompat implements CompatHandler
|
||||
@@ -36,21 +36,21 @@ public class OkZoomerCompat implements CompatHandler
|
||||
.register();
|
||||
|
||||
if (ZoomKeybinds.areExtraKeybindsEnabled()) {
|
||||
new ButtonBinding.Builder("zoom.in")
|
||||
new ButtonBinding.Builder("zoom_in")
|
||||
.buttons(GLFW.GLFW_GAMEPAD_BUTTON_DPAD_UP, ButtonBinding.axisAsButton(GLFW.GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER, true))
|
||||
.onlyInGame()
|
||||
.cooldown(true)
|
||||
.category(ButtonBinding.MISC_CATEGORY)
|
||||
.linkKeybind(ZoomKeybinds.increaseZoomKey)
|
||||
.register();
|
||||
new ButtonBinding.Builder("zoom.out")
|
||||
new ButtonBinding.Builder("zoom_out")
|
||||
.buttons(GLFW.GLFW_GAMEPAD_BUTTON_DPAD_UP, ButtonBinding.axisAsButton(GLFW.GLFW_GAMEPAD_AXIS_LEFT_TRIGGER, true))
|
||||
.onlyInGame()
|
||||
.cooldown(true)
|
||||
.category(ButtonBinding.MISC_CATEGORY)
|
||||
.linkKeybind(ZoomKeybinds.decreaseZoomKey)
|
||||
.register();
|
||||
new ButtonBinding.Builder("zoom.reset")
|
||||
new ButtonBinding.Builder("zoom_reset")
|
||||
.onlyInGame()
|
||||
.cooldown(true)
|
||||
.category(ButtonBinding.MISC_CATEGORY)
|
||||
|
||||
@@ -32,7 +32,7 @@ import static org.lwjgl.glfw.GLFW.*;
|
||||
* Represents a button binding.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.4.0
|
||||
* @version 1.4.3
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class ButtonBinding implements Nameable
|
||||
@@ -75,7 +75,7 @@ public class ButtonBinding implements Nameable
|
||||
.action(InputHandlers.handleInventorySlotPad(0)).onlyInInventory().cooldown(true).register();
|
||||
public static final ButtonBinding SMOOTH_CAMERA = new Builder("toggle_smooth_camera").cooldown(true).register();
|
||||
public static final ButtonBinding SNEAK = new Builder("sneak").buttons(GLFW_GAMEPAD_BUTTON_RIGHT_THUMB)
|
||||
.actions(PressAction.DEFAULT_ACTION, InputHandlers::handleToggleSneak).onlyInGame().cooldown(true).register();
|
||||
.actions(InputHandlers::handleToggleSneak).onlyInGame().cooldown(true).register();
|
||||
public static final ButtonBinding SPRINT = new Builder("sprint").buttons(GLFW_GAMEPAD_BUTTON_LEFT_THUMB).register();
|
||||
public static final ButtonBinding SWAP_HANDS = new Builder("swap_hands").buttons(GLFW_GAMEPAD_BUTTON_X).cooldown(true).register();
|
||||
public static final ButtonBinding TAB_LEFT = new Builder("tab_back").buttons(GLFW_GAMEPAD_BUTTON_LEFT_BUMPER)
|
||||
|
||||
@@ -9,13 +9,20 @@
|
||||
|
||||
package me.lambdaurora.lambdacontrols.client.controller;
|
||||
|
||||
import me.lambdaurora.lambdacontrols.LambdaControls;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.toast.SystemToast;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import org.aperlambda.lambdacommon.utils.Nameable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.lwjgl.PointerBuffer;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.glfw.GLFWGamepadState;
|
||||
import org.lwjgl.system.MemoryStack;
|
||||
import org.lwjgl.system.MemoryUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -34,7 +41,7 @@ import static org.lwjgl.BufferUtils.createByteBuffer;
|
||||
* Represents a controller.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.0.0
|
||||
* @version 1.4.3
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class Controller implements Nameable
|
||||
@@ -167,14 +174,47 @@ public class Controller implements Nameable
|
||||
public static void updateMappings()
|
||||
{
|
||||
try {
|
||||
File mappingsFile = new File("config/gamecontrollerdb.txt");
|
||||
if (!mappingsFile.exists())
|
||||
if (!LambdaControlsClient.MAPPINGS_FILE.exists())
|
||||
return;
|
||||
LambdaControlsClient.get().log("Updating controller mappings...");
|
||||
ByteBuffer buffer = ioResourceToBuffer(mappingsFile.getPath(), 1024);
|
||||
ByteBuffer buffer = ioResourceToBuffer(LambdaControlsClient.MAPPINGS_FILE.getPath(), 1024);
|
||||
GLFW.glfwUpdateGamepadMappings(buffer);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
MemoryStack memoryStack = MemoryStack.stackPush();
|
||||
try {
|
||||
PointerBuffer pointerBuffer = memoryStack.mallocPointer(1);
|
||||
int i = GLFW.glfwGetError(pointerBuffer);
|
||||
if (i != 0) {
|
||||
long l = pointerBuffer.get();
|
||||
String string = l == 0L ? "" : MemoryUtil.memUTF8(l);
|
||||
MinecraftClient client = MinecraftClient.getInstance();
|
||||
if (client != null) {
|
||||
client.getToastManager().add(SystemToast.create(client, SystemToast.Type.TUTORIAL_HINT,
|
||||
new TranslatableText("lambdacontrols.controller.mappings.error"), new LiteralText(string)));
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
/* Ignored :concern: */
|
||||
} finally {
|
||||
memoryStack.close();
|
||||
}
|
||||
|
||||
if (LambdaControlsClient.get().config.hasDebug()) {
|
||||
for (int i = GLFW.GLFW_JOYSTICK_1; i <= GLFW.GLFW_JOYSTICK_16; i++) {
|
||||
Controller controller = byId(i);
|
||||
|
||||
if (!controller.isConnected())
|
||||
continue;
|
||||
|
||||
LambdaControls.get().log(String.format("Controller #%d name: \"%s\"\n GUID: %s\n Gamepad: %s",
|
||||
controller.id,
|
||||
controller.getName(),
|
||||
controller.getGuid(),
|
||||
controller.isGamepad()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
|
||||
import net.minecraft.client.gui.screen.recipebook.RecipeGroupButtonWidget;
|
||||
import net.minecraft.client.options.Option;
|
||||
import net.minecraft.client.util.ScreenshotUtils;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
@@ -39,7 +40,7 @@ import java.util.stream.Collectors;
|
||||
* Represents some input handlers.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.4.0
|
||||
* @version 1.4.3
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class InputHandlers
|
||||
@@ -142,11 +143,15 @@ public class InputHandlers
|
||||
|
||||
public static boolean handleToggleSneak(@NotNull MinecraftClient client, @NotNull ButtonBinding button, float value, @NotNull ButtonState action)
|
||||
{
|
||||
if (client.player != null && !client.player.abilities.flying) {
|
||||
button.asKeyBinding().filter(binding -> action == ButtonState.PRESS).ifPresent(binding -> ((KeyBindingAccessor) binding).lambdacontrols_handlePressState(!binding.isPressed()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
button.asKeyBinding().ifPresent(binding -> {
|
||||
boolean sneakToggled = client.options.sneakToggled;
|
||||
if (client.player.abilities.flying && sneakToggled)
|
||||
client.options.sneakToggled = false;
|
||||
binding.setPressed(button.pressed);
|
||||
if (client.player.abilities.flying && sneakToggled)
|
||||
client.options.sneakToggled = true;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
public static PressAction handleInventorySlotPad(int direction)
|
||||
|
||||
@@ -12,13 +12,14 @@ package me.lambdaurora.lambdacontrols.client.controller;
|
||||
import me.lambdaurora.lambdacontrols.client.ButtonState;
|
||||
import me.lambdaurora.lambdacontrols.client.util.KeyBindingAccessor;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.options.StickyKeyBinding;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a press action callback.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.4.0
|
||||
* @version 1.4.3
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@@ -27,7 +28,12 @@ public interface PressAction
|
||||
PressAction DEFAULT_ACTION = (client, button, value, action) -> {
|
||||
if (action == ButtonState.REPEAT || client.currentScreen != null)
|
||||
return false;
|
||||
button.asKeyBinding().ifPresent(binding -> ((KeyBindingAccessor) binding).lambdacontrols_handlePressState(button.isButtonDown()));
|
||||
button.asKeyBinding().ifPresent(binding -> {
|
||||
if (binding instanceof StickyKeyBinding)
|
||||
binding.setPressed(button.pressed);
|
||||
else
|
||||
((KeyBindingAccessor) binding).lambdacontrols_handlePressState(button.isButtonDown());
|
||||
});
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
||||
import me.lambdaurora.lambdacontrols.client.controller.InputManager;
|
||||
import me.lambdaurora.spruceui.SpruceButtonWidget;
|
||||
import me.lambdaurora.spruceui.SpruceTexts;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.options.ControlsOptionsScreen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
@@ -24,6 +25,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Represents the controls screen.
|
||||
@@ -67,8 +69,8 @@ public class ControllerControlsScreen extends Screen
|
||||
this.bindingsListWidget = new ControlsListWidget(this, this.client);
|
||||
this.children.add(this.bindingsListWidget);
|
||||
this.resetButton = this.addButton(new ButtonWidget(this.width / 2 - 155, this.height - 29, 150, 20,
|
||||
new TranslatableText("controls.resetAll"),
|
||||
btn -> InputManager.streamBindings().forEach(binding -> this.mod.config.setButtonBinding(binding, binding.getDefaultButton()))));
|
||||
SpruceTexts.CONTROLS_RESET_ALL,
|
||||
btn -> InputManager.streamBindings().collect(Collectors.toSet()).forEach(binding -> this.mod.config.setButtonBinding(binding, binding.getDefaultButton()))));
|
||||
this.addButton(new ButtonWidget(this.width / 2 - 155 + 160, this.height - 29, 150, 20,
|
||||
SpruceTexts.GUI_DONE,
|
||||
btn -> this.client.openScreen(this.parent)));
|
||||
@@ -79,7 +81,7 @@ public class ControllerControlsScreen extends Screen
|
||||
{
|
||||
this.renderBackground(matrices);
|
||||
this.bindingsListWidget.render(matrices, mouseX, mouseY, delta);
|
||||
this.drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 8, 16777215);
|
||||
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 8, 16777215);
|
||||
this.resetButton.active = InputManager.streamBindings().anyMatch(Predicates.not(ButtonBinding::isDefault));
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import me.lambdaurora.spruceui.Tooltip;
|
||||
import me.lambdaurora.spruceui.option.*;
|
||||
import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.options.ControlsOptionsScreen;
|
||||
import net.minecraft.client.gui.widget.ButtonListWidget;
|
||||
@@ -247,6 +248,7 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
this.list.addOptionEntry(this.frontBlockPlacingOption, this.verticalReacharoundOption);
|
||||
this.list.addSingleOptionEntry(this.flyDriftingOption);
|
||||
this.list.addSingleOptionEntry(this.flyVerticalDriftingOption);
|
||||
this.list.addOptionEntry(Option.SNEAK_TOGGLED, Option.SPRINT_TOGGLED);
|
||||
// Controller options
|
||||
this.list.addSingleOptionEntry(new SpruceSeparatorOption("lambdacontrols.menu.title.controller", true, null));
|
||||
this.list.addSingleOptionEntry(this.controllerOption);
|
||||
@@ -256,6 +258,8 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
this.list.addOptionEntry(this.unfocusedInputOption, this.virtualMouseOption);
|
||||
this.list.addSingleOptionEntry(this.virtualMouseSkinOption);
|
||||
this.list.addSingleOptionEntry(new ReloadControllerMappingsOption());
|
||||
this.list.addSingleOptionEntry(new SpruceSimpleActionOption("lambdacontrols.menu.mappings.open_input_str",
|
||||
btn -> this.client.openScreen(new MappingsStringInputScreen(this))));
|
||||
// HUD options
|
||||
this.list.addSingleOptionEntry(new SpruceSeparatorOption("lambdacontrols.menu.title.hud", true, null));
|
||||
this.list.addOptionEntry(this.hudEnableOption, this.hudSideOption);
|
||||
@@ -268,7 +272,7 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
|
||||
this.addButton(this.resetOption.createButton(this.client.options, this.width / 2 - 155, this.height - 29, 150));
|
||||
this.addButton(new ButtonWidget(this.width / 2 - 155 + 160, this.height - 29, 150, buttonHeight, SpruceTexts.GUI_DONE,
|
||||
(buttonWidget) -> this.client.openScreen(this.parent)));
|
||||
btn -> this.client.openScreen(this.parent)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -277,10 +281,10 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
this.renderBackground(matrices);
|
||||
this.list.render(matrices, mouseX, mouseY, delta);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
this.drawCenteredString(matrices, this.textRenderer, I18n.translate("lambdacontrols.menu.title"), this.width / 2, 8, 16777215);
|
||||
this.drawCenteredString(matrices, this.textRenderer, I18n.translate("lambdacontrols.controller.mappings.1", Formatting.GREEN.toString(), Formatting.RESET.toString()), this.width / 2, this.height - 29 - (5 + this.textRenderer.fontHeight) * 3, 10526880);
|
||||
drawCenteredString(matrices, this.textRenderer, I18n.translate("lambdacontrols.menu.title"), this.width / 2, 8, 16777215);
|
||||
drawCenteredString(matrices, this.textRenderer, I18n.translate("lambdacontrols.controller.mappings.1", Formatting.GREEN.toString(), Formatting.RESET.toString()), this.width / 2, this.height - 29 - (5 + this.textRenderer.fontHeight) * 3, 10526880);
|
||||
this.gamepadToolUrlLabel.render(matrices, mouseX, mouseY, delta);
|
||||
this.drawCenteredString(matrices, this.textRenderer, I18n.translate("lambdacontrols.controller.mappings.3", Formatting.GREEN.toString(), Formatting.RESET.toString()), this.width / 2, this.height - 29 - (5 + this.textRenderer.fontHeight), 10526880);
|
||||
drawCenteredString(matrices, this.textRenderer, I18n.translate("lambdacontrols.controller.mappings.3", Formatting.GREEN.toString(), Formatting.RESET.toString()), this.width / 2, this.height - 29 - (5 + this.textRenderer.fontHeight), 10526880);
|
||||
|
||||
Tooltip.renderAll(matrices);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright © 2020 LambdAurora <aurora42lambda@gmail.com>
|
||||
*
|
||||
* This file is part of LambdaControls.
|
||||
*
|
||||
* Licensed under the MIT license. For more information,
|
||||
* see the LICENSE file.
|
||||
*/
|
||||
|
||||
package me.lambdaurora.lambdacontrols.client.gui;
|
||||
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||
import me.lambdaurora.lambdacontrols.client.controller.Controller;
|
||||
import me.lambdaurora.spruceui.SpruceTextAreaWidget;
|
||||
import me.lambdaurora.spruceui.SpruceTexts;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.options.Option;
|
||||
import net.minecraft.client.toast.SystemToast;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
/**
|
||||
* Represents the controller mappings file editor screen.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.4.3
|
||||
* @since 1.4.3
|
||||
*/
|
||||
public class MappingsStringInputScreen extends Screen
|
||||
{
|
||||
private final Screen parent;
|
||||
private final Option reloadMappingsOption;
|
||||
private String mappings;
|
||||
private SpruceTextAreaWidget textArea;
|
||||
|
||||
protected MappingsStringInputScreen(@Nullable Screen parent)
|
||||
{
|
||||
super(new TranslatableText("lambdacontrols.menu.title.mappings.string"));
|
||||
this.parent = parent;
|
||||
|
||||
this.reloadMappingsOption = new ReloadControllerMappingsOption(btn -> {
|
||||
this.writeMappings();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removed()
|
||||
{
|
||||
this.writeMappings();
|
||||
Controller.updateMappings();
|
||||
super.removed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose()
|
||||
{
|
||||
this.removed();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
public void writeMappings()
|
||||
{
|
||||
if (this.textArea != null) {
|
||||
this.mappings = this.textArea.getText();
|
||||
System.out.println(this.mappings);
|
||||
try {
|
||||
FileWriter fw = new FileWriter(LambdaControlsClient.MAPPINGS_FILE, false);
|
||||
fw.write(this.mappings);
|
||||
fw.close();
|
||||
} catch (IOException e) {
|
||||
if (this.client != null)
|
||||
this.client.getToastManager().add(SystemToast.create(this.client, SystemToast.Type.TUTORIAL_HINT,
|
||||
new TranslatableText("lambdacontrols.controller.mappings.error.write"), LiteralText.EMPTY));
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
if (this.textArea != null) {
|
||||
this.mappings = this.textArea.getText();
|
||||
}
|
||||
|
||||
String mappings = "";
|
||||
|
||||
if (this.mappings != null)
|
||||
mappings = this.mappings;
|
||||
else if (LambdaControlsClient.MAPPINGS_FILE.exists()) {
|
||||
try {
|
||||
mappings = String.join("\n", Files.readAllLines(LambdaControlsClient.MAPPINGS_FILE.toPath()));
|
||||
this.mappings = mappings;
|
||||
} catch (IOException e) {
|
||||
/* Ignored */
|
||||
}
|
||||
}
|
||||
|
||||
int textFieldWidth = (int) (this.width * (3.0 / 4.0));
|
||||
this.textArea = new SpruceTextAreaWidget(this.textRenderer, this.width / 2 - textFieldWidth / 2, 50, textFieldWidth, this.height - 100, new LiteralText(mappings));
|
||||
this.textArea.setText(mappings);
|
||||
// Display as many lines as possible
|
||||
this.textArea.setDisplayedLines(this.textArea.getInnerHeight() / this.textRenderer.fontHeight);
|
||||
this.addButton(this.textArea);
|
||||
|
||||
this.addButton(this.reloadMappingsOption.createButton(this.client.options, this.width / 2 - 155, this.height - 29, 150));
|
||||
this.addButton(new ButtonWidget(this.width / 2 - 155 + 160, this.height - 29, 150, 20, SpruceTexts.GUI_DONE,
|
||||
(buttonWidget) -> this.client.openScreen(this.parent)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
this.renderBackground(matrices);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 8, 16777215);
|
||||
}
|
||||
}
|
||||
@@ -10,46 +10,39 @@
|
||||
package me.lambdaurora.lambdacontrols.client.gui;
|
||||
|
||||
import me.lambdaurora.lambdacontrols.client.controller.Controller;
|
||||
import me.lambdaurora.spruceui.SpruceButtonWidget;
|
||||
import me.lambdaurora.spruceui.option.SpruceSimpleActionOption;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import net.minecraft.client.options.GameOptions;
|
||||
import net.minecraft.client.options.Option;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.client.toast.SystemToast;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import org.aperlambda.lambdacommon.utils.Nameable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Represents the option to reload the controller mappings.
|
||||
*/
|
||||
public class ReloadControllerMappingsOption extends Option implements Nameable
|
||||
public class ReloadControllerMappingsOption extends SpruceSimpleActionOption
|
||||
{
|
||||
private static final String KEY = "lambdacontrols.menu.reload_controller_mappings";
|
||||
|
||||
public ReloadControllerMappingsOption()
|
||||
{
|
||||
super(KEY);
|
||||
this(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractButtonWidget createButton(GameOptions options, int x, int y, int width)
|
||||
public ReloadControllerMappingsOption(@Nullable Consumer<AbstractButtonWidget> before)
|
||||
{
|
||||
SpruceButtonWidget button = new SpruceButtonWidget(x, y, width, 20, new TranslatableText(KEY), btn -> {
|
||||
super(KEY, btn -> {
|
||||
MinecraftClient client = MinecraftClient.getInstance();
|
||||
if (before != null)
|
||||
before.accept(btn);
|
||||
Controller.updateMappings();
|
||||
if (client.currentScreen != null)
|
||||
if (client.currentScreen instanceof LambdaControlsSettingsScreen)
|
||||
client.currentScreen.init(client, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight());
|
||||
client.getToastManager().add(new SystemToast(SystemToast.Type.TUTORIAL_HINT, new TranslatableText("lambdacontrols.controller.mappings.updated"), null));
|
||||
});
|
||||
button.setTooltip(new TranslatableText("lambdacontrols.tooltip.reload_controller_mappings"));
|
||||
return button;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getName()
|
||||
{
|
||||
return I18n.translate(KEY);
|
||||
client.getToastManager().add(SystemToast.create(client, SystemToast.Type.TUTORIAL_HINT,
|
||||
new TranslatableText("lambdacontrols.controller.mappings.updated"), LiteralText.EMPTY));
|
||||
}, new TranslatableText("lambdacontrols.tooltip.reload_controller_mappings"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright © 2020 LambdAurora <aurora42lambda@gmail.com>
|
||||
*
|
||||
* This file is part of LambdaControls.
|
||||
*
|
||||
* Licensed under the MIT license. For more information,
|
||||
* see the LICENSE file.
|
||||
*/
|
||||
|
||||
package me.lambdaurora.lambdacontrols.client.gui;
|
||||
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||
import me.lambdaurora.lambdacontrols.client.ring.RingPage;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
|
||||
/**
|
||||
* Represents the controls ring screen.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.4.3
|
||||
* @since 1.4.3
|
||||
*/
|
||||
public class RingScreen extends Screen
|
||||
{
|
||||
protected final LambdaControlsClient mod;
|
||||
|
||||
public RingScreen()
|
||||
{
|
||||
super(new TranslatableText("lambdacontrols.menu.title.ring"));
|
||||
this.mod = LambdaControlsClient.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPauseScreen()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
|
||||
RingPage page = this.mod.ring.getCurrentPage();
|
||||
|
||||
page.render(matrices, this.textRenderer, this.width, this.height, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int button)
|
||||
{
|
||||
if (LambdaControlsClient.BINDING_RING.matchesMouse(button)) {
|
||||
this.onClose();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright © 2020 LambdAurora <aurora42lambda@gmail.com>
|
||||
*
|
||||
* This file is part of LambdaControls.
|
||||
*
|
||||
* Licensed under the MIT license. For more information,
|
||||
* see the LICENSE file.
|
||||
*/
|
||||
|
||||
package me.lambdaurora.lambdacontrols.client.ring;
|
||||
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DummyRingAction extends RingAction
|
||||
{
|
||||
@Override
|
||||
public @NotNull String getName()
|
||||
{
|
||||
return "dummy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAction(@NotNull RingButtonMode mode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(@NotNull MatrixStack matrices, @NotNull TextRenderer textRenderer, int x, int y, boolean hovered)
|
||||
{
|
||||
drawCenteredString(matrices, textRenderer, this.getName(), x + 25, y + 25 - textRenderer.fontHeight / 2, 0xffffff);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,10 @@
|
||||
package me.lambdaurora.lambdacontrols.client.ring;
|
||||
|
||||
import me.lambdaurora.lambdacontrols.client.util.KeyBindingAccessor;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.options.KeyBinding;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class KeyBindingRingAction extends RingAction
|
||||
@@ -43,4 +46,10 @@ public class KeyBindingRingAction extends RingAction
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(@NotNull MatrixStack matrices, @NotNull TextRenderer textRenderer, int x, int y, boolean hovered)
|
||||
{
|
||||
drawCenteredText(matrices, textRenderer, new TranslatableText(this.getName()), x + 25, y + 25 - textRenderer.fontHeight / 2, 0xffffff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,13 +19,14 @@ import java.util.List;
|
||||
* Represents a key binding ring.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.4.0
|
||||
* @version 1.4.3
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public class LambdaRing
|
||||
{
|
||||
private final List<RingPage> pages = new ArrayList<>(Collections.singletonList(new RingPage()));
|
||||
private int currentPage = 0;
|
||||
public static final int ELEMENT_SIZE = 50;
|
||||
private final List<RingPage> pages = new ArrayList<>(Collections.singletonList(new RingPage()));
|
||||
private int currentPage = 0;
|
||||
|
||||
public LambdaRing()
|
||||
{
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
|
||||
package me.lambdaurora.lambdacontrols.client.ring;
|
||||
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import org.aperlambda.lambdacommon.utils.Nameable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -17,19 +21,19 @@ import org.jetbrains.annotations.NotNull;
|
||||
* Represents a ring action.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.4.0
|
||||
* @version 1.4.3
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public abstract class RingAction implements Nameable
|
||||
public abstract class RingAction extends DrawableHelper implements Nameable
|
||||
{
|
||||
protected boolean activated = false;
|
||||
|
||||
/**
|
||||
* Gets the translated name of the ring action.
|
||||
* Gets the text name of the ring action.
|
||||
*
|
||||
* @return The translated name.
|
||||
* @return The text name.
|
||||
*/
|
||||
public TranslatableText getTranslatedName()
|
||||
public Text getTextName()
|
||||
{
|
||||
return new TranslatableText(this.getName());
|
||||
}
|
||||
@@ -52,4 +56,12 @@ public abstract class RingAction implements Nameable
|
||||
}
|
||||
|
||||
public abstract void onAction(@NotNull RingButtonMode mode);
|
||||
|
||||
public void render(@NotNull MatrixStack matrices, @NotNull TextRenderer textRenderer, int x, int y, boolean hovered)
|
||||
{
|
||||
fill(matrices, x, y, x + LambdaRing.ELEMENT_SIZE, y + LambdaRing.ELEMENT_SIZE, hovered ? 0xbb777777 : 0xbb000000);
|
||||
drawIcon(matrices, textRenderer, x, y, hovered);
|
||||
}
|
||||
|
||||
public abstract void drawIcon(@NotNull MatrixStack matrices, @NotNull TextRenderer textRenderer, int x, int y, boolean hovered);
|
||||
}
|
||||
|
||||
@@ -9,16 +9,79 @@
|
||||
|
||||
package me.lambdaurora.lambdacontrols.client.ring;
|
||||
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a ring page.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.4.0
|
||||
* @version 1.4.3
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public class RingPage
|
||||
public class RingPage extends DrawableHelper
|
||||
{
|
||||
private RingAction[] actions = new RingAction[8];
|
||||
|
||||
public RingPage()
|
||||
{
|
||||
for (int i = 0; i < 8; i++) {
|
||||
this.actions[i] = new DummyRingAction();
|
||||
}
|
||||
this.actions[1] = new KeyBindingRingAction(LambdaControlsClient.BINDING_LOOK_UP);
|
||||
this.actions[3] = new KeyBindingRingAction(LambdaControlsClient.BINDING_LOOK_LEFT);
|
||||
this.actions[4] = new KeyBindingRingAction(LambdaControlsClient.BINDING_LOOK_RIGHT);
|
||||
this.actions[6] = new KeyBindingRingAction(LambdaControlsClient.BINDING_LOOK_DOWN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the ring page.
|
||||
*
|
||||
* @param matrices The matrices.
|
||||
* @param width The screen width.
|
||||
* @param height The screen height.
|
||||
* @param mouseX The mouse X-coordinate.
|
||||
* @param mouseY The mouse Y-coordinate.
|
||||
* @param tickDelta The tick delta.
|
||||
*/
|
||||
public void render(@NotNull MatrixStack matrices, @NotNull TextRenderer textRenderer, int width, int height, int mouseX, int mouseY, float tickDelta)
|
||||
{
|
||||
int centerX = width / 2;
|
||||
int centerY = height / 2;
|
||||
|
||||
int offset = LambdaRing.ELEMENT_SIZE + (LambdaRing.ELEMENT_SIZE / 2) + 5;
|
||||
|
||||
int y = centerY - offset;
|
||||
int x = centerX - offset;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
RingAction ringAction = this.actions[i];
|
||||
if (ringAction != null)
|
||||
ringAction.render(matrices, textRenderer, x, y, isHovered(x, y, mouseX, mouseY));
|
||||
x += 55;
|
||||
}
|
||||
y += 55;
|
||||
x = centerX - offset;
|
||||
for (int i = 3; i < 5; i++) {
|
||||
RingAction ringAction = this.actions[i];
|
||||
if (ringAction != null)
|
||||
ringAction.render(matrices, textRenderer, x, y, isHovered(x, y, mouseX, mouseY));
|
||||
x += 55 * 2;
|
||||
}
|
||||
y += 55;
|
||||
x = centerX - offset;
|
||||
for (int i = 5; i < 8; i++) {
|
||||
RingAction ringAction = this.actions[i];
|
||||
if (ringAction != null)
|
||||
ringAction.render(matrices, textRenderer, x, y, isHovered(x, y, mouseX, mouseY));
|
||||
x += 55;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isHovered(int x, int y, int mouseX, int mouseY)
|
||||
{
|
||||
return mouseX >= x && mouseY >= y && mouseX <= x + LambdaRing.ELEMENT_SIZE && mouseY <= y + LambdaRing.ELEMENT_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"key.lambdacontrols.look_left": "Look left",
|
||||
"key.lambdacontrols.look_right": "Look right",
|
||||
"key.lambdacontrols.look_up": "Look up",
|
||||
"key.lambdacontrols.ring": "Show controls ring",
|
||||
"lambdacontrols.action.attack": "Attack",
|
||||
"lambdacontrols.action.back": "Back",
|
||||
"lambdacontrols.action.chat": "Open Chat",
|
||||
@@ -64,6 +65,8 @@
|
||||
"lambdacontrols.controller.disconnected": "Controller %d disconnected.",
|
||||
"lambdacontrols.controller.mappings.1": "To configure the controller mappings, please use %sSDL2 Gamepad Tool%s",
|
||||
"lambdacontrols.controller.mappings.3": "and put the mapping in `%s.minecraft/config/gamecontrollerdb.txt%s`.",
|
||||
"lambdacontrols.controller.mappings.error": "Error while loading mappings.",
|
||||
"lambdacontrols.controller.mappings.error.write": "Error while writing mappings to file.",
|
||||
"lambdacontrols.controller.mappings.updated": "Updated mappings!",
|
||||
"lambdacontrols.controller_type.default": "default",
|
||||
"lambdacontrols.controller_type.dualshock": "DualShock",
|
||||
@@ -90,6 +93,7 @@
|
||||
"lambdacontrols.menu.invert_right_x_axis": "Invert Right X",
|
||||
"lambdacontrols.menu.invert_right_y_axis": "Invert Right Y",
|
||||
"lambdacontrols.menu.keyboard_controls": "Keyboard Controls...",
|
||||
"lambdacontrols.menu.mappings.open_input_str": "Open Mappings File Editor",
|
||||
"lambdacontrols.menu.mouse_speed": "Mouse Speed",
|
||||
"lambdacontrols.menu.reacharound.horizontal": "Front Block Placing",
|
||||
"lambdacontrols.menu.reacharound.vertical": "Vertical Reacharound",
|
||||
@@ -101,6 +105,7 @@
|
||||
"lambdacontrols.menu.title.gameplay": "Gameplay Options",
|
||||
"lambdacontrols.menu.title.general": "General Options",
|
||||
"lambdacontrols.menu.title.hud": "HUD Options",
|
||||
"lambdacontrols.menu.title.mappings.string": "Mappings File Editor",
|
||||
"lambdacontrols.menu.unfocused_input": "Unfocused Input",
|
||||
"lambdacontrols.menu.virtual_mouse": "Virtual Mouse",
|
||||
"lambdacontrols.menu.virtual_mouse.skin": "Virtual Mouse Skin",
|
||||
|
||||
@@ -61,6 +61,8 @@
|
||||
"lambdacontrols.controller.disconnected": "Manette %d déconnecté.",
|
||||
"lambdacontrols.controller.mappings.1": "Pour configurer les correspondances de la manette, veuillez utiliser %sSDL2 Gamepad Tool%s",
|
||||
"lambdacontrols.controller.mappings.3": "et mettez les correspondances dans le fichier `%s.minecraft/config/gamecontrollerdb.txt%s`.",
|
||||
"lambdacontrols.controller.mappings.error": "Une erreur est apparue pendant le chargement des manettes.",
|
||||
"lambdacontrols.controller.mappings.error.write": "Une erreur est apparue pendant l'écriture des manettes au fichier.",
|
||||
"lambdacontrols.controller.mappings.updated": "Configuration des manettes mise à jour!",
|
||||
"lambdacontrols.controller_type.default": "default",
|
||||
"lambdacontrols.controller_type.dualshock": "DualShock",
|
||||
@@ -86,10 +88,11 @@
|
||||
"lambdacontrols.menu.invert_right_x_axis": "Inverser le stick droit (X)",
|
||||
"lambdacontrols.menu.invert_right_y_axis": "Inverser le stick droit (Y)",
|
||||
"lambdacontrols.menu.keyboard_controls": "Contrôles clavier...",
|
||||
"lambdacontrols.menu.mappings.open_input_str": "Ouvrir l'éditeur de fichier des manettes",
|
||||
"lambdacontrols.menu.mouse_speed": "Vitesse de la souris",
|
||||
"lambdacontrols.menu.reacharound.horizontal": "Placement avant de bloc",
|
||||
"lambdacontrols.menu.reacharound.vertical": "Placement vertical",
|
||||
"lambdacontrols.menu.reload_controller_mappings": "Recharge la configuration des manettes",
|
||||
"lambdacontrols.menu.reload_controller_mappings": "Recharger les manettes",
|
||||
"lambdacontrols.menu.rotation_speed": "Vitesse de rotation",
|
||||
"lambdacontrols.menu.title": "LambdaControls - Paramètres",
|
||||
"lambdacontrols.menu.title.controller": "Options de manettes",
|
||||
@@ -97,6 +100,7 @@
|
||||
"lambdacontrols.menu.title.gameplay": "Options de Gameplay",
|
||||
"lambdacontrols.menu.title.general": "Options générales",
|
||||
"lambdacontrols.menu.title.hud": "Options du HUD",
|
||||
"lambdacontrols.menu.title.mappings.string": "Éditeur du fichier des manettes",
|
||||
"lambdacontrols.menu.unfocused_input": "Entrée en fond",
|
||||
"lambdacontrols.menu.virtual_mouse": "Souris virtuelle",
|
||||
"lambdacontrols.menu.virtual_mouse.skin": "Apparence souris virtuelle",
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
"lambdacontrols.button.b": "B",
|
||||
"lambdacontrols.button.x": "X",
|
||||
"lambdacontrols.button.y": "Y",
|
||||
"lambdacontrols.button.left_bumper": "Gâchette haute gauche",
|
||||
"lambdacontrols.button.right_bumper": "Gâchette haute droite",
|
||||
"lambdacontrols.button.left_bumper": "Gâchette gauche",
|
||||
"lambdacontrols.button.right_bumper": "Gâchette droite",
|
||||
"lambdacontrols.button.back": "Retour",
|
||||
"lambdacontrols.button.start": "Touche Menu",
|
||||
"lambdacontrols.button.guide": "Guide",
|
||||
@@ -61,6 +61,8 @@
|
||||
"lambdacontrols.controller.disconnected": "Manette %d déconnecté.",
|
||||
"lambdacontrols.controller.mappings.1": "Pour configurer les correspondances de la manette, veuillez utiliser %sSDL2 Gamepad Tool%s",
|
||||
"lambdacontrols.controller.mappings.3": "et mettez les correspondances dans le fichier `%s.minecraft/config/gamecontrollerdb.txt%s`.",
|
||||
"lambdacontrols.controller.mappings.error": "Une erreur est apparue pendant le chargement des manettes.",
|
||||
"lambdacontrols.controller.mappings.error.write": "Une erreur est apparue pendant l'écriture des manettes au fichier.",
|
||||
"lambdacontrols.controller.mappings.updated": "Configuration des manettes mise à jour!",
|
||||
"lambdacontrols.controller_type.default": "default",
|
||||
"lambdacontrols.controller_type.dualshock": "DualShock",
|
||||
@@ -86,10 +88,11 @@
|
||||
"lambdacontrols.menu.invert_right_x_axis": "Inverser le stick droit (X)",
|
||||
"lambdacontrols.menu.invert_right_y_axis": "Inverser le stick droit (Y)",
|
||||
"lambdacontrols.menu.keyboard_controls": "Contrôles clavier...",
|
||||
"lambdacontrols.menu.mappings.open_input_str": "Ouvrir l'éditeur de fichier des manettes",
|
||||
"lambdacontrols.menu.mouse_speed": "Vitesse de la souris",
|
||||
"lambdacontrols.menu.reacharound.horizontal": "Placement avant de bloc",
|
||||
"lambdacontrols.menu.reacharound.vertical": "Placement vertical",
|
||||
"lambdacontrols.menu.reload_controller_mappings": "Recharge la configuration des manettes",
|
||||
"lambdacontrols.menu.reload_controller_mappings": "Recharger les manettes",
|
||||
"lambdacontrols.menu.rotation_speed": "Vitesse de rotation",
|
||||
"lambdacontrols.menu.title": "LambdaControls - Paramètres",
|
||||
"lambdacontrols.menu.title.controller": "Options de manettes",
|
||||
@@ -97,6 +100,7 @@
|
||||
"lambdacontrols.menu.title.gameplay": "Options de Gameplay",
|
||||
"lambdacontrols.menu.title.general": "Options générales",
|
||||
"lambdacontrols.menu.title.hud": "Options du HUD",
|
||||
"lambdacontrols.menu.title.mappings.string": "Éditeur du fichier des manettes",
|
||||
"lambdacontrols.menu.unfocused_input": "Entrée en fond",
|
||||
"lambdacontrols.menu.virtual_mouse": "Souris virtuelle",
|
||||
"lambdacontrols.menu.virtual_mouse.skin": "Apparence souris virtuelle",
|
||||
|
||||
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 334 B |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 4.2 KiB |
@@ -4,6 +4,8 @@
|
||||
controls = "default"
|
||||
# Auto switch mode.
|
||||
auto_switch_mode = false
|
||||
# Debug mode
|
||||
debug = false
|
||||
|
||||
[hud]
|
||||
# Enables the HUD.
|
||||
|
||||
@@ -31,10 +31,10 @@
|
||||
"lambdacontrols_compat.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.8.0",
|
||||
"fabricloader": ">=0.9.0",
|
||||
"fabric": ">=0.4.0",
|
||||
"minecraft": ">=1.16",
|
||||
"spruceui": ">=1.5.2"
|
||||
"minecraft": ">=1.16.2",
|
||||
"spruceui": ">=1.6.3"
|
||||
},
|
||||
"recommends": {
|
||||
"modmenu": ">=1.12.2"
|
||||
@@ -49,7 +49,6 @@
|
||||
"optifabric": "*"
|
||||
},
|
||||
"custom": {
|
||||
"modmenu:clientsideOnly": true,
|
||||
"modupdater": {
|
||||
"strategy": "curseforge",
|
||||
"projectID": 354231
|
||||
|
||||