mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-16 16:34:46 +00:00
Custom Overlays and GUIs now properly set alpha values for some components.
This commit is contained in:
1 parent
e5e1aa1972
commit
966ab4bf72
6 files changed
+71
-36
No files matched your search
@@ -1,14 +1,26 @@
|
||||
package noppes.npcs.client;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class ClientEventHandler {
|
||||
@SubscribeEvent
|
||||
public void onOverlayRender(RenderGameOverlayEvent.Pre event){
|
||||
for(OverlayCustom overlayCustom : Client.customOverlays.values()){
|
||||
overlayCustom.renderGameOverlay(event.partialTicks);
|
||||
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,10 +129,16 @@ 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()) {
|
||||
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);
|
||||
|
||||
if (this.hoverText != null) {
|
||||
this.func_146283_a(Arrays.asList(this.hoverText), mouseX, mouseY);
|
||||
|
||||
@@ -3,6 +3,7 @@ package noppes.npcs.client.gui.customoverlay;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.client.gui.customoverlay.components.CustomOverlayLabel;
|
||||
@@ -27,14 +28,6 @@ public class OverlayCustom extends Gui {
|
||||
public ScriptOverlay overlay;
|
||||
Map<Integer, IOverlayComponent> components = new HashMap();
|
||||
|
||||
float scale = 1.0F;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int textureX = 0;
|
||||
int textureY = 0;
|
||||
int width = 200;
|
||||
int height = 200;
|
||||
|
||||
public OverlayCustom(Minecraft mc) {
|
||||
this.mc = mc;
|
||||
}
|
||||
@@ -81,20 +74,12 @@ public class OverlayCustom extends Gui {
|
||||
scaledWidth = res.getScaledWidth();
|
||||
scaledHeight = res.getScaledHeight();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
Iterator var4 = this.components.values().iterator();
|
||||
|
||||
Iterator var4 = this.components.values().iterator();
|
||||
|
||||
while(var4.hasNext()) {
|
||||
IOverlayComponent component = (IOverlayComponent)var4.next();
|
||||
component.onRender(this.mc, partialTicks);
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glPopMatrix();
|
||||
while(var4.hasNext()) {
|
||||
IOverlayComponent component = (IOverlayComponent)var4.next();
|
||||
component.onRender(this.mc, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
public void setOverlayData(NBTTagCompound compound) {
|
||||
|
||||
+2
-6
@@ -100,19 +100,15 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent {
|
||||
{
|
||||
if (this.field_146172_j)
|
||||
{
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
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
|
||||
|
||||
float red = (color >> 16 & 255) / 255f;
|
||||
float green = (color >> 8 & 255) / 255f;
|
||||
float blue = (color & 255) / 255f;
|
||||
GL11.glColor4f(red,green,blue,this.alpha);
|
||||
|
||||
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.glTranslatef(this.x,this.y,0.0F);
|
||||
GL11.glScalef(this.scale, this.scale, this.scale);
|
||||
Minecraft.getMinecraft().fontRenderer.drawString(fullLabel, 0, 0, this.color, this.labelShadowEnabled);
|
||||
|
||||
+20
-2
@@ -3,6 +3,7 @@ package noppes.npcs.client.gui.customoverlay.components;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
|
||||
import noppes.npcs.client.gui.customoverlay.interfaces.IOverlayComponent;
|
||||
@@ -52,14 +53,31 @@ public class CustomOverlayLine extends Gui implements IOverlayComponent {
|
||||
float red = (color >> 16 & 255) / 255f;
|
||||
float green = (color >> 8 & 255) / 255f;
|
||||
float blue = (color & 255) / 255f;
|
||||
GL11.glColor4f(red,green,blue,this.alpha);
|
||||
|
||||
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.glTranslatef(this.x1,this.y1,0.0F);
|
||||
|
||||
GL11.glRotated(-Math.toDegrees(Math.atan2(x2-x1,y2-y1)),0.0F,0.0F,1.0F);
|
||||
GL11.glScaled(thickness, distance,0.0D);
|
||||
this.drawTexturedModalRect(0,0,0,0, 1, 1);
|
||||
|
||||
int p_73729_1_ = 0;
|
||||
int p_73729_2_ = 0;
|
||||
int p_73729_3_ = 0;
|
||||
int p_73729_4_ = 0;
|
||||
int p_73729_5_ = 1;
|
||||
int p_73729_6_ = 1;
|
||||
|
||||
float f = 0.00390625F;
|
||||
float f1 = 0.00390625F;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorOpaque_F(1, 1, 1);
|
||||
tessellator.setColorRGBA_F(red, green, blue, alpha);
|
||||
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
|
||||
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
|
||||
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + 0) * f1));
|
||||
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + 0) * f1));
|
||||
tessellator.draw();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
+22
-4
@@ -3,6 +3,7 @@ package noppes.npcs.client.gui.customoverlay.components;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
|
||||
import noppes.npcs.client.gui.customoverlay.interfaces.IOverlayComponent;
|
||||
@@ -10,8 +11,8 @@ import noppes.npcs.scripted.interfaces.ICustomOverlayComponent;
|
||||
import noppes.npcs.scripted.overlay.ScriptOverlayTexturedRect;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
|
||||
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static org.lwjgl.opengl.GL14.glBlendFuncSeparate;
|
||||
|
||||
public class CustomOverlayTexturedRect extends Gui implements IOverlayComponent {
|
||||
OverlayCustom parent;
|
||||
@@ -62,12 +63,29 @@ public class CustomOverlayTexturedRect extends Gui implements IOverlayComponent
|
||||
float red = (color >> 16 & 255) / 255f;
|
||||
float green = (color >> 8 & 255) / 255f;
|
||||
float blue = (color & 255) / 255f;
|
||||
GL11.glColor4f(red,green,blue,this.alpha);
|
||||
|
||||
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.glScalef(this.scale, this.scale, this.scale);
|
||||
this.drawTexturedModalRect((int) (this.x/this.scale), (int) (this.y/this.scale), this.textureX, this.textureY, (int)(this.width), (int)(this.height));
|
||||
|
||||
int p_73729_1_ = (int) (this.x/this.scale);
|
||||
int p_73729_2_ = (int) (this.y/this.scale);
|
||||
int p_73729_3_ = this.textureX;
|
||||
int p_73729_4_ = this.textureY;
|
||||
int p_73729_5_ = (int)(this.width);
|
||||
int p_73729_6_ = (int)(this.height);
|
||||
|
||||
float f = 0.00390625F;
|
||||
float f1 = 0.00390625F;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorOpaque_F(1, 1, 1);
|
||||
tessellator.setColorRGBA_F(red, green, blue, alpha);
|
||||
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
|
||||
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
|
||||
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + 0) * f1));
|
||||
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + 0) * f1));
|
||||
tessellator.draw();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user