Skip to content

Commit

Permalink
Merge pull request #53 from repo-alt/rv3-1.7.10
Browse files Browse the repository at this point in the history
Added client config to not preserve the search string in terminals
  • Loading branch information
Dream-Master authored Jun 27, 2021
2 parents 308c855 + 1fa55f6 commit 211a140
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 34 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
aeversion=rv3
aechannel=beta
aebuild=48-GTNH
aebuild=49-GTNH
#KEEP V6 FOR MOD SUPPORT
aegroup=appeng
aebasename=appliedenergistics2
Expand Down
36 changes: 20 additions & 16 deletions src/main/java/appeng/client/gui/AEBaseGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,25 +146,29 @@ public void drawScreen( final int mouseX, final int mouseY, final float btn )
{
if( c instanceof ITooltip )
{
final ITooltip tooltip = (ITooltip) c;
final int x = tooltip.xPos(); // ((GuiImgButton) c).xPosition;
int y = tooltip.yPos(); // ((GuiImgButton) c).yPosition;
handleTooltip(mouseX, mouseY, (ITooltip) c);
}
}
}

protected void handleTooltip(int mouseX, int mouseY, ITooltip c) {
final ITooltip tooltip = c;
final int x = tooltip.xPos(); // ((GuiImgButton) c).xPosition;
int y = tooltip.yPos(); // ((GuiImgButton) c).yPosition;

if( x < mouseX && x + tooltip.getWidth() > mouseX && tooltip.isVisible() )
if( x < mouseX && x + tooltip.getWidth() > mouseX && tooltip.isVisible() )
{
if( y < mouseY && y + tooltip.getHeight() > mouseY)
{
if( y < 15 )
{
if( y < mouseY && y + tooltip.getHeight() > mouseY )
{
if( y < 15 )
{
y = 15;
}
y = 15;
}

final String msg = tooltip.getMessage();
if( msg != null )
{
this.drawTooltip( x + 11, y + 4, 0, msg );
}
}
final String msg = tooltip.getMessage();
if( msg != null )
{
this.drawTooltip( x + 11, y + 4, 0, msg );
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.ButtonToolTips;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
Expand Down Expand Up @@ -304,6 +305,7 @@ public void initGui()
this.searchField.setMaxStringLength( 25 );
this.searchField.setTextColor( 0xFFFFFF );
this.searchField.setVisible( true );
searchField.setMessage(ButtonToolTips.SearchStringTooltip.getLocal());

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

this.searchField.setText( memoryText );
this.repo.setSearchString( memoryText );
if (AEConfig.instance.preserveSearchBar || this.isSubGui())
{
this.searchField.setText(memoryText);
this.repo.setSearchString(memoryText);
}
if( this.isSubGui() )
{
this.repo.updateView();
Expand Down Expand Up @@ -551,4 +556,10 @@ void setStandardSize( final int standardSize )
{
this.standardSize = standardSize;
}
@Override
public void drawScreen( final int mouseX, final int mouseY, final float btn ) {
super.drawScreen(mouseX, mouseY, btn);
if (AEConfig.instance.preserveSearchBar)
handleTooltip(mouseX, mouseY, searchField);
}
}
51 changes: 39 additions & 12 deletions src/main/java/appeng/client/gui/widgets/MEGuiTextField.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
* <p>
* The rendering does pay attention to the size of the '_' caret.
*/
public class MEGuiTextField extends GuiTextField
{
public class MEGuiTextField extends GuiTextField implements ITooltip {
private static final int PADDING = 2;
private String tooltip;

private final int _xPos;
private final int _yPos;
Expand All @@ -50,9 +50,8 @@ public class MEGuiTextField extends GuiTextField
* @param width absolute width
* @param height absolute height
*/
public MEGuiTextField( final FontRenderer fontRenderer, final int xPos, final int yPos, final int width, final int height )
{
super( fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - fontRenderer.getCharWidth( '_' ), height - 2 * PADDING );
public MEGuiTextField(final FontRenderer fontRenderer, final int xPos, final int yPos, final int width, final int height) {
super(fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - fontRenderer.getCharWidth('_'), height - 2 * PADDING);

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

@Override
public void mouseClicked( final int xPos, final int yPos, final int button )
{
super.mouseClicked( xPos, yPos, button );
public void mouseClicked(final int xPos, final int yPos, final int button) {
super.mouseClicked(xPos, yPos, button);

final boolean requiresFocus = this.isMouseIn( xPos, yPos );
final boolean requiresFocus = this.isMouseIn(xPos, yPos);

this.setFocused( requiresFocus );
this.setFocused(requiresFocus);
}

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

return withinXRange && withinYRange;
}

@Override
public String getMessage() {
return tooltip;
}

public void setMessage(String tooltip)
{
this.tooltip = tooltip;
}

@Override
public int xPos() {
return this._xPos;
}

@Override
public int yPos() {
return this._yPos;
}

@Override
public int getHeight() {
return 22;
}

@Override
public boolean isVisible() {
return getVisible();
}
}
3 changes: 2 additions & 1 deletion src/main/java/appeng/core/AEConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public final class AEConfig extends Configuration implements IConfigurableObject
public boolean enableEffects = true;
public boolean useLargeFonts = false;
public boolean useColoredCraftingStatus;
public boolean preserveSearchBar = true;
public int wirelessTerminalBattery = 1600000;
public int entropyManipulatorBattery = 200000;
public int matterCannonBattery = 200000;
Expand Down Expand Up @@ -224,7 +225,7 @@ private void clientSync()
this.enableEffects = this.get( "Client", "enableEffects", true ).getBoolean( true );
this.useLargeFonts = this.get( "Client", "useTerminalUseLargeFont", false ).getBoolean( false );
this.useColoredCraftingStatus = this.get( "Client", "useColoredCraftingStatus", true ).getBoolean( true );

this.preserveSearchBar = this.get( "Client", "preserveSearchBar", true ).getBoolean( true );
// load buttons..
for( int btnNum = 0; btnNum < 4; btnNum++ )
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/appeng/core/localization/ButtonToolTips.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public enum ButtonToolTips
BlockPlacement, BlockPlacementYes, BlockPlacementNo,

// Used in the tooltips of the items in the terminal, when moused over
ItemsStored, ItemsRequestable, P2PFrequency,
ItemsStored, ItemsRequestable, P2PFrequency, SearchStringTooltip,

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ gui.tooltips.appliedenergistics2.ItemsRequestable=Items Requestable: %s
gui.tooltips.appliedenergistics2.P2PFrequency=Frequency: %s
gui.tooltips.appliedenergistics2.OreFilterHint=Filter items using ore dictionary names
gui.tooltips.appliedenergistics2.OreFilter=Ore Dictionary Filter

gui.tooltips.appliedenergistics2.SearchStringTooltip=Right click to clear the search bar
# Units
gui.appliedenergistics2.units.appliedenergstics=AE
gui.appliedenergistics2.units.ic2=Energy Units
Expand Down

0 comments on commit 211a140

Please sign in to comment.