Fixed ModList GUI rendering incorrectly. Closes #2254
This commit is contained in:
parent
3f163fd41e
commit
b9d1d92654
1 changed files with 22 additions and 40 deletions
|
@ -17,6 +17,7 @@ import java.util.List;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
|
@ -96,15 +97,27 @@ public abstract class GuiScrollingList
|
|||
|
||||
protected abstract void drawBackground();
|
||||
|
||||
/**
|
||||
* Draw anything special on the screen. GL_SCISSOR is enabled for anything that
|
||||
* is rendered outside of the view box. Do not mess with SCISSOR unless you support this.
|
||||
*/
|
||||
protected abstract void drawSlot(int slotIdx, int entryRight, int slotTop, int slotBuffer, Tessellator tess);
|
||||
|
||||
@Deprecated protected void func_27260_a(int entryRight, int relativeY, Tessellator tess) {}
|
||||
/**
|
||||
* Draw anything special on the screen. GL_SCISSOR is enabled for anything that
|
||||
* is rendered outside of the view box. Do not mess with SCISSOR unless you support this.
|
||||
*/
|
||||
protected void drawHeader(int entryRight, int relativeY, Tessellator tess) { func_27260_a(entryRight, relativeY, tess); }
|
||||
|
||||
@Deprecated protected void func_27255_a(int x, int y) {}
|
||||
protected void clickHeader(int x, int y) { func_27255_a(x, y); }
|
||||
|
||||
@Deprecated protected void func_27257_b(int mouseX, int mouseY) {}
|
||||
/**
|
||||
* Draw anything special on the screen. GL_SCISSOR is enabled for anything that
|
||||
* is rendered outside of the view box. Do not mess with SCISSOR unless you support this.
|
||||
*/
|
||||
protected void drawScreen(int mouseX, int mouseY) { func_27257_b(mouseX, mouseY); }
|
||||
|
||||
public int func_27256_c(int x, int y)
|
||||
|
@ -252,6 +265,13 @@ public abstract class GuiScrollingList
|
|||
Tessellator tess = Tessellator.getInstance();
|
||||
WorldRenderer worldr = tess.getWorldRenderer();
|
||||
|
||||
ScaledResolution res = new ScaledResolution(client);
|
||||
double scaleW = client.displayWidth / res.getScaledWidth_double();
|
||||
double scaleH = client.displayHeight / res.getScaledHeight_double();
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
GL11.glScissor((int)(left * scaleW), (int)(client.displayHeight - (bottom * scaleH)),
|
||||
(int)(listWidth * scaleW), (int)(viewHeight * scaleH));
|
||||
|
||||
if (this.client.theWorld != null)
|
||||
{
|
||||
this.drawGradientRect(this.left, this.top, this.right, this.bottom, 0xC0101010, 0xD0101010);
|
||||
|
@ -308,30 +328,6 @@ public abstract class GuiScrollingList
|
|||
}
|
||||
|
||||
GlStateManager.disableDepth();
|
||||
if (this.client.theWorld == null)
|
||||
{
|
||||
this.overlayBackground(0, this.top, 255, 255);
|
||||
this.overlayBackground(this.bottom, this.listHeight, 255, 255);
|
||||
}
|
||||
|
||||
// Render the entire background over everything but our view
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.shadeModel(GL11.GL_SMOOTH);
|
||||
GlStateManager.disableTexture2D();
|
||||
worldr.func_181668_a(7, DefaultVertexFormats.field_181709_i);
|
||||
worldr.func_181662_b(this.left, this.top + border, 0).func_181673_a(0, 1).func_181669_b(0x00, 0x00, 0x00, 0x00).func_181675_d();
|
||||
worldr.func_181662_b(this.right, this.top + border, 0).func_181673_a(1, 1).func_181669_b(0x00, 0x00, 0x00, 0x00).func_181675_d();
|
||||
worldr.func_181662_b(this.right, this.top, 0).func_181673_a(1, 0).func_181669_b(0x00, 0x00, 0x00, 0xFF).func_181675_d();
|
||||
worldr.func_181662_b(this.left, this.top, 0).func_181673_a(0, 0).func_181669_b(0x00, 0x00, 0x00, 0xFF).func_181675_d();
|
||||
tess.draw();
|
||||
worldr.func_181668_a(7, DefaultVertexFormats.field_181709_i);
|
||||
worldr.func_181662_b(this.left, this.bottom, 0).func_181673_a(0, 1).func_181669_b(0x00, 0x00, 0x00, 0xFF).func_181675_d();
|
||||
worldr.func_181662_b(this.right, this.bottom, 0).func_181673_a(1, 1).func_181669_b(0x00, 0x00, 0x00, 0xFF).func_181675_d();
|
||||
worldr.func_181662_b(this.right, this.bottom - border, 0).func_181673_a(1, 0).func_181669_b(0x00, 0x00, 0x00, 0x00).func_181675_d();
|
||||
worldr.func_181662_b(this.left, this.bottom - border, 0).func_181673_a(0, 0).func_181669_b(0x00, 0x00, 0x00, 0x00).func_181675_d();
|
||||
tess.draw();
|
||||
|
||||
int extraHeight = this.getContentHeight() - viewHeight - border;
|
||||
if (extraHeight > 0)
|
||||
|
@ -349,6 +345,7 @@ public abstract class GuiScrollingList
|
|||
barTop = this.top;
|
||||
}
|
||||
|
||||
GlStateManager.disableTexture2D();
|
||||
worldr.func_181668_a(7, DefaultVertexFormats.field_181709_i);
|
||||
worldr.func_181662_b(scrollBarLeft, this.bottom, 0.0D).func_181673_a(0.0D, 1.0D).func_181669_b(0x00, 0x00, 0x00, 0xFF).func_181675_d();
|
||||
worldr.func_181662_b(scrollBarRight, this.bottom, 0.0D).func_181673_a(1.0D, 1.0D).func_181669_b(0x00, 0x00, 0x00, 0xFF).func_181675_d();
|
||||
|
@ -374,22 +371,7 @@ public abstract class GuiScrollingList
|
|||
GlStateManager.shadeModel(GL11.GL_FLAT);
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.disableBlend();
|
||||
}
|
||||
|
||||
private void overlayBackground(int top, int height, int alpha1, int alpha2)
|
||||
{
|
||||
Tessellator tess = Tessellator.getInstance();
|
||||
WorldRenderer worldr = tess.getWorldRenderer();
|
||||
this.client.renderEngine.bindTexture(Gui.optionsBackground);
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
float scale = 32.0F;
|
||||
double startUV = (screenWidth / scale) / screenWidth * (left-0);
|
||||
worldr.func_181668_a(7, DefaultVertexFormats.field_181709_i);
|
||||
worldr.func_181662_b(left, height, 0.0D).func_181673_a(startUV, height / scale).func_181669_b(0x40, 0x40, 0x40, alpha2).func_181675_d();
|
||||
worldr.func_181662_b(left+listWidth+8, height, 0.0D).func_181673_a((left+listWidth+8) / scale, height / scale).func_181669_b(0x40, 0x40, 0x40, alpha2).func_181675_d();
|
||||
worldr.func_181662_b(left+listWidth+8, top, 0.0D).func_181673_a((left+listWidth+8) / scale, top / scale ).func_181669_b(0x40, 0x40, 0x40, alpha1).func_181675_d();
|
||||
worldr.func_181662_b(left, top, 0.0D).func_181673_a(startUV, top / scale ).func_181669_b(0x40, 0x40, 0x40, alpha1).func_181675_d();
|
||||
tess.draw();
|
||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
protected void drawGradientRect(int left, int top, int right, int bottom, int color1, int color2)
|
||||
|
|
Loading…
Reference in a new issue