Added clear button to crafting terminal.
This commit is contained in:
@@ -1,13 +1,67 @@
|
|||||||
package appeng.client.gui.implementations;
|
package appeng.client.gui.implementations;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.inventory.Slot;
|
||||||
|
import appeng.api.config.ActionItems;
|
||||||
|
import appeng.api.config.Settings;
|
||||||
import appeng.api.storage.ITerminalHost;
|
import appeng.api.storage.ITerminalHost;
|
||||||
|
import appeng.client.gui.widgets.GuiImgButton;
|
||||||
import appeng.container.implementations.ContainerCraftingTerm;
|
import appeng.container.implementations.ContainerCraftingTerm;
|
||||||
|
import appeng.container.slot.SlotCraftingMatrix;
|
||||||
|
import appeng.core.AELog;
|
||||||
import appeng.core.localization.GuiText;
|
import appeng.core.localization.GuiText;
|
||||||
|
import appeng.core.sync.network.NetworkHandler;
|
||||||
|
import appeng.core.sync.packets.PacketInventoryAction;
|
||||||
|
import appeng.helpers.InventoryAction;
|
||||||
|
|
||||||
public class GuiCraftingTerm extends GuiMEMonitorable
|
public class GuiCraftingTerm extends GuiMEMonitorable
|
||||||
{
|
{
|
||||||
|
|
||||||
|
GuiImgButton clearBtn;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui()
|
||||||
|
{
|
||||||
|
super.initGui();
|
||||||
|
buttonList.add( clearBtn = new GuiImgButton( this.guiLeft + 92, this.guiTop + this.ySize - 156, Settings.ACTIONS, ActionItems.CLOSE ) );
|
||||||
|
clearBtn.halfSize = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void actionPerformed(GuiButton btn)
|
||||||
|
{
|
||||||
|
super.actionPerformed( btn );
|
||||||
|
|
||||||
|
if ( clearBtn == btn )
|
||||||
|
{
|
||||||
|
Slot s = null;
|
||||||
|
Container c = inventorySlots;
|
||||||
|
for (Object j : c.inventorySlots)
|
||||||
|
{
|
||||||
|
if ( j instanceof SlotCraftingMatrix )
|
||||||
|
s = (Slot) j;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( s != null )
|
||||||
|
{
|
||||||
|
PacketInventoryAction p;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
p = new PacketInventoryAction( InventoryAction.MOVE_REGION, s.slotNumber, null );
|
||||||
|
NetworkHandler.instance.sendToServer( p );
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
AELog.error( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public GuiCraftingTerm(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
public GuiCraftingTerm(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||||
super( inventoryPlayer, te, new ContainerCraftingTerm( inventoryPlayer, te ) );
|
super( inventoryPlayer, te, new ContainerCraftingTerm( inventoryPlayer, te ) );
|
||||||
reservedSpace = 73;
|
reservedSpace = 73;
|
||||||
|
|||||||
@@ -180,28 +180,30 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
|||||||
if ( btn instanceof GuiImgButton )
|
if ( btn instanceof GuiImgButton )
|
||||||
{
|
{
|
||||||
GuiImgButton iBtn = (GuiImgButton) btn;
|
GuiImgButton iBtn = (GuiImgButton) btn;
|
||||||
|
if ( iBtn.getSetting() != Settings.ACTIONS )
|
||||||
Enum cv = iBtn.getCurrentValue();
|
|
||||||
Enum next = Platform.nextEnum( cv );
|
|
||||||
|
|
||||||
if ( btn == searchBoxSettings )
|
|
||||||
AEConfig.instance.settings.putSetting( iBtn.getSetting(), next );
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
try
|
Enum cv = iBtn.getCurrentValue();
|
||||||
|
Enum next = Platform.nextEnum( cv );
|
||||||
|
|
||||||
|
if ( btn == searchBoxSettings )
|
||||||
|
AEConfig.instance.settings.putSetting( iBtn.getSetting(), next );
|
||||||
|
else
|
||||||
{
|
{
|
||||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( iBtn.getSetting().name(), next.name() ) );
|
try
|
||||||
}
|
{
|
||||||
catch (IOException e)
|
NetworkHandler.instance.sendToServer( new PacketValueConfig( iBtn.getSetting().name(), next.name() ) );
|
||||||
{
|
}
|
||||||
AELog.error( e );
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
AELog.error( e );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iBtn.set( next );
|
||||||
|
|
||||||
|
if ( next.getClass() == SearchBoxMode.class )
|
||||||
|
re_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
iBtn.set( next );
|
|
||||||
|
|
||||||
if ( next.getClass() == SearchBoxMode.class )
|
|
||||||
re_init();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user