mirror of
https://github.com/TeamMidnightDust/MidnightControls.git
synced 2025-12-13 23:25:10 +01:00
Add controller profiles, Fix HUD issues, Fix Reacharound Outline Color
Addresses #107 and #106
This commit is contained in:
@@ -10,13 +10,13 @@
|
|||||||
package eu.midnightdust.midnightcontrols.client;
|
package eu.midnightdust.midnightcontrols.client;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
import eu.midnightdust.lib.config.MidnightConfig;
|
import eu.midnightdust.lib.config.MidnightConfig;
|
||||||
import eu.midnightdust.midnightcontrols.ControlsMode;
|
import eu.midnightdust.midnightcontrols.ControlsMode;
|
||||||
import eu.midnightdust.midnightcontrols.MidnightControlsFeature;
|
import eu.midnightdust.midnightcontrols.MidnightControlsFeature;
|
||||||
import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding;
|
import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding;
|
||||||
import eu.midnightdust.midnightcontrols.client.controller.Controller;
|
import eu.midnightdust.midnightcontrols.client.controller.Controller;
|
||||||
import eu.midnightdust.midnightcontrols.client.controller.InputManager;
|
import eu.midnightdust.midnightcontrols.client.controller.InputManager;
|
||||||
import net.minecraft.client.MinecraftClient;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
@@ -67,7 +67,7 @@ public class MidnightControlsConfig extends MidnightConfig {
|
|||||||
"net.coderbot.iris.gui", "net.minecraft.client.gui.screen.advancement", "net.minecraft.client.gui.screen.pack.PackScreen", "net.minecraft.class_5375",
|
"net.coderbot.iris.gui", "net.minecraft.client.gui.screen.advancement", "net.minecraft.client.gui.screen.pack.PackScreen", "net.minecraft.class_5375",
|
||||||
"net.minecraft.class_457", "net.minecraft.class_408", "me.flashyreese.mods.reeses_sodium_options.client.gui", "dev.emi.emi.screen",
|
"net.minecraft.class_457", "net.minecraft.class_408", "me.flashyreese.mods.reeses_sodium_options.client.gui", "dev.emi.emi.screen",
|
||||||
"hardcorequesting.client.interfaces.GuiQuestBook", "hardcorequesting.client.interfaces.GuiReward", "hardcorequesting.client.interfaces.EditTrackerScreen");
|
"hardcorequesting.client.interfaces.GuiQuestBook", "hardcorequesting.client.interfaces.GuiReward", "hardcorequesting.client.interfaces.EditTrackerScreen");
|
||||||
@Entry(name = "Keybindings") public static Map<String, String> BINDINGS = new HashMap<>();
|
@Entry(name = "Keybindings") public static Map<String, String> BINDING = new HashMap<>();
|
||||||
|
|
||||||
private static final Pattern BUTTON_BINDING_PATTERN = Pattern.compile("(-?\\d+)\\+?");
|
private static final Pattern BUTTON_BINDING_PATTERN = Pattern.compile("(-?\\d+)\\+?");
|
||||||
@Entry(name = "Max analog values") public static double[] maxAnalogValues = new double[]{1, 1, 1, 1};
|
@Entry(name = "Max analog values") public static double[] maxAnalogValues = new double[]{1, 1, 1, 1};
|
||||||
@@ -76,6 +76,9 @@ public class MidnightControlsConfig extends MidnightConfig {
|
|||||||
@Entry(name = "Enable Shortcut in Controls Options") public static boolean shortcutInControls = true;
|
@Entry(name = "Enable Shortcut in Controls Options") public static boolean shortcutInControls = true;
|
||||||
@Entry(name = "Ring Bindings (WIP)") public static List<String> ringBindings = new ArrayList<>();
|
@Entry(name = "Ring Bindings (WIP)") public static List<String> ringBindings = new ArrayList<>();
|
||||||
@Entry(name = "Ignored Unbound Keys") public static List<String> ignoredUnboundKeys = Lists.newArrayList("inventorytabs.key.next_tab");
|
@Entry(name = "Ignored Unbound Keys") public static List<String> ignoredUnboundKeys = Lists.newArrayList("inventorytabs.key.next_tab");
|
||||||
|
@Entry @Hidden public static Map<String, Map<String, String>> controllerBindingProfiles = new HashMap<>();
|
||||||
|
private static Map<String, String> currentBindingProfile = new HashMap<>();
|
||||||
|
private static Controller prevController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the configuration
|
* Loads the configuration
|
||||||
@@ -95,6 +98,15 @@ public class MidnightControlsConfig extends MidnightConfig {
|
|||||||
MidnightControlsClient.get().log("Configuration saved.");
|
MidnightControlsClient.get().log("Configuration saved.");
|
||||||
MidnightControlsFeature.refreshEnabled();
|
MidnightControlsFeature.refreshEnabled();
|
||||||
}
|
}
|
||||||
|
public static void updateBindingsForController(Controller controller) {
|
||||||
|
if (controller.isConnected() && controller.isGamepad() && controllerBindingProfiles.containsKey(controller.getGuid()))
|
||||||
|
currentBindingProfile = controllerBindingProfiles.get(controller.getGuid());
|
||||||
|
else currentBindingProfile = Maps.newHashMap(BINDING);
|
||||||
|
InputManager.loadButtonBindings();
|
||||||
|
}
|
||||||
|
public static Map<String, String> getBindingsForController() {
|
||||||
|
return currentBindingProfile;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Gets the used controller.
|
* Gets the used controller.
|
||||||
*
|
*
|
||||||
@@ -118,6 +130,8 @@ public class MidnightControlsConfig extends MidnightConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (controller.isConnected() && controller.isGamepad() && MidnightControlsConfig.autoSwitchMode && !isEditing) MidnightControlsConfig.controlsMode = ControlsMode.CONTROLLER;
|
if (controller.isConnected() && controller.isGamepad() && MidnightControlsConfig.autoSwitchMode && !isEditing) MidnightControlsConfig.controlsMode = ControlsMode.CONTROLLER;
|
||||||
|
if (prevController != controller) updateBindingsForController(controller);
|
||||||
|
prevController = controller;
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +206,7 @@ public class MidnightControlsConfig extends MidnightConfig {
|
|||||||
*/
|
*/
|
||||||
public static void loadButtonBinding(@NotNull ButtonBinding button) {
|
public static void loadButtonBinding(@NotNull ButtonBinding button) {
|
||||||
button.setButton(button.getDefaultButton());
|
button.setButton(button.getDefaultButton());
|
||||||
var code = MidnightControlsConfig.BINDINGS.getOrDefault("controller.controls." + button.getName(), button.getButtonCode());
|
var code = getBindingsForController().getOrDefault("controller.controls." + button.getName(), button.getButtonCode());
|
||||||
|
|
||||||
var matcher = BUTTON_BINDING_PATTERN.matcher(code);
|
var matcher = BUTTON_BINDING_PATTERN.matcher(code);
|
||||||
|
|
||||||
@@ -216,14 +230,14 @@ public class MidnightControlsConfig extends MidnightConfig {
|
|||||||
button.setButton(buttons);
|
button.setButton(buttons);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
MidnightControlsClient.get().warn("Malformed config value \"" + code + "\" for binding \"" + button.getName() + "\".");
|
MidnightControlsClient.get().warn("Malformed config value \"" + code + "\" for binding \"" + button.getName() + "\".");
|
||||||
MidnightControlsConfig.BINDINGS.put("controller.controls." + button.getName(), button.getButtonCode());
|
setButtonBinding(button, button.getButton());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean checkValidity(@NotNull ButtonBinding binding, @NotNull String input, String group) {
|
private static boolean checkValidity(@NotNull ButtonBinding binding, @NotNull String input, String group) {
|
||||||
if (group == null) {
|
if (group == null) {
|
||||||
MidnightControlsClient.get().warn("Malformed config value \"" + input + "\" for binding \"" + binding.getName() + "\".");
|
MidnightControlsClient.get().warn("Malformed config value \"" + input + "\" for binding \"" + binding.getName() + "\".");
|
||||||
MidnightControlsConfig.BINDINGS.put("controller.controls." + binding.getName(), binding.getButtonCode());
|
setButtonBinding(binding, binding.getButton());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -237,7 +251,9 @@ public class MidnightControlsConfig extends MidnightConfig {
|
|||||||
*/
|
*/
|
||||||
public static void setButtonBinding(@NotNull ButtonBinding binding, int[] button) {
|
public static void setButtonBinding(@NotNull ButtonBinding binding, int[] button) {
|
||||||
binding.setButton(button);
|
binding.setButton(button);
|
||||||
MidnightControlsConfig.BINDINGS.put("controller.controls." + binding.getName(), binding.getButtonCode());
|
getBindingsForController().put("controller.controls." + binding.getName(), binding.getButtonCode());
|
||||||
|
if (controllerBindingProfiles.containsKey(getController().getGuid())) controllerBindingProfiles.get(getController().getGuid()).put("controller.controls." + binding.getName(), binding.getButtonCode());
|
||||||
|
else BINDING.put("controller.controls." + binding.getName(), binding.getButtonCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isBackButton(int btn, boolean isBtn, int state) {
|
public static boolean isBackButton(int btn, boolean isBtn, int state) {
|
||||||
@@ -304,13 +320,14 @@ public class MidnightControlsConfig extends MidnightConfig {
|
|||||||
secondControllerID = -1;
|
secondControllerID = -1;
|
||||||
controllerType = ControllerType.DEFAULT;
|
controllerType = ControllerType.DEFAULT;
|
||||||
mouseScreens = Lists.newArrayList("me.jellysquid.mods.sodium.client.gui", "net.coderbot.iris.gui", "net.minecraft.client.gui.screen.advancement", "net.minecraft.client.gui.screen.pack.PackScreen", "net.minecraft.class_5375", "net.minecraft.class_457", "net.minecraft.class_408", "me.flashyreese.mods.reeses_sodium_options.client.gui", "dev.emi.emi.screen");
|
mouseScreens = Lists.newArrayList("me.jellysquid.mods.sodium.client.gui", "net.coderbot.iris.gui", "net.minecraft.client.gui.screen.advancement", "net.minecraft.client.gui.screen.pack.PackScreen", "net.minecraft.class_5375", "net.minecraft.class_457", "net.minecraft.class_408", "me.flashyreese.mods.reeses_sodium_options.client.gui", "dev.emi.emi.screen");
|
||||||
BINDINGS = new HashMap<>();
|
BINDING = new HashMap<>();
|
||||||
maxAnalogValues = new double[]{1, 1, 1, 1};
|
maxAnalogValues = new double[]{1, 1, 1, 1};
|
||||||
triggerFix = true;
|
triggerFix = true;
|
||||||
enableHints = true;
|
enableHints = true;
|
||||||
shortcutInControls = true;
|
shortcutInControls = true;
|
||||||
ringBindings = new ArrayList<>();
|
ringBindings = new ArrayList<>();
|
||||||
ignoredUnboundKeys = Lists.newArrayList("inventorytabs.key.next_tab");
|
ignoredUnboundKeys = Lists.newArrayList("inventorytabs.key.next_tab");
|
||||||
|
controllerBindingProfiles = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ public class MidnightControlsHud extends Hud {
|
|||||||
private int inventoryButtonWidth = 0;
|
private int inventoryButtonWidth = 0;
|
||||||
private int swapHandsWidth = 0;
|
private int swapHandsWidth = 0;
|
||||||
private int swapHandsButtonWidth = 0;
|
private int swapHandsButtonWidth = 0;
|
||||||
|
private boolean showSwapHandsAction = false;
|
||||||
private int useWidth = 0;
|
private int useWidth = 0;
|
||||||
private int useButtonWidth = 0;
|
private int useButtonWidth = 0;
|
||||||
private BlockHitResult placeHitResult;
|
private BlockHitResult placeHitResult;
|
||||||
@@ -109,11 +110,7 @@ public class MidnightControlsHud extends Hud {
|
|||||||
int offset = 2 + this.inventoryWidth + this.inventoryButtonWidth + 4;
|
int offset = 2 + this.inventoryWidth + this.inventoryButtonWidth + 4;
|
||||||
int currentX = MidnightControlsConfig.hudSide == HudSide.LEFT ? x : x - this.inventoryButtonWidth;
|
int currentX = MidnightControlsConfig.hudSide == HudSide.LEFT ? x : x - this.inventoryButtonWidth;
|
||||||
if (!ButtonBinding.INVENTORY.isNotBound()) this.drawButton(matrices, currentX, y, ButtonBinding.INVENTORY, true);
|
if (!ButtonBinding.INVENTORY.isNotBound()) this.drawButton(matrices, currentX, y, ButtonBinding.INVENTORY, true);
|
||||||
if (isCrammed) {
|
if (!ButtonBinding.SWAP_HANDS.isNotBound() && !isCrammed && showSwapHandsAction) this.drawButton(matrices, currentX += (MidnightControlsConfig.hudSide == HudSide.LEFT ? offset : -offset), y, ButtonBinding.SWAP_HANDS, true);
|
||||||
offset = 0;
|
|
||||||
y -= 20;
|
|
||||||
}
|
|
||||||
if (!ButtonBinding.SWAP_HANDS.isNotBound()) this.drawButton(matrices, currentX += (MidnightControlsConfig.hudSide == HudSide.LEFT ? offset : -offset), y, ButtonBinding.SWAP_HANDS, true);
|
|
||||||
offset = 2 + this.swapHandsWidth + this.dropItemButtonWidth + 4;
|
offset = 2 + this.swapHandsWidth + this.dropItemButtonWidth + 4;
|
||||||
if (this.client.options.getShowSubtitles().getValue() && MidnightControlsConfig.hudSide == HudSide.RIGHT) {
|
if (this.client.options.getShowSubtitles().getValue() && MidnightControlsConfig.hudSide == HudSide.RIGHT) {
|
||||||
currentX += -offset;
|
currentX += -offset;
|
||||||
@@ -127,6 +124,13 @@ public class MidnightControlsHud extends Hud {
|
|||||||
public void renderSecondIcons(MatrixStack matrices, int x, int y) {
|
public void renderSecondIcons(MatrixStack matrices, int x, int y) {
|
||||||
int offset;
|
int offset;
|
||||||
int currentX = x;
|
int currentX = x;
|
||||||
|
if (isCrammed && showSwapHandsAction && !this.client.options.getShowSubtitles().getValue() && !ButtonBinding.SWAP_HANDS.isNotBound()) {
|
||||||
|
if (MidnightControlsConfig.hudSide == HudSide.LEFT)
|
||||||
|
currentX -= this.useButtonWidth;
|
||||||
|
this.drawButton(matrices, currentX, y, ButtonBinding.SWAP_HANDS, true);
|
||||||
|
currentX = x;
|
||||||
|
y -= 20;
|
||||||
|
}
|
||||||
if (!this.placeAction.isEmpty() && (!ButtonBinding.USE.isNotBound()) ) {
|
if (!this.placeAction.isEmpty() && (!ButtonBinding.USE.isNotBound()) ) {
|
||||||
if (MidnightControlsConfig.hudSide == HudSide.LEFT)
|
if (MidnightControlsConfig.hudSide == HudSide.LEFT)
|
||||||
currentX -= this.useButtonWidth;
|
currentX -= this.useButtonWidth;
|
||||||
@@ -151,11 +155,7 @@ public class MidnightControlsHud extends Hud {
|
|||||||
if (!ButtonBinding.INVENTORY.isNotBound()) this.drawTip(matrices, currentX, y, ButtonBinding.INVENTORY, true);
|
if (!ButtonBinding.INVENTORY.isNotBound()) this.drawTip(matrices, currentX, y, ButtonBinding.INVENTORY, true);
|
||||||
currentX += MidnightControlsConfig.hudSide == HudSide.LEFT ? this.inventoryWidth + 4 + this.swapHandsButtonWidth + 2
|
currentX += MidnightControlsConfig.hudSide == HudSide.LEFT ? this.inventoryWidth + 4 + this.swapHandsButtonWidth + 2
|
||||||
: -this.swapHandsWidth - 2 - this.swapHandsButtonWidth - 4;
|
: -this.swapHandsWidth - 2 - this.swapHandsButtonWidth - 4;
|
||||||
if (isCrammed) {
|
if (!ButtonBinding.SWAP_HANDS.isNotBound() && !isCrammed && showSwapHandsAction) this.drawTip(matrices, currentX, y, ButtonBinding.SWAP_HANDS, true);
|
||||||
currentX = MidnightControlsConfig.hudSide == HudSide.LEFT ? x + this.inventoryButtonWidth + 2 : x - this.inventoryButtonWidth - 2 - this.inventoryWidth;
|
|
||||||
y -= 20;
|
|
||||||
}
|
|
||||||
if (!ButtonBinding.SWAP_HANDS.isNotBound()) this.drawTip(matrices, currentX, y, ButtonBinding.SWAP_HANDS, true);
|
|
||||||
if (this.client.options.getShowSubtitles().getValue() && MidnightControlsConfig.hudSide == HudSide.RIGHT) {
|
if (this.client.options.getShowSubtitles().getValue() && MidnightControlsConfig.hudSide == HudSide.RIGHT) {
|
||||||
currentX += -this.dropItemWidth - 2 - this.dropItemButtonWidth - 4;
|
currentX += -this.dropItemWidth - 2 - this.dropItemButtonWidth - 4;
|
||||||
} else {
|
} else {
|
||||||
@@ -168,6 +168,14 @@ public class MidnightControlsHud extends Hud {
|
|||||||
public void renderSecondSection(MatrixStack matrices, int x, int y) {
|
public void renderSecondSection(MatrixStack matrices, int x, int y) {
|
||||||
int currentX = x;
|
int currentX = x;
|
||||||
|
|
||||||
|
if (isCrammed && showSwapHandsAction && !this.client.options.getShowSubtitles().getValue() && !ButtonBinding.SWAP_HANDS.isNotBound()) {
|
||||||
|
currentX += MidnightControlsConfig.hudSide == HudSide.RIGHT ? this.swapHandsButtonWidth + 2 : -this.swapHandsButtonWidth - 2 - this.swapHandsWidth;
|
||||||
|
|
||||||
|
this.drawTip(matrices, currentX, y, ButtonBinding.SWAP_HANDS, true);
|
||||||
|
|
||||||
|
currentX = x;
|
||||||
|
y -= 20;
|
||||||
|
}
|
||||||
if (!this.placeAction.isEmpty()) {
|
if (!this.placeAction.isEmpty()) {
|
||||||
currentX += MidnightControlsConfig.hudSide == HudSide.RIGHT ? this.useButtonWidth + 2 : -this.useButtonWidth - 2 - this.useWidth;
|
currentX += MidnightControlsConfig.hudSide == HudSide.RIGHT ? this.useButtonWidth + 2 : -this.useButtonWidth - 2 - this.useWidth;
|
||||||
|
|
||||||
@@ -244,6 +252,7 @@ public class MidnightControlsHud extends Hud {
|
|||||||
placeAction = customUseAction;
|
placeAction = customUseAction;
|
||||||
|
|
||||||
this.placeAction = placeAction;
|
this.placeAction = placeAction;
|
||||||
|
this.showSwapHandsAction = !this.client.player.getMainHandStack().isEmpty() || !this.client.player.getOffHandStack().isEmpty();
|
||||||
|
|
||||||
// Cache the "Use" tip width.
|
// Cache the "Use" tip width.
|
||||||
if (this.placeAction.isEmpty())
|
if (this.placeAction.isEmpty())
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
|
|||||||
private final SpruceOption unfocusedInputOption;
|
private final SpruceOption unfocusedInputOption;
|
||||||
private final SpruceOption invertsRightXAxis;
|
private final SpruceOption invertsRightXAxis;
|
||||||
private final SpruceOption invertsRightYAxis;
|
private final SpruceOption invertsRightYAxis;
|
||||||
|
private final SpruceOption toggleControllerProfileOption;
|
||||||
private final SpruceOption rightDeadZoneOption;
|
private final SpruceOption rightDeadZoneOption;
|
||||||
private final SpruceOption leftDeadZoneOption;
|
private final SpruceOption leftDeadZoneOption;
|
||||||
private final SpruceOption[] maxAnalogValueOptions = new SpruceOption[]{
|
private final SpruceOption[] maxAnalogValueOptions = new SpruceOption[]{
|
||||||
@@ -163,7 +164,7 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
|
|||||||
MidnightControlsConfig.controlsMode = next;
|
MidnightControlsConfig.controlsMode = next;
|
||||||
MidnightControlsConfig.save();
|
MidnightControlsConfig.save();
|
||||||
|
|
||||||
if (this.client.player != null) {
|
if (this.client != null && this.client.player != null) {
|
||||||
ClientPlayNetworking.getSender().sendPacket(MidnightControls.CONTROLS_MODE_CHANNEL, this.mod.makeControlsModeBuffer(next));
|
ClientPlayNetworking.getSender().sendPacket(MidnightControls.CONTROLS_MODE_CHANNEL, this.mod.makeControlsModeBuffer(next));
|
||||||
}
|
}
|
||||||
}, option -> option.getDisplayText(Text.translatable(MidnightControlsConfig.controlsMode.getTranslationKey())),
|
}, option -> option.getDisplayText(Text.translatable(MidnightControlsConfig.controlsMode.getTranslationKey())),
|
||||||
@@ -183,7 +184,6 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
|
|||||||
value -> MidnightControlsConfig.mouseSpeed = value, option -> option.getDisplayText(Text.literal(String.valueOf(option.get()))),
|
value -> MidnightControlsConfig.mouseSpeed = value, option -> option.getDisplayText(Text.literal(String.valueOf(option.get()))),
|
||||||
Text.translatable("midnightcontrols.tooltip.mouse_speed"));
|
Text.translatable("midnightcontrols.tooltip.mouse_speed"));
|
||||||
this.resetOption = SpruceSimpleActionOption.reset(btn -> {
|
this.resetOption = SpruceSimpleActionOption.reset(btn -> {
|
||||||
// TODO
|
|
||||||
MidnightControlsConfig.reset();
|
MidnightControlsConfig.reset();
|
||||||
var client = MinecraftClient.getInstance();
|
var client = MinecraftClient.getInstance();
|
||||||
this.init(client, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight());
|
this.init(client, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight());
|
||||||
@@ -225,6 +225,16 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
|
|||||||
option -> option.getDisplayText(MidnightControlsConfig.hudSide.getTranslatedText()),
|
option -> option.getDisplayText(MidnightControlsConfig.hudSide.getTranslatedText()),
|
||||||
Text.translatable("midnightcontrols.tooltip.hud_side"));
|
Text.translatable("midnightcontrols.tooltip.hud_side"));
|
||||||
// Controller options
|
// Controller options
|
||||||
|
this.toggleControllerProfileOption = new SpruceToggleBooleanOption("midnightcontrols.menu.separate_controller_profile", () -> MidnightControlsConfig.controllerBindingProfiles.containsKey(MidnightControlsConfig.getController().getGuid()), value -> {
|
||||||
|
if (value) {
|
||||||
|
MidnightControlsConfig.controllerBindingProfiles.put(MidnightControlsConfig.getController().getGuid(), MidnightControlsConfig.getBindingsForController());
|
||||||
|
MidnightControlsConfig.updateBindingsForController(MidnightControlsConfig.getController());
|
||||||
|
} else {
|
||||||
|
MidnightControlsConfig.controllerBindingProfiles.remove(MidnightControlsConfig.getController().getGuid());
|
||||||
|
MidnightControlsConfig.updateBindingsForController(MidnightControlsConfig.getController());
|
||||||
|
}
|
||||||
|
|
||||||
|
}, Text.translatable(""));
|
||||||
this.rightDeadZoneOption = new SpruceDoubleOption("midnightcontrols.menu.right_dead_zone", 0.05, 1.0, .05f,
|
this.rightDeadZoneOption = new SpruceDoubleOption("midnightcontrols.menu.right_dead_zone", 0.05, 1.0, .05f,
|
||||||
() -> MidnightControlsConfig.rightDeadZone,
|
() -> MidnightControlsConfig.rightDeadZone,
|
||||||
value -> MidnightControlsConfig.rightDeadZone = value, option -> {
|
value -> MidnightControlsConfig.rightDeadZone = value, option -> {
|
||||||
@@ -372,6 +382,7 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
|
|||||||
list.setBackground(new MidnightControlsBackground(130));
|
list.setBackground(new MidnightControlsBackground(130));
|
||||||
list.addSingleOptionEntry(this.controllerOption);
|
list.addSingleOptionEntry(this.controllerOption);
|
||||||
list.addSingleOptionEntry(this.secondControllerOption);
|
list.addSingleOptionEntry(this.secondControllerOption);
|
||||||
|
list.addSingleOptionEntry(this.toggleControllerProfileOption);
|
||||||
list.addSingleOptionEntry(this.unfocusedInputOption);
|
list.addSingleOptionEntry(this.unfocusedInputOption);
|
||||||
list.addOptionEntry(this.invertsRightXAxis, this.invertsRightYAxis);
|
list.addOptionEntry(this.invertsRightXAxis, this.invertsRightYAxis);
|
||||||
list.addSingleOptionEntry(this.rightDeadZoneOption);
|
list.addSingleOptionEntry(this.rightDeadZoneOption);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class GameRendererMixin {
|
|||||||
@Final
|
@Final
|
||||||
private MinecraftClient client;
|
private MinecraftClient client;
|
||||||
|
|
||||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Mouse;getX()D"))
|
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Mouse;getX()D", shift = At.Shift.BEFORE))
|
||||||
private void onRender(float tickDelta, long startTime, boolean fullRender, CallbackInfo ci) {
|
private void onRender(float tickDelta, long startTime, boolean fullRender, CallbackInfo ci) {
|
||||||
if (this.client.currentScreen != null && MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER)
|
if (this.client.currentScreen != null && MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER)
|
||||||
MidnightControlsClient.get().input.onPreRenderScreen(this.client, this.client.currentScreen);
|
MidnightControlsClient.get().input.onPreRenderScreen(this.client, this.client.currentScreen);
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
package eu.midnightdust.midnightcontrols.client.mixin;
|
package eu.midnightdust.midnightcontrols.client.mixin;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import eu.midnightdust.lib.util.MidnightColorUtil;
|
import eu.midnightdust.lib.util.MidnightColorUtil;
|
||||||
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
|
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
|
||||||
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
|
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
|
||||||
@@ -53,7 +52,7 @@ public abstract class WorldRendererMixin {
|
|||||||
private BufferBuilderStorage bufferBuilders;
|
private BufferBuilderStorage bufferBuilders;
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
public static void drawShapeOutline(MatrixStack matrixStack, VertexConsumer vertexConsumer, VoxelShape voxelShape, double d, double e, double f, float g, float h, float i, float j) {
|
private static void drawCuboidShapeOutline(MatrixStack matrices, VertexConsumer vertexConsumer, VoxelShape shape, double offsetX, double offsetY, double offsetZ, float red, float green, float blue, float alpha) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
@@ -73,7 +72,7 @@ public abstract class WorldRendererMixin {
|
|||||||
if (result == null)
|
if (result == null)
|
||||||
return;
|
return;
|
||||||
var blockPos = result.getBlockPos();
|
var blockPos = result.getBlockPos();
|
||||||
if (this.world.getWorldBorder().contains(blockPos)) {
|
if (this.world.getWorldBorder().contains(blockPos) && this.client.player != null) {
|
||||||
var stack = this.client.player.getStackInHand(Hand.MAIN_HAND);
|
var stack = this.client.player.getStackInHand(Hand.MAIN_HAND);
|
||||||
if (stack == null || !(stack.getItem() instanceof BlockItem))
|
if (stack == null || !(stack.getItem() instanceof BlockItem))
|
||||||
return;
|
return;
|
||||||
@@ -92,15 +91,9 @@ public abstract class WorldRendererMixin {
|
|||||||
var outlineShape = placementState.getOutlineShape(this.client.world, blockPos, ShapeContext.of(camera.getFocusedEntity()));
|
var outlineShape = placementState.getOutlineShape(this.client.world, blockPos, ShapeContext.of(camera.getFocusedEntity()));
|
||||||
Color rgb = MidnightColorUtil.hex2Rgb(MidnightControlsConfig.reacharoundOutlineColorHex);
|
Color rgb = MidnightColorUtil.hex2Rgb(MidnightControlsConfig.reacharoundOutlineColorHex);
|
||||||
if (MidnightControlsConfig.reacharoundOutlineColorHex.isEmpty()) rgb = MidnightColorUtil.radialRainbow(1,1);
|
if (MidnightControlsConfig.reacharoundOutlineColorHex.isEmpty()) rgb = MidnightColorUtil.radialRainbow(1,1);
|
||||||
|
|
||||||
RenderSystem.defaultBlendFunc();
|
|
||||||
RenderSystem.disableTexture();
|
|
||||||
RenderSystem.disableBlend();
|
|
||||||
RenderSystem.setShader(GameRenderer::getPositionColorShader);
|
|
||||||
RenderSystem.setShaderColor(rgb.getRed(), rgb.getGreen(), rgb.getBlue(), MidnightControlsConfig.reacharoundOutlineColorAlpha);
|
|
||||||
matrices.push();
|
matrices.push();
|
||||||
var vertexConsumer = this.bufferBuilders.getOutlineVertexConsumers().getBuffer(RenderLayer.getLines());
|
var vertexConsumer = this.bufferBuilders.getEntityVertexConsumers().getBuffer(RenderLayer.getLines());
|
||||||
drawShapeOutline(matrices, vertexConsumer, outlineShape,
|
drawCuboidShapeOutline(matrices, vertexConsumer, outlineShape,
|
||||||
(double) blockPos.getX() - pos.getX(), (double) blockPos.getY() - pos.getY(), (double) blockPos.getZ() - pos.getZ(),
|
(double) blockPos.getX() - pos.getX(), (double) blockPos.getY() - pos.getY(), (double) blockPos.getZ() - pos.getZ(),
|
||||||
rgb.getRed() / 255.f, rgb.getGreen() / 255.f, rgb.getBlue() / 255.f, MidnightControlsConfig.reacharoundOutlineColorAlpha / 255.f);
|
rgb.getRed() / 255.f, rgb.getGreen() / 255.f, rgb.getBlue() / 255.f, MidnightControlsConfig.reacharoundOutlineColorAlpha / 255.f);
|
||||||
matrices.pop();
|
matrices.pop();
|
||||||
|
|||||||
@@ -110,6 +110,7 @@
|
|||||||
"midnightcontrols.menu.right_dead_zone": "Tote Zone des rechten Sticks",
|
"midnightcontrols.menu.right_dead_zone": "Tote Zone des rechten Sticks",
|
||||||
"midnightcontrols.menu.rotation_speed": "Rotationsgeschwindigkeit (X-Achse)",
|
"midnightcontrols.menu.rotation_speed": "Rotationsgeschwindigkeit (X-Achse)",
|
||||||
"midnightcontrols.menu.y_axis_rotation_speed": "Rotationsgeschwindigkeit (Y-Achse)",
|
"midnightcontrols.menu.y_axis_rotation_speed": "Rotationsgeschwindigkeit (Y-Achse)",
|
||||||
|
"midnightcontrols.menu.separate_controller_profile": "Separates Controller-Profil",
|
||||||
"midnightcontrols.menu.separator.controller": "Controller",
|
"midnightcontrols.menu.separator.controller": "Controller",
|
||||||
"midnightcontrols.menu.separator.general": "Generell",
|
"midnightcontrols.menu.separator.general": "Generell",
|
||||||
"midnightcontrols.menu.title": "MidnightControls - Einstellungen",
|
"midnightcontrols.menu.title": "MidnightControls - Einstellungen",
|
||||||
|
|||||||
@@ -132,6 +132,7 @@
|
|||||||
"midnightcontrols.menu.right_dead_zone": "Right Stick Dead Zone",
|
"midnightcontrols.menu.right_dead_zone": "Right Stick Dead Zone",
|
||||||
"midnightcontrols.menu.rotation_speed": "X Axis Rotation Speed",
|
"midnightcontrols.menu.rotation_speed": "X Axis Rotation Speed",
|
||||||
"midnightcontrols.menu.y_axis_rotation_speed": "Y Axis Rotation Speed",
|
"midnightcontrols.menu.y_axis_rotation_speed": "Y Axis Rotation Speed",
|
||||||
|
"midnightcontrols.menu.separate_controller_profile": "Separate Controller Profile",
|
||||||
"midnightcontrols.menu.separator.controller": "Controller",
|
"midnightcontrols.menu.separator.controller": "Controller",
|
||||||
"midnightcontrols.menu.separator.general": "General",
|
"midnightcontrols.menu.separator.general": "General",
|
||||||
"midnightcontrols.menu.title": "MidnightControls - Settings",
|
"midnightcontrols.menu.title": "MidnightControls - Settings",
|
||||||
|
|||||||
Reference in New Issue
Block a user