|
|
|
@@ -22,11 +22,15 @@ package appeng.client.gui.implementations;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
import akka.event.Logging;
|
|
|
|
|
import appeng.client.render.BlockPosHighlighter;
|
|
|
|
|
import appeng.util.BlockPosUtils;
|
|
|
|
|
import com.google.common.collect.HashMultimap;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
|
import net.minecraft.client.gui.GuiButton;
|
|
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
|
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
|
|
|
|
import net.minecraft.inventory.Slot;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
@@ -46,8 +50,10 @@ import appeng.parts.reporting.PartInterfaceTerminal;
|
|
|
|
|
import appeng.util.Platform;
|
|
|
|
|
import net.minecraft.nbt.NBTUtil;
|
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
|
import net.minecraft.util.text.ITextComponent;
|
|
|
|
|
import net.minecraft.util.text.TextComponentString;
|
|
|
|
|
|
|
|
|
|
import org.lwjgl.util.Color;
|
|
|
|
|
import org.lwjgl.util.ReadableColor;
|
|
|
|
|
|
|
|
|
|
import static appeng.client.render.BlockPosHighlighter.hilightBlock;
|
|
|
|
|
|
|
|
|
@@ -72,15 +78,12 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
|
|
|
|
private boolean refreshList = false;
|
|
|
|
|
private MEGuiTextField searchFieldOutputs;
|
|
|
|
|
private MEGuiTextField searchFieldInputs;
|
|
|
|
|
private PartInterfaceTerminal partInterfaceTerminal;
|
|
|
|
|
private GuiButton guiButtonHide;
|
|
|
|
|
private GuiButton guiButtonNextAssembler;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public GuiInterfaceTerminal( final InventoryPlayer inventoryPlayer, final PartInterfaceTerminal te )
|
|
|
|
|
{
|
|
|
|
|
super( new ContainerInterfaceTerminal( inventoryPlayer, te ) );
|
|
|
|
|
|
|
|
|
|
this.partInterfaceTerminal = te;
|
|
|
|
|
final GuiScrollbar scrollbar = new GuiScrollbar();
|
|
|
|
|
this.setScrollBar( scrollbar );
|
|
|
|
|
this.xSize = 195;
|
|
|
|
@@ -103,7 +106,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
|
|
|
|
this.searchFieldInputs.setVisible( true );
|
|
|
|
|
this.searchFieldInputs.setFocused( false );
|
|
|
|
|
|
|
|
|
|
// this.searchFieldOutputs = new MEGuiTextField( this.fontRenderer, this.guiLeft + Math.max( 105, this.offsetX ), this.guiTop + 4, 65, 12 );
|
|
|
|
|
// this.searchFieldOutputs = new MEGuiTextField( this.fontRenderer, this.guiLeft + Math.max( 104, this.offsetX ), this.guiTop + 4, 65, 12 );
|
|
|
|
|
this.searchFieldOutputs = new MEGuiTextField( this.fontRenderer, this.guiLeft + Math.max( 94, this.offsetX ), this.guiTop + 18, 65, 12 );
|
|
|
|
|
this.searchFieldOutputs.setEnableBackgroundDrawing( false );
|
|
|
|
|
this.searchFieldOutputs.setMaxStringLength( 25 );
|
|
|
|
@@ -111,15 +114,6 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
|
|
|
|
this.searchFieldOutputs.setVisible( true );
|
|
|
|
|
this.searchFieldOutputs.setFocused( true );
|
|
|
|
|
|
|
|
|
|
this.searchFieldInputs.setText( partInterfaceTerminal.in );
|
|
|
|
|
this.searchFieldOutputs.setText( partInterfaceTerminal.out );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onGuiClosed()
|
|
|
|
|
{
|
|
|
|
|
partInterfaceTerminal.saveSearchStrings( this.searchFieldInputs.getText().toLowerCase(), this.searchFieldOutputs.getText().toLowerCase() );
|
|
|
|
|
super.onGuiClosed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@@ -132,12 +126,6 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
|
|
|
|
|
|
|
|
|
final int ex = this.getScrollBar().getCurrentScroll();
|
|
|
|
|
|
|
|
|
|
this.guiButtonNextAssembler = new GuiButton( -1, guiLeft + 110, guiTop + 4, 12, 12, "M" );
|
|
|
|
|
this.buttonList.add( guiButtonNextAssembler );
|
|
|
|
|
|
|
|
|
|
this.guiButtonHide = new GuiButton( -1, guiLeft + 128, guiTop + 4, 60, 12, "Hide Full" );
|
|
|
|
|
this.buttonList.add( guiButtonHide );
|
|
|
|
|
|
|
|
|
|
final Iterator<Slot> o = this.inventorySlots.inventorySlots.iterator();
|
|
|
|
|
while( o.hasNext() )
|
|
|
|
|
{
|
|
|
|
@@ -216,27 +204,6 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
|
|
|
|
mc.player.sendStatusMessage( new TextComponentString( "The interface is now highlighted at " + "X: " + blockPos.getX() + "Y: " + blockPos.getY() + "Z: " + blockPos.getZ() ), false );
|
|
|
|
|
mc.player.closeScreen();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (btn == guiButtonHide)
|
|
|
|
|
{
|
|
|
|
|
partInterfaceTerminal.onlyInterfacesWithFreeSlots = !partInterfaceTerminal.onlyInterfacesWithFreeSlots;
|
|
|
|
|
this.refreshList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (btn == guiButtonNextAssembler)
|
|
|
|
|
{
|
|
|
|
|
// Set Search to "Molecular Assembler" and set "Only Free Interface"
|
|
|
|
|
boolean currentOnlyInterfacesWithFreeSlots = this.partInterfaceTerminal.onlyInterfacesWithFreeSlots;
|
|
|
|
|
String currentSearchText = this.searchFieldOutputs.getText();
|
|
|
|
|
|
|
|
|
|
this.partInterfaceTerminal.onlyInterfacesWithFreeSlots = true;
|
|
|
|
|
this.searchFieldOutputs.setText("Molecular Assembler");
|
|
|
|
|
|
|
|
|
|
this.refreshList();
|
|
|
|
|
|
|
|
|
|
this.partInterfaceTerminal.onlyInterfacesWithFreeSlots = currentOnlyInterfacesWithFreeSlots;
|
|
|
|
|
this.searchFieldOutputs.setText(currentSearchText);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@@ -357,20 +324,19 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
|
|
|
|
final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase();
|
|
|
|
|
final String searchFieldOutputs = this.searchFieldOutputs.getText().toLowerCase();
|
|
|
|
|
|
|
|
|
|
final Set<Object> cachedSearch = this.getCacheForSearchTerm( "IN:" + searchFieldInputs + " OUT:" + searchFieldOutputs + partInterfaceTerminal.onlyInterfacesWithFreeSlots);
|
|
|
|
|
final Set<Object> cachedSearch = this.getCacheForSearchTerm( "IN:" + searchFieldInputs + " OUT:" + searchFieldOutputs );
|
|
|
|
|
final boolean rebuild = cachedSearch.isEmpty();
|
|
|
|
|
|
|
|
|
|
for( final ClientDCInternalInv entry : this.byId.values() )
|
|
|
|
|
{
|
|
|
|
|
// ignore inventory if not doing a full rebuild and cache already marks it as miss.
|
|
|
|
|
// ignore inventory if not doing a full rebuild or cache already marks it as miss.
|
|
|
|
|
if( !rebuild && !cachedSearch.contains( entry ) )
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Shortcut to skip any filter if search term is ""/empty
|
|
|
|
|
|
|
|
|
|
boolean found = (searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty() && !partInterfaceTerminal.onlyInterfacesWithFreeSlots);
|
|
|
|
|
boolean found = (searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty());
|
|
|
|
|
|
|
|
|
|
// Search if the current inventory holds a pattern containing the search term.
|
|
|
|
|
if( !found )
|
|
|
|
@@ -388,32 +354,13 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If only Interfaces with empty slots should be shown, check that here
|
|
|
|
|
boolean interfaceHasFreeSlots = false;
|
|
|
|
|
if (partInterfaceTerminal.onlyInterfacesWithFreeSlots) {
|
|
|
|
|
for( final ItemStack itemStack : entry.getInventory() )
|
|
|
|
|
{
|
|
|
|
|
if(itemStack.isEmpty()){
|
|
|
|
|
interfaceHasFreeSlots = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if found, filter skipped or machine name matching the search term, add it
|
|
|
|
|
if( found || (entry.getName().toLowerCase().contains( searchFieldInputs ) && entry.getName().toLowerCase().contains( searchFieldOutputs )))
|
|
|
|
|
{
|
|
|
|
|
if (!partInterfaceTerminal.onlyInterfacesWithFreeSlots)
|
|
|
|
|
{
|
|
|
|
|
this.byName.put( entry.getName(), entry );
|
|
|
|
|
cachedSearch.add( entry );
|
|
|
|
|
}
|
|
|
|
|
else if ( interfaceHasFreeSlots ){
|
|
|
|
|
this.byName.put( entry.getName(), entry );
|
|
|
|
|
cachedSearch.add( entry );
|
|
|
|
|
}
|
|
|
|
|
this.byName.put( entry.getName(), entry );
|
|
|
|
|
cachedSearch.add( entry );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|