Standard and Auto Search Settings.
This commit is contained in:
parent
0c24d0ef76
commit
ca738e6065
3 changed files with 94 additions and 7 deletions
|
@ -3,8 +3,8 @@ package appeng.client.gui.implementations;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.GuiTextField;
|
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import appeng.api.config.SearchBoxMode;
|
||||||
import appeng.api.config.Settings;
|
import appeng.api.config.Settings;
|
||||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||||
import appeng.api.implementations.tiles.IMEChest;
|
import appeng.api.implementations.tiles.IMEChest;
|
||||||
|
@ -14,6 +14,7 @@ import appeng.client.gui.AEBaseMEGui;
|
||||||
import appeng.client.gui.widgets.GuiImgButton;
|
import appeng.client.gui.widgets.GuiImgButton;
|
||||||
import appeng.client.gui.widgets.GuiScrollbar;
|
import appeng.client.gui.widgets.GuiScrollbar;
|
||||||
import appeng.client.gui.widgets.ISortSource;
|
import appeng.client.gui.widgets.ISortSource;
|
||||||
|
import appeng.client.gui.widgets.MEGuiTextField;
|
||||||
import appeng.client.me.InternalSlotME;
|
import appeng.client.me.InternalSlotME;
|
||||||
import appeng.client.me.ItemRepo;
|
import appeng.client.me.ItemRepo;
|
||||||
import appeng.container.implementations.ContainerMEMonitorable;
|
import appeng.container.implementations.ContainerMEMonitorable;
|
||||||
|
@ -28,7 +29,7 @@ import appeng.util.Platform;
|
||||||
public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource
|
public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource
|
||||||
{
|
{
|
||||||
|
|
||||||
GuiTextField searchField;
|
MEGuiTextField searchField;
|
||||||
ItemRepo repo;
|
ItemRepo repo;
|
||||||
|
|
||||||
GuiText myName;
|
GuiText myName;
|
||||||
|
@ -81,6 +82,12 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource
|
||||||
myScrollBar.setRange( 0, (repo.size() + perRow - 1) / perRow - rows, Math.max( 1, rows / 6 ) );
|
myScrollBar.setRange( 0, (repo.size() + perRow - 1) / perRow - rows, Math.max( 1, rows / 6 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void re_init()
|
||||||
|
{
|
||||||
|
this.buttonList.clear();
|
||||||
|
this.initGui();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initGui()
|
public void initGui()
|
||||||
{
|
{
|
||||||
|
@ -121,15 +128,21 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource
|
||||||
offset += 20;
|
offset += 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonList.add( new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, AEConfig.instance.settings
|
buttonList
|
||||||
.getSetting( Settings.SORT_DIRECTION ) ) );
|
.add( new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, AEConfig.instance.settings.getSetting( Settings.SORT_DIRECTION ) ) );
|
||||||
|
offset += 20;
|
||||||
|
|
||||||
searchField = new GuiTextField( fontRendererObj, this.guiLeft + Math.max( 82, xoffset ), this.guiTop + 6, 89, fontRendererObj.FONT_HEIGHT );
|
buttonList.add( new GuiImgButton( this.guiLeft - 18, offset, Settings.SEARCH_MODE, AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE ) ) );
|
||||||
|
|
||||||
|
searchField = new MEGuiTextField( fontRendererObj, this.guiLeft + Math.max( 82, xoffset ), this.guiTop + 6, 89, fontRendererObj.FONT_HEIGHT );
|
||||||
searchField.setEnableBackgroundDrawing( false );
|
searchField.setEnableBackgroundDrawing( false );
|
||||||
searchField.setMaxStringLength( 25 );
|
searchField.setMaxStringLength( 25 );
|
||||||
searchField.setTextColor( 0xFFFFFF );
|
searchField.setTextColor( 0xFFFFFF );
|
||||||
searchField.setVisible( true );
|
searchField.setVisible( true );
|
||||||
searchField.setFocused( true );
|
|
||||||
|
// Enum setting = AEConfig.instance.getSetting( "Terminal", SearchBoxMode.class, SearchBoxMode.AUTOSEARCH );
|
||||||
|
Enum setting = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
|
||||||
|
searchField.setFocused( SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting );
|
||||||
|
|
||||||
setScrollBar();
|
setScrollBar();
|
||||||
|
|
||||||
|
@ -155,9 +168,29 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource
|
||||||
AEConfig.instance.settings.putSetting( iBtn.getSetting(), next );
|
AEConfig.instance.settings.putSetting( iBtn.getSetting(), next );
|
||||||
iBtn.set( next );
|
iBtn.set( next );
|
||||||
repo.updateView();
|
repo.updateView();
|
||||||
|
|
||||||
|
if ( next.getClass() == SearchBoxMode.class )
|
||||||
|
re_init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void mouseClicked(int xCoord, int yCoord, int btn)
|
||||||
|
{
|
||||||
|
Enum setting = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
|
||||||
|
if ( !(SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting) )
|
||||||
|
searchField.mouseClicked( xCoord, yCoord, btn );
|
||||||
|
|
||||||
|
if ( btn == 1 && searchField.isMouseIn( xCoord, yCoord ) )
|
||||||
|
{
|
||||||
|
searchField.setText( "" );
|
||||||
|
repo.searchString = "";
|
||||||
|
repo.updateView();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.mouseClicked( xCoord, yCoord, btn );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void keyTyped(char character, int key)
|
protected void keyTyped(char character, int key)
|
||||||
{
|
{
|
||||||
|
@ -190,6 +223,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource
|
||||||
|
|
||||||
this.drawTexturedModalRect( offsetX, offsetY + 16 + rows * 18 + lowerTextureOffset, 0, 106 - 18 - 18, x_width, 99 + reservedSpace - lowerTextureOffset );
|
this.drawTexturedModalRect( offsetX, offsetY + 16 + rows * 18 + lowerTextureOffset, 0, 106 - 18 - 18, x_width, 99 + reservedSpace - lowerTextureOffset );
|
||||||
|
|
||||||
|
if ( searchField != null )
|
||||||
searchField.drawTextBox();
|
searchField.drawTextBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
28
client/gui/widgets/MEGuiTextField.java
Normal file
28
client/gui/widgets/MEGuiTextField.java
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
package appeng.client.gui.widgets;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
|
|
||||||
|
public class MEGuiTextField extends GuiTextField
|
||||||
|
{
|
||||||
|
|
||||||
|
int posX;
|
||||||
|
int posY;
|
||||||
|
|
||||||
|
int myWidth;
|
||||||
|
int myHeight;
|
||||||
|
|
||||||
|
public MEGuiTextField(FontRenderer par1FontRenderer, int xPos, int yPos, int width, int height) {
|
||||||
|
super( par1FontRenderer, xPos, yPos, width, height );
|
||||||
|
posX = xPos;
|
||||||
|
posY = yPos;
|
||||||
|
myWidth = width;
|
||||||
|
myHeight = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMouseIn(int xCoord, int yCoord)
|
||||||
|
{
|
||||||
|
return xCoord >= posX && xCoord < posX + myWidth && yCoord >= posY && yCoord < posY + myHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ import net.minecraftforge.common.config.Property;
|
||||||
import appeng.api.config.CondenserOuput;
|
import appeng.api.config.CondenserOuput;
|
||||||
import appeng.api.config.PowerMultiplier;
|
import appeng.api.config.PowerMultiplier;
|
||||||
import appeng.api.config.PowerUnits;
|
import appeng.api.config.PowerUnits;
|
||||||
|
import appeng.api.config.SearchBoxMode;
|
||||||
import appeng.api.config.Settings;
|
import appeng.api.config.Settings;
|
||||||
import appeng.api.config.SortDir;
|
import appeng.api.config.SortDir;
|
||||||
import appeng.api.config.SortOrder;
|
import appeng.api.config.SortOrder;
|
||||||
|
@ -116,6 +117,7 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo
|
||||||
settings.registerSetting( Settings.SEARCH_TOOLTIPS, YesNo.YES );
|
settings.registerSetting( Settings.SEARCH_TOOLTIPS, YesNo.YES );
|
||||||
settings.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
settings.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||||
settings.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
settings.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||||
|
settings.registerSetting( Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH );
|
||||||
|
|
||||||
WirelessBaseCost = get( "wireless", "WirelessBaseCost", WirelessBaseCost ).getDouble( WirelessBaseCost );
|
WirelessBaseCost = get( "wireless", "WirelessBaseCost", WirelessBaseCost ).getDouble( WirelessBaseCost );
|
||||||
WirelessCostMultiplier = get( "wireless", "WirelessCostMultiplier", WirelessCostMultiplier ).getDouble( WirelessCostMultiplier );
|
WirelessCostMultiplier = get( "wireless", "WirelessCostMultiplier", WirelessCostMultiplier ).getDouble( WirelessCostMultiplier );
|
||||||
|
@ -232,4 +234,27 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Enum getSetting(String Category, Class<? extends Enum> class1, Enum myDefault)
|
||||||
|
{
|
||||||
|
String name = class1.getSimpleName();
|
||||||
|
Property p = get( Category, name, myDefault.name() );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return (Enum) class1.getField( p.toString() ).get( class1 );
|
||||||
|
}
|
||||||
|
catch (Throwable t)
|
||||||
|
{
|
||||||
|
// :{
|
||||||
|
}
|
||||||
|
|
||||||
|
return myDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSetting(String Category, Enum s)
|
||||||
|
{
|
||||||
|
String name = s.getClass().getSimpleName();
|
||||||
|
get( Category, name, s.name() ).set( s.name() );
|
||||||
|
save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue