Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/main/java/de/eydamos/guiadvanced/ContainerWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import de.eydamos.guiadvanced.misc.AbstractGui;
import de.eydamos.guiadvanced.misc.AbstractGuiPart;
import de.eydamos.guiadvanced.util.Rectangle;
import de.eydamos.guiadvanced.util.RenderHelper;

public class ContainerWindow extends GuiContainer implements AbstractGui {
Expand Down Expand Up @@ -69,15 +70,18 @@ public void clearSubParts() {
@Override
protected void drawGuiContainerBackgroundLayer(float something, int mouseX, int mouseY) {
// draw background
RenderHelper.drawOuterCornerTopLeft(guiLeft, guiTop);
RenderHelper.drawBorderTop(guiLeft + 4, guiTop, xSize - 8, 4);
RenderHelper.drawOuterCornerTopRight(guiLeft + xSize - 4, guiTop);
RenderHelper.drawBorderLeft(guiLeft, guiTop + 4, 4, ySize - 8);
RenderHelper.drawBackground(guiLeft + 4, guiTop + 4, xSize - 8, ySize - 8);
RenderHelper.drawBorderRight(guiLeft + xSize - 4, guiTop + 4, 4, ySize - 8);
RenderHelper.drawOuterCornerBottomLeft(guiLeft, guiTop + ySize - 4);
RenderHelper.drawBorderBottom(guiLeft + 4, guiTop + ySize - 4, xSize - 8, 4);
RenderHelper.drawOuterCornerBottomRight(guiLeft + xSize - 4, guiTop + ySize - 4);
Rectangle rect = new Rectangle();
rect.startDrawing();
RenderHelper.drawOuterCornerTopLeft(rect, guiLeft, guiTop);
RenderHelper.drawBorderTop(rect, guiLeft + 4, guiTop, xSize - 8, 4);
RenderHelper.drawOuterCornerTopRight(rect, guiLeft + xSize - 4, guiTop);
RenderHelper.drawBorderLeft(rect, guiLeft, guiTop + 4, 4, ySize - 8);
RenderHelper.drawBackground(rect, guiLeft + 4, guiTop + 4, xSize - 8, ySize - 8);
RenderHelper.drawBorderRight(rect, guiLeft + xSize - 4, guiTop + 4, 4, ySize - 8);
RenderHelper.drawOuterCornerBottomLeft(rect, guiLeft, guiTop + ySize - 4);
RenderHelper.drawBorderBottom(rect, guiLeft + 4, guiTop + ySize - 4, xSize - 8, 4);
RenderHelper.drawOuterCornerBottomRight(rect, guiLeft + xSize - 4, guiTop + ySize - 4);
rect.performDrawing();

// draw subparts
for (AbstractGuiPart guiPart : subParts) {
Expand Down
22 changes: 13 additions & 9 deletions src/main/java/de/eydamos/guiadvanced/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import de.eydamos.guiadvanced.misc.AbstractGui;
import de.eydamos.guiadvanced.misc.AbstractGuiPart;
import de.eydamos.guiadvanced.util.Rectangle;
import de.eydamos.guiadvanced.util.RenderHelper;

public class Window extends GuiScreen implements AbstractGui {
Expand Down Expand Up @@ -69,15 +70,18 @@ public void clearSubParts() {
@Override
public void drawScreen(int mouseX, int mouseY, float something) {
// draw background
RenderHelper.drawOuterCornerTopLeft(guiLeft, guiTop);
RenderHelper.drawBorderTop(guiLeft + 4, guiTop, xSize - 8, 4);
RenderHelper.drawOuterCornerTopRight(guiLeft + xSize - 4, guiTop);
RenderHelper.drawBorderLeft(guiLeft, guiTop + 4, 4, ySize - 8);
RenderHelper.drawBackground(guiLeft + 4, guiTop + 4, xSize - 8, ySize - 8);
RenderHelper.drawBorderRight(guiLeft + xSize - 4, guiTop + 4, 4, ySize - 8);
RenderHelper.drawOuterCornerBottomLeft(guiLeft, guiTop + ySize - 4);
RenderHelper.drawBorderBottom(guiLeft + 4, guiTop + ySize - 4, xSize - 8, 4);
RenderHelper.drawOuterCornerBottomRight(guiLeft + xSize - 4, guiTop + ySize - 4);
Rectangle rect = new Rectangle();
rect.startDrawing();
RenderHelper.drawOuterCornerTopLeft(rect, guiLeft, guiTop);
RenderHelper.drawBorderTop(rect, guiLeft + 4, guiTop, xSize - 8, 4);
RenderHelper.drawOuterCornerTopRight(rect, guiLeft + xSize - 4, guiTop);
RenderHelper.drawBorderLeft(rect, guiLeft, guiTop + 4, 4, ySize - 8);
RenderHelper.drawBackground(rect, guiLeft + 4, guiTop + 4, xSize - 8, ySize - 8);
RenderHelper.drawBorderRight(rect, guiLeft + xSize - 4, guiTop + 4, 4, ySize - 8);
RenderHelper.drawOuterCornerBottomLeft(rect, guiLeft, guiTop + ySize - 4);
RenderHelper.drawBorderBottom(rect, guiLeft + 4, guiTop + ySize - 4, xSize - 8, 4);
RenderHelper.drawOuterCornerBottomRight(rect, guiLeft + xSize - 4, guiTop + ySize - 4);
rect.performDrawing();

// draw subparts
for (AbstractGuiPart guiPart : subParts) {
Expand Down
20 changes: 11 additions & 9 deletions src/main/java/de/eydamos/guiadvanced/form/Button.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,47 +69,49 @@ public void drawButton(Minecraft mc, int mouseX, int mouseY) {
Rectangle rectangle = new Rectangle(2, 2);
rectangle.setBackground(buttonTextures);
rectangle.setBackgroundSize(2, 2);
rectangle.startDrawing();
// draw upper left corner
rectangle.setBackgroundPosition(0, 46 + offset * 20);
rectangle.draw(xPosition, yPosition);
rectangle.addBoxVertices(xPosition, yPosition);
// draw upper right corner
rectangle.setBackgroundPosition(198, 46 + offset * 20);
rectangle.draw(xPosition + width - 2, yPosition);
rectangle.addBoxVertices(xPosition + width - 2, yPosition);
// draw lower left corner
rectangle.setBackgroundPosition(0, 64 + offset * 20);
rectangle.draw(xPosition, yPosition + height - 2);
rectangle.addBoxVertices(xPosition, yPosition + height - 2);
// draw lower right corner
rectangle.setBackgroundPosition(198, 64 + offset * 20);
rectangle.draw(xPosition + width - 2, yPosition + height - 2);
rectangle.addBoxVertices(xPosition + width - 2, yPosition + height - 2);

// borders top/bottom
rectangle.setWidth(width - 4);
rectangle.setBackgroundRepeat(BackgroundRepeat.REPEAT_X);
// draw top border
rectangle.setBackgroundPosition(2, 46 + offset * 20);
rectangle.draw(xPosition + 2, yPosition);
rectangle.addBoxVertices(xPosition + 2, yPosition);
// draw bottom border
rectangle.setBackgroundPosition(2, 64 + offset * 20);
rectangle.draw(xPosition + 2, yPosition + height - 2);
rectangle.addBoxVertices(xPosition + 2, yPosition + height - 2);

// borders left/right
rectangle.setWidth(2);
rectangle.setHeight(height - 4);
rectangle.setBackgroundRepeat(BackgroundRepeat.REPEAT_Y);
// draw left border
rectangle.setBackgroundPosition(0, 48 + offset * 20);
rectangle.draw(xPosition, yPosition + 2);
rectangle.addBoxVertices(xPosition, yPosition + 2);
// draw right border
rectangle.setBackgroundPosition(198, 48 + offset * 20);
rectangle.draw(xPosition + width - 2, yPosition + 2);
rectangle.addBoxVertices(xPosition + width - 2, yPosition + 2);

// draw background
rectangle.setWidth(width - 4);
rectangle.setHeight(height - 4);
rectangle.setBackgroundSize(18, 18);
rectangle.setBackgroundRepeat(BackgroundRepeat.REPEAT);
rectangle.setBackgroundPosition(2, 48 + offset * 20);
rectangle.draw(xPosition + 2, yPosition + 2);
rectangle.addBoxVertices(xPosition + 2, yPosition + 2);
rectangle.performDrawing();

mouseDragged(mc, mouseX, mouseY);
int l = 14737632;
Expand Down
20 changes: 11 additions & 9 deletions src/main/java/de/eydamos/guiadvanced/subpart/GuiSlot.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,47 +53,49 @@ public void setHeight(int value) {
@Override
public void draw(Minecraft mc, int mouseX, int mouseY, float something) {
Rectangle rectangle = new Rectangle(1, 1);
rectangle.startDrawing();
// draw upper left corner
rectangle.setBackgroundPosition(201, 0);
rectangle.draw(xPosition, yPosition);
rectangle.addBoxVertices(xPosition, yPosition);
// draw upper right corner
rectangle.setBackgroundPosition(218, 0);
rectangle.draw(xPosition + width - 1, yPosition);
rectangle.addBoxVertices(xPosition + width - 1, yPosition);
// draw lower left corner
rectangle.setBackgroundPosition(201, 17);
rectangle.draw(xPosition, yPosition + height - 1);
rectangle.addBoxVertices(xPosition, yPosition + height - 1);
// draw lower right corner
rectangle.setBackgroundPosition(218, 17);
rectangle.draw(xPosition + width - 1, yPosition + height - 1);
rectangle.addBoxVertices(xPosition + width - 1, yPosition + height - 1);

// borders top/bottom
rectangle.setWidth(width - 2);
rectangle.setBackgroundRepeat(BackgroundRepeat.REPEAT_X);
// draw top border
rectangle.setBackgroundPosition(202, 0);
rectangle.draw(xPosition + 1, yPosition);
rectangle.addBoxVertices(xPosition + 1, yPosition);
// draw bottom border
rectangle.setBackgroundPosition(202, 17);
rectangle.draw(xPosition + 1, yPosition + height - 1);
rectangle.addBoxVertices(xPosition + 1, yPosition + height - 1);

// borders left/right
rectangle.setWidth(1);
rectangle.setHeight(height - 2);
rectangle.setBackgroundRepeat(BackgroundRepeat.REPEAT_Y);
// draw left border
rectangle.setBackgroundPosition(201, 1);
rectangle.draw(xPosition, yPosition + 1);
rectangle.addBoxVertices(xPosition, yPosition + 1);
// draw right border
rectangle.setBackgroundPosition(218, 1);
rectangle.draw(xPosition + width - 1, yPosition + 1);
rectangle.addBoxVertices(xPosition + width - 1, yPosition + 1);

// draw background
rectangle.setWidth(width - 2);
rectangle.setHeight(height - 2);
rectangle.setBackgroundSize(14, 14);
rectangle.setBackgroundRepeat(BackgroundRepeat.REPEAT);
rectangle.setBackgroundPosition(202, 1);
rectangle.draw(xPosition + 1, yPosition + 1);
rectangle.addBoxVertices(xPosition + 1, yPosition + 1);
rectangle.performDrawing();
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/de/eydamos/guiadvanced/subpart/Icon.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ public void setHeight(int value) {
@Override
public void draw(Minecraft mc, int mouseX, int mouseY, float something) {
Rectangle icon = new Rectangle(width, height);
icon.startDrawing();
if (image != null) {
icon.setBackground(image);
}
icon.setBackgroundPosition(uPosition, vPosition);
icon.setBackgroundSize(width, height);
icon.draw(xPosition, yPosition);
icon.addBoxVertices(xPosition, yPosition);
icon.performDrawing();
}

@Override
Expand Down
29 changes: 15 additions & 14 deletions src/main/java/de/eydamos/guiadvanced/util/Rectangle.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public class Rectangle {
protected ResourceLocation graphic = Constants.guiCombined;
protected BackgroundRepeat repeat = BackgroundRepeat.NONE;

public Rectangle() {
this(0, 0);
}

public Rectangle(int width, int height) {
this.width = width;
this.height = height;
Expand Down Expand Up @@ -57,20 +61,19 @@ public void setBackground(ResourceLocation resourceLocation) {
graphic = resourceLocation;
}

public void draw(int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
getMinecraft().getTextureManager().bindTexture(graphic);
public void startDrawing() {
Tessellator.instance.startDrawingQuads();
}

public void addBoxVertices(int x, int y) {
Tessellator tessellator = Tessellator.instance;
float f = 0.00390625F;
float f1 = 0.00390625F;
Tessellator tessellator = Tessellator.instance;
if (repeat == BackgroundRepeat.NONE) {
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(x, y + height, z, u * f, (v + height) * f1);
tessellator.addVertexWithUV(x + width, y + height, z, (u + width) * f, (v + height) * f1);
tessellator.addVertexWithUV(x + width, y, z, (u + width) * f, v * f1);
tessellator.addVertexWithUV(x, y, z, u * f, v * f1);
tessellator.draw();
} else if (repeat == BackgroundRepeat.REPEAT) {
uMax = Math.min(width, uMax);
vMax = Math.min(height, vMax);
Expand All @@ -79,45 +82,43 @@ public void draw(int x, int y) {
for (int j = 0; j <= height; j += vMax) {
drawWidth = Math.min(i + uMax, width);
drawHeight = Math.min(j + vMax, height);
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(x + i, y + drawHeight, z, u * f, (v + vMax) * f1);
tessellator.addVertexWithUV(x + drawWidth, y + drawHeight, z, (u + uMax) * f, (v + vMax) * f1);
tessellator.addVertexWithUV(x + drawWidth, y, z, (u + uMax) * f, v * f1);
tessellator.addVertexWithUV(x + i, y, z, u * f, v * f1);
tessellator.draw();
}
}
} else if (repeat == BackgroundRepeat.REPEAT_X) {
int drawHeight = vMax = Math.min(height, vMax);
int drawWidth;
for (int i = 0; i <= width; i += uMax) {
drawWidth = Math.min(i + uMax, width);
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(x + i, y + drawHeight, z, u * f, (v + drawHeight) * f1);
tessellator.addVertexWithUV(x + drawWidth, y + drawHeight, z, (u + uMax) * f, (v + drawHeight) * f1);
tessellator.addVertexWithUV(x + drawWidth, y, z, (u + uMax) * f, v * f1);
tessellator.addVertexWithUV(x + i, y, z, u * f, v * f1);
tessellator.draw();
}
} else if (repeat == BackgroundRepeat.REPEAT_Y) {
int drawWidth = uMax = Math.min(width, uMax);
int drawHeight;
for (int i = 0; i <= height; i += vMax) {
drawHeight = Math.min(i + vMax, height);
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(x, y + drawHeight, z, u * f, (v + vMax) * f1);
tessellator.addVertexWithUV(x + drawWidth, y + drawHeight, z, (u + drawWidth) * f, (v + vMax) * f1);
tessellator.addVertexWithUV(x + drawWidth, y + i, z, (u + drawWidth) * f, v * f1);
tessellator.addVertexWithUV(x, y + i, z, u * f, v * f1);
tessellator.draw();
}
} else {
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(x, y + height, z, u * f, vMax * f1);
tessellator.addVertexWithUV(x + width, y + height, z, uMax * f, vMax * f1);
tessellator.addVertexWithUV(x + width, y, z, uMax * f, v * f1);
tessellator.addVertexWithUV(x, y, z, u * f, v * f1);
tessellator.draw();
}
}

public void performDrawing() {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
getMinecraft().getTextureManager().bindTexture(graphic);
Tessellator.instance.draw();
}
}
Loading