Gui fixes

This commit is contained in:
Raoul Van den Berge
2016-05-07 14:57:51 +02:00
parent f422dbf336
commit 1b2cf968d1
2 changed files with 19 additions and 10 deletions

View File

@@ -112,10 +112,13 @@ public abstract class GuiBase extends GuiContainer {
} }
public GuiButton addButton(int x, int y, int w, int h, String text) { public GuiButton addButton(int x, int y, int w, int h, String text) {
return addButton(new GuiButton(lastButtonId++, x, y, w, h, text)); return addButton(x, y, w, h, text, true);
} }
public GuiButton addButton(GuiButton button) { public GuiButton addButton(int x, int y, int w, int h, String text, boolean enabled) {
GuiButton button = new GuiButton(lastButtonId++, x, y, w, h, text);
button.enabled = enabled;
buttonList.add(button); buttonList.add(button);
return button; return button;

View File

@@ -26,8 +26,10 @@ public class GuiCraftingMonitor extends GuiBase {
private GuiButton cancelAllButton; private GuiButton cancelAllButton;
private int itemSelected = -1; private int itemSelected = -1;
private boolean renderItemSelection; private boolean renderItemSelection;
private int itemSelectedX, itemSelectedY; private int renderItemSelectionX;
private int renderItemSelectionY;
private Scrollbar scrollbar = new Scrollbar(157, 20, 12, 89); private Scrollbar scrollbar = new Scrollbar(157, 20, 12, 89);
@@ -41,8 +43,14 @@ public class GuiCraftingMonitor extends GuiBase {
public void init(int x, int y) { public void init(int x, int y) {
addSideButton(new SideButtonRedstoneMode(craftingMonitor)); addSideButton(new SideButtonRedstoneMode(craftingMonitor));
cancelButton = addButton(x + 7, y + 113, 50, 20, t("misc.refinedstorage:cancel")); String cancel = t("misc.refinedstorage:cancel");
cancelAllButton = addButton(x + 7 + 50 + 4, y + 113, 12 + fontRendererObj.getStringWidth(t("misc.refinedstorage:cancel_all")), 20, t("misc.refinedstorage:cancel_all")); String cancelAll = t("misc.refinedstorage:cancel_all");
int cancelButtonWidth = 14 + fontRendererObj.getStringWidth(cancel);
int cancelAllButtonWidth = 14 + fontRendererObj.getStringWidth(cancelAll);
cancelButton = addButton(x + 7, y + 113, cancelButtonWidth, 20, cancel, false);
cancelAllButton = addButton(x + 7 + cancelButtonWidth + 4, y + 113, cancelAllButtonWidth, 20, cancelAll, false);
} }
@Override @Override
@@ -65,7 +73,7 @@ public class GuiCraftingMonitor extends GuiBase {
drawTexture(x, y, 0, 0, width, height); drawTexture(x, y, 0, 0, width, height);
if (renderItemSelection) { if (renderItemSelection) {
drawTexture(x + itemSelectedX, y + itemSelectedY, 178, 0, ITEM_WIDTH, ITEM_HEIGHT); drawTexture(x + renderItemSelectionX, y + renderItemSelectionY, 178, 0, ITEM_WIDTH, ITEM_HEIGHT);
} }
scrollbar.draw(this); scrollbar.draw(this);
@@ -100,8 +108,8 @@ public class GuiCraftingMonitor extends GuiBase {
if (item < tasks.size() && item < craftingMonitor.getInfo().length) { if (item < tasks.size() && item < craftingMonitor.getInfo().length) {
if (item == itemSelected) { if (item == itemSelected) {
renderItemSelection = true; renderItemSelection = true;
itemSelectedX = x; renderItemSelectionX = x;
itemSelectedY = y; renderItemSelectionY = y;
} }
ItemStack task = tasks.get(item); ItemStack task = tasks.get(item);
@@ -183,8 +191,6 @@ public class GuiCraftingMonitor extends GuiBase {
if (inBounds(ix, iy, ITEM_WIDTH, ITEM_HEIGHT, mouseX - guiLeft, mouseY - guiTop) && item < craftingMonitor.getTasks().size()) { if (inBounds(ix, iy, ITEM_WIDTH, ITEM_HEIGHT, mouseX - guiLeft, mouseY - guiTop) && item < craftingMonitor.getTasks().size()) {
itemSelected = item; itemSelected = item;
itemSelectedX = ix;
itemSelectedY = iy;
} }
item++; item++;