mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 19:59:56 +00:00
Rewrote all GuiScriptTextArea scissoring logic to handle new panning
This commit is contained in:
1 parent
35b9b8e66f
commit
69f9d218ca
7 files changed
+39
-21
No files matched your search
@@ -76,7 +76,8 @@ public abstract class GuiNPCInterface extends GuiScreen {
|
||||
*/
|
||||
public double currentPanX, currentPanY;
|
||||
|
||||
public static double activePanX, activePanY;
|
||||
public double getPanX() { return currentPanX; }
|
||||
public double getPanY() { return currentPanY; }
|
||||
|
||||
protected double minPanX, maxPanX, minPanY, maxPanY;
|
||||
protected int panViewportX, panViewportY, panViewportWidth, panViewportHeight;
|
||||
@@ -507,8 +508,6 @@ public abstract class GuiNPCInterface extends GuiScreen {
|
||||
if (panning) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(-currentPanX, -currentPanY, 0);
|
||||
activePanX = currentPanX;
|
||||
activePanY = currentPanY;
|
||||
}
|
||||
|
||||
if (background != null && mc.renderEngine != null) {
|
||||
@@ -557,8 +556,6 @@ public abstract class GuiNPCInterface extends GuiScreen {
|
||||
|
||||
if (panning) {
|
||||
GL11.glPopMatrix();
|
||||
activePanX = 0;
|
||||
activePanY = 0;
|
||||
}
|
||||
|
||||
if (subgui != null) {
|
||||
|
||||
@@ -1084,7 +1084,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
|
||||
if (parent != null)
|
||||
parent.fullscreenButton.draw(xMouse, yMouse);
|
||||
|
||||
// Draw search/replace bar (overlays viewport)
|
||||
searchBar.ownerGui = parent;
|
||||
searchBar.draw(xMouse, yMouse);
|
||||
|
||||
// Draw go to line dialog (overlays everything)
|
||||
@@ -1092,7 +1092,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
|
||||
|
||||
KEYS_OVERLAY.draw(xMouse, yMouse, wheelDelta);
|
||||
|
||||
// Draw autocomplete menu (overlays code area)
|
||||
autocompleteManager.getMenu().ownerGui = parent;
|
||||
autocompleteManager.draw(xMouse, yMouse);
|
||||
|
||||
// Draw hover tooltips (on top of everything)
|
||||
@@ -1101,7 +1101,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
|
||||
int viewportWidth = width - LINE_NUMBER_GUTTER_WIDTH;
|
||||
int viewportY = y;
|
||||
int viewportHeight = height;
|
||||
TokenHoverRenderer.render(hoverState, viewportX, viewportWidth+xOffset, viewportY, viewportHeight);
|
||||
TokenHoverRenderer.render(hoverState, viewportX, viewportWidth+xOffset, viewportY, viewportHeight,parent);
|
||||
}
|
||||
|
||||
// Draw gutter icon tooltip
|
||||
@@ -1114,9 +1114,11 @@ public class GuiScriptTextArea extends GuiNpcTextField {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
int scaleFactor = sr.getScaleFactor();
|
||||
int scissorX = (this.x) * scaleFactor;
|
||||
int scissorY = (sr.getScaledHeight() - (this.y + this.height)) * scaleFactor;
|
||||
int scissorW = (this.width) * scaleFactor;
|
||||
double panX = parent != null ? parent.getPanX() : 0;
|
||||
double panY = parent != null ? parent.getPanY() : 0;
|
||||
int scissorX = (int)((this.x - panX) * scaleFactor);
|
||||
int scissorY = (int)((sr.getScaledHeight() - (this.y - panY + this.height)) * scaleFactor);
|
||||
int scissorW = this.width * scaleFactor;
|
||||
int scissorH = this.height * scaleFactor;
|
||||
GL11.glScissor(scissorX, scissorY, scissorW, scissorH);
|
||||
}
|
||||
|
||||
@@ -10,11 +10,19 @@ import org.lwjgl.opengl.GL11;
|
||||
public class GuiUtil {
|
||||
|
||||
public static void setScissorClip(int x, int y, int width, int height) {
|
||||
setScissorClip(x, y, width, height, null);
|
||||
}
|
||||
|
||||
public static void setScissorClip(int x, int y, int width, int height, GuiNPCInterface gui) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
int scale = res.getScaleFactor();
|
||||
|
||||
|
||||
if (gui != null) {
|
||||
x -= (int) gui.getPanX();
|
||||
y -= (int) gui.getPanY();
|
||||
}
|
||||
|
||||
// Adjust position to Top-Left origin (OpenGL window/screen space uses bottom-left origin)
|
||||
y = mc.displayHeight - y * scale;
|
||||
height *= scale;
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.util.ChatAllowedCharacters;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||
import noppes.npcs.client.gui.util.GuiScriptTextArea.UndoData;
|
||||
import noppes.npcs.client.gui.util.GuiUtil;
|
||||
import noppes.npcs.client.gui.util.key.OverlayKeyPresetViewer;
|
||||
@@ -35,6 +36,7 @@ public class SearchReplaceBar {
|
||||
|
||||
// ==================== DIMENSIONS ====================
|
||||
private int x, y, width;
|
||||
public GuiNPCInterface ownerGui;
|
||||
private int barHeight = 24;
|
||||
private int replaceBarHeight = 22;
|
||||
private int textFieldWidth = 150;
|
||||
@@ -538,7 +540,7 @@ public class SearchReplaceBar {
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
GuiUtil.setScissorClip(fieldX + 2, fieldY, fieldWidth - 4, fieldHeight);
|
||||
GuiUtil.setScissorClip(fieldX + 2, fieldY, fieldWidth - 4, fieldHeight, ownerGui);
|
||||
|
||||
|
||||
// Draw selection highlight
|
||||
@@ -604,7 +606,7 @@ public class SearchReplaceBar {
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
GuiUtil.setScissorClip(fieldX + 2, fieldY, fieldWidth - 4, fieldHeight);
|
||||
GuiUtil.setScissorClip(fieldX + 2, fieldY, fieldWidth - 4, fieldHeight, ownerGui);
|
||||
|
||||
{
|
||||
// Draw selection highlight
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||
import noppes.npcs.client.gui.util.script.interpreter.token.TokenType;
|
||||
import noppes.npcs.client.gui.util.script.interpreter.type.TypeInfo;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -71,6 +72,7 @@ public class AutocompleteMenu extends Gui {
|
||||
|
||||
// ==================== POSITION ====================
|
||||
private int x, y;
|
||||
public GuiNPCInterface ownerGui;
|
||||
private int width, height;
|
||||
private int menuWidth;
|
||||
private int visibleItemsCount; // Actual number of items that fit in the menu
|
||||
@@ -910,6 +912,11 @@ public class AutocompleteMenu extends Gui {
|
||||
ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
int scaleFactor = sr.getScaleFactor();
|
||||
|
||||
if (ownerGui != null) {
|
||||
x -= (int) ownerGui.getPanX();
|
||||
y -= (int) ownerGui.getPanY();
|
||||
}
|
||||
|
||||
int scissorX = x * scaleFactor;
|
||||
int scissorY = mc.displayHeight - (y + height) * scaleFactor;
|
||||
int scissorW = width * scaleFactor;
|
||||
|
||||
+8
-6
@@ -4,6 +4,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import noppes.npcs.client.ClientProxy;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -82,7 +83,7 @@ public class TokenHoverRenderer {
|
||||
/**
|
||||
* Render the hover tooltip.
|
||||
*/
|
||||
public static void render(HoverState hoverState, int viewportX, int viewportWidth, int viewportY, int viewportHeight) {
|
||||
public static void render(HoverState hoverState, int viewportX, int viewportWidth, int viewportY, int viewportHeight, GuiNPCInterface gui) {
|
||||
if (!hoverState.isTooltipVisible()) return;
|
||||
hoverState.updateSmoothScroll();
|
||||
|
||||
@@ -186,7 +187,7 @@ public class TokenHoverRenderer {
|
||||
|
||||
// Render the tooltip
|
||||
renderTooltipBox(tooltipX, tooltipY, boxWidth, maxContentWidth, info, hoverState,
|
||||
totalContentHeight, visibleContentHeight);
|
||||
totalContentHeight, visibleContentHeight, gui);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,7 +207,7 @@ public class TokenHoverRenderer {
|
||||
* Render the tooltip box with all content.
|
||||
*/
|
||||
private static void renderTooltipBox(int x, int y, int boxWidth, int wrapWidth, TokenHoverInfo info,
|
||||
HoverState hoverState, int totalContentHeight, int visibleContentHeight) {
|
||||
HoverState hoverState, int totalContentHeight, int visibleContentHeight, GuiNPCInterface gui) {
|
||||
|
||||
boolean hasScrollbar = totalContentHeight > visibleContentHeight;
|
||||
// Wrap at the actual box content area width, not the max allowed width.
|
||||
@@ -228,12 +229,13 @@ public class TokenHoverRenderer {
|
||||
Gui.drawRect(x, y, x + 1, y + boxHeight, BORDER_COLOR);
|
||||
Gui.drawRect(x + boxWidth - 1, y, x + boxWidth, y + boxHeight, BORDER_COLOR);
|
||||
|
||||
// Set up GL scissor to clip scrollable content within the tooltip box (inside borders)
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
int sf = sr.getScaleFactor();
|
||||
int clipX = (x + 1) * sf;
|
||||
int clipY = (sr.getScaledHeight() - (y + boxHeight - 1 - BOTTOM_GAP)) * sf;
|
||||
double panX = gui != null ? gui.getPanX() : 0;
|
||||
double panY = gui != null ? gui.getPanY() : 0;
|
||||
int clipX = (int)((x + 1 - panX) * sf);
|
||||
int clipY = (int)((sr.getScaledHeight() - (y - panY + boxHeight - 1 - BOTTOM_GAP)) * sf);
|
||||
int clipW = (hasScrollbar ? boxWidth - PADDING - 1 : boxWidth - 2) * sf;
|
||||
int clipH = (boxHeight - 2 - BOTTOM_GAP) * sf;
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
|
||||
Reference in new issue
Block a user