diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiButton.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiButton.java index 57ad3bc66..9cce17988 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiButton.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiButton.java @@ -6,7 +6,6 @@ package noppes.npcs.client.gui.custom.components; import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.util.ResourceLocation; @@ -23,17 +22,17 @@ public class CustomGuiButton extends GuiButton implements IClickListener { public int textureY; boolean field_146123_n; String label; - int colour; String[] hoverText; + int color; + float alpha; + public CustomGuiButton(int id, String buttonText, int x, int y) { super(id, GuiCustom.guiLeft + x, GuiCustom.guiTop + y, buttonText); - this.colour = 16777215; } public CustomGuiButton(int id, String buttonText, int x, int y, int width, int height) { super(id, GuiCustom.guiLeft + x, GuiCustom.guiTop + y, width, height, buttonText); - this.colour = 16777215; } public CustomGuiButton(int buttonId, String buttonText, int x, int y, int width, int height, String texture) { @@ -66,6 +65,9 @@ public class CustomGuiButton extends GuiButton implements IClickListener { btn = new CustomGuiButton(component.getID(), component.getLabel(), component.getPosX(), component.getPosY()); } + btn.color = component.getColor(); + btn.alpha = component.getAlpha(); + if (component.hasHoverText()) { btn.hoverText = component.getHoverText(); } @@ -81,59 +83,59 @@ public class CustomGuiButton extends GuiButton implements IClickListener { //GL11.func_179094_E(); //GL11.func_179109_b(0.0F, 0.0F, (float)this.id); GL11.glPushMatrix(); - GL11.glTranslatef(0.0F, 0.0F, (float)this.id); - FontRenderer fontRenderer = mc.fontRenderer; - int i; - if (this.texture == null) { - 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; - i = this.getHoverState(this.field_146123_n); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - //GL11.func_187428_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO); - //GL11.func_187401_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA); - this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + i * 20, this.width / 2, this.height); - this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height); - this.mouseDragged(mc, mouseX, mouseY); - int j = 14737632; - if (this.packedFGColour != 0) { - j = this.packedFGColour; - } else if (!this.enabled) { - j = 10526880; - } else if (this.field_146123_n) { - j = 16777120; - } + 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.glTranslated(0.0D, 0.0D, 0.1D); - this.drawCenteredString(fontRenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, j); - } else { - mc.getTextureManager().bindTexture(this.texture); - 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; - i = this.hoverState(this.field_146123_n); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - //GL11.func_187428_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO); - //GL11.func_187401_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA); - this.drawTexturedModalRect(this.xPosition, this.yPosition, this.textureX, this.textureY + i * this.height, this.width, this.height); - this.drawCenteredString(fontRenderer, this.label, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, this.colour); - if (this.field_146123_n && this.hoverText != null && this.hoverText.length > 0) { - this.parent.hoverText = this.hoverText; - } - } + GL11.glTranslatef(0.0F, 0.0F, (float)this.id); + FontRenderer fontRenderer = mc.fontRenderer; + int i; + if (this.texture == null) { + mc.getTextureManager().bindTexture(buttonTextures); + this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; + i = this.getHoverState(this.field_146123_n); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + //GL11.func_187428_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO); + //GL11.func_187401_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA); + this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + i * 20, this.width / 2, this.height); + this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height); + this.mouseDragged(mc, mouseX, mouseY); + int j = 14737632; + if (this.packedFGColour != 0) { + j = this.packedFGColour; + } else if (!this.enabled) { + j = 10526880; + } else if (this.field_146123_n) { + j = 16777120; + } + GL11.glTranslated(0.0D, 0.0D, 0.1D); + this.drawCenteredString(fontRenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, j); + } else { + mc.getTextureManager().bindTexture(this.texture); + this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; + i = this.hoverState(this.field_146123_n); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + //GL11.func_187428_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO); + //GL11.func_187401_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA); + this.drawTexturedModalRect(this.xPosition, this.yPosition, this.textureX, this.textureY + i * this.height, this.width, this.height); + this.drawCenteredString(fontRenderer, this.label, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, this.color); + if (this.field_146123_n && this.hoverText != null && this.hoverText.length > 0) { + this.parent.hoverText = this.hoverText; + } + } GL11.glPopMatrix(); } public ICustomGuiComponent toComponent() { ScriptGuiButton component = new ScriptGuiButton(this.id, this.label, this.xPosition, this.yPosition, this.width, this.height, this.texture.toString(), this.textureX, this.textureY); component.setHoverText(this.hoverText); + component.setColor(this.color); + component.setAlpha(this.alpha); return component; } - public void setColour(int colour) { - this.colour = colour; - } - protected int hoverState(boolean mouseOver) { int i = 0; if (mouseOver) { diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java index 1a7085efe..aab12ed58 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java @@ -22,7 +22,6 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { int x, y, width, height; GuiCustom parent; String fullLabel; - int color; String[] hoverText; float scale; int id; @@ -30,6 +29,9 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { boolean labelBgEnabled = true; boolean labelShadowEnabled = false; + int color; + float alpha; + protected int field_146167_a; protected int field_146161_f; public int field_146162_g; @@ -85,6 +87,8 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { lbl.hoverText = component.getHoverText(); } lbl.labelShadowEnabled = component.hasShadow(); + lbl.color = component.getColor(); + lbl.alpha = component.getAlpha(); return lbl; } @@ -93,6 +97,8 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { ScriptGuiLabel component = new ScriptGuiLabel(this.id, this.fullLabel, this.field_146162_g, this.field_146174_h, this.field_146167_a, this.field_146161_f, this.color); component.setHoverText(this.hoverText); component.enableShadow(this.labelShadowEnabled); + component.setColor(this.color); + component.setAlpha(this.alpha); return component; } @@ -106,6 +112,11 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { this.drawLabelBackground(); GL11.glPushMatrix(); + 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.x,this.y,0.0F); GL11.glScalef(this.scale, this.scale, this.scale); Minecraft.getMinecraft().fontRenderer.drawString(fullLabel, 0, 0, this.color, this.labelShadowEnabled); diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLine.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLine.java index 5bfcfe404..b4948aa6a 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLine.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLine.java @@ -9,6 +9,9 @@ import noppes.npcs.scripted.gui.ScriptGuiLine; import noppes.npcs.scripted.interfaces.ICustomGuiComponent; 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; + public class CustomGuiLine extends Gui implements IGuiComponent { int id; GuiCustom parent; @@ -17,6 +20,7 @@ public class CustomGuiLine extends Gui implements IGuiComponent { int x2; int y2; int color; + float alpha; int thickness; public CustomGuiLine(int id, int x1, int y1, int x2, int y2, int color, int thickness){ @@ -41,13 +45,13 @@ public class CustomGuiLine extends Gui implements IGuiComponent { public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) { double distance = Math.sqrt(Math.pow(x1-x2,2)+Math.pow(y1-y2,2)); - float red = (color >> 16 & 255) / 255f; - float green = (color >> 8 & 255) / 255f; - float blue = (color & 255) / 255f; - mc.getTextureManager().bindTexture(new ResourceLocation("customnpcs:textures/gui/misc.png")); GL11.glPushMatrix(); - GL11.glColor4f(red,green,blue,1.0F); + 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.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); @@ -56,10 +60,16 @@ public class CustomGuiLine extends Gui implements IGuiComponent { } public ICustomGuiComponent toComponent() { - return new ScriptGuiLine(this.id, this.x1,this.y1,this.x2,this.y2,this.color,this.thickness); + ScriptGuiLine line = new ScriptGuiLine(this.id, this.x1,this.y1,this.x2,this.y2,this.color,this.thickness); + line.setColor(this.color); + line.setAlpha(this.alpha); + return line; } public static CustomGuiLine fromComponent(ScriptGuiLine component) { - return new CustomGuiLine(component.getID(), component.getX1(), component.getY1(), component.getX2(), component.getY2(), component.getColor(), component.getThickness()); + CustomGuiLine line = new CustomGuiLine(component.getID(), component.getX1(), component.getY1(), component.getX2(), component.getY2(), component.getColor(), component.getThickness()); + line.color = component.getColor(); + line.alpha = component.getAlpha(); + return line; } } diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiScrollComponent.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiScrollComponent.java index eba41ba2c..26f626ad9 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiScrollComponent.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiScrollComponent.java @@ -25,6 +25,9 @@ public class CustomGuiScrollComponent extends GuiCustomScroll implements IDataHo String[] hoverText; public boolean multiSelect = false; + int color; + float alpha; + public CustomGuiScrollComponent(Minecraft mc, GuiScreen parent, int id) { super(parent, id); this.mc = mc; @@ -48,13 +51,17 @@ public class CustomGuiScrollComponent extends GuiCustomScroll implements IDataHo public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) { GL11.glPushMatrix(); - GL11.glTranslatef(0.0F, 0.0F, (float)this.id); - boolean hovered = mouseX >= this.guiLeft && mouseY >= this.guiTop && mouseX < this.guiLeft + this.xSize && mouseY < this.guiTop + this.ySize; - super.drawScreen(mouseX, mouseY, partialTicks, mouseWheel); - if (hovered && this.hoverText != null && this.hoverText.length > 0) { - this.parent.hoverText = this.hoverText; - } + 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(0.0F, 0.0F, (float)this.id); + boolean hovered = mouseX >= this.guiLeft && mouseY >= this.guiTop && mouseX < this.guiLeft + this.xSize && mouseY < this.guiTop + this.ySize; + super.drawScreen(mouseX, mouseY, partialTicks, mouseWheel); + if (hovered && this.hoverText != null && this.hoverText.length > 0) { + this.parent.hoverText = this.hoverText; + } GL11.glPopMatrix(); } @@ -79,11 +86,15 @@ public class CustomGuiScrollComponent extends GuiCustomScroll implements IDataHo this.hoverText = component.getHoverText(); } + this.color = component.getColor(); + this.alpha = component.getAlpha(); } public ICustomGuiComponent toComponent() { ScriptGuiScroll component = new ScriptGuiScroll(this.id, this.guiLeft - GuiCustom.guiLeft, this.guiTop - GuiCustom.guiTop, this.width, this.height, (String[])this.getList().toArray(new String[0])); component.setHoverText(this.hoverText); + component.setColor(color); + component.setAlpha(alpha); return component; } diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTextField.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTextField.java index 0e0c1eb73..876eccd41 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTextField.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTextField.java @@ -16,12 +16,16 @@ import noppes.npcs.client.gui.custom.interfaces.IKeyListener; import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.scripted.gui.ScriptGuiTextField; import noppes.npcs.scripted.interfaces.ICustomGuiComponent; +import org.lwjgl.opengl.GL11; public class CustomGuiTextField extends GuiTextField implements IKeyListener, IDataHolder, IClickListener { GuiCustom parent; String[] hoverText; int id; + int color; + float alpha; + public CustomGuiTextField(int id, int x, int y, int width, int height) { super(Minecraft.getMinecraft().fontRenderer, GuiCustom.guiLeft + x, GuiCustom.guiTop + y, width, height); this.id = id; @@ -34,7 +38,12 @@ public class CustomGuiTextField extends GuiTextField implements IKeyListener, ID public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) { boolean hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; + float red = (color >> 16 & 255) / 255f; + float green = (color >> 8 & 255) / 255f; + float blue = (color & 255) / 255f; + GL11.glColor4f(red,green,blue,this.alpha); this.drawTextBox(); + GL11.glColor4f(1.0F,1.0F,1.0F,1.0F); if (hovered && this.hoverText != null && this.hoverText.length > 0) { this.parent.hoverText = this.hoverText; } @@ -59,6 +68,8 @@ public class CustomGuiTextField extends GuiTextField implements IKeyListener, ID ScriptGuiTextField component = new ScriptGuiTextField(this.id, this.xPosition - GuiCustom.guiLeft, this.yPosition - GuiCustom.guiTop, this.width, this.height); component.setText(this.getText()); component.setHoverText(this.hoverText); + component.setColor(color); + component.setAlpha(alpha); return component; } @@ -72,6 +83,9 @@ public class CustomGuiTextField extends GuiTextField implements IKeyListener, ID txt.setText(component.getText()); } + txt.color = component.getColor(); + txt.alpha = component.getAlpha(); + return txt; } diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java index 992e024ca..0f480771c 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java @@ -15,6 +15,9 @@ import noppes.npcs.scripted.gui.ScriptGuiTexturedRect; import noppes.npcs.scripted.interfaces.ICustomGuiComponent; 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; + public class CustomGuiTexturedRect extends Gui implements IGuiComponent { GuiCustom parent; ResourceLocation texture; @@ -28,6 +31,9 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent { float scale; String[] hoverText; + int color; + float alpha; + public CustomGuiTexturedRect(int id, String texture, int x, int y, int width, int height) { this(id, texture, x, y, width, height, 0, 0); } @@ -57,7 +63,11 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent { mc.getTextureManager().bindTexture(this.texture); GL11.glPushMatrix(); - GL11.glColor4f(1.0F,1.0F,1.0F,1.0F); + 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.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)); GL11.glPopMatrix(); @@ -71,6 +81,8 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent { ScriptGuiTexturedRect component = new ScriptGuiTexturedRect(this.id, this.texture.toString(), this.x, this.y, this.width, this.height, this.textureX, this.textureY); component.setHoverText(this.hoverText); component.setScale(this.scale); + component.setColor(color); + component.setAlpha(alpha); return component; } @@ -87,6 +99,9 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent { rect.hoverText = component.getHoverText(); } + rect.color = component.getColor(); + rect.alpha = component.getAlpha(); + return rect; } } diff --git a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLabel.java b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLabel.java index 0d74aeaf9..c6302e318 100644 --- a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLabel.java +++ b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLabel.java @@ -13,6 +13,9 @@ import org.lwjgl.opengl.GL11; import java.util.ArrayList; +import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA; +import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA; + public class CustomOverlayLabel extends Gui implements IOverlayComponent { OverlayCustom parent; int alignment; @@ -70,13 +73,13 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { } public static CustomOverlayLabel fromComponent(ScriptOverlayLabel component) { - CustomOverlayLabel lbl = new CustomOverlayLabel(component.getID(), component.getText(), GuiCustom.guiLeft + component.getPosX(), GuiCustom.guiTop + component.getPosY(), component.getWidth(), component.getHeight(), component.hasShadow()); + 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.hasShadow(); + lbl.labelShadowEnabled = component.getShadow(); lbl.alignment = component.getAlignment(); lbl.alpha = component.getAlpha(); lbl.color = component.getColor(); @@ -86,7 +89,7 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { public ICustomOverlayComponent toComponent() { ScriptOverlayLabel component = new ScriptOverlayLabel(this.id, this.fullLabel, this.field_146162_g, this.field_146174_h, this.field_146167_a, this.field_146161_f, this.color); - component.enableShadow(this.labelShadowEnabled); + component.setShadow(this.labelShadowEnabled); component.setAlignment(alignment); component.setAlpha(alpha); component.setColor(color); diff --git a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLine.java b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLine.java index 8bac43c13..2c06ef275 100644 --- a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLine.java +++ b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLine.java @@ -2,6 +2,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.util.ResourceLocation; import noppes.npcs.client.gui.customoverlay.OverlayCustom; import noppes.npcs.client.gui.customoverlay.interfaces.IOverlayComponent; @@ -9,6 +10,9 @@ import noppes.npcs.scripted.interfaces.ICustomOverlayComponent; import noppes.npcs.scripted.overlay.ScriptOverlayLine; 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; + public class CustomOverlayLine extends Gui implements IOverlayComponent { OverlayCustom parent; int alignment; diff --git a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayTexturedRect.java b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayTexturedRect.java index 9d5917d94..323552240 100644 --- a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayTexturedRect.java +++ b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayTexturedRect.java @@ -2,6 +2,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.util.ResourceLocation; import noppes.npcs.client.gui.customoverlay.OverlayCustom; import noppes.npcs.client.gui.customoverlay.interfaces.IOverlayComponent; @@ -9,6 +10,9 @@ 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; + public class CustomOverlayTexturedRect extends Gui implements IOverlayComponent { OverlayCustom parent; int alignment; diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiComponent.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiComponent.java index 4ae43e774..68158b762 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiComponent.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiComponent.java @@ -4,6 +4,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; import noppes.npcs.scripted.interfaces.ICustomGuiComponent; +import noppes.npcs.scripted.interfaces.ICustomOverlayComponent; public abstract class ScriptGuiComponent implements ICustomGuiComponent { int id; @@ -11,6 +12,9 @@ public abstract class ScriptGuiComponent implements ICustomGuiComponent { int posY; String[] hoverText; + int color = 0xFFFFFF; + float alpha = 1.0F; + public ScriptGuiComponent() { } @@ -55,11 +59,30 @@ public abstract class ScriptGuiComponent implements ICustomGuiComponent { return this; } + public int getColor() { + return this.color; + } + + public ICustomGuiComponent setColor(int color) { + this.color = color; + return this; + } + + public float getAlpha() { + return this.alpha; + } + + public void setAlpha(float alpha) { + this.alpha = alpha; + } + public abstract int getType(); public NBTTagCompound toNBT(NBTTagCompound nbt) { nbt.setInteger("id", this.id); nbt.setIntArray("pos", new int[]{this.posX, this.posY}); + nbt.setInteger("color", this.color); + nbt.setFloat("alpha",this.alpha); if (this.hoverText != null) { NBTTagList list = new NBTTagList(); String[] var3 = this.hoverText; @@ -84,6 +107,8 @@ public abstract class ScriptGuiComponent implements ICustomGuiComponent { public ScriptGuiComponent fromNBT(NBTTagCompound nbt) { this.setID(nbt.getInteger("id")); this.setPos(nbt.getIntArray("pos")[0], nbt.getIntArray("pos")[1]); + this.setColor(nbt.getInteger("color")); + this.setAlpha(nbt.getFloat("alpha")); if (nbt.hasKey("hover")) { NBTTagList list = nbt.getTagList("hover", 8); String[] hoverText = new String[list.tagCount()]; diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLabel.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLabel.java index c4e36ec20..bba1444d2 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLabel.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLabel.java @@ -7,17 +7,14 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel { String label; int width; int height; - int color; float scale; boolean shadow; public ScriptGuiLabel() { - this.color = 16777215; this.scale = 1.0F; } public ScriptGuiLabel(int id, String label, int x, int y, int width, int height) { - this.color = 16777215; this.scale = 1.0F; this.setID(id); this.setText(label); @@ -54,15 +51,6 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel { return this; } - public int getColor() { - return this.color; - } - - public ILabel setColor(int color) { - this.color = color; - return this; - } - public float getScale() { return this.scale; } @@ -88,7 +76,6 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel { super.toNBT(nbt); nbt.setString("label", this.label); nbt.setIntArray("size", new int[]{this.width, this.height}); - nbt.setInteger("color", this.color); nbt.setFloat("scale", this.scale); nbt.setBoolean("shadow",this.shadow); return nbt; @@ -98,7 +85,6 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel { super.fromNBT(nbt); this.setText(nbt.getString("label")); this.setSize(nbt.getIntArray("size")[0], nbt.getIntArray("size")[1]); - this.setColor(nbt.getInteger("color")); this.setScale(nbt.getFloat("scale")); this.enableShadow(nbt.getBoolean("shadow")); return this; diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLine.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLine.java index 69c72a711..c59a425c0 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLine.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLine.java @@ -8,7 +8,6 @@ public class ScriptGuiLine extends ScriptGuiComponent implements ILine { int y1; int x2; int y2; - int color = 0; int thickness = 2; public ScriptGuiLine(){ @@ -49,7 +48,6 @@ public class ScriptGuiLine extends ScriptGuiComponent implements ILine { nbt.setInteger("Y1",y1); nbt.setInteger("X2",x2); nbt.setInteger("Y2",y2); - nbt.setInteger("Color",color); nbt.setInteger("Thickness",thickness); return nbt; @@ -61,7 +59,6 @@ public class ScriptGuiLine extends ScriptGuiComponent implements ILine { y1 = nbt.getInteger("Y1"); x2 = nbt.getInteger("X2"); y2 = nbt.getInteger("Y2"); - color = nbt.getInteger("Color"); thickness = nbt.getInteger("Thickness"); return this; @@ -79,9 +76,6 @@ public class ScriptGuiLine extends ScriptGuiComponent implements ILine { public int getY2(){ return this.y2; } - public int getColor(){ - return this.color; - } public int getThickness(){ return this.thickness; } @@ -98,9 +92,6 @@ public class ScriptGuiLine extends ScriptGuiComponent implements ILine { public void setY2(int y2){ this.y2 = y2; } - public void setColor(int color){ - this.color = color; - } public void setThickness(int thickness){ this.thickness = thickness; } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ILabel.java b/src/main/java/noppes/npcs/scripted/interfaces/ILabel.java index 6e3b00e99..30a09704f 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ILabel.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ILabel.java @@ -16,10 +16,6 @@ public interface ILabel extends ICustomGuiComponent { ILabel setSize(int var1, int var2); - int getColor(); - - ILabel setColor(int var1); - float getScale(); ILabel setScale(float var1); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ILine.java b/src/main/java/noppes/npcs/scripted/interfaces/ILine.java index b1a6690b0..2ea987d5c 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ILine.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ILine.java @@ -5,13 +5,11 @@ public interface ILine extends ICustomGuiComponent { int getY1(); int getX2(); int getY2(); - int getColor(); int getThickness(); void setX1(int x1); void setY1(int y1); void setX2(int x2); void setY2(int y2); - void setColor(int color); void setThickness(int thickness); } diff --git a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayComponent.java b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayComponent.java index 10891007f..edbcab83d 100644 --- a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayComponent.java +++ b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayComponent.java @@ -92,7 +92,7 @@ public abstract class ScriptOverlayComponent implements ICustomOverlayComponent this.setPos(nbt.getIntArray("pos")[0], nbt.getIntArray("pos")[1]); this.setAlignment(nbt.getInteger("alignment")); this.setColor(nbt.getInteger("color")); - this.setAlpha(nbt.getInteger("alpha")); + this.setAlpha(nbt.getFloat("alpha")); return this; } diff --git a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayLabel.java b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayLabel.java index 2394e0a72..3e2e041ad 100644 --- a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayLabel.java +++ b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayLabel.java @@ -24,7 +24,7 @@ public class ScriptOverlayLabel extends ScriptOverlayComponent implements IOverl this.setText(label); this.setPos(x, y); this.setSize(width, height); - this.enableShadow(false); + this.setShadow(false); } public ScriptOverlayLabel(int id, String label, int x, int y, int width, int height, int color) { @@ -64,11 +64,11 @@ public class ScriptOverlayLabel extends ScriptOverlayComponent implements IOverl return this; } - public boolean hasShadow(){ + public boolean getShadow(){ return this.shadow; } - public void enableShadow(boolean shadow){ + public void setShadow(boolean shadow){ this.shadow = shadow; } @@ -91,7 +91,7 @@ public class ScriptOverlayLabel extends ScriptOverlayComponent implements IOverl this.setText(nbt.getString("label")); this.setSize(nbt.getIntArray("size")[0], nbt.getIntArray("size")[1]); this.setScale(nbt.getFloat("scale")); - this.enableShadow(nbt.getBoolean("shadow")); + this.setShadow(nbt.getBoolean("shadow")); return this; } }