1
0
Fork 0

improve container gui

This commit is contained in:
Sen 2025-09-07 14:03:54 +02:00
parent d44352c40e
commit 5421552dde
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
23 changed files with 133 additions and 190 deletions

View file

@ -608,12 +608,6 @@ public class Client implements IThreadListener {
@Variable(name = "gui_scale", category = CVarCategory.GUI, min = 1, max = 5, display = "Skalierung", unit = "x", callback = RedrawFunction.class)
private int scaleVar = 1;
@Variable(name = "gui_scale_items", category = CVarCategory.GUI, display = "Gegenstände vergrößern", callback = ItemRedrawFunction.class)
public boolean scaleItems = true;
@Variable(name = "gui_scale_items_always", category = CVarCategory.GUI, display = "Immer vergrößern", callback = ItemRedrawFunction.class)
public boolean scaleItemsAlways = false;
@Variable(name = "gui_scale_hotbar", category = CVarCategory.GUI, display = "Leiste vergrößern")
public boolean scaleHotbar = true;
@Variable(name = "hud_margin", category = CVarCategory.GUI, min = 0, max = 120, unit = "px", display = "Seitenabstand der HUD")
private int hudMargin = 4;
@Variable(name = "phy_sensitivity", category = CVarCategory.INPUT, min = 0.01f, max = 10.0f, display = "Mausempfindlichkeit", precision = 2, unit = "%")
@ -1182,7 +1176,7 @@ public class Client implements IThreadListener {
public void renderHud() {
final int selected = this.world != null && this.player != null && this.viewEntity == this.player ? this.player.getSelectedIndex() : -1;
final int scale = this.scaleHotbar ? 2 : 1;
final int scale = 2;
final int size = this.world != null && this.player != null && this.viewEntity == this.player ? this.player.getHotbarSize() : 1;
int total = 1;
if(this.world != null && this.player != null && this.viewEntity == this.player) {
@ -1224,7 +1218,7 @@ public class Client implements IThreadListener {
continue;
if(selected == n)
Drawing.drawRect(x - scale * 2, by - scale * 2, 20 * scale, 20 * scale, 0xffffffff);
InventoryButton.drawButton(this, x - scale, by - scale, 18 * scale, 18 * scale, this.scaleHotbar);
InventoryButton.drawButton(this, x - scale, by - scale, 18 * scale, 18 * scale);
x += (width >= 20 || selected == n || selected == n + 1 ? 20 : width) * scale;
}
@ -1283,7 +1277,7 @@ public class Client implements IThreadListener {
stats += 1;
}
x = this.fbX - this.hudMargin - 250;
y = this.fbY - this.hudMargin - 14 - (this.scaleHotbar ? 24 : 0) - stats * 40;
y = this.fbY - this.hudMargin - 14 - 24 - stats * 40;
int hp = entity.getHealth();
int max = entity.getMaxHealth();
y = this.drawStat(x, y, Color.RED + "Schaden", hp, max, 0xff0000);
@ -1316,7 +1310,7 @@ public class Client implements IThreadListener {
}
x = this.hudMargin;
y = this.fbY - this.hudMargin - 14 - (this.scaleHotbar ? 24 : 0) - (this.player.isRidingHorse() && this.player.getHorseJumpPower() != 0.0f ? 2 : 1) * 40;
y = this.fbY - this.hudMargin - 14 - 24 - (this.player.isRidingHorse() && this.player.getHorseJumpPower() != 0.0f ? 2 : 1) * 40;
if(this.player.isRidingHorse() && this.player.getHorseJumpPower() != 0.0f) // {
y = this.drawBar(x, y, String.format(Color.NEON + "Sprungkraft: " + Color.CYAN + "%d %%", (int)(this.player.getHorseJumpPower() * 100.0f)),
this.player.getHorseJumpPower(), 0x4040ff);
@ -1379,8 +1373,7 @@ public class Client implements IThreadListener {
ItemRenderer.enableGUIStandardItemLighting();
GL15.glPushMatrix();
GL15.glTranslatef(0.0f, (float)by, 0.0f);
if(this.scaleHotbar)
GL15.glScalef(2.0f, 2.0f, 2.0f);
GL15.glScalef(2.0f, 2.0f, 2.0f);
int xPos = xoff;
int cnt = 0;
@ -1433,7 +1426,7 @@ public class Client implements IThreadListener {
if(itemstack != null && itemstack.getItem().getCategory() == this.itemSelection) {
if(width >= 17 || index == selected) {
GuiContainer.renderItemOverlay(itemstack,
xPos, by, null, index == this.player.getSelectedIndex() ? this.controller.getUseCooldown() : 0, this.controller.getUseCooldownMax(), scale);
xPos, by, null, index == this.player.getSelectedIndex() ? this.controller.getUseCooldown() : 0, this.controller.getUseCooldownMax());
}
xPos += (width >= 20 || selected == index || selected == index + 1 ? 20 : width) * scale;
}

View file

@ -14,6 +14,6 @@ public class GuiChest extends GuiContainer {
}
public void addElements() {
this.label(this.block.getDisplay(), 8, 16);
this.label(this.block.getDisplay(), 16, 32);
}
}

View file

@ -8,7 +8,6 @@ import java.util.Map.Entry;
import org.lwjgl.opengl.GL15;
import client.Client;
import client.gui.Font;
import client.gui.Gui;
import client.gui.element.ActButton;
@ -31,7 +30,6 @@ import common.enchantment.Enchantment;
import common.entity.npc.Attribute;
import common.init.ItemRegistry;
import common.inventory.Container;
import common.inventory.ContainerChest;
import common.inventory.Slot;
import common.item.CheatTab;
import common.item.ItemStack;
@ -78,9 +76,6 @@ public abstract class GuiContainer extends Gui
protected int container_x;
protected int container_y;
protected int container_w;
protected int container_h;
protected int container_scale;
private int hover_x;
private int hover_y;
@ -194,43 +189,33 @@ public abstract class GuiContainer extends Gui
return list;
}
public int getScale() {
return this.container_scale;
}
public ItemStack getHoverItem(Slot slot) {
return this.gm.player != null && this.gm.player.getMouseItem() != null ? this.gm.player.getMouseItem() : (this.gm.itemCheat && this.cheatStack != null ? this.cheatStack : (Bind.CRAFT.isDown()
&& slot.canCheatItem() && slot.getHasStack() ? this.gm.player.inventoryContainer.getSingleRecipe(slot.getStack()) : null));
}
public Label label(String text, int x, int y) {
x = x * this.container_scale + this.container_x;
y = y * this.container_scale + this.container_y;
return this.add(new FontLabel(x, y, 300, this.container_scale > 1 ? Font.LARGE : Font.SMALL, text, true));
return this.add(new FontLabel(x + this.container_x, y + this.container_y, 300, Font.LARGE, text, true));
}
public DisplayLabel display(String text, int x, int y, int w, int lines) {
x = x * this.container_scale + this.container_x;
y = y * this.container_scale + this.container_y;
return this.add(new DisplayLabel(x, y, w * this.container_scale, lines, this.container_scale > 1 ? Font.LARGE : Font.TINY, text));
return this.add(new DisplayLabel(x + this.container_x, y + this.container_y, w, lines, Font.LARGE, text));
}
public Bar bar(int x, int y, int w, int h) {
x = x * this.container_scale + this.container_x;
y = y * this.container_scale + this.container_y;
return this.add(new Bar(x, y, w * this.container_scale, h * this.container_scale, this.container_scale > 1 ? Font.LARGE : Font.TINY));
return this.add(new Bar(x + this.container_x, y + this.container_y, w, h, Font.LARGE));
}
public void rect(int x, int y, int width, int height, int color) {
Drawing.drawRect(this.container_x + x * this.container_scale, this.container_y + y * this.container_scale, width * this.container_scale, height * this.container_scale, 0xff000000 | color);
Drawing.drawRect(this.container_x + x, this.container_y + y, width, height, 0xff000000 | color);
}
public void grad(int x, int y, int width, int height, int top, int bottom, int topleft, int btmright) {
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);
Drawing.drawGradient(this.container_x + x, this.container_y + y, width, height, 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));
return this.add(new InventoryButton(this.container_x + x, this.container_y + y, w, h, slot));
}
public InventoryButton slot(int x, int y, int w, int h) {
@ -238,51 +223,50 @@ public abstract class GuiContainer extends Gui
}
public ActButton button(int x, int y, int w, int h, ButtonCallback callback, String text) {
return this.add(new ActButton(this.container_x + x * this.container_scale, this.container_y + y * this.container_scale, w * this.container_scale, h * this.container_scale, callback, text));
return this.add(new ActButton(this.container_x + x, this.container_y + 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 - this.container_x) / this.container_scale, (y - this.container_y) / this.container_scale, btn.ordinal()); //TODO: enum
this.mouseClicked(x - this.container_x, y - this.container_y, btn.ordinal()); //TODO: enum
}
public void mouserel(Button btn, int x, int y) {
super.mouserel(btn, x, y);
this.mouseReleased((x - this.container_x) / this.container_scale, (y - this.container_y) / this.container_scale, btn.ordinal()); //TODO: enum
this.mouseReleased(x - this.container_x, y - this.container_y, btn.ordinal()); //TODO: enum
}
public void drag(int x, int y) {
super.drag(x, y);
if(Button.MOUSE_LEFT.isDown() || Button.MOUSE_RIGHT.isDown() || Button.MOUSE_MIDDLE.isDown())
this.mouseDragged((x - this.container_x) / this.container_scale, (y - this.container_y) / this.container_scale);
this.mouseDragged(x - this.container_x, y - this.container_y);
}
public GuiContainer(Container container)
{
this.inventorySlots = container;
this.ignoreMouseUp = true;
this.xSize = (container.getInventoryOffsetX() - 1) * 2 + 18 * Container.INVENTORY_WIDTH;
this.ySize = container.getInventoryOffsetY() + 26 + 18 * ((Equipment.INVENTORY_SLOTS + Container.INVENTORY_WIDTH - 1) / Container.INVENTORY_WIDTH);
this.xSize = (container.getInventoryOffsetX() - 2) * 2 + 36 * Container.INVENTORY_WIDTH;
this.ySize = container.getInventoryOffsetY() + 52 + 36 * ((Equipment.INVENTORY_SLOTS + Container.INVENTORY_WIDTH - 1) / Container.INVENTORY_WIDTH);
}
public void init(int width, int height) {
this.itemRender = this.gm.getRenderItem();
this.tooltip = null;
this.cheatStack = null;
this.container_scale = this.gm.scaleItems && (this.gm.scaleItemsAlways || (this.xSize * 2 <= Client.MIN_WIDTH && this.ySize * 2 <= Client.MIN_HEIGHT)) ? 2 : 1;
this.container_x = (width - (this.container_w = (this.xSize * this.container_scale))) / 2;
this.container_y = (height - (this.container_h = (this.ySize * this.container_scale))) / 2;
this.container_x = (width - this.xSize) / 2;
this.container_y = (height - this.ySize) / 2;
this.initGui();
this.addButtons();
this.addElements();
this.label("Inventar", this.inventorySlots.getInventoryOffsetX(), this.inventorySlots.getInventoryOffsetY() - 2);
this.inventoryLabel = this.label("", this.inventorySlots.getInventoryOffsetX() + 18 * Container.INVENTORY_WIDTH - 90, this.inventorySlots.getInventoryOffsetY() - 2);
this.label("Inventar", this.inventorySlots.getInventoryOffsetX(), this.inventorySlots.getInventoryOffsetY() - 4);
this.inventoryLabel = this.label("", this.inventorySlots.getInventoryOffsetX() + 36 * Container.INVENTORY_WIDTH - 180, this.inventorySlots.getInventoryOffsetY() - 4);
}
public void hover(String text, int x, int y) {
this.tooltip = text;
this.hover_x = x * this.container_scale + this.container_x + 16;
this.hover_y = y * this.container_scale + this.container_y + 16;
this.hover_x = x + this.container_x + 16;
this.hover_y = y + this.container_y + 16;
}
public String getTitle() {
@ -293,10 +277,10 @@ public abstract class GuiContainer extends Gui
{
this.gm.player.openContainer = this.inventorySlots;
if(this.gm.itemCheat) {
this.cheatX = this.container_x + this.container_w + 4;
this.cheatY = 16;
this.cheatWidth = Math.max((this.gm.fbX - this.container_x - this.container_w - 16) / 18, 1);
this.cheatHeight = Math.max((this.gm.fbY - 20 * ((CheatTab.values().length + (this.cheatWidth - 1)) / this.cheatWidth) - 46) / 18, 1);
this.cheatX = this.container_x + this.xSize + 4;
this.cheatY = 32;
this.cheatWidth = Math.max((this.gm.fbX - this.container_x - this.xSize - 32) / 36, 1);
this.cheatHeight = Math.max((this.gm.fbY - 40 * ((CheatTab.values().length + (this.cheatWidth - 1)) / this.cheatWidth) - 92) / 36, 1);
}
}
@ -305,16 +289,16 @@ public abstract class GuiContainer extends Gui
for (int i1 = 0; i1 < this.inventorySlots.inventorySlots.size(); ++i1) {
Slot slot = this.inventorySlots.inventorySlots.get(i1);
if(slot.canDraw())
this.slot(slot.xDisplayPosition - 1, slot.yDisplayPosition - 1, 18, 18, slot);
this.slot(slot.xDisplayPosition - 2, slot.yDisplayPosition - 2, 36, 36, slot);
}
}
if(this.gm.itemCheat) {
this.cheatLabel = this.add(new FontLabel(this.cheatX, this.cheatY, this.cheatWidth * 18, Font.SMALL, "", true));
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 * 18 + 20 * ((CheatTab.values().length + (this.cheatWidth - 1)) / this.cheatWidth) + 4, this.cheatWidth * 18 + 10, 0, 128, null, ""));
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, ""));
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, null));
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));
}
this.setCurrentTab(selectedTab);
}
@ -335,10 +319,8 @@ public abstract class GuiContainer extends Gui
}
if(this.gm.itemCheat) {
GL15.glPushMatrix();
GL15.glTranslatef(-(float)((this.gm.fbX - this.xSize * this.container_scale) / 2) * (1.0f / (float)this.container_scale), -(float)((this.gm.fbY - this.ySize * this.container_scale) / 2) * (1.0f / (float)this.container_scale), 0.0f);
if(this.container_scale != 1)
GL15.glScalef(1.0f / (float)this.container_scale, 1.0f / (float)this.container_scale, 1.0f / (float)this.container_scale);
// GL15.glPushMatrix();
// GL15.glTranslatef(-(float)((this.gm.fbX - this.xSize * SCALE) / 2) * (1.0f / (float)SCALE), -(float)((this.gm.fbY - this.ySize * SCALE) / 2) * (1.0f / (float)SCALE), 0.0f);
int i = (ITEM_LIST.size() + this.cheatWidth - 1) / this.cheatWidth - this.cheatHeight;
int j = (int)((double)(this.currentScroll * (float)i) + 0.5D);
@ -357,9 +339,9 @@ public abstract class GuiContainer extends Gui
this.itemRender.zLevel = 100.0F;
GlState.enableDepth();
this.itemRender.renderItemAndEffectIntoGUI(ITEM_LIST.get(i1), this.cheatX + 18 * l + 1, this.cheatY + k * 18 + 1);
this.itemRender.renderItemAndEffectIntoGUI(ITEM_LIST.get(i1), this.cheatX + 36 * l + 2, this.cheatY + k * 36 + 2);
this.itemRender.zLevel = 0.0F;
if(this.isPointInRegion(this.cheatX + 18 * l + 1, this.cheatY + k * 18 + 1, 16, 16, this.gm.mouseX, this.gm.mouseY))
if(this.isPointInRegion(this.cheatX + 36 * l + 2, this.cheatY + k * 36 + 2, 32, 32, this.gm.mouseX, this.gm.mouseY))
this.renderToolTip(ITEM_LIST.get(i1), mouseX, mouseY);
}
}
@ -369,7 +351,7 @@ public abstract class GuiContainer extends Gui
{
this.drawTab(tabs);
}
GL15.glPopMatrix();
// GL15.glPopMatrix();
}
}
@ -391,10 +373,10 @@ public abstract class GuiContainer extends Gui
return;
if(this.gm.itemCheat) {
boolean flag = Button.MOUSE_LEFT.isDown(); //TODO: remove?
int x1 = this.cheatX + this.cheatWidth * 18 + 2;
int x1 = this.cheatX + this.cheatWidth * 36 + 4;
int y1 = this.cheatY;
int x2 = x1 + 8;
int y2 = y1 + this.cheatHeight * 18;
int x2 = x1 + 16;
int y2 = y1 + this.cheatHeight * 36;
if (!this.wasClicking && flag && this.gm.mouseX >= x1 && this.gm.mouseY >= y1 && this.gm.mouseX < x2 && this.gm.mouseY < y2)
{
@ -410,7 +392,7 @@ public abstract class GuiContainer extends Gui
if (this.isScrolling)
{
this.currentScroll = ((float)(this.gm.mouseY - y1) - 7.5F) / ((float)(y2 - y1) - 15.0F);
this.currentScroll = ((float)(this.gm.mouseY - y1) - 15.0F) / ((float)(y2 - y1) - 30.0F);
this.currentScroll = ExtMath.clampf(this.currentScroll, 0.0F, 1.0F);
}
}
@ -439,8 +421,8 @@ public abstract class GuiContainer extends Gui
if (stack != null)
{
int j2 = 8;
int k2 = 8;
int j2 = 16;
int k2 = 16;
String s = null;
if(stack == this.cheatStack) {
@ -482,7 +464,7 @@ public abstract class GuiContainer extends Gui
{
GL15.glTranslatef(0.0F, 0.0F, 32.0F);
this.itemRender.zLevel = 200.0F;
this.itemRender.renderItemAndEffectIntoGUI(stack, x, y);
this.itemRender.renderItemAndEffectIntoGUI(stack, this.container_x + x, this.container_y + y);
this.drawnOverlays.add(new Overlay(stack, x, y, altText));
this.itemRender.zLevel = 0.0F;
}
@ -503,13 +485,13 @@ public abstract class GuiContainer extends Gui
super.draw();
if(this.gm.itemCheat) {
if(this.needsScrollBars()) {
int x1 = this.cheatX + this.cheatWidth * 18 + 2;
int x1 = this.cheatX + this.cheatWidth * 36 + 4;
int y1 = this.cheatY;
int y2 = y1 + this.cheatHeight * 18;
Drawing.drawRect(x1, y1, 8, this.cheatHeight * 18, 0xff000000);
Drawing.drawGradient(x1, y1 + (int)((float)(y2 - y1 - 15) * this.currentScroll), 8, 15, this.gm.style.fill_top, this.gm.style.fill_btm, this.gm.style.brdr_top, this.gm.style.brdr_btm);
int y2 = y1 + this.cheatHeight * 36;
Drawing.drawRect(x1, y1, 16, this.cheatHeight * 36, 0xff000000);
Drawing.drawGradient(x1, y1 + (int)((float)(y2 - y1 - 30) * this.currentScroll), 16, 30, this.gm.style.fill_top, this.gm.style.fill_btm, this.gm.style.brdr_top, this.gm.style.brdr_btm);
}
Drawing.drawRect(this.cheatX + 18 * (selectedTab.getIndex() % this.cheatWidth), this.cheatY + this.cheatHeight * 18 + 4 + 20 * (selectedTab.getIndex() / this.cheatWidth) - 2, 18, 2, 0xffffffff);
Drawing.drawRect(this.cheatX + 36 * (selectedTab.getIndex() % this.cheatWidth), this.cheatY + this.cheatHeight * 36 + 8 + 40 * (selectedTab.getIndex() / this.cheatWidth) - 4, 36, 4, 0xffffffff);
}
if(Bind.isWindowActive())
super.drawOverlay();
@ -520,10 +502,9 @@ public abstract class GuiContainer extends Gui
public void drawPost() {
GL15.glPushMatrix();
GL15.glTranslatef((float)((this.gm.fbX - this.xSize * this.container_scale) / 2), (float)((this.gm.fbY - this.ySize * this.container_scale) / 2), 0.0f);
if(this.container_scale != 1)
GL15.glScalef((float)this.container_scale, (float)this.container_scale, (float)this.container_scale);
this.drawScreen((this.gm.mouseX - this.container_x) / this.container_scale, (this.gm.mouseY - this.container_y) / this.container_scale);
// GL15.glTranslatef((float)((this.gm.fbX - this.xSize * SCALE) / 2), (float)((this.gm.fbY - this.ySize * SCALE) / 2), 0.0f);
// GL15.glScalef(2.0f, 2.0f, 2.0f);
this.drawScreen(this.gm.mouseX - this.container_x, this.gm.mouseY - this.container_y);
GL15.glPopMatrix();
ItemRenderer.disableStandardItemLighting();
}
@ -540,7 +521,7 @@ public abstract class GuiContainer extends Gui
this.itemRender.zLevel = 100.0F;
GlState.enableDepth();
this.itemRender.renderItemAndEffectIntoGUI(itemstack, i, j);
this.itemRender.renderItemAndEffectIntoGUI(itemstack, this.container_x + i, this.container_y + j);
this.drawnOverlays.add(new Overlay(itemstack, i, j, s));
this.itemRender.zLevel = 0.0F;
@ -594,7 +575,7 @@ public abstract class GuiContainer extends Gui
return;
}
long i = System.currentTimeMillis();
this.doubleClick = this.lastClickSlot == slot && i - this.lastClickTime < 250L && this.lastClickButton == mouseButton;
this.doubleClick = this.lastClickSlot == slot && i - this.lastClickTime < (long)this.gm.dclickDelay && this.lastClickButton == mouseButton;
this.ignoreMouseUp = false;
if (mouseButton == 0 || mouseButton == 1)
@ -719,7 +700,7 @@ public abstract class GuiContainer extends Gui
private boolean isMouseOverSlot(Slot slotIn, int mouseX, int mouseY)
{
return this.isPointInRegion(slotIn.xDisplayPosition, slotIn.yDisplayPosition, 16, 16, mouseX, mouseY);
return this.isPointInRegion(slotIn.xDisplayPosition, slotIn.yDisplayPosition, 32, 32, mouseX, mouseY);
}
protected boolean isPointInRegion(int left, int top, int right, int bottom, int pointX, int pointY)
@ -785,10 +766,10 @@ public abstract class GuiContainer extends Gui
public void renderItemOverlayIntoGUI(ItemStack stack, int xPosition, int yPosition, String text)
{
renderItemOverlay(stack, this.container_x + xPosition * this.container_scale, this.container_y + yPosition * this.container_scale, text, 0, 0, this.container_scale);
renderItemOverlay(stack, this.container_x + xPosition, this.container_y + yPosition, text, 0, 0);
}
public static void renderItemOverlay(ItemStack stack, int xPosition, int yPosition, String text, int bar2, int bar2max, int scale)
public static void renderItemOverlay(ItemStack stack, int xPosition, int yPosition, String text, int bar2, int bar2max)
{
if (stack != null)
{
@ -800,27 +781,27 @@ public abstract class GuiContainer extends Gui
{
s = Color.RED + formatAmount(stack.getSize());
}
Font.set(scale > 1 ? Font.SMALL : Font.TINY);
Drawing.drawTextRight(s, xPosition + scale * 16, yPosition + scale * 16 + 1 - Font.HEIGHT, 0xffffffff);
Font.set(Font.SMALL);
Drawing.drawTextRight(s, xPosition + 32, yPosition + 32 + 1 - Font.HEIGHT, 0xffffffff);
Font.unset();
}
if (stack.isItemDamaged())
{
int j = (int)Math.round(14.0D * (double)scale - (double)stack.getItemDamage() * (14.0D * (double)scale) / (double)stack.getMaxDamage());
int j = (int)Math.round(28.0D - (double)stack.getItemDamage() * 28.0D / (double)stack.getMaxDamage());
int i = (int)Math.round(255.0D - (double)stack.getItemDamage() * 255.0D / (double)stack.getMaxDamage());
draw(xPosition + scale, yPosition + 13 * scale, 14 * scale, scale * 2, 0, 0, 0);
draw(xPosition + scale, yPosition + 13 * scale, 13 * scale, scale, (255 - i) / 4, 64, 0);
draw(xPosition + scale, yPosition + 13 * scale, j, scale, 255 - i, i, 0);
draw(xPosition + 2, yPosition + 26, 28, 4, 0, 0, 0);
draw(xPosition + 2, yPosition + 26, 26, 2, (255 - i) / 4, 64, 0);
draw(xPosition + 2, yPosition + 26, j, 2, 255 - i, i, 0);
}
if (bar2 > 0)
{
int j = (int)Math.round(14.0D * (double)scale - (double)bar2 * (14.0D * (double)scale) / (double)bar2max);
int j = (int)Math.round(28.0D - (double)bar2 * 28.0D / (double)bar2max);
int i = (int)Math.round(255.0D - (double)bar2 * 255.0D / (double)bar2max);
draw(xPosition + scale, yPosition + scale * 2, 14 * scale, scale * 2, 0, 0, 0);
draw(xPosition + scale, yPosition + scale * 2, 13 * scale, scale, (255 - i) / 8, (255 - i) / 16, i / 4);
draw(xPosition + scale + 14 * scale - j, yPosition + scale * 2, j, scale, (255 - i) / 2, (255 - i) / 4, i);
draw(xPosition + 2, yPosition + 4, 28, 4, 0, 0, 0);
draw(xPosition + 2, yPosition + 4, 26, 2, (255 - i) / 8, (255 - i) / 16, i / 4);
draw(xPosition + 2 + 28 - j, yPosition + 4, j, 2, (255 - i) / 2, (255 - i) / 4, i);
}
}
}
@ -831,19 +812,19 @@ public abstract class GuiContainer extends Gui
}
public void drawBackground() {
Drawing.drawGradientBorder(this.container_x, this.container_y, this.container_w, this.container_h, Util.mulColor(this.gm.style.fill_top, 0.8f), Util.mulColor(this.gm.style.fill_btm, 0.8f), 0xff000000, Util.mulColor(this.gm.style.brdr_top, 0.8f), Util.mulColor(this.gm.style.brdr_btm, 0.8f));
Drawing.drawGradientBorder(this.container_x, this.container_y, this.xSize, this.ySize, Util.mulColor(this.gm.style.fill_top, 0.8f), Util.mulColor(this.gm.style.fill_btm, 0.8f), 0xff000000, Util.mulColor(this.gm.style.brdr_top, 0.8f), Util.mulColor(this.gm.style.brdr_btm, 0.8f));
}
protected boolean isInsideTab(CheatTab tab, int x, int y)
{
return x >= this.cheatX + 18 * (tab.getIndex() % this.cheatWidth) && x < this.cheatX + 18 * (tab.getIndex() % this.cheatWidth) + 18 &&
y >= this.cheatY + this.cheatHeight * 18 + 4 + 20 * (tab.getIndex() / this.cheatWidth) && y < this.cheatY + this.cheatHeight * 18 + 4 + 20 * (tab.getIndex() / this.cheatWidth) + 18;
return x >= this.cheatX + 36 * (tab.getIndex() % this.cheatWidth) && x < this.cheatX + 36 * (tab.getIndex() % this.cheatWidth) + 36 &&
y >= this.cheatY + this.cheatHeight * 36 + 8 + 40 * (tab.getIndex() / this.cheatWidth) && y < this.cheatY + this.cheatHeight * 36 + 8 + 40 * (tab.getIndex() / this.cheatWidth) + 36;
}
private boolean renderInventoryHoveringText(CheatTab tab, int x, int z)
{
if (this.isPointInRegion(this.cheatX + 18 * (tab.getIndex() % this.cheatWidth), this.cheatY + this.cheatHeight * 18 + 4 + 20 * (tab.getIndex() / this.cheatWidth), 18, 18, this.gm.mouseX, this.gm.mouseY))
if (this.isPointInRegion(this.cheatX + 36 * (tab.getIndex() % this.cheatWidth), this.cheatY + this.cheatHeight * 36 + 8 + 40 * (tab.getIndex() / this.cheatWidth), 36, 36, this.gm.mouseX, this.gm.mouseY))
{
this.hover(tab.getName(), x, z);
return true;
@ -859,7 +840,7 @@ public abstract class GuiContainer extends Gui
this.itemRender.zLevel = 100.0F;
ItemStack itemstack = tab.getIcon();
GlState.enableDepth();
this.itemRender.renderItemAndEffectIntoGUI(itemstack, this.cheatX + 18 * (tab.getIndex() % this.cheatWidth) + 1, this.cheatY + this.cheatHeight * 18 + 4 + 20 * (tab.getIndex() / this.cheatWidth) + 1);
this.itemRender.renderItemAndEffectIntoGUI(itemstack, this.cheatX + 36 * (tab.getIndex() % this.cheatWidth) + 2, this.cheatY + this.cheatHeight * 36 + 8 + 40 * (tab.getIndex() / this.cheatWidth) + 2);
this.itemRender.zLevel = 0.0F;
}
@ -900,7 +881,7 @@ public abstract class GuiContainer extends Gui
}
private boolean clickSide(int mouseX, int mouseY, int slot, boolean instant, boolean full) {
if(this.gm.itemCheat && this.isPointInRegion(this.cheatX, this.cheatY, 18 * this.cheatWidth, 18 * this.cheatHeight, mouseX, mouseY) && this.gm.player != null && this.gm.player.getMouseItem() == null && this.cheatStack == null) {
if(this.gm.itemCheat && this.isPointInRegion(this.cheatX, this.cheatY, 36 * this.cheatWidth, 36 * this.cheatHeight, mouseX, mouseY) && this.gm.player != null && this.gm.player.getMouseItem() == null && this.cheatStack == null) {
int size = (ITEM_LIST.size() + this.cheatWidth - 1) / this.cheatWidth - this.cheatHeight;
int off = (int)((double)(this.currentScroll * (float)size) + 0.5D);
@ -909,8 +890,8 @@ public abstract class GuiContainer extends Gui
off = 0;
}
int sx = (mouseX - this.cheatX) / 18;
int sy = (mouseY - this.cheatY) / 18;
int sx = (mouseX - this.cheatX) / 36;
int sy = (mouseY - this.cheatY) / 36;
int idx = sx + (sy + off) * this.cheatWidth;
if(idx >= 0 && idx < ITEM_LIST.size()) {

View file

@ -15,6 +15,6 @@ public class GuiCrafting extends GuiContainer {
}
public void addElements() {
this.label(this.type.getDisplay(), 8, 16);
this.label(this.type.getDisplay(), 16, 32);
}
}

View file

@ -47,13 +47,13 @@ public class GuiDevice extends GuiContainer {
}
public void addElements() {
this.header = this.label("", 8, 16);
this.desc = this.display("", 8, 18, 160, 4);
this.progress = this.tile.hasProgress() ? this.bar(7, 70, 162, 9) : null;
this.temperature = this.tile.hasTemperature() ? this.bar(7, this.progress == null ? 70 : 60, 162, 9) : null;
this.header = this.label("", 16, 32);
this.desc = this.display("", 16, 36, 320, 4);
this.progress = this.tile.hasProgress() ? this.bar(14, 140, 324, 18) : null;
this.temperature = this.tile.hasTemperature() ? this.bar(14, this.progress == null ? 140 : 120, 324, 18) : null;
this.resources = new Bar[this.tile.getNumResources()];
for(int z = 0; z < this.resources.length; z++) {
this.resources[z] = this.bar(7, 80 - (this.resources.length + (this.progress == null ? 0 : 1) + (this.temperature == null ? 0 : 1)) * 10 + z * 10, 162, 9);
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);
}
}
}

View file

@ -59,12 +59,12 @@ public class GuiEnchant extends GuiContainer implements ButtonCallback {
}
public void addElements() {
this.label(Blocks.enchanting_table.getDisplay(), 8, 16);
this.label(Blocks.enchanting_table.getDisplay(), 16, 32);
for(int l = 0; l < 3; ++l) {
int i1 = 60;
int j1 = i1 + 2;
this.labels[l] = this.label("", j1, 26 + 19 * l);
this.mana[l] = this.label("", j1, 26 + 19 * l + 7);
int i1 = 120;
int j1 = i1 + 4;
this.labels[l] = this.label("", j1, 52 + 38 * l);
this.mana[l] = this.label("", j1, 52 + 38 * l + 14);
}
}
@ -78,7 +78,7 @@ public class GuiEnchant extends GuiContainer implements ButtonCallback {
public void addButtons() {
super.addButtons();
for(int l = 0; l < 3; ++l) {
this.buttons[l] = this.button(60, 14 + 19 * l, 108, 19, this, "");
this.buttons[l] = this.button(120, 28 + 38 * l, 216, 38, this, "");
}
}

View file

@ -14,6 +14,6 @@ public class GuiEntity extends GuiContainer {
}
public void addElements() {
this.label(this.title, 8, 16);
this.label(this.title, 16, 32);
}
}

View file

@ -30,17 +30,17 @@ public class GuiMerchant extends GuiContainer implements ButtonCallback {
public void addButtons() {
super.addButtons();
this.nextBtn = this.button(120 + 27, 24, 12, 16, this, ">");
this.prevBtn = this.button(36 - 19, 24, 12, 16, this, "<");
this.slot(36 - 1, 24 - 1, 18, 18);
this.slot(62 - 1, 24 - 1, 18, 18);
this.slot(120 - 1, 24 - 1, 18, 18);
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);
this.slot(124 - 2, 48 - 2, 36, 36);
this.slot(240 - 2, 48 - 2, 36, 36);
this.nextBtn.enabled = false;
this.prevBtn.enabled = false;
}
public void addElements() {
this.label(this.title, 8, 16);
this.label(this.title, 16, 32);
}
public void drawOverlays() {

View file

@ -30,7 +30,7 @@ public class GuiRepair extends GuiContainer {
}
public void addElements() {
this.label("Amboss", 8, 16);
this.info = this.label("", 60, 77);
this.label("Amboss", 16, 32);
this.info = this.label("", 120, 154);
}
}

View file

@ -8,41 +8,33 @@ import common.inventory.Slot;
import common.item.ItemStack;
public class InventoryButton extends Element {
private final boolean bordered;
private final Slot slot;
private final String texture;
private final boolean background;
private final int bgW;
private final int bgH;
public InventoryButton(int x, int y, int w, int h, boolean bordered, Slot slot) {
public InventoryButton(int x, int y, int w, int h, Slot slot) {
super(x, y, w, h, null);
this.bordered = bordered;
this.texture = slot == null || slot.getTexture() == null || slot.getTexture().isEmpty() ? null : "textures/items/icon_" + slot.getTexture() + ".png";
this.background = slot == null || slot.getTexture() != null;
this.slot = slot;
int scale = this.bordered ? 2 : 1;
this.bgW = slot == null ? w : slot.getBackgroundWidth() * 18 * scale;
this.bgH = slot == null ? h : slot.getBackgroundHeight() * 18 * scale;
this.bgW = slot == null ? w : slot.getBackgroundWidth() * 36;
this.bgH = slot == null ? h : slot.getBackgroundHeight() * 36;
}
protected void drawBackground() {
if(this.background)
drawButton(this.gm, this.pos_x, this.pos_y, this.bgW, this.bgH, 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);
}
drawButton(this.gm, this.pos_x, this.pos_y, this.bgW, this.bgH);
if(this.texture != null && !this.slot.getHasStack())
Drawing.drawTexturedRect(this.gm, this.texture, 32, 32, this.pos_x + 2, this.pos_y + 2, 0, 0, this.size_x - 4, this.size_y - 4);
}
protected void drawForeground(int x1, int y1, int x2, int y2) {
}
public static void drawButton(Client gm, int x, int y, int w, int h, boolean border) {
if(border)
Drawing.drawGradientBorder(x, y, w, h, gm.style.fill_top, gm.style.fill_btm, 0xff000000, gm.style.brdr_top, gm.style.brdr_btm);
else
Drawing.drawGradient(x, y, w, h, gm.style.fill_top, gm.style.fill_btm, gm.style.brdr_top, gm.style.brdr_btm);
public static void drawButton(Client gm, int x, int y, int w, int h) {
Drawing.drawGradientBorder(x, y, w, h, gm.style.fill_top, gm.style.fill_btm, 0xff000000, gm.style.brdr_top, gm.style.brdr_btm);
}
public boolean canHover() {
@ -53,8 +45,7 @@ public class InventoryButton extends Element {
}
public void drawHover() {
int scale = this.bordered ? 2 : 1;
Drawing.drawRect(this.pos_x + scale, this.pos_y + scale, 16 * scale, 16 * scale, Gui.HOVER_COLOR);
Drawing.drawRect(this.pos_x + 2, this.pos_y + 2, 32, 32, Gui.HOVER_COLOR);
}
public boolean canClick() {

View file

@ -26,7 +26,6 @@ public class GuiDisplay extends GuiOptions {
this.addSelector("crosshair_color_target", H_SHIFT, y, 0, 0);
this.addSelector("hud_margin", 0, y += BASE_SHIFT, 0, 0);
this.addSelector("gui_scale_hotbar", H_SHIFT, y, 0, 0);
super.init(width, height);
}

View file

@ -76,9 +76,6 @@ public class GuiStyle extends GuiOptions {
this.addSelector("gui_scale", 0, y += BASE_SHIFT, 0, 0);
this.addSelector("gui_font", H_SHIFT, y, 0, 0);
this.addSelector("gui_scale_items", 0, y += BASE_SHIFT, 0, 0);
this.addSelector("gui_scale_items_always", H_SHIFT, y, 0, 0);
super.init(width, height);
}

View file

@ -334,20 +334,20 @@ public class RenderItem
private void setupGuiTransform(int xPosition, int yPosition, boolean isGui3d)
{
GL15.glTranslatef((float)xPosition, (float)yPosition, 100.0F + this.zLevel);
GL15.glTranslatef(8.0F, 8.0F, 0.0F);
GL15.glTranslatef(16.0F, 16.0F, 0.0F);
GL15.glScalef(1.0F, 1.0F, -1.0F);
GL15.glScalef(0.5F, 0.5F, 0.5F);
if (isGui3d)
{
GL15.glScalef(40.0F, 40.0F, 40.0F);
GL15.glScalef(80.0F, 80.0F, 80.0F);
GL15.glRotatef(210.0F, 1.0F, 0.0F, 0.0F);
GL15.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F);
GlState.enableLighting();
}
else
{
GL15.glScalef(64.0F, 64.0F, 64.0F);
GL15.glScalef(128.0F, 128.0F, 128.0F);
GL15.glRotatef(180.0F, 1.0F, 0.0F, 0.0F);
GlState.disableLighting();
}