improve container gui
This commit is contained in:
parent
c8d4b8a48e
commit
f63ec691eb
9 changed files with 81 additions and 70 deletions
|
@ -12,8 +12,8 @@ public class GuiChest extends GuiContainer {
|
|||
super(new ContainerChest(player, chest));
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label(this.block.getDisplay(), 16, 32);
|
||||
|
||||
public String getTitle() {
|
||||
return this.block.getDisplay();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,6 +90,9 @@ public abstract class GuiContainer extends Gui
|
|||
private Field cheatSearch;
|
||||
private String cheatLast;
|
||||
private Label inventoryLabel;
|
||||
|
||||
private int controlX;
|
||||
private int controlY;
|
||||
|
||||
public static String formatAmount(int amount) {
|
||||
if(amount < 0)
|
||||
|
@ -191,26 +194,6 @@ public abstract class GuiContainer extends Gui
|
|||
&& slot.canCheatItem() && slot.getHasStack() ? this.gm.player.inventoryContainer.getSingleRecipe(slot.getStack()) : null));
|
||||
}
|
||||
|
||||
public Label label(String text, int x, int y) {
|
||||
return this.add(new FontLabel(x, y, 300, Font.LARGE, text, true));
|
||||
}
|
||||
|
||||
public DisplayLabel display(String text, int x, int y, int w, int lines) {
|
||||
return this.add(new DisplayLabel(x, y, w, lines, Font.LARGE, text));
|
||||
}
|
||||
|
||||
public Bar bar(int x, int y, int w, int h) {
|
||||
return this.add(new Bar(x, y, w, h, Font.LARGE));
|
||||
}
|
||||
|
||||
public InventoryButton slot(int x, int y, int w, int h) {
|
||||
return this.add(new InventoryButton(x, y, w, h, null, 1, 1));
|
||||
}
|
||||
|
||||
public ActButton button(int x, int y, int w, int h, ButtonCallback callback, String text) {
|
||||
return this.add(new ActButton(x, y, w, h, callback, text));
|
||||
}
|
||||
|
||||
public void mouse(Button btn, int x, int y, boolean ctrl, boolean shift) {
|
||||
super.mouse(btn, x, y, ctrl, shift);
|
||||
this.mouseClicked(x, y, btn.ordinal()); //TODO: enum
|
||||
|
@ -231,6 +214,26 @@ public abstract class GuiContainer extends Gui
|
|||
public int getControlAreaWidth() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Label label(String text, int x, int y) {
|
||||
return this.add(new FontLabel(this.controlX + x, this.controlY + y, 300, Font.LARGE, text, true));
|
||||
}
|
||||
|
||||
public DisplayLabel display(String text, int x, int y, int w, int lines) {
|
||||
return this.add(new DisplayLabel(this.controlX + x, this.controlY + y, w, lines, Font.LARGE, text));
|
||||
}
|
||||
|
||||
public Bar bar(int x, int y, int w, int h) {
|
||||
return this.add(new Bar(this.controlX + x, this.controlY + y, w, h, Font.LARGE));
|
||||
}
|
||||
|
||||
public InventoryButton slot(int x, int y, int w, int h) {
|
||||
return this.add(new InventoryButton(this.controlX + x, this.controlY + y, w, h, null, 1, 1));
|
||||
}
|
||||
|
||||
public ActButton button(int x, int y, int w, int h, ButtonCallback callback, String text) {
|
||||
return this.add(new ActButton(this.controlX + x, this.controlY + y, w, h, callback, text));
|
||||
}
|
||||
|
||||
public void init(int width, int height) {
|
||||
this.itemRender = this.gm.getRenderItem();
|
||||
|
@ -255,14 +258,14 @@ public abstract class GuiContainer extends Gui
|
|||
invLeft = true;
|
||||
}
|
||||
}
|
||||
boolean center = leftSlots == 0 || rightSlots == 0;
|
||||
boolean center = (leftSlots == 0 || rightSlots == 0) && this.getControlAreaWidth() <= 0;
|
||||
|
||||
int area = this.getControlAreaWidth();
|
||||
int side = this.gm.itemCheat ? 450 : 0;
|
||||
int gap = 2;
|
||||
int border = 2;
|
||||
int frame = 16;
|
||||
int header = 20;
|
||||
int area = this.getControlAreaWidth() == 0 ? 0 : frame + Math.abs(this.getControlAreaWidth()) + frame;
|
||||
int side = this.gm.itemCheat ? 450 : 0;
|
||||
|
||||
int invWidth = (this.gm.fbX - frame - border - border - side - frame) / 32;
|
||||
int invHeight = ((Equipment.INVENTORY_SLOTS + invWidth - 1) / invWidth);
|
||||
|
@ -317,7 +320,7 @@ public abstract class GuiContainer extends Gui
|
|||
x = rightX + border + ((rightSlots < slotsWidth ? n + slotsWidth - rightSlots : n) % slotsWidth) * (32 + (invRight ? 0 : border + gap + border));
|
||||
y = rightY + header + border + (n / slotsWidth) * (32 + (invRight ? 0 : border + gap + border));
|
||||
if(invRight) {
|
||||
w = slotsWidth;
|
||||
w = rightSlots < slotsWidth ? rightSlots : slotsWidth;
|
||||
h = rightSlotsHeight;
|
||||
}
|
||||
}
|
||||
|
@ -332,6 +335,9 @@ public abstract class GuiContainer extends Gui
|
|||
}
|
||||
this.invButtons[z] = this.add(new InventoryButton(x, y, 32, 32, slot, w, h));
|
||||
}
|
||||
|
||||
this.controlX = leftX2 + frame;
|
||||
this.controlY = frame;
|
||||
|
||||
if(this.gm.itemCheat) {
|
||||
int x2 = Math.max(playerX2, rightX2);
|
||||
|
@ -339,25 +345,7 @@ public abstract class GuiContainer extends Gui
|
|||
this.cheatY = 32;
|
||||
this.cheatWidth = Math.max((this.gm.fbX - x2 - 32) / 36, 1);
|
||||
this.cheatHeight = Math.max((this.gm.fbY - 40 * ((CheatTab.values().length + (this.cheatWidth - 1)) / this.cheatWidth) - 92) / 36, 1);
|
||||
}
|
||||
this.addButtons();
|
||||
this.addElements();
|
||||
this.label("Inventar", playerX, playerY + 18);
|
||||
this.inventoryLabel = this.label("", playerX2 - 180, playerY + 18);
|
||||
}
|
||||
|
||||
public void hover(String text, int x, int y) {
|
||||
this.tooltip = text;
|
||||
this.hover_x = x + 16;
|
||||
this.hover_y = y + 16;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return "Inventar";
|
||||
}
|
||||
|
||||
public void addButtons() {
|
||||
if(this.gm.itemCheat) {
|
||||
this.cheatLabel = this.add(new FontLabel(this.cheatX, this.cheatY, this.cheatWidth * 36, Font.SMALL, "", true));
|
||||
// this.cheatDesc = this.add(new DisplayLabel(this.cheatX, this.cheatY + this.cheatHeight * 18 + 20 * ((CheatTab.values().length + (this.cheatWidth - 1)) / this.cheatWidth) + 4 + 18, this.cheatWidth * 18, 4, Font.SMALL, "Vorsicht: Schummeln\nwird mit Keule bestraft!!\n(Halte Strg beim Klick\nfür vollen Stapel)"));
|
||||
this.cheatSearch = this.add(new Field(this.cheatX, this.cheatY + this.cheatHeight * 36 + 40 * ((CheatTab.values().length + (this.cheatWidth - 1)) / this.cheatWidth) + 8, this.cheatWidth * 36 + 20, 0, 128, null, ""));
|
||||
|
@ -366,10 +354,24 @@ public abstract class GuiContainer extends Gui
|
|||
this.add(new InventoryButton(this.cheatX + 36 * (tab.getIndex() % this.cheatWidth), this.cheatY + this.cheatHeight * 36 + 8 + 40 * (tab.getIndex() / this.cheatWidth), 36, 36, null, 1, 1));
|
||||
}
|
||||
this.setCurrentTab(selectedTab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.add(new FontLabel(playerX, playerY + header - 2, 300, Font.LARGE, "Inventar", true));
|
||||
this.inventoryLabel = this.add(new FontLabel(playerX2 - 180, playerY + header - 2, 300, Font.LARGE, "", true));
|
||||
|
||||
this.add(new FontLabel(frame, frame + header - 2, 300, Font.LARGE, this.getTitle(), true));
|
||||
|
||||
this.addElements();
|
||||
}
|
||||
|
||||
public void hover(String text, int x, int y) {
|
||||
this.tooltip = text;
|
||||
this.hover_x = x + 16;
|
||||
this.hover_y = y + 16;
|
||||
}
|
||||
|
||||
public abstract void addElements();
|
||||
public void addElements() {
|
||||
}
|
||||
|
||||
protected void drawSlots(int mouseX, int mouseY) {
|
||||
for (int i1 = 0; i1 < this.invButtons.length; ++i1)
|
||||
|
|
|
@ -15,10 +15,13 @@ public class GuiCrafting extends GuiContainer {
|
|||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label(this.type.getDisplay(), 16, 32);
|
||||
}
|
||||
|
||||
public int getControlAreaWidth() {
|
||||
return 300;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.type.getDisplay();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public class GuiDevice extends GuiContainer {
|
|||
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
this.header.setText(this.tile.getStatus().color + this.tile.getBlock().getDisplay());
|
||||
this.header.setText(this.tile.getStatus().color + this.tile.getStatus().name);
|
||||
this.desc.setText(this.tile.formatDisplay((ContainerTile)this.inventorySlots));
|
||||
if(this.progress != null) {
|
||||
this.progress.setText(this.tile.getTotal() <= 0 || this.tile.getProgress() < 0 ? "" : String.format("%d/%d (%.1f %%)",
|
||||
|
@ -60,4 +60,8 @@ public class GuiDevice extends GuiContainer {
|
|||
this.resources[z] = this.bar(14, 160 - (this.resources.length + (this.progress == null ? 0 : 1) + (this.temperature == null ? 0 : 1)) * 20 + z * 20, 324, 18);
|
||||
}
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.tile.getBlock().getDisplay();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,9 @@ public class GuiEnchant extends GuiContainer implements ButtonCallback {
|
|||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label(Blocks.enchanting_table.getDisplay(), 16, 32);
|
||||
for(int l = 0; l < 3; ++l) {
|
||||
this.buttons[l] = this.button(120, 28 + 38 * l, 216, 38, this, "");
|
||||
}
|
||||
for(int l = 0; l < 3; ++l) {
|
||||
int i1 = 120;
|
||||
int j1 = i1 + 4;
|
||||
|
@ -71,6 +73,10 @@ public class GuiEnchant extends GuiContainer implements ButtonCallback {
|
|||
this.mana[l] = this.label("", j1, 52 + 38 * l + 14);
|
||||
}
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return Blocks.enchanting_table.getDisplay();
|
||||
}
|
||||
|
||||
public void use(ActButton btn, PressType type) {
|
||||
for(int k = 0; k < 3; ++k) {
|
||||
|
@ -79,13 +85,6 @@ public class GuiEnchant extends GuiContainer implements ButtonCallback {
|
|||
}
|
||||
}
|
||||
|
||||
public void addButtons() {
|
||||
super.addButtons();
|
||||
for(int l = 0; l < 3; ++l) {
|
||||
this.buttons[l] = this.button(120, 28 + 38 * l, 216, 38, this, "");
|
||||
}
|
||||
}
|
||||
|
||||
public void drawScreen(int mouseX, int mouseY) {
|
||||
super.drawScreen(mouseX, mouseY);
|
||||
|
||||
|
|
|
@ -14,10 +14,10 @@ public class GuiEntity extends GuiContainer {
|
|||
}
|
||||
|
||||
public int getControlAreaWidth() {
|
||||
return 16;
|
||||
return -150;
|
||||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label(this.title, 16, 32);
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@ public class GuiInventory extends GuiContainer {
|
|||
public GuiInventory(EntityNPC player) {
|
||||
super(player.inventoryContainer);
|
||||
}
|
||||
|
||||
public void addElements() {
|
||||
|
||||
public String getTitle() {
|
||||
return "Inventar";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,8 +32,7 @@ public class GuiMerchant extends GuiContainer implements ButtonCallback {
|
|||
return 380;
|
||||
}
|
||||
|
||||
public void addButtons() {
|
||||
super.addButtons();
|
||||
public void addElements() {
|
||||
this.nextBtn = this.button(240 + 54, 48, 24, 32, this, ">");
|
||||
this.prevBtn = this.button(72 - 38, 48, 24, 32, this, "<");
|
||||
this.slot(72 - 2, 48 - 2, 36, 36);
|
||||
|
@ -42,9 +41,9 @@ public class GuiMerchant extends GuiContainer implements ButtonCallback {
|
|||
this.nextBtn.enabled = false;
|
||||
this.prevBtn.enabled = false;
|
||||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label(this.title, 16, 32);
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public void drawOverlays() {
|
||||
|
|
|
@ -34,7 +34,10 @@ public class GuiRepair extends GuiContainer {
|
|||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label("Amboss", 16, 32);
|
||||
this.info = this.label("", 120, 154);
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return "Amboss";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue