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>.
|
|
|
|
*/
|
|
|
|
|
2013-12-30 06:56:43 +01:00
|
|
|
package appeng.client.gui.implementations;
|
|
|
|
|
2014-12-29 21:59:05 +01:00
|
|
|
import org.lwjgl.input.Mouse;
|
|
|
|
|
2014-01-02 06:51:41 +01:00
|
|
|
import net.minecraft.client.gui.GuiButton;
|
2013-12-30 06:56:43 +01:00
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2014-01-05 09:48:20 +01:00
|
|
|
|
2014-01-02 06:51:41 +01:00
|
|
|
import appeng.api.config.FuzzyMode;
|
|
|
|
import appeng.api.config.RedstoneMode;
|
|
|
|
import appeng.api.config.Settings;
|
|
|
|
import appeng.api.config.Upgrades;
|
2014-07-05 03:59:50 +02:00
|
|
|
import appeng.api.config.YesNo;
|
2014-01-23 20:02:48 +01:00
|
|
|
import appeng.api.implementations.IUpgradeableHost;
|
2013-12-30 06:56:43 +01:00
|
|
|
import appeng.client.gui.AEBaseGui;
|
2014-01-02 06:51:41 +01:00
|
|
|
import appeng.client.gui.widgets.GuiImgButton;
|
2014-01-20 17:41:37 +01:00
|
|
|
import appeng.container.implementations.ContainerUpgradeable;
|
2013-12-30 06:56:43 +01:00
|
|
|
import appeng.core.localization.GuiText;
|
2014-02-09 02:34:52 +01:00
|
|
|
import appeng.core.sync.network.NetworkHandler;
|
2014-01-02 06:51:41 +01:00
|
|
|
import appeng.core.sync.packets.PacketConfigButton;
|
2014-01-01 09:57:16 +01:00
|
|
|
import appeng.parts.automation.PartImportBus;
|
2013-12-30 06:56:43 +01:00
|
|
|
|
2014-01-20 17:41:37 +01:00
|
|
|
public class GuiUpgradeable extends AEBaseGui
|
2013-12-30 06:56:43 +01:00
|
|
|
{
|
|
|
|
|
2014-09-29 09:54:34 +02:00
|
|
|
final ContainerUpgradeable cvb;
|
|
|
|
final IUpgradeableHost bc;
|
2014-01-01 09:57:16 +01:00
|
|
|
|
2014-01-02 06:51:41 +01:00
|
|
|
GuiImgButton redstoneMode;
|
|
|
|
GuiImgButton fuzzyMode;
|
2014-07-05 03:59:50 +02:00
|
|
|
GuiImgButton craftMode;
|
2014-01-02 06:51:41 +01:00
|
|
|
|
2014-01-23 20:02:48 +01:00
|
|
|
public GuiUpgradeable(InventoryPlayer inventoryPlayer, IUpgradeableHost te) {
|
2014-01-20 17:41:37 +01:00
|
|
|
this( new ContainerUpgradeable( inventoryPlayer, te ) );
|
2014-01-05 09:48:20 +01:00
|
|
|
}
|
2014-01-02 06:51:41 +01:00
|
|
|
|
2014-01-20 17:41:37 +01:00
|
|
|
public GuiUpgradeable(ContainerUpgradeable te) {
|
2014-01-05 09:48:20 +01:00
|
|
|
super( te );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.cvb = te;
|
2014-01-05 09:48:20 +01:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.bc = (IUpgradeableHost) te.getTarget();
|
|
|
|
this.xSize = this.hasToolbox() ? 246 : 211;
|
2013-12-30 06:56:43 +01:00
|
|
|
this.ySize = 184;
|
|
|
|
}
|
|
|
|
|
2014-01-02 06:51:41 +01:00
|
|
|
@Override
|
|
|
|
public void initGui()
|
|
|
|
{
|
|
|
|
super.initGui();
|
2014-12-29 15:13:47 +01:00
|
|
|
this.addButtons();
|
2014-01-05 09:48:20 +01:00
|
|
|
}
|
2014-01-02 06:51:41 +01:00
|
|
|
|
2014-01-05 09:48:20 +01:00
|
|
|
protected void addButtons()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
|
|
|
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
|
|
|
this.craftMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.CRAFT_ONLY, YesNo.NO );
|
2014-01-02 06:51:41 +01:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.buttonList.add( this.craftMode );
|
|
|
|
this.buttonList.add( this.redstoneMode );
|
|
|
|
this.buttonList.add( this.fuzzyMode );
|
2014-01-02 06:51:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void actionPerformed(GuiButton btn)
|
|
|
|
{
|
|
|
|
super.actionPerformed( btn );
|
|
|
|
|
2014-01-05 09:48:20 +01:00
|
|
|
boolean backwards = Mouse.isButtonDown( 1 );
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( btn == this.redstoneMode )
|
|
|
|
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.redstoneMode.getSetting(), backwards ) );
|
2014-07-05 03:59:50 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( btn == this.craftMode )
|
|
|
|
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.craftMode.getSetting(), backwards ) );
|
2014-01-02 06:51:41 +01:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( btn == this.fuzzyMode )
|
|
|
|
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.fuzzyMode.getSetting(), backwards ) );
|
2014-01-02 06:51:41 +01:00
|
|
|
}
|
|
|
|
|
2014-01-20 17:41:37 +01:00
|
|
|
protected boolean hasToolbox()
|
2013-12-30 06:56:43 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return ((ContainerUpgradeable) this.inventorySlots).hasToolbox();
|
2013-12-30 06:56:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.handleButtonVisibility();
|
|
|
|
|
|
|
|
this.bindTexture( this.getBackground() );
|
|
|
|
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, this.ySize );
|
|
|
|
if ( this.drawUpgrades() )
|
|
|
|
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 14 + this.cvb.availableUpgrades() * 18 );
|
|
|
|
if ( this.hasToolbox() )
|
|
|
|
this.drawTexturedModalRect( offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68 );
|
2014-01-20 17:41:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected boolean drawUpgrades()
|
|
|
|
{
|
|
|
|
return true;
|
2013-12-30 06:56:43 +01:00
|
|
|
}
|
|
|
|
|
2014-01-05 09:48:20 +01:00
|
|
|
protected String getBackground()
|
|
|
|
{
|
|
|
|
return "guis/bus.png";
|
|
|
|
}
|
|
|
|
|
2014-09-21 02:10:27 +02:00
|
|
|
protected void handleButtonVisibility()
|
2014-01-05 09:48:20 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.redstoneMode != null )
|
|
|
|
this.redstoneMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.REDSTONE ) > 0 );
|
|
|
|
if ( this.fuzzyMode != null )
|
|
|
|
this.fuzzyMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 );
|
|
|
|
if ( this.craftMode != null )
|
|
|
|
this.craftMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 );
|
2014-01-05 09:48:20 +01:00
|
|
|
}
|
|
|
|
|
2013-12-30 06:56:43 +01:00
|
|
|
@Override
|
|
|
|
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.fontRendererObj.drawString( this.getGuiDisplayName( this.getName().getLocal() ), 8, 6, 4210752 );
|
|
|
|
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
2014-01-02 06:51:41 +01:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.redstoneMode != null )
|
|
|
|
this.redstoneMode.set( this.cvb.rsMode );
|
2014-01-06 07:54:25 +01:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.fuzzyMode != null )
|
|
|
|
this.fuzzyMode.set( this.cvb.fzMode );
|
2014-07-05 03:59:50 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.craftMode != null )
|
|
|
|
this.craftMode.set( this.cvb.cMode );
|
2013-12-30 06:56:43 +01:00
|
|
|
}
|
|
|
|
|
2014-01-05 09:48:20 +01:00
|
|
|
protected GuiText getName()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.bc instanceof PartImportBus ? GuiText.ImportBus : GuiText.ExportBus;
|
2014-01-05 09:48:20 +01:00
|
|
|
}
|
|
|
|
|
2013-12-30 06:56:43 +01:00
|
|
|
}
|