Compare commits

..

1 Commits

Author SHA1 Message Date
Salomão bc2e4c84b9 highlight interfaces from interface terminal. 2021-02-28 15:36:45 -03:00
4 changed files with 16 additions and 79 deletions
@@ -476,10 +476,7 @@ public abstract class AEBaseGui extends GuiContainer implements IMTModGuiContain
switch( clickType ) switch( clickType )
{ {
case PICKUP: // pickup / set-down. case PICKUP: // pickup / set-down.
if (slot.getStack().isEmpty() && !player.inventory.getItemStack().isEmpty()) action = ( mouseButton == 1 ) ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
action = InventoryAction.SPLIT_OR_PLACE_SINGLE;
if (!slot.getStack().isEmpty() && player.inventory.getItemStack().isEmpty())
action = InventoryAction.PICKUP_OR_SET_DOWN;
break; break;
case QUICK_MOVE: case QUICK_MOVE:
action = ( mouseButton == 1 ) ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK; action = ( mouseButton == 1 ) ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
@@ -22,11 +22,15 @@ package appeng.client.gui.implementations;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
import akka.event.Logging;
import appeng.client.render.BlockPosHighlighter;
import appeng.util.BlockPosUtils; import appeng.util.BlockPosUtils;
import com.google.common.collect.HashMultimap; import com.google.common.collect.HashMultimap;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -46,8 +50,10 @@ import appeng.parts.reporting.PartInterfaceTerminal;
import appeng.util.Platform; import appeng.util.Platform;
import net.minecraft.nbt.NBTUtil; import net.minecraft.nbt.NBTUtil;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentString;
import org.lwjgl.util.Color;
import org.lwjgl.util.ReadableColor;
import static appeng.client.render.BlockPosHighlighter.hilightBlock; import static appeng.client.render.BlockPosHighlighter.hilightBlock;
@@ -72,15 +78,12 @@ public class GuiInterfaceTerminal extends AEBaseGui
private boolean refreshList = false; private boolean refreshList = false;
private MEGuiTextField searchFieldOutputs; private MEGuiTextField searchFieldOutputs;
private MEGuiTextField searchFieldInputs; private MEGuiTextField searchFieldInputs;
private PartInterfaceTerminal partInterfaceTerminal;
private GuiButton guiButtonHide;
private GuiButton guiButtonNextAssembler;
public GuiInterfaceTerminal( final InventoryPlayer inventoryPlayer, final PartInterfaceTerminal te ) public GuiInterfaceTerminal( final InventoryPlayer inventoryPlayer, final PartInterfaceTerminal te )
{ {
super( new ContainerInterfaceTerminal( inventoryPlayer, te ) ); super( new ContainerInterfaceTerminal( inventoryPlayer, te ) );
this.partInterfaceTerminal = te;
final GuiScrollbar scrollbar = new GuiScrollbar(); final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar( scrollbar ); this.setScrollBar( scrollbar );
this.xSize = 195; this.xSize = 195;
@@ -103,7 +106,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
this.searchFieldInputs.setVisible( true ); this.searchFieldInputs.setVisible( true );
this.searchFieldInputs.setFocused( false ); 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 = new MEGuiTextField( this.fontRenderer, this.guiLeft + Math.max( 94, this.offsetX ), this.guiTop + 18, 65, 12 );
this.searchFieldOutputs.setEnableBackgroundDrawing( false ); this.searchFieldOutputs.setEnableBackgroundDrawing( false );
this.searchFieldOutputs.setMaxStringLength( 25 ); this.searchFieldOutputs.setMaxStringLength( 25 );
@@ -111,15 +114,6 @@ public class GuiInterfaceTerminal extends AEBaseGui
this.searchFieldOutputs.setVisible( true ); this.searchFieldOutputs.setVisible( true );
this.searchFieldOutputs.setFocused( 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 @Override
@@ -132,12 +126,6 @@ public class GuiInterfaceTerminal extends AEBaseGui
final int ex = this.getScrollBar().getCurrentScroll(); 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(); final Iterator<Slot> o = this.inventorySlots.inventorySlots.iterator();
while( o.hasNext() ) 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.sendStatusMessage( new TextComponentString( "The interface is now highlighted at " + "X: " + blockPos.getX() + "Y: " + blockPos.getY() + "Z: " + blockPos.getZ() ), false );
mc.player.closeScreen(); 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 @Override
@@ -357,20 +324,19 @@ public class GuiInterfaceTerminal extends AEBaseGui
final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase(); final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase();
final String searchFieldOutputs = this.searchFieldOutputs.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(); final boolean rebuild = cachedSearch.isEmpty();
for( final ClientDCInternalInv entry : this.byId.values() ) 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 ) ) if( !rebuild && !cachedSearch.contains( entry ) )
{ {
continue; continue;
} }
// Shortcut to skip any filter if search term is ""/empty // Shortcut to skip any filter if search term is ""/empty
boolean found = (searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty());
boolean found = (searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty() && !partInterfaceTerminal.onlyInterfacesWithFreeSlots);
// Search if the current inventory holds a pattern containing the search term. // Search if the current inventory holds a pattern containing the search term.
if( !found ) if( !found )
@@ -390,30 +356,11 @@ public class GuiInterfaceTerminal extends AEBaseGui
} }
} }
// 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, filter skipped or machine name matching the search term, add it
if( found || (entry.getName().toLowerCase().contains( searchFieldInputs ) && entry.getName().toLowerCase().contains( searchFieldOutputs ))) if( found || (entry.getName().toLowerCase().contains( searchFieldInputs ) && entry.getName().toLowerCase().contains( searchFieldOutputs )))
{ {
if (!partInterfaceTerminal.onlyInterfacesWithFreeSlots) this.byName.put( entry.getName(), entry );
{ cachedSearch.add( entry );
this.byName.put( entry.getName(), entry );
cachedSearch.add( entry );
}
else if ( interfaceHasFreeSlots ){
this.byName.put( entry.getName(), entry );
cachedSearch.add( entry );
}
} }
else else
{ {
@@ -419,7 +419,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
this.client = new AppEngInternalInventory( null, this.server.getSlots() ); this.client = new AppEngInternalInventory( null, this.server.getSlots() );
this.unlocalizedName = unlocalizedName; this.unlocalizedName = unlocalizedName;
this.sortBy = dual.getSortValue(); this.sortBy = dual.getSortValue();
this.pos = dual.getLocation().getPos(); this.pos = dual.getTile().getPos();
} }
} }
@@ -44,9 +44,6 @@ public class PartInterfaceTerminal extends AbstractPartDisplay
public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF ); public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF );
public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_ON ); public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_ON );
public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL ); public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL );
public String in = "";
public String out = "";
public boolean onlyInterfacesWithFreeSlots = false;
public PartInterfaceTerminal( final ItemStack is ) public PartInterfaceTerminal( final ItemStack is )
{ {
@@ -72,8 +69,4 @@ public class PartInterfaceTerminal extends AbstractPartDisplay
return this.selectModel( MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL ); return this.selectModel( MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL );
} }
public void saveSearchStrings(String in, String out){
this.in = in;
this.out = out;
}
} }