Drawn border for OverlayKeyPreset + accounted for text editor's scroll bar in init

This commit is contained in:
bigguy345 committed 2025-12-19 18:06:27 +02:00
1 parent 37cd4f1b7a
commit 9d8fd5bada
3 files changed
+55 -6

No files matched your search

@@ -94,11 +94,12 @@ public class GuiScriptTextArea extends GuiNpcTextField {
public void initGui() {
int endX = x + width, endY = y + height;
KEYS_OVERLAY.elementSpacing = 0;
KEYS_OVERLAY.initGui(endX - (width / 2) , y + (height / 4), endX - 7, endY - 27);
int xOffset = hasVerticalScrollbar() ? -8 : -2;
KEYS_OVERLAY.elementSpacing = KEYS_OVERLAY.yStartSpacing = 0;
KEYS_OVERLAY.initGui(endX - (width / 2), y + (height / 4) - 10, endX + xOffset - 2, endY - 28);
KEYS_OVERLAY.viewButton.scale = 0.45f;
KEYS_OVERLAY.viewButton.initGui(endX - 7, endY - 26);
KEYS_OVERLAY.viewButton.initGui(endX + xOffset, endY - 26);
}
// ==================== RENDERING ====================
@@ -112,6 +112,39 @@ public class GuiUtil {
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
public static void drawGradientRectHorizontal(int left, int top, int right, int bottom, int startColor, int endColor) {
double zLevel = 0;
float sA = (float) (startColor >> 24 & 255) / 255.0F;
float sR = (float) (startColor >> 16 & 255) / 255.0F;
float sG = (float) (startColor >> 8 & 255) / 255.0F;
float sB = (float) (startColor & 255) / 255.0F;
float eA = (float) (endColor >> 24 & 255) / 255.0F;
float eR = (float) (endColor >> 16 & 255) / 255.0F;
float eG = (float) (endColor >> 8 & 255) / 255.0F;
float eB = (float) (endColor & 255) / 255.0F;
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_ALPHA_TEST);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glShadeModel(GL11.GL_SMOOTH);
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorRGBA_F(sR, sG, sB, sA);
tessellator.addVertex(left, top, zLevel);
tessellator.addVertex(left, bottom, zLevel);
tessellator.setColorRGBA_F(eR, eG, eB, eA);
tessellator.addVertex(right, bottom, zLevel);
tessellator.addVertex(right, top, zLevel);
tessellator.draw();
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
public static void drawTexturedModalRect(double x, double y, double width, double height, int textureX, int textureY) {
double zLevel = 0;
@@ -33,6 +33,8 @@ public class OverlayKeyPresetViewer {
public float RELATIVE_MAX_DESC_WIDTH = 0.5f;
private final FontRenderer font = Minecraft.getMinecraft().fontRenderer;
public boolean hasBorder = true;
public OverlayKeyPresetViewer(KeyPresetManager manager) {
this.manager = manager;
@@ -72,10 +74,23 @@ public class OverlayKeyPresetViewer {
public void drawOverlay(int wheel) {
scroll.update(wheel);
if (hasBorder) {
int fromCol = 0x22ffffff, toCol = 0xffffffff; //BORDER GRADIENT
// int fromCol = 0xffff00ff,toCol = 0xff00ffff; NEON
// Top
GuiUtil.drawGradientRectHorizontal(startX - 1, startY - 1, endX + 1, startY, toCol, fromCol);
// Bottom
GuiUtil.drawGradientRectHorizontal(startX - 1, endY, endX + 1, endY + 1, fromCol, toCol);
// Left
GuiUtil.drawGradientRect(startX - 1, startY - 1, startX, endY, toCol, fromCol);
//Right
GuiUtil.drawGradientRect(endX, startY, endX + 1, endY, fromCol, toCol);
}
GuiUtil.drawGradientRect(startX + 1, startY + 1, endX - 1, endY - 1, 0x88000000, 0xcc303030);
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GuiUtil.drawGradientRect(startX, startY, endX, endY, 0x88000000, 0x88303030);
GuiUtil.setScissorClip(startX, startY, scroll.maxScroll > 0 ? width - scroll.barWidth : width, height);
GL11.glPushMatrix();
GL11.glTranslatef((startX + 2), startY + yStartSpacing - scroll.scrollY, 0);
@@ -419,7 +434,7 @@ public class OverlayKeyPresetViewer {
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GL11.glPushMatrix();
float color = 0.55f;
float color = 0.75f;
GL11.glColor4f(color, color, color, 1);
GL11.glScalef(scale, scale, 1);
GuiUtil.drawTexturedModalRect(screenX, screenY, textureWidth, textureHeight, 0, 0);