aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java26
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Toolbar.java9
2 files changed, 32 insertions, 3 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..88e7a205 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;
@@ -84,8 +85,10 @@ import org.lwjgl.opengl.GL14;
import org.lwjgl.util.vector.Vector2f;
import java.awt.*;
+import java.awt.datatransfer.StringSelection;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
+import java.math.BigDecimal;
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");
@@ -111,7 +116,8 @@ public class NEUOverlay extends Gui {
"notenoughupdates:supersecretassets/lunar.png");
private static final ResourceLocation SEARCH_BAR = new ResourceLocation("notenoughupdates:search_bar.png");
private static final ResourceLocation SEARCH_BAR_GOLD = new ResourceLocation("notenoughupdates:search_bar_gold.png");
- private static final ResourceLocation SEARCH_MODE_BUTTON = new ResourceLocation("notenoughupdates:search_mode_button.png");
+ private static final ResourceLocation SEARCH_MODE_BUTTON = new ResourceLocation(
+ "notenoughupdates:search_mode_button.png");
private final NEUManager manager;
@@ -1059,6 +1065,19 @@ 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());
+ if (NotEnoughUpdates.INSTANCE.config.toolbar.copyToClipboardWhenGettingResult) {
+ Toolkit.getDefaultToolkit().getSystemClipboard()
+ .setContents(new StringSelection(calculate.toPlainString()), null);
+
+ }
+ } catch (Calculator.CalculatorException | IllegalStateException | HeadlessException ignored) {
+ }
+ }
+
if (searchBarHasFocus) {
if (keyPressed == 1) {
searchBarHasFocus = false;
@@ -1150,7 +1169,8 @@ public class NEUOverlay extends Gui {
} else if (keyPressed == manager.keybindViewRecipe.getKeyCode()) {
manager.showRecipe(item);
return true;
- } else if (keyPressed == NotEnoughUpdates.INSTANCE.config.misc.keybindWaypoint && NotEnoughUpdates.INSTANCE.navigation.isValidWaypoint(item)) {
+ } else if (keyPressed == NotEnoughUpdates.INSTANCE.config.misc.keybindWaypoint &&
+ NotEnoughUpdates.INSTANCE.navigation.isValidWaypoint(item)) {
NotEnoughUpdates.INSTANCE.navigation.trackWaypoint(item);
} else if (keyPressed == manager.keybindGive.getKeyCode()) {
if (Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode) {
@@ -1834,6 +1854,7 @@ public class NEUOverlay extends Gui {
int guiScaleLast = 0;
private boolean showVanillaLast = false;
+
/**
* Renders the search bar, quick commands, item selection (right), item info (left) and armor hud gui elements.
*/
@@ -2256,7 +2277,6 @@ public class NEUOverlay extends Gui {
}
}
-
/**
* Used in SettingsInfoPane to redraw the items when a setting changes.
*/
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Toolbar.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Toolbar.java
index d8fe91d5..c7ff3f70 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Toolbar.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Toolbar.java
@@ -82,6 +82,15 @@ public class Toolbar {
@Expose
@ConfigOption(
+ name = "Copy calculation result to clipboard",
+ desc = "Copy the calculation result to clipboard when pressing ENTER in the search bar while calculating"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean copyToClipboardWhenGettingResult = true;
+
+ @Expose
+ @ConfigOption(
name = "Search Bar Width",
desc = "Change the width of the search bar"
)