aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz <lo.scherf@gmail.com>2022-07-30 01:11:49 +0200
committerLorenz <lo.scherf@gmail.com>2022-07-30 01:11:49 +0200
commitdb2d2fce29df19870e97132dd2edd0cb8d7b597c (patch)
tree18c340faaf300c38606e4543ea782f239ea5c4b5
parent2b8c960c1a6a8fa6fca2d4e2ee7ec0f20492cb9e (diff)
downloadNotEnoughUpdates-db2d2fce29df19870e97132dd2edd0cb8d7b597c.tar.gz
NotEnoughUpdates-db2d2fce29df19870e97132dd2edd0cb8d7b597c.tar.bz2
NotEnoughUpdates-db2d2fce29df19870e97132dd2edd0cb8d7b597c.zip
completely reformatted the hover design
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java58
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperOverlay.java97
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java36
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/requirements/CollectionRequirement.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/requirements/ReputationRequirement.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/requirements/SlayerRequirement.java2
6 files changed, 110 insertions, 89 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java
index 5bbdf090..9c729854 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java
@@ -108,6 +108,7 @@ public class MinionHelperManager {
}
public String calculateUpgradeCostsFormat(MinionSource source, boolean upgradeOnly) {
+ if (source == null) return "§c?";
String internalName = source.getMinion().getInternalName();
if (upgradeOnly) {
if (upgradeCostFormatCache.containsKey(internalName)) {
@@ -120,13 +121,11 @@ public class MinionHelperManager {
}
if (source instanceof CustomSource) {
- return "§7" + ((CustomSource) source).getCustomSource();
+ return "§f" + ((CustomSource) source).getCustomSource();
}
long costs = calculateUpgradeCosts(source, upgradeOnly);
- String format = Utils.shortNumberFormat(costs, 0);
- String fullCostsFormat = !upgradeOnly ? "§o" : "";
- String result = "§6" + fullCostsFormat + format + " coins";
+ String result = formatCoins(costs, !upgradeOnly ? "§o" : "");
if (source instanceof NpcSource) {
ArrayListMultimap<String, Integer> items = ((NpcSource) source).getItems();
@@ -166,26 +165,9 @@ public class MinionHelperManager {
long upgradeCost = 0;
for (Map.Entry<String, Integer> entry : items.entries()) {
String internalName = entry.getKey();
+ long price = getPrice(internalName);
int amount = entry.getValue();
- JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(internalName);
- if (bazaarInfo == null) {
- if (internalName.contains("_GENERATOR_")) {
- upgradeCost += calculateUpgradeCosts(getMinionById(internalName).getMinionSource(), false);
- } else {
- if (!cheapItems.contains(internalName)) {
- double lowestBin = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAvgBin(internalName);
- upgradeCost += lowestBin * amount;
- }
- }
- continue;
- }
- if (!bazaarInfo.has("curr_sell")) {
- System.err.println("curr_sell does not exist for '" + internalName + "'");
- continue;
- }
- long bazaarInstantSellPrice = (long) bazaarInfo.get("curr_sell").getAsFloat();
- long added = bazaarInstantSellPrice * amount;
- upgradeCost += added;
+ upgradeCost += price * amount;
}
if (!upgradeOnly) {
Minion parent = source.getMinion().getParent();
@@ -196,6 +178,27 @@ public class MinionHelperManager {
return upgradeCost;
}
+ public long getPrice(String internalName) {
+ JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(internalName);
+ if (bazaarInfo == null) {
+ if (internalName.contains("_GENERATOR_")) {
+ return calculateUpgradeCosts(getMinionById(internalName).getMinionSource(), false);
+ } else {
+ if (!cheapItems.contains(internalName)) {
+ return (long) NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAvgBin(internalName);
+ }
+ }
+ return 0;
+ }
+
+ //TODO use average bazaar price?
+ if (!bazaarInfo.has("curr_sell")) {
+ System.err.println("curr_sell does not exist for '" + internalName + "'");
+ return 0;
+ }
+ return (long) bazaarInfo.get("curr_sell").getAsDouble();
+ }
+
public void createMinion(String internalName, int tier) {
minions.put(internalName, new Minion(internalName, tier));
}
@@ -287,4 +290,13 @@ public class MinionHelperManager {
minion.setMeetRequirements(meetAllRequirements(minion));
}
}
+
+ public String formatCoins(long coins) {
+ return formatCoins(coins, "");
+ }
+
+ public String formatCoins(long coins, String extraFormat) {
+ String format = Utils.shortNumberFormat(coins, 0);
+ return "§6" + extraFormat + format + " coins";
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperOverlay.java
index 788315c4..754d4c42 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperOverlay.java
@@ -22,11 +22,11 @@ package io.github.moulberry.notenoughupdates.miscgui.minionhelper;
import com.google.common.collect.ArrayListMultimap;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.miscgui.TrophyRewardOverlay;
+import io.github.moulberry.notenoughupdates.miscgui.minionhelper.loaders.MinionHelperRepoLoader;
import io.github.moulberry.notenoughupdates.miscgui.minionhelper.renderables.RenderableObject;
import io.github.moulberry.notenoughupdates.miscgui.minionhelper.renderables.RenderableText;
import io.github.moulberry.notenoughupdates.miscgui.minionhelper.requirements.MinionRequirement;
import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.CraftingSource;
-import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.CustomSource;
import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.MinionSource;
import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.NpcSource;
import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer;
@@ -80,10 +80,9 @@ public class MinionHelperOverlay {
public void onDrawBackground(GuiScreenEvent.BackgroundDrawnEvent event) {
if (!manager.inCraftedMinionsInventory()) return;
- boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
- LinkedHashMap<String, RenderableObject> renderMap = getRenderMap(shift);
+ LinkedHashMap<String, RenderableObject> renderMap = getRenderMap();
- renderHover(renderMap, shift);
+ renderHover(renderMap);
render(event, renderMap);
}
@@ -92,8 +91,7 @@ public class MinionHelperOverlay {
if (!manager.inCraftedMinionsInventory()) return;
if (!Mouse.getEventButtonState()) return;
- boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
- LinkedHashMap<String, RenderableObject> renderMap = getRenderMap(shift);
+ LinkedHashMap<String, RenderableObject> renderMap = getRenderMap();
RenderableObject mouseObject = getObjectOverMouse(renderMap);
@@ -136,10 +134,7 @@ public class MinionHelperOverlay {
return null;
}
- private void renderHover(
- LinkedHashMap<String, RenderableObject> renderMap,
- boolean shift
- ) {
+ private void renderHover(LinkedHashMap<String, RenderableObject> renderMap) {
lastHovered = null;
if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return;
@@ -154,7 +149,7 @@ public class MinionHelperOverlay {
if (mouseObject != null) {
GlStateManager.pushMatrix();
GlStateManager.scale(2f / scaledresolution.getScaleFactor(), 2f / scaledresolution.getScaleFactor(), 1);
- Utils.drawHoveringText(getTooltip(shift, mouseObject),
+ Utils.drawHoveringText(getTooltip(mouseObject),
mouseX * scaledresolution.getScaleFactor() / 2,
mouseY * scaledresolution.getScaleFactor() / 2,
scaledWidth * scaledresolution.getScaleFactor() / 2,
@@ -164,7 +159,7 @@ public class MinionHelperOverlay {
}
}
- private List<String> getTooltip(boolean shift, RenderableObject renderableObject) {
+ private List<String> getTooltip(RenderableObject renderableObject) {
List<String> lines = new ArrayList<>();
if (renderableObject instanceof RenderableText) {
@@ -180,72 +175,53 @@ public class MinionHelperOverlay {
List<MinionRequirement> requirements = manager.getRequirements(minionSource.getMinion());
if (!requirements.isEmpty()) {
for (MinionRequirement requirement : requirements) {
- String color = manager.meetRequirement(minion, requirement) ? "§a" : "§c";
- lines.add(" " + color + "Requirement: §f" + requirement.printDescription());
+ String color = manager.meetRequirement(minion, requirement) ? "§a" : "§7";
+ lines.add(" §8- " + color + requirement.printDescription());
}
} else {
- lines.add("§cCould not find any requirements!");
- lines.add("§cThis is ");
+ lines.add("§cNo requirements loaded!");
}
if (minionSource instanceof CraftingSource) {
CraftingSource craftingSource = (CraftingSource) minionSource;
lines.add("");
- if (shift || minion.getTier() == 1) {
- lines.add("Full crafting costs:");
+ String format = manager.calculateUpgradeCostsFormat(craftingSource, true);
+ if (minion.getTier() == 1) {
+ lines.add("Full crafting costs: " + format);
} else {
- lines.add("Upgrade costs:");
+ lines.add("Upgrade costs: " + format);
}
- String format = manager.calculateUpgradeCostsFormat(craftingSource, !shift);
- lines.add(format);
-
- lines.add("");
-
- Map<String, Integer> allItems = grabAllItems(craftingSource.getItems());
+ formatItems(lines, grabAllItems(craftingSource.getItems()));
- lines.add("Crafting recipe requires:");
- for (Map.Entry<String, Integer> entry : allItems.entrySet()) {
- String name = entry.getKey();
- int amount = entry.getValue();
- lines.add(name + ": " + amount);
- }
} else if (minionSource instanceof NpcSource) {
NpcSource npcSource = (NpcSource) minionSource;
- int coins = npcSource.getCoins();
String npcName = npcSource.getNpcName();
lines.add("");
- lines.add("Can bet bought at the NPC");
- lines.add("name: " + npcName);
+ lines.add("Buy at §9" + npcName + " (NPC)");
lines.add("");
- lines.add("Cost:");
- String format = Utils.shortNumberFormat(coins, 0);
- String result = "§6" + format + " coins";
- lines.add(" coins: " + result);
- lines.add(" Items:");
- Map<String, Integer> allItems = grabAllItems(npcSource.getItems());
- for (Map.Entry<String, Integer> entry : allItems.entrySet()) {
- String name = entry.getKey();
- int amount = entry.getValue();
- lines.add(" " + name + ": " + amount);
- }
-
- } else if (minionSource instanceof CustomSource) {
- CustomSource customSource = (CustomSource) minionSource;
- String source = customSource.getCustomSource();
- lines.add("");
- lines.add(source);
+ lines.add("Buy costs: " + manager.calculateUpgradeCostsFormat(npcSource, true));
+ lines.add(" §8- " + manager.formatCoins(npcSource.getCoins()));
+ formatItems(lines, grabAllItems(npcSource.getItems()));
}
lines.add("");
lines.add("§eClick to view recipe");
- if (!shift) {
- lines.add("");
- lines.add("§8[SHIFT show full costs]");
- }
}
return lines;
}
+ private void formatItems(List<String> lines, Map<String, Integer> allItems) {
+ for (Map.Entry<String, Integer> entry : allItems.entrySet()) {
+ String internalName = entry.getKey();
+ String name = MinionHelperRepoLoader.getInstance().getDisplayName(internalName);
+
+ int amount = entry.getValue();
+ String amountText = amount != 1 ? amount + "x " : "";
+ String price = manager.formatCoins(manager.getPrice(internalName) * amount);
+ lines.add(" §8- §f" + amountText + name + " " + price);
+ }
+ }
+
private Map<String, Integer> grabAllItems(ArrayListMultimap<String, Integer> multimap) {
Map<String, Integer> allItems = new HashMap<>();
for (Map.Entry<String, Integer> entry : multimap.entries()) {
@@ -258,7 +234,6 @@ public class MinionHelperOverlay {
}
private Map<Minion, Long> getMissing(boolean shift) {
-
Map<Minion, Long> prices = new HashMap<>();
for (Minion minion : manager.getAllMinions().values()) {
@@ -302,7 +277,8 @@ public class MinionHelperOverlay {
}
}
- private LinkedHashMap<String, RenderableObject> getRenderMap(boolean shift) {
+ private LinkedHashMap<String, RenderableObject> getRenderMap() {
+ boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
if (!shift) {
if (cacheNoShift != null) return cacheNoShift;
} else {
@@ -316,11 +292,12 @@ public class MinionHelperOverlay {
} else {
renderMap.put(
"To craft: " + prices.size(),
+ //TODO formulierung
new RenderableText("you can craft that many more minions!")
- );//TODO formulierung
+ );
int i = 0;
- //TOOD change
+ //TODO change
int max = 20;
Map<Minion, Long> sort = TrophyRewardOverlay.sortByValue(prices);
@@ -336,7 +313,7 @@ public class MinionHelperOverlay {
String format = manager.calculateUpgradeCostsFormat(minion.getMinionSource(), true);
String requirementFormat = !minion.doesMeetRequirements() ? "§7§o" : "";
renderMap.put(
- requirementFormat + displayName + "§r " + requirementFormat + minion.getTier() + "§r §8- " + format,
+ requirementFormat + displayName + "§r " + requirementFormat + minion.getTier() + " §r§8- " + format,
minion.getMinionSource()
);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java
index 1885eb68..8873aca2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java
@@ -51,6 +51,7 @@ public class MinionHelperRepoLoader {
private final MinionHelperManager manager = MinionHelperManager.getInstance();
private boolean dirty = true;
private int ticks = 0;
+ private final Map<String, String> displayNameCache = new HashMap<>();
public static MinionHelperRepoLoader getInstance() {
if (instance == null) {
@@ -65,6 +66,7 @@ public class MinionHelperRepoLoader {
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onRepoReload(RepositoryReloadEvent event) {
dirty = true;
+ displayNameCache.clear();
}
@SubscribeEvent
@@ -121,9 +123,9 @@ public class MinionHelperRepoLoader {
}
manager.getMinionById("FLOWER_GENERATOR_1").getRequirements().add(new CustomRequirement(
- "Buy Flower Minion 1 from Dark Auction"));
+ "Buy a Flower Minion 1 from Dark Auction"));
manager.getMinionById("SNOW_GENERATOR_1").getRequirements().add(new CustomRequirement(
- "Gain Snow Minion 1 from opening gifts"));
+ "Get a Snow Minion 1 from opening gifts"));
}
@@ -264,7 +266,8 @@ public class MinionHelperRepoLoader {
error = true;
if (NotEnoughUpdates.INSTANCE.config.hidden.dev) {
Utils.addChatMessage(
- "§c[NEU] Error in MinionHelperRepoLoader while loading repo entry " + minion.getDisplayName() + " " + minion.getTier() + ": " +
+ "§c[NEU] Error in MinionHelperRepoLoader while loading repo entry " + minion.getDisplayName() + " " +
+ minion.getTier() + ": " +
e.getClass().getSimpleName() + ": " + e.getMessage());
}
e.printStackTrace();
@@ -335,4 +338,31 @@ public class MinionHelperRepoLoader {
}
}
}
+
+ //TODO move into utils class or somewhere
+ public String getDisplayName(String internalName) {
+ if (displayNameCache.containsKey(internalName)) {
+ return displayNameCache.get(internalName);
+ }
+
+ String displayName = null;
+ TreeMap<String, JsonObject> itemInformation = NotEnoughUpdates.INSTANCE.manager.getItemInformation();
+ if (itemInformation.containsKey(internalName)) {
+ JsonObject jsonObject = itemInformation.get(internalName);
+ if (jsonObject.has("displayname")) {
+ displayName = jsonObject.get("displayname").getAsString();
+ }
+ }
+
+ if (displayName == null) {
+ displayName = internalName;
+ Utils.showOutdatedRepoNotification();
+ if (NotEnoughUpdates.INSTANCE.config.hidden.dev) {
+ Utils.addChatMessage("§c[NEU] Found no display name in repo for '" + internalName + "'!");
+ }
+ }
+
+ displayNameCache.put(internalName, displayName);
+ return displayName;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/requirements/CollectionRequirement.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/requirements/CollectionRequirement.java
index 376065a0..e6b3c542 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/requirements/CollectionRequirement.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/requirements/CollectionRequirement.java
@@ -39,6 +39,6 @@ public class CollectionRequirement extends MinionRequirement {
@Override
public String printDescription() {
- return collection + " collection at level " + level;
+ return "Collection: " + collection + " lvl " + level;
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/requirements/ReputationRequirement.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/requirements/ReputationRequirement.java
index 0ee153a2..671a14f4 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/requirements/ReputationRequirement.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/requirements/ReputationRequirement.java
@@ -19,6 +19,8 @@
package io.github.moulberry.notenoughupdates.miscgui.minionhelper.requirements;
+import io.github.moulberry.notenoughupdates.util.Utils;
+
public class ReputationRequirement extends MinionRequirement {
private final String reputationType;
@@ -39,6 +41,6 @@ public class ReputationRequirement extends MinionRequirement {
@Override
public String printDescription() {
- return reputation + " " + reputationType + " reputation";
+ return "Reputation: " + Utils.formatNumberWithDots(reputation) + " " + reputationType.toLowerCase();
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/requirements/SlayerRequirement.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/requirements/SlayerRequirement.java
index 0b81c5be..30b09cb0 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/requirements/SlayerRequirement.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/requirements/SlayerRequirement.java
@@ -39,6 +39,6 @@ public class SlayerRequirement extends MinionRequirement {
@Override
public String printDescription() {
- return slayer + " slayer at level " + level;
+ return "Slayer: " + slayer + " lvl " + level;
}
}