mirror of
https://github.com/TeamMidnightDust/MidnightControls.git
synced 2025-12-13 23:25:10 +01:00
🔖 LambdaControls v1.3.0: Update to Minecraft 1.16.1.
This commit is contained in:
@@ -56,6 +56,7 @@ public class LambdaControlsClient extends LambdaControls implements ClientModIni
|
|||||||
InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_KP_4, "key.categories.movement");
|
InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_KP_4, "key.categories.movement");
|
||||||
public static final Identifier CONTROLLER_BUTTONS = new Identifier(LambdaControlsConstants.NAMESPACE, "textures/gui/controller_buttons.png");
|
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 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 LambdaControlsConfig config = new LambdaControlsConfig(this);
|
public final LambdaControlsConfig config = new LambdaControlsConfig(this);
|
||||||
public final LambdaInput input = new LambdaInput(this);
|
public final LambdaInput input = new LambdaInput(this);
|
||||||
private LambdaControlsHud hud;
|
private LambdaControlsHud hud;
|
||||||
|
|||||||
@@ -34,23 +34,25 @@ import static org.lwjgl.glfw.GLFW.GLFW_GAMEPAD_AXIS_LEFT_Y;
|
|||||||
public class LambdaControlsConfig
|
public class LambdaControlsConfig
|
||||||
{
|
{
|
||||||
// General
|
// General
|
||||||
private static final ControlsMode DEFAULT_CONTROLS_MODE = ControlsMode.DEFAULT;
|
private static final ControlsMode DEFAULT_CONTROLS_MODE = ControlsMode.DEFAULT;
|
||||||
private static final boolean DEFAULT_AUTO_SWITCH_MODE = false;
|
private static final boolean DEFAULT_AUTO_SWITCH_MODE = false;
|
||||||
// HUD
|
// HUD
|
||||||
private static final boolean DEFAULT_HUD_ENABLE = true;
|
private static final boolean DEFAULT_HUD_ENABLE = true;
|
||||||
private static final HudSide DEFAULT_HUD_SIDE = HudSide.LEFT;
|
private static final HudSide DEFAULT_HUD_SIDE = HudSide.LEFT;
|
||||||
// Gameplay
|
// Gameplay
|
||||||
private static final boolean DEFAULT_FAST_BLOCK_INTERACTION = true;
|
private static final boolean DEFAULT_FAST_BLOCK_INTERACTION = true;
|
||||||
private static final boolean DEFAULT_FLY_DRIFTING = false;
|
private static final boolean DEFAULT_FLY_DRIFTING = false;
|
||||||
private static final boolean DEFAULT_FLY_VERTICAL_DRIFTING = true;
|
private static final boolean DEFAULT_FLY_VERTICAL_DRIFTING = true;
|
||||||
private static final boolean DEFAULT_FRONT_BLOCK_PLACING = false;
|
private static final boolean DEFAULT_FRONT_BLOCK_PLACING = false;
|
||||||
private static final boolean DEFAULT_FRONT_BLOCK_OUTLINE = true;
|
private static final boolean DEFAULT_FRONT_BLOCK_OUTLINE = true;
|
||||||
// Controller
|
// Controller
|
||||||
private static final ControllerType DEFAULT_CONTROLLER_TYPE = ControllerType.DEFAULT;
|
private static final ControllerType DEFAULT_CONTROLLER_TYPE = ControllerType.DEFAULT;
|
||||||
private static final double DEFAULT_DEAD_ZONE = 0.25;
|
private static final double DEFAULT_DEAD_ZONE = 0.25;
|
||||||
private static final double DEFAULT_ROTATION_SPEED = 40.0;
|
private static final double DEFAULT_ROTATION_SPEED = 40.0;
|
||||||
private static final double DEFAULT_MOUSE_SPEED = 25.0;
|
private static final double DEFAULT_MOUSE_SPEED = 25.0;
|
||||||
private static final boolean DEFAULT_UNFOCUSED_INPUT = false;
|
private static final boolean DEFAULT_UNFOCUSED_INPUT = false;
|
||||||
|
private static final boolean DEFAULT_VIRTUAL_MOUSE = false;
|
||||||
|
private static final VirtualMouseSkin DEFAULT_VIRTUAL_MOUSE_SKIN = VirtualMouseSkin.DEFAULT_LIGHT;
|
||||||
|
|
||||||
private static final Pattern BUTTON_BINDING_PATTERN = Pattern.compile("(-?\\d+)\\+?");
|
private static final Pattern BUTTON_BINDING_PATTERN = Pattern.compile("(-?\\d+)\\+?");
|
||||||
|
|
||||||
@@ -66,6 +68,8 @@ public class LambdaControlsConfig
|
|||||||
private double rotationSpeed;
|
private double rotationSpeed;
|
||||||
private double mouseSpeed;
|
private double mouseSpeed;
|
||||||
private boolean unfocusedInput;
|
private boolean unfocusedInput;
|
||||||
|
private boolean virtualMouse;
|
||||||
|
private VirtualMouseSkin virtualMouseSkin;
|
||||||
// HUD settings.
|
// HUD settings.
|
||||||
private boolean hudEnable;
|
private boolean hudEnable;
|
||||||
private HudSide hudSide;
|
private HudSide hudSide;
|
||||||
@@ -98,6 +102,8 @@ public class LambdaControlsConfig
|
|||||||
this.rotationSpeed = this.config.getOrElse("controller.rotation_speed", DEFAULT_ROTATION_SPEED);
|
this.rotationSpeed = this.config.getOrElse("controller.rotation_speed", DEFAULT_ROTATION_SPEED);
|
||||||
this.mouseSpeed = this.config.getOrElse("controller.mouse_speed", DEFAULT_MOUSE_SPEED);
|
this.mouseSpeed = this.config.getOrElse("controller.mouse_speed", DEFAULT_MOUSE_SPEED);
|
||||||
this.unfocusedInput = this.config.getOrElse("controller.unfocused_input", DEFAULT_UNFOCUSED_INPUT);
|
this.unfocusedInput = this.config.getOrElse("controller.unfocused_input", DEFAULT_UNFOCUSED_INPUT);
|
||||||
|
this.virtualMouse = this.config.getOrElse("controller.virtual_mouse", DEFAULT_VIRTUAL_MOUSE);
|
||||||
|
this.virtualMouseSkin = VirtualMouseSkin.byId(this.config.getOrElse("controller.virtual_mouse_skin", DEFAULT_VIRTUAL_MOUSE_SKIN.getName())).orElse(DEFAULT_VIRTUAL_MOUSE_SKIN);
|
||||||
// Controller controls.
|
// Controller controls.
|
||||||
InputManager.loadButtonBindings(this);
|
InputManager.loadButtonBindings(this);
|
||||||
}
|
}
|
||||||
@@ -111,6 +117,7 @@ public class LambdaControlsConfig
|
|||||||
this.config.set("controller.rotation_speed", this.rotationSpeed);
|
this.config.set("controller.rotation_speed", this.rotationSpeed);
|
||||||
this.config.set("controller.mouse_speed", this.mouseSpeed);
|
this.config.set("controller.mouse_speed", this.mouseSpeed);
|
||||||
this.config.set("controller.unfocused_input", this.unfocusedInput);
|
this.config.set("controller.unfocused_input", this.unfocusedInput);
|
||||||
|
this.config.set("controller.virtual_mouse", this.virtualMouse);
|
||||||
this.config.save();
|
this.config.save();
|
||||||
this.mod.log("Configuration saved.");
|
this.mod.log("Configuration saved.");
|
||||||
}
|
}
|
||||||
@@ -165,6 +172,8 @@ public class LambdaControlsConfig
|
|||||||
this.setRotationSpeed(DEFAULT_ROTATION_SPEED);
|
this.setRotationSpeed(DEFAULT_ROTATION_SPEED);
|
||||||
this.setMouseSpeed(DEFAULT_MOUSE_SPEED);
|
this.setMouseSpeed(DEFAULT_MOUSE_SPEED);
|
||||||
this.setUnfocusedInput(DEFAULT_UNFOCUSED_INPUT);
|
this.setUnfocusedInput(DEFAULT_UNFOCUSED_INPUT);
|
||||||
|
this.setVirtualMouse(DEFAULT_VIRTUAL_MOUSE);
|
||||||
|
this.setVirtualMouseSkin(DEFAULT_VIRTUAL_MOUSE_SKIN);
|
||||||
// HUD
|
// HUD
|
||||||
this.setHudEnabled(DEFAULT_HUD_ENABLE);
|
this.setHudEnabled(DEFAULT_HUD_ENABLE);
|
||||||
this.setHudSide(DEFAULT_HUD_SIDE);
|
this.setHudSide(DEFAULT_HUD_SIDE);
|
||||||
@@ -577,6 +586,47 @@ public class LambdaControlsConfig
|
|||||||
this.unfocusedInput = unfocusedInput;
|
this.unfocusedInput = unfocusedInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the mouse is virtual or not.
|
||||||
|
*
|
||||||
|
* @return True if the mouse is virtual, else false.
|
||||||
|
*/
|
||||||
|
public boolean hasVirtualMouse()
|
||||||
|
{
|
||||||
|
return this.virtualMouse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether the mouse is virtual or not.
|
||||||
|
*
|
||||||
|
* @param virtualMouse True if the mouse is virtual, else false.
|
||||||
|
*/
|
||||||
|
public void setVirtualMouse(boolean virtualMouse)
|
||||||
|
{
|
||||||
|
this.virtualMouse = virtualMouse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the virtual mouse skin.
|
||||||
|
*
|
||||||
|
* @return The virtual mouse skin.
|
||||||
|
*/
|
||||||
|
public VirtualMouseSkin getVirtualMouseSkin()
|
||||||
|
{
|
||||||
|
return this.virtualMouseSkin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the virtual mouse skin.
|
||||||
|
*
|
||||||
|
* @param skin The virtual mouse skin.
|
||||||
|
*/
|
||||||
|
public void setVirtualMouseSkin(VirtualMouseSkin skin)
|
||||||
|
{
|
||||||
|
this.virtualMouseSkin = skin;
|
||||||
|
this.config.set("controller.virtual_mouse_skin", skin.getName());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the right X axis sign.
|
* Gets the right X axis sign.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import me.lambdaurora.lambdacontrols.client.mixin.AdvancementsScreenAccessor;
|
|||||||
import me.lambdaurora.lambdacontrols.client.mixin.CreativeInventoryScreenAccessor;
|
import me.lambdaurora.lambdacontrols.client.mixin.CreativeInventoryScreenAccessor;
|
||||||
import me.lambdaurora.lambdacontrols.client.mixin.EntryListWidgetAccessor;
|
import me.lambdaurora.lambdacontrols.client.mixin.EntryListWidgetAccessor;
|
||||||
import me.lambdaurora.lambdacontrols.client.util.HandledScreenAccessor;
|
import me.lambdaurora.lambdacontrols.client.util.HandledScreenAccessor;
|
||||||
|
import me.lambdaurora.lambdacontrols.client.util.MouseAccessor;
|
||||||
import me.lambdaurora.spruceui.SpruceLabelWidget;
|
import me.lambdaurora.spruceui.SpruceLabelWidget;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
@@ -81,7 +82,6 @@ public class LambdaInput
|
|||||||
// Cooldowns
|
// Cooldowns
|
||||||
private int actionGuiCooldown = 0;
|
private int actionGuiCooldown = 0;
|
||||||
private int ignoreNextA = 0;
|
private int ignoreNextA = 0;
|
||||||
// Sneak state.
|
|
||||||
private double targetYaw = 0.0;
|
private double targetYaw = 0.0;
|
||||||
private double targetPitch = 0.0;
|
private double targetPitch = 0.0;
|
||||||
private float prevXAxis = 0.F;
|
private float prevXAxis = 0.F;
|
||||||
@@ -222,6 +222,9 @@ public class LambdaInput
|
|||||||
if (client.currentScreen == null) {
|
if (client.currentScreen == null) {
|
||||||
this.mouseSpeedX = this.mouseSpeedY = 0.0F;
|
this.mouseSpeedX = this.mouseSpeedY = 0.0F;
|
||||||
INPUT_MANAGER.resetMousePosition(windowWidth, windowHeight);
|
INPUT_MANAGER.resetMousePosition(windowWidth, windowHeight);
|
||||||
|
} else if (isScreenInteractive(client.currentScreen) && this.config.hasVirtualMouse()) {
|
||||||
|
((MouseAccessor) client.mouse).lambdacontrols_onCursorPos(client.getWindow().getHandle(), 0, 0);
|
||||||
|
INPUT_MANAGER.resetMouseTarget(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -616,7 +619,7 @@ public class LambdaInput
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isScreenInteractive(@NotNull Screen screen)
|
public static boolean isScreenInteractive(@NotNull Screen screen)
|
||||||
{
|
{
|
||||||
return !(screen instanceof AdvancementsScreen || screen instanceof HandledScreen || LambdaControlsCompat.requireMouseOnScreen(screen));
|
return !(screen instanceof AdvancementsScreen || screen instanceof HandledScreen || LambdaControlsCompat.requireMouseOnScreen(screen));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import net.minecraft.client.resource.language.I18n;
|
||||||
|
import org.aperlambda.lambdacommon.utils.Nameable;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the virtual mouse skins.
|
||||||
|
*
|
||||||
|
* @version 1.2.0
|
||||||
|
* @since 1.2.0
|
||||||
|
*/
|
||||||
|
public enum VirtualMouseSkin implements Nameable
|
||||||
|
{
|
||||||
|
DEFAULT_LIGHT("default_light"),
|
||||||
|
DEFAULT_DARK("default_dark"),
|
||||||
|
SECOND_LIGHT("second_light"),
|
||||||
|
SECOND_DARK("second_dark");
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
VirtualMouseSkin(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the next virtual mouse skin available.
|
||||||
|
*
|
||||||
|
* @return The next available virtual mouse skin.
|
||||||
|
*/
|
||||||
|
public VirtualMouseSkin next()
|
||||||
|
{
|
||||||
|
VirtualMouseSkin[] v = values();
|
||||||
|
if (v.length == this.ordinal() + 1)
|
||||||
|
return v[0];
|
||||||
|
return v[this.ordinal() + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the translated name of this controller type.
|
||||||
|
*
|
||||||
|
* @return The translated name of this controller type.
|
||||||
|
*/
|
||||||
|
public String getTranslatedName()
|
||||||
|
{
|
||||||
|
return I18n.translate("lambdacontrols.virtual_mouse.skin." + this.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull String getName()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the controller type from its identifier.
|
||||||
|
*
|
||||||
|
* @param id The identifier of the controller type.
|
||||||
|
* @return The controller type if found, else empty.
|
||||||
|
*/
|
||||||
|
public static Optional<VirtualMouseSkin> byId(@NotNull String id)
|
||||||
|
{
|
||||||
|
return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,7 +32,7 @@ import java.util.stream.Stream;
|
|||||||
* Represents an input manager for controllers.
|
* Represents an input manager for controllers.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.1.0
|
* @version 1.3.0
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
public class InputManager
|
public class InputManager
|
||||||
@@ -74,7 +74,8 @@ public class InputManager
|
|||||||
if (this.prevTargetMouseX != this.targetMouseX || this.prevTargetMouseY != this.targetMouseY) {
|
if (this.prevTargetMouseX != this.targetMouseX || this.prevTargetMouseY != this.targetMouseY) {
|
||||||
double mouseX = this.prevTargetMouseX + (this.targetMouseX - this.prevTargetMouseX) * client.getTickDelta() + 0.5;
|
double mouseX = this.prevTargetMouseX + (this.targetMouseX - this.prevTargetMouseX) * client.getTickDelta() + 0.5;
|
||||||
double mouseY = this.prevTargetMouseY + (this.targetMouseY - this.prevTargetMouseY) * client.getTickDelta() + 0.5;
|
double mouseY = this.prevTargetMouseY + (this.targetMouseY - this.prevTargetMouseY) * client.getTickDelta() + 0.5;
|
||||||
GLFW.glfwSetCursorPos(client.getWindow().getHandle(), mouseX, mouseY);
|
if (!LambdaControlsClient.get().config.hasVirtualMouse())
|
||||||
|
GLFW.glfwSetCursorPos(client.getWindow().getHandle(), mouseX, mouseY);
|
||||||
((MouseAccessor) client.mouse).lambdacontrols_onCursorPos(client.getWindow().getHandle(), mouseX, mouseY);
|
((MouseAccessor) client.mouse).lambdacontrols_onCursorPos(client.getWindow().getHandle(), mouseX, mouseY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,19 +9,24 @@
|
|||||||
|
|
||||||
package me.lambdaurora.lambdacontrols.client.gui;
|
package me.lambdaurora.lambdacontrols.client.gui;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||||
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
||||||
|
import me.lambdaurora.lambdacontrols.client.util.HandledScreenAccessor;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.font.TextRenderer;
|
import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.gui.DrawableHelper;
|
import net.minecraft.client.gui.DrawableHelper;
|
||||||
|
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||||
import net.minecraft.client.resource.language.I18n;
|
import net.minecraft.client.resource.language.I18n;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.screen.slot.Slot;
|
||||||
import org.aperlambda.lambdacommon.utils.Pair;
|
import org.aperlambda.lambdacommon.utils.Pair;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the LambdaControls renderer.
|
* Represents the LambdaControls renderer.
|
||||||
*
|
*
|
||||||
@@ -186,7 +191,7 @@ public class LambdaControlsRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
client.getTextureManager().bindTexture(axis ? LambdaControlsClient.CONTROLLER_AXIS : LambdaControlsClient.CONTROLLER_BUTTONS);
|
client.getTextureManager().bindTexture(axis ? LambdaControlsClient.CONTROLLER_AXIS : LambdaControlsClient.CONTROLLER_BUTTONS);
|
||||||
GlStateManager.disableDepthTest();
|
RenderSystem.disableDepthTest();
|
||||||
|
|
||||||
int assetSize = axis ? AXIS_SIZE : BUTTON_SIZE;
|
int assetSize = axis ? AXIS_SIZE : BUTTON_SIZE;
|
||||||
|
|
||||||
@@ -195,7 +200,7 @@ public class LambdaControlsRenderer
|
|||||||
(float) buttonOffset, (float) (controllerType * (axis ? AXIS_SIZE : BUTTON_SIZE)),
|
(float) buttonOffset, (float) (controllerType * (axis ? AXIS_SIZE : BUTTON_SIZE)),
|
||||||
assetSize, assetSize,
|
assetSize, assetSize,
|
||||||
256, 256);
|
256, 256);
|
||||||
GlStateManager.enableDepthTest();
|
RenderSystem.enableDepthTest();
|
||||||
|
|
||||||
return ICON_SIZE;
|
return ICON_SIZE;
|
||||||
}
|
}
|
||||||
@@ -223,4 +228,70 @@ public class LambdaControlsRenderer
|
|||||||
{
|
{
|
||||||
return 15 + 5 + textRenderer.getWidth(action);
|
return 15 + 5 + textRenderer.getWidth(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void renderVirtualCursor(@NotNull MatrixStack matrices, @NotNull MinecraftClient client)
|
||||||
|
{
|
||||||
|
if (!LambdaControlsClient.get().config.hasVirtualMouse() || client.currentScreen == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int mouseX = (int) (client.mouse.getX() * (double) client.getWindow().getScaledWidth() / (double) client.getWindow().getWidth());
|
||||||
|
int mouseY = (int) (client.mouse.getY() * (double) client.getWindow().getScaledHeight() / (double) client.getWindow().getHeight());
|
||||||
|
|
||||||
|
boolean hoverSlot = false;
|
||||||
|
|
||||||
|
if (client.currentScreen instanceof HandledScreen) {
|
||||||
|
HandledScreen inventoryScreen = (HandledScreen) client.currentScreen;
|
||||||
|
HandledScreenAccessor accessor = (HandledScreenAccessor) inventoryScreen;
|
||||||
|
int guiLeft = accessor.getX();
|
||||||
|
int guiTop = accessor.getY();
|
||||||
|
|
||||||
|
// Finds the closest slot in the GUI within 14 pixels.
|
||||||
|
int finalMouseX = mouseX;
|
||||||
|
int finalMouseY = mouseY;
|
||||||
|
Optional<Pair<Slot, Double>> closestSlot = inventoryScreen.getScreenHandler().slots.parallelStream()
|
||||||
|
.map(slot -> {
|
||||||
|
int x = guiLeft + slot.x + 8;
|
||||||
|
int y = guiTop + slot.y + 8;
|
||||||
|
|
||||||
|
// Distance between the slot and the cursor.
|
||||||
|
double distance = Math.sqrt(Math.pow(x - finalMouseX, 2) + Math.pow(y - finalMouseY, 2));
|
||||||
|
return Pair.of(slot, distance);
|
||||||
|
}).filter(entry -> entry.value <= 9.0)
|
||||||
|
.min(Comparator.comparingDouble(p -> p.value));
|
||||||
|
|
||||||
|
if (closestSlot.isPresent()) {
|
||||||
|
Slot slot = closestSlot.get().key;
|
||||||
|
mouseX = guiLeft + slot.x;
|
||||||
|
mouseY = guiTop + slot.y;
|
||||||
|
hoverSlot = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hoverSlot) {
|
||||||
|
mouseX -= 8;
|
||||||
|
mouseY -= 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
drawCursor(matrices, mouseX, mouseY, hoverSlot, client);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws the virtual cursor.
|
||||||
|
*
|
||||||
|
* @param matrices The matrix stack.
|
||||||
|
* @param x X coordinate.
|
||||||
|
* @param y Y coordinate.
|
||||||
|
* @param hoverSlot True if hovering a slot, else false.
|
||||||
|
* @param client The client instance.
|
||||||
|
*/
|
||||||
|
public static void drawCursor(@NotNull MatrixStack matrices, int x, int y, boolean hoverSlot, @NotNull MinecraftClient client)
|
||||||
|
{
|
||||||
|
client.getTextureManager().bindTexture(LambdaControlsClient.CURSOR_TEXTURE);
|
||||||
|
|
||||||
|
RenderSystem.disableDepthTest();
|
||||||
|
|
||||||
|
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
DrawableHelper.drawTexture(matrices, x, y, hoverSlot ? 16.F : 0.F, LambdaControlsClient.get().config.getVirtualMouseSkin().ordinal() * 16.F, 16, 16, 32, 64);
|
||||||
|
RenderSystem.enableDepthTest();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ public class LambdaControlsSettingsScreen extends Screen
|
|||||||
private final Option invertsRightXAxis;
|
private final Option invertsRightXAxis;
|
||||||
private final Option invertsRightYAxis;
|
private final Option invertsRightYAxis;
|
||||||
private final Option unfocusedInputOption;
|
private final Option unfocusedInputOption;
|
||||||
|
private final Option virtualMouseOption;
|
||||||
|
private final Option virtualMouseSkinOption;
|
||||||
// Hud options
|
// Hud options
|
||||||
private final Option hudEnableOption;
|
private final Option hudEnableOption;
|
||||||
private final Option hudSideOption;
|
private final Option hudSideOption;
|
||||||
@@ -168,6 +170,12 @@ public class LambdaControlsSettingsScreen extends Screen
|
|||||||
}, null, true);
|
}, null, true);
|
||||||
this.unfocusedInputOption = new SpruceBooleanOption("lambdacontrols.menu.unfocused_input", this.mod.config::hasUnfocusedInput,
|
this.unfocusedInputOption = new SpruceBooleanOption("lambdacontrols.menu.unfocused_input", this.mod.config::hasUnfocusedInput,
|
||||||
this.mod.config::setUnfocusedInput, new TranslatableText("lambdacontrols.tooltip.unfocused_input"), true);
|
this.mod.config::setUnfocusedInput, new TranslatableText("lambdacontrols.tooltip.unfocused_input"), true);
|
||||||
|
this.virtualMouseOption = new SpruceBooleanOption("lambdacontrols.menu.virtual_mouse", this.mod.config::hasVirtualMouse,
|
||||||
|
this.mod.config::setVirtualMouse, new TranslatableText("lambdacontrols.tooltip.virtual_mouse"), true);
|
||||||
|
this.virtualMouseSkinOption = new SpruceCyclingOption("lambdacontrols.menu.virtual_mouse.skin",
|
||||||
|
amount -> this.mod.config.setVirtualMouseSkin(this.mod.config.getVirtualMouseSkin().next()),
|
||||||
|
option -> option.getDisplayPrefix().append(this.mod.config.getVirtualMouseSkin().getTranslatedName()),
|
||||||
|
null);
|
||||||
// HUD options
|
// HUD options
|
||||||
this.hudEnableOption = new SpruceBooleanOption("lambdacontrols.menu.hud_enable", this.mod.config::isHudEnabled,
|
this.hudEnableOption = new SpruceBooleanOption("lambdacontrols.menu.hud_enable", this.mod.config::isHudEnabled,
|
||||||
this.mod::setHudEnabled, new TranslatableText("lambdacontrols.tooltip.hud_enable"), true);
|
this.mod::setHudEnabled, new TranslatableText("lambdacontrols.tooltip.hud_enable"), true);
|
||||||
@@ -241,7 +249,8 @@ public class LambdaControlsSettingsScreen extends Screen
|
|||||||
this.list.addSingleOptionEntry(this.secondControllerOption);
|
this.list.addSingleOptionEntry(this.secondControllerOption);
|
||||||
this.list.addOptionEntry(this.controllerTypeOption, this.deadZoneOption);
|
this.list.addOptionEntry(this.controllerTypeOption, this.deadZoneOption);
|
||||||
this.list.addOptionEntry(this.invertsRightXAxis, this.invertsRightYAxis);
|
this.list.addOptionEntry(this.invertsRightXAxis, this.invertsRightYAxis);
|
||||||
this.list.addSingleOptionEntry(this.unfocusedInputOption);
|
this.list.addOptionEntry(this.unfocusedInputOption, this.virtualMouseOption);
|
||||||
|
this.list.addSingleOptionEntry(this.virtualMouseSkinOption);
|
||||||
this.list.addSingleOptionEntry(new ReloadControllerMappingsOption());
|
this.list.addSingleOptionEntry(new ReloadControllerMappingsOption());
|
||||||
// HUD options
|
// HUD options
|
||||||
this.list.addSingleOptionEntry(new SpruceSeparatorOption("lambdacontrols.menu.title.hud", true, null));
|
this.list.addSingleOptionEntry(new SpruceSeparatorOption("lambdacontrols.menu.title.hud", true, null));
|
||||||
|
|||||||
@@ -12,12 +12,14 @@ package me.lambdaurora.lambdacontrols.client.mixin;
|
|||||||
import me.lambdaurora.lambdacontrols.LambdaControlsFeature;
|
import me.lambdaurora.lambdacontrols.LambdaControlsFeature;
|
||||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||||
import me.lambdaurora.lambdacontrols.client.LambdaInput;
|
import me.lambdaurora.lambdacontrols.client.LambdaInput;
|
||||||
|
import me.lambdaurora.lambdacontrols.client.gui.LambdaControlsRenderer;
|
||||||
import me.lambdaurora.lambdacontrols.client.util.FrontBlockPlaceResultAccessor;
|
import me.lambdaurora.lambdacontrols.client.util.FrontBlockPlaceResultAccessor;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.network.ClientPlayerEntity;
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
import net.minecraft.client.network.ClientPlayerInteractionManager;
|
import net.minecraft.client.network.ClientPlayerInteractionManager;
|
||||||
import net.minecraft.client.render.GameRenderer;
|
import net.minecraft.client.render.GameRenderer;
|
||||||
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.world.ClientWorld;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@@ -128,6 +130,11 @@ public abstract class MinecraftClientMixin implements FrontBlockPlaceResultAcces
|
|||||||
LambdaControlsClient.get().onRender((MinecraftClient) (Object) (this));
|
LambdaControlsClient.get().onRender((MinecraftClient) (Object) (this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/GameRenderer;render(FJZ)V", shift = At.Shift.AFTER))
|
||||||
|
private void renderVirtualCursor(boolean fullRender, CallbackInfo ci) {
|
||||||
|
LambdaControlsRenderer.renderVirtualCursor(new MatrixStack(), (MinecraftClient) (Object) this);
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "disconnect(Lnet/minecraft/client/gui/screen/Screen;)V", at = @At("RETURN"))
|
@Inject(method = "disconnect(Lnet/minecraft/client/gui/screen/Screen;)V", at = @At("RETURN"))
|
||||||
private void onLeave(@Nullable Screen screen, CallbackInfo ci)
|
private void onLeave(@Nullable Screen screen, CallbackInfo ci)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ package me.lambdaurora.lambdacontrols.client.mixin;
|
|||||||
|
|
||||||
import me.lambdaurora.lambdacontrols.ControlsMode;
|
import me.lambdaurora.lambdacontrols.ControlsMode;
|
||||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||||
|
import me.lambdaurora.lambdacontrols.client.LambdaControlsConfig;
|
||||||
import me.lambdaurora.lambdacontrols.client.util.MouseAccessor;
|
import me.lambdaurora.lambdacontrols.client.util.MouseAccessor;
|
||||||
import net.minecraft.client.Mouse;
|
import net.minecraft.client.Mouse;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -31,7 +32,8 @@ public abstract class MouseMixin implements MouseAccessor
|
|||||||
@Inject(method = "lockCursor", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "lockCursor", at = @At("HEAD"), cancellable = true)
|
||||||
private void onMouseLocked(CallbackInfo ci)
|
private void onMouseLocked(CallbackInfo ci)
|
||||||
{
|
{
|
||||||
if (LambdaControlsClient.get().config.getControlsMode() == ControlsMode.TOUCHSCREEN)
|
LambdaControlsConfig config = LambdaControlsClient.get().config;
|
||||||
|
if (config.getControlsMode() == ControlsMode.TOUCHSCREEN || config.hasVirtualMouse())
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,6 +99,8 @@
|
|||||||
"lambdacontrols.menu.title.hud": "HUD Options",
|
"lambdacontrols.menu.title.hud": "HUD Options",
|
||||||
"lambdacontrols.menu.unbound": "Unbound",
|
"lambdacontrols.menu.unbound": "Unbound",
|
||||||
"lambdacontrols.menu.unfocused_input": "Unfocused Input",
|
"lambdacontrols.menu.unfocused_input": "Unfocused Input",
|
||||||
|
"lambdacontrols.menu.virtual_mouse": "Virtual Mouse",
|
||||||
|
"lambdacontrols.menu.virtual_mouse.skin": "Virtual Mouse Skin",
|
||||||
"lambdacontrols.narrator.unbound": "Unbound %s",
|
"lambdacontrols.narrator.unbound": "Unbound %s",
|
||||||
"lambdacontrols.not_bound": "Not bound",
|
"lambdacontrols.not_bound": "Not bound",
|
||||||
"lambdacontrols.tooltip.auto_switch_mode": "If the controls mode should be switched to Controller automatically if one is connected.",
|
"lambdacontrols.tooltip.auto_switch_mode": "If the controls mode should be switched to Controller automatically if one is connected.",
|
||||||
@@ -115,5 +117,10 @@
|
|||||||
"lambdacontrols.tooltip.mouse_speed": "The controller's emulated mouse speed.",
|
"lambdacontrols.tooltip.mouse_speed": "The controller's emulated mouse speed.",
|
||||||
"lambdacontrols.tooltip.rotation_speed": "The camera rotation speed in controller mode.",
|
"lambdacontrols.tooltip.rotation_speed": "The camera rotation speed in controller mode.",
|
||||||
"lambdacontrols.tooltip.reload_controller_mappings": "Reloads the controller mappings file.",
|
"lambdacontrols.tooltip.reload_controller_mappings": "Reloads the controller mappings file.",
|
||||||
"lambdacontrols.tooltip.unfocused_input": "Allow controller input when the window is not focused."
|
"lambdacontrols.tooltip.unfocused_input": "Allow controller input when the window is not focused.",
|
||||||
|
"lambdacontrols.tooltip.virtual_mouse": "Enable the virtual mouse which is handful in the case of a splitscreen.",
|
||||||
|
"lambdacontrols.virtual_mouse.skin.default_light": "Default Light",
|
||||||
|
"lambdacontrols.virtual_mouse.skin.default_dark": "Default Dark",
|
||||||
|
"lambdacontrols.virtual_mouse.skin.second_light": "Second Light",
|
||||||
|
"lambdacontrols.virtual_mouse.skin.second_dark": "Second Dark"
|
||||||
}
|
}
|
||||||
@@ -98,6 +98,8 @@
|
|||||||
"lambdacontrols.menu.title.hud": "Options du HUD",
|
"lambdacontrols.menu.title.hud": "Options du HUD",
|
||||||
"lambdacontrols.menu.unbound": "Délier",
|
"lambdacontrols.menu.unbound": "Délier",
|
||||||
"lambdacontrols.menu.unfocused_input": "Entrée en fond",
|
"lambdacontrols.menu.unfocused_input": "Entrée en fond",
|
||||||
|
"lambdacontrols.menu.virtual_mouse": "Souris virtuelle",
|
||||||
|
"lambdacontrols.menu.virtual_mouse.skin": "Apparence souris virtuelle",
|
||||||
"lambdacontrols.narrator.unbound": "Délier %s",
|
"lambdacontrols.narrator.unbound": "Délier %s",
|
||||||
"lambdacontrols.not_bound": "Non défini",
|
"lambdacontrols.not_bound": "Non défini",
|
||||||
"lambdacontrols.tooltip.auto_switch_mode": "Détermine si le mode de contrôle doit automatiquement changer sur Manette si une manette est connectée et inversement.",
|
"lambdacontrols.tooltip.auto_switch_mode": "Détermine si le mode de contrôle doit automatiquement changer sur Manette si une manette est connectée et inversement.",
|
||||||
@@ -113,5 +115,10 @@
|
|||||||
"lambdacontrols.tooltip.mouse_speed": "Change la vitesse de la souris émulée par la manette.",
|
"lambdacontrols.tooltip.mouse_speed": "Change la vitesse de la souris émulée par la manette.",
|
||||||
"lambdacontrols.tooltip.rotation_speed": "Change la vitesse de rotation de la caméra.",
|
"lambdacontrols.tooltip.rotation_speed": "Change la vitesse de rotation de la caméra.",
|
||||||
"lambdacontrols.tooltip.reload_controller_mappings": "Recharge le fichier de configuration des manettes.",
|
"lambdacontrols.tooltip.reload_controller_mappings": "Recharge le fichier de configuration des manettes.",
|
||||||
"lambdacontrols.tooltip.unfocused_input": "Autorise les entrées manette quand la fenêtre n'est pas sélectionnée."
|
"lambdacontrols.tooltip.unfocused_input": "Autorise les entrées manette quand la fenêtre n'est pas sélectionnée.",
|
||||||
|
"lambdacontrols.tooltip.virtual_mouse": "Active la souris virtuelle qui est pratique dans le cas d'un écran partagé.",
|
||||||
|
"lambdacontrols.virtual_mouse.skin.default_light": "défaut clair",
|
||||||
|
"lambdacontrols.virtual_mouse.skin.default_dark": "défaut foncé",
|
||||||
|
"lambdacontrols.virtual_mouse.skin.second_light": "second clair",
|
||||||
|
"lambdacontrols.virtual_mouse.skin.second_dark": "second foncé"
|
||||||
}
|
}
|
||||||
@@ -98,6 +98,8 @@
|
|||||||
"lambdacontrols.menu.title.hud": "Options du HUD",
|
"lambdacontrols.menu.title.hud": "Options du HUD",
|
||||||
"lambdacontrols.menu.unbound": "Délier",
|
"lambdacontrols.menu.unbound": "Délier",
|
||||||
"lambdacontrols.menu.unfocused_input": "Entrée en fond",
|
"lambdacontrols.menu.unfocused_input": "Entrée en fond",
|
||||||
|
"lambdacontrols.menu.virtual_mouse": "Souris virtuelle",
|
||||||
|
"lambdacontrols.menu.virtual_mouse.skin": "Apparence souris virtuelle",
|
||||||
"lambdacontrols.narrator.unbound": "Délier %s",
|
"lambdacontrols.narrator.unbound": "Délier %s",
|
||||||
"lambdacontrols.not_bound": "Non défini",
|
"lambdacontrols.not_bound": "Non défini",
|
||||||
"lambdacontrols.tooltip.auto_switch_mode": "Détermine si le mode de contrôle doit automatiquement changer sur Manette si une manette est connectée et inversement.",
|
"lambdacontrols.tooltip.auto_switch_mode": "Détermine si le mode de contrôle doit automatiquement changer sur Manette si une manette est connectée et inversement.",
|
||||||
@@ -113,5 +115,10 @@
|
|||||||
"lambdacontrols.tooltip.mouse_speed": "Change la vitesse de la souris émulée par la manette.",
|
"lambdacontrols.tooltip.mouse_speed": "Change la vitesse de la souris émulée par la manette.",
|
||||||
"lambdacontrols.tooltip.rotation_speed": "Change la vitesse de rotation de la caméra.",
|
"lambdacontrols.tooltip.rotation_speed": "Change la vitesse de rotation de la caméra.",
|
||||||
"lambdacontrols.tooltip.reload_controller_mappings": "Recharge le fichier de configuration des manettes.",
|
"lambdacontrols.tooltip.reload_controller_mappings": "Recharge le fichier de configuration des manettes.",
|
||||||
"lambdacontrols.tooltip.unfocused_input": "Autorise les entrées manette quand la fenêtre n'est pas sélectionnée."
|
"lambdacontrols.tooltip.unfocused_input": "Autorise les entrées manette quand la fenêtre n'est pas sélectionnée.",
|
||||||
|
"lambdacontrols.tooltip.virtual_mouse": "Active la souris virtuelle qui est pratique dans le cas d'un écran partagé.",
|
||||||
|
"lambdacontrols.virtual_mouse.skin.default_light": "défaut clair",
|
||||||
|
"lambdacontrols.virtual_mouse.skin.default_dark": "défaut foncé",
|
||||||
|
"lambdacontrols.virtual_mouse.skin.second_light": "second clair",
|
||||||
|
"lambdacontrols.virtual_mouse.skin.second_dark": "second foncé"
|
||||||
}
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -49,6 +49,10 @@ auto_switch_mode = false
|
|||||||
invert_right_y_axis = false
|
invert_right_y_axis = false
|
||||||
# Allow unfocused input.
|
# Allow unfocused input.
|
||||||
unfocused_input = false
|
unfocused_input = false
|
||||||
|
# Virtual mouse.
|
||||||
|
virtual_mouse = false
|
||||||
|
# Virtual mouse skin
|
||||||
|
virtual_mouse_skin = "default_light"
|
||||||
# Controller controls.
|
# Controller controls.
|
||||||
[controller.controls]
|
[controller.controls]
|
||||||
# Attack control.
|
# Attack control.
|
||||||
|
|||||||
@@ -31,21 +31,22 @@
|
|||||||
"lambdacontrols_compat.mixins.json"
|
"lambdacontrols_compat.mixins.json"
|
||||||
],
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.4.0",
|
"fabricloader": ">=0.8.0",
|
||||||
"fabric": "*",
|
"fabric": "*",
|
||||||
"minecraft": ">=1.15",
|
"minecraft": ">=1.16",
|
||||||
"spruceui": ">=1.3.5"
|
"spruceui": ">=1.5.1"
|
||||||
},
|
},
|
||||||
"recommends": {
|
"recommends": {
|
||||||
"modmenu": ">=1.9.0",
|
"modmenu": ">=1.12.2",
|
||||||
"okzoomer": ">=1.0.4"
|
"okzoomer": ">=4.0.0"
|
||||||
},
|
},
|
||||||
"suggests": {
|
"suggests": {
|
||||||
"flamingo": "*",
|
"flamingo": "*",
|
||||||
"roughlyenoughitems": ">=3.4.5"
|
"roughlyenoughitems": ">=4.5.5"
|
||||||
},
|
},
|
||||||
"breaks": {
|
"breaks": {
|
||||||
"modmenu": "<1.9.0"
|
"modmenu": "<1.12.2",
|
||||||
|
"optifabric": "*"
|
||||||
},
|
},
|
||||||
"custom": {
|
"custom": {
|
||||||
"modmenu:clientsideOnly": true
|
"modmenu:clientsideOnly": true
|
||||||
|
|||||||
Reference in New Issue
Block a user