aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
diff options
context:
space:
mode:
authorBuildTools <james.jenour@protonmail.com>2020-07-08 16:28:49 +1000
committerBuildTools <james.jenour@protonmail.com>2020-07-08 16:28:49 +1000
commit7bdf7f256fe3968fe7129928c0a7100c30628bf9 (patch)
tree222deed2be57223e3b1703a638843fbf21a254e7 /src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
parentf39c28236bc47a9e5395b041b494fdd7f332734e (diff)
downloadnotenoughupdates-7bdf7f256fe3968fe7129928c0a7100c30628bf9.tar.gz
notenoughupdates-7bdf7f256fe3968fe7129928c0a7100c30628bf9.tar.bz2
notenoughupdates-7bdf7f256fe3968fe7129928c0a7100c30628bf9.zip
1.9.7
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java846
1 files changed, 634 insertions, 212 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
index 0cc17afe..aad82b9f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
@@ -17,6 +17,7 @@ import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
+import net.minecraft.inventory.ContainerChest;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -31,9 +32,12 @@ import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
import java.awt.*;
+import java.awt.datatransfer.StringSelection;
import java.text.NumberFormat;
import java.util.*;
import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import static io.github.moulberry.notenoughupdates.GuiTextures.*;
@@ -44,11 +48,18 @@ public class CustomAH extends Gui {
private static final ResourceLocation creativeInventoryTabs =
new ResourceLocation("textures/gui/container/creative_inventory/tabs.png");
- private List<String> auctionIds = new ArrayList<>();
+ private HashSet<String> auctionIds = new HashSet<>();
+ private List<String> sortedAuctionIds = new ArrayList<>();
private boolean scrollClicked = false;
+ private long lastUpdateSearch;
+ private long lastSearchFieldUpdate;
+ private boolean shouldUpdateSearch = false;
+ private boolean shouldSortItems = false;
+
private int startingBid = 0;
+ private String currentAucId = null;
private int clickedMainCategory = -1;
private int clickedSubCategory = -1;
@@ -59,6 +70,9 @@ public class CustomAH extends Gui {
private boolean renderOverAuctionView = false;
private long lastRenderDisable = 0;
+ private long currAucIdSetTimer = 0;
+ private long resetCurrAucIdTimer = 0;
+
private int eventButton;
private long lastMouseEvent;
public long lastOpen;
@@ -96,7 +110,7 @@ public class CustomAH extends Gui {
private Category CATEGORY_COMBAT = new Category("weapon", "Combat", "golden_sword", CATEGORY_SWORD,
CATEGORY_BOWS, CATEGORY_ARMOR, CATEGORY_ACCESSORIES);
- private Category CATEGORY_TOOL = new Category("", "Tools", "iron_pickaxe", CATEGORY_FISHING_ROD, CATEGORY_PICKAXE,
+ private Category CATEGORY_TOOL = new Category("", "Tools", "diamond_pickaxe", CATEGORY_FISHING_ROD, CATEGORY_PICKAXE,
CATEGORY_AXE, CATEGORY_SHOVEL);
private Category CATEGORY_PET = new Category("pet", "Pets", "bone", CATEGORY_PET_ITEM);
private Category CATEGORY_CONSUMABLES = new Category("consumables", "Consumables", "apple", CATEGORY_EBOOKS, CATEGORY_POTIONS,
@@ -114,15 +128,25 @@ public class CustomAH extends Gui {
private static final String[] rarities = { "COMMON", "UNCOMMON", "RARE", "EPIC",
"LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL" };
+ private static final String[] rarityColours = { ""+EnumChatFormatting.WHITE,
+ ""+EnumChatFormatting.GREEN, ""+EnumChatFormatting.BLUE, ""+EnumChatFormatting.DARK_PURPLE,
+ ""+EnumChatFormatting.GOLD, ""+EnumChatFormatting.LIGHT_PURPLE, ""+EnumChatFormatting.RED,
+ ""+EnumChatFormatting.RED };
private static final int BIN_FILTER_ALL = 0;
private static final int BIN_FILTER_BIN = 1;
private static final int BIN_FILTER_AUC = 2;
+ private static final int ENCH_FILTER_ALL = 0;
+ private static final int ENCH_FILTER_CLEAN = 1;
+ private static final int ENCH_FILTER_ENCH = 2;
+ private static final int ENCH_FILTER_ENCHHPB = 3;
+
private int sortMode = SORT_MODE_HIGH;
private int rarityFilter = -1;
private boolean filterMyAuctions = false;
private int binFilter = BIN_FILTER_ALL;
+ private int enchFilter = ENCH_FILTER_ALL;
private static ItemStack CONTROL_SORT = Utils.createItemStack(Item.getItemFromBlock(Blocks.hopper),
EnumChatFormatting.GREEN+"Sort");
@@ -132,7 +156,11 @@ public class CustomAH extends Gui {
EnumChatFormatting.GREEN+"My Auctions");
private static ItemStack CONTROL_BIN = Utils.createItemStack(Item.getItemFromBlock(Blocks.golden_rail),
EnumChatFormatting.GREEN+"BIN Filter");
- private ItemStack[] controls = {null,CONTROL_SORT,CONTROL_TIER,null,CONTROL_MYAUC,null,CONTROL_BIN,null,null};
+ private static ItemStack CONTROL_ENCH = Utils.createItemStack(Items.enchanted_book,
+ EnumChatFormatting.GREEN+"Enchant Filter");
+ private static ItemStack CONTROL_STATS = Utils.createItemStack(Item.getItemFromBlock(Blocks.command_block),
+ EnumChatFormatting.GREEN+"Stats for nerds");
+ private ItemStack[] controls = {null,CONTROL_SORT,CONTROL_TIER,null,CONTROL_MYAUC,null,CONTROL_BIN,CONTROL_ENCH,CONTROL_STATS};
private NEUManager manager;
@@ -141,17 +169,28 @@ public class CustomAH extends Gui {
}
public void clearSearch() {
+ if(searchField == null || priceField == null) init();
if(System.currentTimeMillis() - lastOpen < 1000) Mouse.setGrabbed(false);
- sortMode = SORT_MODE_HIGH;
+ //sortMode = SORT_MODE_HIGH;
rarityFilter = -1;
filterMyAuctions = false;
- binFilter = BIN_FILTER_ALL;
+ //binFilter = BIN_FILTER_ALL;
+ enchFilter = ENCH_FILTER_ALL;
searchField.setText("");
+ searchField.setFocused(true);
priceField.setText("");
}
+ public void tick() {
+ if(shouldUpdateSearch) updateSearch();
+ if(shouldSortItems) {
+ sortItems();
+ shouldSortItems = false;
+ }
+ }
+
public class Category {
public String categoryMatch;
public Category[] subcategories;
@@ -179,15 +218,15 @@ public class CustomAH extends Gui {
private void init() {
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
this.searchField = new GuiTextField(0, fr, this.guiLeft + 82, this.guiTop + 6,
- 89, fr.FONT_HEIGHT);
+ 84, fr.FONT_HEIGHT);
this.priceField = new GuiTextField(1, fr, this.guiLeft + 82, this.guiTop + 6,
- 89, fr.FONT_HEIGHT);
+ 84, fr.FONT_HEIGHT);
- this.searchField.setMaxStringLength(15);
+ this.searchField.setMaxStringLength(30);
this.searchField.setEnableBackgroundDrawing(false);
this.searchField.setTextColor(16777215);
this.searchField.setVisible(true);
- this.searchField.setCanLoseFocus(false);
+ this.searchField.setCanLoseFocus(true);
this.searchField.setFocused(true);
this.searchField.setText("");
@@ -195,7 +234,7 @@ public class CustomAH extends Gui {
this.priceField.setEnableBackgroundDrawing(false);
this.priceField.setTextColor(16777215);
this.priceField.setVisible(true);
- this.priceField.setCanLoseFocus(false);
+ this.priceField.setCanLoseFocus(true);
this.priceField.setFocused(false);
this.priceField.setText("");
}
@@ -217,26 +256,14 @@ public class CustomAH extends Gui {
return 136 + ySplitSize*splits;
}
- private TexLoc tl = new TexLoc(0, 0, Keyboard.KEY_M);
-
- public List<String> getTooltipForAucId(String aucId) {
- AuctionManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucId);
-
- List<String> tooltip = new ArrayList<>();
-
- for(String line : auc.getStack().getTooltip(Minecraft.getMinecraft().thePlayer, false)) {
- tooltip.add(EnumChatFormatting.GRAY+line);
- }
+ private String prettyTime(long millis) {
+ long seconds = millis / 1000 % 60;
+ long minutes = (millis / 1000 / 60) % 60;
+ long hours = (millis / 1000 / 60 / 60) % 24;
+ long days = (millis / 1000 / 60 / 60 / 24);
- long timeUntilEnd = auc.end - System.currentTimeMillis();
-
- long seconds = timeUntilEnd / 1000 % 60;
- long minutes = (timeUntilEnd / 1000 / 60) % 60;
- long hours = (timeUntilEnd / 1000 / 60 / 60) % 24;
- long days = (timeUntilEnd / 1000 / 60 / 60 / 24);
-
- String endsIn = EnumChatFormatting.YELLOW+"";
- if(timeUntilEnd < 0) {
+ String endsIn = "";
+ if(millis < 0) {
endsIn += "Ended!";
} else if(minutes == 0 && hours == 0 && days == 0) {
endsIn += seconds + "s";
@@ -252,6 +279,21 @@ public class CustomAH extends Gui {
endsIn += days + "d" + hours + "h";
}
+ return endsIn;
+ }
+
+ public List<String> getTooltipForAucId(String aucId) {
+ AuctionManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucId);
+
+ List<String> tooltip = new ArrayList<>();
+
+ for(String line : auc.getStack().getTooltip(Minecraft.getMinecraft().thePlayer, false)) {
+ tooltip.add(EnumChatFormatting.GRAY+line);
+ }
+
+ long timeUntilEnd = auc.end - System.currentTimeMillis();
+ String endsIn = EnumChatFormatting.YELLOW+prettyTime(timeUntilEnd);
+
NumberFormat format = NumberFormat.getInstance(Locale.US);
tooltip.add(EnumChatFormatting.DARK_GRAY+""+EnumChatFormatting.STRIKETHROUGH+"-----------------");
@@ -293,7 +335,7 @@ public class CustomAH extends Gui {
boolean clicked = i == clickedSubCategory;
int x = guiLeft-28;
- int y = guiTop+17+28*i;
+ int y = guiTop+17+28*(i+1);
float uMin = 28/256f;
float uMax = 56/256f;
float vMin = 0+(clicked?32/256f:0);
@@ -328,6 +370,53 @@ public class CustomAH extends Gui {
GlStateManager.disableBlend();
}
+ private HashMap<Pattern, Long> timeParseMap = new HashMap<>();
+ public long prettyTimeToMillis(String endsInStr) {
+ if(timeParseMap.isEmpty()) {
+ Pattern dayPattern = Pattern.compile("([0-9]+)d");
+ Pattern hourPattern = Pattern.compile("([0-9]+)h");
+ Pattern minutePattern = Pattern.compile("([0-9]+)m");
+ Pattern secondPattern = Pattern.compile("([0-9]+)s");
+
+ timeParseMap.put(dayPattern, 24*60*60*1000L);
+ timeParseMap.put(hourPattern, 60*60*1000L);
+ timeParseMap.put(minutePattern, 60*1000L);
+ timeParseMap.put(secondPattern, 1000L);
+ }
+
+ if(endsInStr != null) {
+ long timeUntilEnd = 0;
+
+ String timeStr = Utils.cleanColour(endsInStr);
+
+ for(Map.Entry<Pattern, Long> timeEntry : timeParseMap.entrySet()) {
+ Matcher matcher = timeEntry.getKey().matcher(timeStr);
+ if(matcher.find()) {
+ String days = matcher.group(1);
+ timeUntilEnd += Long.parseLong(days) * timeEntry.getValue();
+ }
+ }
+
+ return timeUntilEnd;
+ }
+
+ return -1;
+ }
+
+ public String findEndsInStr(ItemStack stack) {
+ if(stack.hasTagCompound()) {
+ //ยง7Ends in:
+ String endsIn = EnumChatFormatting.GRAY+"Ends in: ";
+ for(String line : manager.getLoreFromNBT(stack.getTagCompound())) {
+ if(line.trim().startsWith(endsIn)) {
+ return line.substring(endsIn.length());
+ }
+ }
+ }
+
+ return null;
+ }
+
public void drawScreen(int mouseX, int mouseY) {
if(System.currentTimeMillis() - lastOpen < 1000) Mouse.setGrabbed(false);
@@ -335,96 +424,158 @@ public class CustomAH extends Gui {
int width = scaledResolution.getScaledWidth();
int height = scaledResolution.getScaledHeight();
- //Dark background
- drawGradientRect(0, 0, width, height, -1072689136, -804253680);
-
if(searchField == null || priceField == null) init();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- tl.handleKeyboardInput();
-
guiLeft = (width - getXSize())/2;
guiTop = (height - getYSize())/2;
this.searchField.xPosition = guiLeft + 82;
this.searchField.yPosition = guiTop + 6;
- this.searchField.setFocused(true);
- this.priceField.setFocused(false);
-
if(!isEditingPrice()) priceField.setText("IAUSHDIUAH");
+ if((Minecraft.getMinecraft().currentScreen instanceof GuiChest ||
+ Minecraft.getMinecraft().currentScreen instanceof GuiEditSign) && currentAucId == null) {
+ Minecraft.getMinecraft().displayGuiScreen(null);
+ }
+
List<String> tooltipToRender = null;
if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ resetCurrAucIdTimer = System.currentTimeMillis();
GuiChest auctionView = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest container = (ContainerChest) auctionView.inventorySlots;
+ String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText();
float slideAmount = 1-Math.max(0, Math.min(1, (System.currentTimeMillis() - lastGuiScreenSwitch)/200f));
int auctionViewLeft = guiLeft+getXSize()+4 - (int)(slideAmount*(78+4));
- Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view);
- this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 78, 172);
+ if(containerName.trim().equals("Auction View") || containerName.trim().equals("BIN Auction View")) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view);
+ this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 78, 172);
- if(auctionViewLeft+31 > guiLeft+getXSize()) {
- try {
- ItemStack topStack = auctionView.inventorySlots.getSlot(13).getStack();
- ItemStack leftStack = auctionView.inventorySlots.getSlot(29).getStack();
- ItemStack middleStack = auctionView.inventorySlots.getSlot(31).getStack();
- ItemStack rightStack = auctionView.inventorySlots.getSlot(33).getStack();
+ if(auctionViewLeft+31 > guiLeft+getXSize()) {
+ try {
+ ItemStack topStack = auctionView.inventorySlots.getSlot(13).getStack();
+ ItemStack leftStack = auctionView.inventorySlots.getSlot(29).getStack();
+ ItemStack middleStack = auctionView.inventorySlots.getSlot(31).getStack();
+ ItemStack rightStack = auctionView.inventorySlots.getSlot(33).getStack();
- boolean isBin = isGuiFiller(leftStack) || isGuiFiller(leftStack);
+ boolean isBin = isGuiFiller(leftStack) || isGuiFiller(leftStack);
- if(isBin) {
- leftStack = middleStack;
- middleStack = null;
- }
- Utils.drawItemStack(leftStack, auctionViewLeft+31, guiTop+100);
-
- if(!isGuiFiller(leftStack)) {
- NBTTagCompound tag = leftStack.getTagCompound();
- NBTTagCompound display = tag.getCompoundTag("display");
- if (display.hasKey("Lore", 9)) {
- NBTTagList list = display.getTagList("Lore", 8);
- String line2 = list.getStringTagAt(1);
- line2 = Utils.cleanColour(line2);
- StringBuilder priceNumbers = new StringBuilder();
- for(int i=0; i<line2.length(); i++) {
- char c = line2.charAt(i);
- if((int)c >= 48 && (int)c <= 57) {
- priceNumbers.append(c);
+ if(isBin) {
+ leftStack = middleStack;
+ middleStack = null;
+ }
+
+ String endsInStr = findEndsInStr(topStack);
+ if(endsInStr != null) {
+ long auctionViewEndsIn = prettyTimeToMillis(endsInStr);
+ if(auctionViewEndsIn > 0) {
+ if(System.currentTimeMillis() - currAucIdSetTimer > 1000) {
+ AuctionManager.Auction auc = manager.auctionManager.getAuctionItems().get(currentAucId);
+ if(auc != null) {
+ auc.end = auctionViewEndsIn + lastGuiScreenSwitch;
+ }
}
+ endsInStr = EnumChatFormatting.DARK_PURPLE+prettyTime(
+ auctionViewEndsIn + lastGuiScreenSwitch - System.currentTimeMillis());
}
- if(priceNumbers.length() > 0) {
- startingBid = Integer.parseInt(priceNumbers.toString());
+ Utils.drawStringCenteredScaledMaxWidth(endsInStr, Minecraft.getMinecraft().fontRendererObj,
+ auctionViewLeft+39, guiTop+20, false, 70, 4210752);
+ }
+
+ Utils.drawItemStack(leftStack, auctionViewLeft+31, guiTop+100);
+
+ if(!isGuiFiller(leftStack)) {
+ NBTTagCompound tag = leftStack.getTagCompound();
+ NBTTagCompound display = tag.getCompoundTag("display");
+ if (display.hasKey("Lore", 9)) {
+ NBTTagList list = display.getTagList("Lore", 8);
+ String line2 = list.getStringTagAt(1);
+ line2 = Utils.cleanColour(line2);
+ StringBuilder priceNumbers = new StringBuilder();
+ for(int i=0; i<line2.length(); i++) {
+ char c = line2.charAt(i);
+ if((int)c >= 48 && (int)c <= 57) {
+ priceNumbers.append(c);
+ }
+ }
+ if(priceNumbers.length() > 0) {
+ startingBid = Integer.parseInt(priceNumbers.toString());
+ }
}
}
- }
- Utils.drawItemStack(topStack, auctionViewLeft+31, guiTop+35);
+ Utils.drawItemStack(topStack, auctionViewLeft+31, guiTop+35);
- if(!isGuiFiller(middleStack)) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons);
- boolean hover = mouseX > auctionViewLeft+31 && mouseX <auctionViewLeft+31+16 &&
- mouseY > guiTop+126 && mouseY < guiTop+126+16;
- this.drawTexturedModalRect(auctionViewLeft+31, guiTop+126, hover?16:0, 0, 16, 16);
- } else {
- middleStack = null;
+ if(!isGuiFiller(middleStack)) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons);
+ boolean hover = mouseX > auctionViewLeft+31 && mouseX <auctionViewLeft+31+16 &&
+ mouseY > guiTop+126 && mouseY < guiTop+126+16;
+ this.drawTexturedModalRect(auctionViewLeft+31, guiTop+126, hover?16:0, 0, 16, 16);
+ } else {
+ middleStack = null;
+ }
+
+ if(mouseX > auctionViewLeft+31 && mouseX <auctionViewLeft+31+16) {
+ if(mouseY > guiTop+35 && mouseY < guiTop+35+16) {
+ if(topStack != null) tooltipToRender = topStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ } else if(mouseY > guiTop+100 && mouseY < guiTop+100+16) {
+ if(leftStack != null) tooltipToRender = leftStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ } else if(mouseY > guiTop+61 && mouseY < guiTop+61+16) {
+ if(rightStack != null) tooltipToRender = rightStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ } else if(mouseY > guiTop+126 && mouseY < guiTop+126+16) {
+ if(middleStack != null) tooltipToRender = middleStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+ }
+ } catch(NullPointerException e) { //i cant be bothered
}
+ }
+ } else if(containerName.trim().equals("Confirm Bid")) {
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(auction_accept);
+ this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 78, 172);
- if(mouseX > auctionViewLeft+31 && mouseX <auctionViewLeft+31+16) {
- if(mouseY > guiTop+35 && mouseY < guiTop+35+16) {
- if(topStack != null) tooltipToRender = topStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- } else if(mouseY > guiTop+100 && mouseY < guiTop+100+16) {
- if(leftStack != null) tooltipToRender = leftStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- } else if(mouseY > guiTop+61 && mouseY < guiTop+61+16) {
- if(rightStack != null) tooltipToRender = rightStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- } else if(mouseY > guiTop+126 && mouseY < guiTop+126+16) {
- if(middleStack != null) tooltipToRender = middleStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ if(auctionViewLeft+31 > guiLeft+getXSize()) {
+ try {
+ ItemStack leftStack = auctionView.inventorySlots.getSlot(11).getStack();
+ ItemStack middleStack = auctionView.inventorySlots.getSlot(13).getStack();
+ ItemStack rightStack = auctionView.inventorySlots.getSlot(15).getStack();
+
+ Utils.drawItemStack(middleStack, auctionViewLeft+31, guiTop+78);
+
+ boolean topHovered = false;
+ boolean bottomHovered = false;
+
+ if(mouseX > auctionViewLeft+31 && mouseX <auctionViewLeft+31+16) {
+ if(mouseY > guiTop+31 && mouseY < guiTop+31+16) {
+ if(leftStack != null) {
+ topHovered = true;
+ tooltipToRender = leftStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+ } else if(mouseY > guiTop+125 && mouseY < guiTop+125+16) {
+ if(rightStack != null) {
+ bottomHovered = true;
+ tooltipToRender = rightStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+ } else if(mouseY > guiTop+78 && mouseY < guiTop+78+16) {
+ if(middleStack != null) tooltipToRender = middleStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
}
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons);
+ this.drawTexturedModalRect(auctionViewLeft+31, guiTop+31, topHovered?16:0, 48, 16, 16);
+ this.drawTexturedModalRect(auctionViewLeft+31, guiTop+125, bottomHovered?16:0, 64, 16, 16);
+ } catch(NullPointerException blah) { //i cant be bothered
}
- } catch(NullPointerException e) { //i cant be bothered
}
}
+
+ Utils.drawStringCenteredScaledMaxWidth(containerName, Minecraft.getMinecraft().fontRendererObj,
+ auctionViewLeft+39, guiTop+10, false, 70, 4210752);
} else if(isEditingPrice()) {
+ resetCurrAucIdTimer = System.currentTimeMillis();
float slideAmount = 1-Math.max(0, Math.min(1, (System.currentTimeMillis() - lastGuiScreenSwitch)/200f));
int auctionViewLeft = guiLeft+getXSize()+4 - (int)(slideAmount*(96+4));
@@ -439,6 +590,9 @@ public class CustomAH extends Gui {
this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 96, 99);
priceField.drawTextBox();
+ Utils.drawStringCenteredScaledMaxWidth("Bid Amount", Minecraft.getMinecraft().fontRendererObj,
+ auctionViewLeft+39, guiTop+10, false, 70, 4210752);
+
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons);
this.drawTexturedModalRect(auctionViewLeft+16, guiTop+32, 0, 16, 30, 16);
@@ -465,9 +619,25 @@ public class CustomAH extends Gui {
"tileSign", "field_146848_f");
tes.lineBeingEdited = 0;
tes.signText[0] = new ChatComponentText(priceField.getText());
+ } else {
+ if(System.currentTimeMillis() - resetCurrAucIdTimer > 500 &&
+ System.currentTimeMillis() - currAucIdSetTimer > 500) {
+ currentAucId = null;
+ currAucIdSetTimer = System.currentTimeMillis();
+ }
}
Minecraft.getMinecraft().getTextureManager().bindTexture(creativeInventoryTabs);
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ if(mouseY > guiTop-28 && mouseY < guiTop+4) {
+ if(mouseX > guiLeft && mouseX < guiLeft+168) {
+ int offset = mouseX-guiLeft;
+ int hoveredCat = offset/28;
+ if(hoveredCat >= 0 && hoveredCat < mainCategories.length) {
+ tooltipToRender = Utils.createList(mainCategories[hoveredCat].displayName);
+ }
+ }
+ }
if(clickedMainCategory == -1) {
this.drawTexturedModalRect(guiLeft, guiTop-28, 0, 0, 168, 32);
} else {
@@ -475,16 +645,31 @@ public class CustomAH extends Gui {
this.drawTexturedModalRect(guiLeft, guiTop-28, 0, 0, selStart, 32);
this.drawTexturedModalRect(guiLeft+selStart+28, guiTop-28, selStart+28, 0,
168-selStart-28, 32);
+
if(clickedMainCategory >= 0 && clickedMainCategory < mainCategories.length) {
Category mainCategory = mainCategories[clickedMainCategory];
- for(int i=0; i<mainCategory.subcategories.length; i++) {
+ if(mouseX > guiLeft-28 && mouseX < guiLeft) {
+ int offset = mouseY-(guiTop+17);
+ if(offset > 0) {
+ int hovered = offset/28-1;
+ if(hovered < 0) {
+ tooltipToRender = Utils.createList(mainCategory.displayName);
+ } else if(hovered < mainCategory.subcategories.length) {
+ tooltipToRender = Utils.createList(mainCategory.subcategories[hovered].displayName);
+ }
+ }
+ }
+
+ for(int i=-1; i<mainCategory.subcategories.length; i++) {
if(i != clickedSubCategory) drawCategorySide(i);
}
}
}
+ //Main GUI
Minecraft.getMinecraft().getTextureManager().bindTexture(creativeTabSearch);
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, getXSize(), ySplit);
int y = guiTop+ySplit;
for(int i=0; i<splits; i++) {
@@ -493,17 +678,24 @@ public class CustomAH extends Gui {
}
this.drawTexturedModalRect(guiLeft, y, 0, ySplit, getXSize(), 136-ySplit);
+ //GUI Name
+ Utils.drawStringCenteredScaledMaxWidth("Auction House", Minecraft.getMinecraft().fontRendererObj, guiLeft+42,
+ guiTop+10, false, 68, 4210752);
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+
//Categories
Minecraft.getMinecraft().getTextureManager().bindTexture(creativeInventoryTabs);
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
if(clickedMainCategory != -1) {
int selStart = clickedMainCategory*28;
- this.drawTexturedModalRect(guiLeft+selStart, guiTop-28, 28, 32, 28, 32);
+ this.drawTexturedModalRect(guiLeft+selStart, guiTop-28, clickedMainCategory==0?0:28, 32, 28, 32);
if(clickedMainCategory >= 0 && clickedMainCategory < mainCategories.length) {
Category mainCategory = mainCategories[clickedMainCategory];
- if(clickedSubCategory >= 0 && clickedSubCategory < mainCategory.subcategories.length) {
+ if(clickedSubCategory >= -1 && clickedSubCategory < mainCategory.subcategories.length) {
drawCategorySide(clickedSubCategory);
}
}
@@ -517,8 +709,9 @@ public class CustomAH extends Gui {
if(clickedMainCategory >= 0 && clickedMainCategory < mainCategories.length) {
Category mainCategory = mainCategories[clickedMainCategory];
+ Utils.drawItemStack(mainCategory.displayItem, guiLeft-19, guiTop+23);
for(int i=0; i<mainCategory.subcategories.length; i++) {
- Utils.drawItemStack(mainCategory.subcategories[i].displayItem, guiLeft-19, guiTop+23+28*i);
+ Utils.drawItemStack(mainCategory.subcategories[i].displayItem, guiLeft-19, guiTop+23+28*(i+1));
}
}
@@ -546,7 +739,7 @@ public class CustomAH extends Gui {
if(auctionIds.size() <= id) break out;
try {
- String aucid = auctionIds.get(id);
+ String aucid = sortedAuctionIds.get(id);
GL11.glTranslatef(0,0,100);
ItemStack stack = manager.auctionManager.getAuctionItems().get(aucid).getStack();
@@ -568,14 +761,14 @@ public class CustomAH extends Gui {
searchField.drawTextBox();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- if(auctionIds.size() == 0 && searchField.getText().length() == 0) {
+ /*if(auctionIds.size() == 0 && searchField.getText().length() == 0) {
drawRect(guiLeft+8, guiTop+17, guiLeft+170, guiTop+107+18*splits,
new Color(100, 100, 100, 100).getRGB());
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
int strWidth = fr.getStringWidth("Loading items...");
fr.drawString("Loading items...", guiLeft+(8+170-strWidth)/2, guiTop+(17+107+18*splits)/2, Color.BLACK.getRGB());
- }
+ }*/
Minecraft.getMinecraft().getTextureManager().bindTexture(creativeInventoryTabs);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
@@ -594,8 +787,13 @@ public class CustomAH extends Gui {
public List<String> getTooltipForControl(int index) {
List<String> lore = new ArrayList<>();
+ if(index < 0 || index >= controls.length) return lore;
+ if(controls[index] == null) return lore;
+
+ lore.add(controls[index].getDisplayName());
String arrow = "\u25b6";
- String selPrefix = EnumChatFormatting.DARK_AQUA + " " + arrow + " ";
+ String selPrefixNC = " " + arrow + " ";
+ String selPrefix = EnumChatFormatting.DARK_AQUA + selPrefixNC;
String unselPrefix = EnumChatFormatting.GRAY.toString();
switch(index) {
case 0: break;
@@ -616,10 +814,11 @@ public class CustomAH extends Gui {
return lore;
case 2:
lore.add("");
- lore.add(rarityFilter == -1 ? selPrefix : unselPrefix + "No Filter");
+ lore.add((rarityFilter == -1 ? EnumChatFormatting.DARK_GRAY+selPrefixNC : unselPrefix) + "No Filter");
for(int i=0; i<rarities.length; i++) {
- lore.add(rarityFilter == i ? selPrefix : unselPrefix + "Filter " + rarities[i]);
+ lore.add((rarityFilter == i ? rarityColours[i]+selPrefixNC : unselPrefix) +
+ Utils.prettyCase(rarities[i]));
}
lore.add("");
lore.add(EnumChatFormatting.AQUA + "Right-Click to go backwards!");
@@ -651,8 +850,40 @@ public class CustomAH extends Gui {
lore.add(EnumChatFormatting.AQUA + "Right-Click to go backwards!");
lore.add(EnumChatFormatting.YELLOW + "Click to switch filter!");
return lore;
- case 7: break;
- case 8: break;
+ case 7:
+ lore.add("");
+ String[] linesEnch = {"Show All","Clean Only","Ench Only","Ench/HPB Only"};
+ for(int i=0; i<linesEnch.length; i++) {
+ String line = linesEnch[i];
+ if(i == enchFilter) {
+ line = selPrefix + line;
+ } else {
+ line = unselPrefix + line;
+ }
+ lore.add(line);
+ }
+ lore.add("");
+ lore.add(EnumChatFormatting.AQUA + "Right-Click to go backwards!");
+ lore.add(EnumChatFormatting.YELLOW + "Click to switch filter!");
+ return lore;
+ case 8:
+ lore.add("");
+ lore.add("Current aucid: " + currentAucId);
+ lore.add(" --- Processing");
+ lore.add("Page Process Millis: " + manager.auctionManager.processMillis);
+ lore.add(" --- Auction Stats");
+ lore.add("Active Auctions: " + manager.auctionManager.activeAuctions);
+ lore.add("Tracked Auctions: " + manager.auctionManager.getAuctionItems().size());
+ lore.add("Displayed Auctions: " + auctionIds.size());
+ lore.add("Tracked Player Auctions: " + manager.auctionManager.getPlayerBids().size());
+ lore.add("Unique Items: " + manager.auctionManager.uniqueItems);
+ lore.add("ID Tagged Auctions: " + manager.auctionManager.internalnameTaggedAuctions);
+ lore.add("Total Tags: " + manager.auctionManager.totalTags);
+ lore.add("Tagged Auctions: " + manager.auctionManager.taggedAuctions);
+ lore.add("");
+ lore.add(EnumChatFormatting.AQUA + "Right-Click to copy current aucid to clipboard!");
+ lore.add(EnumChatFormatting.YELLOW + "Click to refresh!");
+ return lore;
}
return new ArrayList<>();
}
@@ -712,90 +943,226 @@ public class CustomAH extends Gui {
return mainCategory.subcategories[clickedSubCategory];
}
+ private boolean doesAucMatch(AuctionManager.Auction auc) {
+ if(auc == null) return false;
+
+ Category currentCategory = getCurrentCategory();
+
+ boolean match = true;
+ if(currentCategory != null) {
+ match = false;
+ String[] categories = currentCategory.getTotalCategories();
+ for(String category : categories) {
+ match |= category.equalsIgnoreCase(auc.category);
+ }
+ }
+
+ if(rarityFilter >= 0 && rarityFilter < rarities.length) {
+ match &= rarities[rarityFilter].equals(auc.rarity);
+ }
+
+ if(binFilter == BIN_FILTER_BIN) {
+ match &= auc.bin;
+ } else if(binFilter == BIN_FILTER_AUC) {
+ match &= !auc.bin;
+ }
+
+ if(enchFilter > ENCH_FILTER_ALL) {
+ switch(enchFilter) {
+ case ENCH_FILTER_CLEAN:
+ match &= auc.enchLevel == 0; break;
+ case ENCH_FILTER_ENCH:
+ match &= auc.enchLevel >= 1; break;
+ case ENCH_FILTER_ENCHHPB:
+ match &= auc.enchLevel == 2; break;
+ }
+ }
+
+ return match;
+ }
+
+ private HashSet<String> search(String query, Set<String> dontMatch) {
+ query = query.trim();
+ HashSet<String> matches = new HashSet<>();
+
+ Set<String> itemMatches = manager.search(query);
+ for(String internalname : itemMatches) {
+ for(String aucid : manager.auctionManager.getAuctionsForInternalname(internalname)) {
+ AuctionManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucid);
+ if(doesAucMatch(auc)) {
+ matches.add(aucid);
+ } else {
+ dontMatch.add(aucid);
+ }
+ }
+ }
+
+ if(!query.contains(" ")) {
+ for(HashSet<String> aucids : manager.subMapWithKeysThatAreSuffixes(query,
+ manager.auctionManager.extrasToAucIdMap).values()) {
+ for(String aucid : aucids) {
+ AuctionManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucid);
+ if(!dontMatch.contains(aucid) && doesAucMatch(auc)) {
+ matches.add(aucid);
+ } else {
+ dontMatch.add(aucid);
+ }
+ }
+ }
+ }
+
+ return matches;