mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-21 04:32:39 +00:00
New cursor handler
This commit is contained in:
1 parent
a7d1b9cd1f
commit
a4bca99126
6 files changed
+41
-17
No files matched your search
@@ -22,6 +22,7 @@ import noppes.npcs.client.gui.hud.CompassHudComponent;
|
||||
import noppes.npcs.client.gui.hud.EnumHudComponent;
|
||||
import noppes.npcs.client.gui.hud.HudComponent;
|
||||
import noppes.npcs.client.gui.player.inventory.GuiCNPCInventory;
|
||||
import noppes.npcs.client.gui.util.animation.Cursors;
|
||||
import noppes.npcs.client.renderer.RenderNPCInterface;
|
||||
import noppes.npcs.constants.MarkType;
|
||||
import noppes.npcs.controllers.data.MarkData;
|
||||
@@ -86,6 +87,8 @@ public class ClientTickHandler {
|
||||
PacketClient.sendClient(new ScreenSizePacket(mc.displayWidth, mc.displayHeight));
|
||||
}
|
||||
|
||||
Cursors.tick();
|
||||
|
||||
if (mc.theWorld == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package noppes.npcs.client.gui.util.animation;
|
||||
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||
import noppes.npcs.client.gui.util.GuiUtil;
|
||||
import noppes.npcs.client.gui.util.animation.panel.PanelActiveFrame;
|
||||
import noppes.npcs.client.gui.util.animation.panel.PanelFrameType;
|
||||
import noppes.npcs.constants.animation.EnumFrameType;
|
||||
@@ -25,24 +24,31 @@ public class AnimationGraphEditor extends ViewportGraphEditor {
|
||||
}
|
||||
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks, int wheel) {
|
||||
frameTypePanel.draw();
|
||||
activeFramePanel.draw();
|
||||
frameTypePanel.draw(wheel);
|
||||
if (pointManager.selectedPoint != null)
|
||||
activeFramePanel.draw(wheel);
|
||||
grid.draw(mouseX, mouseY, partialTicks, wheel);
|
||||
pointManager.draw(mouseX, mouseY, partialTicks);
|
||||
presetOverlay.draw(mouseX, mouseY, wheel);
|
||||
|
||||
if (Cursors.currentCursor() != null)
|
||||
Cursors.currentCursor().draw(mouseX, mouseY);
|
||||
|
||||
}
|
||||
|
||||
public void mouseClicked(int mouseX, int mouseY, int button) {
|
||||
super.mouseClicked(mouseX, mouseY, button);
|
||||
frameTypePanel.mouseClicked(mouseX, mouseY, button);
|
||||
activeFramePanel.mouseClicked(mouseX, mouseY, button);
|
||||
if (pointManager.selectedPoint != null)
|
||||
activeFramePanel.mouseClicked(mouseX, mouseY, button);
|
||||
pointManager.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
public void keyTyped(char c, int i) {
|
||||
super.keyTyped(c, i);
|
||||
frameTypePanel.keyTyped(c, i);
|
||||
activeFramePanel.keyTyped(c, i);
|
||||
if (pointManager.selectedPoint != null)
|
||||
activeFramePanel.keyTyped(c, i);
|
||||
pointManager.keyTyped(c, i);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,14 +9,17 @@ import org.lwjgl.input.Cursor;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public enum Cursors {
|
||||
|
||||
MOVE(0, 0, 0, 0, 19, 19);
|
||||
MOVE(0, 0, 0, 0, 19, 19, 0.5f), SLIDE(0, 0, 0, 20, 16, 8, 0.66f), EMPTY(0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
|
||||
public int offsetX, offsetY, textureX, textureY, width, height;
|
||||
public float scale;
|
||||
|
||||
Cursors(int offsetX, int offsetY, int textureX, int textureY, int width, int height) {
|
||||
Cursors(int offsetX, int offsetY, int textureX, int textureY, int width, int height, float scale) {
|
||||
|
||||
this.textureX = textureX;
|
||||
this.textureY = textureY;
|
||||
@@ -24,25 +27,29 @@ public enum Cursors {
|
||||
this.height = height;
|
||||
this.offsetX = -width / 2;
|
||||
this.offsetY = offsetY;
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
public void draw(double mouseX, double mouseY) {
|
||||
offsetX = width / 2;
|
||||
offsetY = height / 2;
|
||||
float scale = 0.5f;
|
||||
double screenX = (mouseX / scale - offsetX);
|
||||
double screenY = (mouseY / scale - offsetY);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(scale, scale, 1);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
|
||||
GuiUtil.drawTexturedModalRect(screenX, screenY, width, height, textureX, textureY);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
public static Cursors currentCursor;
|
||||
private static Cursors currentCursor;
|
||||
public static Supplier<Boolean> condition;
|
||||
|
||||
public static void setCursor(Cursors cursor) {
|
||||
public static void setCursor(Cursors cursor, Supplier<Boolean> con) {
|
||||
try {
|
||||
Cursor c = null;
|
||||
if (cursor != null)
|
||||
@@ -51,10 +58,21 @@ public enum Cursors {
|
||||
} catch (LWJGLException e) {
|
||||
}
|
||||
currentCursor = cursor;
|
||||
condition = con;
|
||||
}
|
||||
|
||||
public static void reset() {
|
||||
setCursor(null);
|
||||
setCursor(null, null);
|
||||
condition = null;
|
||||
}
|
||||
|
||||
public static void tick() {
|
||||
if (condition != null && !condition.get())
|
||||
reset();
|
||||
}
|
||||
|
||||
public static Cursors currentCursor() {
|
||||
return currentCursor;
|
||||
}
|
||||
|
||||
private static ResourceLocation TEXTURE = new ResourceLocation("customnpcs:textures/gui/cursors.png");
|
||||
|
||||
@@ -75,11 +75,10 @@ public class GridPointManager {
|
||||
if (isFreeTransforming) {
|
||||
selectedPoint.set(ftGrabX, ftGrabY);
|
||||
ftGrabX = ftGrabY = 0;
|
||||
Cursors.reset();
|
||||
} else {
|
||||
ftGrabX = selectedPoint.worldX;
|
||||
ftGrabY = selectedPoint.worldY;
|
||||
Cursors.setCursor(Cursors.MOVE);
|
||||
Cursors.setCursor(Cursors.MOVE, () -> selectedPoint != null && isFreeTransforming);
|
||||
}
|
||||
|
||||
isFreeTransforming = !isFreeTransforming;
|
||||
@@ -96,7 +95,7 @@ public class GridPointManager {
|
||||
|
||||
if (button == 0 && isFreeTransforming) {
|
||||
selectedPoint.updateKey();
|
||||
Cursors.reset();
|
||||
// Cursors.reset();
|
||||
isFreeTransforming = false;
|
||||
}
|
||||
|
||||
@@ -291,8 +290,6 @@ public class GridPointManager {
|
||||
if (selectedPoint != null)
|
||||
selectedPoint.draw(mouseX, mouseY, partialTicks);
|
||||
|
||||
if (Cursors.currentCursor != null)
|
||||
Cursors.currentCursor.draw(mouseX, mouseY);
|
||||
|
||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ViewportGraphEditor {
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (Cursors.currentCursor != null)
|
||||
if (Cursors.currentCursor() != null)
|
||||
Cursors.reset();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 667 B After Width: | Height: | Size: 814 B |
Reference in new issue
Block a user