Skip to content

Commit

Permalink
make icon a record
Browse files Browse the repository at this point in the history
  • Loading branch information
Mari023 committed Jun 29, 2024
1 parent 07e5912 commit d8105c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
18 changes: 2 additions & 16 deletions src/main/java/de/mari_023/ae2wtlib/terminal/Icon.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
/**
* Edit in {@code assets/ae2/textures/wtlib/guis/icons.png}.
*/
public class Icon {
public record Icon(int x, int y, int width, int height, Texture texture) {

public static final Texture TEXTURE = new Texture(AppEng.makeId("textures/wtlib/guis/icons.png"), 128, 128);
public static final Texture AE2TEXTURE = new Texture(appeng.client.gui.Icon.TEXTURE,
appeng.client.gui.Icon.TEXTURE_WIDTH, appeng.client.gui.Icon.TEXTURE_HEIGHT);
Expand Down Expand Up @@ -48,12 +49,6 @@ public class Icon {
public static final Icon UPGRADE_BACKGROUND_SCROLLING_MIDDLE = new Icon(53, 85, 29, 18);
public static final Icon UPGRADE_BACKGROUND_SCROLLING_BOTTOM = new Icon(53, 103, 29, 25);

public final Texture texture;
public final int x;
public final int y;
public final int width;
public final int height;

private Icon(int x, int y) {
this(x, y, 16, 16);
}
Expand All @@ -62,19 +57,10 @@ private Icon(int x, int y, int width, int height) {
this(x, y, width, height, TEXTURE);
}

public Icon(int x, int y, int width, int height, Texture texture) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.texture = texture;
}

public Blitter getBlitter() {
return Blitter.texture(texture.location(), texture.width(), texture.height())
.src(x, y, width, height);
}

public record Texture(ResourceLocation location, int width, int height) {
}
}
8 changes: 4 additions & 4 deletions src/main/java/de/mari_023/ae2wtlib/terminal/IconButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float

var yOffset = isHoveredOrFocused() ? 1 : 0;
var bg = getBG();
var bgSizeOffset = bg.width > 16 ? 1 : 0;
var bgSizeOffset = bg.width() > 16 ? 1 : 0;

bg.getBlitter()
.dest(getX() - 1, getY() + yOffset, bg.width, bg.height)
.dest(getX() - 1, getY() + yOffset, bg.width(), bg.height())
.zOffset(2)
.blit(guiGraphics);
getIcon().getBlitter().dest(getX() - 1 + bgSizeOffset, getY() + bgSizeOffset + yOffset).zOffset(3)
Expand All @@ -77,8 +77,8 @@ public Rect2i getTooltipArea() {
return new Rect2i(
getX(),
getY(),
getBG().width,
getBG().height);
getBG().width(),
getBG().height());
}

@Override
Expand Down

0 comments on commit d8105c3

Please sign in to comment.