From 523ec21467b805f9c96f8bf210b78a439bfc8b11 Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Tue, 22 Jul 2014 22:16:20 -0400 Subject: [PATCH] Added button to remove upgrade, fixed font size. Almost done! --- .../client/gui/GuiUpgradeManagement.java | 43 ++++++++++++++---- .../common/network/PacketRemoveUpgrade.java | 35 +++++--------- .../mekanism/gui/GuiUpgradeManagement.png | Bin 5092 -> 5157 bytes .../resources/assets/mekanism/lang/en_US.lang | 7 +-- 4 files changed, 51 insertions(+), 34 deletions(-) diff --git a/src/main/java/mekanism/client/gui/GuiUpgradeManagement.java b/src/main/java/mekanism/client/gui/GuiUpgradeManagement.java index ab4c15735..35da089c3 100644 --- a/src/main/java/mekanism/client/gui/GuiUpgradeManagement.java +++ b/src/main/java/mekanism/client/gui/GuiUpgradeManagement.java @@ -1,10 +1,8 @@ package mekanism.client.gui; -import java.util.Arrays; import java.util.Set; import mekanism.api.Coord4D; -import mekanism.api.EnumColor; import mekanism.client.render.MekanismRenderer; import mekanism.client.sound.SoundHandler; import mekanism.common.IUpgradeTile; @@ -12,6 +10,7 @@ import mekanism.common.Mekanism; import mekanism.common.Upgrade; import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.inventory.container.ContainerUpgradeManagement; +import mekanism.common.network.PacketRemoveUpgrade.RemoveUpgradeMessage; import mekanism.common.network.PacketSimpleGui.SimpleGuiMessage; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; @@ -47,14 +46,20 @@ public class GuiUpgradeManagement extends GuiMekanism if(selectedType == null) { - renderText(MekanismUtils.localize("gui.upgrades.noSelection") + ".", 96, 9, 0.8F); + renderText(MekanismUtils.localize("gui.upgrades.noSelection") + ".", 92, 8, 0.8F, true); + } + else { + int amount = tileEntity.getComponent().getUpgrades(selectedType); + + renderText(selectedType.getName() + " " + MekanismUtils.localize("gui.upgrade"), 92, 8, 0.6F, true); + renderText(MekanismUtils.localize("gui.upgrades.amount") + ": " + amount + "/" + selectedType.getMax(), 92, 16, 0.6F, true); } int rendered = 0; for(Upgrade upgrade : tileEntity.getComponent().getSupportedTypes()) { - renderUpgrade(upgrade, 84 + (rendered++*12), 60, 0.8F); + renderUpgrade(upgrade, 80 + (rendered++*12), 58, 0.8F, true); } int counter = 0; @@ -65,6 +70,10 @@ public class GuiUpgradeManagement extends GuiMekanism int yPos = 7 + (counter++*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) { func_146283_a(MekanismUtils.splitLines(upgrade.getDescription()), xAxis, yAxis); @@ -74,20 +83,20 @@ public class GuiUpgradeManagement extends GuiMekanism super.drawGuiContainerForegroundLayer(mouseX, mouseY); } - private void renderText(String text, int x, int y, float size) + private void renderText(String text, int x, int y, float size, boolean scale) { GL11.glPushMatrix(); GL11.glScalef(size, size, size); - fontRendererObj.drawString(text, (int)(x*(1+(1-size))), (int)(y*(1+(1-size))), 0x00CD00); + fontRendererObj.drawString(text, scale ? (int)((1F/size)*x) : x, scale ? (int)((1F/size)*y) : y, 0x00CD00); GL11.glPopMatrix(); } - private void renderUpgrade(Upgrade type, int x, int y, float size) + private void renderUpgrade(Upgrade type, int x, int y, float size, boolean scale) { GL11.glPushMatrix(); GL11.glScalef(size, size, size); GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), type.getStack(), (int)(x*(1+(1-size))), (int)(y*(1+(1-size)))); + itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), type.getStack(), scale ? (int)((1F/size)*x) : x, scale ? (int)((1F/size)*y) : y); GL11.glDisable(GL11.GL_LIGHTING); GL11.glPopMatrix(); } @@ -113,6 +122,18 @@ public class GuiUpgradeManagement extends GuiMekanism drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 14, 14, 14); } + if(selectedType == null) + { + drawTexturedModalRect(guiWidth + 136, guiHeight + 58, 176 + 14, 24, 12, 12); + } + else if(xAxis >= 136 && xAxis <= 148 && yAxis >= 58 && yAxis <= 70) + { + drawTexturedModalRect(guiWidth + 136, guiHeight + 58, 176 + 14, 0, 12, 12); + } + else { + drawTexturedModalRect(guiWidth + 136, guiHeight + 58, 176 + 14, 12, 12, 12); + } + int displayInt = tileEntity.getComponent().getScaledUpgradeProgress(14); drawTexturedModalRect(guiWidth + 154, guiHeight + 26, 176, 28, 10, displayInt); @@ -174,6 +195,12 @@ 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) + { + SoundHandler.playSound("gui.button.press"); + Mekanism.packetHandler.sendToServer(new RemoveUpgradeMessage(Coord4D.get(tile), selectedType.ordinal())); + } + int counter = 0; for(Upgrade upgrade : getCurrentUpgrades()) diff --git a/src/main/java/mekanism/common/network/PacketRemoveUpgrade.java b/src/main/java/mekanism/common/network/PacketRemoveUpgrade.java index 977433e01..994836bab 100644 --- a/src/main/java/mekanism/common/network/PacketRemoveUpgrade.java +++ b/src/main/java/mekanism/common/network/PacketRemoveUpgrade.java @@ -2,9 +2,10 @@ package mekanism.common.network; import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; -import mekanism.common.IUpgradeManagement; +import mekanism.common.IUpgradeTile; import mekanism.common.Mekanism; import mekanism.common.PacketHandler; +import mekanism.common.Upgrade; import mekanism.common.network.PacketRemoveUpgrade.RemoveUpgradeMessage; import mekanism.common.tile.TileEntityBasicBlock; import net.minecraft.entity.player.EntityPlayer; @@ -22,28 +23,16 @@ public class PacketRemoveUpgrade implements IMessageHandler 0) { - if(upgradeTile.getSpeedMultiplier() > 0) + if(player.inventory.addItemStackToInventory(upgrade.getStack())) { - if(player.inventory.addItemStackToInventory(new ItemStack(Mekanism.SpeedUpgrade))) - { - upgradeTile.setSpeedMultiplier(upgradeTile.getSpeedMultiplier()-1); - } - } - } - else if(message.upgradeType == 1) - { - if(upgradeTile.getEnergyMultiplier() > 0) - { - if(player.inventory.addItemStackToInventory(new ItemStack(Mekanism.EnergyUpgrade))) - { - upgradeTile.setEnergyMultiplier(upgradeTile.getEnergyMultiplier()-1); - } + upgradeTile.getComponent().removeUpgrade(upgrade); } } } @@ -55,11 +44,11 @@ public class PacketRemoveUpgrade implements IMessageHandlern|GD?~Joo(lJ?Hyb&+{Esd8}HBgWy?fvm=fXsOf>0 zppLJS%(5qs6-m7Zdg54;&!EDo=k%1kTS<6JWR!WT~; zcj=o7yExfbx)gBl00ghPW=j-$l>F{n);pJ89$i-Fxl!v?TD_;^r!>v=xw4Uehy2!y zvV!wV&!WX2mShx}-dJ0DtFaXp@3wUe%;r{$pBQ(0 zRZ~->dAjC-6-ZbweQ;rkNwf`se;&WKxRF&uSRxR%j9$1GhG@b1u$?-mSDFF|zxMa` z-XrA;(PDO9(2=?r65{Z@xY#20c?eX!5$Uvp4q>_PW)~RnskbWwOKnN-W`jKf0w~9? zh3poV9v+Kv^}l{OwDQNI0v(ML*}Xr19+xH+$4++^@M;Hy zhm$BhKU3-l8Wmsa3gtb(fCXRezD`E~ecXodeA=V_lGdQ&#&^HniBZ2+(>(_8ltqdb8>y&_i z!09rNUPC-S>%!F6uQtOJm7x6m{EiPF%zWCWTRe@{Nd7Qv{S|(bMTS?)VTWoXqc-j5 zUp7|zm)c$yC+OG$-g?eg_!+T1Jw5wT#xd(ZB5y1%hNXn5?Uns;{sDv0;$Bj8`9ejl zZj+x0dAH<7)Fe*UgRwQWf)9=H^CyW?Eyl!Yff%cCyYNxZJ6i`TH0^~n*E>73-jW@# zTh-$3=ziGHp4VWIp1Sy$D*$0w%o!#m%{%H(sBBenn%!EQnCe__<4g`!zAYPXOk$1T zcUxFkyzgFySILB*bCgQ76?l__xxM7*6%b&XX%w#cqP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N?Bdq3I>(J5^y5%rg4eqhPl%cark22#`Cm31Ng^tj&~`7JzdDkln>T$Tl=v1v zQt(%9@YK6iZX>sE2d&)F*%Lee_V;O0K&xW;5_}Z2wwUo^IKjIE@1d z7T{-P$VK~~`mh-yM^y^d53Zc}_XQy$$43Ip{Arb^p2#F zCr?(B4=5L7;7Vm(nPRQq@LiH9TBV%>{1;t5L|f;IOCXm&3w?Yf_DS}8jg9D zU8;_}xS)k2t51&d9Zt=V7MRaa6_7c|JhBX%5HAN-s;2P($YW+?arVU-w;TTgh{Lrc diff --git a/src/main/resources/assets/mekanism/lang/en_US.lang b/src/main/resources/assets/mekanism/lang/en_US.lang index 89ec5fa37..038f0cb34 100644 --- a/src/main/resources/assets/mekanism/lang/en_US.lang +++ b/src/main/resources/assets/mekanism/lang/en_US.lang @@ -354,10 +354,14 @@ gui.key=Key gui.id=ID gui.finished=Finished gui.well=All is well! +gui.upgrade=Upgrade gui.upgrades=Upgrades gui.upgrades.supported=Supported gui.upgrades.noSelection=No selection +gui.upgrades.amount=Amount +gui.upgrades.max=Max +gui.upgrades.effect=Effect gui.chemicalInfuser.short=C. Infuser gui.chemicalDissolutionChamber.short=C. Dissolution Chamber @@ -657,9 +661,6 @@ tile.Generator.BioGenerator.name=Bio-Generator tile.Generator.AdvancedSolarGenerator.name=Advanced Solar Generator tile.Generator.WindTurbine.name=Wind Turbine -//Reactor Blocks -tile.Reactor.ReactorController.name=Reactor Controller - //Gui text gui.heatGenerator.fuel=Fuel gui.solarGenerator.sun=Sun