The Grid now resizes based on screen size, fixes #130
This commit is contained in:
@@ -3,6 +3,7 @@ package com.raoulvdberge.refinedstorage.container;
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.block.EnumGridType;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.*;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.IGridDisplay;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
|
||||
@@ -19,24 +20,31 @@ public class ContainerGrid extends ContainerBase {
|
||||
public static final int TAB_HEIGHT = 31;
|
||||
|
||||
private IGrid grid;
|
||||
|
||||
private boolean hadTabs;
|
||||
private IGridDisplay display;
|
||||
|
||||
private SlotGridCraftingResult craftingResultSlot;
|
||||
private SlotDisabled patternResultSlot;
|
||||
|
||||
public ContainerGrid(IGrid grid, EntityPlayer player) {
|
||||
public ContainerGrid(IGrid grid, IGridDisplay display, EntityPlayer player) {
|
||||
super(grid instanceof TileBase ? (TileBase) grid : null, player);
|
||||
|
||||
this.grid = grid;
|
||||
this.display = display;
|
||||
|
||||
this.hadTabs = !getGrid().getTabs().isEmpty();
|
||||
initSlots();
|
||||
}
|
||||
|
||||
addPlayerInventory(8, ((grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 165 : 126) + getTabDelta());
|
||||
public void initSlots() {
|
||||
this.inventorySlots.clear();
|
||||
this.inventoryItemStacks.clear();
|
||||
|
||||
int headerAndSlots = getTabDelta() + display.getHeader() + (display.getVisibleRows() * 18);
|
||||
|
||||
addPlayerInventory(8, display.getYPlayerInventory());
|
||||
|
||||
if (grid.getType() == EnumGridType.CRAFTING) {
|
||||
int x = 26;
|
||||
int y = 96 + getTabDelta();
|
||||
int y = headerAndSlots + 4;
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addSlotToContainer(new SlotGridCrafting(((TileGrid) grid).getMatrix(), i, x, y));
|
||||
@@ -49,10 +57,10 @@ public class ContainerGrid extends ContainerBase {
|
||||
}
|
||||
}
|
||||
|
||||
addSlotToContainer(craftingResultSlot = new SlotGridCraftingResult(this, player, (TileGrid) grid, 0, 130 + 4, 110 + 4 + getTabDelta()));
|
||||
addSlotToContainer(craftingResultSlot = new SlotGridCraftingResult(this, getPlayer(), (TileGrid) grid, 0, 130 + 4, headerAndSlots + 22));
|
||||
} else if (grid.getType() == EnumGridType.PATTERN) {
|
||||
int x = 8;
|
||||
int y = 96 + getTabDelta();
|
||||
int y = headerAndSlots + 4;
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addSlotToContainer(new SlotFilterLegacy(((TileGrid) grid).getMatrix(), i, x, y));
|
||||
@@ -65,10 +73,10 @@ public class ContainerGrid extends ContainerBase {
|
||||
}
|
||||
}
|
||||
|
||||
addSlotToContainer(patternResultSlot = new SlotDisabled(((TileGrid) grid).getResult(), 0, 112 + 4, 110 + 4 + getTabDelta()));
|
||||
addSlotToContainer(patternResultSlot = new SlotDisabled(((TileGrid) grid).getResult(), 0, 112 + 4, headerAndSlots + 22));
|
||||
|
||||
addSlotToContainer(new SlotItemHandler(((TileGrid) grid).getPatterns(), 0, 152, 96 + getTabDelta()));
|
||||
addSlotToContainer(new SlotOutput(((TileGrid) grid).getPatterns(), 1, 152, 132 + getTabDelta()));
|
||||
addSlotToContainer(new SlotItemHandler(((TileGrid) grid).getPatterns(), 0, 152, headerAndSlots + 4));
|
||||
addSlotToContainer(new SlotOutput(((TileGrid) grid).getPatterns(), 1, 152, headerAndSlots + 40));
|
||||
}
|
||||
|
||||
if (grid.getType() != EnumGridType.FLUID) {
|
||||
@@ -78,25 +86,6 @@ 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;
|
||||
}
|
||||
|
||||
@@ -52,18 +52,18 @@ public abstract class GuiBase extends GuiContainer {
|
||||
private int lastButtonId;
|
||||
private int lastSideButtonY;
|
||||
|
||||
protected int width;
|
||||
protected int height;
|
||||
protected int screenWidth;
|
||||
protected int screenHeight;
|
||||
|
||||
protected Scrollbar scrollbar;
|
||||
|
||||
public GuiBase(Container container, int width, int height) {
|
||||
public GuiBase(Container container, int screenWidth, int screenHeight) {
|
||||
super(container);
|
||||
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.xSize = width;
|
||||
this.ySize = height;
|
||||
this.screenWidth = screenWidth;
|
||||
this.screenHeight = screenHeight;
|
||||
this.xSize = screenWidth;
|
||||
this.ySize = screenHeight;
|
||||
}
|
||||
|
||||
public Scrollbar getScrollbar() {
|
||||
@@ -72,6 +72,8 @@ public abstract class GuiBase extends GuiContainer {
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
calcHeight();
|
||||
|
||||
super.initGui();
|
||||
|
||||
buttonList.clear();
|
||||
@@ -82,6 +84,9 @@ public abstract class GuiBase extends GuiContainer {
|
||||
init(guiLeft, guiTop);
|
||||
}
|
||||
|
||||
protected void calcHeight() {
|
||||
}
|
||||
|
||||
protected int getSideButtonYStart() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class GuiConstructor extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/constructor.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,7 +42,7 @@ public class GuiController extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/controller.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
|
||||
int barHeightNew = TileController.getEnergyScaled(TileController.ENERGY_STORED.getValue(), TileController.ENERGY_CAPACITY.getValue(), barHeight);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class GuiCrafter extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/crafter.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -94,7 +94,7 @@ public class GuiCraftingMonitor extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/crafting_monitor.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
|
||||
if (itemSelectedX != -1 &&
|
||||
itemSelectedY != -1 &&
|
||||
|
||||
@@ -88,7 +88,7 @@ public class GuiCraftingPreview extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/crafting_preview.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
|
||||
if (stacks.isEmpty()) {
|
||||
drawRect(x + 7, y + 20, x + 142, y + 139, 0xFFDBDBDB);
|
||||
|
||||
@@ -33,7 +33,7 @@ public class GuiDestructor extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/destructor.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -46,7 +46,7 @@ public class GuiDetector extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/detector.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
|
||||
AMOUNT.drawTextBox();
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class GuiDiskManipulator extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/disk_manipulator.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,7 +31,7 @@ public class GuiExporter extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/exporter.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,7 +29,7 @@ public class GuiFluidInterface extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/fluid_interface.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
|
||||
if (TileFluidInterface.TANK_IN.getValue() != null) {
|
||||
TANK_RENDERER.draw(mc, x + 46, y + 56, TileFluidInterface.TANK_IN.getValue());
|
||||
|
||||
@@ -65,7 +65,7 @@ public class GuiGridFilter extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/grid_filter.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
|
||||
nameField.drawTextBox();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSGui;
|
||||
import com.raoulvdberge.refinedstorage.container.*;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GridDisplayDummy;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
||||
import com.raoulvdberge.refinedstorage.tile.*;
|
||||
import com.raoulvdberge.refinedstorage.tile.craftingmonitor.TileCraftingMonitor;
|
||||
@@ -23,7 +24,7 @@ public class GuiHandler implements IGuiHandler {
|
||||
case RSGui.CONTROLLER:
|
||||
return new ContainerController((TileController) tile, player);
|
||||
case RSGui.GRID:
|
||||
return new ContainerGrid((TileGrid) tile, player);
|
||||
return new ContainerGrid((TileGrid) tile, new GridDisplayDummy(), player);
|
||||
case RSGui.DISK_DRIVE:
|
||||
return new ContainerDiskDrive((TileDiskDrive) tile, player);
|
||||
case RSGui.IMPORTER:
|
||||
@@ -90,7 +91,9 @@ public class GuiHandler implements IGuiHandler {
|
||||
case RSGui.CONTROLLER:
|
||||
return new GuiController((ContainerController) getContainer(ID, player, tile), (TileController) tile);
|
||||
case RSGui.GRID:
|
||||
return new GuiGrid((ContainerGrid) getContainer(ID, player, tile), (TileGrid) tile);
|
||||
GuiGrid gui = new GuiGrid(null, (TileGrid) tile);
|
||||
gui.inventorySlots = new ContainerGrid((TileGrid) tile, gui, player);
|
||||
return gui;
|
||||
case RSGui.WIRELESS_GRID:
|
||||
return getWirelessGridGui(player, x, y);
|
||||
case RSGui.DISK_DRIVE:
|
||||
@@ -149,11 +152,13 @@ public class GuiHandler implements IGuiHandler {
|
||||
private GuiGrid getWirelessGridGui(EntityPlayer player, int hand, int controllerDimension) {
|
||||
WirelessGrid grid = getWirelessGrid(player, hand, controllerDimension);
|
||||
|
||||
return new GuiGrid(new ContainerGrid(grid, player), grid);
|
||||
GuiGrid gui = new GuiGrid(null, grid);
|
||||
gui.inventorySlots = new ContainerGrid(grid, gui, player);
|
||||
return gui;
|
||||
}
|
||||
|
||||
private ContainerGrid getWirelessGridContainer(EntityPlayer player, int hand, int controllerDimension) {
|
||||
return new ContainerGrid(getWirelessGrid(player, hand, controllerDimension), player);
|
||||
return new ContainerGrid(getWirelessGrid(player, hand, controllerDimension), new GridDisplayDummy(), player);
|
||||
}
|
||||
|
||||
private WirelessCraftingMonitor getWirelessCraftingMonitor(EntityPlayer player, int hand, int controllerDimension) {
|
||||
|
||||
@@ -34,7 +34,7 @@ public class GuiImporter extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/importer.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,7 +28,7 @@ public class GuiInterface extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/interface.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,7 +26,7 @@ public class GuiNetworkTransmitter extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/network_transmitter.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -46,7 +46,7 @@ public class GuiProcessingPatternEncoder extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/processing_pattern_encoder.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
|
||||
int ty = 0;
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public class GuiReaderWriter extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/readerwriter.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
|
||||
if (itemSelectedX != -1 &&
|
||||
itemSelectedY != -1 &&
|
||||
|
||||
@@ -22,7 +22,7 @@ public class GuiRelay extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/relay.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,7 @@ public class GuiSolderer extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/solderer.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
|
||||
if (TileSolderer.WORKING.getValue()) {
|
||||
drawTexture(x + 83, y + 38 - 1, 212, 0, getProgressScaled(22), 15);
|
||||
|
||||
@@ -73,7 +73,7 @@ public class GuiStorage extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture(texture);
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
|
||||
int barHeightNew = (int) ((float) gui.getStored() / (float) gui.getCapacity() * (float) barHeight);
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class GuiWirelessTransmitter extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/wireless_transmitter.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
28
src/main/java/com/raoulvdberge/refinedstorage/gui/grid/GridDisplayDummy.java
Executable file
28
src/main/java/com/raoulvdberge/refinedstorage/gui/grid/GridDisplayDummy.java
Executable file
@@ -0,0 +1,28 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.grid;
|
||||
|
||||
public class GridDisplayDummy implements IGridDisplay {
|
||||
@Override
|
||||
public int getVisibleRows() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRows() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeader() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFooter() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getYPlayerInventory() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,13 @@ package com.raoulvdberge.refinedstorage.gui.grid;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class GridFilteredItem {
|
||||
public class GridFilter {
|
||||
private ItemStack stack;
|
||||
private int compare;
|
||||
private int mode;
|
||||
private boolean modFilter;
|
||||
|
||||
public GridFilteredItem(ItemStack stack, int compare, int mode, boolean modFilter) {
|
||||
public GridFilter(ItemStack stack, int compare, int mode, boolean modFilter) {
|
||||
this.stack = stack;
|
||||
this.compare = compare;
|
||||
this.mode = mode;
|
||||
@@ -5,17 +5,17 @@ import net.minecraft.item.ItemStack;
|
||||
import java.util.List;
|
||||
|
||||
public class GridTab {
|
||||
private List<GridFilteredItem> filters;
|
||||
private List<GridFilter> filters;
|
||||
private String name;
|
||||
private ItemStack icon;
|
||||
|
||||
public GridTab(List<GridFilteredItem> filters, String name, ItemStack icon) {
|
||||
public GridTab(List<GridFilter> filters, String name, ItemStack icon) {
|
||||
this.filters = filters;
|
||||
this.name = name;
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public List<GridFilteredItem> getFilters() {
|
||||
public List<GridFilter> getFilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.google.common.primitives.Ints;
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerCraftingSettings;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.ClientStackItem;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackItem;
|
||||
import com.raoulvdberge.refinedstorage.network.MessageGridCraftingPreview;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
@@ -21,19 +21,19 @@ public class GuiCraftingStart extends GuiBase {
|
||||
|
||||
protected GuiTextField amountField;
|
||||
private GuiBase parent;
|
||||
private ClientStackItem stack;
|
||||
private GridStackItem stack;
|
||||
private GuiButton startButton;
|
||||
private GuiButton cancelButton;
|
||||
private GuiButton[] incrementButtons = new GuiButton[6];
|
||||
|
||||
public GuiCraftingStart(GuiBase parent, ClientStackItem stack, Container container, int w, int h) {
|
||||
public GuiCraftingStart(GuiBase parent, GridStackItem stack, Container container, int w, int h) {
|
||||
super(container, w, h);
|
||||
|
||||
this.parent = parent;
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public GuiCraftingStart(GuiGrid parent, EntityPlayer player, ClientStackItem stack) {
|
||||
public GuiCraftingStart(GuiGrid parent, EntityPlayer player, GridStackItem stack) {
|
||||
this(parent, stack, new ContainerCraftingSettings(player, stack.getStack()), 172, 99);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class GuiCraftingStart extends GuiBase {
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture(getTexture());
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
|
||||
amountField.drawTextBox();
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ import com.raoulvdberge.refinedstorage.gui.grid.filtering.GridFilterParser;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.filtering.IGridFilter;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.sorting.GridSortingName;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.sorting.GridSortingQuantity;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.ClientStackFluid;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.ClientStackItem;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IClientStack;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackFluid;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackItem;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||
import com.raoulvdberge.refinedstorage.gui.sidebutton.*;
|
||||
import com.raoulvdberge.refinedstorage.integration.jei.IntegrationJEI;
|
||||
import com.raoulvdberge.refinedstorage.integration.jei.RSJEIPlugin;
|
||||
@@ -42,14 +42,14 @@ import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class GuiGrid extends GuiBase {
|
||||
public class GuiGrid extends GuiBase implements IGridDisplay {
|
||||
private static final GridSortingQuantity SORTING_QUANTITY = new GridSortingQuantity();
|
||||
private static final GridSortingName SORTING_NAME = new GridSortingName();
|
||||
|
||||
public static final ListMultimap<Item, ClientStackItem> ITEMS = Multimaps.synchronizedListMultimap(ArrayListMultimap.create());
|
||||
public static final ListMultimap<Fluid, ClientStackFluid> FLUIDS = Multimaps.synchronizedListMultimap(ArrayListMultimap.create());
|
||||
public static final ListMultimap<Item, GridStackItem> ITEMS = Multimaps.synchronizedListMultimap(ArrayListMultimap.create());
|
||||
public static final ListMultimap<Fluid, GridStackFluid> FLUIDS = Multimaps.synchronizedListMultimap(ArrayListMultimap.create());
|
||||
|
||||
public static List<IClientStack> STACKS = new ArrayList<>();
|
||||
public static List<IGridStack> STACKS = new ArrayList<>();
|
||||
|
||||
private static boolean markedForSorting;
|
||||
|
||||
@@ -58,7 +58,6 @@ public class GuiGrid extends GuiBase {
|
||||
private GuiTextField searchField;
|
||||
private GuiCheckBox oredictPattern;
|
||||
|
||||
private ContainerGrid container;
|
||||
private IGrid grid;
|
||||
|
||||
private boolean hadTabs = false;
|
||||
@@ -87,9 +86,8 @@ public class GuiGrid extends GuiBase {
|
||||
}
|
||||
|
||||
public GuiGrid(ContainerGrid container, IGrid grid) {
|
||||
super(container, grid.getType() == EnumGridType.FLUID ? 193 : 227, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 247 : 208);
|
||||
super(container, grid.getType() == EnumGridType.FLUID ? 193 : 227, 0);
|
||||
|
||||
this.container = container;
|
||||
this.grid = grid;
|
||||
this.wasConnected = this.grid.isActive();
|
||||
|
||||
@@ -97,9 +95,22 @@ public class GuiGrid extends GuiBase {
|
||||
this.konamiOffsetsY = new int[9 * getVisibleRows()];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void calcHeight() {
|
||||
this.ySize = getHeader() + getFooter() + (getVisibleRows() * 18);
|
||||
|
||||
if (hadTabs) {
|
||||
this.ySize += ContainerGrid.TAB_HEIGHT;
|
||||
}
|
||||
|
||||
this.screenHeight = ySize;
|
||||
}
|
||||
|
||||
@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);
|
||||
((ContainerGrid) this.inventorySlots).initSlots();
|
||||
|
||||
this.scrollbar = new Scrollbar(174, getTabDelta() + getHeader(), 12, (getVisibleRows() * 18) - 2);
|
||||
|
||||
if (grid.getRedstoneModeConfig() != null) {
|
||||
addSideButton(new SideButtonRedstoneMode(this, grid.getRedstoneModeConfig()));
|
||||
@@ -121,7 +132,7 @@ public class GuiGrid extends GuiBase {
|
||||
}
|
||||
|
||||
if (grid.getType() == EnumGridType.PATTERN) {
|
||||
oredictPattern = addCheckBox(x + 64, y + 138 + getTabDelta(), t("misc.refinedstorage:oredict"), TileGrid.OREDICT_PATTERN.getValue());
|
||||
oredictPattern = addCheckBox(x + 64, getTabDelta() + getHeader() + (getVisibleRows() * 18) + 78, t("misc.refinedstorage:oredict"), TileGrid.OREDICT_PATTERN.getValue());
|
||||
}
|
||||
|
||||
if (grid.getType() != EnumGridType.FLUID) {
|
||||
@@ -145,7 +156,7 @@ public class GuiGrid extends GuiBase {
|
||||
}
|
||||
|
||||
private void sortItems() {
|
||||
List<IClientStack> stacks = new ArrayList<>();
|
||||
List<IGridStack> stacks = new ArrayList<>();
|
||||
|
||||
if (grid.isActive()) {
|
||||
stacks.addAll(grid.getType() == EnumGridType.FLUID ? FLUIDS.values() : ITEMS.values());
|
||||
@@ -156,10 +167,10 @@ public class GuiGrid extends GuiBase {
|
||||
(grid.getTabSelected() >= 0 && grid.getTabSelected() < grid.getTabs().size()) ? grid.getTabs().get(grid.getTabSelected()).getFilters() : grid.getFilteredItems()
|
||||
);
|
||||
|
||||
Iterator<IClientStack> t = stacks.iterator();
|
||||
Iterator<IGridStack> t = stacks.iterator();
|
||||
|
||||
while (t.hasNext()) {
|
||||
IClientStack stack = t.next();
|
||||
IGridStack stack = t.next();
|
||||
|
||||
for (IGridFilter filter : filters) {
|
||||
if (!filter.accepts(stack)) {
|
||||
@@ -212,24 +223,45 @@ public class GuiGrid extends GuiBase {
|
||||
if (hadTabs != hasTabs) {
|
||||
hadTabs = hasTabs;
|
||||
|
||||
ySize = (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 247 : 208;
|
||||
|
||||
if (hasTabs) {
|
||||
ySize += ContainerGrid.TAB_HEIGHT;
|
||||
}
|
||||
|
||||
this.height = ySize;
|
||||
|
||||
initGui();
|
||||
|
||||
container.updateSlotsAccordingToTabs();
|
||||
}
|
||||
}
|
||||
|
||||
private int getRows() {
|
||||
@Override
|
||||
public int getHeader() {
|
||||
return 19;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFooter() {
|
||||
return (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 156 : 99;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getYPlayerInventory() {
|
||||
int yp = getTabDelta() + getHeader() + (getVisibleRows() * 18);
|
||||
|
||||
if (grid.getType() == EnumGridType.NORMAL || grid.getType() == EnumGridType.FLUID) {
|
||||
yp += 16;
|
||||
} else if (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) {
|
||||
yp += 73;
|
||||
}
|
||||
|
||||
return yp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRows() {
|
||||
return Math.max(0, (int) Math.ceil((float) STACKS.size() / 9F));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVisibleRows() {
|
||||
int screenSpaceAvailable = height - getHeader() - getFooter() - (hadTabs ? ContainerGrid.TAB_HEIGHT : 0);
|
||||
|
||||
return Math.max(3, (screenSpaceAvailable / 18) - 3);
|
||||
}
|
||||
|
||||
private boolean isOverSlotWithItem() {
|
||||
return grid.isActive() && isOverSlot() && slotNumber < STACKS.size();
|
||||
}
|
||||
@@ -242,23 +274,21 @@ public class GuiGrid extends GuiBase {
|
||||
return inBounds(7, 19 + getTabDelta(), 162, 18 * getVisibleRows(), mouseX, mouseY);
|
||||
}
|
||||
|
||||
private int getVisibleRows() {
|
||||
return (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 4 : 5;
|
||||
}
|
||||
|
||||
private boolean isOverClear(int mouseX, int mouseY) {
|
||||
int y = getTabDelta() + getHeader() + (getVisibleRows() * 18) + 4;
|
||||
|
||||
switch (grid.getType()) {
|
||||
case CRAFTING:
|
||||
return inBounds(82, 95 + getTabDelta(), 7, 7, mouseX, mouseY);
|
||||
return inBounds(82, y, 7, 7, mouseX, mouseY);
|
||||
case PATTERN:
|
||||
return inBounds(64, 95 + getTabDelta(), 7, 7, mouseX, mouseY);
|
||||
return inBounds(64, y, 7, 7, mouseX, mouseY);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isOverCreatePattern(int mouseX, int mouseY) {
|
||||
return grid.getType() == EnumGridType.PATTERN && inBounds(152, 114 + getTabDelta(), 16, 16, mouseX, mouseY) && ((TileGrid) grid).canCreatePattern();
|
||||
return grid.getType() == EnumGridType.PATTERN && inBounds(152, getTabDelta() + getHeader() + (getVisibleRows() * 18) + 22, 16, 16, mouseX, mouseY) && ((TileGrid) grid).canCreatePattern();
|
||||
}
|
||||
|
||||
private int getTabDelta() {
|
||||
@@ -327,7 +357,20 @@ public class GuiGrid extends GuiBase {
|
||||
bindTexture("gui/grid.png");
|
||||
}
|
||||
|
||||
drawTexture(x, y + getTabDelta(), 0, 0, width, height - (!grid.getTabs().isEmpty() ? ContainerGrid.TAB_HEIGHT : 0));
|
||||
int yy = y + getTabDelta();
|
||||
|
||||
drawTexture(x, yy, 0, 0, screenWidth, getHeader());
|
||||
int r = getVisibleRows();
|
||||
|
||||
for (int i = 0; i < r; ++i) {
|
||||
yy += 18;
|
||||
|
||||
drawTexture(x, yy, 0, getHeader() + (i > 0 ? (i == r - 1 ? 18 * 2 : 18) : 0), screenWidth, 18);
|
||||
}
|
||||
|
||||
yy += 18;
|
||||
|
||||
drawTexture(x, yy, 0, getHeader() + (18 * 3), screenWidth, getFooter());
|
||||
|
||||
for (GridTab tab : grid.getTabs()) {
|
||||
renderTab(tab, true, x, y, mouseX, mouseY);
|
||||
@@ -344,7 +387,7 @@ public class GuiGrid extends GuiBase {
|
||||
ty = 2;
|
||||
}
|
||||
|
||||
drawTexture(x + 152, y + 114 + getTabDelta(), 240, ty * 16, 16, 16);
|
||||
drawTexture(x + 152, y + getTabDelta() + getHeader() + (getVisibleRows() * 18) + 22, 240, ty * 16, 16, 16);
|
||||
}
|
||||
|
||||
searchField.drawTextBox();
|
||||
@@ -353,10 +396,10 @@ public class GuiGrid extends GuiBase {
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7 + getTabDelta(), t(grid.getGuiTitle()));
|
||||
drawString(7, ((grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 153 : 114) + getTabDelta(), t("container.inventory"));
|
||||
drawString(7, getYPlayerInventory() - 12, t("container.inventory"));
|
||||
|
||||
int x = 8;
|
||||
int y = 20 + getTabDelta();
|
||||
int y = 19 + getTabDelta();
|
||||
|
||||
this.slotNumber = -1;
|
||||
|
||||
@@ -457,7 +500,7 @@ public class GuiGrid extends GuiBase {
|
||||
RS.INSTANCE.network.sendToServer(new MessageGridCraftingClear((TileGrid) grid));
|
||||
}
|
||||
|
||||
ItemStack held = container.getPlayer().inventory.getItemStack();
|
||||
ItemStack held = ((ContainerGrid) this.inventorySlots).getPlayer().inventory.getItemStack();
|
||||
|
||||
if (isOverSlotArea(mouseX - guiLeft, mouseY - guiTop) && !held.isEmpty() && (clickedButton == 0 || clickedButton == 1)) {
|
||||
RS.INSTANCE.network.sendToServer(grid.getType() == EnumGridType.FLUID ? new MessageGridFluidInsertHeld() : new MessageGridItemInsertHeld(clickedButton == 1));
|
||||
@@ -465,10 +508,10 @@ public class GuiGrid extends GuiBase {
|
||||
|
||||
if (isOverSlotWithItem()) {
|
||||
if (grid.getType() != EnumGridType.FLUID && (held.isEmpty() || (!held.isEmpty() && clickedButton == 2))) {
|
||||
ClientStackItem stack = (ClientStackItem) STACKS.get(slotNumber);
|
||||
GridStackItem stack = (GridStackItem) STACKS.get(slotNumber);
|
||||
|
||||
if (stack.isCraftable() && (stack.doesDisplayCraftText() || (GuiScreen.isShiftKeyDown() && GuiScreen.isCtrlKeyDown()))) {
|
||||
FMLCommonHandler.instance().showGuiScreen(new GuiCraftingStart(this, container.getPlayer(), stack));
|
||||
FMLCommonHandler.instance().showGuiScreen(new GuiCraftingStart(this, ((ContainerGrid) this.inventorySlots).getPlayer(), stack));
|
||||
} else {
|
||||
int flags = 0;
|
||||
|
||||
|
||||
13
src/main/java/com/raoulvdberge/refinedstorage/gui/grid/IGridDisplay.java
Executable file
13
src/main/java/com/raoulvdberge/refinedstorage/gui/grid/IGridDisplay.java
Executable file
@@ -0,0 +1,13 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.grid;
|
||||
|
||||
public interface IGridDisplay {
|
||||
int getVisibleRows();
|
||||
|
||||
int getRows();
|
||||
|
||||
int getHeader();
|
||||
|
||||
int getFooter();
|
||||
|
||||
int getYPlayerInventory();
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.grid.filtering;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.ClientStackItem;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IClientStack;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackItem;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||
|
||||
public class GridFilterCraftable implements IGridFilter {
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class GridFilterCraftable implements Predicate<IGridStack> {
|
||||
private boolean craftable;
|
||||
|
||||
public GridFilterCraftable(boolean craftable) {
|
||||
@@ -11,7 +13,7 @@ public class GridFilterCraftable implements IGridFilter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accepts(IClientStack stack) {
|
||||
return stack instanceof ClientStackItem && ((ClientStackItem) stack).isCraftable() == craftable;
|
||||
public boolean test(IGridStack stack) {
|
||||
return stack instanceof GridStackItem && ((GridStackItem) stack).isCraftable() == craftable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,33 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.grid.filtering;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GridFilteredItem;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.ClientStackItem;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IClientStack;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GridFilter;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackItem;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemGridFilter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class GridFilterFilteredItems implements IGridFilter {
|
||||
private List<GridFilteredItem> filteredItems;
|
||||
public class GridFilterFilteredItems implements Predicate<IGridStack> {
|
||||
private List<GridFilter> filteredItems;
|
||||
|
||||
public GridFilterFilteredItems(List<GridFilteredItem> filteredItems) {
|
||||
public GridFilterFilteredItems(List<GridFilter> filteredItems) {
|
||||
this.filteredItems = filteredItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accepts(IClientStack stack) {
|
||||
public boolean test(IGridStack stack) {
|
||||
int lastMode = ItemGridFilter.MODE_WHITELIST;
|
||||
|
||||
for (GridFilteredItem filteredItem : filteredItems) {
|
||||
for (GridFilter filteredItem : filteredItems) {
|
||||
lastMode = filteredItem.getMode();
|
||||
|
||||
if (filteredItem.isModFilter()) {
|
||||
if (filteredItem.getStack().getItem().getRegistryName().getResourceDomain().equalsIgnoreCase(stack.getModId())) {
|
||||
return filteredItem.getMode() == ItemGridFilter.MODE_WHITELIST;
|
||||
}
|
||||
} else if (API.instance().getComparer().isEqual(((ClientStackItem) stack).getStack(), filteredItem.getStack(), filteredItem.getCompare())) {
|
||||
} else if (API.instance().getComparer().isEqual(((GridStackItem) stack).getStack(), filteredItem.getStack(), filteredItem.getCompare())) {
|
||||
return filteredItem.getMode() == ItemGridFilter.MODE_WHITELIST;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.grid.filtering;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IClientStack;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
|
||||
public class GridFilterMod implements IGridFilter {
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class GridFilterMod implements Predicate<IGridStack> {
|
||||
private String modName;
|
||||
|
||||
public GridFilterMod(String modName) {
|
||||
@@ -21,7 +23,7 @@ public class GridFilterMod implements IGridFilter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accepts(IClientStack stack) {
|
||||
public boolean test(IGridStack stack) {
|
||||
String otherModId = stack.getModId().toLowerCase();
|
||||
|
||||
if (!getModNameFromModId(otherModId).contains(modName)) {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.grid.filtering;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IClientStack;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||
|
||||
public class GridFilterName implements IGridFilter {
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class GridFilterName implements Predicate<IGridStack> {
|
||||
private String name;
|
||||
|
||||
public GridFilterName(String name) {
|
||||
@@ -10,7 +12,7 @@ public class GridFilterName implements IGridFilter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accepts(IClientStack stack) {
|
||||
public boolean test(IGridStack stack) {
|
||||
return stack.getName().toLowerCase().contains(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.grid.filtering;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GridFilteredItem;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GridFilter;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class GridFilterParser {
|
||||
public static List<IGridFilter> getFilters(IGrid grid, String query, List<GridFilteredItem> itemFilters) {
|
||||
List<IGridFilter> filters = new LinkedList<>();
|
||||
public static List<Predicate<IGridStack>> getFilters(IGrid grid, String query, List<GridFilter> filteredItems) {
|
||||
List<Predicate<IGridStack>> filters = new LinkedList<>();
|
||||
|
||||
for (String part : query.toLowerCase().trim().split(" ")) {
|
||||
if (part.startsWith("@")) {
|
||||
@@ -27,8 +29,8 @@ public class GridFilterParser {
|
||||
filters.add(new GridFilterCraftable(true));
|
||||
}
|
||||
|
||||
if (!itemFilters.isEmpty()) {
|
||||
filters.add(new GridFilterFilteredItems(itemFilters));
|
||||
if (!filteredItems.isEmpty()) {
|
||||
filters.add(new GridFilterFilteredItems(filteredItems));
|
||||
}
|
||||
|
||||
return filters;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.grid.filtering;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IClientStack;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||
|
||||
public class GridFilterTooltip implements IGridFilter {
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class GridFilterTooltip implements Predicate<IGridStack> {
|
||||
private String tooltip;
|
||||
|
||||
public GridFilterTooltip(String tooltip) {
|
||||
@@ -10,7 +12,7 @@ public class GridFilterTooltip implements IGridFilter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accepts(IClientStack stack) {
|
||||
public boolean test(IGridStack stack) {
|
||||
String otherTooltip = stack.getTooltip().trim().toLowerCase();
|
||||
|
||||
if (!otherTooltip.contains("\n")) {
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.grid.filtering;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IClientStack;
|
||||
|
||||
public interface IGridFilter {
|
||||
boolean accepts(IClientStack stack);
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.grid.sorting;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IClientStack;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public abstract class GridSorting implements Comparator<IClientStack> {
|
||||
public abstract class GridSorting implements Comparator<IGridStack> {
|
||||
protected int sortingDirection;
|
||||
|
||||
public void setSortingDirection(int sortingDirection) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.grid.sorting;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IClientStack;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
|
||||
|
||||
public class GridSortingName extends GridSorting {
|
||||
@Override
|
||||
public int compare(IClientStack left, IClientStack right) {
|
||||
public int compare(IGridStack left, IGridStack right) {
|
||||
String leftName = left.getName();
|
||||
String rightName = right.getName();
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.grid.sorting;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IClientStack;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
|
||||
|
||||
public class GridSortingQuantity extends GridSorting {
|
||||
@Override
|
||||
public int compare(IClientStack left, IClientStack right) {
|
||||
public int compare(IGridStack left, IGridStack right) {
|
||||
int leftSize = left.getQuantity();
|
||||
int rightSize = right.getQuantity();
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class ClientStackFluid implements IClientStack {
|
||||
public class GridStackFluid implements IGridStack {
|
||||
private int hash;
|
||||
private FluidStack stack;
|
||||
|
||||
public ClientStackFluid(Pair<Integer, FluidStack> data) {
|
||||
public GridStackFluid(Pair<Integer, FluidStack> data) {
|
||||
this.hash = data.getLeft();
|
||||
this.stack = data.getRight();
|
||||
}
|
||||
@@ -57,6 +57,6 @@ public class ClientStackFluid implements IClientStack {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof ClientStackFluid && ((ClientStackFluid) obj).getStack().isFluidEqual(stack);
|
||||
return obj instanceof GridStackFluid && ((GridStackFluid) obj).getStack().isFluidEqual(stack);
|
||||
}
|
||||
}
|
||||
@@ -9,17 +9,16 @@ import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ClientStackItem implements IClientStack {
|
||||
public class GridStackItem implements IGridStack {
|
||||
private int hash;
|
||||
private ItemStack stack;
|
||||
private boolean craftable;
|
||||
private boolean displayCraftText;
|
||||
|
||||
public ClientStackItem(ByteBuf buf) {
|
||||
public GridStackItem(ByteBuf buf) {
|
||||
stack = RSUtils.readItemStack(buf);
|
||||
hash = buf.readInt();
|
||||
craftable = buf.readBoolean();
|
||||
@@ -109,6 +108,6 @@ public class ClientStackItem implements IClientStack {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof IClientStack && ((ClientStackItem) obj).getHash() == hash;
|
||||
return obj instanceof IGridStack && ((GridStackItem) obj).getHash() == hash;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.raoulvdberge.refinedstorage.gui.grid.stack;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
|
||||
public interface IClientStack {
|
||||
public interface IGridStack {
|
||||
int getHash();
|
||||
|
||||
String getName();
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.raoulvdberge.refinedstorage.inventory;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSItems;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GridFilteredItem;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GridFilter;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GridTab;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemGridFilter;
|
||||
@@ -13,10 +13,10 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemHandlerGridFilterInGrid extends ItemHandlerBasic {
|
||||
private List<GridFilteredItem> filteredItems;
|
||||
private List<GridFilter> filteredItems;
|
||||
private List<GridTab> tabs;
|
||||
|
||||
public ItemHandlerGridFilterInGrid(List<GridFilteredItem> filteredItems, List<GridTab> tabs) {
|
||||
public ItemHandlerGridFilterInGrid(List<GridFilter> filteredItems, List<GridTab> tabs) {
|
||||
super(4, new ItemValidatorBasic(RSItems.GRID_FILTER));
|
||||
|
||||
this.filteredItems = filteredItems;
|
||||
@@ -40,11 +40,11 @@ public class ItemHandlerGridFilterInGrid extends ItemHandlerBasic {
|
||||
|
||||
ItemHandlerGridFilter items = new ItemHandlerGridFilter(filter);
|
||||
|
||||
List<GridFilteredItem> filters = new ArrayList<>();
|
||||
List<GridFilter> filters = new ArrayList<>();
|
||||
|
||||
for (ItemStack item : items.getFilteredItems()) {
|
||||
if (!item.isEmpty()) {
|
||||
filters.add(new GridFilteredItem(item, compare, mode, modFilter));
|
||||
filters.add(new GridFilter(item, compare, mode, modFilter));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.raoulvdberge.refinedstorage.network;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.ClientStackFluid;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackFluid;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -14,7 +14,7 @@ public class MessageGridFluidDelta implements IMessage, IMessageHandler<MessageG
|
||||
private FluidStack stack;
|
||||
private int delta;
|
||||
|
||||
private ClientStackFluid clientStack;
|
||||
private GridStackFluid clientStack;
|
||||
|
||||
public MessageGridFluidDelta() {
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class MessageGridFluidDelta implements IMessage, IMessageHandler<MessageG
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
clientStack = new ClientStackFluid(RSUtils.readFluidStack(buf));
|
||||
clientStack = new GridStackFluid(RSUtils.readFluidStack(buf));
|
||||
delta = buf.readInt();
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class MessageGridFluidDelta implements IMessage, IMessageHandler<MessageG
|
||||
public IMessage onMessage(MessageGridFluidDelta message, MessageContext ctx) {
|
||||
Fluid fluid = message.clientStack.getStack().getFluid();
|
||||
|
||||
for (ClientStackFluid stack : GuiGrid.FLUIDS.get(fluid)) {
|
||||
for (GridStackFluid stack : GuiGrid.FLUIDS.get(fluid)) {
|
||||
if (stack.equals(message.clientStack)) {
|
||||
if (stack.getStack().amount + message.delta == 0) {
|
||||
GuiGrid.FLUIDS.remove(fluid, stack);
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.raoulvdberge.refinedstorage.network;
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.ClientStackFluid;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackFluid;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
@@ -15,7 +15,7 @@ import java.util.List;
|
||||
|
||||
public class MessageGridFluidUpdate implements IMessage, IMessageHandler<MessageGridFluidUpdate, IMessage> {
|
||||
private INetworkMaster network;
|
||||
private List<ClientStackFluid> stacks = new ArrayList<>();
|
||||
private List<GridStackFluid> stacks = new ArrayList<>();
|
||||
|
||||
public MessageGridFluidUpdate() {
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public class MessageGridFluidUpdate implements IMessage, IMessageHandler<Message
|
||||
int items = buf.readInt();
|
||||
|
||||
for (int i = 0; i < items; ++i) {
|
||||
this.stacks.add(new ClientStackFluid(RSUtils.readFluidStack(buf)));
|
||||
this.stacks.add(new GridStackFluid(RSUtils.readFluidStack(buf)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class MessageGridFluidUpdate implements IMessage, IMessageHandler<Message
|
||||
public IMessage onMessage(MessageGridFluidUpdate message, MessageContext ctx) {
|
||||
GuiGrid.FLUIDS.clear();
|
||||
|
||||
for (ClientStackFluid item : message.stacks) {
|
||||
for (GridStackFluid item : message.stacks) {
|
||||
GuiGrid.FLUIDS.put(item.getStack().getFluid(), item);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.raoulvdberge.refinedstorage.network;
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.ClientStackItem;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackItem;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -16,7 +16,7 @@ public class MessageGridItemDelta implements IMessage, IMessageHandler<MessageGr
|
||||
private ItemStack stack;
|
||||
private int delta;
|
||||
|
||||
private ClientStackItem clientStack;
|
||||
private GridStackItem clientStack;
|
||||
|
||||
public MessageGridItemDelta() {
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public class MessageGridItemDelta implements IMessage, IMessageHandler<MessageGr
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
clientStack = new ClientStackItem(buf);
|
||||
clientStack = new GridStackItem(buf);
|
||||
delta = buf.readInt();
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class MessageGridItemDelta implements IMessage, IMessageHandler<MessageGr
|
||||
public IMessage onMessage(MessageGridItemDelta message, MessageContext ctx) {
|
||||
Item item = message.clientStack.getStack().getItem();
|
||||
|
||||
for (ClientStackItem stack : GuiGrid.ITEMS.get(item)) {
|
||||
for (GridStackItem stack : GuiGrid.ITEMS.get(item)) {
|
||||
if (stack.equals(message.clientStack)) {
|
||||
if (stack.getStack().getCount() + message.delta == 0) {
|
||||
if (message.clientStack.isCraftable()) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.ClientStackItem;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackItem;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
@@ -17,7 +17,7 @@ import java.util.List;
|
||||
|
||||
public class MessageGridItemUpdate implements IMessage, IMessageHandler<MessageGridItemUpdate, IMessage> {
|
||||
private INetworkMaster network;
|
||||
private List<ClientStackItem> stacks = new ArrayList<>();
|
||||
private List<GridStackItem> stacks = new ArrayList<>();
|
||||
|
||||
public MessageGridItemUpdate() {
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class MessageGridItemUpdate implements IMessage, IMessageHandler<MessageG
|
||||
int items = buf.readInt();
|
||||
|
||||
for (int i = 0; i < items; ++i) {
|
||||
this.stacks.add(new ClientStackItem(buf));
|
||||
this.stacks.add(new GridStackItem(buf));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,12 +62,12 @@ public class MessageGridItemUpdate implements IMessage, IMessageHandler<MessageG
|
||||
public IMessage onMessage(MessageGridItemUpdate message, MessageContext ctx) {
|
||||
GuiGrid.ITEMS.clear();
|
||||
|
||||
for (ClientStackItem item : message.stacks) {
|
||||
for (GridStackItem item : message.stacks) {
|
||||
boolean canAdd = true;
|
||||
|
||||
if (item.doesDisplayCraftText()) {
|
||||
// This is an output from a pattern being sent. Only add it if it hasn't been added before.
|
||||
for (ClientStackItem otherItem : GuiGrid.ITEMS.get(item.getStack().getItem())) {
|
||||
for (GridStackItem otherItem : GuiGrid.ITEMS.get(item.getStack().getItem())) {
|
||||
if (API.instance().getComparer().isEqualNoQuantity(item.getStack(), otherItem.getStack())) {
|
||||
canAdd = false;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.raoulvdberge.refinedstorage.tile.grid;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IFluidGridHandler;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IItemGridHandler;
|
||||
import com.raoulvdberge.refinedstorage.block.EnumGridType;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GridFilteredItem;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GridFilter;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GridTab;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
@@ -44,7 +44,7 @@ public interface IGrid {
|
||||
|
||||
void onTabSelectionChanged(int tab);
|
||||
|
||||
List<GridFilteredItem> getFilteredItems();
|
||||
List<GridFilter> getFilteredItems();
|
||||
|
||||
List<GridTab> getTabs();
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.block.BlockGrid;
|
||||
import com.raoulvdberge.refinedstorage.block.EnumGridType;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerGrid;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GridFilteredItem;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GridFilter;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GridTab;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
|
||||
@@ -183,7 +183,7 @@ public class TileGrid extends TileNode implements IGrid {
|
||||
private InventoryCraftResult result = new InventoryCraftResult();
|
||||
|
||||
private ItemHandlerBasic patterns = new ItemHandlerBasic(2, this, new ItemValidatorBasic(RSItems.PATTERN));
|
||||
private List<GridFilteredItem> filteredItems = new ArrayList<>();
|
||||
private List<GridFilter> filteredItems = new ArrayList<>();
|
||||
private List<GridTab> tabs = new ArrayList<>();
|
||||
private ItemHandlerGridFilterInGrid filter = new ItemHandlerGridFilterInGrid(filteredItems, tabs);
|
||||
|
||||
@@ -284,7 +284,7 @@ public class TileGrid extends TileNode implements IGrid {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GridFilteredItem> getFilteredItems() {
|
||||
public List<GridFilter> getFilteredItems() {
|
||||
return filteredItems;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IFluidGridHandler;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IItemGridHandler;
|
||||
import com.raoulvdberge.refinedstorage.block.EnumGridType;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GridFilteredItem;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GridFilter;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GridTab;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
|
||||
@@ -39,7 +39,7 @@ public class WirelessGrid implements IGrid {
|
||||
private int searchBoxMode;
|
||||
private int tabSelected;
|
||||
|
||||
private List<GridFilteredItem> filteredItems = new ArrayList<>();
|
||||
private List<GridFilter> filteredItems = new ArrayList<>();
|
||||
private List<GridTab> tabs = new ArrayList<>();
|
||||
private ItemHandlerGridFilterInGrid filter = new ItemHandlerGridFilterInGrid(filteredItems, tabs) {
|
||||
@Override
|
||||
@@ -175,7 +175,7 @@ public class WirelessGrid implements IGrid {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GridFilteredItem> getFilteredItems() {
|
||||
public List<GridFilter> getFilteredItems() {
|
||||
return filteredItems;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.5 KiB |
Reference in New Issue
Block a user