add armor slot textures

This commit is contained in:
Sen 2025-08-07 16:43:48 +02:00
parent 3960bff398
commit 2eda9771ad
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
14 changed files with 27 additions and 11 deletions

View file

@ -210,8 +210,12 @@ public abstract class GuiContainer extends Gui
Drawing.drawGradient(this.container_x + x * this.container_scale, this.container_y + y * this.container_scale, width * this.container_scale, height * this.container_scale, 0xff000000 | top, 0xff000000 | bottom, 0xff000000 | topleft, 0xff000000 | btmright);
}
public InventoryButton slot(int x, int y, int w, int h, Slot slot) {
return this.add(new InventoryButton(this.container_x + x * this.container_scale, this.container_y + y * this.container_scale, w * this.container_scale, h * this.container_scale, this.container_scale > 1, slot));
}
public InventoryButton slot(int x, int y, int w, int h) {
return this.add(new InventoryButton(this.container_x + x * this.container_scale, this.container_y + y * this.container_scale, w * this.container_scale, h * this.container_scale, this.container_scale > 1));
return this.slot(x, y, w, h, null);
}
public ActButton button(int x, int y, int w, int h, ButtonCallback callback, String text) {
@ -276,8 +280,8 @@ public abstract class GuiContainer extends Gui
public void addButtons() {
if(this.inventorySlots != null) {
for (int i1 = 0; i1 < this.inventorySlots.inventorySlots.size(); ++i1) {
Slot slot = (Slot)this.inventorySlots.inventorySlots.get(i1);
this.slot(slot.xDisplayPosition - 1, slot.yDisplayPosition - 1, 18, 18);
Slot slot = this.inventorySlots.inventorySlots.get(i1);
this.slot(slot.xDisplayPosition - 1, slot.yDisplayPosition - 1, 18, 18, slot);
}
}
if(this.gm.itemCheat) {
@ -286,7 +290,7 @@ public abstract class GuiContainer extends Gui
this.cheatSearch = this.add(new Field(this.cheatX, this.cheatY + this.cheatHeight * 18 + 20 * ((CheatTab.values().length + (this.cheatWidth - 1)) / this.cheatWidth) + 4, this.cheatWidth * 18, 0, 128, null, ""));
this.cheatLast = "";
for(CheatTab tab : CheatTab.values()) {
this.add(new InventoryButton(this.cheatX + 18 * (tab.getIndex() % this.cheatWidth), this.cheatY + this.cheatHeight * 18 + 4 + 20 * (tab.getIndex() / this.cheatWidth), 18, 18, false));
this.add(new InventoryButton(this.cheatX + 18 * (tab.getIndex() % this.cheatWidth), this.cheatY + this.cheatHeight * 18 + 4 + 20 * (tab.getIndex() / this.cheatWidth), 18, 18, false, null));
}
this.setCurrentTab(selectedTab);
}

View file

@ -1,17 +1,26 @@
package client.gui.element;
import client.renderer.Drawing;
import common.inventory.Slot;
public class InventoryButton extends Element {
private final boolean bordered;
private final Slot slot;
private final String texture;
public InventoryButton(int x, int y, int w, int h, boolean bordered) {
public InventoryButton(int x, int y, int w, int h, boolean bordered, Slot slot) {
super(x, y, w, h, null);
this.bordered = bordered;
this.texture = slot == null || slot.getTexture() == null ? null : "textures/items/icon_" + slot.getTexture() + ".png";
this.slot = this.texture == null ? null : slot;
}
protected void drawBackground() {
drawButton(this.pos_x, this.pos_y, this.size_x, this.size_y, this.bordered);
if(this.texture != null && !this.slot.getHasStack()) {
int scale = this.bordered ? 2 : 1;
Drawing.drawTexturedRect(this.gm, this.texture, 16 * scale, 16 * scale, this.pos_x + scale, this.pos_y + scale, 0, 0, this.size_x - scale * 2, this.size_y - scale * 2);
}
}
protected void drawForeground(int x1, int y1, int x2, int y2) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB