Redstone Logic for Buses, and Part Image Button goodness

This commit is contained in:
AlgorithmX2
2014-01-01 23:51:41 -06:00
parent 0acbefbfaa
commit db4cf7aa5d
22 changed files with 367 additions and 73 deletions
+54
View File
@@ -1,24 +1,72 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.FuzzyMode;
import appeng.api.config.RedstoneMode;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
import appeng.api.implementations.IBusCommon;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.container.implementations.ContainerBus;
import appeng.core.localization.GuiText;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.parts.automation.PartImportBus;
import cpw.mods.fml.common.network.PacketDispatcher;
public class GuiBus extends AEBaseGui
{
ContainerBus cvb;
IBusCommon bc;
GuiImgButton redstoneMode;
GuiImgButton fuzzyMode;
public GuiBus(InventoryPlayer inventoryPlayer, IBusCommon te) {
super( new ContainerBus( inventoryPlayer, te ) );
cvb = (ContainerBus) inventorySlots;
bc = te;
this.xSize = hasToolbox() ? 246 : 211;
this.ySize = 184;
}
@Override
public void initGui()
{
super.initGui();
redstoneMode = new GuiImgButton( 122 + guiLeft, 31 + guiTop, Settings.REDSTONE_OUTPUT, RedstoneMode.IGNORE );
fuzzyMode = new GuiImgButton( 122 + guiLeft, 49 + guiTop, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
buttonList.add( redstoneMode );
buttonList.add( fuzzyMode );
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
try
{
if ( btn == redstoneMode )
PacketDispatcher.sendPacketToServer( (new PacketConfigButton( Settings.REDSTONE_OUTPUT )).getPacket() );
if ( btn == fuzzyMode )
PacketDispatcher.sendPacketToServer( (new PacketConfigButton( Settings.FUZZY_MODE )).getPacket() );
}
catch (IOException e)
{
e.printStackTrace();
}
}
private boolean hasToolbox()
{
return ((ContainerBus) inventorySlots).hasToolbox();
@@ -27,6 +75,9 @@ public class GuiBus extends AEBaseGui
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
redstoneMode.setVisibility( bc.getInstalledUpgrades( Upgrades.REDSTONE ) > 0 );
fuzzyMode.setVisibility( bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 );
bindTexture( "guis/bus.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize - 34, ySize );
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 86 );
@@ -39,6 +90,9 @@ public class GuiBus extends AEBaseGui
{
fontRenderer.drawString( (bc instanceof PartImportBus ? GuiText.ImportBus : GuiText.ExportBus).getLocal(), 8, 6, 4210752 );
fontRenderer.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
redstoneMode.set( cvb.rsMode );
fuzzyMode.set( cvb.fzMode );
}
}
+2 -2
View File
@@ -26,8 +26,8 @@ public class GuiInterface extends AEBaseGui
{
fontRenderer.drawString( GuiText.Interface.getLocal(), 8, 6, 4210752 );
fontRenderer.drawString( GuiText.Config.getLocal(), 8, 6 + 11 + 7, 4210752 );
fontRenderer.drawString( GuiText.StoredItems.getLocal(), 8 + 18, 6 + 60 + 7, 4210752 );
fontRenderer.drawString( GuiText.Config.getLocal(), 18, 6 + 11 + 7, 4210752 );
fontRenderer.drawString( GuiText.StoredItems.getLocal(), 18, 6 + 60 + 7, 4210752 );
fontRenderer.drawString( GuiText.Patterns.getLocal(), 8, 6 + 73 + 7, 4210752 );
fontRenderer.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
+17 -5
View File
@@ -82,6 +82,12 @@ public class GuiImgButton extends GuiButton implements ITooltip
Appearances.put( new EnumPair( setting, val ), a );
}
public void setVisibility(boolean vis)
{
drawButton = vis;
enabled = vis;
}
public GuiImgButton(int x, int y, Enum idx, Enum val) {
super( 0, 0, 16, "" );
buttonSetting = idx;
@@ -110,10 +116,10 @@ public class GuiImgButton extends GuiButton implements ITooltip
registerApp( 16 * 10 + 3, Settings.POWER_UNITS, PowerUnits.KJ, "AppEng.GuiITooltip.PowerUnits", "AppEng.GuiITooltip.UEUnits" );
registerApp( 16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.WA, "AppEng.GuiITooltip.PowerUnits", "AppEng.GuiITooltip.WUnits" );
registerApp( 3, Settings.REDSTONE_INPUT, RedstoneMode.IGNORE, "AppEng.GuiITooltip.RedstoneMode", "AppEng.GuiITooltip.AlwaysActive" );
registerApp( 0, Settings.REDSTONE_INPUT, RedstoneMode.LOW_SIGNAL, "AppEng.GuiITooltip.RedstoneMode", "AppEng.GuiITooltip.ActiveWithoutSignal" );
registerApp( 1, Settings.REDSTONE_INPUT, RedstoneMode.HIGH_SIGNAL, "AppEng.GuiITooltip.RedstoneMode", "AppEng.GuiITooltip.ActiveWithSignal" );
registerApp( 2, Settings.REDSTONE_INPUT, RedstoneMode.SIGNAL_PULSE, "AppEng.GuiITooltip.RedstoneMode", "AppEng.GuiITooltip.ActiveOnPulse" );
registerApp( 3, Settings.REDSTONE_OUTPUT, RedstoneMode.IGNORE, "AppEng.GuiITooltip.RedstoneMode", "AppEng.GuiITooltip.AlwaysActive" );
registerApp( 0, Settings.REDSTONE_OUTPUT, RedstoneMode.LOW_SIGNAL, "AppEng.GuiITooltip.RedstoneMode", "AppEng.GuiITooltip.ActiveWithoutSignal" );
registerApp( 1, Settings.REDSTONE_OUTPUT, RedstoneMode.HIGH_SIGNAL, "AppEng.GuiITooltip.RedstoneMode", "AppEng.GuiITooltip.ActiveWithSignal" );
registerApp( 2, Settings.REDSTONE_OUTPUT, RedstoneMode.SIGNAL_PULSE, "AppEng.GuiITooltip.RedstoneMode", "AppEng.GuiITooltip.ActiveOnPulse" );
registerApp( 3, Settings.REDSTONE_INPUT, RedstoneMode.IGNORE, "AppEng.GuiITooltip.RedstoneMode", "AppEng.GuiITooltip.AlwaysActive" );
registerApp( 0, Settings.REDSTONE_INPUT, RedstoneMode.LOW_SIGNAL, "AppEng.GuiITooltip.RedstoneMode", "AppEng.GuiITooltip.ActiveWithoutSignal" );
@@ -230,7 +236,10 @@ public class GuiImgButton extends GuiButton implements ITooltip
{
if ( buttonSetting != null && currentValue != null )
{
return Appearances.get( new EnumPair( buttonSetting, currentValue ) ).index;
BtnAppearance app = Appearances.get( new EnumPair( buttonSetting, currentValue ) );
if ( app == null )
return 256 - 1;
return app.index;
}
return 256 - 1;
}
@@ -254,6 +263,9 @@ public class GuiImgButton extends GuiButton implements ITooltip
if ( buttonSetting != null && currentValue != null )
{
BtnAppearance ba = Appearances.get( new EnumPair( buttonSetting, currentValue ) );
if ( ba == null )
return "No Such Message";
DisplayName = ba.DisplayName;
DisplayValue = ba.DisplayValue;
}