2014-02-04 05:27:49 +01:00
|
|
|
package appeng.client.gui.implementations;
|
|
|
|
|
2014-08-02 08:12:36 +02:00
|
|
|
import net.minecraft.client.gui.GuiButton;
|
2014-02-04 05:27:49 +01:00
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2014-08-02 08:12:36 +02:00
|
|
|
|
|
|
|
import org.lwjgl.input.Mouse;
|
|
|
|
|
|
|
|
import appeng.api.config.Settings;
|
2014-02-04 05:27:49 +01:00
|
|
|
import appeng.client.gui.AEBaseGui;
|
2014-08-02 08:12:36 +02:00
|
|
|
import appeng.client.gui.widgets.GuiImgButton;
|
2014-02-04 05:27:49 +01:00
|
|
|
import appeng.container.implementations.ContainerWireless;
|
2014-08-02 08:12:36 +02:00
|
|
|
import appeng.core.AEConfig;
|
2014-02-04 05:27:49 +01:00
|
|
|
import appeng.core.localization.GuiText;
|
|
|
|
import appeng.tile.networking.TileWireless;
|
2014-08-02 08:12:36 +02:00
|
|
|
import appeng.util.Platform;
|
2014-02-04 05:27:49 +01:00
|
|
|
|
|
|
|
public class GuiWireless extends AEBaseGui
|
|
|
|
{
|
|
|
|
|
2014-08-02 08:12:36 +02:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2014-02-04 05:27:49 +01:00
|
|
|
public GuiWireless(InventoryPlayer inventoryPlayer, TileWireless te) {
|
|
|
|
super( new ContainerWireless( inventoryPlayer, te ) );
|
|
|
|
this.ySize = 166;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
|
|
|
{
|
|
|
|
bindTexture( "guis/wireless.png" );
|
|
|
|
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
|
|
|
{
|
2014-03-15 07:58:21 +01:00
|
|
|
fontRendererObj.drawString( getGuiDisplayName( GuiText.Wireless.getLocal() ), 8, 6, 4210752 );
|
2014-02-09 02:34:52 +01:00
|
|
|
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
2014-08-02 08:12:36 +02:00
|
|
|
|
|
|
|
ContainerWireless cw = (ContainerWireless) inventorySlots;
|
|
|
|
|
|
|
|
if ( cw.range > 0 )
|
|
|
|
{
|
2014-09-28 20:56:16 +02:00
|
|
|
String firstMessage = GuiText.Range.getLocal() + ": " + (cw.range / 10.0) + " m";
|
2014-09-28 11:47:17 +02:00
|
|
|
String secondMessage = GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong( cw.drain, true );
|
2014-08-02 08:12:36 +02:00
|
|
|
|
2014-09-28 11:47:17 +02:00
|
|
|
int strWidth = Math.max( fontRendererObj.getStringWidth( firstMessage ), fontRendererObj.getStringWidth( secondMessage ) );
|
2014-08-02 08:12:36 +02:00
|
|
|
int cOffset = (this.xSize / 2) - (strWidth / 2);
|
2014-09-28 11:47:17 +02:00
|
|
|
fontRendererObj.drawString( firstMessage, cOffset, 20, 4210752 );
|
|
|
|
fontRendererObj.drawString( secondMessage, cOffset, 20 + 12, 4210752 );
|
2014-08-02 08:12:36 +02:00
|
|
|
}
|
2014-02-04 05:27:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|