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>.
|
|
|
|
*/
|
|
|
|
|
2014-04-08 02:43:57 +02:00
|
|
|
package appeng.client.gui.implementations;
|
|
|
|
|
2014-04-10 06:51:08 +02:00
|
|
|
import java.io.IOException;
|
|
|
|
|
2014-04-08 02:43:57 +02:00
|
|
|
import net.minecraft.client.gui.GuiButton;
|
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2014-04-10 06:51:08 +02:00
|
|
|
import net.minecraft.init.Blocks;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2014-12-29 21:59:05 +01:00
|
|
|
|
2014-04-08 02:43:57 +02:00
|
|
|
import appeng.api.config.ActionItems;
|
|
|
|
import appeng.api.config.Settings;
|
|
|
|
import appeng.api.storage.ITerminalHost;
|
|
|
|
import appeng.client.gui.widgets.GuiImgButton;
|
2014-04-10 06:51:08 +02:00
|
|
|
import appeng.client.gui.widgets.GuiTabButton;
|
2014-04-08 02:43:57 +02:00
|
|
|
import appeng.container.implementations.ContainerPatternTerm;
|
2014-07-02 03:43:08 +02:00
|
|
|
import appeng.container.slot.AppEngSlot;
|
2014-04-08 02:43:57 +02:00
|
|
|
import appeng.core.localization.GuiText;
|
2014-04-10 06:51:08 +02:00
|
|
|
import appeng.core.sync.network.NetworkHandler;
|
|
|
|
import appeng.core.sync.packets.PacketValueConfig;
|
2014-04-08 02:43:57 +02:00
|
|
|
|
|
|
|
public class GuiPatternTerm extends GuiMEMonitorable
|
|
|
|
{
|
|
|
|
|
2014-09-29 09:54:34 +02:00
|
|
|
final ContainerPatternTerm container;
|
2014-04-10 06:51:08 +02:00
|
|
|
|
|
|
|
GuiTabButton tabCraftButton;
|
|
|
|
GuiTabButton tabProcessButton;
|
2014-07-15 05:33:17 +02:00
|
|
|
// GuiImgButton substitutionsBtn;
|
2014-04-10 06:51:08 +02:00
|
|
|
GuiImgButton encodeBtn;
|
2014-04-17 08:15:56 +02:00
|
|
|
GuiImgButton clearBtn;
|
2014-04-08 02:43:57 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void initGui()
|
|
|
|
{
|
|
|
|
super.initGui();
|
2014-12-29 15:13:47 +01:00
|
|
|
this.buttonList.add( this.tabCraftButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.crafting_table ),
|
2014-04-10 06:51:08 +02:00
|
|
|
GuiText.CraftingPattern.getLocal(), itemRender ) );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.buttonList.add( this.tabProcessButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.furnace ),
|
2014-04-10 06:51:08 +02:00
|
|
|
GuiText.ProcessingPattern.getLocal(), itemRender ) );
|
2014-04-17 08:15:56 +02:00
|
|
|
|
2014-07-15 05:33:17 +02:00
|
|
|
// buttonList.add( substitutionsBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163,
|
|
|
|
// Settings.ACTIONS, ActionItems.SUBSTITUTION ) );
|
|
|
|
// substitutionsBtn.halfSize = true;
|
2014-04-17 08:15:56 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.buttonList.add( this.clearBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE ) );
|
|
|
|
this.clearBtn.halfSize = true;
|
2014-04-17 08:15:56 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.buttonList.add( this.encodeBtn = new GuiImgButton( this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE ) );
|
2014-04-08 02:43:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void actionPerformed(GuiButton btn)
|
|
|
|
{
|
|
|
|
super.actionPerformed( btn );
|
|
|
|
|
2014-04-10 06:51:08 +02:00
|
|
|
try
|
2014-04-08 02:43:57 +02:00
|
|
|
{
|
2014-04-17 08:15:56 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.tabCraftButton == btn || this.tabProcessButton == btn )
|
2014-04-10 06:51:08 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.CraftMode", this.tabProcessButton == btn ? "1" : "0" ) );
|
2014-04-10 06:51:08 +02:00
|
|
|
}
|
2014-04-08 02:43:57 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.encodeBtn == btn )
|
2014-04-10 06:51:08 +02:00
|
|
|
{
|
|
|
|
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.Encode", "1" ) );
|
|
|
|
}
|
2014-04-17 08:15:56 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.clearBtn == btn )
|
2014-04-17 08:15:56 +02:00
|
|
|
{
|
|
|
|
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.Clear", "1" ) );
|
|
|
|
}
|
|
|
|
|
2014-04-10 06:51:08 +02:00
|
|
|
}
|
|
|
|
catch (IOException e)
|
|
|
|
{
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
e.printStackTrace();
|
2014-04-08 02:43:57 +02:00
|
|
|
}
|
|
|
|
|
2014-07-15 05:33:17 +02:00
|
|
|
// if ( substitutionsBtn == btn )
|
|
|
|
// {
|
2014-04-08 02:43:57 +02:00
|
|
|
|
2014-07-15 05:33:17 +02:00
|
|
|
// }
|
2014-04-08 02:43:57 +02:00
|
|
|
}
|
|
|
|
|
2014-09-28 20:34:00 +02:00
|
|
|
@Override
|
2014-07-02 03:43:08 +02:00
|
|
|
protected void repositionSlot(AppEngSlot s)
|
|
|
|
{
|
|
|
|
if ( s.isPlayerSide() )
|
2014-12-29 15:13:47 +01:00
|
|
|
s.yDisplayPosition = s.defY + this.ySize - 78 - 5;
|
2014-07-02 03:43:08 +02:00
|
|
|
else
|
2014-12-29 15:13:47 +01:00
|
|
|
s.yDisplayPosition = s.defY + this.ySize - 78 - 3;
|
2014-07-02 03:43:08 +02:00
|
|
|
}
|
|
|
|
|
2014-04-08 02:43:57 +02:00
|
|
|
public GuiPatternTerm(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
|
|
|
super( inventoryPlayer, te, new ContainerPatternTerm( inventoryPlayer, te ) );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.container = (ContainerPatternTerm) this.inventorySlots;
|
|
|
|
this.reservedSpace = 81;
|
2014-04-08 02:43:57 +02:00
|
|
|
}
|
|
|
|
|
2014-09-28 20:34:00 +02:00
|
|
|
@Override
|
2014-04-08 02:43:57 +02:00
|
|
|
protected String getBackground()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.container.craftingMode )
|
2014-04-10 06:51:08 +02:00
|
|
|
return "guis/pattern.png";
|
|
|
|
return "guis/pattern2.png";
|
2014-04-08 02:43:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( !this.container.craftingMode )
|
2014-04-10 06:51:08 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.tabCraftButton.visible = false;
|
|
|
|
this.tabProcessButton.visible = true;
|
2014-04-10 06:51:08 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.tabCraftButton.visible = true;
|
|
|
|
this.tabProcessButton.visible = false;
|
2014-04-10 06:51:08 +02:00
|
|
|
}
|
|
|
|
|
2014-04-08 02:43:57 +02:00
|
|
|
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.fontRendererObj.drawString( GuiText.PatternTerminal.getLocal(), 8, this.ySize - 96 + 2 - this.reservedSpace, 4210752 );
|
2014-04-08 02:43:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|