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