From a999c30bbccf70e8ad89471899ffcab81c0ff589 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 2 Aug 2014 01:12:36 -0500 Subject: [PATCH] Added Feature: #0134 - Need info on wireless terminal GUI --- client/gui/implementations/GuiWireless.java | 46 +++++++++++++++++++ .../implementations/ContainerWireless.java | 23 +++++++++- core/localization/GuiText.java | 2 +- 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/client/gui/implementations/GuiWireless.java b/client/gui/implementations/GuiWireless.java index 23a10fe7..ac574bb2 100644 --- a/client/gui/implementations/GuiWireless.java +++ b/client/gui/implementations/GuiWireless.java @@ -1,14 +1,47 @@ package appeng.client.gui.implementations; +import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.InventoryPlayer; + +import org.lwjgl.input.Mouse; + +import appeng.api.config.Settings; import appeng.client.gui.AEBaseGui; +import appeng.client.gui.widgets.GuiImgButton; import appeng.container.implementations.ContainerWireless; +import appeng.core.AEConfig; import appeng.core.localization.GuiText; import appeng.tile.networking.TileWireless; +import appeng.util.Platform; public class GuiWireless extends AEBaseGui { + GuiImgButton units; + + @Override + protected void actionPerformed(GuiButton btn) + { + super.actionPerformed( btn ); + + boolean backwards = Mouse.isButtonDown( 1 ); + + if ( btn == units ) + { + AEConfig.instance.nextPowerUnit( backwards ); + units.set( AEConfig.instance.selectedPowerUnit() ); + } + } + + @Override + public void initGui() + { + super.initGui(); + + units = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.POWER_UNITS, AEConfig.instance.selectedPowerUnit() ); + buttonList.add( units ); + } + public GuiWireless(InventoryPlayer inventoryPlayer, TileWireless te) { super( new ContainerWireless( inventoryPlayer, te ) ); this.ySize = 166; @@ -26,6 +59,19 @@ public class GuiWireless extends AEBaseGui { fontRendererObj.drawString( getGuiDisplayName( GuiText.Wireless.getLocal() ), 8, 6, 4210752 ); fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 ); + + ContainerWireless cw = (ContainerWireless) inventorySlots; + + if ( cw.range > 0 ) + { + String msga = GuiText.Range.getLocal() + ": " + ((double) cw.range / 10.0) + " m"; + String msgb = GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong( cw.drain, true ); + + int strWidth = Math.max( fontRendererObj.getStringWidth( msga ), fontRendererObj.getStringWidth( msgb ) ); + int cOffset = (this.xSize / 2) - (strWidth / 2); + fontRendererObj.drawString( msga, cOffset, 20, 4210752 ); + fontRendererObj.drawString( msgb, cOffset, 20 + 12, 4210752 ); + } } } diff --git a/container/implementations/ContainerWireless.java b/container/implementations/ContainerWireless.java index 6f1b90b7..79a20f3a 100644 --- a/container/implementations/ContainerWireless.java +++ b/container/implementations/ContainerWireless.java @@ -2,8 +2,10 @@ package appeng.container.implementations; import net.minecraft.entity.player.InventoryPlayer; import appeng.container.AEBaseContainer; +import appeng.container.guisync.GuiSync; import appeng.container.slot.SlotRestrictedInput; import appeng.container.slot.SlotRestrictedInput.PlaceableItemType; +import appeng.core.AEConfig; import appeng.tile.networking.TileWireless; public class ContainerWireless extends AEBaseContainer @@ -11,13 +13,32 @@ public class ContainerWireless extends AEBaseContainer TileWireless myte; + @GuiSync(1) + public long range = 0; + + @GuiSync(2) + public long drain = 0; + + SlotRestrictedInput boosterSlot; + public ContainerWireless(InventoryPlayer ip, TileWireless te) { super( ip, te, null ); myte = te; - addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.RANGE_BOOSTER, myte, 0, 80, 37, invPlayer ) ); + addSlotToContainer( boosterSlot = new SlotRestrictedInput( PlaceableItemType.RANGE_BOOSTER, myte, 0, 80, 47, invPlayer ) ); bindPlayerInventory( ip, 0, 166 - /* height of playerinventory */82 ); } + @Override + public void detectAndSendChanges() + { + int boosters = boosterSlot.getStack() == null ? 0 : boosterSlot.getStack().stackSize; + + range = (long) (10 * AEConfig.instance.wireless_getMaxRange( boosters )); + drain = (long) (100 * AEConfig.instance.wireless_getPowerDrain( boosters )); + + super.detectAndSendChanges(); + } + } diff --git a/core/localization/GuiText.java b/core/localization/GuiText.java index 0b2fdddb..862cfab7 100644 --- a/core/localization/GuiText.java +++ b/core/localization/GuiText.java @@ -32,7 +32,7 @@ public enum GuiText OfSecondOutput, NoSecondOutput, RFTunnel, Stores, Next, SelectAmount, Lumen, Empty, ConfirmCrafting, - Stored, Crafting, Scheduled, CraftingStatus, Cancel, FromStorage, ToCraft, CraftingPlan, CalculatingWait, Start, Bytes, CraftingCPU, Automatic, CoProcessors, Simulation, Missing, InterfaceTerminal, NoCraftingCPUs, LightTunnel, Clean, InvalidPattern, InterfaceTerminalHint; + Stored, Crafting, Scheduled, CraftingStatus, Cancel, FromStorage, ToCraft, CraftingPlan, CalculatingWait, Start, Bytes, CraftingCPU, Automatic, CoProcessors, Simulation, Missing, InterfaceTerminal, NoCraftingCPUs, LightTunnel, Clean, InvalidPattern, InterfaceTerminalHint, Range; String root;