diff --git a/src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java b/src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java index 9314e43e1..e1006897a 100644 --- a/src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java +++ b/src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java @@ -197,8 +197,14 @@ public class GuiDigitalMinerConfig extends GuiMekanism if(xAxis >= 154 && xAxis <= 166 && yAxis >= getScroll()+18 && yAxis <= getScroll()+18+15) { - dragOffset = yAxis - (getScroll()+18); - isDragging = true; + if(tileEntity.filters.size()>4) + { + dragOffset = yAxis - (getScroll()+18); + isDragging = true; + } + else { + scroll = 0; + } } for(int i = 0; i < 4; i++) diff --git a/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java b/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java index 3e1ce30fa..4c8edd4fc 100644 --- a/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java +++ b/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java @@ -186,8 +186,14 @@ public class GuiLogisticalSorter extends GuiMekanism { if(xAxis >= 154 && xAxis <= 166 && yAxis >= getScroll()+18 && yAxis <= getScroll()+18+15) { - dragOffset = yAxis - (getScroll()+18); - isDragging = true; + if(tileEntity.filters.size()>4) + { + dragOffset = yAxis - (getScroll()+18); + isDragging = true; + } + else { + scroll = 0; + } } for(int i = 0; i < 4; i++) diff --git a/src/main/java/mekanism/client/gui/GuiUpgradeManagement.java b/src/main/java/mekanism/client/gui/GuiUpgradeManagement.java index d5fa1fc43..3e77cba26 100644 --- a/src/main/java/mekanism/client/gui/GuiUpgradeManagement.java +++ b/src/main/java/mekanism/client/gui/GuiUpgradeManagement.java @@ -29,6 +29,12 @@ public class GuiUpgradeManagement extends GuiMekanism public Upgrade selectedType; + public boolean isDragging = false; + + public int dragOffset = 0; + + public float scroll; + public GuiUpgradeManagement(InventoryPlayer inventory, IUpgradeTile tile) { super(new ContainerUpgradeManagement(inventory, tile)); @@ -41,8 +47,12 @@ public class GuiUpgradeManagement extends GuiMekanism int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiUpgradeManagement.png")); + GL11.glColor4f(1, 1, 1, 1); + drawTexturedModalRect(84, 8+getScroll(), 202, 0, 4, 4); + fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - fontRendererObj.drawString(MekanismUtils.localize("gui.upgrades.supported") + ":", 26, 60, 0x404040); + fontRendererObj.drawString(MekanismUtils.localize("gui.upgrades.supported") + ":", 26, 59, 0x404040); if(selectedType == null) { @@ -66,22 +76,31 @@ public class GuiUpgradeManagement extends GuiMekanism for(Upgrade upgrade : tileEntity.getComponent().getSupportedTypes()) { - renderUpgrade(upgrade, 80 + (rendered++*12), 58, 0.8F, true); + renderUpgrade(upgrade, 80 + (rendered++*12), 57, 0.8F, true); } - int counter = 0; + Upgrade[] upgrades = getCurrentUpgrades().toArray(new Upgrade[getCurrentUpgrades().size()]); - for(Upgrade upgrade : getCurrentUpgrades()) + for(int i = 0; i < 4; i++) { + int index = getUpgradeIndex()+i; + + if(index > upgrades.length-1) + { + break; + } + + Upgrade upgrade = upgrades[index]; + int xPos = 25; - int yPos = 7 + (counter++*12); + int yPos = 7 + (i++*12); int yRender = 0; fontRendererObj.drawString(upgrade.getName(), xPos + 12, yPos + 2, 0x404040); renderUpgrade(upgrade, xPos + 2, yPos + 2, 0.5F, true); - if(xAxis >= xPos && xAxis <= xPos+64 && yAxis >= yPos && yAxis <= yPos+12) + if(xAxis >= xPos && xAxis <= xPos+58 && yAxis >= yPos && yAxis <= yPos+12) { func_146283_a(MekanismUtils.splitLines(upgrade.getDescription()), xAxis, yAxis); } @@ -131,14 +150,14 @@ public class GuiUpgradeManagement extends GuiMekanism if(selectedType == null) { - drawTexturedModalRect(guiWidth + 136, guiHeight + 58, 176 + 14, 24, 12, 12); + drawTexturedModalRect(guiWidth + 136, guiHeight + 57, 176 + 14, 24, 12, 12); } - else if(xAxis >= 136 && xAxis <= 148 && yAxis >= 58 && yAxis <= 70) + else if(xAxis >= 136 && xAxis <= 148 && yAxis >= 57 && yAxis <= 69) { - drawTexturedModalRect(guiWidth + 136, guiHeight + 58, 176 + 14, 0, 12, 12); + drawTexturedModalRect(guiWidth + 136, guiHeight + 57, 176 + 14, 0, 12, 12); } else { - drawTexturedModalRect(guiWidth + 136, guiHeight + 58, 176 + 14, 12, 12, 12); + drawTexturedModalRect(guiWidth + 136, guiHeight + 57, 176 + 14, 12, 12, 12); } int displayInt = tileEntity.getComponent().getScaledUpgradeProgress(14); @@ -161,7 +180,7 @@ public class GuiUpgradeManagement extends GuiMekanism { yRender = 166 + 24; } - else if(xAxis >= xPos && xAxis <= xPos+64 && yAxis >= yPos && yAxis <= yPos+12) + else if(xAxis >= xPos && xAxis <= xPos+58 && yAxis >= yPos && yAxis <= yPos+12) { yRender = 166; } @@ -170,7 +189,7 @@ public class GuiUpgradeManagement extends GuiMekanism } MekanismRenderer.color(upgrade.getColor(), 1.0F, 2.5F); - drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 0, yRender, 64, 12); + drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 0, yRender, 58, 12); MekanismRenderer.resetColor(); } @@ -183,6 +202,47 @@ public class GuiUpgradeManagement extends GuiMekanism return tileEntity.getComponent().getInstalledTypes(); } + public int getScroll() + { + return Math.max(Math.min((int)(scroll*42), 42), 0); + } + + public int getUpgradeIndex() + { + if(getCurrentUpgrades().size() <= 4) + { + return 0; + } + + return (int)((getCurrentUpgrades().size()*scroll) - ((4F/(float)getCurrentUpgrades().size()))*scroll); + } + + @Override + protected void mouseClickMove(int mouseX, int mouseY, int button, long ticks) + { + super.mouseClickMove(mouseX, mouseY, button, ticks); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if(isDragging) + { + scroll = Math.min(Math.max((float)(yAxis-8-dragOffset)/42F, 0), 1); + } + } + + @Override + protected void mouseMovedOrUp(int mouseX, int mouseY, int type) + { + super.mouseMovedOrUp(mouseX, mouseY, type); + + if(type == 0 && isDragging) + { + dragOffset = 0; + isDragging = false; + } + } + @Override protected void mouseClicked(int mouseX, int mouseY, int button) { @@ -195,6 +255,18 @@ public class GuiUpgradeManagement extends GuiMekanism if(button == 0) { + if(xAxis >= 84 && xAxis <= 88 && yAxis >= getScroll()+8 && yAxis <= getScroll()+8+4) + { + if(getCurrentUpgrades().size()>4) + { + dragOffset = yAxis - (getScroll()+8); + isDragging = true; + } + else { + scroll = 0; + } + } + if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { int guiId = MachineType.get(tile.getBlockType(), tile.getBlockMetadata()).guiId; @@ -202,7 +274,7 @@ public class GuiUpgradeManagement extends GuiMekanism Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tile), guiId)); } - if(selectedType != null && xAxis >= 136 && xAxis <= 148 && yAxis >= 58 && yAxis <= 70) + if(selectedType != null && xAxis >= 136 && xAxis <= 148 && yAxis >= 57 && yAxis <= 69) { SoundHandler.playSound("gui.button.press"); Mekanism.packetHandler.sendToServer(new RemoveUpgradeMessage(Coord4D.get(tile), selectedType.ordinal())); @@ -216,7 +288,7 @@ public class GuiUpgradeManagement extends GuiMekanism int yPos = 7 + (counter++*12); int yRender = 0; - if(xAxis >= xPos && xAxis <= xPos+64 && yAxis >= yPos && yAxis <= yPos+12) + if(xAxis >= xPos && xAxis <= xPos+58 && yAxis >= yPos && yAxis <= yPos+12) { selectedType = upgrade; break; diff --git a/src/main/resources/assets/mekanism/gui/GuiUpgradeManagement.png b/src/main/resources/assets/mekanism/gui/GuiUpgradeManagement.png index 1feb0488f..35aee32c4 100644 Binary files a/src/main/resources/assets/mekanism/gui/GuiUpgradeManagement.png and b/src/main/resources/assets/mekanism/gui/GuiUpgradeManagement.png differ