Security Block Fully Functional.
This commit is contained in:
@@ -33,12 +33,18 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
|
||||
int xoffset = 9;
|
||||
int perRow = 9;
|
||||
int reservedSpace = 0;
|
||||
|
||||
int rows = 0;
|
||||
int maxRows = Integer.MAX_VALUE;
|
||||
|
||||
public GuiMEMonitorable(InventoryPlayer inventoryPlayer, IStorageMonitorable te) {
|
||||
super( new ContainerMEMonitorable( inventoryPlayer, null ) );
|
||||
this( inventoryPlayer, te, new ContainerMEMonitorable( inventoryPlayer, null ) );
|
||||
}
|
||||
|
||||
public GuiMEMonitorable(InventoryPlayer inventoryPlayer, IStorageMonitorable te, ContainerMEMonitorable c) {
|
||||
|
||||
super( c );
|
||||
myScrollBar = new GuiScrollbar();
|
||||
repo = new ItemRepo( myScrollBar );
|
||||
xSize = 195;
|
||||
@@ -74,7 +80,7 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
{
|
||||
int NEI = 0;
|
||||
int top = 4;
|
||||
int extraSpace = height - 114 - NEI - top;
|
||||
int extraSpace = height - 114 - NEI - top - reservedSpace;
|
||||
|
||||
rows = (int) Math.floor( extraSpace / 18 );
|
||||
if ( rows > maxRows )
|
||||
@@ -97,7 +103,7 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
// extra slots : 72
|
||||
// slot 18
|
||||
|
||||
this.ySize = 114 + rows * 18;
|
||||
this.ySize = 114 + rows * 18 + reservedSpace;
|
||||
this.guiTop = top;
|
||||
|
||||
buttonList.add( new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.SORT_BY, Configuration.instance.settings.getSetting( Settings.SORT_BY ) ) );
|
||||
@@ -163,7 +169,7 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
for (int x = 0; x < rows; x++)
|
||||
this.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, xSize, 18 );
|
||||
|
||||
this.drawTexturedModalRect( offsetX, offsetY + 16 + rows * 18, 0, 106, xSize, 98 );
|
||||
this.drawTexturedModalRect( offsetX, offsetY + 16 + rows * 18, 0, 106, xSize, 98 + reservedSpace );
|
||||
|
||||
searchField.drawTextBox();
|
||||
}
|
||||
@@ -178,6 +184,7 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
{
|
||||
fontRenderer.drawString( myName.getLocal(), 8, 6, 4210752 );
|
||||
fontRenderer.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
fontRenderer.drawString( GuiText.SecurityCardEditor.getLocal(), 8, ySize - 96 + 3 - reservedSpace, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +1,88 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.client.gui.widgets.GuiToggleButton;
|
||||
import appeng.container.implementations.ContainerSecurity;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
|
||||
public class GuiSecurity extends GuiMEMonitorable
|
||||
{
|
||||
|
||||
public GuiSecurity(InventoryPlayer inventoryPlayer, IStorageMonitorable te) {
|
||||
super( inventoryPlayer, te );
|
||||
perRow = 5;
|
||||
xoffset = 81;
|
||||
super( inventoryPlayer, te, new ContainerSecurity( inventoryPlayer, te ) );
|
||||
reservedSpace = 32;
|
||||
}
|
||||
|
||||
GuiToggleButton inject, extract, craft, build, security;
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
int top = this.guiTop + this.ySize - 114;
|
||||
buttonList.add( inject = new GuiToggleButton( this.guiLeft + 56 + 18 * 0, top, 11 * 16 + 0, 12 * 16 + 0, SecurityPermissions.INJECT
|
||||
.getUnlocalizedName(), SecurityPermissions.INJECT.getUnlocalizedTip() ) );
|
||||
|
||||
buttonList.add( extract = new GuiToggleButton( this.guiLeft + 56 + 18 * 1, top, 11 * 16 + 1, 12 * 16 + 1, SecurityPermissions.EXTRACT
|
||||
.getUnlocalizedName(), SecurityPermissions.EXTRACT.getUnlocalizedTip() ) );
|
||||
|
||||
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() ) );
|
||||
|
||||
buttonList.add( security = new GuiToggleButton( this.guiLeft + 56 + 18 * 4, top, 11 * 16 + 4, 12 * 16 + 4, SecurityPermissions.SECURITY
|
||||
.getUnlocalizedName(), SecurityPermissions.SECURITY.getUnlocalizedTip() ) );
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
PacketDispatcher.sendPacketToServer( (new PacketValueConfig( "TileSecurity.ToggleOption", toggleSetting.name() )).getPacket() );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
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";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user