mirror of
https://github.com/darksaid98/draggable_lists.git
synced 2026-12-03 14:38:46 +00:00
Fixes #18 - Use static cursor flag to prevent the wrong cursor showing
This commit is contained in:
4 files changed
+27
-11
No files matched your search
@@ -0,0 +1,19 @@
|
|||||||
|
package com.mrmelon54.DraggableLists;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
|
public class Cursor {
|
||||||
|
private static boolean isDragging;
|
||||||
|
|
||||||
|
public static void setDragging() {
|
||||||
|
isDragging = true;
|
||||||
|
GLFW.glfwSetCursor(Minecraft.getInstance().getWindow().getWindow(), GLFW.glfwCreateStandardCursor(GLFW.GLFW_VRESIZE_CURSOR));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void reset() {
|
||||||
|
if (!isDragging) return;
|
||||||
|
isDragging = false;
|
||||||
|
GLFW.glfwSetCursor(Minecraft.getInstance().getWindow().getWindow(), GLFW.glfwCreateStandardCursor(GLFW.GLFW_ARROW_CURSOR));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,23 +1,18 @@
|
|||||||
package com.mrmelon54.DraggableLists.mixin;
|
package com.mrmelon54.DraggableLists.mixin;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.Window;
|
import com.mrmelon54.DraggableLists.Cursor;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import org.lwjgl.glfw.GLFW;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
@Mixin(Minecraft.class)
|
@Mixin(Minecraft.class)
|
||||||
public abstract class MinecraftMixin {
|
public abstract class MinecraftMixin {
|
||||||
@Shadow
|
|
||||||
public abstract Window getWindow();
|
|
||||||
|
|
||||||
@Inject(method = "setScreen", at = @At("HEAD"))
|
@Inject(method = "setScreen", at = @At("HEAD"))
|
||||||
private void injectedSetScreen(Screen screen, CallbackInfo ci) {
|
private void injectedSetScreen(Screen screen, CallbackInfo ci) {
|
||||||
// reset cursor when screen changes
|
// reset cursor when screen changes
|
||||||
GLFW.glfwSetCursor(getWindow().getWindow(), GLFW.glfwCreateStandardCursor(GLFW.GLFW_ARROW_CURSOR));
|
Cursor.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-2
@@ -1,5 +1,6 @@
|
|||||||
package com.mrmelon54.DraggableLists.mixin.packs;
|
package com.mrmelon54.DraggableLists.mixin.packs;
|
||||||
|
|
||||||
|
import com.mrmelon54.DraggableLists.Cursor;
|
||||||
import com.mrmelon54.DraggableLists.duck.AbstractPackDuckProvider;
|
import com.mrmelon54.DraggableLists.duck.AbstractPackDuckProvider;
|
||||||
import com.mrmelon54.DraggableLists.duck.ResourcePackEntryDuckProvider;
|
import com.mrmelon54.DraggableLists.duck.ResourcePackEntryDuckProvider;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
@@ -60,7 +61,7 @@ public abstract class TransferableSelectionListMixin extends ObjectSelectionList
|
|||||||
this.setFocused(draggable_lists$draggingObject);
|
this.setFocused(draggable_lists$draggingObject);
|
||||||
duckProvider.draggable_lists$setBeingDragged(true);
|
duckProvider.draggable_lists$setBeingDragged(true);
|
||||||
draggable_lists$softScrollingTimer = 0;
|
draggable_lists$softScrollingTimer = 0;
|
||||||
GLFW.glfwSetCursor(minecraft.getWindow().getWindow(), GLFW.glfwCreateStandardCursor(GLFW.GLFW_VRESIZE_CURSOR));
|
Cursor.setDragging();
|
||||||
super.mouseClicked(mouseX, mouseY, button);
|
super.mouseClicked(mouseX, mouseY, button);
|
||||||
this.setSelected(null);
|
this.setSelected(null);
|
||||||
return true;
|
return true;
|
||||||
@@ -73,7 +74,7 @@ public abstract class TransferableSelectionListMixin extends ObjectSelectionList
|
|||||||
public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
||||||
this.setDragging(false);
|
this.setDragging(false);
|
||||||
if (draggable_lists$draggingObject != null) {
|
if (draggable_lists$draggingObject != null) {
|
||||||
GLFW.glfwSetCursor(minecraft.getWindow().getWindow(), GLFW.glfwCreateStandardCursor(GLFW.GLFW_ARROW_CURSOR));
|
Cursor.reset();
|
||||||
if (draggable_lists$draggingObject instanceof ResourcePackEntryDuckProvider duckProvider)
|
if (draggable_lists$draggingObject instanceof ResourcePackEntryDuckProvider duckProvider)
|
||||||
duckProvider.draggable_lists$setBeingDragged(false);
|
duckProvider.draggable_lists$setBeingDragged(false);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -1,5 +1,6 @@
|
|||||||
package com.mrmelon54.DraggableLists.mixin.server;
|
package com.mrmelon54.DraggableLists.mixin.server;
|
||||||
|
|
||||||
|
import com.mrmelon54.DraggableLists.Cursor;
|
||||||
import com.mrmelon54.DraggableLists.duck.MultiplayerScreenDuckProvider;
|
import com.mrmelon54.DraggableLists.duck.MultiplayerScreenDuckProvider;
|
||||||
import com.mrmelon54.DraggableLists.duck.ServerEntryDuckProvider;
|
import com.mrmelon54.DraggableLists.duck.ServerEntryDuckProvider;
|
||||||
import com.mrmelon54.DraggableLists.duck.ServerListDuckProvider;
|
import com.mrmelon54.DraggableLists.duck.ServerListDuckProvider;
|
||||||
@@ -78,7 +79,7 @@ public abstract class ServerSelectionListMixin extends ObjectSelectionList<Serve
|
|||||||
this.setFocused(draggable_lists$draggingObject);
|
this.setFocused(draggable_lists$draggingObject);
|
||||||
duckProvider.draggable_lists$setBeingDragged(true);
|
duckProvider.draggable_lists$setBeingDragged(true);
|
||||||
draggable_lists$softScrollingTimer = 0;
|
draggable_lists$softScrollingTimer = 0;
|
||||||
GLFW.glfwSetCursor(minecraft.getWindow().getWindow(), GLFW.glfwCreateStandardCursor(GLFW.GLFW_VRESIZE_CURSOR));
|
Cursor.setDragging();
|
||||||
super.mouseClicked(mouseX, mouseY, button);
|
super.mouseClicked(mouseX, mouseY, button);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@@ -92,7 +93,7 @@ public abstract class ServerSelectionListMixin extends ObjectSelectionList<Serve
|
|||||||
public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
||||||
this.setDragging(false);
|
this.setDragging(false);
|
||||||
if (draggable_lists$draggingObject != null) {
|
if (draggable_lists$draggingObject != null) {
|
||||||
GLFW.glfwSetCursor(minecraft.getWindow().getWindow(), GLFW.glfwCreateStandardCursor(GLFW.GLFW_ARROW_CURSOR));
|
Cursor.reset();
|
||||||
if (draggable_lists$draggingObject instanceof ServerEntryDuckProvider duckProvider)
|
if (draggable_lists$draggingObject instanceof ServerEntryDuckProvider duckProvider)
|
||||||
duckProvider.draggable_lists$setBeingDragged(false);
|
duckProvider.draggable_lists$setBeingDragged(false);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user