Resize inv when patterns go away / appear
This commit is contained in:
@@ -20,6 +20,8 @@ public class ContainerGrid extends ContainerBase {
|
||||
|
||||
private IGrid grid;
|
||||
|
||||
private boolean hadTabs;
|
||||
|
||||
private SlotGridCraftingResult craftingResultSlot;
|
||||
private SlotDisabled patternResultSlot;
|
||||
|
||||
@@ -28,6 +30,8 @@ public class ContainerGrid extends ContainerBase {
|
||||
|
||||
this.grid = grid;
|
||||
|
||||
this.hadTabs = !getGrid().getTabs().isEmpty();
|
||||
|
||||
addPlayerInventory(8, ((grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 165 : 126) + getTabDelta());
|
||||
|
||||
if (grid.getType() == EnumGridType.CRAFTING) {
|
||||
@@ -74,6 +78,25 @@ public class ContainerGrid extends ContainerBase {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
updateSlotsAccordingToTabs();
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
public void updateSlotsAccordingToTabs() {
|
||||
boolean hasTabs = !getGrid().getTabs().isEmpty();
|
||||
|
||||
if (hadTabs != hasTabs) {
|
||||
hadTabs = hasTabs;
|
||||
|
||||
for (Slot slot : this.inventorySlots) {
|
||||
slot.yPos += (TAB_HEIGHT - 4) * (hasTabs ? 1 : -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getTabDelta() {
|
||||
return !grid.getTabs().isEmpty() ? TAB_HEIGHT - 4 : 0;
|
||||
}
|
||||
|
||||
@@ -49,9 +49,8 @@ public abstract class GuiBase extends GuiContainer {
|
||||
}
|
||||
}
|
||||
|
||||
protected int sideButtonYStart = 6;
|
||||
private int lastButtonId;
|
||||
private int lastSideButtonY = sideButtonYStart;
|
||||
private int lastSideButtonY;
|
||||
|
||||
protected int width;
|
||||
protected int height;
|
||||
@@ -75,12 +74,18 @@ public abstract class GuiBase extends GuiContainer {
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
buttonList.clear();
|
||||
|
||||
lastButtonId = 0;
|
||||
lastSideButtonY = sideButtonYStart;
|
||||
lastSideButtonY = getSideButtonYStart();
|
||||
|
||||
init(guiLeft, guiTop);
|
||||
}
|
||||
|
||||
protected int getSideButtonYStart() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
|
||||
@@ -61,6 +61,7 @@ public class GuiGrid extends GuiBase {
|
||||
private ContainerGrid container;
|
||||
private IGrid grid;
|
||||
|
||||
private boolean hadTabs = false;
|
||||
private int tabSelected = -1;
|
||||
private int tabHovering = -1;
|
||||
|
||||
@@ -92,12 +93,7 @@ public class GuiGrid extends GuiBase {
|
||||
this.container = container;
|
||||
this.grid = grid;
|
||||
this.wasConnected = this.grid.isActive();
|
||||
|
||||
this.scrollbar = new Scrollbar(174, 20 + getTabDelta(), 12, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN || grid.getType() == EnumGridType.FLUID) ? 70 : 88);
|
||||
|
||||
if (!grid.getTabs().isEmpty()) {
|
||||
sideButtonYStart += ContainerGrid.TAB_HEIGHT - 3;
|
||||
}
|
||||
this.hadTabs = !grid.getTabs().isEmpty();
|
||||
|
||||
this.konamiOffsetsX = new int[9 * getVisibleRows()];
|
||||
this.konamiOffsetsY = new int[9 * getVisibleRows()];
|
||||
@@ -105,6 +101,8 @@ public class GuiGrid extends GuiBase {
|
||||
|
||||
@Override
|
||||
public void init(int x, int y) {
|
||||
this.scrollbar = new Scrollbar(174, 20 + getTabDelta(), 12, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN || grid.getType() == EnumGridType.FLUID) ? 70 : 88);
|
||||
|
||||
if (grid.getRedstoneModeConfig() != null) {
|
||||
addSideButton(new SideButtonRedstoneMode(this, grid.getRedstoneModeConfig()));
|
||||
}
|
||||
@@ -139,6 +137,11 @@ public class GuiGrid extends GuiBase {
|
||||
sortItems();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSideButtonYStart() {
|
||||
return super.getSideButtonYStart() + (!grid.getTabs().isEmpty() ? ContainerGrid.TAB_HEIGHT - 3 : 0);
|
||||
}
|
||||
|
||||
public IGrid getGrid() {
|
||||
return grid;
|
||||
}
|
||||
@@ -201,6 +204,23 @@ public class GuiGrid extends GuiBase {
|
||||
|
||||
sortItems();
|
||||
}
|
||||
|
||||
boolean hasTabs = !getGrid().getTabs().isEmpty();
|
||||
|
||||
if (hadTabs != hasTabs) {
|
||||
hadTabs = hasTabs;
|
||||
|
||||
height = (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 247 : 208;
|
||||
ySize = height;
|
||||
|
||||
if (hasTabs) {
|
||||
height += ContainerGrid.TAB_HEIGHT;
|
||||
}
|
||||
|
||||
initGui();
|
||||
|
||||
container.updateSlotsAccordingToTabs();
|
||||
}
|
||||
}
|
||||
|
||||
private int getRows() {
|
||||
@@ -259,7 +279,8 @@ public class GuiGrid extends GuiBase {
|
||||
ty += 3;
|
||||
}
|
||||
|
||||
int uvx = 0, uvy = 225;
|
||||
int uvx = 0;
|
||||
int uvy = 225;
|
||||
int tbw = ContainerGrid.TAB_WIDTH;
|
||||
int otx = tx;
|
||||
|
||||
@@ -388,7 +409,7 @@ public class GuiGrid extends GuiBase {
|
||||
drawTooltip(mouseX, mouseY, t("gui.refinedstorage:grid.pattern_create"));
|
||||
}
|
||||
|
||||
if (tabHovering >= 0 && tabHovering < grid.getTabs().size()) {
|
||||
if (tabHovering >= 0 && tabHovering < grid.getTabs().size() && !grid.getTabs().get(tabHovering).getName().equalsIgnoreCase("")) {
|
||||
drawTooltip(mouseX, mouseY, grid.getTabs().get(tabHovering).getName());
|
||||
}
|
||||
}
|
||||
@@ -408,7 +429,7 @@ public class GuiGrid extends GuiBase {
|
||||
|
||||
searchField.mouseClicked(mouseX, mouseY, clickedButton);
|
||||
|
||||
if (tabHovering != -1) {
|
||||
if (tabHovering >= 0 && tabHovering < grid.getTabs().size()) {
|
||||
tabSelected = tabSelected == tabHovering ? -1 : tabHovering;
|
||||
|
||||
sortItems();
|
||||
|
||||
@@ -50,6 +50,17 @@ public class ItemGridFilter extends ItemBase {
|
||||
return new ActionResult<>(EnumActionResult.PASS, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
String name = getName(stack);
|
||||
|
||||
if (!name.equalsIgnoreCase("")) {
|
||||
return name;
|
||||
}
|
||||
|
||||
return super.getItemStackDisplayName(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
|
||||
super.addInformation(stack, player, tooltip, advanced);
|
||||
|
||||
Reference in New Issue
Block a user