mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 08:45:11 +00:00
Moved OpenGL lines to within the loop that renders each component, fixing some weird alpha errors.
This commit is contained in:
1 parent
54fadbe63f
commit
3be088c4cc
5 files changed
+33
-75
No files matched your search
@@ -10,17 +10,9 @@ public class ClientEventHandler {
|
||||
@SubscribeEvent
|
||||
public void onOverlayRender(RenderGameOverlayEvent.Post event){
|
||||
if(event.type == RenderGameOverlayEvent.ElementType.ALL) {
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
for (OverlayCustom overlayCustom : Client.customOverlays.values()) {
|
||||
overlayCustom.renderGameOverlay(event.partialTicks);
|
||||
}
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,16 +129,18 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
|
||||
Iterator var4 = this.components.values().iterator();
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
while(var4.hasNext()) {
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
IGuiComponent component = (IGuiComponent)var4.next();
|
||||
component.onRender(this.mc, mouseX, mouseY, Mouse.getDWheel(), partialTicks);
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
}
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
if (this.hoverText != null) {
|
||||
this.func_146283_a(Arrays.asList(this.hoverText), mouseX, mouseY);
|
||||
|
||||
@@ -45,7 +45,6 @@ public class CustomGuiLabel extends Gui implements IGuiComponent {
|
||||
protected int field_146161_f;
|
||||
public int field_146162_g;
|
||||
public int field_146174_h;
|
||||
public boolean field_146172_j;
|
||||
|
||||
private boolean randomStyle = false;
|
||||
private boolean boldStyle = false;
|
||||
@@ -106,7 +105,6 @@ public class CustomGuiLabel extends Gui implements IGuiComponent {
|
||||
CustomGuiLabel lbl = new CustomGuiLabel(component.getID(), component.getText(), GuiCustom.guiLeft + component.getPosX(), GuiCustom.guiTop + component.getPosY(), component.getWidth(), component.getHeight(), component.hasShadow());
|
||||
lbl.scale = 1.0F;
|
||||
lbl.color = component.getColor();
|
||||
lbl.field_146172_j = true;
|
||||
lbl.setScale(component.getScale());
|
||||
if (component.hasHoverText()) {
|
||||
lbl.hoverText = component.getHoverText();
|
||||
@@ -129,35 +127,15 @@ public class CustomGuiLabel extends Gui implements IGuiComponent {
|
||||
|
||||
public void drawLabel()
|
||||
{
|
||||
if (this.field_146172_j)
|
||||
{
|
||||
this.drawLabelBackground();
|
||||
GL11.glPushMatrix();
|
||||
red = (color >> 16 & 255) / 255f;
|
||||
green = (color >> 8 & 255) / 255f;
|
||||
blue = (color & 255) / 255f;
|
||||
GL11.glPushMatrix();
|
||||
red = (color >> 16 & 255) / 255f;
|
||||
green = (color >> 8 & 255) / 255f;
|
||||
blue = (color & 255) / 255f;
|
||||
|
||||
GL11.glTranslatef(this.x,this.y,0.0F);
|
||||
GL11.glScalef(this.scale, this.scale, this.scale);
|
||||
this.drawString(fullLabel, 0, 0, this.color, this.labelShadowEnabled);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawLabelBackground()
|
||||
{
|
||||
if (this.labelBgEnabled)
|
||||
{
|
||||
int k = (int)(this.width*this.scale) + this.border * 2;
|
||||
int l = (int)(this.height*this.scale) + this.border * 2;
|
||||
int i1 = this.x - this.border;
|
||||
int j1 = this.y - this.border;
|
||||
drawRect(i1, j1, i1 + k, j1 + l, this.color);//backColor
|
||||
this.drawHorizontalLine(i1, i1 + k, j1, this.color);//ulColor
|
||||
this.drawHorizontalLine(i1, i1 + k, j1 + l, this.color);//brColor
|
||||
this.drawVerticalLine(i1, j1, j1 + l, this.color);//ulColor
|
||||
this.drawVerticalLine(i1 + k, j1, j1 + l, this.color);//brColor
|
||||
}
|
||||
GL11.glTranslatef(this.x,this.y,0.0F);
|
||||
GL11.glScalef(this.scale, this.scale, this.scale);
|
||||
this.drawString(fullLabel, 0, 0, this.color, this.labelShadowEnabled);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public int drawString(String p_85187_1_, int p_85187_2_, int p_85187_3_, int p_85187_4_, boolean p_85187_5_)
|
||||
|
||||
@@ -77,8 +77,16 @@ public class OverlayCustom extends Gui {
|
||||
Iterator var4 = this.components.values().iterator();
|
||||
|
||||
while(var4.hasNext()) {
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
IOverlayComponent component = (IOverlayComponent)var4.next();
|
||||
component.onRender(this.mc, partialTicks);
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-31
@@ -43,7 +43,6 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent {
|
||||
protected int field_146161_f;
|
||||
public int field_146162_g;
|
||||
public int field_146174_h;
|
||||
public boolean field_146172_j;
|
||||
|
||||
private boolean randomStyle = false;
|
||||
private boolean boldStyle = false;
|
||||
@@ -100,7 +99,6 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent {
|
||||
CustomOverlayLabel lbl = new CustomOverlayLabel(component.getID(), component.getText(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight(), component.getShadow());
|
||||
lbl.scale = 1.0F;
|
||||
lbl.color = component.getColor();
|
||||
lbl.field_146172_j = true;
|
||||
lbl.setScale(component.getScale());
|
||||
|
||||
lbl.labelShadowEnabled = component.getShadow();
|
||||
@@ -123,37 +121,17 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent {
|
||||
|
||||
public void drawLabel()
|
||||
{
|
||||
if (this.field_146172_j)
|
||||
{
|
||||
this.drawLabelBackground();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(this.alignment%3*((float)(OverlayCustom.scaledWidth)/2), (float) (Math.floor((float)(alignment/3))*((float)(OverlayCustom.scaledHeight)/2)),0.0F);//alignment%3 * width/2 Math.floor(alignment/3) * height/2
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(this.alignment%3*((float)(OverlayCustom.scaledWidth)/2), (float) (Math.floor((float)(alignment/3))*((float)(OverlayCustom.scaledHeight)/2)),0.0F);//alignment%3 * width/2 Math.floor(alignment/3) * height/2
|
||||
|
||||
red = (color >> 16 & 255) / 255f;
|
||||
green = (color >> 8 & 255) / 255f;
|
||||
blue = (color & 255) / 255f;
|
||||
red = (color >> 16 & 255) / 255f;
|
||||
green = (color >> 8 & 255) / 255f;
|
||||
blue = (color & 255) / 255f;
|
||||
|
||||
GL11.glTranslatef(this.x,this.y,0.0F);
|
||||
GL11.glScalef(this.scale, this.scale, this.scale);
|
||||
this.drawString(fullLabel, 0, 0, this.color, this.labelShadowEnabled);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawLabelBackground()
|
||||
{
|
||||
if (this.labelBgEnabled)
|
||||
{
|
||||
int k = (int)(this.width*this.scale) + this.border * 2;
|
||||
int l = (int)(this.height*this.scale) + this.border * 2;
|
||||
int i1 = this.x - this.border;
|
||||
int j1 = this.y - this.border;
|
||||
drawRect(i1, j1, i1 + k, j1 + l, this.color);//backColor
|
||||
this.drawHorizontalLine(i1, i1 + k, j1, this.color);//ulColor
|
||||
this.drawHorizontalLine(i1, i1 + k, j1 + l, this.color);//brColor
|
||||
this.drawVerticalLine(i1, j1, j1 + l, this.color);//ulColor
|
||||
this.drawVerticalLine(i1 + k, j1, j1 + l, this.color);//brColor
|
||||
}
|
||||
GL11.glTranslatef(this.x,this.y,0.0F);
|
||||
GL11.glScalef(this.scale, this.scale, this.scale);
|
||||
this.drawString(fullLabel, 0, 0, this.color, this.labelShadowEnabled);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public int drawString(String p_85187_1_, int p_85187_2_, int p_85187_3_, int p_85187_4_, boolean p_85187_5_)
|
||||
|
||||
Reference in new issue
Block a user