mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 02:59:42 +00:00
Fix Some issues with Lang Setup, Button Widths, Moving System
This commit is contained in:
1 parent
676c0626d1
commit
b0168c1d55
7 files changed
+141
-41
No files matched your search
@@ -5,6 +5,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
@@ -166,8 +167,13 @@ public class GuiNpcButton extends GuiButton {
|
||||
}
|
||||
}
|
||||
}
|
||||
// First, draw the button normally using the superclass method.
|
||||
super.drawButton(mc, mouseX, mouseY);
|
||||
// Wide buttons (>396px) break the vanilla 200px button texture.
|
||||
// Draw them with a three-patch approach instead.
|
||||
if (this.width > 396) {
|
||||
drawWideButton(mc, mouseX, mouseY);
|
||||
} else {
|
||||
super.drawButton(mc, mouseX, mouseY);
|
||||
}
|
||||
// Restore original display string
|
||||
this.displayString = original;
|
||||
// Then, if an icon texture is set, draw it.
|
||||
@@ -175,17 +181,58 @@ public class GuiNpcButton extends GuiButton {
|
||||
mc.getTextureManager().bindTexture(iconTexture);
|
||||
GL11.glPushMatrix();
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
// Calculate the icon position so that it's centered in the button.
|
||||
// (Assumes the button's (xPosition,yPosition) is its top left.)
|
||||
int iconX = this.xPosition + (this.width - iconWidth) / 2;
|
||||
int iconY = this.yPosition + (this.height - iconHeight) / 2;
|
||||
// Draw the texture; we assume texture coordinates start at (0,0) with the desired size.
|
||||
this.drawTexturedModalRect(iconX, iconY, iconPosX, iconPosY, iconWidth, iconHeight);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a button wider than the vanilla 200px texture allows.
|
||||
* Uses three-patch rendering: left cap, tiled center, right cap.
|
||||
*/
|
||||
private void drawWideButton(Minecraft mc, int mouseX, int mouseY) {
|
||||
FontRenderer fontrenderer = mc.fontRenderer;
|
||||
mc.getTextureManager().bindTexture(buttonTextures);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition
|
||||
&& mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
|
||||
int k = this.getHoverState(this.field_146123_n);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
int texY = 46 + k * 20;
|
||||
int cap = 100;
|
||||
|
||||
// Left cap (first 100px of texture)
|
||||
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, texY, cap, this.height);
|
||||
// Right cap (last 100px of texture)
|
||||
this.drawTexturedModalRect(this.xPosition + this.width - cap, this.yPosition, 200 - cap, texY, cap, this.height);
|
||||
// Tile the center column to fill the gap
|
||||
int gapStart = this.xPosition + cap;
|
||||
int gapEnd = this.xPosition + this.width - cap;
|
||||
for (int x = gapStart; x < gapEnd; x += 2) {
|
||||
int drawW = Math.min(2, gapEnd - x);
|
||||
this.drawTexturedModalRect(x, this.yPosition, 99, texY, drawW, this.height);
|
||||
}
|
||||
|
||||
this.mouseDragged(mc, mouseX, mouseY);
|
||||
|
||||
int l = 14737632;
|
||||
if (packedFGColour != 0) {
|
||||
l = packedFGColour;
|
||||
} else if (!this.enabled) {
|
||||
l = 10526880;
|
||||
} else if (this.field_146123_n) {
|
||||
l = 16777120;
|
||||
}
|
||||
this.drawCenteredString(fontrenderer, this.displayString,
|
||||
this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l);
|
||||
}
|
||||
|
||||
public void drawHover(int i, int j, boolean hasSubGui) {
|
||||
if (hasSubGui || !visible || hoverableText.isEmpty())
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user