Various fixes

- Fix #309 (Missing translations)
- Fix controller input always being read
- Improved injection of options button (Closes #305)
This commit is contained in:
Martin Prokoph
2024-10-20 16:59:26 +02:00
parent 929639c081
commit a3b8d7cbb5
4 changed files with 17 additions and 15 deletions

View File

@@ -88,8 +88,10 @@ public class MidnightControlsClient extends MidnightControls {
timer.scheduleAtFixedRate(new TimerTask() {
public void run() { // TODO: Add a try/catch here after the alpha testing period
if (lateInitDone && client.isRunning()) {
input.tickCameraStick();
input.updateCamera();
if (MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER && (client.isWindowFocused() || MidnightControlsConfig.unfocusedInput)) {
input.tickCameraStick();
input.updateCamera();
}
}
}
}, delay, period);

View File

@@ -74,7 +74,7 @@ public class MidnightControlsConfig extends MidnightConfig {
@Entry(category = VISUAL, name = "Reacharound Outline Alpha", isSlider = true, min = 0, max = 255) public static int reacharoundOutlineColorAlpha = 102;
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.right_dead_zone", isSlider = true, min = 0.05, max = 1) public static double rightDeadZone = 0.25;
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.left_dead_zone", isSlider = true, min = 0.05, max = 1) public static double leftDeadZone = 0.25;
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.trigger_dead_zone", isSlider = true, min = 0.05, max = 1) public static double triggerDeadZone = 0.1;
@Entry(category = CONTROLLER, name = "Trigger Dead-Zone", isSlider = true, min = 0.05, max = 1) public static double triggerDeadZone = 0.1;
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.invert_right_y_axis") public static boolean invertRightYAxis = false;
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.invert_right_x_axis") public static boolean invertRightXAxis = false;
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.rotation_speed", isSlider = true, min = 0, max = 100, precision = 10) public static double rotationSpeed = 35.0; //used for x-axis, name kept for compatibility

View File

@@ -40,22 +40,22 @@ public abstract class GameOptionsScreenMixin extends Screen {
super(title);
}
@Inject(method = "initTabNavigation", at = @At("TAIL"))
public void addMidnightButton(CallbackInfo ci) {
@Inject(method = "init", at = @At("TAIL"))
public void midnightcontrols$addMCButton(CallbackInfo ci) {
if (this.getClass().toString().equals(ControlsOptionsScreen.class.toString())) {
this.midnightcontrols$setupButton();
this.midnightcontrols$setButtonPos();
this.addDrawableChild(midnightcontrols$button);
}
}
@Override
public void resize(MinecraftClient client, int width, int height) {
super.resize(client, width, height);
this.midnightcontrols$setupButton();
@Inject(method = "initTabNavigation", at = @At("TAIL"))
public void midnightcontrols$onResize(CallbackInfo ci) {
this.midnightcontrols$setButtonPos();
}
@Unique
public void midnightcontrols$setupButton() {
assert body != null;
midnightcontrols$button.setPosition(body.getWidth() / 2 + 158, body.getY() + 4);
public void midnightcontrols$setButtonPos() {
if (body != null) {
midnightcontrols$button.setPosition(body.getWidth() / 2 + 158, body.getY() + 4);
}
}
}

View File

@@ -130,8 +130,8 @@
"midnightcontrols.controls_mode.default": "Keyboard/Mouse",
"midnightcontrols.controls_mode.controller": "Controller",
"midnightcontrols.controls_mode.touchscreen": "Touchscreen (Beta)",
"midnightcontrols.hud_side.left": "Left",
"midnightcontrols.hud_side.right": "Right",
"midnightcontrols.hud_side.LEFT": "Left",
"midnightcontrols.hud_side.RIGHT": "Right",
"midnightcontrols.menu.analog_movement": "Analog Movement",
"midnightcontrols.menu.analog_movement.tooltip": "When possible, enables analog movement.",
"midnightcontrols.menu.auto_switch_mode": "Auto Switch Mode",