Right Click Buttons.
This commit is contained in:
parent
8c4798615b
commit
09a8f82245
2 changed files with 52 additions and 11 deletions
|
@ -4,6 +4,9 @@ import java.io.IOException;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
|
||||||
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
import appeng.api.config.FuzzyMode;
|
import appeng.api.config.FuzzyMode;
|
||||||
import appeng.api.config.RedstoneMode;
|
import appeng.api.config.RedstoneMode;
|
||||||
import appeng.api.config.Settings;
|
import appeng.api.config.Settings;
|
||||||
|
@ -27,10 +30,14 @@ public class GuiBus extends AEBaseGui
|
||||||
GuiImgButton fuzzyMode;
|
GuiImgButton fuzzyMode;
|
||||||
|
|
||||||
public GuiBus(InventoryPlayer inventoryPlayer, IBusCommon te) {
|
public GuiBus(InventoryPlayer inventoryPlayer, IBusCommon te) {
|
||||||
super( new ContainerBus( inventoryPlayer, te ) );
|
this( new ContainerBus( inventoryPlayer, te ) );
|
||||||
cvb = (ContainerBus) inventorySlots;
|
}
|
||||||
|
|
||||||
bc = te;
|
public GuiBus(ContainerBus te) {
|
||||||
|
super( te );
|
||||||
|
cvb = (ContainerBus) te;
|
||||||
|
|
||||||
|
bc = (IBusCommon) te.getTarget();
|
||||||
this.xSize = hasToolbox() ? 246 : 211;
|
this.xSize = hasToolbox() ? 246 : 211;
|
||||||
this.ySize = 184;
|
this.ySize = 184;
|
||||||
}
|
}
|
||||||
|
@ -39,26 +46,40 @@ public class GuiBus extends AEBaseGui
|
||||||
public void initGui()
|
public void initGui()
|
||||||
{
|
{
|
||||||
super.initGui();
|
super.initGui();
|
||||||
|
addButtons();
|
||||||
|
}
|
||||||
|
|
||||||
redstoneMode = new GuiImgButton( 122 + guiLeft, 31 + guiTop, Settings.REDSTONE_OUTPUT, RedstoneMode.IGNORE );
|
protected void addButtons()
|
||||||
|
{
|
||||||
|
redstoneMode = new GuiImgButton( 122 + guiLeft, 31 + guiTop, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||||
fuzzyMode = new GuiImgButton( 122 + guiLeft, 49 + guiTop, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
fuzzyMode = new GuiImgButton( 122 + guiLeft, 49 + guiTop, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||||
|
|
||||||
buttonList.add( redstoneMode );
|
buttonList.add( redstoneMode );
|
||||||
buttonList.add( fuzzyMode );
|
buttonList.add( fuzzyMode );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void mouseClicked(int par1, int par2, int par3)
|
||||||
|
{
|
||||||
|
if ( par3 == 1 )
|
||||||
|
super.mouseClicked( par1, par2, 0 );
|
||||||
|
else
|
||||||
|
super.mouseClicked( par1, par2, par3 );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void actionPerformed(GuiButton btn)
|
protected void actionPerformed(GuiButton btn)
|
||||||
{
|
{
|
||||||
super.actionPerformed( btn );
|
super.actionPerformed( btn );
|
||||||
|
|
||||||
|
boolean backwards = Mouse.isButtonDown( 1 );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ( btn == redstoneMode )
|
if ( btn == redstoneMode )
|
||||||
PacketDispatcher.sendPacketToServer( (new PacketConfigButton( Settings.REDSTONE_OUTPUT )).getPacket() );
|
PacketDispatcher.sendPacketToServer( (new PacketConfigButton( redstoneMode.getSetting(), backwards )).getPacket() );
|
||||||
|
|
||||||
if ( btn == fuzzyMode )
|
if ( btn == fuzzyMode )
|
||||||
PacketDispatcher.sendPacketToServer( (new PacketConfigButton( Settings.FUZZY_MODE )).getPacket() );
|
PacketDispatcher.sendPacketToServer( (new PacketConfigButton( fuzzyMode.getSetting(), backwards )).getPacket() );
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
|
@ -75,24 +96,39 @@ public class GuiBus extends AEBaseGui
|
||||||
@Override
|
@Override
|
||||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||||
{
|
{
|
||||||
redstoneMode.setVisibility( bc.getInstalledUpgrades( Upgrades.REDSTONE ) > 0 );
|
handleButtonVisiblity();
|
||||||
fuzzyMode.setVisibility( bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 );
|
|
||||||
|
|
||||||
bindTexture( "guis/bus.png" );
|
bindTexture( getBackground() );
|
||||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize - 34, ySize );
|
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize - 34, ySize );
|
||||||
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 86 );
|
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 86 );
|
||||||
if ( hasToolbox() )
|
if ( hasToolbox() )
|
||||||
this.drawTexturedModalRect( offsetX + 178, offsetY + 94, 178, 94, 68, 68 );
|
this.drawTexturedModalRect( offsetX + 178, offsetY + 94, 178, 94, 68, 68 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getBackground()
|
||||||
|
{
|
||||||
|
return "guis/bus.png";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void handleButtonVisiblity()
|
||||||
|
{
|
||||||
|
redstoneMode.setVisibility( bc.getInstalledUpgrades( Upgrades.REDSTONE ) > 0 );
|
||||||
|
fuzzyMode.setVisibility( bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||||
{
|
{
|
||||||
fontRenderer.drawString( (bc instanceof PartImportBus ? GuiText.ImportBus : GuiText.ExportBus).getLocal(), 8, 6, 4210752 );
|
fontRenderer.drawString( getName().getLocal(), 8, 6, 4210752 );
|
||||||
fontRenderer.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
fontRenderer.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||||
|
|
||||||
redstoneMode.set( cvb.rsMode );
|
redstoneMode.set( cvb.rsMode );
|
||||||
fuzzyMode.set( cvb.fzMode );
|
fuzzyMode.set( cvb.fzMode );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected GuiText getName()
|
||||||
|
{
|
||||||
|
return bc instanceof PartImportBus ? GuiText.ImportBus : GuiText.ExportBus;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,9 @@ import java.io.IOException;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
|
||||||
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
import appeng.api.config.Settings;
|
import appeng.api.config.Settings;
|
||||||
import appeng.client.gui.AEBaseGui;
|
import appeng.client.gui.AEBaseGui;
|
||||||
import appeng.client.gui.widgets.GuiImgButton;
|
import appeng.client.gui.widgets.GuiImgButton;
|
||||||
|
@ -33,11 +36,13 @@ public class GuiCondenser extends AEBaseGui
|
||||||
{
|
{
|
||||||
super.actionPerformed( btn );
|
super.actionPerformed( btn );
|
||||||
|
|
||||||
|
boolean backwards = Mouse.isButtonDown( 1 );
|
||||||
|
|
||||||
if ( mode == btn )
|
if ( mode == btn )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PacketDispatcher.sendPacketToServer( (new PacketConfigButton( Settings.CONDENSER_OUTPUT )).getPacket() );
|
PacketDispatcher.sendPacketToServer( (new PacketConfigButton( Settings.CONDENSER_OUTPUT, backwards )).getPacket() );
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue