Applied-Energistics-2-tiler.../client/gui/implementations/GuiSecurity.java

111 lines
3.7 KiB
Java
Raw Normal View History

package appeng.client.gui.implementations;
2014-02-01 06:37:27 +01:00
import java.io.IOException;
import net.minecraft.entity.player.InventoryPlayer;
2014-02-01 06:37:27 +01:00
import appeng.api.config.SecurityPermissions;
2014-02-06 06:08:05 +01:00
import appeng.api.config.SortOrder;
2014-02-17 01:50:25 +01:00
import appeng.api.storage.ITerminalHost;
2014-02-01 06:37:27 +01:00
import appeng.client.gui.widgets.GuiToggleButton;
import appeng.container.implementations.ContainerSecurity;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
2014-02-09 02:34:52 +01:00
import appeng.core.sync.network.NetworkHandler;
2014-02-01 06:37:27 +01:00
import appeng.core.sync.packets.PacketValueConfig;
public class GuiSecurity extends GuiMEMonitorable
{
2014-02-17 01:50:25 +01:00
public GuiSecurity(InventoryPlayer inventoryPlayer, ITerminalHost te) {
2014-02-01 06:37:27 +01:00
super( inventoryPlayer, te, new ContainerSecurity( inventoryPlayer, te ) );
2014-02-06 06:08:05 +01:00
customSortOrder = false;
reservedSpace = 33;
// increase size so that the slot is over the gui.
xSize += 56;
standardSize = xSize;
2014-02-01 06:37:27 +01:00
}
GuiToggleButton inject, extract, craft, build, security;
@Override
public void initGui()
{
super.initGui();
int top = this.guiTop + this.ySize - 116;
2014-02-09 02:34:52 +01:00
buttonList.add( inject = new GuiToggleButton( this.guiLeft + 56 + 18 * 0, top, 11 * 16 + 0, 12 * 16 + 0, SecurityPermissions.INJECT
.getUnlocalizedName(), SecurityPermissions.INJECT.getUnlocalizedTip() ) );
2014-02-01 06:37:27 +01:00
2014-02-09 02:34:52 +01:00
buttonList.add( extract = new GuiToggleButton( this.guiLeft + 56 + 18 * 1, top, 11 * 16 + 1, 12 * 16 + 1, SecurityPermissions.EXTRACT
.getUnlocalizedName(), SecurityPermissions.EXTRACT.getUnlocalizedTip() ) );
2014-02-01 06:37:27 +01:00
buttonList.add( craft = new GuiToggleButton( this.guiLeft + 56 + 18 * 2, top, 11 * 16 + 2, 12 * 16 + 2, SecurityPermissions.CRAFT.getUnlocalizedName(),
SecurityPermissions.CRAFT.getUnlocalizedTip() ) );
buttonList.add( build = new GuiToggleButton( this.guiLeft + 56 + 18 * 3, top, 11 * 16 + 3, 12 * 16 + 3, SecurityPermissions.BUILD.getUnlocalizedName(),
SecurityPermissions.BUILD.getUnlocalizedTip() ) );
2014-02-09 02:34:52 +01:00
buttonList.add( security = new GuiToggleButton( this.guiLeft + 56 + 18 * 4, top, 11 * 16 + 4, 12 * 16 + 4, SecurityPermissions.SECURITY
.getUnlocalizedName(), SecurityPermissions.SECURITY.getUnlocalizedTip() ) );
}
2014-02-01 06:37:27 +01:00
protected void actionPerformed(net.minecraft.client.gui.GuiButton btn)
{
super.actionPerformed( btn );
SecurityPermissions toggleSetting = null;
if ( btn == inject )
toggleSetting = SecurityPermissions.INJECT;
if ( btn == extract )
toggleSetting = SecurityPermissions.EXTRACT;
if ( btn == craft )
toggleSetting = SecurityPermissions.CRAFT;
if ( btn == build )
toggleSetting = SecurityPermissions.BUILD;
if ( btn == security )
toggleSetting = SecurityPermissions.SECURITY;
if ( toggleSetting != null )
{
try
{
2014-02-09 02:34:52 +01:00
NetworkHandler.instance.sendToServer( new PacketValueConfig( "TileSecurity.ToggleOption", toggleSetting.name() ) );
2014-02-01 06:37:27 +01:00
}
catch (IOException e)
{
AELog.error( e );
2014-02-01 06:37:27 +01:00
}
}
};
protected String getBackground()
{
2014-02-01 06:37:27 +01:00
ContainerSecurity cs = (ContainerSecurity) inventorySlots;
inject.setState( (cs.security & (1 << SecurityPermissions.INJECT.ordinal())) > 0 );
extract.setState( (cs.security & (1 << SecurityPermissions.EXTRACT.ordinal())) > 0 );
craft.setState( (cs.security & (1 << SecurityPermissions.CRAFT.ordinal())) > 0 );
build.setState( (cs.security & (1 << SecurityPermissions.BUILD.ordinal())) > 0 );
security.setState( (cs.security & (1 << SecurityPermissions.SECURITY.ordinal())) > 0 );
return "guis/security.png";
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
super.drawFG( offsetX, offsetY, mouseX, mouseY );
2014-02-09 02:34:52 +01:00
fontRendererObj.drawString( GuiText.SecurityCardEditor.getLocal(), 8, ySize - 96 + 1 - reservedSpace, 4210752 );
}
2014-02-06 06:08:05 +01:00
@Override
public Enum getSortBy()
{
return SortOrder.NAME;
}
}