aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-09-02 15:02:39 +0200
committernea <nea@nea.moe>2023-09-02 15:02:39 +0200
commitab634fd6abb69f62f1ca364ff479b4ab83cf949b (patch)
treee1f840a363af692949fe40886372dacc4e25d96c
parentce52a805da551f4cef1b14beab58821887e349b9 (diff)
downloadNotEnoughUpdates-ab634fd6abb69f62f1ca364ff479b4ab83cf949b.tar.gz
NotEnoughUpdates-ab634fd6abb69f62f1ca364ff479b4ab83cf949b.tar.bz2
NotEnoughUpdates-ab634fd6abb69f62f1ca364ff479b4ab83cf949b.zip
Replace calculation with result in search bar on return press
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
index f7f0049f..d0947539 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
@@ -39,6 +39,7 @@ import io.github.moulberry.notenoughupdates.miscfeatures.SunTzu;
import io.github.moulberry.notenoughupdates.miscgui.NeuSearchCalculator;
import io.github.moulberry.notenoughupdates.miscgui.pricegraph.GuiPriceGraph;
import io.github.moulberry.notenoughupdates.options.NEUConfigEditor;
+import io.github.moulberry.notenoughupdates.util.Calculator;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.GuiTextures;
import io.github.moulberry.notenoughupdates.util.LerpingFloat;
@@ -86,6 +87,8 @@ import org.lwjgl.util.vector.Vector2f;
import java.awt.*;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
@@ -103,6 +106,8 @@ import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
+import static io.github.moulberry.notenoughupdates.miscgui.NeuSearchCalculator.PROVIDE_LOWEST_BIN;
+
public class NEUOverlay extends Gui {
private static final ResourceLocation SUPERGEHEIMNISVERMOGEN = new ResourceLocation(
"notenoughupdates:supersecretassets/bald.png");
@@ -1059,6 +1064,14 @@ public class NEUOverlay extends Gui {
return true;
}
+ if (Keyboard.getEventKey() == Keyboard.KEY_RETURN && searchBarHasFocus) {
+ try {
+ BigDecimal calculate = Calculator.calculate(textField.getText(), PROVIDE_LOWEST_BIN);
+ textField.setText(calculate.toPlainString());
+ } catch (Calculator.CalculatorException ignored) {
+ }
+ }
+
if (searchBarHasFocus) {
if (keyPressed == 1) {
searchBarHasFocus = false;