Added NEI Sync.

This commit is contained in:
AlgorithmX2
2014-04-19 23:35:13 -05:00
parent c5f2a3914e
commit 2e71a6530e
2 changed files with 46 additions and 5 deletions
@@ -30,6 +30,7 @@ import appeng.container.implementations.ContainerMEMonitorable;
import appeng.container.slot.AppEngSlot;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.AppEng;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
@@ -132,8 +133,11 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
maxRows = getMaxRows();
perRow = AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) != TerminalStyle.FULL ? 9 : 9 + ((width - standardSize) / 18);
int NEI = 0;
int top = 4;
boolean hasNEI = AppEng.instance.isIntegrationEnabled( "NEI" );
int NEI = hasNEI ? 4 : 0;
int top = hasNEI ? 22 : 4;
int magicNumber = 114 + 1;
int extraSpace = height - magicNumber - NEI - top - reservedSpace;
@@ -144,6 +148,9 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
rows = maxRows;
}
if ( hasNEI )
rows--;
meSlots.clear();
for (int y = 0; y < rows; y++)
{
@@ -181,12 +188,12 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
.getSetting( Settings.SEARCH_MODE ) ) );
offset += 20;
if ( !(this instanceof GuiMEPortableCell ) )
if ( !(this instanceof GuiMEPortableCell) )
{
buttonList.add( terminalStyleBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.TERMINAL_STYLE, AEConfig.instance.settings
.getSetting( Settings.TERMINAL_STYLE ) ) );
}
searchField = new MEGuiTextField( fontRendererObj, this.guiLeft + Math.max( 82, xoffset ), this.guiTop + 6, 89, fontRendererObj.FONT_HEIGHT );
searchField.setEnableBackgroundDrawing( false );
searchField.setMaxStringLength( 25 );
@@ -299,7 +306,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
bindTexture( getBackground() );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18 );
if ( viewCell || ( this instanceof GuiSecurity))
if ( viewCell || (this instanceof GuiSecurity) )
this.drawTexturedModalRect( offsetX + x_width, offsetY, x_width, 0, 46, 128 );
for (int x = 0; x < rows; x++)
+34
View File
@@ -1,5 +1,7 @@
package appeng.client.me;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.regex.Pattern;
@@ -8,6 +10,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.config.SearchBoxMode;
import appeng.api.config.Settings;
import appeng.api.config.SortOrder;
import appeng.api.config.Upgrades;
@@ -26,6 +29,7 @@ import appeng.util.prioitylist.FuzzyPriorityList;
import appeng.util.prioitylist.IPartitionList;
import appeng.util.prioitylist.MergedPriorityList;
import appeng.util.prioitylist.PrecisePriorityList;
import cpw.mods.fml.relauncher.ReflectionHelper;
public class ItemRepo
{
@@ -151,6 +155,32 @@ public class ItemRepo
updateView();
}
private String NEIWord = null;
private void updateNEI(String filter)
{
try
{
if ( NEIWord == null || !NEIWord.equals( filter ) )
{
Class c = ReflectionHelper.getClass( getClass().getClassLoader(), "codechicken.nei.LayoutManager" );
Field fldSearchField = c.getField( "searchField" );
Object searchField = fldSearchField.get( c );
Method a = searchField.getClass().getMethod( "setText", String.class );
Method b = searchField.getClass().getMethod( "onTextChange", String.class );
NEIWord = filter;
a.invoke( searchField, filter );
b.invoke( searchField, "" );
}
}
catch (Throwable _)
{
}
}
public void updateView()
{
view.clear();
@@ -159,6 +189,10 @@ public class ItemRepo
view.ensureCapacity( list.size() );
dsp.ensureCapacity( list.size() );
Enum mode = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
if ( mode == SearchBoxMode.NEI_AUTOSEARCH || mode == SearchBoxMode.NEI_MANUAL_SEARCH )
updateNEI( searchString );
boolean terminalSearchToolTips = AEConfig.instance.settings.getSetting( Settings.SEARCH_TOOLTIPS ) != YesNo.NO;
// boolean terminalSearchMods = Configuration.instance.settings.getSetting( Settings.SEARCH_MODS ) != YesNo.NO;