Cleanup SideButton a bit.
This commit is contained in:
@@ -264,10 +264,10 @@ public abstract class BaseScreen<T extends Container> extends ContainerScreen<T>
|
||||
}
|
||||
|
||||
public void addSideButton(SideButton button) {
|
||||
button.x = guiLeft + -SideButton.WIDTH - 2;
|
||||
button.x = guiLeft - button.getWidth() - 2;
|
||||
button.y = guiTop + sideButtonY;
|
||||
|
||||
sideButtonY += SideButton.HEIGHT + 2;
|
||||
sideButtonY += button.getHeight() + 2;
|
||||
|
||||
this.addButton(button);
|
||||
}
|
||||
|
@@ -10,14 +10,16 @@ import net.minecraft.util.text.StringTextComponent;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public abstract class SideButton extends Button {
|
||||
public static final int WIDTH = 18;
|
||||
public static final int HEIGHT = 18;
|
||||
private static final Button.IPressable NO_ACTION = btn -> {
|
||||
};
|
||||
|
||||
private static final int WIDTH = 18;
|
||||
private static final int HEIGHT = 18;
|
||||
|
||||
protected final BaseScreen<?> screen;
|
||||
|
||||
public SideButton(BaseScreen<?> screen) {
|
||||
super(-1, -1, 18, 18, new StringTextComponent(""), btn -> {
|
||||
});
|
||||
super(-1, -1, WIDTH, HEIGHT, StringTextComponent.EMPTY, NO_ACTION);
|
||||
|
||||
this.screen = screen;
|
||||
}
|
||||
@@ -30,7 +32,7 @@ public abstract class SideButton extends Button {
|
||||
isHovered = RenderUtils.inBounds(x, y, width, height, mouseX, mouseY);
|
||||
|
||||
screen.bindTexture(RS.ID, "icons.png");
|
||||
screen.blit(matrixStack, x, y, 238, isHovered ? 35 : 16, 18, 18);
|
||||
screen.blit(matrixStack, x, y, 238, isHovered ? 35 : 16, WIDTH, HEIGHT);
|
||||
|
||||
renderButtonIcon(matrixStack, x + 1, y + 1);
|
||||
|
||||
@@ -38,11 +40,15 @@ public abstract class SideButton extends Button {
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
screen.blit(matrixStack, x, y, 238, 54, 18, 18);
|
||||
screen.blit(matrixStack, x, y, 238, 54, WIDTH, HEIGHT);
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
protected abstract void renderButtonIcon(MatrixStack matrixStack, int x, int y);
|
||||
|
||||
public abstract String getTooltip();
|
||||
|
Reference in New Issue
Block a user