Applied-Energistics-2-tiler.../src/main/java/appeng/client/gui/implementations/GuiIOPort.java

132 lines
4 KiB
Java
Raw Normal View History

2014-11-14 12:02:52 +01:00
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
2014-09-24 02:26:27 +02:00
package appeng.client.gui.implementations;
2015-06-16 02:44:59 +02:00
import java.io.IOException;
2014-12-29 21:59:05 +01:00
2014-09-24 02:26:27 +02:00
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
2014-09-24 02:26:27 +02:00
2015-06-16 02:44:59 +02:00
import org.lwjgl.input.Mouse;
2014-09-24 02:26:27 +02:00
import appeng.api.AEApi;
import appeng.api.config.FullnessMode;
import appeng.api.config.OperationMode;
import appeng.api.config.RedstoneMode;
import appeng.api.config.Settings;
import appeng.api.definitions.IDefinitions;
2014-09-24 02:26:27 +02:00
import appeng.client.gui.widgets.GuiImgButton;
import appeng.container.implementations.ContainerIOPort;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.tile.storage.TileIOPort;
2014-09-24 02:26:27 +02:00
public class GuiIOPort extends GuiUpgradeable
{
GuiImgButton fullMode;
GuiImgButton operationMode;
2015-09-30 14:24:40 +02:00
public GuiIOPort( final InventoryPlayer inventoryPlayer, final TileIOPort te )
{
2014-09-24 02:26:27 +02:00
super( new ContainerIOPort( inventoryPlayer, te ) );
this.ySize = 166;
}
@Override
protected void addButtons()
2014-09-24 02:26:27 +02:00
{
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
this.fullMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.FULLNESS_MODE, FullnessMode.EMPTY );
this.operationMode = new GuiImgButton( this.guiLeft + 80, this.guiTop + 17, Settings.OPERATION_MODE, OperationMode.EMPTY );
this.buttonList.add( this.operationMode );
this.buttonList.add( this.redstoneMode );
this.buttonList.add( this.fullMode );
2014-09-24 02:26:27 +02:00
}
@Override
2015-09-30 14:24:40 +02:00
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
2014-09-24 02:26:27 +02:00
{
2014-12-29 15:13:47 +01:00
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.IOPort.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
2014-09-24 02:26:27 +02:00
if( this.redstoneMode != null )
2015-04-29 02:30:53 +02:00
{
2014-12-29 15:13:47 +01:00
this.redstoneMode.set( this.cvb.rsMode );
2015-04-29 02:30:53 +02:00
}
2014-09-24 02:26:27 +02:00
if( this.operationMode != null )
2015-04-29 02:30:53 +02:00
{
this.operationMode.set( ( (ContainerIOPort) this.cvb ).opMode );
2015-04-29 02:30:53 +02:00
}
2014-09-24 02:26:27 +02:00
if( this.fullMode != null )
2015-04-29 02:30:53 +02:00
{
this.fullMode.set( ( (ContainerIOPort) this.cvb ).fMode );
2015-04-29 02:30:53 +02:00
}
2014-09-24 02:26:27 +02:00
}
@Override
2015-09-30 14:24:40 +02:00
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
2014-09-24 02:26:27 +02:00
{
super.drawBG( offsetX, offsetY, mouseX, mouseY );
2014-09-24 02:26:27 +02:00
final IDefinitions definitions = AEApi.instance().definitions();
2015-09-30 14:24:40 +02:00
for( final ItemStack cell1kStack : definitions.items().cell1k().maybeStack( 1 ).asSet() )
{
this.drawItem( offsetX + 66 - 8, offsetY + 17, cell1kStack );
}
2015-09-30 14:24:40 +02:00
for( final ItemStack driveStack : definitions.blocks().drive().maybeStack( 1 ).asSet() )
{
this.drawItem( offsetX + 94 + 8, offsetY + 17, driveStack );
}
2014-09-24 02:26:27 +02:00
}
@Override
protected String getBackground()
{
return "guis/ioport.png";
}
@Override
2015-09-30 14:24:40 +02:00
protected void actionPerformed( final GuiButton btn ) throws IOException
2014-09-24 02:26:27 +02:00
{
super.actionPerformed( btn );
2015-09-30 14:24:40 +02:00
final boolean backwards = Mouse.isButtonDown( 1 );
2014-09-24 02:26:27 +02:00
if( btn == this.fullMode )
2015-04-29 02:30:53 +02:00
{
2014-12-29 15:13:47 +01:00
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.fullMode.getSetting(), backwards ) );
2015-04-29 02:30:53 +02:00
}
2014-10-04 08:08:28 +02:00
if( btn == this.operationMode )
2015-04-29 02:30:53 +02:00
{
2014-12-29 15:13:47 +01:00
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.operationMode.getSetting(), backwards ) );
2015-04-29 02:30:53 +02:00
}
2014-09-24 02:26:27 +02:00
}
}