From 251b365e4846aa89513d78208a7c0f77a5540701 Mon Sep 17 00:00:00 2001 From: Lorenz Date: Wed, 10 Aug 2022 14:27:59 +0200 Subject: fixed needed minion count read error on profile switch and reworked the design --- .../miscgui/minionhelper/MinionHelperManager.java | 3 ++- .../loaders/MinionHelperInventoryLoader.java | 8 +++++++- .../minionhelper/render/MinionHelperOverlay.java | 18 +++++------------- 3 files changed, 14 insertions(+), 15 deletions(-) (limited to 'src/main') 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 9a3a4883..952bd07a 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 @@ -134,9 +134,10 @@ public class MinionHelperManager { minion.setMeetRequirements(false); } + needForNextSlot = -1; api.onProfileSwitch(); overlay.onProfileSwitch(); - needForNextSlot = -1; + inventoryLoader.onProfileSwitch(); } public void reloadData() { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java index fa3cc5de..3ff5a9c8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java @@ -59,7 +59,9 @@ public class MinionHelperInventoryLoader { checkInventory(); } else { pagesSeenAlready.clear(); - shouldCheckNextSlot = true; + if (shouldCheckNextSlot) { + shouldCheckNextSlot = true; + } } } @@ -137,4 +139,8 @@ public class MinionHelperInventoryLoader { manager.getOverlay().resetCache(); } } + + public void onProfileSwitch() { + shouldCheckNextSlot = true; + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java index 5f1e7e16..12a8c24d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java @@ -223,8 +223,9 @@ public class MinionHelperOverlay { LinkedHashMap renderMap ) { int neededForNextSlot = manager.getNeedForNextSlot(); + String color = showOnlyAvailable ? "§e" : "§c"; if (neededForNextSlot == -1) { - renderMap.put("Next slot in: ?", new OverviewText(Collections.emptyList(), () -> {})); + renderMap.put(color + "Next slot in: ?", new OverviewText(Collections.emptyList(), () -> {})); return; } @@ -236,17 +237,8 @@ public class MinionHelperOverlay { if (index == neededForNextSlot) break; } String format = manager.getPriceCalculation().formatCoins(priceNeeded); - String text = "Next slot in: §b" + neededForNextSlot + " §8- " + format; - List list = new ArrayList<>(); - list.add("§7The combined upgrade cost for"); - list.add("§7the next §b" + index + " minions §7is " + format); - - if (!showOnlyAvailable) { - list.add(""); - list.add("§cThis shows minions that don't meet requirements!"); - } - - renderMap.put(text, new OverviewText(list, () -> {})); + String text = color + "Next slot in: §b" + neededForNextSlot + " §8- " + format; + renderMap.put(text, new OverviewText(Collections.emptyList(), () -> {})); } private void addTitle(Map prices, LinkedHashMap renderMap) { @@ -264,7 +256,7 @@ public class MinionHelperOverlay { } } String toggleText = "§eClick to " + (showOnlyAvailable ? "show" : "hide") + " minion upgrades without requirements"; - renderMap.put(name, new OverviewText(Arrays.asList(hoverText, "", toggleText), this::toggleShowAvailable)); + renderMap.put("§e" + name, new OverviewText(Arrays.asList(hoverText, "", toggleText), this::toggleShowAvailable)); } private void addMinions(Map prices, LinkedHashMap renderMap) { -- cgit