Skip to content

Commit 1fa55f6

Browse files
committed
Added client config to not preserve the search string in terminals
Added tooltip to the search bar, that it may be cleared via right click
1 parent 308c855 commit 1fa55f6

File tree

7 files changed

+77
-34
lines changed

7 files changed

+77
-34
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
aeversion=rv3
22
aechannel=beta
3-
aebuild=48-GTNH
3+
aebuild=49-GTNH
44
#KEEP V6 FOR MOD SUPPORT
55
aegroup=appeng
66
aebasename=appliedenergistics2

src/main/java/appeng/client/gui/AEBaseGui.java

+20-16
Original file line numberDiff line numberDiff line change
@@ -146,25 +146,29 @@ public void drawScreen( final int mouseX, final int mouseY, final float btn )
146146
{
147147
if( c instanceof ITooltip )
148148
{
149-
final ITooltip tooltip = (ITooltip) c;
150-
final int x = tooltip.xPos(); // ((GuiImgButton) c).xPosition;
151-
int y = tooltip.yPos(); // ((GuiImgButton) c).yPosition;
149+
handleTooltip(mouseX, mouseY, (ITooltip) c);
150+
}
151+
}
152+
}
153+
154+
protected void handleTooltip(int mouseX, int mouseY, ITooltip c) {
155+
final ITooltip tooltip = c;
156+
final int x = tooltip.xPos(); // ((GuiImgButton) c).xPosition;
157+
int y = tooltip.yPos(); // ((GuiImgButton) c).yPosition;
152158

153-
if( x < mouseX && x + tooltip.getWidth() > mouseX && tooltip.isVisible() )
159+
if( x < mouseX && x + tooltip.getWidth() > mouseX && tooltip.isVisible() )
160+
{
161+
if( y < mouseY && y + tooltip.getHeight() > mouseY)
162+
{
163+
if( y < 15 )
154164
{
155-
if( y < mouseY && y + tooltip.getHeight() > mouseY )
156-
{
157-
if( y < 15 )
158-
{
159-
y = 15;
160-
}
165+
y = 15;
166+
}
161167

162-
final String msg = tooltip.getMessage();
163-
if( msg != null )
164-
{
165-
this.drawTooltip( x + 11, y + 4, 0, msg );
166-
}
167-
}
168+
final String msg = tooltip.getMessage();
169+
if( msg != null )
170+
{
171+
this.drawTooltip( x + 11, y + 4, 0, msg );
168172
}
169173
}
170174
}

src/main/java/appeng/client/gui/implementations/GuiMEMonitorable.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import appeng.container.slot.SlotFakeCraftingMatrix;
4040
import appeng.core.AEConfig;
4141
import appeng.core.AELog;
42+
import appeng.core.localization.ButtonToolTips;
4243
import appeng.core.localization.GuiText;
4344
import appeng.core.sync.GuiBridge;
4445
import appeng.core.sync.network.NetworkHandler;
@@ -304,6 +305,7 @@ public void initGui()
304305
this.searchField.setMaxStringLength( 25 );
305306
this.searchField.setTextColor( 0xFFFFFF );
306307
this.searchField.setVisible( true );
308+
searchField.setMessage(ButtonToolTips.SearchStringTooltip.getLocal());
307309

308310
if( this.viewCell || this instanceof GuiWirelessTerm )
309311
{
@@ -315,8 +317,11 @@ public void initGui()
315317
final Enum setting = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
316318
this.searchField.setFocused( SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting );
317319

318-
this.searchField.setText( memoryText );
319-
this.repo.setSearchString( memoryText );
320+
if (AEConfig.instance.preserveSearchBar || this.isSubGui())
321+
{
322+
this.searchField.setText(memoryText);
323+
this.repo.setSearchString(memoryText);
324+
}
320325
if( this.isSubGui() )
321326
{
322327
this.repo.updateView();
@@ -551,4 +556,10 @@ void setStandardSize( final int standardSize )
551556
{
552557
this.standardSize = standardSize;
553558
}
559+
@Override
560+
public void drawScreen( final int mouseX, final int mouseY, final float btn ) {
561+
super.drawScreen(mouseX, mouseY, btn);
562+
if (AEConfig.instance.preserveSearchBar)
563+
handleTooltip(mouseX, mouseY, searchField);
564+
}
554565
}

src/main/java/appeng/client/gui/widgets/MEGuiTextField.java

+39-12
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
* <p>
3232
* The rendering does pay attention to the size of the '_' caret.
3333
*/
34-
public class MEGuiTextField extends GuiTextField
35-
{
34+
public class MEGuiTextField extends GuiTextField implements ITooltip {
3635
private static final int PADDING = 2;
36+
private String tooltip;
3737

3838
private final int _xPos;
3939
private final int _yPos;
@@ -50,9 +50,8 @@ public class MEGuiTextField extends GuiTextField
5050
* @param width absolute width
5151
* @param height absolute height
5252
*/
53-
public MEGuiTextField( final FontRenderer fontRenderer, final int xPos, final int yPos, final int width, final int height )
54-
{
55-
super( fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - fontRenderer.getCharWidth( '_' ), height - 2 * PADDING );
53+
public MEGuiTextField(final FontRenderer fontRenderer, final int xPos, final int yPos, final int width, final int height) {
54+
super(fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - fontRenderer.getCharWidth('_'), height - 2 * PADDING);
5655

5756
this._xPos = xPos;
5857
this._yPos = yPos;
@@ -61,13 +60,12 @@ public MEGuiTextField( final FontRenderer fontRenderer, final int xPos, final in
6160
}
6261

6362
@Override
64-
public void mouseClicked( final int xPos, final int yPos, final int button )
65-
{
66-
super.mouseClicked( xPos, yPos, button );
63+
public void mouseClicked(final int xPos, final int yPos, final int button) {
64+
super.mouseClicked(xPos, yPos, button);
6765

68-
final boolean requiresFocus = this.isMouseIn( xPos, yPos );
66+
final boolean requiresFocus = this.isMouseIn(xPos, yPos);
6967

70-
this.setFocused( requiresFocus );
68+
this.setFocused(requiresFocus);
7169
}
7270

7371
/**
@@ -77,11 +75,40 @@ public void mouseClicked( final int xPos, final int yPos, final int button )
7775
* @param yCoord current y coord of the mouse
7876
* @return true if mouse position is within the text field area
7977
*/
80-
public boolean isMouseIn( final int xCoord, final int yCoord )
81-
{
78+
public boolean isMouseIn(final int xCoord, final int yCoord) {
8279
final boolean withinXRange = this._xPos <= xCoord && xCoord < this._xPos + this._width;
8380
final boolean withinYRange = this._yPos <= yCoord && yCoord < this._yPos + this._height;
8481

8582
return withinXRange && withinYRange;
8683
}
84+
85+
@Override
86+
public String getMessage() {
87+
return tooltip;
88+
}
89+
90+
public void setMessage(String tooltip)
91+
{
92+
this.tooltip = tooltip;
93+
}
94+
95+
@Override
96+
public int xPos() {
97+
return this._xPos;
98+
}
99+
100+
@Override
101+
public int yPos() {
102+
return this._yPos;
103+
}
104+
105+
@Override
106+
public int getHeight() {
107+
return 22;
108+
}
109+
110+
@Override
111+
public boolean isVisible() {
112+
return getVisible();
113+
}
87114
}

src/main/java/appeng/core/AEConfig.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public final class AEConfig extends Configuration implements IConfigurableObject
7979
public boolean enableEffects = true;
8080
public boolean useLargeFonts = false;
8181
public boolean useColoredCraftingStatus;
82+
public boolean preserveSearchBar = true;
8283
public int wirelessTerminalBattery = 1600000;
8384
public int entropyManipulatorBattery = 200000;
8485
public int matterCannonBattery = 200000;
@@ -224,7 +225,7 @@ private void clientSync()
224225
this.enableEffects = this.get( "Client", "enableEffects", true ).getBoolean( true );
225226
this.useLargeFonts = this.get( "Client", "useTerminalUseLargeFont", false ).getBoolean( false );
226227
this.useColoredCraftingStatus = this.get( "Client", "useColoredCraftingStatus", true ).getBoolean( true );
227-
228+
this.preserveSearchBar = this.get( "Client", "preserveSearchBar", true ).getBoolean( true );
228229
// load buttons..
229230
for( int btnNum = 0; btnNum < 4; btnNum++ )
230231
{

src/main/java/appeng/core/localization/ButtonToolTips.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public enum ButtonToolTips
6262
BlockPlacement, BlockPlacementYes, BlockPlacementNo,
6363

6464
// Used in the tooltips of the items in the terminal, when moused over
65-
ItemsStored, ItemsRequestable, P2PFrequency,
65+
ItemsStored, ItemsRequestable, P2PFrequency, SearchStringTooltip,
6666

6767
SchedulingMode, SchedulingModeDefault, SchedulingModeRoundRobin, SchedulingModeRandom, OreFilter, OreFilterHint;
6868

src/main/resources/assets/appliedenergistics2/lang/en_US.lang

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ gui.tooltips.appliedenergistics2.ItemsRequestable=Items Requestable: %s
333333
gui.tooltips.appliedenergistics2.P2PFrequency=Frequency: %s
334334
gui.tooltips.appliedenergistics2.OreFilterHint=Filter items using ore dictionary names
335335
gui.tooltips.appliedenergistics2.OreFilter=Ore Dictionary Filter
336-
336+
gui.tooltips.appliedenergistics2.SearchStringTooltip=Right click to clear the search bar
337337
# Units
338338
gui.appliedenergistics2.units.appliedenergstics=AE
339339
gui.appliedenergistics2.units.ic2=Energy Units

0 commit comments

Comments
 (0)