mirror of
https://github.com/TeamMidnightDust/MidnightControls.git
synced 2025-12-13 15:25:08 +01:00
Compare commits
5 Commits
architectu
...
architectu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e022fd1827 | ||
|
|
fbecfd5642 | ||
|
|
036be42bec | ||
|
|
4cfee5ba2e | ||
|
|
d753641fa9 |
10
.github/workflows/build.yml
vendored
10
.github/workflows/build.yml
vendored
@@ -8,10 +8,8 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/actions/wrapper-validation@v3
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
@@ -24,6 +22,4 @@ jobs:
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: MidnightControls-Artifacts
|
||||
path: |
|
||||
fabric/build/libs/
|
||||
neoforge/build/libs/
|
||||
path: /build/libs/
|
||||
|
||||
6
.github/workflows/publish.yml
vendored
6
.github/workflows/publish.yml
vendored
@@ -11,10 +11,8 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/actions/wrapper-validation@v3
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
|
||||
10
build.gradle
10
build.gradle
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id "architectury-plugin" version "3.4-SNAPSHOT"
|
||||
id "dev.architectury.loom" version "1.10-SNAPSHOT" apply false
|
||||
id "dev.architectury.loom" version "1.7-SNAPSHOT" apply false
|
||||
id "me.shedaniel.unified-publishing" version "0.1.+" apply false
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
|
||||
}
|
||||
@@ -13,9 +13,6 @@ repositories {
|
||||
maven {
|
||||
url = "https://api.modrinth.com/maven"
|
||||
}
|
||||
flatDir {
|
||||
dirs("localMaven")
|
||||
}
|
||||
}
|
||||
|
||||
subprojects {
|
||||
@@ -25,9 +22,6 @@ subprojects {
|
||||
url = "https://api.modrinth.com/maven"
|
||||
}
|
||||
maven { url 'https://jitpack.io' }
|
||||
flatDir {
|
||||
dirs("../localMaven")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -85,4 +79,4 @@ allprojects {
|
||||
java {
|
||||
withSourcesJar()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ dependencies {
|
||||
modCompileOnlyApi "org.quiltmc:quilt-json5:1.0.0"
|
||||
modImplementation "maven.modrinth:sodium:${project.sodium_version}-fabric"
|
||||
modCompileOnlyApi "maven.modrinth:emi:${project.emi_version}"
|
||||
modImplementation "maven.modrinth:emotecraft:${project.emotecraft_version}"
|
||||
modCompileOnlyApi "maven.modrinth:emotecraft:${project.emotecraft_version}"
|
||||
modCompileOnlyApi "io.github.kosmx:bendy-lib:${project.bendylib_version}"
|
||||
modCompileOnlyApi "dev.isxander:yet-another-config-lib:${project.yacl_version}"
|
||||
modCompileOnlyApi "maven.modrinth:inventory-tabs-updated:${project.inventorytabs_version}"
|
||||
|
||||
@@ -26,7 +26,6 @@ import eu.midnightdust.midnightcontrols.client.mixin.KeyBindingIDAccessor;
|
||||
import eu.midnightdust.midnightcontrols.client.ring.ButtonBindingRingAction;
|
||||
import eu.midnightdust.midnightcontrols.client.ring.MidnightRing;
|
||||
import eu.midnightdust.midnightcontrols.client.util.platform.NetworkUtil;
|
||||
import eu.midnightdust.midnightcontrols.client.virtualkeyboard.MouseClickInterceptor;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import org.thinkingstudio.obsidianui.hud.HudManager;
|
||||
import eu.midnightdust.midnightcontrols.client.touch.TouchInput;
|
||||
@@ -72,17 +71,15 @@ public class MidnightControlsClient extends MidnightControls {
|
||||
public static final Identifier WAYLAND_CURSOR_TEXTURE_LIGHT = id("cursor/light/mouse_pointer");
|
||||
public static final Identifier WAYLAND_CURSOR_TEXTURE_DARK = id("cursor/dark/mouse_pointer");
|
||||
public static final File MAPPINGS_FILE = new File("config/gamecontrollercustommappings.txt");
|
||||
public static MinecraftClient client = MinecraftClient.getInstance();
|
||||
public static final MinecraftClient client = MinecraftClient.getInstance();
|
||||
public static final MidnightInput input = new MidnightInput();
|
||||
public static final MidnightRing ring = new MidnightRing();
|
||||
public static final MidnightReacharound reacharound = new MidnightReacharound();
|
||||
public static final MouseClickInterceptor clickInterceptor = new MouseClickInterceptor();
|
||||
public static boolean isWayland;
|
||||
private static MidnightControlsHud hud;
|
||||
private static ControlsMode previousControlsMode;
|
||||
|
||||
public static void initClient() {
|
||||
client = MinecraftClient.getInstance();
|
||||
ring.registerAction("buttonbinding", ButtonBindingRingAction.FACTORY);
|
||||
|
||||
int delay = 0; // delay for 0 sec.
|
||||
@@ -93,7 +90,7 @@ public class MidnightControlsClient extends MidnightControls {
|
||||
try {
|
||||
if (lateInitDone && client.isRunning()) {
|
||||
if (MidnightControlsConfig.controlsMode != ControlsMode.DEFAULT && (client.isWindowFocused() || MidnightControlsConfig.unfocusedInput)) {
|
||||
if (MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER) input.tickCameraStick();
|
||||
input.tickCameraStick();
|
||||
input.updateCamera();
|
||||
}
|
||||
}
|
||||
@@ -207,12 +204,10 @@ public class MidnightControlsClient extends MidnightControls {
|
||||
RainbowColor.tick();
|
||||
TouchInput.tick();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when opening a screen.
|
||||
*/
|
||||
public static void onScreenOpen(Screen screen) {
|
||||
client = MinecraftClient.getInstance();
|
||||
if (screen == null && MidnightControlsConfig.controlsMode == ControlsMode.TOUCHSCREEN) {
|
||||
screen = new TouchscreenOverlay();
|
||||
screen.init(client, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight());
|
||||
|
||||
@@ -11,7 +11,7 @@ package eu.midnightdust.midnightcontrols.client;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mojang.blaze3d.platform.GLX;
|
||||
import com.mojang.blaze3d.platform.GlDebugInfo;
|
||||
import eu.midnightdust.lib.config.MidnightConfig;
|
||||
import eu.midnightdust.midnightcontrols.ControlsMode;
|
||||
import eu.midnightdust.midnightcontrols.MidnightControls;
|
||||
@@ -52,108 +52,78 @@ public class MidnightControlsConfig extends MidnightConfig {
|
||||
public static boolean isEditing = false;
|
||||
@Hidden @Entry public static int configVersion = 2;
|
||||
// General
|
||||
@Comment(category = CONTROLLER, centered = true, name="\uD83C\uDFAE General") public static Comment _general;
|
||||
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.controls_mode") public static ControlsMode controlsMode = ControlsMode.DEFAULT;
|
||||
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.auto_switch_mode") public static boolean autoSwitchMode = true;
|
||||
@Entry(category = MISC, name = "Debug") public static boolean debug = false;
|
||||
// HUD
|
||||
@Comment(category = VISUAL, centered = true, name="\uD83D\uDDB9 Hud") public static Comment _hud;
|
||||
@Entry(category = VISUAL, name = "midnightcontrols.menu.hud_enable") public static boolean hudEnable = true;
|
||||
@Entry(category = VISUAL, name = "midnightcontrols.menu.hud_side") public static HudSide hudSide = HudSide.LEFT;
|
||||
@Entry(category = VISUAL, name = "midnightcontrols.menu.controller_type") public static ControllerType controllerType = ControllerType.DEFAULT;
|
||||
@Entry(category = SCREENS, name = "midnightcontrols.menu.move_chat") public static boolean moveChat = false;
|
||||
// Gameplay
|
||||
@Comment(category = GAMEPLAY, centered = true, name="\uD83D\uDECB Comfort") public static Comment _comfort;
|
||||
@Entry(category = GAMEPLAY, name = "Enable Hints") public static boolean enableHints = true;
|
||||
@Entry(category = GAMEPLAY, name = "midnightcontrols.menu.analog_movement") public static boolean analogMovement = true;
|
||||
@Entry(category = GAMEPLAY, name = "midnightcontrols.menu.double_tap_to_sprint") public static boolean doubleTapToSprint = true;
|
||||
@Entry(category = GAMEPLAY, name = "midnightcontrols.menu.controller_toggle_sneak") public static boolean controllerToggleSneak = MinecraftClient.getInstance().options.getSneakToggled().getValue();
|
||||
@Entry(category = GAMEPLAY, name = "midnightcontrols.menu.controller_toggle_sprint") public static boolean controllerToggleSprint = MinecraftClient.getInstance().options.getSprintToggled().getValue();
|
||||
|
||||
@Condition(requiredModId = "midnightcontrols-extra")
|
||||
@Comment(category = GAMEPLAY, centered = true, name="✨ Extras") public static Comment _extras;
|
||||
@Condition(requiredModId = "midnightcontrols-extra")
|
||||
@Entry(category = GAMEPLAY, name = "midnightcontrols.menu.fast_block_placing") public static boolean fastBlockPlacing = false; // Disabled by default as this behaviour can be considered cheating on multiplayer servers.
|
||||
@Condition(requiredModId = "midnightcontrols-extra")
|
||||
@Entry(category = GAMEPLAY, name = "midnightcontrols.menu.fly_drifting") public static boolean flyDrifting = true; // Enabled by default as disabling this behaviour can be considered cheating on multiplayer servers. It can also conflict with some other mods.
|
||||
@Condition(requiredModId = "midnightcontrols-extra")
|
||||
@Entry(category = GAMEPLAY, name = "midnightcontrols.menu.fly_drifting_vertical") public static boolean verticalFlyDrifting = true; // Enabled by default as disabling this behaviour can be considered cheating on multiplayer servers.
|
||||
@Condition(requiredModId = "midnightcontrols-extra")
|
||||
@Entry(category = GAMEPLAY, name = "midnightcontrols.menu.reacharound.horizontal") public static boolean horizontalReacharound = false; // Disabled by default as this behaviour can be considered cheating on multiplayer servers.
|
||||
@Condition(requiredModId = "midnightcontrols-extra")
|
||||
@Entry(category = GAMEPLAY, name = "midnightcontrols.menu.reacharound.vertical") public static boolean verticalReacharound = false; // Disabled by default as this behaviour can be considered cheating on multiplayer servers.
|
||||
@Condition(requiredModId = "midnightcontrols-extra")
|
||||
@Comment(category = VISUAL, centered = true, name="⊽ Reacharound") public static Comment _reacharoundOutline;
|
||||
@Condition(requiredModId = "midnightcontrols-extra")
|
||||
@Entry(category = VISUAL, name = "Reacharound Outline") public static boolean shouldRenderReacharoundOutline = true;
|
||||
@Condition(requiredModId = "midnightcontrols-extra", requiredOption = "shouldRenderReacharoundOutline")
|
||||
@Entry(category = VISUAL, name = "Reacharound Outline Color", isColor = true) public static String reacharoundOutlineColorHex = "#ffffff";
|
||||
@Condition(requiredModId = "midnightcontrols-extra", requiredOption = "shouldRenderReacharoundOutline")
|
||||
@Entry(category = VISUAL, name = "Reacharound Outline Alpha", isSlider = true, min = 0, max = 255) public static int reacharoundOutlineColorAlpha = 102;
|
||||
@Comment(category = CONTROLLER, centered = true, name="\uD83D\uDCF7 Camera Settings") public static Comment _cameraSettings;
|
||||
@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 = "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
|
||||
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.y_axis_rotation_speed", isSlider = true, min = 0, max = 100, precision = 10) public static double yAxisRotationSpeed = rotationSpeed;
|
||||
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.camera_mode") public static CameraMode cameraMode = CameraMode.FLAT;
|
||||
@Comment(category = SCREENS, centered = true, name="\uD83D\uDDB1 Mouse Behaviour") public static Comment _mouseBehaviour;
|
||||
@Entry(category = SCREENS, name = "midnightcontrols.menu.mouse_speed", isSlider = true, min = 0, max = 150, precision = 10) public static double mouseSpeed = 25.0;
|
||||
@Entry(category = SCREENS, name = "midnightcontrols.menu.joystick_as_mouse") public static boolean joystickAsMouse = false;
|
||||
@Entry(category = SCREENS, name = "midnightcontrols.menu.eye_tracker_as_mouse") public static boolean eyeTrackerAsMouse = false;
|
||||
@Entry(category = SCREENS, name = "midnightcontrols.menu.eye_tracker_deadzone", isSlider = true, min = 0, max = 0.4) public static double eyeTrackerDeadzone = 0.05;
|
||||
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.unfocused_input") public static boolean unfocusedInput = false;
|
||||
@Entry(category = SCREENS, name = "midnightcontrols.menu.virtual_mouse") public static boolean virtualMouse = false;
|
||||
@Entry(category = SCREENS, name = "midnightcontrols.menu.virtual_mouse.skin") public static VirtualMouseSkin virtualMouseSkin = VirtualMouseSkin.DEFAULT_LIGHT;
|
||||
@Entry(category = SCREENS, name = "midnightcontrols.menu.hide_cursor") public static boolean hideNormalMouse = false;
|
||||
@Entry(category = CONTROLLER, name = "Controller ID") @Hidden public static Object controllerID = 0;
|
||||
@Entry(category = CONTROLLER, name = "2nd Controller ID") @Hidden public static Object secondControllerID = -1;
|
||||
@Entry(category = VISUAL, name = "midnightcontrols.menu.controller_type") public static ControllerType controllerType = ControllerType.DEFAULT;
|
||||
@Entry(category = SCREENS, name = "Mouse screens") public static List<String> mouseScreens = Lists.newArrayList("net.minecraft.client.gui.screen.advancement",
|
||||
"net.minecraft.class_457", "net.minecraft.class_408", "net.minecraft.class_3872", "me.flashyreese.mods.reeses_sodium_options.client.gui", "dev.emi.emi.screen",
|
||||
"hardcorequesting.client.interfaces.GuiQuestBook", "hardcorequesting.client.interfaces.GuiReward", "hardcorequesting.client.interfaces.EditTrackerScreen",
|
||||
"me.shedaniel.clothconfig2.gui.ClothConfigScreen", "com.mamiyaotaru.voxelmap.gui.GuiWaypoints", "com.mamiyaotaru.voxelmap.gui.GuiPersistentMap");
|
||||
@Entry(category = SCREENS, name = "Arrow screens") public static List<String> arrowScreens = Lists.newArrayList(ChatScreen.class.getCanonicalName());
|
||||
@Entry(category = SCREENS, name = "WASD screens") public static List<String> wasdScreens = Lists.newArrayList("com.ultreon.devices.core.Laptop");
|
||||
@Comment(category = CONTROLLER, centered = true, name="\uD83D\uDC40 Eye Tracking") public static Comment _eyeTracker;
|
||||
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.eye_tracker_as_mouse") public static boolean eyeTrackerAsMouse = false;
|
||||
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.eye_tracker_deadzone", isSlider = true, min = 0, max = 0.4) public static double eyeTrackerDeadzone = 0.05;
|
||||
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.unfocused_input") public static boolean unfocusedInput = false;
|
||||
@Comment(category = SCREENS, centered = true, name="\uD83D\uDC46 Virtual Mouse") public static Comment _virtualMouse;
|
||||
@Entry(category = SCREENS, name = "midnightcontrols.menu.virtual_mouse") public static boolean virtualMouse = false;
|
||||
@Condition(requiredOption = "virtualMouse", visibleButLocked = true)
|
||||
@Entry(category = SCREENS, name = "midnightcontrols.menu.virtual_mouse.skin") public static VirtualMouseSkin virtualMouseSkin = VirtualMouseSkin.DEFAULT_LIGHT;
|
||||
@Entry(category = SCREENS, name = "midnightcontrols.menu.hide_cursor") public static boolean hideNormalMouse = false;
|
||||
@Entry(category = SCREENS, name = "midnightcontrols.menu.virtual_keyboard") public static boolean virtualKeyboard = false;
|
||||
@Entry(category = CONTROLLER, name = "Controller ID") @Hidden public static Object controllerID = 0;
|
||||
@Entry(category = CONTROLLER, name = "2nd Controller ID") @Hidden public static Object secondControllerID = -1;
|
||||
@Comment(category = TOUCH, centered = true, name="\uD83E\uDE84 Behaviour") public static Comment _touchBehaviour;
|
||||
@Entry(category = TOUCH, name = "Screens with close button") public static List<String> closeButtonScreens = Lists.newArrayList(ChatScreen.class.getCanonicalName(), AdvancementsScreen.class.getCanonicalName(), RingScreen.class.getCanonicalName());
|
||||
@Entry(category = TOUCH, name = "midnightcontrols.menu.touch_with_controller") public static boolean touchInControllerMode = false;
|
||||
@Entry(category = TOUCH, name = "midnightcontrols.menu.touch_speed", isSlider = true, min = 0, max = 150, precision = 10) public static double touchSpeed = 50.0;
|
||||
@Entry(category = TOUCH, name = "midnightcontrols.menu.invert_touch") public static boolean invertTouch = false;
|
||||
@Entry(category = TOUCH, name = "midnightcontrols.menu.touch_mode") public static TouchMode touchMode = TouchMode.CROSSHAIR;
|
||||
@Entry(category = TOUCH, name = "midnightcontrols.menu.touch_break_delay", isSlider = true, min = 50, max = 500) public static int touchBreakDelay = 120;
|
||||
@Comment(category = TOUCH, centered = true, name="\uD83D\uDCA1 Visuals") public static Comment _visuals;
|
||||
@Entry(category = TOUCH, name = "midnightcontrols.menu.touch_transparency", isSlider = true, min = 0, max = 100) public static int touchTransparency = 75;
|
||||
@Entry(category = TOUCH, name = "Touch Outline Color", isColor = true) public static String touchOutlineColorHex = "#ffffff";
|
||||
@Entry(category = TOUCH, name = "Touch Outline Alpha", isSlider = true, min = 0, max = 255) public static int touchOutlineColorAlpha = 150;
|
||||
@Comment(category = TOUCH, centered = true, name="\uD83E\uDDEA Advanced") public static Comment _advanced;
|
||||
@Entry(category = TOUCH, name = "Screens with close button") public static List<String> closeButtonScreens = Lists.newArrayList(ChatScreen.class.getCanonicalName(), AdvancementsScreen.class.getCanonicalName(), RingScreen.class.getCanonicalName());
|
||||
@Entry(category = TOUCH, name = "Left Touch button bindings") public static List<String> leftTouchBinds = Lists.newArrayList("debug_screen", "screenshot","toggle_perspective");
|
||||
@Entry(category = TOUCH, name = "Right Touch button bindings") public static List<String> rightTouchBinds = Lists.newArrayList("screenshot","toggle_perspective", "use");
|
||||
|
||||
@Entry @Hidden public static Map<String, String> BINDING = new HashMap<>();
|
||||
|
||||
private static final Pattern BUTTON_BINDING_PATTERN = Pattern.compile("(-?\\d+)\\+?");
|
||||
@Comment(category = CONTROLLER, centered = true, name="\uD83D\uDD79 Max Analog Stick Values") public static Comment _maxAnalogValues;
|
||||
@Entry(category = CONTROLLER, name = "Max analog value: Left X", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueLeftX = 1;
|
||||
@Entry(category = CONTROLLER, name = "Max analog value: Left Y", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueLeftY = 1;
|
||||
@Entry(category = CONTROLLER, name = "Max analog value: Right X", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueRightX = 1;
|
||||
@Entry(category = CONTROLLER, name = "Max analog value: Right Y", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueRightY = 1;
|
||||
@Comment(category = CONTROLLER, centered = true, name="☠ Dead Zones") public static Comment _deadZones;
|
||||
@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 = "Trigger Dead-Zone", isSlider = true, min = 0.05, max = 1) public static double triggerDeadZone = 0.1;
|
||||
@Comment(category = CONTROLLER, centered = true, name="☆ Other Options") public static Comment _otherOptions;
|
||||
@Entry(category = CONTROLLER, name = "Trigger button fix") public static boolean triggerFix = true;
|
||||
@Entry(category = CONTROLLER, name = "Excluded Controllers (Name Regex)") public static List<String> excludedControllers = Lists.newArrayList(".*(Keyboard)$", ".*(Touchpad)$", ".*(Pen)$", ".*(Finger)$");
|
||||
@Comment(category = SCREENS, centered = true, name="\uD83D\uDD27 UI Modifications") public static Comment _uiMods;
|
||||
@Entry(category = SCREENS, name = "midnightcontrols.menu.move_chat") public static boolean moveChat = false;
|
||||
@Entry(category = SCREENS, name = "Enable Shortcut in Controls Options") public static boolean shortcutInControls = true;
|
||||
@Entry(category = MISC, name = "midnightcontrols.menu.virtual_keyboard_layout") public static String keyboardLayout = "en_US:qwerty";
|
||||
@Entry(category = MISC, name = "Debug") public static boolean debug = false;
|
||||
@Entry(category = MISC, name = "Excluded Keybindings") public static List<String> excludedKeybindings = Lists.newArrayList("key.forward", "key.left", "key.back", "key.right", "key.jump", "key.sneak", "key.sprint", "key.inventory",
|
||||
"key.swapOffhand", "key.drop", "key.use", "key.attack", "key.chat", "key.playerlist", "key.screenshot", "key.togglePerspective", "key.smoothCamera", "key.fullscreen", "key.saveToolbarActivator", "key.loadToolbarActivator",
|
||||
"key.pickItem", "key.hotbar.1", "key.hotbar.2", "key.hotbar.3", "key.hotbar.4", "key.hotbar.5", "key.hotbar.6", "key.hotbar.7", "key.hotbar.8", "key.hotbar.9");
|
||||
@Entry(category = MISC, name = "Ring Bindings (WIP)") @Hidden public static List<String> ringBindings = new ArrayList<>();
|
||||
@Entry(category = GAMEPLAY, name = "Enable Hints") public static boolean enableHints = true;
|
||||
@Entry(category = SCREENS, name = "Enable Shortcut in Controls Options") public static boolean shortcutInControls = true;
|
||||
@Entry(category = MISC, name = "Ring Bindings (WIP)") public static List<String> ringBindings = new ArrayList<>();
|
||||
@Entry(category = MISC, 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<>();
|
||||
@@ -404,7 +374,6 @@ public class MidnightControlsConfig extends MidnightConfig {
|
||||
unfocusedInput = false;
|
||||
virtualMouse = false;
|
||||
virtualMouseSkin = VirtualMouseSkin.DEFAULT_LIGHT;
|
||||
virtualKeyboard = false;
|
||||
controllerID = 0;
|
||||
secondControllerID = -1;
|
||||
controllerType = ControllerType.DEFAULT;
|
||||
@@ -431,7 +400,7 @@ public class MidnightControlsConfig extends MidnightConfig {
|
||||
String controller = getController().getName().toLowerCase();
|
||||
if (controller.contains("xbox 360")) return ControllerType.XBOX_360;
|
||||
else if (controller.contains("xbox") || controller.contains("afterglow")) return ControllerType.XBOX;
|
||||
else if (controller.contains("steam") && GLX._getCpuInfo().contains("AMD Custom APU")) return ControllerType.STEAM_DECK;
|
||||
else if (controller.contains("steam") && GlDebugInfo.getCpuInfo().contains("AMD Custom APU")) return ControllerType.STEAM_DECK;
|
||||
else if (controller.contains("steam")) return ControllerType.STEAM_CONTROLLER;
|
||||
else if (controller.contains("dualsense") || controller.contains("ps5")) return ControllerType.DUALSENSE;
|
||||
else if (controller.contains("dualshock") || controller.contains("ps4") || controller.contains("sony")) return ControllerType.DUALSHOCK;
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package eu.midnightdust.midnightcontrols.client;
|
||||
|
||||
import eu.midnightdust.midnightcontrols.client.virtualkeyboard.KeyboardLayoutManager;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
import net.minecraft.resource.SynchronousResourceReloader;
|
||||
|
||||
public class MidnightControlsReloadListener implements SynchronousResourceReloader {
|
||||
public static final MidnightControlsReloadListener INSTANCE = new MidnightControlsReloadListener();
|
||||
|
||||
private MidnightControlsReloadListener() {}
|
||||
|
||||
@Override
|
||||
public void reload(ResourceManager manager) {
|
||||
manager.findResources("keyboard_layouts", path -> path.toString().startsWith("midnightcontrols") && path.toString().endsWith(".json")).forEach(KeyboardLayoutManager::loadLayout);
|
||||
}
|
||||
}
|
||||
@@ -214,10 +214,10 @@ public class MidnightInput {
|
||||
return;
|
||||
|
||||
if (this.targetYaw != 0.f || this.targetPitch != 0.f) {
|
||||
float rotationYaw = (float) (client.player.lastYaw + (this.targetYaw * 0.175));
|
||||
float rotationPitch = (float) (client.player.lastPitch + (this.targetPitch * 0.175));
|
||||
client.player.lastYaw = rotationYaw;
|
||||
client.player.lastPitch = MathHelper.clamp(rotationPitch, -90.f, 90.f);
|
||||
float rotationYaw = (float) (client.player.prevYaw + (this.targetYaw * 0.175));
|
||||
float rotationPitch = (float) (client.player.prevPitch + (this.targetPitch * 0.175));
|
||||
client.player.prevYaw = rotationYaw;
|
||||
client.player.prevPitch = MathHelper.clamp(rotationPitch, -90.f, 90.f);
|
||||
client.player.setYaw(rotationYaw);
|
||||
client.player.setPitch(MathHelper.clamp(rotationPitch, -90.f, 90.f));
|
||||
if (client.player.isRiding() && client.player.getVehicle() != null) {
|
||||
|
||||
@@ -77,7 +77,7 @@ public class MidnightReacharound {
|
||||
}
|
||||
|
||||
public static float getPlayerRange(@NotNull MinecraftClient client) {
|
||||
return client.player != null ? Double.valueOf(client.player.getAttributeValue(EntityAttributes.BLOCK_INTERACTION_RANGE)).floatValue() : 0.f;
|
||||
return client.player != null ? Double.valueOf(client.player.getAttributeValue(EntityAttributes.PLAYER_BLOCK_INTERACTION_RANGE)).floatValue() : 0.f;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,51 +1,36 @@
|
||||
package eu.midnightdust.midnightcontrols.client.compat;
|
||||
|
||||
import eu.midnightdust.midnightcontrols.client.controller.InputManager;
|
||||
import eu.midnightdust.midnightcontrols.client.mixin.MouseAccessor;
|
||||
import io.github.kosmx.emotes.arch.screen.ingame.FastMenuScreen;
|
||||
import io.github.kosmx.emotes.arch.gui.EmoteMenuImpl;
|
||||
import io.github.kosmx.emotes.arch.gui.screen.ingame.FastChosseScreen;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import org.joml.Vector2i;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
public class EmotecraftCompat {
|
||||
private static final MinecraftClient client = MinecraftClient.getInstance();
|
||||
|
||||
public static void openEmotecraftScreen(Screen parent) {
|
||||
client.setScreen(new FastMenuScreen(parent));
|
||||
client.setScreen(new EmoteMenuImpl(parent));
|
||||
}
|
||||
public static boolean isEmotecraftScreen(Screen screen) {
|
||||
return screen instanceof FastMenuScreen;
|
||||
return screen instanceof FastChosseScreen;
|
||||
}
|
||||
|
||||
static int prevIndex = -1;
|
||||
public static void handleEmoteSelector(int index) {
|
||||
try {
|
||||
if (client.currentScreen instanceof FastMenuScreen) {
|
||||
boolean stickReleased = index == -1 && prevIndex != -1;
|
||||
var pos = calcMousePos(stickReleased ? prevIndex : index);
|
||||
InputManager.queueMousePosition(pos.x, pos.y);
|
||||
InputManager.INPUT_MANAGER.updateMousePosition(client);
|
||||
if (client.currentScreen instanceof FastChosseScreen) {
|
||||
int x = client.getWindow().getWidth() / 2;
|
||||
int y = client.getWindow().getHeight() / 2;
|
||||
switch (index) {
|
||||
case 0, 3, 5 -> x -= 200;
|
||||
case 2, 4, 7 -> x += 200;
|
||||
}
|
||||
switch (index) {
|
||||
case 0, 1, 2 -> y -= 200;
|
||||
case 5, 6, 7 -> y += 200;
|
||||
}
|
||||
InputManager.queueMousePosition(x, y);
|
||||
|
||||
if (stickReleased) {
|
||||
((MouseAccessor) client.mouse).midnightcontrols$onMouseButton(client.getWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_LEFT, GLFW.GLFW_PRESS, 0);
|
||||
prevIndex = -1;
|
||||
}
|
||||
else prevIndex = index;
|
||||
} else prevIndex = -1;
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
public static Vector2i calcMousePos(int index) {
|
||||
int x = client.getWindow().getWidth() / 2;
|
||||
int y = client.getWindow().getHeight() / 2;
|
||||
switch (index) {
|
||||
case 0, 3, 5 -> x -= 275;
|
||||
case 2, 4, 7 -> x += 275;
|
||||
InputManager.INPUT_MANAGER.updateMousePosition(client);
|
||||
}
|
||||
switch (index) {
|
||||
case 0, 1, 2 -> y -= 275;
|
||||
case 5, 6, 7 -> y += 275;
|
||||
}
|
||||
return new Vector2i(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,11 +60,10 @@ public class InputHandlers {
|
||||
// When in-game
|
||||
if (client.currentScreen == null && client.player != null) {
|
||||
if (!client.player.isSpectator()) {
|
||||
var inv = client.player.getInventory();
|
||||
if (next)
|
||||
inv.setSelectedSlot(inv.getSelectedSlot() < 8 ? inv.getSelectedSlot() + 1 : inv.getSelectedSlot() - 8);
|
||||
client.player.getInventory().scrollInHotbar(-1.0);
|
||||
else
|
||||
inv.setSelectedSlot(inv.getSelectedSlot() > 0 ? inv.getSelectedSlot() - 1 : inv.getSelectedSlot() + 8);
|
||||
client.player.getInventory().scrollInHotbar(1.0);
|
||||
}
|
||||
else {
|
||||
if (client.inGameHud.getSpectatorHud().isOpen()) {
|
||||
@@ -80,9 +79,11 @@ public class InputHandlers {
|
||||
} else if (client.currentScreen instanceof CreativeInventoryScreenAccessor inventory) {
|
||||
inventory.midnightcontrols$setSelectedTab(ItemGroupUtil.cycleTab(next, client));
|
||||
return true;
|
||||
} else if (client.currentScreen instanceof RecipeBookScreen<?> recipeBookScreen) {
|
||||
RecipeBookWidget<?> recipeBook = ((RecipeBookScreenAccessor) recipeBookScreen).getRecipeBook();
|
||||
|
||||
} else if (client.currentScreen instanceof InventoryScreen || client.currentScreen instanceof CraftingScreen || client.currentScreen instanceof AbstractFurnaceScreen<?>) {
|
||||
RecipeBookWidget recipeBook;
|
||||
if (client.currentScreen instanceof InventoryScreen inventoryScreen) recipeBook = inventoryScreen.getRecipeBookWidget();
|
||||
else if (client.currentScreen instanceof CraftingScreen craftingScreen) recipeBook = craftingScreen.getRecipeBookWidget();
|
||||
else recipeBook = ((AbstractFurnaceScreen<?>)client.currentScreen).getRecipeBookWidget();
|
||||
var recipeBookAccessor = (RecipeBookWidgetAccessor) recipeBook;
|
||||
var tabs = recipeBookAccessor.getTabButtons();
|
||||
var currentTab = recipeBookAccessor.getCurrentTab();
|
||||
@@ -97,7 +98,7 @@ public class InputHandlers {
|
||||
currentTab.setToggled(false);
|
||||
recipeBookAccessor.setCurrentTab(currentTab = tabs.get(nextTab));
|
||||
currentTab.setToggled(true);
|
||||
recipeBookScreen.refreshRecipeBook();
|
||||
recipeBookAccessor.midnightcontrols$refreshResults(true);
|
||||
return true;
|
||||
} else if (client.currentScreen instanceof AdvancementsScreenAccessor screen) {
|
||||
var tabs = screen.getTabs().values().stream().distinct().toList();
|
||||
|
||||
@@ -41,7 +41,7 @@ import static eu.midnightdust.midnightcontrols.client.MidnightControlsClient.cli
|
||||
*/
|
||||
public class InputManager {
|
||||
public static final InputManager INPUT_MANAGER = new InputManager();
|
||||
private static final List<ButtonBinding> BINDINGS = Collections.synchronizedList(new ArrayList<>());
|
||||
private static final List<ButtonBinding> BINDINGS = new ArrayList<>();
|
||||
private static final List<ButtonCategory> CATEGORIES = new ArrayList<>();
|
||||
public static final Int2ObjectMap<ButtonState> STATES = new Int2ObjectOpenHashMap<>();
|
||||
public static final Int2FloatMap BUTTON_VALUES = new Int2FloatOpenHashMap();
|
||||
@@ -76,8 +76,8 @@ public class InputManager {
|
||||
public void updateMousePosition(@NotNull MinecraftClient client) {
|
||||
Objects.requireNonNull(client, "Client instance cannot be null.");
|
||||
if (this.prevTargetMouseX != this.targetMouseX || this.prevTargetMouseY != this.targetMouseY) {
|
||||
double mouseX = this.prevTargetMouseX + (this.targetMouseX - this.prevTargetMouseX) * client.getRenderTickCounter().getTickProgress(true) + 0.5;
|
||||
double mouseY = this.prevTargetMouseY + (this.targetMouseY - this.prevTargetMouseY) * client.getRenderTickCounter().getTickProgress(true) + 0.5;
|
||||
double mouseX = this.prevTargetMouseX + (this.targetMouseX - this.prevTargetMouseX) * client.getRenderTickCounter().getTickDelta(true) + 0.5;
|
||||
double mouseY = this.prevTargetMouseY + (this.targetMouseY - this.prevTargetMouseY) * client.getRenderTickCounter().getTickDelta(true) + 0.5;
|
||||
if (!MidnightControlsConfig.virtualMouse)
|
||||
GLFW.glfwSetCursorPos(client.getWindow().getHandle(), mouseX, mouseY);
|
||||
((MouseAccessor) client.mouse).midnightcontrols$onCursorPos(client.getWindow().getHandle(), mouseX, mouseY);
|
||||
@@ -109,9 +109,7 @@ public class InputManager {
|
||||
* @return true if the binding is registered, else false
|
||||
*/
|
||||
public static boolean hasBinding(@NotNull ButtonBinding binding) {
|
||||
synchronized (BINDINGS) {
|
||||
return BINDINGS.contains(binding);
|
||||
}
|
||||
return BINDINGS.contains(binding);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,9 +119,7 @@ public class InputManager {
|
||||
* @return true if the binding is registered, else false
|
||||
*/
|
||||
public static boolean hasBinding(@NotNull String name) {
|
||||
synchronized (BINDINGS) {
|
||||
return BINDINGS.parallelStream().map(ButtonBinding::getName).anyMatch(binding -> binding.equalsIgnoreCase(name));
|
||||
}
|
||||
return BINDINGS.parallelStream().map(ButtonBinding::getName).anyMatch(binding -> binding.equalsIgnoreCase(name));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,22 +139,18 @@ public class InputManager {
|
||||
* @return true if the binding is registered, else false
|
||||
*/
|
||||
public static ButtonBinding getBinding(@NotNull String name) {
|
||||
synchronized (BINDINGS) {
|
||||
if (BINDINGS.parallelStream().map(ButtonBinding::getName).anyMatch(binding -> binding.equalsIgnoreCase(name)))
|
||||
BINDINGS.forEach(binding -> {
|
||||
if (binding.getName().equalsIgnoreCase(name)) InputManager.tempBinding = binding;
|
||||
});
|
||||
}
|
||||
if (BINDINGS.parallelStream().map(ButtonBinding::getName).anyMatch(binding -> binding.equalsIgnoreCase(name)))
|
||||
BINDINGS.forEach(binding -> {
|
||||
if (binding.getName().equalsIgnoreCase(name)) InputManager.tempBinding = binding;
|
||||
});
|
||||
return tempBinding;
|
||||
}
|
||||
private static List<ButtonBinding> unboundBindings;
|
||||
public static List<ButtonBinding> getUnboundBindings() {
|
||||
unboundBindings = new ArrayList<>();
|
||||
synchronized (BINDINGS) {
|
||||
BINDINGS.forEach(binding -> {
|
||||
if (binding.isNotBound() && !MidnightControlsConfig.ignoredUnboundKeys.contains(binding.getTranslationKey())) unboundBindings.add(binding);
|
||||
});
|
||||
}
|
||||
BINDINGS.forEach(binding -> {
|
||||
if (binding.isNotBound() && !MidnightControlsConfig.ignoredUnboundKeys.contains(binding.getTranslationKey())) unboundBindings.add(binding);
|
||||
});
|
||||
unboundBindings.sort(Comparator.comparing(s -> I18n.translate(s.getTranslationKey())));
|
||||
return unboundBindings;
|
||||
}
|
||||
@@ -170,11 +162,9 @@ public class InputManager {
|
||||
* @return the registered binding
|
||||
*/
|
||||
public static @NotNull ButtonBinding registerBinding(@NotNull ButtonBinding binding) {
|
||||
synchronized (BINDINGS) {
|
||||
if (BINDINGS.contains(binding))
|
||||
throw new IllegalStateException("Cannot register twice a button binding in the registry.");
|
||||
BINDINGS.add(binding);
|
||||
}
|
||||
if (hasBinding(binding))
|
||||
throw new IllegalStateException("Cannot register twice a button binding in the registry.");
|
||||
BINDINGS.add(binding);
|
||||
return binding;
|
||||
}
|
||||
|
||||
@@ -294,9 +284,7 @@ public class InputManager {
|
||||
* @return true if the button has duplicated bindings, else false
|
||||
*/
|
||||
public static boolean hasDuplicatedBindings(int[] button) {
|
||||
synchronized (BINDINGS) {
|
||||
return BINDINGS.parallelStream().filter(binding -> areButtonsEquivalent(binding.getButton(), button)).count() > 1;
|
||||
}
|
||||
return BINDINGS.parallelStream().filter(binding -> areButtonsEquivalent(binding.getButton(), button)).count() > 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -306,9 +294,7 @@ public class InputManager {
|
||||
* @return true if the button has duplicated bindings, else false
|
||||
*/
|
||||
public static boolean hasDuplicatedBindings(ButtonBinding binding) {
|
||||
synchronized (BINDINGS) {
|
||||
return BINDINGS.parallelStream().filter(other -> areButtonsEquivalent(other.getButton(), binding.getButton()) && other.filter.equals(binding.filter)).count() > 1;
|
||||
}
|
||||
return BINDINGS.parallelStream().filter(other -> areButtonsEquivalent(other.getButton(), binding.getButton()) && other.filter.equals(binding.filter)).count() > 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -361,8 +347,7 @@ public class InputManager {
|
||||
record ButtonStateValue(ButtonState state, float value) {
|
||||
}
|
||||
var states = new Object2ObjectOpenHashMap<ButtonBinding, ButtonStateValue>();
|
||||
synchronized (BINDINGS) {
|
||||
for (var binding : BINDINGS) {
|
||||
for (var binding : BINDINGS) {
|
||||
var state = binding.isAvailable() ? getBindingState(binding) : ButtonState.NONE;
|
||||
if (skipButtons.intStream().anyMatch(btn -> containsButton(binding.getButton(), btn))) {
|
||||
if (binding.isPressed())
|
||||
@@ -383,7 +368,6 @@ public class InputManager {
|
||||
float value = getBindingValue(binding, state);
|
||||
|
||||
states.put(binding, new ButtonStateValue(state, value));
|
||||
}
|
||||
}
|
||||
|
||||
states.forEach((binding, state) -> {
|
||||
@@ -403,9 +387,7 @@ public class InputManager {
|
||||
}
|
||||
|
||||
public static @NotNull Stream<ButtonBinding> streamBindings() {
|
||||
synchronized (BINDINGS) {
|
||||
return BINDINGS.stream();
|
||||
}
|
||||
return BINDINGS.stream();
|
||||
}
|
||||
|
||||
public static @NotNull Stream<ButtonCategory> streamCategories() {
|
||||
|
||||
@@ -11,14 +11,11 @@ package eu.midnightdust.midnightcontrols.client.controller;
|
||||
|
||||
import eu.midnightdust.midnightcontrols.client.enums.ButtonState;
|
||||
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
|
||||
import eu.midnightdust.midnightcontrols.client.mixin.InputAccessor;
|
||||
import eu.midnightdust.midnightcontrols.client.util.MathUtil;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.entity.attribute.EntityAttributes;
|
||||
import net.minecraft.util.PlayerInput;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -51,12 +48,14 @@ public final class MovementHandler implements PressAction {
|
||||
public void applyMovement(@NotNull ClientPlayerEntity player) {
|
||||
if (!this.shouldOverrideMovement)
|
||||
return;
|
||||
player.input.playerInput = new PlayerInput(this.pressingForward, this.pressingBack, this.pressingLeft, this.pressingRight,
|
||||
player.input.playerInput.jump(), player.input.playerInput.sneak(), player.input.playerInput.sprint());
|
||||
player.input.pressingForward = this.pressingForward;
|
||||
player.input.pressingBack = this.pressingBack;
|
||||
player.input.pressingLeft = this.pressingLeft;
|
||||
player.input.pressingRight = this.pressingRight;
|
||||
|
||||
polarUtil.calculate(this.movementSideways, this.movementForward, this.slowdownFactor);
|
||||
Vec2f inputVector = new Vec2f(polarUtil.polarX, polarUtil.polarY);
|
||||
((InputAccessor)player.input).setMovementVector(inputVector);
|
||||
player.input.movementForward = polarUtil.polarY;
|
||||
player.input.movementSideways = polarUtil.polarX;
|
||||
|
||||
this.shouldOverrideMovement = false;
|
||||
}
|
||||
@@ -82,7 +81,7 @@ public final class MovementHandler implements PressAction {
|
||||
}
|
||||
|
||||
this.slowdownFactor = client.player.shouldSlowDown() ? (MathHelper.clamp(
|
||||
0.3F + (float) client.player.getAttributeValue(EntityAttributes.SNEAKING_SPEED),
|
||||
0.3F + (float) client.player.getAttributeValue(EntityAttributes.PLAYER_SNEAKING_SPEED),
|
||||
0.0F,
|
||||
1.0F
|
||||
)) : 1.f;
|
||||
|
||||
@@ -107,7 +107,7 @@ public class MappingsStringInputWidget extends SpruceContainerWidget {
|
||||
@Override
|
||||
public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
super.renderWidget(context, mouseX, mouseY, delta);
|
||||
context.drawCenteredTextWithShadow(this.client.textRenderer, Text.translatable("midnightcontrols.menu.multiple_mapping_tip"), this.textArea.getX() + this.textArea.getWidth() / 2, this.textArea.getY() + this.textArea.getHeight() - 12, 0xFF888888);
|
||||
context.drawCenteredTextWithShadow(this.client.textRenderer, Text.translatable("midnightcontrols.menu.current_controller_guid", MidnightControlsConfig.getController().getGuid()), this.textArea.getX() + this.textArea.getWidth() / 2, this.height - 21, 0xFFFFFFFF);
|
||||
context.drawCenteredTextWithShadow(this.client.textRenderer, Text.translatable("midnightcontrols.menu.multiple_mapping_tip"), this.textArea.getX() + this.textArea.getWidth() / 2, this.textArea.getY() + this.textArea.getHeight() - 12, 0x888888);
|
||||
context.drawCenteredTextWithShadow(this.client.textRenderer, Text.translatable("midnightcontrols.menu.current_controller_guid", MidnightControlsConfig.getController().getGuid()), this.textArea.getX() + this.textArea.getWidth() / 2, this.height - 21, 0xFFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,19 +10,21 @@
|
||||
package eu.midnightdust.midnightcontrols.client.gui;
|
||||
|
||||
import eu.midnightdust.midnightcontrols.ControlsMode;
|
||||
import eu.midnightdust.midnightcontrols.MidnightControlsConstants;
|
||||
import eu.midnightdust.midnightcontrols.client.enums.HudSide;
|
||||
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
|
||||
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
|
||||
import eu.midnightdust.midnightcontrols.client.compat.MidnightControlsCompat;
|
||||
import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
import org.joml.Matrix3x2fStack;
|
||||
import org.thinkingstudio.obsidianui.hud.Hud;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -38,7 +40,7 @@ import static eu.midnightdust.midnightcontrols.MidnightControls.id;
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class MidnightControlsHud extends Hud {
|
||||
private MinecraftClient client = MinecraftClient.getInstance();
|
||||
private final MinecraftClient client = MinecraftClient.getInstance();
|
||||
private int attackWidth = 0;
|
||||
private int attackButtonWidth = 0;
|
||||
private int dropItemWidth = 0;
|
||||
@@ -61,7 +63,6 @@ public class MidnightControlsHud extends Hud {
|
||||
|
||||
@Override
|
||||
public void init(@NotNull MinecraftClient client, int screenWidth, int screenHeight) {
|
||||
this.client = MinecraftClient.getInstance();
|
||||
super.init(client, screenWidth, screenHeight);
|
||||
this.inventoryWidth = this.width(ButtonBinding.INVENTORY);
|
||||
this.inventoryButtonWidth = MidnightControlsRenderer.getBindingIconWidth(ButtonBinding.INVENTORY);
|
||||
@@ -83,13 +84,13 @@ public class MidnightControlsHud extends Hud {
|
||||
if (MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER && this.client.currentScreen == null) {
|
||||
isCrammed = client.getWindow().getScaledWidth() < 520;
|
||||
int y = bottom(2);
|
||||
Matrix3x2fStack matrices = context.getMatrices();
|
||||
matrices.pushMatrix();
|
||||
MatrixStack matrices = context.getMatrices();
|
||||
matrices.push();
|
||||
this.renderFirstIcons(context, MidnightControlsConfig.hudSide == HudSide.LEFT ? 2 : client.getWindow().getScaledWidth() - 2, y);
|
||||
this.renderSecondIcons(context, MidnightControlsConfig.hudSide == HudSide.RIGHT ? 2 : client.getWindow().getScaledWidth() - 2, y);
|
||||
this.renderFirstSection(context, MidnightControlsConfig.hudSide == HudSide.LEFT ? 2 : client.getWindow().getScaledWidth() - 2, y);
|
||||
this.renderSecondSection(context, MidnightControlsConfig.hudSide == HudSide.RIGHT ? 2 : client.getWindow().getScaledWidth() - 2, y);
|
||||
matrices.popMatrix();
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
if (MidnightControlsClient.reacharound.isLastReacharoundVertical()) {
|
||||
@@ -97,12 +98,12 @@ public class MidnightControlsHud extends Hud {
|
||||
var window = this.client.getWindow();
|
||||
var text = "[ ]";
|
||||
|
||||
float scale = Math.min(5, this.ticksDisplayedCrosshair + tickCounter.getTickProgress(true)) / 5F;
|
||||
float scale = Math.min(5, this.ticksDisplayedCrosshair + tickCounter.getTickDelta(true)) / 5F;
|
||||
scale *= scale;
|
||||
int opacity = ((int) (255 * scale)) << 24;
|
||||
|
||||
context.drawText(client.textRenderer, text, (int) (window.getScaledWidth() / 2.f - this.client.textRenderer.getWidth(text) / 2.f),
|
||||
(int) (window.getScaledHeight() / 2.f - 4), 0xFFCCCCCC | opacity, false);
|
||||
(int) (window.getScaledHeight() / 2.f - 4), 0xCCCCCC | opacity, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,6 +299,6 @@ public class MidnightControlsHud extends Hud {
|
||||
return;
|
||||
var translatedAction = I18n.translate(action);
|
||||
int textY = (MidnightControlsRenderer.ICON_SIZE / 2 - this.client.textRenderer.fontHeight / 2) + 1;
|
||||
context.drawText(this.client.textRenderer, translatedAction, x, (y + textY), 0xFFFFFFFF, false);
|
||||
context.drawText(this.client.textRenderer, translatedAction, x, (y + textY), 14737632, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,7 @@
|
||||
|
||||
package eu.midnightdust.midnightcontrols.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.textures.GpuTextureView;
|
||||
import eu.midnightdust.midnightcontrols.ControlsMode;
|
||||
import eu.midnightdust.midnightcontrols.client.enums.ControllerType;
|
||||
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
|
||||
@@ -20,31 +18,25 @@ import eu.midnightdust.midnightcontrols.client.MidnightInput;
|
||||
import eu.midnightdust.midnightcontrols.client.compat.MidnightControlsCompat;
|
||||
import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding;
|
||||
import eu.midnightdust.midnightcontrols.client.enums.VirtualMouseSkin;
|
||||
import eu.midnightdust.midnightcontrols.client.gui.render.UnalignedTexturedQuadGuiElementRenderState;
|
||||
import eu.midnightdust.midnightcontrols.client.mixin.DrawContextAccessor;
|
||||
import eu.midnightdust.midnightcontrols.client.util.HandledScreenAccessor;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gl.RenderPipelines;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.render.state.TexturedQuadGuiElementRenderState;
|
||||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.render.BufferBuilder;
|
||||
import net.minecraft.client.render.BufferRenderer;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import net.minecraft.client.render.Tessellator;
|
||||
import net.minecraft.client.render.VertexFormat;
|
||||
import net.minecraft.client.render.VertexFormats;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.texture.TextureSetup;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.ColorHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Matrix3x2f;
|
||||
import org.joml.Matrix4f;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import static eu.midnightdust.midnightcontrols.MidnightControls.id;
|
||||
import static eu.midnightdust.midnightcontrols.client.MidnightControlsClient.client;
|
||||
|
||||
/**
|
||||
* Represents the midnightcontrols renderer.
|
||||
@@ -178,14 +170,17 @@ public class MidnightControlsRenderer {
|
||||
case GLFW.GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER + 100, GLFW.GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER + 200 -> buttonOffset = 10 * 15;
|
||||
}
|
||||
|
||||
RenderSystem.disableDepthTest();
|
||||
|
||||
int assetSize = axis || (button >= 15 && button <= 18) ? AXIS_SIZE : BUTTON_SIZE;
|
||||
|
||||
//RenderSystem.setShaderColor(1.f, second ? 0.f : 1.f, 1.f, 1.f);
|
||||
context.drawTexture(RenderPipelines.GUI_TEXTURED, axis ? MidnightControlsClient.CONTROLLER_AXIS : button >= 15 && button <= 19 ? MidnightControlsClient.CONTROLLER_EXPANDED :MidnightControlsClient.CONTROLLER_BUTTONS
|
||||
RenderSystem.setShaderColor(1.f, second ? 0.f : 1.f, 1.f, 1.f);
|
||||
context.drawTexture(axis ? MidnightControlsClient.CONTROLLER_AXIS : button >= 15 && button <= 19 ? MidnightControlsClient.CONTROLLER_EXPANDED :MidnightControlsClient.CONTROLLER_BUTTONS
|
||||
, x + (ICON_SIZE / 2 - assetSize / 2), y + (ICON_SIZE / 2 - assetSize / 2),
|
||||
(float) buttonOffset, (float) (controllerType * assetSize),
|
||||
assetSize, assetSize,
|
||||
256, 256);
|
||||
RenderSystem.enableDepthTest();
|
||||
|
||||
return ICON_SIZE;
|
||||
}
|
||||
@@ -201,8 +196,7 @@ public class MidnightControlsRenderer {
|
||||
var translatedAction = I18n.translate(action);
|
||||
int textY = (MidnightControlsRenderer.ICON_SIZE / 2 - client.textRenderer.fontHeight / 2) + 1;
|
||||
|
||||
context.drawTextWithShadow(client.textRenderer, translatedAction, (x + buttonWidth + 2), (y + textY), 0xFFFFFFFF);
|
||||
return (x + buttonWidth + 2) + client.textRenderer.getWidth(translatedAction);
|
||||
return context.drawTextWithShadow(client.textRenderer, translatedAction, (x + buttonWidth + 2), (y + textY), 14737632);
|
||||
}
|
||||
|
||||
return -10;
|
||||
@@ -222,7 +216,7 @@ public class MidnightControlsRenderer {
|
||||
if (MidnightControlsConfig.virtualMouseSkin == VirtualMouseSkin.DEFAULT_DARK || MidnightControlsConfig.virtualMouseSkin == VirtualMouseSkin.SECOND_DARK)
|
||||
spritePath = MidnightControlsClient.WAYLAND_CURSOR_TEXTURE_DARK;
|
||||
Sprite sprite = client.getGuiAtlasManager().getSprite(spritePath);
|
||||
drawUnalignedTexturedQuad(RenderPipelines.GUI_TEXTURED, sprite.getAtlasId(), context, mouseX, mouseX + 8, mouseY, mouseY + 8, sprite.getMinU(), sprite.getMaxU(), sprite.getMinV(), sprite.getMaxV());
|
||||
drawUnalignedTexturedQuad(sprite.getAtlasId(), context, mouseX, mouseX + 8, mouseY, mouseY + 8, 999, sprite.getMinU(), sprite.getMaxU(), sprite.getMinV(), sprite.getMaxV());
|
||||
} catch (IllegalStateException ignored) {}
|
||||
}
|
||||
|
||||
@@ -266,12 +260,19 @@ public class MidnightControlsRenderer {
|
||||
|
||||
try {
|
||||
Sprite sprite = client.getGuiAtlasManager().getSprite(id(MidnightControlsConfig.virtualMouseSkin.getSpritePath() + (hoverSlot ? "_slot" : "")));
|
||||
drawUnalignedTexturedQuad(RenderPipelines.GUI_TEXTURED, sprite.getAtlasId(), context, mouseX, mouseX + 16, mouseY, mouseY + 16, sprite.getMinU(), sprite.getMaxU(), sprite.getMinV(), sprite.getMaxV());
|
||||
drawUnalignedTexturedQuad(sprite.getAtlasId(), context, mouseX, mouseX + 16, mouseY, mouseY + 16, 999, sprite.getMinU(), sprite.getMaxU(), sprite.getMinV(), sprite.getMaxV());
|
||||
} catch (IllegalStateException ignored) {}
|
||||
}
|
||||
private static void drawUnalignedTexturedQuad(RenderPipeline pipeline, Identifier texture, DrawContext context, float x1, float x2, float y1, float y2, float u1, float u2, float v1, float v2) {
|
||||
DrawContextAccessor accessor = (DrawContextAccessor) context;
|
||||
accessor.getState().addSimpleElement(new UnalignedTexturedQuadGuiElementRenderState(pipeline, TextureSetup.withoutGlTexture(client.getTextureManager().getTexture(texture).getGlTextureView()), new Matrix3x2f(context.getMatrices()), x1, y1, x2, y2, u1, u2, v1, v2, 0xffffffff, accessor.getScissorStack().peekLast()));
|
||||
private static void drawUnalignedTexturedQuad(Identifier texture, DrawContext context, float x1, float x2, float y1, float y2, float z, float u1, float u2, float v1, float v2) {
|
||||
RenderSystem.setShaderTexture(0, texture);
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
|
||||
Matrix4f matrix4f = context.getMatrices().peek().getPositionMatrix();
|
||||
BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE);
|
||||
bufferBuilder.vertex(matrix4f, x1, y1, z).texture(u1, v1);
|
||||
bufferBuilder.vertex(matrix4f, x1, y2, z).texture(u1, v2);
|
||||
bufferBuilder.vertex(matrix4f, x2, y2, z).texture(u2, v2);
|
||||
bufferBuilder.vertex(matrix4f, x2, y1, z).texture(u2, v1);
|
||||
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
|
||||
}
|
||||
|
||||
public record ButtonSize(int length, int height) {
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
|
||||
package eu.midnightdust.midnightcontrols.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import eu.midnightdust.midnightcontrols.MidnightControlsConstants;
|
||||
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
|
||||
import eu.midnightdust.midnightcontrols.client.util.platform.NetworkUtil;
|
||||
import eu.midnightdust.midnightcontrols.client.virtualkeyboard.KeyboardLayoutManager;
|
||||
import net.minecraft.util.math.ColorHelper;
|
||||
import org.thinkingstudio.obsidianui.background.Background;
|
||||
import org.thinkingstudio.obsidianui.widget.SpruceWidget;
|
||||
import eu.midnightdust.lib.util.MidnightColorUtil;
|
||||
import eu.midnightdust.midnightcontrols.MidnightControls;
|
||||
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
|
||||
import eu.midnightdust.midnightcontrols.client.controller.Controller;
|
||||
@@ -34,13 +34,18 @@ import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Util;
|
||||
import org.joml.Matrix4f;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Represents the midnightcontrols settings screen.
|
||||
*/
|
||||
@@ -58,7 +63,6 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
|
||||
private final SpruceOption eyeTrackingAsMouseOption;
|
||||
private final SpruceOption eyeTrackingDeadzone;
|
||||
private final SpruceOption virtualMouseOption;
|
||||
private final SpruceOption virtualKeyboardOption;
|
||||
private final SpruceOption hideCursorOption;
|
||||
private final SpruceOption resetOption;
|
||||
private final SpruceOption advancedConfigOption;
|
||||
@@ -133,15 +137,6 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
|
||||
maxAnalogValueOption("midnightcontrols.menu.max_right_x_value", GLFW.GLFW_GAMEPAD_AXIS_RIGHT_X),
|
||||
maxAnalogValueOption("midnightcontrols.menu.max_right_y_value", GLFW.GLFW_GAMEPAD_AXIS_RIGHT_Y)
|
||||
};
|
||||
// Controller options
|
||||
public final static SpruceOption virtualKeyboardLayoutOption =
|
||||
new SpruceCyclingOption("midnightcontrols.menu.virtual_keyboard_layout",
|
||||
amount -> {
|
||||
MidnightControlsConfig.keyboardLayout = KeyboardLayoutManager.getNext(KeyboardLayoutManager.getById(MidnightControlsConfig.keyboardLayout)).getId();
|
||||
},
|
||||
option -> {
|
||||
return option.getDisplayText(Text.translatable(KeyboardLayoutManager.getById(MidnightControlsConfig.keyboardLayout).getTranslationKey()));
|
||||
}, null);
|
||||
|
||||
private static SpruceOption maxAnalogValueOption(String key, int axis) {
|
||||
return new SpruceDoubleOption(key, .25f, 1.f, 0.05f,
|
||||
@@ -303,8 +298,6 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
|
||||
value -> MidnightControlsConfig.unfocusedInput = value, Text.translatable("midnightcontrols.menu.unfocused_input.tooltip"));
|
||||
this.virtualMouseOption = new SpruceToggleBooleanOption("midnightcontrols.menu.virtual_mouse", () -> MidnightControlsConfig.virtualMouse,
|
||||
value -> MidnightControlsConfig.virtualMouse = value, Text.translatable("midnightcontrols.menu.virtual_mouse.tooltip"));
|
||||
this.virtualKeyboardOption = new SpruceToggleBooleanOption("midnightcontrols.menu.virtual_keyboard", () -> MidnightControlsConfig.virtualMouse,
|
||||
value -> MidnightControlsConfig.virtualKeyboard = value, Text.translatable("midnightcontrols.menu.virtual_keyboard.tooltip"));
|
||||
this.hideCursorOption = new SpruceToggleBooleanOption("midnightcontrols.menu.hide_cursor", () -> MidnightControlsConfig.hideNormalMouse,
|
||||
value -> MidnightControlsConfig.hideNormalMouse = value, Text.translatable("midnightcontrols.menu.hide_cursor.tooltip"));
|
||||
// Touch options
|
||||
@@ -396,8 +389,6 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
|
||||
list.addSingleOptionEntry(this.yAxisRotationSpeedOption);
|
||||
list.addSingleOptionEntry(this.mouseSpeedOption);
|
||||
list.addSingleOptionEntry(this.virtualMouseOption);
|
||||
list.addSingleOptionEntry(this.virtualKeyboardOption);
|
||||
list.addSingleOptionEntry(this.virtualKeyboardLayoutOption);
|
||||
list.addSingleOptionEntry(this.hideCursorOption);
|
||||
list.addSingleOptionEntry(this.joystickAsMouseOption);
|
||||
list.addSingleOptionEntry(this.eyeTrackingAsMouseOption);
|
||||
@@ -499,7 +490,7 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
|
||||
|
||||
@Override
|
||||
public void renderTitle(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
context.drawCenteredTextWithShadow(this.textRenderer, I18n.translate("midnightcontrols.menu.title"), this.width / 2, 8, 0xFFFFFFFF);
|
||||
context.drawCenteredTextWithShadow(this.textRenderer, I18n.translate("midnightcontrols.menu.title"), this.width / 2, 8, 16777215);
|
||||
}
|
||||
|
||||
public static class MidnightControlsBackground implements Background {
|
||||
@@ -510,7 +501,27 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
|
||||
}
|
||||
@Override
|
||||
public void render(DrawContext context, SpruceWidget widget, int vOffset, int mouseX, int mouseY, float delta) {
|
||||
context.fill(widget.getX(), widget.getY(), widget.getX() + widget.getWidth(), widget.getY() + widget.getHeight(), ColorHelper.getArgb(transparency, 0, 0, 0));
|
||||
fill(context.getMatrices(), widget.getX(), widget.getY(), widget.getX() + widget.getWidth(), widget.getY() + widget.getHeight(), MidnightColorUtil.hex2Rgb("#000000"));
|
||||
}
|
||||
private static void fill(MatrixStack matrixStack, int x2, int y2, int x1, int y1, Color color) {
|
||||
matrixStack.push();
|
||||
|
||||
Matrix4f matrix = matrixStack.peek().getPositionMatrix();
|
||||
float r = (float)(color.getRed()) / 255.0F;
|
||||
float g = (float)(color.getGreen()) / 255.0F;
|
||||
float b = (float)(color.getBlue()) / 255.0F;
|
||||
float t = (float)(transparency) / 255.0F;
|
||||
BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
RenderSystem.setShader(GameRenderer::getPositionColorProgram);
|
||||
bufferBuilder.vertex(matrix, (float)x1, (float)y2, 0.0F).color(r, g, b, t);
|
||||
bufferBuilder.vertex(matrix, (float)x2, (float)y2, 0.0F).color(r, g, b, t);
|
||||
bufferBuilder.vertex(matrix, (float)x2, (float)y1, 0.0F).color(r, g, b, t);
|
||||
bufferBuilder.vertex(matrix, (float)x1, (float)y1, 0.0F).color(r, g, b, t);
|
||||
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
|
||||
RenderSystem.disableBlend();
|
||||
matrixStack.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package eu.midnightdust.midnightcontrols.client.gui.render;
|
||||
|
||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.gui.ScreenRect;
|
||||
import net.minecraft.client.gui.render.state.SimpleGuiElementRenderState;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.texture.TextureSetup;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Matrix3x2f;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public record UnalignedTexturedQuadGuiElementRenderState(RenderPipeline pipeline, TextureSetup textureSetup, Matrix3x2f pose, float x1, float y1, float x2, float y2, float u1, float u2, float v1, float v2, int color, @Nullable ScreenRect scissorArea, @Nullable ScreenRect bounds) implements SimpleGuiElementRenderState {
|
||||
public UnalignedTexturedQuadGuiElementRenderState(RenderPipeline pipeline, TextureSetup textureSetup, Matrix3x2f pose, float x1, float y1, float x2, float y2, float u1, float u2, float v1, float v2, int color, @Nullable ScreenRect scissorArea) {
|
||||
this(pipeline, textureSetup, pose, x1, y1, x2, y2, u1, u2, v1, v2, color, scissorArea, createBounds(x1, y1, x2, y2, pose, scissorArea));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupVertices(VertexConsumer vertices, float depth) {
|
||||
vertices.vertex(pose(), x1(), y1(), depth).texture(u1(), v1()).color(color());
|
||||
vertices.vertex(pose(), x1(), y2(), depth).texture(u1(), v2()).color(color());
|
||||
vertices.vertex(pose(), x2(), y2(), depth).texture(u2(), v2()).color(color());
|
||||
vertices.vertex(pose(), x2(), y1(), depth).texture(u2(), v1()).color(color());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static ScreenRect createBounds(float x1, float y1, float x2, float y2, Matrix3x2f pose, @Nullable ScreenRect scissorArea) {
|
||||
ScreenRect screenRect = (new ScreenRect((int) x1, (int) y1, (int) (x2 - x1), (int) (y2 - y1))).transformEachVertex(pose);
|
||||
return scissorArea != null ? scissorArea.intersection(screenRect) : screenRect;
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class ControllerControlsWidget extends SpruceContainerWidget {
|
||||
@Override
|
||||
public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
context.drawCenteredTextWithShadow(this.client.textRenderer, Text.translatable("midnightcontrols.menu.title.controller_controls"),
|
||||
this.getX() + this.width / 2, this.getY() + 4, 0xFFFFFFFF);
|
||||
this.getX() + this.width / 2, this.getY() + 4, 16777215);
|
||||
this.resetButton.setActive(InputManager.streamBindings().anyMatch(Predicates.not(ButtonBinding::isDefault)));
|
||||
super.renderWidget(context, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
@@ -14,15 +14,11 @@ import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
|
||||
import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding;
|
||||
import eu.midnightdust.midnightcontrols.client.controller.ButtonCategory;
|
||||
import eu.midnightdust.midnightcontrols.client.controller.InputManager;
|
||||
import net.minecraft.client.gl.RenderPipelines;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.thinkingstudio.obsidianui.Position;
|
||||
import org.thinkingstudio.obsidianui.SpruceTexts;
|
||||
import org.thinkingstudio.obsidianui.navigation.NavigationDirection;
|
||||
import org.thinkingstudio.obsidianui.navigation.NavigationUtils;
|
||||
import org.thinkingstudio.obsidianui.widget.SpruceButtonWidget;
|
||||
import org.thinkingstudio.obsidianui.widget.SpruceIconButtonWidget;
|
||||
import org.thinkingstudio.obsidianui.widget.SpruceSeparatorWidget;
|
||||
import org.thinkingstudio.obsidianui.widget.SpruceWidget;
|
||||
import org.thinkingstudio.obsidianui.widget.container.SpruceEntryListWidget;
|
||||
@@ -90,7 +86,7 @@ public class ControlsListWidget extends SpruceEntryListWidget<ControlsListWidget
|
||||
super(parent);
|
||||
this.binding = binding;
|
||||
this.bindingName = I18n.translate(this.binding.getTranslationKey());
|
||||
this.editButton = new ControllerButtonWidget(Position.of(this, parent.getWidth() / 2 - 8, 0), 120, this.binding, btn -> {
|
||||
this.editButton = new ControllerButtonWidget(Position.of(this, parent.getWidth() / 2 - 8, 0), 110, this.binding, btn -> {
|
||||
gui.focusedBinding = binding;
|
||||
MidnightControlsClient.input.beginControlsInput(gui);
|
||||
}) {
|
||||
@@ -100,24 +96,13 @@ public class ControlsListWidget extends SpruceEntryListWidget<ControlsListWidget
|
||||
}
|
||||
};
|
||||
this.children.add(editButton);
|
||||
this.resetButton = new SpruceIconButtonWidget(Position.of(this,
|
||||
this.resetButton = new SpruceButtonWidget(Position.of(this,
|
||||
this.editButton.getPosition().getRelativeX() + this.editButton.getWidth() + 2, 0),
|
||||
37, 20, Text.empty(),
|
||||
44, 20, Text.translatable("controls.reset"),
|
||||
btn -> MidnightControlsConfig.setButtonBinding(binding, binding.getDefaultButton())) {
|
||||
protected Text getNarrationMessage() {
|
||||
return Text.translatable("narrator.controls.reset", bindingName);
|
||||
}
|
||||
|
||||
private final Identifier resetTexture = Identifier.of("midnightlib","icon/reset");
|
||||
|
||||
@Override
|
||||
protected int renderIcon(DrawContext drawContext, int mouseX, int mouseY, float delta) {
|
||||
int size = 12;
|
||||
int x = this.getX() + this.getWidth() / 2 - size / 2;
|
||||
int y = this.getY() + this.getHeight() / 2 - size / 2;
|
||||
drawContext.drawGuiTexture(RenderPipelines.GUI_TEXTURED, resetTexture, x, y, size, size);
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
this.children.add(this.resetButton);
|
||||
this.unbindButton = new SpruceButtonWidget(Position.of(this,
|
||||
@@ -248,7 +233,7 @@ public class ControlsListWidget extends SpruceEntryListWidget<ControlsListWidget
|
||||
int height = this.getHeight();
|
||||
//float textX = (float) (this.getX() + 70 - ControlsListWidget.this.maxTextLength);
|
||||
int textY = this.getY() + height / 2;
|
||||
context.drawText(textRenderer, this.bindingName, this.getX(), (textY - 9 / 2), 0xFFFFFFFF, true);
|
||||
context.drawText(textRenderer, this.bindingName, this.getX(), (textY - 9 / 2), 16777215, true);
|
||||
|
||||
this.resetButton.setVisible(!focused);
|
||||
this.unbindButton.setVisible(focused);
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package eu.midnightdust.midnightcontrols.client.mixin;
|
||||
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldView;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(AbstractBlock.class)
|
||||
public interface AbstractBlockAccessor {
|
||||
@Invoker("canPlaceAt")
|
||||
boolean midnightcontrols$canPlaceAt(BlockState state, WorldView world, BlockPos pos);
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package eu.midnightdust.midnightcontrols.client.mixin;
|
||||
|
||||
import eu.midnightdust.midnightcontrols.client.util.AbstractSignEditScreenAccessor;
|
||||
import net.minecraft.block.entity.SignBlockEntity;
|
||||
import net.minecraft.block.entity.SignText;
|
||||
import net.minecraft.client.gui.screen.ingame.AbstractSignEditScreen;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(AbstractSignEditScreen.class)
|
||||
public class AbstractSignEditScreenMixin implements AbstractSignEditScreenAccessor {
|
||||
@Shadow @Final private String[] messages;
|
||||
@Shadow private SignText text;
|
||||
@Shadow @Final protected SignBlockEntity blockEntity;
|
||||
@Shadow @Final private boolean front;
|
||||
|
||||
@Override
|
||||
public String[] midnightcontrols$getMessages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void midnightcontrols$setMessage(int line, String text) {
|
||||
this.messages[line] = text;
|
||||
this.text = this.text.withMessage(line, Text.literal(text));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void midnightcontrols$writeToBlockEntity() {
|
||||
this.blockEntity.setText(this.text, this.front);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package eu.midnightdust.midnightcontrols.client.mixin;
|
||||
|
||||
import net.minecraft.client.gui.screen.ingame.BookEditScreen;
|
||||
import net.minecraft.client.gui.widget.EditBoxWidget;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(BookEditScreen.class)
|
||||
public interface BookEditScreenAccessor {
|
||||
@Accessor("editBox")
|
||||
EditBoxWidget midnightcontrols$getEditBox();
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package eu.midnightdust.midnightcontrols.client.mixin;
|
||||
|
||||
import net.minecraft.client.gui.screen.ingame.BookSigningScreen;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(BookSigningScreen.class)
|
||||
public interface BookSigningScreenAccessor {
|
||||
@Accessor("bookTitleTextField")
|
||||
TextFieldWidget midnightcontrols$getBookTitleTextField();
|
||||
}
|
||||
@@ -26,10 +26,10 @@ public abstract class ChatScreenMixin extends Screen {
|
||||
}
|
||||
@Inject(method = "render", at = @At("HEAD"))
|
||||
private void midnightcontrols$moveInputFieldBackground(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
if (MidnightControlsConfig.moveChat) context.getMatrices().translate(0f, -this.height + 16);
|
||||
if (MidnightControlsConfig.moveChat) context.getMatrices().translate(0f, -this.height + 16, 0f);
|
||||
}
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;fill(IIIII)V", shift = At.Shift.AFTER))
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/TextFieldWidget;render(Lnet/minecraft/client/gui/DrawContext;IIF)V", shift = At.Shift.BEFORE))
|
||||
private void midnightcontrols$dontMoveOtherStuff(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
if (MidnightControlsConfig.moveChat) context.getMatrices().translate(0f, this.height - 16);
|
||||
if (MidnightControlsConfig.moveChat) context.getMatrices().translate(0f, this.height - 16, 0f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;tick()V", shift = At.Shift.AFTER))
|
||||
@Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;tick(ZF)V", shift = At.Shift.AFTER))
|
||||
public void onInputUpdate(CallbackInfo ci) {
|
||||
MovementHandler.HANDLER.applyMovement((ClientPlayerEntity) (Object) this);
|
||||
}
|
||||
@@ -88,11 +88,11 @@ public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity
|
||||
if (MidnightControlsConfig.verticalFlyDrifting || !MidnightControls.isExtrasLoaded)
|
||||
return;
|
||||
int moving = 0;
|
||||
if (this.input.playerInput.sneak()) {
|
||||
if (this.input.sneaking) {
|
||||
--moving;
|
||||
}
|
||||
|
||||
if (this.input.playerInput.jump()) {
|
||||
if (this.input.jumping) {
|
||||
++moving;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,10 +58,4 @@ public interface CreativeInventoryScreenAccessor {
|
||||
*/
|
||||
@Invoker("hasScrollbar")
|
||||
boolean midnightcontrols$hasScrollbar();
|
||||
|
||||
/**
|
||||
* Triggers searching the creative inventory from the current value of the internal {@link net.minecraft.client.gui.widget.TextFieldWidget}
|
||||
*/
|
||||
@Invoker("search")
|
||||
void midnightcontrols$search();
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2021 LambdAurora <aurora42lambda@gmail.com>
|
||||
*
|
||||
* This file is part of midnightcontrols.
|
||||
*
|
||||
* Licensed under the MIT license. For more information,
|
||||
* see the LICENSE file.
|
||||
*/
|
||||
|
||||
package eu.midnightdust.midnightcontrols.client.mixin;
|
||||
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.render.state.GuiRenderState;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(DrawContext.class)
|
||||
public interface DrawContextAccessor {
|
||||
@Accessor("state")
|
||||
GuiRenderState getState();
|
||||
|
||||
@Accessor("scissorStack")
|
||||
DrawContext.ScissorStack getScissorStack();
|
||||
}
|
||||
@@ -33,29 +33,22 @@ import static eu.midnightdust.midnightcontrols.MidnightControls.id;
|
||||
@Mixin(GameOptionsScreen.class)
|
||||
public abstract class GameOptionsScreenMixin extends Screen {
|
||||
@Shadow @Nullable protected OptionListWidget body;
|
||||
@Unique TextIconButtonWidget midnightcontrols$button = TextIconButtonWidget.builder(Text.translatable("midnightcontrols.menu.title.controller"),
|
||||
(button -> this.client.setScreen(new MidnightControlsSettingsScreen(this, false))), true)
|
||||
@Unique TextIconButtonWidget midnightcontrols$button = TextIconButtonWidget.builder(Text.translatable("midnightcontrols.menu.title.controller"), (button -> this.client.setScreen(new MidnightControlsSettingsScreen(this, false))), true)
|
||||
.dimension(20,20).texture(id("icon/controller"), 20, 20).build();
|
||||
|
||||
protected GameOptionsScreenMixin(Text title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(method = "initBody", at = @At("TAIL"))
|
||||
@Inject(method = "init", at = @At("TAIL"))
|
||||
public void midnightcontrols$addMCButton(CallbackInfo ci) {
|
||||
if (this.getClass().toString().equals(ControlsOptionsScreen.class.toString())) {
|
||||
this.midnightcontrols$setButtonPos();
|
||||
this.addSelectableChild(midnightcontrols$button);
|
||||
}
|
||||
}
|
||||
@Inject(method = "init", at = @At("TAIL"))
|
||||
public void midnightcontrols$drawMCButton(CallbackInfo ci) {
|
||||
if (this.getClass().toString().equals(ControlsOptionsScreen.class.toString())) {
|
||||
this.addDrawableChild(midnightcontrols$button);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "refreshWidgetPositions", at = @At("TAIL"))
|
||||
@Inject(method = "initTabNavigation", at = @At("TAIL"))
|
||||
public void midnightcontrols$onResize(CallbackInfo ci) {
|
||||
this.midnightcontrols$setButtonPos();
|
||||
}
|
||||
|
||||
@@ -30,23 +30,23 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
public abstract class GameRendererMixin {
|
||||
@Shadow @Final private MinecraftClient client;
|
||||
@Shadow @Final MinecraftClient client;
|
||||
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Mouse;getScaledX(Lnet/minecraft/client/util/Window;)D", shift = At.Shift.BEFORE))
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Mouse;getX()D", shift = At.Shift.BEFORE))
|
||||
private void midnightcontrols$onRender(RenderTickCounter tickCounter, boolean tick, CallbackInfo ci) {
|
||||
if (this.client.currentScreen != null && MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER)
|
||||
MidnightControlsClient.input.onPreRenderScreen(this.client.currentScreen);
|
||||
}
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;renderWithTooltip(Lnet/minecraft/client/gui/DrawContext;IIF)V", shift = At.Shift.AFTER))
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;draw()V", shift = At.Shift.BEFORE))
|
||||
private void midnightcontrols$renderVirtualCursor(RenderTickCounter tickCounter, boolean tick, CallbackInfo ci, @Local DrawContext drawContext) {
|
||||
MidnightControlsRenderer.renderVirtualCursor(drawContext, client);
|
||||
if (MidnightControlsClient.isWayland) MidnightControlsRenderer.renderWaylandCursor(drawContext, client);
|
||||
//drawContext.draw();
|
||||
drawContext.draw();
|
||||
}
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/GameRenderer;renderHand(FZLorg/joml/Matrix4f;)V"), method = "renderWorld")
|
||||
private void midnigtcontrols$captureMatrices(RenderTickCounter tickCounter, CallbackInfo ci, @Local(ordinal = 1) Matrix4f projectionMatrix, @Local(ordinal = 2) Matrix4f worldSpaceMatrix) {
|
||||
TouchUtils.lastProjMat.set(projectionMatrix);
|
||||
@Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/GameRenderer;renderHand:Z"), method = "renderWorld")
|
||||
private void midnigtcontrols$captureMatrices(RenderTickCounter tickCounter, CallbackInfo ci, @Local(ordinal = 1) Matrix4f matrices) {
|
||||
TouchUtils.lastProjMat.set(RenderSystem.getProjectionMatrix());
|
||||
TouchUtils.lastModMat.set(RenderSystem.getModelViewMatrix());
|
||||
TouchUtils.lastWorldSpaceMatrix.set(worldSpaceMatrix);
|
||||
TouchUtils.lastWorldSpaceMatrix.set(matrices);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package eu.midnightdust.midnightcontrols.client.mixin;
|
||||
|
||||
import net.minecraft.client.input.Input;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(Input.class)
|
||||
public interface InputAccessor {
|
||||
@Accessor
|
||||
void setMovementVector(Vec2f input);
|
||||
}
|
||||
@@ -28,7 +28,6 @@ import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
@@ -39,7 +38,6 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static eu.midnightdust.midnightcontrols.client.MidnightControlsClient.client;
|
||||
import static eu.midnightdust.midnightcontrols.client.MidnightControlsClient.reacharound;
|
||||
|
||||
@Mixin(MinecraftClient.class)
|
||||
@@ -56,10 +54,6 @@ public abstract class MinecraftClientMixin {
|
||||
|
||||
@Shadow public abstract void setScreen(Screen screen);
|
||||
|
||||
@Shadow public int attackCooldown;
|
||||
|
||||
@Shadow protected abstract void handleInputEvents();
|
||||
|
||||
@Unique private BlockPos midnightcontrols$lastTargetPos;
|
||||
@Unique private Vec3d midnightcontrols$lastPos;
|
||||
@Unique private Direction midnightcontrols$lastTargetSide;
|
||||
@@ -87,7 +81,7 @@ public abstract class MinecraftClientMixin {
|
||||
var side = hitResult.getSide();
|
||||
|
||||
boolean sidewaysBlockPlacing = this.midnightcontrols$lastTargetPos == null || !targetPos.equals(this.midnightcontrols$lastTargetPos.offset(this.midnightcontrols$lastTargetSide));
|
||||
boolean backwardsBlockPlacing = this.player.input.getMovementInput().y < 0.0f && (this.midnightcontrols$lastTargetPos == null || targetPos.equals(this.midnightcontrols$lastTargetPos.offset(this.midnightcontrols$lastTargetSide)));
|
||||
boolean backwardsBlockPlacing = this.player.input.movementForward < 0.0f && (this.midnightcontrols$lastTargetPos == null || targetPos.equals(this.midnightcontrols$lastTargetPos.offset(this.midnightcontrols$lastTargetSide)));
|
||||
|
||||
if (cooldown > 1
|
||||
&& !targetPos.equals(this.midnightcontrols$lastTargetPos)
|
||||
@@ -133,12 +127,12 @@ public abstract class MinecraftClientMixin {
|
||||
int previousStackCount = stackInHand.getCount();
|
||||
var result = this.interactionManager.interactBlock(this.player, hand, hitResult);
|
||||
if (result.isAccepted()) {
|
||||
//if (result.shouldSwingHand()) {
|
||||
if (result.shouldSwingHand()) {
|
||||
this.player.swingHand(hand);
|
||||
if (!stackInHand.isEmpty() && (stackInHand.getCount() != previousStackCount || this.player.isInCreativeMode())) {
|
||||
if (!stackInHand.isEmpty() && (stackInHand.getCount() != previousStackCount || this.interactionManager.hasCreativeInventory())) {
|
||||
this.gameRenderer.firstPersonRenderer.resetEquipProgress(hand);
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
ci.cancel();
|
||||
}
|
||||
@@ -150,21 +144,10 @@ public abstract class MinecraftClientMixin {
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: Replace this with MixinExtras' Expressions once that's officially released
|
||||
@Inject(method = "tick", at = @At(value = "INVOKE",target = "Lnet/minecraft/client/gui/hud/DebugHud;shouldShowDebugHud()Z"))
|
||||
private void midnightcontrols$handleKeybindsWithTouchOverlay(CallbackInfo ci, @Local Profiler profiler) {
|
||||
if (client.currentScreen instanceof TouchscreenOverlay) {
|
||||
profiler.swap("Keybindings");
|
||||
this.handleInputEvents();
|
||||
if (this.attackCooldown > 0) {
|
||||
--this.attackCooldown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Needed, as it will cause item actions not to work in touchscreen mode otherwise with the above method
|
||||
@Inject(method = "handleInputEvents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isUsingItem()Z"), cancellable = true)
|
||||
private void midnightcontrols$dontHandleItemAndBlockInteractions(CallbackInfo ci) {
|
||||
if (client.currentScreen instanceof TouchscreenOverlay) ci.cancel();
|
||||
}
|
||||
// This is always supposed to be located at before the line 'this.profiler.swap("Keybindings");'
|
||||
// @Redirect(method = "tick", at = @At(value = "FIELD",target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;", ordinal = 6))
|
||||
// private Screen midnightcontrols$ignoreTouchOverlay(MinecraftClient instance) {
|
||||
// if (instance.currentScreen instanceof TouchscreenOverlay) return null;
|
||||
// return instance.currentScreen;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import net.minecraft.client.Mouse;
|
||||
import net.minecraft.client.util.GlfwUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ThrowablePotionItem;
|
||||
import net.minecraft.item.consume.UseAction;
|
||||
import net.minecraft.util.UseAction;
|
||||
import net.minecraft.util.math.Smoother;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
@@ -77,8 +77,7 @@ public abstract class MouseMixin implements MouseAccessor {
|
||||
for (int slot = 0; slot < 9; ++slot) {
|
||||
int slotX = centerX - 90 + slot * 20 + 2;
|
||||
if (mouseX >= (double) slotX && mouseX <= (double) (slotX + 20)) {
|
||||
client.player.getInventory().setSelectedSlot(slot);
|
||||
TouchInput.clickStartTime = -1;
|
||||
client.player.getInventory().selectedSlot = slot;
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2021 LambdAurora <aurora42lambda@gmail.com>
|
||||
*
|
||||
* This file is part of midnightcontrols.
|
||||
*
|
||||
* Licensed under the MIT license. For more information,
|
||||
* see the LICENSE file.
|
||||
*/
|
||||
|
||||
package eu.midnightdust.midnightcontrols.client.mixin;
|
||||
|
||||
import net.minecraft.client.gui.screen.ingame.RecipeBookScreen;
|
||||
import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(RecipeBookScreen.class)
|
||||
public interface RecipeBookScreenAccessor {
|
||||
@Accessor("recipeBook")
|
||||
RecipeBookWidget<?> getRecipeBook();
|
||||
}
|
||||
@@ -27,4 +27,7 @@ public interface RecipeBookWidgetAccessor {
|
||||
|
||||
@Accessor("currentTab")
|
||||
void setCurrentTab(RecipeGroupButtonWidget currentTab);
|
||||
|
||||
@Invoker("refreshResults")
|
||||
void midnightcontrols$refreshResults(boolean resetCurrentPage);
|
||||
}
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
|
||||
package eu.midnightdust.midnightcontrols.client.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import eu.midnightdust.lib.util.MidnightColorUtil;
|
||||
import eu.midnightdust.midnightcontrols.ControlsMode;
|
||||
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
|
||||
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
|
||||
import eu.midnightdust.midnightcontrols.client.touch.TouchInput;
|
||||
import eu.midnightdust.midnightcontrols.client.enums.TouchMode;
|
||||
@@ -26,7 +28,8 @@ import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.util.math.ColorHelper;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import org.joml.Matrix4f;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -58,8 +61,12 @@ public abstract class WorldRendererMixin {
|
||||
@Final
|
||||
private BufferBuilderStorage bufferBuilders;
|
||||
|
||||
@Redirect(method = "renderTargetBlockOutline", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/hit/BlockHitResult;getType()Lnet/minecraft/util/hit/HitResult$Type;"))
|
||||
private HitResult.Type dontRenderOutline(BlockHitResult instance) {
|
||||
@Shadow
|
||||
private static void drawCuboidShapeOutline(MatrixStack matrices, VertexConsumer vertexConsumer, VoxelShape shape, double offsetX, double offsetY, double offsetZ, float red, float green, float blue, float alpha) {
|
||||
}
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/hit/HitResult;getType()Lnet/minecraft/util/hit/HitResult$Type;"))
|
||||
private HitResult.Type dontRenderOutline(HitResult instance) {
|
||||
if (MidnightControlsConfig.controlsMode == ControlsMode.TOUCHSCREEN && MidnightControlsConfig.touchMode == TouchMode.FINGER_POS) {
|
||||
return HitResult.Type.MISS;
|
||||
}
|
||||
@@ -67,10 +74,15 @@ public abstract class WorldRendererMixin {
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "renderTargetBlockOutline",
|
||||
at = @At("HEAD")
|
||||
method = "render",
|
||||
at = @At(
|
||||
value = "FIELD",
|
||||
target = "Lnet/minecraft/client/MinecraftClient;crosshairTarget:Lnet/minecraft/util/hit/HitResult;",
|
||||
ordinal = 1,
|
||||
shift = At.Shift.AFTER
|
||||
)
|
||||
)
|
||||
private void onOutlineRender(Camera camera, VertexConsumerProvider.Immediate vertexConsumers, MatrixStack matrices, boolean translucent, CallbackInfo ci) {
|
||||
private void onOutlineRender(RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci, @Local MatrixStack matrices) {
|
||||
if (((MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER && MidnightControlsConfig.touchInControllerMode) || MidnightControlsConfig.controlsMode == ControlsMode.TOUCHSCREEN)
|
||||
&& MidnightControlsConfig.touchMode == TouchMode.FINGER_POS) {
|
||||
this.midnightcontrols$renderFingerOutline(matrices, camera);
|
||||
@@ -90,8 +102,8 @@ public abstract class WorldRendererMixin {
|
||||
var pos = camera.getPos();
|
||||
matrices.push();
|
||||
var vertexConsumer = this.bufferBuilders.getEntityVertexConsumers().getBuffer(RenderLayer.getLines());
|
||||
VertexRendering.drawOutline(matrices, vertexConsumer, outlineShape, blockPos.getX() - pos.getX(), blockPos.getY() - pos.getY(), blockPos.getZ() - pos.getZ(),
|
||||
ColorHelper.withAlpha(MidnightControlsConfig.touchOutlineColorAlpha, rgb.getRGB()));
|
||||
drawCuboidShapeOutline(matrices, vertexConsumer, outlineShape, blockPos.getX() - pos.getX(), blockPos.getY() - pos.getY(), blockPos.getZ() - pos.getZ(),
|
||||
rgb.getRed() / 255.f, rgb.getGreen() / 255.f, rgb.getBlue() / 255.f, MidnightControlsConfig.touchOutlineColorAlpha / 255.f);
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
@@ -122,8 +134,9 @@ public abstract class WorldRendererMixin {
|
||||
if (MidnightControlsConfig.reacharoundOutlineColorHex.isEmpty()) rgb = RainbowColor.radialRainbow(1,1);
|
||||
matrices.push();
|
||||
var vertexConsumer = this.bufferBuilders.getEntityVertexConsumers().getBuffer(RenderLayer.getLines());
|
||||
VertexRendering.drawOutline(matrices, vertexConsumer, outlineShape, blockPos.getX() - pos.getX(), blockPos.getY() - pos.getY(), blockPos.getZ() - pos.getZ(),
|
||||
ColorHelper.withAlpha(MidnightControlsConfig.touchOutlineColorAlpha, rgb.getRGB()));
|
||||
drawCuboidShapeOutline(matrices, vertexConsumer, outlineShape,
|
||||
(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);
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,12 +85,12 @@ public class TouchInput {
|
||||
int previousStackCount = stackInHand.getCount();
|
||||
var interaction = client.interactionManager.interactBlock(client.player, client.player.getActiveHand(), blockHit);
|
||||
if (interaction.isAccepted()) {
|
||||
//if (interaction.shouldSwingHand()) {
|
||||
if (interaction.shouldSwingHand()) {
|
||||
client.player.swingHand(client.player.preferredHand);
|
||||
if (!stackInHand.isEmpty() && (stackInHand.getCount() != previousStackCount || client.player.isInCreativeMode())) {
|
||||
if (!stackInHand.isEmpty() && (stackInHand.getCount() != previousStackCount || client.interactionManager.hasCreativeInventory())) {
|
||||
client.gameRenderer.firstPersonRenderer.resetEquipProgress(client.player.preferredHand);
|
||||
}
|
||||
//}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.entity.projectile.ProjectileUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.consume.UseAction;
|
||||
import net.minecraft.util.UseAction;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.hit.EntityHitResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
@@ -38,7 +38,7 @@ public class TouchUtils {
|
||||
|
||||
if (entityCast != null && entityCast.getType() == HitResult.Type.ENTITY) return entityCast;
|
||||
|
||||
BlockHitResult result = client.world.raycast(new RaycastContext(near, far, RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, client.player));
|
||||
BlockHitResult result = client.world.raycast(new RaycastContext(near, far, RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.ANY, client.player));
|
||||
|
||||
if (client.player.getPos().distanceTo(result.getPos()) > playerRange) return null;
|
||||
return result;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package eu.midnightdust.midnightcontrols.client.touch.gui;
|
||||
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.item.consume.UseAction;
|
||||
import org.thinkingstudio.obsidianui.Position;
|
||||
import org.thinkingstudio.obsidianui.widget.SpruceButtonWidget;
|
||||
import eu.midnightdust.midnightcontrols.MidnightControlsConstants;
|
||||
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
|
||||
import net.minecraft.item.ArmorItem;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.UseAction;
|
||||
|
||||
public class ItemUseButtonWidget extends SpruceButtonWidget {
|
||||
|
||||
@@ -30,7 +30,7 @@ public class ItemUseButtonWidget extends SpruceButtonWidget {
|
||||
this.setMessage(Text.translatable(MidnightControlsConstants.NAMESPACE+".action.eat"));
|
||||
} else if (action == UseAction.DRINK) {
|
||||
this.setMessage(Text.translatable(MidnightControlsConstants.NAMESPACE+".action.drink"));
|
||||
} else if (client.player.getMainHandStack().getComponents().contains(DataComponentTypes.EQUIPPABLE)) {
|
||||
} else if (client.player.getMainHandStack().getItem() instanceof ArmorItem) {
|
||||
this.setMessage(Text.translatable(MidnightControlsConstants.NAMESPACE+".action.equip"));
|
||||
} else if (!action.equals(UseAction.NONE)) {
|
||||
this.setMessage(Text.translatable(MidnightControlsConstants.NAMESPACE+".action.use"));
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package eu.midnightdust.midnightcontrols.client.touch.gui;
|
||||
|
||||
import eu.midnightdust.midnightcontrols.client.touch.TouchInput;
|
||||
import org.thinkingstudio.obsidianui.Position;
|
||||
import org.thinkingstudio.obsidianui.widget.SpruceTexturedButtonWidget;
|
||||
import net.minecraft.text.Text;
|
||||
@@ -35,7 +34,6 @@ public class SilentTexturedButtonWidget extends SpruceTexturedButtonWidget {
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
this.setActive(true);
|
||||
super.onClick(mouseX, mouseY);
|
||||
TouchInput.clickStartTime = -1;
|
||||
this.setActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ import eu.midnightdust.midnightcontrols.client.util.storage.AxisStorage;
|
||||
import net.minecraft.client.gui.screen.ChatScreen;
|
||||
import net.minecraft.client.gui.screen.GameMenuScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.item.consume.UseAction;
|
||||
import net.minecraft.item.ArmorItem;
|
||||
import net.minecraft.util.Arm;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.UseAction;
|
||||
import org.thinkingstudio.obsidianui.Position;
|
||||
import org.thinkingstudio.obsidianui.widget.SpruceButtonWidget;
|
||||
import eu.midnightdust.lib.util.PlatformFunctions;
|
||||
@@ -34,8 +34,10 @@ import eu.midnightdust.midnightcontrols.client.util.KeyBindingAccessor;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
|
||||
import net.minecraft.client.gui.widget.TextIconButtonWidget;
|
||||
import net.minecraft.client.option.KeyBinding;
|
||||
import net.minecraft.client.texture.MissingSprite;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -90,7 +92,7 @@ public class TouchscreenOverlay extends Screen {
|
||||
assert this.client != null;
|
||||
this.client.setScreen(new GameMenuScreen(true));
|
||||
if (this.client.isIntegratedServerRunning() && !Objects.requireNonNull(this.client.getServer()).isRemote()) {
|
||||
this.client.getSoundManager().pauseAllExcept();
|
||||
this.client.getSoundManager().pauseAll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,13 +298,7 @@ public class TouchscreenOverlay extends Screen {
|
||||
if (binding == null) continue;
|
||||
boolean hasTexture = client.getGuiAtlasManager().getSprite(id("binding/"+bindName)) != missingSprite;
|
||||
if (MidnightControlsConfig.debug) System.out.println(left +" "+id("binding/"+bindName)+" "+ hasTexture);
|
||||
var button = TextIconButtonWidget.builder(Text.translatable(binding.getTranslationKey()), b -> {
|
||||
binding.handle(client, 1.0f, ButtonState.PRESS);
|
||||
if (binding.asKeyBinding().isPresent()) {
|
||||
binding.asKeyBinding().get().setPressed(true);
|
||||
((KeyBindingAccessor)binding.asKeyBinding().get()).midnightcontrols$press();
|
||||
}
|
||||
}, hasTexture)
|
||||
var button = TextIconButtonWidget.builder(Text.translatable(binding.getTranslationKey()), b -> binding.handle(client, 1, ButtonState.PRESS), hasTexture)
|
||||
.texture(hasTexture ? id("binding/"+bindName) : emptySprite, 20, 20).dimension(20, 20).build();
|
||||
button.setPosition(left ? (3+(i*23)) : this.width-(23+(i*23)), 3);
|
||||
button.setAlpha(MidnightControlsConfig.touchTransparency / 100f);
|
||||
@@ -344,7 +340,7 @@ public class TouchscreenOverlay extends Screen {
|
||||
this.forwardLeftButton.setVisible(false);
|
||||
this.forwardRightButton.setVisible(false);
|
||||
}
|
||||
this.useButton.setVisible(client.player.getMainHandStack() != null && (client.player.getMainHandStack().getUseAction() != UseAction.NONE || client.player.getMainHandStack().getComponents().contains(DataComponentTypes.EQUIPPABLE)) && !TouchUtils.hasInWorldUseAction(client.player.getMainHandStack()));
|
||||
this.useButton.setVisible(client.player.getMainHandStack() != null && (client.player.getMainHandStack().getUseAction() != UseAction.NONE || client.player.getMainHandStack().getItem() instanceof ArmorItem) && !TouchUtils.hasInWorldUseAction(client.player.getMainHandStack()));
|
||||
this.updateJumpButtons();
|
||||
}
|
||||
|
||||
@@ -363,4 +359,10 @@ public class TouchscreenOverlay extends Screen {
|
||||
}
|
||||
return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
|
||||
}
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||
KeyBinding.onKeyPressed(InputUtil.fromKeyCode(keyCode, scanCode));
|
||||
super.keyPressed(keyCode,scanCode,modifiers);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package eu.midnightdust.midnightcontrols.client.util;
|
||||
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
public interface AbstractSignEditScreenAccessor {
|
||||
@Unique
|
||||
String[] midnightcontrols$getMessages();
|
||||
|
||||
@Unique
|
||||
void midnightcontrols$setMessage(int line, String text);
|
||||
|
||||
@Unique
|
||||
void midnightcontrols$writeToBlockEntity();
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class InventoryUtil {
|
||||
|
||||
if (closestSlot.isPresent() && client.player != null) {
|
||||
var slot = closestSlot.get().getLeft();
|
||||
if (slot.hasStack() || !client.player.getInventory().getSelectedStack().isEmpty()) {
|
||||
if (slot.hasStack() || !client.player.getInventory().getMainHandStack().isEmpty()) {
|
||||
int slotCenterXScaled = guiLeft + slot.x + 8;
|
||||
int slotCenterYScaled = guiTop + slot.y + 8;
|
||||
int slotCenterX = (int) (slotCenterXScaled / ((double) client.getWindow().getScaledWidth() / (double) client.getWindow().getWidth()));
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
package eu.midnightdust.midnightcontrols.client.virtualkeyboard;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class KeyboardLayout {
|
||||
|
||||
public static KeyboardLayout QWERTY = new KeyboardLayout("en_US:qwerty", createQwertyLetterLayout(), createSymbolLayout());
|
||||
|
||||
private final String id;
|
||||
private final List<List<String>> letters;
|
||||
private final List<List<String>> symbols;
|
||||
|
||||
private KeyboardLayout(String id, List<List<String>> letters, List<List<String>> symbols) {
|
||||
this.id = id;
|
||||
this.letters = letters;
|
||||
this.symbols = symbols;
|
||||
}
|
||||
|
||||
public static KeyboardLayout fromJson(JsonObject json) {
|
||||
try {
|
||||
return new KeyboardLayout(json.get("id").getAsString(), getFromJson(json, true), getFromJson(json, false));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error loading keyboard definition: %s".formatted(e));
|
||||
}
|
||||
}
|
||||
private static List<List<String>> getFromJson(JsonObject json, boolean letters) {
|
||||
String type = letters ? "letters" : "symbols";
|
||||
List<List<String>> arr = new ArrayList<>();
|
||||
if (json.has(type)) {
|
||||
JsonObject lettersJson = json.get(type).getAsJsonObject();
|
||||
for (int i = 0; ; i++) {
|
||||
if (!lettersJson.has("row"+i)) break;
|
||||
var rowJson = lettersJson.get("row%s".formatted(i)).getAsJsonArray();
|
||||
List<String> row = new ArrayList<>();
|
||||
for (int j = 0; j < rowJson.size(); j++) {
|
||||
row.add(rowJson.get(j).getAsString());
|
||||
}
|
||||
arr.add(row);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
else {
|
||||
return letters ? createQwertyLetterLayout() : createSymbolLayout();
|
||||
}
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTranslationKey() {
|
||||
String[] identifier = id.split(":");
|
||||
if (identifier.length != 2) return "Invalid Keyboard ID: %s".formatted(id);
|
||||
return "midnightcontrols.virtual_keyboard.layout.%s.%s".formatted(identifier[0], identifier[1]);
|
||||
}
|
||||
|
||||
public List<List<String>> getLetters() {
|
||||
return letters;
|
||||
}
|
||||
|
||||
public List<List<String>> getSymbols() {
|
||||
return symbols;
|
||||
}
|
||||
|
||||
private static List<List<String>> createQwertyLetterLayout() {
|
||||
List<List<String>> letters = new ArrayList<>();
|
||||
letters.add(Arrays.asList(
|
||||
"q", "w", "e", "r", "t",
|
||||
"y", "u", "i", "o", "p"
|
||||
));
|
||||
letters.add(Arrays.asList(
|
||||
"a", "s", "d", "f", "g",
|
||||
"h", "j", "k", "l"
|
||||
));
|
||||
letters.add(Arrays.asList(
|
||||
"z", "x", "c", "v",
|
||||
"b", "n", "m"
|
||||
));
|
||||
return letters;
|
||||
}
|
||||
|
||||
private static List<List<String>> createSymbolLayout() {
|
||||
List<List<String>> symbols = new ArrayList<>();
|
||||
symbols.add(Arrays.asList(
|
||||
"1", "2", "3", "4", "5",
|
||||
"6", "7", "8", "9", "0"
|
||||
));
|
||||
symbols.add(Arrays.asList(
|
||||
"@", "#", "$", "%", "&",
|
||||
"*", "-", "+", "(", ")"
|
||||
));
|
||||
symbols.add(Arrays.asList(
|
||||
"!", "\"", "'", ":", ";",
|
||||
",", ".", "?", "/"
|
||||
));
|
||||
return symbols;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package eu.midnightdust.midnightcontrols.client.virtualkeyboard;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
|
||||
import net.minecraft.resource.Resource;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class KeyboardLayoutManager {
|
||||
private static final Map<String, KeyboardLayout> KEYBOARD_LAYOUTS = new HashMap<>();
|
||||
|
||||
public static void loadLayout(Identifier id, Resource resource) {
|
||||
try {
|
||||
JsonObject json = JsonParser.parseReader(resource.getReader()).getAsJsonObject();
|
||||
KeyboardLayout layout = KeyboardLayout.fromJson(json);
|
||||
KEYBOARD_LAYOUTS.put(layout.getId(), layout);
|
||||
if (MidnightControlsConfig.debug) System.out.printf("Loaded keyboard layout: %s\n", layout.getId());
|
||||
} catch (IOException e) { throw new RuntimeException(e); }
|
||||
}
|
||||
public static KeyboardLayout getById(String id) {
|
||||
return KEYBOARD_LAYOUTS.get(id) == null ? KeyboardLayout.QWERTY : KEYBOARD_LAYOUTS.get(id);
|
||||
}
|
||||
public static KeyboardLayout getNext(KeyboardLayout current) {
|
||||
KeyboardLayout[] layouts = KEYBOARD_LAYOUTS.values().toArray(KeyboardLayout[]::new);
|
||||
int currentIndex = -1;
|
||||
for (int i = 0; i < layouts.length; i++) {
|
||||
if (layouts[i] == current) currentIndex = i;
|
||||
}
|
||||
currentIndex = currentIndex+1 >= layouts.length ? 0 : currentIndex + 1;
|
||||
return layouts[currentIndex];
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package eu.midnightdust.midnightcontrols.client.virtualkeyboard;
|
||||
|
||||
import eu.midnightdust.midnightcontrols.client.virtualkeyboard.clickhandler.AbstractScreenClickHandler;
|
||||
import eu.midnightdust.midnightcontrols.client.virtualkeyboard.clickhandler.BookEditScreenClickHandler;
|
||||
import eu.midnightdust.midnightcontrols.client.virtualkeyboard.clickhandler.DefaultScreenClickHandler;
|
||||
import eu.midnightdust.midnightcontrols.client.virtualkeyboard.clickhandler.SignEditScreenClickHandler;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.ingame.BookEditScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.BookSigningScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.SignEditScreen;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class MouseClickInterceptor {
|
||||
|
||||
private final Map<Class<?>, AbstractScreenClickHandler<?>> clickHandlers;
|
||||
|
||||
public MouseClickInterceptor() {
|
||||
this.clickHandlers = new HashMap<>();
|
||||
this.clickHandlers.put(BookSigningScreen.class, new BookEditScreenClickHandler.Signing());
|
||||
this.clickHandlers.put(BookEditScreen.class, new BookEditScreenClickHandler());
|
||||
this.clickHandlers.put(SignEditScreen.class, new SignEditScreenClickHandler());
|
||||
this.clickHandlers.put(Screen.class, new DefaultScreenClickHandler());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Screen> void intercept(T screen, double mouseX, double mouseY) {
|
||||
AbstractScreenClickHandler<T> handler = (AbstractScreenClickHandler<T>) clickHandlers.get(screen.getClass());
|
||||
|
||||
if (handler == null) {
|
||||
handler = (AbstractScreenClickHandler<T>) clickHandlers.get(Screen.class);
|
||||
}
|
||||
|
||||
handler.handle(screen, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package eu.midnightdust.midnightcontrols.client.virtualkeyboard.clickhandler;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
||||
public abstract class AbstractScreenClickHandler<T extends Screen> {
|
||||
public abstract void handle(T screen, double mouseX, double mouseY);
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package eu.midnightdust.midnightcontrols.client.virtualkeyboard.clickhandler;
|
||||
|
||||
import eu.midnightdust.midnightcontrols.client.mixin.BookEditScreenAccessor;
|
||||
import eu.midnightdust.midnightcontrols.client.mixin.BookSigningScreenAccessor;
|
||||
import eu.midnightdust.midnightcontrols.client.virtualkeyboard.gui.VirtualKeyboardScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.BookEditScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.BookSigningScreen;
|
||||
import net.minecraft.client.gui.widget.EditBoxWidget;
|
||||
|
||||
import static eu.midnightdust.midnightcontrols.client.MidnightControlsClient.client;
|
||||
|
||||
public class BookEditScreenClickHandler extends AbstractScreenClickHandler<BookEditScreen> {
|
||||
@Override
|
||||
public void handle(BookEditScreen screen, double mouseX, double mouseY) {
|
||||
// don't open the keyboard if a UI element was clicked
|
||||
if(screen.hoveredElement(mouseX, mouseY).isPresent() && !(screen.hoveredElement(mouseX, mouseY).get() instanceof EditBoxWidget)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var accessor = (BookEditScreenAccessor) screen;
|
||||
|
||||
VirtualKeyboardScreen virtualKeyboardScreen = new VirtualKeyboardScreen(accessor.midnightcontrols$getEditBox().getText(), (text) -> {
|
||||
client.setScreen(screen);
|
||||
accessor.midnightcontrols$getEditBox().setText(text);
|
||||
}, true);
|
||||
|
||||
client.setScreen(virtualKeyboardScreen);
|
||||
}
|
||||
public static class Signing extends AbstractScreenClickHandler<BookSigningScreen> {
|
||||
@Override
|
||||
public void handle(BookSigningScreen screen, double mouseX, double mouseY) {
|
||||
// don't open the keyboard if a UI element was clicked
|
||||
if(screen.hoveredElement(mouseX, mouseY).isPresent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var accessor = (BookSigningScreenAccessor) screen;
|
||||
|
||||
VirtualKeyboardScreen virtualKeyboardScreen = new VirtualKeyboardScreen(accessor.midnightcontrols$getBookTitleTextField().getText(), (text) -> {
|
||||
client.setScreen(screen);
|
||||
accessor.midnightcontrols$getBookTitleTextField().setText(text);
|
||||
}, false);
|
||||
|
||||
client.setScreen(virtualKeyboardScreen);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
package eu.midnightdust.midnightcontrols.client.virtualkeyboard.clickhandler;
|
||||
|
||||
import eu.midnightdust.midnightcontrols.client.mixin.CreativeInventoryScreenAccessor;
|
||||
import eu.midnightdust.midnightcontrols.client.virtualkeyboard.gui.VirtualKeyboardScreen;
|
||||
import net.minecraft.client.gui.Element;
|
||||
import net.minecraft.client.gui.ParentElement;
|
||||
import net.minecraft.client.gui.screen.ChatScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static eu.midnightdust.midnightcontrols.client.MidnightControlsClient.client;
|
||||
|
||||
public class DefaultScreenClickHandler extends AbstractScreenClickHandler<Screen> {
|
||||
|
||||
private Screen parentScreen;
|
||||
private List<Integer> textFieldElementPath;
|
||||
|
||||
@Override
|
||||
public void handle(Screen screen, double mouseX, double mouseY) {
|
||||
var textField = findClickedTextField(screen.children(), mouseX, mouseY);
|
||||
if (textField == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.parentScreen = screen;
|
||||
this.textFieldElementPath = calculatePathToElement(screen, textField.asElement());
|
||||
|
||||
var virtualKeyboardScreen = new VirtualKeyboardScreen(textField.getText(), this::handleKeyboardClose, false);
|
||||
client.setScreen(virtualKeyboardScreen);
|
||||
}
|
||||
|
||||
private void handleKeyboardClose(String newText) {
|
||||
if (this.parentScreen == null || this.textFieldElementPath == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
client.setScreen(this.parentScreen);
|
||||
TextFieldWrapper textField = findTextFieldByPath(this.parentScreen, this.textFieldElementPath);
|
||||
if (textField == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
textField.setText(newText);
|
||||
|
||||
switch (this.parentScreen) {
|
||||
case CreativeInventoryScreen creativeInventoryScreen -> {
|
||||
var accessor = (CreativeInventoryScreenAccessor) creativeInventoryScreen;
|
||||
accessor.midnightcontrols$search();
|
||||
}
|
||||
case ChatScreen chatScreen -> {
|
||||
// send the chat message
|
||||
chatScreen.keyPressed(GLFW.GLFW_KEY_ENTER, 0, 0);
|
||||
}
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private TextFieldWrapper findClickedTextField(List<? extends Element> elements, double mouseX, double mouseY) {
|
||||
for (Element element : elements) {
|
||||
if (TextFieldWrapper.isValidTextField(element)) {
|
||||
TextFieldWrapper textField = new TextFieldWrapper(element);
|
||||
if (textField.isMouseOver(mouseX, mouseY) && textField.isFocused()) {
|
||||
return textField;
|
||||
}
|
||||
}
|
||||
|
||||
if (element instanceof ParentElement parentElement) {
|
||||
TextFieldWrapper found = findClickedTextField(parentElement.children(), mouseX, mouseY);
|
||||
if (found != null) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the path between a parent and a target in the UI hierarchy
|
||||
*/
|
||||
protected List<Integer> calculatePathToElement(Element parent, Element target) {
|
||||
if (!(parent instanceof ParentElement parentElement)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<? extends Element> children = parentElement.children();
|
||||
|
||||
for (int i = 0; i < children.size(); i++) {
|
||||
Element child = children.get(i);
|
||||
|
||||
if (child == target) {
|
||||
return Collections.singletonList(i);
|
||||
}
|
||||
|
||||
if (child instanceof ParentElement) {
|
||||
List<Integer> subPath = calculatePathToElement(child, target);
|
||||
if (subPath != null) {
|
||||
List<Integer> fullPath = new ArrayList<>(subPath.size() + 1);
|
||||
fullPath.add(i);
|
||||
fullPath.addAll(subPath);
|
||||
return fullPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected TextFieldWrapper findTextFieldByPath(Element parent, List<Integer> path) {
|
||||
if (path == null || path.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!(parent instanceof ParentElement parentElement)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<? extends Element> children = parentElement.children();
|
||||
int index = path.get(0);
|
||||
|
||||
if (index < 0 || index >= children.size()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Element child = children.get(index);
|
||||
|
||||
if (path.size() == 1) {
|
||||
return TextFieldWrapper.isValidTextField(child) ? new TextFieldWrapper(child) : null;
|
||||
}
|
||||
|
||||
if (child instanceof ParentElement) {
|
||||
return findTextFieldByPath(child, path.subList(1, path.size()));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package eu.midnightdust.midnightcontrols.client.virtualkeyboard.clickhandler;
|
||||
|
||||
import eu.midnightdust.midnightcontrols.client.util.AbstractSignEditScreenAccessor;
|
||||
import eu.midnightdust.midnightcontrols.client.virtualkeyboard.gui.VirtualKeyboardScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.SignEditScreen;
|
||||
|
||||
import static eu.midnightdust.midnightcontrols.client.MidnightControlsClient.client;
|
||||
|
||||
public class SignEditScreenClickHandler extends AbstractScreenClickHandler<SignEditScreen> {
|
||||
@Override
|
||||
public void handle(SignEditScreen screen, double mouseX, double mouseY) {
|
||||
// don't open the keyboard if a UI element was clicked
|
||||
if(screen.hoveredElement(mouseX, mouseY).isPresent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var accessor = (AbstractSignEditScreenAccessor) screen;
|
||||
|
||||
StringBuilder linesToString = new StringBuilder();
|
||||
String[] messages = accessor.midnightcontrols$getMessages();
|
||||
for (int i = 0; i < Math.min(4, messages.length); i++) {
|
||||
String line = messages[i];
|
||||
linesToString.append(line);
|
||||
if (!line.isEmpty() && i < 3) linesToString.append("\n");
|
||||
}
|
||||
|
||||
VirtualKeyboardScreen virtualKeyboardScreen = new VirtualKeyboardScreen(linesToString.toString(), (text) -> {
|
||||
client.setScreen(screen);
|
||||
String[] lines = text.split("\n");
|
||||
for (int i = 0; i < 4; i++) accessor.midnightcontrols$setMessage(i, lines.length > i ? lines[i] : "");
|
||||
accessor.midnightcontrols$writeToBlockEntity();
|
||||
}, true);
|
||||
|
||||
client.setScreen(virtualKeyboardScreen);
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package eu.midnightdust.midnightcontrols.client.virtualkeyboard.clickhandler;
|
||||
|
||||
import net.minecraft.client.gui.Element;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import org.thinkingstudio.obsidianui.widget.text.SpruceTextFieldWidget;
|
||||
|
||||
public record TextFieldWrapper(Object textField) {
|
||||
|
||||
public TextFieldWrapper {
|
||||
if (!isValidTextField(textField)) {
|
||||
throw new IllegalArgumentException("Type " + textField.getClass() + " is not marked as a valid text field");
|
||||
}
|
||||
}
|
||||
|
||||
Element asElement() {
|
||||
return (Element) textField;
|
||||
}
|
||||
|
||||
String getText() {
|
||||
switch (textField) {
|
||||
case SpruceTextFieldWidget spruceTextField -> {
|
||||
return spruceTextField.getText();
|
||||
}
|
||||
case TextFieldWidget vanillaTextField -> {
|
||||
return vanillaTextField.getText();
|
||||
}
|
||||
default -> {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setText(String text) {
|
||||
switch (textField) {
|
||||
case SpruceTextFieldWidget spruceTextField -> {
|
||||
spruceTextField.setText(text);
|
||||
}
|
||||
case TextFieldWidget vanillaTextField -> {
|
||||
vanillaTextField.setText(text);
|
||||
}
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean isMouseOver(double mouseX, double mouseY) {
|
||||
switch (textField) {
|
||||
case SpruceTextFieldWidget spruceTextField -> {
|
||||
return spruceTextField.isMouseOver(mouseX, mouseY);
|
||||
}
|
||||
case TextFieldWidget vanillaTextField -> {
|
||||
return vanillaTextField.isMouseOver(mouseX, mouseY);
|
||||
}
|
||||
default -> {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean isFocused() {
|
||||
switch (textField) {
|
||||
case SpruceTextFieldWidget spruceTextField -> {
|
||||
return spruceTextField.isFocused();
|
||||
}
|
||||
case TextFieldWidget vanillaTextField -> {
|
||||
return vanillaTextField.isFocused();
|
||||
}
|
||||
default -> {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isValidTextField(Object textField) {
|
||||
return textField instanceof TextFieldWidget || textField instanceof SpruceTextFieldWidget;
|
||||
}
|
||||
}
|
||||
@@ -1,296 +0,0 @@
|
||||
package eu.midnightdust.midnightcontrols.client.virtualkeyboard.gui;
|
||||
|
||||
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
|
||||
import eu.midnightdust.midnightcontrols.client.virtualkeyboard.KeyboardLayout;
|
||||
import eu.midnightdust.midnightcontrols.client.virtualkeyboard.KeyboardLayoutManager;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.text.Text;
|
||||
import org.thinkingstudio.obsidianui.Position;
|
||||
import org.thinkingstudio.obsidianui.SpruceTexts;
|
||||
import org.thinkingstudio.obsidianui.screen.SpruceScreen;
|
||||
import org.thinkingstudio.obsidianui.widget.SpruceButtonWidget;
|
||||
import org.thinkingstudio.obsidianui.widget.container.SpruceContainerWidget;
|
||||
import org.thinkingstudio.obsidianui.widget.text.SpruceTextAreaWidget;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class VirtualKeyboardScreen extends SpruceScreen {
|
||||
|
||||
@FunctionalInterface
|
||||
public interface CloseCallback {
|
||||
void onClose(String text);
|
||||
}
|
||||
|
||||
private static final int STANDARD_KEY_WIDTH = 20;
|
||||
private static final int SPECIAL_KEY_WIDTH = (int) (STANDARD_KEY_WIDTH * 1.5);
|
||||
private static final int KEY_HEIGHT = 20;
|
||||
private static final int HORIZONTAL_SPACING = 2;
|
||||
private static final int VERTICAL_SPACING = 4;
|
||||
private static final int CONTAINER_PADDING = 10;
|
||||
|
||||
// Key symbols
|
||||
private static final String BACKSPACE_SYMBOL = "\b";
|
||||
private static final String NEWLINE_SYMBOL = "\n";
|
||||
private static final String SPACE_SYMBOL = " ";
|
||||
|
||||
private final StringBuilder buffer;
|
||||
private final CloseCallback closeCallback;
|
||||
private final KeyboardLayout layout;
|
||||
private final boolean newLineSupport;
|
||||
|
||||
private boolean capsMode;
|
||||
private boolean symbolMode;
|
||||
private SpruceTextAreaWidget bufferDisplayArea;
|
||||
private SpruceContainerWidget keyboardContainer;
|
||||
|
||||
public VirtualKeyboardScreen(String initialText, CloseCallback closeCallback, boolean newLineSupport) {
|
||||
super(Text.translatable("midnightcontrols.virtual_keyboard.screen"));
|
||||
this.buffer = new StringBuilder(initialText);
|
||||
this.closeCallback = closeCallback;
|
||||
this.layout = KeyboardLayoutManager.getById(MidnightControlsConfig.keyboardLayout);
|
||||
this.capsMode = false;
|
||||
this.symbolMode = false;
|
||||
this.newLineSupport = newLineSupport;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
|
||||
this.bufferDisplayArea = createBufferDisplayArea();
|
||||
this.addDrawableChild(this.bufferDisplayArea);
|
||||
|
||||
rebuildKeyboard();
|
||||
|
||||
int doneButtonY = this.keyboardContainer.getY() + this.keyboardContainer.getHeight() + VERTICAL_SPACING * 2;
|
||||
this.addDrawableChild(
|
||||
new SpruceButtonWidget(
|
||||
Position.of(this, this.width / 2 - 50, doneButtonY),
|
||||
100,
|
||||
20,
|
||||
SpruceTexts.GUI_DONE,
|
||||
btn -> this.close()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldPause() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
super.close();
|
||||
if (this.closeCallback != null) {
|
||||
this.closeCallback.onClose(this.buffer.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private void rebuildKeyboard() {
|
||||
if (this.keyboardContainer != null) {
|
||||
this.remove(this.keyboardContainer);
|
||||
}
|
||||
|
||||
var layoutKeys = getActiveKeyLayout();
|
||||
var keyboardContainer = createKeyboardContainer(layoutKeys);
|
||||
|
||||
addLayoutRows(keyboardContainer, layoutKeys);
|
||||
addFunctionKeys(keyboardContainer);
|
||||
addBottomRow(keyboardContainer);
|
||||
|
||||
this.keyboardContainer = keyboardContainer;
|
||||
this.addDrawableChild(this.keyboardContainer);
|
||||
}
|
||||
|
||||
private SpruceContainerWidget createKeyboardContainer(List<List<String>> layoutKeys) {
|
||||
int containerWidth = this.width;
|
||||
int totalKeyboardHeight = calculateKeyboardHeight(layoutKeys);
|
||||
int keyboardY = this.bufferDisplayArea.getY() + this.bufferDisplayArea.getHeight() + VERTICAL_SPACING * 2;
|
||||
|
||||
return new SpruceContainerWidget(
|
||||
Position.of(0, keyboardY),
|
||||
containerWidth,
|
||||
totalKeyboardHeight
|
||||
);
|
||||
}
|
||||
|
||||
private SpruceTextAreaWidget createBufferDisplayArea() {
|
||||
int lineCount = this.newLineSupport ? 4 : 1;
|
||||
int bufferX = this.width / 2 - 100;
|
||||
int bufferY = this.height / 4 - VERTICAL_SPACING * 5 - 5;
|
||||
int bufferWidth = 200;
|
||||
int desiredHeight = (this.textRenderer.fontHeight + 2) * lineCount + 6;
|
||||
|
||||
var bufferDisplay = new SpruceTextAreaWidget(
|
||||
Position.of(bufferX, bufferY),
|
||||
bufferWidth,
|
||||
desiredHeight,
|
||||
Text.literal("Buffer Display")
|
||||
);
|
||||
bufferDisplay.setText(this.buffer.toString());
|
||||
bufferDisplay.setEditable(false);
|
||||
bufferDisplay.setUneditableColor(0xFFFFFFFF);
|
||||
bufferDisplay.setDisplayedLines(lineCount);
|
||||
bufferDisplay.setCursorToEnd();
|
||||
|
||||
return bufferDisplay;
|
||||
}
|
||||
|
||||
private int calculateKeyboardHeight(List<List<String>> keyRows) {
|
||||
return keyRows.size() * (KEY_HEIGHT + VERTICAL_SPACING) +
|
||||
(KEY_HEIGHT + VERTICAL_SPACING) + // space for bottom row
|
||||
CONTAINER_PADDING * 2; // top and bottom padding
|
||||
}
|
||||
|
||||
private void addLayoutRows(SpruceContainerWidget container, List<List<String>> keyLayoutRows) {
|
||||
int currentY = CONTAINER_PADDING;
|
||||
|
||||
for (List<String> row : keyLayoutRows) {
|
||||
int rowWidth = calculateRowWidth(row);
|
||||
// center row
|
||||
int currentX = (container.getWidth() - rowWidth) / 2;
|
||||
|
||||
for (String key : row) {
|
||||
String displayText = (this.capsMode && !this.symbolMode) ? key.toUpperCase() : key;
|
||||
container.addChild(
|
||||
new SpruceButtonWidget(
|
||||
Position.of(currentX, currentY),
|
||||
STANDARD_KEY_WIDTH,
|
||||
KEY_HEIGHT,
|
||||
Text.literal(displayText),
|
||||
btn -> handleKeyPress(displayText)
|
||||
)
|
||||
);
|
||||
|
||||
currentX += STANDARD_KEY_WIDTH + HORIZONTAL_SPACING;
|
||||
}
|
||||
|
||||
currentY += KEY_HEIGHT + VERTICAL_SPACING;
|
||||
}
|
||||
}
|
||||
|
||||
private int calculateRowWidth(List<String> row) {
|
||||
int rowWidth = 0;
|
||||
for (int i = 0; i < row.size(); i++) {
|
||||
rowWidth += STANDARD_KEY_WIDTH;
|
||||
// padding
|
||||
if (i < row.size() - 1) {
|
||||
rowWidth += HORIZONTAL_SPACING;
|
||||
}
|
||||
}
|
||||
return rowWidth;
|
||||
}
|
||||
|
||||
private void addFunctionKeys(SpruceContainerWidget container) {
|
||||
List<String> firstRow = getActiveKeyLayout().getFirst();
|
||||
int firstRowWidth = calculateRowWidth(firstRow);
|
||||
|
||||
// position backspace at the right of the first row
|
||||
int backspaceWidth = (int) (STANDARD_KEY_WIDTH * 1.5);
|
||||
int backspaceX = (container.getWidth() + firstRowWidth) / 2 + HORIZONTAL_SPACING;
|
||||
|
||||
container.addChild(
|
||||
new SpruceButtonWidget(
|
||||
Position.of(backspaceX, CONTAINER_PADDING),
|
||||
backspaceWidth,
|
||||
KEY_HEIGHT,
|
||||
Text.literal("←"),
|
||||
btn -> handleKeyPress(BACKSPACE_SYMBOL)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
if (this.newLineSupport) {
|
||||
// position newline at the right of the second row
|
||||
List<String> secondRow = getActiveKeyLayout().get(1);
|
||||
int newlineWidth = (int) (STANDARD_KEY_WIDTH * 1.5);
|
||||
int secondRowWidth = calculateRowWidth(secondRow);
|
||||
int newlineX = (container.getWidth() + secondRowWidth) / 2 + HORIZONTAL_SPACING;
|
||||
int newlineY = CONTAINER_PADDING + (KEY_HEIGHT + VERTICAL_SPACING);
|
||||
|
||||
container.addChild(
|
||||
new SpruceButtonWidget(
|
||||
Position.of(newlineX, newlineY),
|
||||
newlineWidth,
|
||||
KEY_HEIGHT,
|
||||
Text.literal("⏎"),
|
||||
btn -> handleKeyPress(NEWLINE_SYMBOL)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private void addBottomRow(SpruceContainerWidget container) {
|
||||
// calculate positions for bottom row
|
||||
int rowY = CONTAINER_PADDING + getActiveKeyLayout().size() * (KEY_HEIGHT + VERTICAL_SPACING);
|
||||
|
||||
// space bar - wide key in the middle
|
||||
double spaceWidthFactor = 5.0;
|
||||
int spaceKeyWidth = (int) (STANDARD_KEY_WIDTH * spaceWidthFactor);
|
||||
int spaceX = (container.getWidth() - spaceKeyWidth) / 2;
|
||||
|
||||
container.addChild(
|
||||
new SpruceButtonWidget(
|
||||
Position.of(spaceX, rowY),
|
||||
spaceKeyWidth,
|
||||
KEY_HEIGHT,
|
||||
Text.translatable("midnightcontrols.virtual_keyboard.keyboard.space"),
|
||||
btn -> handleKeyPress(SPACE_SYMBOL)
|
||||
)
|
||||
);
|
||||
|
||||
// caps key - left of space
|
||||
if (!this.symbolMode) {
|
||||
int capsX = spaceX - SPECIAL_KEY_WIDTH - HORIZONTAL_SPACING * 2;
|
||||
var capsModeButton = new SpruceButtonWidget(
|
||||
Position.of(capsX, rowY),
|
||||
SPECIAL_KEY_WIDTH,
|
||||
KEY_HEIGHT,
|
||||
Text.literal(this.capsMode ? "caps" : "CAPS"),
|
||||
btn -> toggleCapsMode());
|
||||
|
||||
container.addChild(capsModeButton);
|
||||
}
|
||||
|
||||
// symbols key - right of space
|
||||
int symbolsX = spaceX + spaceKeyWidth + HORIZONTAL_SPACING * 2;
|
||||
var symbolModeButton = new SpruceButtonWidget(
|
||||
Position.of(symbolsX, rowY),
|
||||
SPECIAL_KEY_WIDTH,
|
||||
KEY_HEIGHT,
|
||||
Text.literal(this.symbolMode ? "ABC" : "123?!"),
|
||||
btn -> toggleSymbolMode()
|
||||
);
|
||||
container.addChild(symbolModeButton);
|
||||
}
|
||||
|
||||
private void handleKeyPress(String key) {
|
||||
if (key.equals(BACKSPACE_SYMBOL)) {
|
||||
if (!this.buffer.isEmpty()) {
|
||||
this.buffer.deleteCharAt(buffer.length() - 1);
|
||||
}
|
||||
} else {
|
||||
this.buffer.append(key);
|
||||
}
|
||||
|
||||
if (this.bufferDisplayArea != null) {
|
||||
this.bufferDisplayArea.setText(this.buffer.toString());
|
||||
this.bufferDisplayArea.setCursorToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
private List<List<String>> getActiveKeyLayout() {
|
||||
return this.symbolMode ? this.layout.getSymbols() : this.layout.getLetters();
|
||||
}
|
||||
|
||||
private void toggleCapsMode() {
|
||||
this.capsMode = !this.capsMode;
|
||||
rebuildKeyboard();
|
||||
}
|
||||
|
||||
private void toggleSymbolMode() {
|
||||
this.symbolMode = !this.symbolMode;
|
||||
rebuildKeyboard();
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"id": "de_DE:qwertz",
|
||||
|
||||
"letters": {
|
||||
"row0": ["q", "w", "e", "r", "t", "z", "u", "i", "o", "p", "ü"],
|
||||
"row1": ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ö", "ä"],
|
||||
"row2": ["y", "x", "c", "v", "b", "n", "m", "ß"]
|
||||
},
|
||||
"symbols": {
|
||||
"row0": ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
|
||||
"row1": ["@", "#", "$", "%", "&", "*", "-", "+", "(", ")"],
|
||||
"row2": ["!", "\"", "'", ":", ";", ",", ".", "?", "/"]
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"id": "en_US:qwerty",
|
||||
|
||||
"letters": {
|
||||
"row0": ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"],
|
||||
"row1": ["a", "s", "d", "f", "g", "h", "j", "k", "l"],
|
||||
"row2": ["z", "x", "c", "v", "b", "n", "m"]
|
||||
},
|
||||
"symbols": {
|
||||
"row0": ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
|
||||
"row1": ["@", "#", "$", "%", "&", "*", "-", "+", "(", ")"],
|
||||
"row2": ["!", "\"", "'", ":", ";", ",", ".", "?", "/"]
|
||||
}
|
||||
}
|
||||
@@ -1,239 +0,0 @@
|
||||
{
|
||||
"midnightcontrols.midnightconfig.title": "Pokročilá konfigurace MidnightControls",
|
||||
"midnightcontrols.midnightconfig.enum.VirtualMouseSkin.DEFAULT_LIGHT": "Výchozí světlá",
|
||||
"midnightcontrols.midnightconfig.enum.VirtualMouseSkin.DEFAULT_DARK": "Výchozí tmavá",
|
||||
"midnightcontrols.midnightconfig.enum.VirtualMouseSkin.SECOND_LIGHT": "Druhá světlá",
|
||||
"midnightcontrols.midnightconfig.enum.VirtualMouseSkin.SECOND_DARK": "Druhá tmavá",
|
||||
"midnightcontrols.midnightconfig.enum.ControllerType.DEFAULT": "Výchozí",
|
||||
"midnightcontrols.midnightconfig.enum.ControllerType.DUALSHOCK": "DualShock",
|
||||
"midnightcontrols.midnightconfig.enum.ControllerType.DUALSENSE": "DualSense",
|
||||
"midnightcontrols.midnightconfig.enum.ControllerType.SWITCH": "Switch/Wii ovladač",
|
||||
"midnightcontrols.midnightconfig.enum.ControllerType.XBOX": "Xbox One/Series ovladač",
|
||||
"midnightcontrols.midnightconfig.enum.ControllerType.XBOX_360": "Xbox 360 Controller",
|
||||
"midnightcontrols.midnightconfig.enum.ControllerType.STEAM_CONTROLLER": "Steam Controller",
|
||||
"midnightcontrols.midnightconfig.enum.ControllerType.STEAM_DECK": "Steam Deck",
|
||||
"midnightcontrols.midnightconfig.enum.ControllerType.OUYA": "OUYA ovladač",
|
||||
"midnightcontrols.midnightconfig.enum.ControllerType.NUMBERED": "Ovladač s číslicemi",
|
||||
"midnightcontrols.midnightconfig.enum.ControlsMode.DEFAULT": "Klávesnice/Myš",
|
||||
"midnightcontrols.midnightconfig.enum.ControlsMode.CONTROLLER": "Ovladač",
|
||||
"midnightcontrols.midnightconfig.enum.ControlsMode.TOUCHSCREEN": "Dotyk (Beta)",
|
||||
"midnightcontrols.midnightconfig.enum.HudSide.LEFT": "Levá",
|
||||
"midnightcontrols.midnightconfig.enum.HudSide.RIGHT": "Pravá",
|
||||
"midnightcontrols.midnightconfig.enum.TouchMode.CROSSHAIR": "Crosshair režim",
|
||||
"midnightcontrols.midnightconfig.enum.TouchMode.FINGER_POS": "Pozice prstu",
|
||||
"midnightcontrols.midnightconfig.enum.CameraMode.FLAT": "Plochá",
|
||||
"midnightcontrols.midnightconfig.enum.CameraMode.ADAPTIVE": "Adaptivní",
|
||||
"key.categories.midnightcontrols": "MidnightControls",
|
||||
"key.midnightcontrols.look_down": "Podívat se dolů",
|
||||
"key.midnightcontrols.look_left": "Podívat se doleva",
|
||||
"key.midnightcontrols.look_right": "Podívat se doprava",
|
||||
"key.midnightcontrols.look_up": "Podívat se nahoru",
|
||||
"key.midnightcontrols.ring": "Otevřít ovládací kroužek",
|
||||
"midnightcontrols.action.attack": "Útok",
|
||||
"midnightcontrols.action.back": "Zpět",
|
||||
"midnightcontrols.action.chat": "Otevřít chat",
|
||||
"midnightcontrols.action.controls_ring": "Otevřít ovládací kroužek",
|
||||
"midnightcontrols.action.debug_screen": "Otevřít debugovací HUD (F3)",
|
||||
"midnightcontrols.action.drop_item": "Odhodit věc",
|
||||
"midnightcontrols.action.drink": "Napít se",
|
||||
"midnightcontrols.action.eat": "Najíst se",
|
||||
"midnightcontrols.action.equip": "Vybavit se",
|
||||
"midnightcontrols.action.exit": "Ukončit",
|
||||
"midnightcontrols.action.forward": "Dopředu",
|
||||
"midnightcontrols.action.hit": "Útok",
|
||||
"midnightcontrols.action.hotbar_left": "Hotbar doleva",
|
||||
"midnightcontrols.action.hotbar_right": "Hotbar doprava",
|
||||
"midnightcontrols.action.inventory": "Inventář",
|
||||
"midnightcontrols.action.jump": "Skok",
|
||||
"midnightcontrols.action.left": "Doleva",
|
||||
"midnightcontrols.action.pause_game": "Pozastavit hru",
|
||||
"midnightcontrols.action.pick_block": "Vybrat blok",
|
||||
"midnightcontrols.action.pickup": "Vzít",
|
||||
"midnightcontrols.action.pickup_all": "Vzít vše",
|
||||
"midnightcontrols.action.place": "Položit",
|
||||
"midnightcontrols.action.player_list": "Seznam hráčů",
|
||||
"midnightcontrols.action.quick_move": "Rychlý přesun",
|
||||
"midnightcontrols.action.right": "Doprava",
|
||||
"midnightcontrols.action.screenshot": "Vyfotit snímek obrazovky",
|
||||
"midnightcontrols.action.slot_up": "Přesunout slot nahoru",
|
||||
"midnightcontrols.action.slot_down": "Přesunout slot dolů",
|
||||
"midnightcontrols.action.slot_left": "Přesunout slot doleva",
|
||||
"midnightcontrols.action.slot_right": "Přesunout slot doprava",
|
||||
"midnightcontrols.action.sneak": "Plížit se",
|
||||
"midnightcontrols.action.sprint": "Sprintovat",
|
||||
"midnightcontrols.action.swap_hands": "Vyměnit si ruce",
|
||||
"midnightcontrols.action.toggle_perspective": "Změnit perspektivu",
|
||||
"midnightcontrols.action.toggle_smooth_camera": "Nastavit kinematografickou kameru",
|
||||
"midnightcontrols.action.page_back": "Předchozí stránka",
|
||||
"midnightcontrols.action.page_next": "Následující stránka",
|
||||
"midnightcontrols.action.tab_back": "Předchozí karta",
|
||||
"midnightcontrols.action.tab_next": "Následující karta",
|
||||
"midnightcontrols.action.take": "Vzít věc",
|
||||
"midnightcontrols.action.take_all": "Vzít stack",
|
||||
"midnightcontrols.action.use": "Použít",
|
||||
"midnightcontrols.action.zoom": "Přiblížit",
|
||||
"midnightcontrols.action.zoom_in": "Zvýšit přiblížení",
|
||||
"midnightcontrols.action.zoom_out": "Snížit příblížení",
|
||||
"midnightcontrols.action.zoom_reset": "Resetovat Přiblížení",
|
||||
"midnightcontrols.action.emi_page_left": "Předchozí stránka",
|
||||
"midnightcontrols.action.emi_page_right": "Následující stránka",
|
||||
"midnightcontrols.category.emi": "EMI",
|
||||
"midnightcontrols.button.a": "A",
|
||||
"midnightcontrols.button.b": "B",
|
||||
"midnightcontrols.button.x": "X",
|
||||
"midnightcontrols.button.y": "Y",
|
||||
"midnightcontrols.button.left_bumper": "Levý bumper",
|
||||
"midnightcontrols.button.right_bumper": "Pravý bumper",
|
||||
"midnightcontrols.button.back": "Zpět",
|
||||
"midnightcontrols.button.start": "Start",
|
||||
"midnightcontrols.button.guide": "Guide",
|
||||
"midnightcontrols.button.left_thumb": "Levá páčka",
|
||||
"midnightcontrols.button.right_thumb": "Pravá páčka",
|
||||
"midnightcontrols.button.dpad_up": "DPAD nahoru",
|
||||
"midnightcontrols.button.dpad_right": "DPAD doprava",
|
||||
"midnightcontrols.button.dpad_down": "DPAD dolů",
|
||||
"midnightcontrols.button.dpad_left": "DPAD doleva",
|
||||
"midnightcontrols.button.l4": "L4",
|
||||
"midnightcontrols.button.l5": "L5",
|
||||
"midnightcontrols.button.r4": "R4",
|
||||
"midnightcontrols.button.r5": "L5",
|
||||
"midnightcontrols.axis.left_x+": "Levý X+",
|
||||
"midnightcontrols.axis.left_y+": "Levý Y+",
|
||||
"midnightcontrols.axis.right_x+": "Pravý X+",
|
||||
"midnightcontrols.axis.right_y+": "Pravý Y+",
|
||||
"midnightcontrols.axis.left_trigger": "Levý trigger",
|
||||
"midnightcontrols.axis.right_trigger": "Pravý trigger",
|
||||
"midnightcontrols.axis.left_x-": "Levý X-",
|
||||
"midnightcontrols.axis.left_y-": "Levý Y-",
|
||||
"midnightcontrols.axis.right_x-": "Pravý X-",
|
||||
"midnightcontrols.axis.right_y-": "Pravý Y-",
|
||||
"midnightcontrols.button.unknown": "Neznámý (%d)",
|
||||
"midnightcontrols.controller.tutorial.title": "Hrajte hru s ovladačem!",
|
||||
"midnightcontrols.controller.tutorial.description": "jděte do %s -> %s -> %s",
|
||||
"midnightcontrols.controller.connected": "Ovladač %d připojen.",
|
||||
"midnightcontrols.controller.disconnected": "Ovladač %d odpojen.",
|
||||
"midnightcontrols.controller.mappings.1": "Chcete-li nakonfigurovat mapování ovladače, použijte %s",
|
||||
"midnightcontrols.controller.mappings.3": "a vložte mapování do editoru souboru mapování.",
|
||||
"midnightcontrols.controller.mappings.error": "Chyba při načítání mapování.",
|
||||
"midnightcontrols.controller.mappings.error.write": "Chyba při zápisu mapování do souboru.",
|
||||
"midnightcontrols.controller.mappings.updated": "Aktualizované mapování!",
|
||||
"midnightcontrols.controller_type.default": "Výchozí",
|
||||
"midnightcontrols.controller_type.dualshock": "DualShock",
|
||||
"midnightcontrols.controller_type.dualsense": "DualSense",
|
||||
"midnightcontrols.controller_type.switch": "Switch/Wii ovladač",
|
||||
"midnightcontrols.controller_type.xbox": "Xbox One/Series ovladač",
|
||||
"midnightcontrols.controller_type.xbox_360": "Xbox 360 ovladač",
|
||||
"midnightcontrols.controller_type.steam_controller": "Steam ovladač",
|
||||
"midnightcontrols.controller_type.steam_deck": "Steam Deck",
|
||||
"midnightcontrols.controller_type.ouya": "OUYA ovladač",
|
||||
"midnightcontrols.controller_type.numbered": "Ovladač s číslicemi",
|
||||
"midnightcontrols.controls_mode.default": "Klávesnice/Myš",
|
||||
"midnightcontrols.controls_mode.controller": "Ovladač",
|
||||
"midnightcontrols.controls_mode.touchscreen": "Dotyk (Beta)",
|
||||
"midnightcontrols.hud_side.LEFT": "Levý",
|
||||
"midnightcontrols.hud_side.RIGHT": "Pravý",
|
||||
"midnightcontrols.menu.analog_movement": "Analogový pohyb",
|
||||
"midnightcontrols.menu.analog_movement.tooltip": "Pokud je to možné, umožňuje analogový pohyb.",
|
||||
"midnightcontrols.menu.auto_switch_mode": "Režim automatického přepínání",
|
||||
"midnightcontrols.menu.auto_switch_mode.tooltip": "Zda se má režim ovládání automaticky přepnout na ovladač, pokud je připojen.",
|
||||
"midnightcontrols.menu.camera_mode": "Režim kamery",
|
||||
"midnightcontrols.menu.controller": "Ovladač",
|
||||
"midnightcontrols.menu.controller2": "Druhý ovladač",
|
||||
"midnightcontrols.menu.controller2.tooltip": "Použije druhý ovladač, který umožňuje (například) podporu Joy-Conů.",
|
||||
"midnightcontrols.menu.controller_toggle_sneak": "Přepnutí plížení na ovladači",
|
||||
"midnightcontrols.menu.controller_toggle_sprint": "Přepnutí sprintování na ovladačí",
|
||||
"midnightcontrols.menu.controller_type": "Typ ovladače",
|
||||
"midnightcontrols.menu.controller_type.tooltip": "Typ používaného ovladače (potřebné pro zobrazení správných tlačítek).",
|
||||
"midnightcontrols.menu.controls_mode": "Režim",
|
||||
"midnightcontrols.menu.controls_mode.tooltip": "Režim ovládání.",
|
||||
"midnightcontrols.menu.copy_controller_guid": "Zkopírovat GUID",
|
||||
"midnightcontrols.menu.current_controller_guid": "GUID aktuálního ovladače: %s",
|
||||
"midnightcontrols.menu.double_tap_to_sprint": "Dvojité klepnutí na sprintování",
|
||||
"midnightcontrols.menu.double_tap_to_sprint.tooltip": "Přepíná, zda klávesa chůze vpřed při dvojitém rychlém poklepání umožní hráči sprintovat.",
|
||||
"midnightcontrols.menu.fast_block_placing": "Rychlé pokládání bloků",
|
||||
"midnightcontrols.menu.fast_block_placing.tooltip": "Při letu v kreativním režimu umožňuje rychlé pokládání bloků v závislosti na vaší rychlosti. §cNa některých serverech to může být považováno za podvádění§r.",
|
||||
"midnightcontrols.menu.fly_drifting": "Fly Drifting",
|
||||
"midnightcontrols.menu.fly_drifting.tooltip": "Za letu umožňuje Vanilla driftování/setrvačnost.",
|
||||
"midnightcontrols.menu.fly_drifting_vertical": "Vertikální Fly Drifting",
|
||||
"midnightcontrols.menu.fly_drifting_vertical.tooltip": "Za letu umožňuje Vanilla vertikální driftování/setrvačnost.",
|
||||
"midnightcontrols.menu.hud_enable": "Zapnout HUD",
|
||||
"midnightcontrols.menu.hud_enable.tooltip": "Přepíná indikátor tlačítek ovladače na obrazovce.",
|
||||
"midnightcontrols.menu.hud_side": "Strana HUD",
|
||||
"midnightcontrols.menu.hud_side.tooltip": "Pozice HUD.",
|
||||
"midnightcontrols.menu.invert_right_x_axis": "Invertovat pravý X",
|
||||
"midnightcontrols.menu.invert_right_y_axis": "Invertovat pravý Y",
|
||||
"midnightcontrols.menu.joystick_as_mouse": "Vždy použít levou páčku jako myš",
|
||||
"midnightcontrols.menu.joystick_as_mouse.tooltip": "V každém menu se páčka chová jako myš.",
|
||||
"midnightcontrols.menu.eye_tracker_as_mouse": "Použití eye trackeru jako myši"
|
||||
"midnightcontrols.menu.eye_tracker_as_mouse.tooltip": "Nahraďte myš zařízením pro sledování očí (například Tobii 5).",
|
||||
"midnightcontrols.menu.eye_tracker_deadzone": "Velikost mrtvé zóny eye trackeru",
|
||||
"midnightcontrols.menu.eye_tracker_deadzone.tooltip": "Zastaví pohyb kamery při pohledu do blízkosti crosshair",
|
||||
"midnightcontrols.menu.keyboard_controls": "Ovládání klávesnice...",
|
||||
"midnightcontrols.menu.left_dead_zone": "Mrtvá zóna levé páčky",
|
||||
"midnightcontrols.menu.left_dead_zone.tooltip": "Mrtvá zóna levé analogové páčky ovladače.",
|
||||
"midnightcontrols.menu.mappings.open_input_str": "Otevřít editor souborů mapování",
|
||||
"midnightcontrols.menu.max_left_x_value": "Maximální hodnota levé osy X",
|
||||
"midnightcontrols.menu.max_left_x_value.tooltip": "Změní hodnotu, kterou mod považuje za nejvyšší pro levou osu X. Užitečné, pokud osa nevyužívá celý rozsah a zdá se pomalá.",
|
||||
"midnightcontrols.menu.max_left_y_value": "Maximální hodnota levé osy Y",
|
||||
"midnightcontrols.menu.max_left_y_value.tooltip": "Změní hodnotu, kterou mod považuje za nejvyšší pro levou osu Y. Užitečné, pokud osa nevyužívá celý rozsah a zdá se pomalá.",
|
||||
"midnightcontrols.menu.max_right_x_value": "Maximální hodnota pravé osy X",
|
||||
"midnightcontrols.menu.max_right_x_value.tooltip": "Změní hodnotu, kterou mod považuje za nejvyšší pro pravou osu X. Užitečné, pokud osa nevyužívá celý rozsah a zdá se pomalá.",
|
||||
"midnightcontrols.menu.max_right_y_value": "Maximální hodnota pravé osy Y",
|
||||
"midnightcontrols.menu.max_right_y_value.tooltip": "Změní hodnotu, kterou mod považuje za nejvyšší pro pravou osu Y. Užitečné, pokud osa nevyužívá celý rozsah a zdá se pomalá.",
|
||||
"midnightcontrols.menu.mouse_speed": "Rychlost myši",
|
||||
"midnightcontrols.menu.mouse_speed.tooltip": "Rychlost emulované myši ovladače.",
|
||||
"midnightcontrols.menu.move_chat": "Přesunutí vstupního pole chatu nahoru",
|
||||
"midnightcontrols.menu.move_chat.tooltip": "Přesune pole pro zadávání chatu nahoru, aby se lépe zadávalo na zařízeních s klávesnicí na obrazovce.",
|
||||
"midnightcontrols.menu.multiple_mapping_tip": "(Tip: Můžete také vložit více mapování najednou.)",
|
||||
"midnightcontrols.menu.reacharound.horizontal": "Pokládání předního bloku",
|
||||
"midnightcontrols.menu.reacharound.horizontal.tooltip": "Umožňuje umístění předního bloku, §ccož může být na některých serverech považováno za podvod.§r",
|
||||
"midnightcontrols.menu.reacharound.vertical": "Vertikální dosah",
|
||||
"midnightcontrols.menu.reacharound.vertical.tooltip": "Zapiná vertikální dosah, §ccož může být na některých serverech považováno za podvod.§r",
|
||||
"midnightcontrols.menu.reload_controller_mappings": "Opětovné načíst mapování ovladače",
|
||||
"midnightcontrols.menu.reload_controller_mappings.tooltip": "Znovu načte soubor mapování ovladače.",
|
||||
"midnightcontrols.menu.right_dead_zone": "Mrtvá zóna pravé páčky",
|
||||
"midnightcontrols.menu.right_dead_zone.tooltip": "Mrtvá zóna pravé analogové páčky ovladače.",
|
||||
"midnightcontrols.menu.rotation_speed": "Rychlost otáčení osy X",
|
||||
"midnightcontrols.menu.rotation_speed.tooltip": "Rychlost otáčení osy X v režimu ovladače.",
|
||||
"midnightcontrols.menu.y_axis_rotation_speed": "Rychlost otáčení osy Y",
|
||||
"midnightcontrols.menu.y_axis_rotation_speed.tooltip": "Rychlost otáčení osy Y v režimu ovladače.",
|
||||
"midnightcontrols.menu.separate_controller_profile": "Samostatný profil ovladače",
|
||||
"midnightcontrols.menu.separator.controller": "Ovladač",
|
||||
"midnightcontrols.menu.separator.general": "Obecné",
|
||||
"midnightcontrols.menu.title": "MidnightControls - Nastavení",
|
||||
"midnightcontrols.menu.title.controller": "Nastavení ovladače",
|
||||
"midnightcontrols.menu.title.controller_controls": "Vazby ovladače",
|
||||
"midnightcontrols.menu.title.gameplay": "Herní možnosti",
|
||||
"midnightcontrols.menu.title.general": "Obecné možnosti",
|
||||
"midnightcontrols.menu.title.hud": "Možnosti HUD",
|
||||
"midnightcontrols.menu.title.mappings.string": "Editor souborů mapování",
|
||||
"midnightcontrols.menu.title.touch": "Možnosti dotyku",
|
||||
"midnightcontrols.menu.title.visual": "Možnosti vzhledu",
|
||||
"midnightcontrols.menu.touch_break_delay": "Zpoždění přerušení dotyku",
|
||||
"midnightcontrols.menu.touch_speed": "Rychlost dotyku",
|
||||
"midnightcontrols.menu.invert_touch": "Invertování směru dotyku",
|
||||
"midnightcontrols.menu.touch_mode": "Režim dotykové interakce",
|
||||
"midnightcontrols.menu.touch_transparency": "Průhlednost dotykového HUD",
|
||||
"midnightcontrols.menu.touch_with_controller": "Dotyk v režimu ovladače",
|
||||
"midnightcontrols.menu.unfocused_input": "Nezaostřený vstup",
|
||||
"midnightcontrols.menu.unfocused_input.tooltip": "Umožňuje vstup do ovladače, když okno není zaostřené.",
|
||||
"midnightcontrols.menu.virtual_mouse": "Virtuální myš",
|
||||
"midnightcontrols.menu.virtual_mouse.tooltip": "Povoluje virtuální myš, která je užitečná při rozdělené obrazovce.",
|
||||
"midnightcontrols.menu.virtual_mouse.skin": "Skin virtuální myši",
|
||||
"midnightcontrols.menu.hide_cursor": "Skrytí normálního kurzoru myši",
|
||||
"midnightcontrols.menu.hide_cursor.tooltip": "Skryje normální kurzor myši a ponechá viditelný pouze virtuální kurzor myši.",
|
||||
"midnightcontrols.narrator.unbound": "Zrušení vazby na tlačítko %s",
|
||||
"midnightcontrols.not_bound": "Není vázano",
|
||||
"midnightcontrols.virtual_mouse.skin.default_light": "Výchozí světlá",
|
||||
"midnightcontrols.virtual_mouse.skin.default_dark": "Výchozí tmavá",
|
||||
"midnightcontrols.virtual_mouse.skin.second_light": "Druhá světlá",
|
||||
"midnightcontrols.virtual_mouse.skin.second_dark": "Druhá tmavá",
|
||||
"midnightcontrols.midnightconfig.category.controller": "Ovladač",
|
||||
"midnightcontrols.midnightconfig.category.misc": "Různé",
|
||||
"midnightcontrols.midnightconfig.category.screens": "Obrazovky",
|
||||
"midnightcontrols.midnightconfig.category.gameplay": "Hra",
|
||||
"midnightcontrols.midnightconfig.category.touch": "Dotyk",
|
||||
"midnightcontrols.midnightconfig.category.visual": "Vizuál",
|
||||
"modmenu.descriptionTranslation.midnightcontrols": "Přidává podporu ovladačů a celkově vylepšuje ovládání.\nPřevzato z LambdaControls, jehož vývoj byl ukončen."
|
||||
}
|
||||
|
||||
@@ -146,10 +146,6 @@
|
||||
"midnightcontrols.menu.title.visual": "Visuelle Optionen",
|
||||
"midnightcontrols.menu.unfocused_input": "Unfokussierte Eingabe",
|
||||
"midnightcontrols.menu.unfocused_input.tooltip": "Erlaube Controllereingabe auch wenn das Fenster nicht fokussiert ist.",
|
||||
"midnightcontrols.virtual_keyboard.screen": "Virtuelle Tastatur",
|
||||
"midnightcontrols.virtual_keyboard.keyboard.space": "Leertaste",
|
||||
"midnightcontrols.virtual_keyboard.layout.en_US.qwerty": "Englisch (Qwerty)",
|
||||
"midnightcontrols.virtual_keyboard.layout.de_DE.qwertz": "Deutsch (Qwertz)",
|
||||
"midnightcontrols.menu.virtual_mouse": "Virtuelle Maus",
|
||||
"midnightcontrols.menu.virtual_mouse.tooltip": "Aktiviere die virtuelle Maus.",
|
||||
"midnightcontrols.menu.virtual_mouse.skin": "Aussehen der Virtuellen Maus",
|
||||
|
||||
@@ -217,10 +217,6 @@
|
||||
"midnightcontrols.menu.touch_with_controller": "Touch in Controller mode",
|
||||
"midnightcontrols.menu.unfocused_input": "Unfocused Input",
|
||||
"midnightcontrols.menu.unfocused_input.tooltip": "Allows controller input when the window is not focused.",
|
||||
"midnightcontrols.menu.virtual_keyboard": "Virtual Keyboard",
|
||||
"midnightcontrols.menu.virtual_keyboard.tooltip": "Enables a virtual on-screen keyboard",
|
||||
"midnightcontrols.menu.virtual_keyboard_layout": "Virtual Keyboard Layout",
|
||||
"midnightcontrols.menu.virtual_keyboard_layout.tooltip": "Defines which layout the on-screen keyboard will follow.",
|
||||
"midnightcontrols.menu.virtual_mouse": "Virtual Mouse",
|
||||
"midnightcontrols.menu.virtual_mouse.tooltip": "Enables the virtual mouse, which is useful during splitscreen.",
|
||||
"midnightcontrols.menu.virtual_mouse.skin": "Virtual Mouse Skin",
|
||||
@@ -228,10 +224,6 @@
|
||||
"midnightcontrols.menu.hide_cursor.tooltip": "Hides the normal mouse cursor, leaving only the virtual mouse visible.",
|
||||
"midnightcontrols.narrator.unbound": "Unbound %s",
|
||||
"midnightcontrols.not_bound": "Not bound",
|
||||
"midnightcontrols.virtual_keyboard.screen": "Virtual Keyboard",
|
||||
"midnightcontrols.virtual_keyboard.keyboard.space": "Space",
|
||||
"midnightcontrols.virtual_keyboard.layout.en_US.qwerty": "English (Qwerty)",
|
||||
"midnightcontrols.virtual_keyboard.layout.de_DE.qwertz": "German (Qwertz)",
|
||||
"midnightcontrols.virtual_mouse.skin.default_light": "Default Light",
|
||||
"midnightcontrols.virtual_mouse.skin.default_dark": "Default Dark",
|
||||
"midnightcontrols.virtual_mouse.skin.second_light": "Second Light",
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
accessWidener v1 named
|
||||
|
||||
accessible class net/minecraft/client/gui/DrawContext$ScissorStack
|
||||
#accessible class net/minecraft/client/gui/widget/EntryListWidget$MoveDirection
|
||||
@@ -3,32 +3,25 @@
|
||||
"package": "eu.midnightdust.midnightcontrols.client.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"client": [
|
||||
"AbstractBlockAccessor",
|
||||
"AbstractSignEditScreenMixin",
|
||||
"AdvancementsScreenAccessor",
|
||||
"BookEditScreenAccessor",
|
||||
"BookSigningScreenAccessor",
|
||||
"ChatScreenMixin",
|
||||
"ClickableWidgetAccessor",
|
||||
"AdvancementsScreenAccessor",
|
||||
"ClientPlayerEntityMixin",
|
||||
"CreativeInventoryScreenAccessor",
|
||||
"DrawContextAccessor",
|
||||
"GameOptionsScreenMixin",
|
||||
"CreativeInventoryScreenAccessor",
|
||||
"GameRendererMixin",
|
||||
"HandledScreenMixin",
|
||||
"InputAccessor",
|
||||
"InputUtilMixin",
|
||||
"KeyBindingIDAccessor",
|
||||
"KeyBindingMixin",
|
||||
"KeyboardMixin",
|
||||
"InputUtilMixin",
|
||||
"MinecraftClientMixin",
|
||||
"MouseAccessor",
|
||||
"MouseMixin",
|
||||
"RecipeBookScreenAccessor",
|
||||
"MouseAccessor",
|
||||
"ChatScreenMixin",
|
||||
"RecipeBookWidgetAccessor",
|
||||
"ScreenMixin",
|
||||
"WorldRendererMixin",
|
||||
"KeyBindingIDAccessor",
|
||||
"TabNavigationWidgetAccessor",
|
||||
"WorldRendererMixin"
|
||||
"ScreenMixin",
|
||||
"KeyboardMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
||||
@@ -24,9 +24,9 @@ dependencies {
|
||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
|
||||
modImplementation include ("maven.modrinth:midnightlib:${rootProject.midnightlib_version}-fabric")
|
||||
modImplementation include ("maven.modrinth:obsidianui:${rootProject.obsidianui_version}-fabric")
|
||||
modImplementation include ("maven.modrinth:obsidianui:${rootProject.obsidianui_version}-fabric") {}
|
||||
include 'org.aperlambda:lambdajcommon:1.8.1'
|
||||
modCompileOnly "maven.modrinth:emi:${project.emi_version}"
|
||||
modImplementation "maven.modrinth:emi:${project.emi_version}"
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
|
||||
@@ -92,8 +92,7 @@ unifiedPublishing {
|
||||
curseforge {
|
||||
token = CURSEFORGE_TOKEN
|
||||
id = rootProject.curseforge_id
|
||||
gameVersions.addAll "Java 21", project.minecraft_version
|
||||
if (project.supported_versions != "") gameVersions.addAll project.supported_versions
|
||||
gameVersions.addAll "Java 21", project.minecraft_version, project.supported_versions
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,8 +102,7 @@ unifiedPublishing {
|
||||
token = MODRINTH_TOKEN
|
||||
id = rootProject.modrinth_id
|
||||
version = "$project.version-$project.name"
|
||||
gameVersions.addAll project.minecraft_version
|
||||
if (project.supported_versions != "") gameVersions.addAll project.supported_versions
|
||||
gameVersions.addAll project.minecraft_version, project.supported_versions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ package eu.midnightdust.midnightcontrols.fabric;
|
||||
import eu.midnightdust.midnightcontrols.MidnightControlsConstants;
|
||||
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
|
||||
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
|
||||
import eu.midnightdust.midnightcontrols.client.MidnightControlsReloadListener;
|
||||
import eu.midnightdust.midnightcontrols.fabric.event.MouseClickListener;
|
||||
import eu.midnightdust.midnightcontrols.packet.ControlsModePayload;
|
||||
import eu.midnightdust.midnightcontrols.packet.FeaturePayload;
|
||||
import eu.midnightdust.midnightcontrols.packet.HelloPayload;
|
||||
@@ -13,16 +11,11 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
|
||||
import net.fabricmc.fabric.api.client.screen.v1.ScreenMouseEvents;
|
||||
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
||||
import net.fabricmc.fabric.api.resource.ResourcePackActivationType;
|
||||
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
import net.minecraft.resource.ResourceType;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.thinkingstudio.obsidianui.fabric.event.OpenScreenCallback;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -58,25 +51,11 @@ public class MidnightControlsClientFabric implements ClientModInitializer {
|
||||
ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> MidnightControlsClient.onLeave());
|
||||
|
||||
ClientTickEvents.START_CLIENT_TICK.register(MidnightControlsClient::onTick);
|
||||
ScreenEvents.AFTER_INIT.register((client, screen, scaledWidth, scaledHeight) -> {
|
||||
ScreenMouseEvents.allowMouseClick(screen).register(new MouseClickListener(screen));
|
||||
});
|
||||
|
||||
FabricLoader.getInstance().getModContainer(MidnightControlsConstants.NAMESPACE).ifPresent(modContainer -> {
|
||||
ResourceManagerHelper.registerBuiltinResourcePack(id("bedrock"), modContainer, ResourcePackActivationType.NORMAL);
|
||||
ResourceManagerHelper.registerBuiltinResourcePack(id("legacy"), modContainer, ResourcePackActivationType.NORMAL);
|
||||
});
|
||||
MidnightControlsClient.initClient();
|
||||
|
||||
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(new SimpleSynchronousResourceReloadListener() {
|
||||
@Override
|
||||
public Identifier getFabricId() {
|
||||
return id("keyboard_layouts");
|
||||
}
|
||||
@Override
|
||||
public void reload(ResourceManager manager) {
|
||||
MidnightControlsReloadListener.INSTANCE.reload(manager);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package eu.midnightdust.midnightcontrols.fabric.event;
|
||||
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
|
||||
import net.fabricmc.fabric.api.client.screen.v1.ScreenMouseEvents;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
||||
import static eu.midnightdust.midnightcontrols.client.MidnightControlsClient.clickInterceptor;
|
||||
|
||||
public class MouseClickListener implements ScreenMouseEvents.AllowMouseClick {
|
||||
private final Screen screen;
|
||||
|
||||
public MouseClickListener(Screen screen) {
|
||||
this.screen = screen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowMouseClick(Screen screen, double mouseX, double mouseY, int button) {
|
||||
if(MidnightControlsConfig.virtualKeyboard) {
|
||||
clickInterceptor.intercept(screen, mouseX, mouseY);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Add equals and hashCode to prevent duplicate registrations
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof MouseClickListener) {
|
||||
return ((MouseClickListener) obj).screen == this.screen;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return screen.hashCode();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -2,34 +2,34 @@
|
||||
org.gradle.parallel=true
|
||||
org.gradle.jvmargs=-Xmx2048M
|
||||
|
||||
minecraft_version=1.21.6
|
||||
supported_versions=1.21.8
|
||||
yarn_mappings=1.21.6+build.1
|
||||
minecraft_version=1.21
|
||||
supported_versions=1.21.1
|
||||
yarn_mappings=1.21+build.2
|
||||
enabled_platforms=fabric,neoforge
|
||||
|
||||
archives_base_name=midnightcontrols
|
||||
mod_version=1.11.2
|
||||
mod_version=1.10.0.1
|
||||
maven_group=eu.midnightdust
|
||||
release_type=release
|
||||
release_type=beta
|
||||
modrinth_id = bXX9h73M
|
||||
curseforge_id = 621768
|
||||
# Configure the IDs here after creating the projects on the websites
|
||||
|
||||
midnightlib_version=1.7.5+1.21.6
|
||||
midnightlib_version=1.6.3
|
||||
|
||||
fabric_loader_version=0.16.14
|
||||
fabric_api_version=0.127.0+1.21.6
|
||||
fabric_loader_version=0.15.11
|
||||
fabric_api_version=0.100.1+1.21
|
||||
|
||||
neoforge_version=21.6.0-beta
|
||||
neoforge_version=21.0.14-beta
|
||||
yarn_mappings_patch_neoforge_version = 1.21+build.4
|
||||
|
||||
quilt_loader_version=0.19.0-beta.18
|
||||
quilt_fabric_api_version=7.0.1+0.83.0-1.20
|
||||
|
||||
sodium_version=mc1.21-0.6.0-beta.1
|
||||
obsidianui_version=0.2.12+mc1.21.6
|
||||
obsidianui_version=0.2.7+mc1.21
|
||||
modmenu_version=10.0.0-beta.1
|
||||
emotecraft_version=2.5.5+1.21.4-fabric
|
||||
emotecraft_version=2.1.3-SNAPSHOT-build.29-MC1.19-fabric
|
||||
bendylib_version=2.0.+
|
||||
emi_version=1.1.10+1.21+fabric
|
||||
libgui_version=6.0.0+1.19
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
10
gradlew
vendored
10
gradlew
vendored
@@ -15,8 +15,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -57,7 +55,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -86,7 +84,7 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -202,10 +200,10 @@ fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"'
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
186
gradlew.bat
vendored
186
gradlew.bat
vendored
@@ -1,94 +1,92 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
|
||||
@@ -41,7 +41,7 @@ configurations {
|
||||
dependencies {
|
||||
neoForge "net.neoforged:neoforge:$rootProject.neoforge_version"
|
||||
modImplementation include ("maven.modrinth:midnightlib:${rootProject.midnightlib_version}-neoforge")
|
||||
modImplementation include ("maven.modrinth:obsidianui:${rootProject.obsidianui_version}-neoforge")
|
||||
modImplementation include ("maven.modrinth:obsidianui:${rootProject.obsidianui_version}-neoforge") {}
|
||||
shadowBundle('org.aperlambda:lambdajcommon:1.8.1') {
|
||||
exclude group: 'com.google.code.gson'
|
||||
exclude group: 'com.google.guava'
|
||||
@@ -104,8 +104,7 @@ unifiedPublishing {
|
||||
curseforge {
|
||||
token = CURSEFORGE_TOKEN
|
||||
id = rootProject.curseforge_id
|
||||
gameVersions.addAll "Java 21", project.minecraft_version
|
||||
if (project.supported_versions != "") gameVersions.addAll project.supported_versions
|
||||
gameVersions.addAll "Java 21", project.minecraft_version, project.supported_versions
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,8 +114,7 @@ unifiedPublishing {
|
||||
token = MODRINTH_TOKEN
|
||||
id = rootProject.modrinth_id
|
||||
version = "$project.version-$project.name"
|
||||
gameVersions.addAll project.minecraft_version
|
||||
if (project.supported_versions != "") gameVersions.addAll project.supported_versions
|
||||
gameVersions.addAll project.minecraft_version, project.supported_versions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package eu.midnightdust.midnightcontrols.client.util.platform.neoforge;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.network.packet.CustomPayload;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
|
||||
import static eu.midnightdust.midnightcontrols.client.MidnightControlsClient.client;
|
||||
|
||||
@@ -19,12 +19,7 @@ public class NetworkUtilImpl {
|
||||
handler.send(packet);
|
||||
}
|
||||
public static void sendPayloadC2S(CustomPayload payload) {
|
||||
if (handler != null && client.world != null) {
|
||||
try {
|
||||
handler.send(new CustomPayloadC2SPacket(payload));
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
if (handler != null && client.world != null && handler.hasChannel(payload.getId().id()))
|
||||
PacketDistributor.sendToServer(payload);
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,9 @@ package eu.midnightdust.midnightcontrols.neoforge;
|
||||
|
||||
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
|
||||
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
|
||||
import eu.midnightdust.midnightcontrols.client.MidnightControlsReloadListener;
|
||||
import eu.midnightdust.midnightcontrols.client.util.platform.NetworkUtil;
|
||||
import eu.midnightdust.midnightcontrols.packet.ControlsModePayload;
|
||||
import eu.midnightdust.midnightcontrols.packet.HelloPayload;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.resource.DirectoryResourcePack;
|
||||
import net.minecraft.resource.ResourcePackInfo;
|
||||
import net.minecraft.resource.ResourcePackPosition;
|
||||
@@ -20,7 +18,9 @@ import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.client.event.*;
|
||||
import net.neoforged.neoforge.client.event.ClientPlayerNetworkEvent;
|
||||
import net.neoforged.neoforge.client.event.ClientTickEvent;
|
||||
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;
|
||||
import net.neoforged.neoforge.event.AddPackFindersEvent;
|
||||
import net.neoforged.neoforgespi.locating.IModFile;
|
||||
|
||||
@@ -34,8 +34,6 @@ import static eu.midnightdust.midnightcontrols.client.MidnightControlsClient.BIN
|
||||
import static eu.midnightdust.midnightcontrols.client.MidnightControlsClient.BINDING_LOOK_UP;
|
||||
import static eu.midnightdust.midnightcontrols.client.MidnightControlsClient.BINDING_RING;
|
||||
import static eu.midnightdust.midnightcontrols.client.MidnightControlsClient.client;
|
||||
import static eu.midnightdust.midnightcontrols.client.MidnightControlsClient.clickInterceptor;
|
||||
|
||||
|
||||
@Mod(value = NAMESPACE, dist = Dist.CLIENT)
|
||||
public class MidnightControlsClientNeoforge {
|
||||
@@ -73,10 +71,6 @@ public class MidnightControlsClientNeoforge {
|
||||
} catch (NullPointerException e) {e.fillInStackTrace();}
|
||||
}));
|
||||
}
|
||||
@SubscribeEvent
|
||||
public static void onResourceReload(AddClientReloadListenersEvent event) {
|
||||
event.addListener(id("keyboard-layouts"), MidnightControlsReloadListener.INSTANCE);
|
||||
}
|
||||
}
|
||||
|
||||
@EventBusSubscriber(modid = NAMESPACE, bus = EventBusSubscriber.Bus.GAME, value = Dist.CLIENT)
|
||||
@@ -96,15 +90,5 @@ public class MidnightControlsClientNeoforge {
|
||||
public static void startClientTick(ClientTickEvent.Pre event) {
|
||||
MidnightControlsClient.onTick(client);
|
||||
}
|
||||
@SubscribeEvent
|
||||
public static void onMouseButtonPressed(ScreenEvent.MouseButtonPressed.Pre event) {
|
||||
if (MidnightControlsConfig.virtualKeyboard && !event.isCanceled()) {
|
||||
Screen screen = event.getScreen();
|
||||
double mouseX = event.getMouseX();
|
||||
double mouseY = event.getMouseY();
|
||||
|
||||
clickInterceptor.intercept(screen, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user