GuiArrowButton now draws from Texture instead of awful calculations
This commit is contained in:
@@ -1,13 +1,25 @@
|
|||||||
package eu.crushedpixel.replaymod.gui.elements;
|
package eu.crushedpixel.replaymod.gui.elements;
|
||||||
|
|
||||||
|
import eu.crushedpixel.replaymod.gui.overlay.GuiReplayOverlay;
|
||||||
|
import eu.crushedpixel.replaymod.utils.OpenGLUtils;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
public class GuiArrowButton extends GuiAdvancedButton {
|
public class GuiArrowButton extends GuiAdvancedButton {
|
||||||
|
|
||||||
|
private static final int TEXTURE_X = 40;
|
||||||
|
private static final int TEXTURE_Y = 80;
|
||||||
|
private static final int TEXTURE_WIDTH = 12;
|
||||||
|
private static final int TEXTURE_HEIGHT = 12;
|
||||||
|
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
public enum Direction {
|
public enum Direction {
|
||||||
UP, DOWN, RIGHT, LEFT
|
UP(-90), DOWN(90), RIGHT(0), LEFT(180);
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private int rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Direction dir;
|
private Direction dir;
|
||||||
@@ -20,30 +32,23 @@ public class GuiArrowButton extends GuiAdvancedButton {
|
|||||||
height = 20;
|
height = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
|
||||||
|
draw(mc, mouseX, mouseY);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Minecraft mc, int mouseX, int mouseY, boolean hovering) {
|
public void draw(Minecraft mc, int mouseX, int mouseY, boolean hovering) {
|
||||||
try {
|
try {
|
||||||
super.draw(mc, mouseX, mouseY, hovering);
|
super.draw(mc, mouseX, mouseY, hovering);
|
||||||
if(dir == Direction.UP) {
|
|
||||||
for(int i = 0; i <= Math.ceil(height / 2) - 5; i++) {
|
mc.getTextureManager().bindTexture(GuiReplayOverlay.replay_gui);
|
||||||
drawHorizontalLine(xPosition + width - height + i + 4, xPosition + width - i - 6, yPosition + height - ((height / 3) + i + 2), Color.BLACK.getRGB());
|
|
||||||
}
|
OpenGLUtils.drawRotatedRectWithCustomSizedTexture(xPosition+4, yPosition+4, dir.getRotation(),
|
||||||
} else if(dir == Direction.DOWN) {
|
TEXTURE_X, TEXTURE_Y, TEXTURE_WIDTH, TEXTURE_HEIGHT, 128, 128);
|
||||||
for(int i = 0; i <= Math.ceil(height / 2) - 5; i++) {
|
|
||||||
drawHorizontalLine(xPosition + width - height + i + 4, xPosition + width - i - 6, yPosition + (height / 3) + i + 2, Color.BLACK.getRGB());
|
|
||||||
}
|
|
||||||
} else if(dir == Direction.LEFT) {
|
|
||||||
for(int i = -1; i < Math.ceil(height / 2) - 5; i++) {
|
|
||||||
drawVerticalLine(xPosition + height - ((height / 3) + i + 4), yPosition + width - height + i + 4, yPosition + width - i - 6, Color.BLACK.getRGB());
|
|
||||||
}
|
|
||||||
} else if(dir == Direction.RIGHT) {
|
|
||||||
for(int i = -1; i < Math.ceil(height / 2) - 5; i++) {
|
|
||||||
drawVerticalLine(xPosition + (height / 3) + i + 2, yPosition + width - height + i + 4, yPosition + width - i - 6, Color.BLACK.getRGB());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 8.5 KiB |
Reference in New Issue
Block a user