aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLulonaut <lulonaut@tutanota.de>2021-09-30 15:55:14 +0200
committerLulonaut <lulonaut@tutanota.de>2021-09-30 15:55:14 +0200
commit215e4a84802b9e02078ff0938cb1651bda673bc3 (patch)
treea9be5698d28537a08fa64e8934450d96439d3069 /src
parente598793adf941238928b69b0d7bcdb5a5e9c3a9c (diff)
downloadNotEnoughUpdates-215e4a84802b9e02078ff0938cb1651bda673bc3.tar.gz
NotEnoughUpdates-215e4a84802b9e02078ff0938cb1651bda673bc3.tar.bz2
NotEnoughUpdates-215e4a84802b9e02078ff0938cb1651bda673bc3.zip
highlight selected item with texture
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java35
-rw-r--r--src/main/resources/assets/notenoughupdates/auc_search/ah_search_overlay_tab_completed.pngbin0 -> 6969 bytes
2 files changed, 22 insertions, 13 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java
index e900321d..016e638b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java
@@ -32,6 +32,7 @@ import java.util.concurrent.atomic.AtomicInteger;
public class AuctionSearchOverlay {
private static final ResourceLocation SEARCH_OVERLAY_TEXTURE = new ResourceLocation("notenoughupdates:auc_search/ah_search_overlay.png");
+ private static final ResourceLocation SEARCH_OVERLAY_TEXTURE_TAB_COMPLETED = new ResourceLocation("notenoughupdates:auc_search/ah_search_overlay_tab_completed.png");
private static final ResourceLocation STAR = new ResourceLocation("notenoughupdates:auc_search/star.png");
private static final ResourceLocation STAR_BOARD = new ResourceLocation("notenoughupdates:auc_search/star_board.png");
@@ -41,7 +42,7 @@ public class AuctionSearchOverlay {
private static String searchStringExtra = "";
private static Splitter SPACE_SPLITTER = Splitter.on(" ").omitEmptyStrings().trimResults();
private static boolean tabCompleted = false;
- private static int tabCompletionIndex = 0;
+ private static int tabCompletionIndex = -1;
private static int selectedStars = 0;
private static boolean atLeast = true;
@@ -148,24 +149,31 @@ public class AuctionSearchOverlay {
int num = 0;
synchronized(autocompletedItems) {
- for(String str : autocompletedItems) {
+ String[] autoCompletedItemsArray = autocompletedItems.toArray(new String[0]);
+ for (int i = 0; i < autocompletedItems.size(); i++) {
+ String str = autoCompletedItemsArray[i];
JsonObject obj = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(str);
- if(obj != null) {
+ if (obj != null) {
ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(obj);
//Gui.drawRect(width/2-96, height/4+30+num*22, width/2+96, height/4+30+num*22+20, 0xff505050);
+ if (i == tabCompletionIndex) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_OVERLAY_TEXTURE_TAB_COMPLETED);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(width / 2 - 96 + 1, topY + 30 + num * 22 + 1, 193, 21, 0 / 512f, 193 / 512f, 0, 21 / 256f, GL11.GL_NEAREST);
+ } else {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_OVERLAY_TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(width / 2 - 96 + 1, topY + 30 + num * 22 + 1, 193, 21, 214 / 512f, 407 / 512f, 0, 21 / 256f, GL11.GL_NEAREST);
- Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_OVERLAY_TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(width/2-96+1, topY+30+num*22+1, 193, 21, 214/512f, 407/512f, 0, 21/256f, GL11.GL_NEAREST);
-
+ }
String itemName = Utils.trimIgnoreColour(stack.getDisplayName().replaceAll("\\[.+]", ""));
- if(itemName.contains("Enchanted Book") && str.contains(";")) {
+ if (itemName.contains("Enchanted Book") && str.contains(";")) {
String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
itemName = lore[0].trim();
}
Minecraft.getMinecraft().fontRendererObj.drawString(Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(itemName, 165),
- width/2-74, topY+35+num*22+1, 0xdddddd, true);
+ width / 2 - 74, topY + 35 + num * 22 + 1, 0xdddddd, true);
GlStateManager.enableDepth();
Utils.drawItemStack(stack, width/2-94+2, topY+32+num*22+1);
@@ -277,7 +285,7 @@ public class AuctionSearchOverlay {
private static String getItemIdAtIndex(int i) {
if (!autocompletedItems.isEmpty()) {
- if ((i > autocompletedItems.size() - 1) || i < 0) {
+ if ((i > autocompletedItems.size() - 1) || i < 0 || i > 4) {
return "";
}
String searchString = autocompletedItems.toArray()[i].toString();
@@ -365,6 +373,7 @@ public class AuctionSearchOverlay {
textField.setFocus(true);
textField.setText(searchString);
} else {
+ tabCompletionIndex = 0;
searchString = id;
}
} else if(Keyboard.getEventKeyState()) {
@@ -377,7 +386,7 @@ public class AuctionSearchOverlay {
textField.setFocus(true);
textField.setText(searchString);
tabCompleted = false;
- tabCompletionIndex = 0;
+ tabCompletionIndex = -1;
} else if (id.equals("")) {
//At the end of the autocompletion List, do nothing
return;
@@ -393,7 +402,7 @@ public class AuctionSearchOverlay {
textField.setFocus(true);
textField.setText(searchString);
tabCompleted = false;
- tabCompletionIndex = 0;
+ tabCompletionIndex = -1;
} else if (id.equals("")) {
//At the end of the autocompletion List, do nothing
return;
@@ -404,7 +413,7 @@ public class AuctionSearchOverlay {
}
break;
default:
- tabCompletionIndex = 0;
+ tabCompletionIndex = -1;
tabCompleted = false;
}
}
diff --git a/src/main/resources/assets/notenoughupdates/auc_search/ah_search_overlay_tab_completed.png b/src/main/resources/assets/notenoughupdates/auc_search/ah_search_overlay_tab_completed.png
new file mode 100644
index 00000000..b5cf62c0
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/auc_search/ah_search_overlay_tab_completed.png
Binary files differ