diff options
author | Lorenz <lo.scherf@gmail.com> | 2022-08-02 10:04:41 +0200 |
---|---|---|
committer | Lorenz <lo.scherf@gmail.com> | 2022-08-02 10:04:41 +0200 |
commit | a5a6dd79389377563b09f3d17f74d364623de73d (patch) | |
tree | fca36f2fd437ee899112641595e6ee91c0dd43f3 /src/main/java/io | |
parent | 376229d97def549ff577e37cbf1b3fa2d9dd255b (diff) | |
download | NotEnoughUpdates-a5a6dd79389377563b09f3d17f74d364623de73d.tar.gz NotEnoughUpdates-a5a6dd79389377563b09f3d17f74d364623de73d.tar.bz2 NotEnoughUpdates-a5a6dd79389377563b09f3d17f74d364623de73d.zip |
changed toggle trigger from shift click to click first line
Diffstat (limited to 'src/main/java/io')
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java | 51 |
1 files changed, 22 insertions, 29 deletions
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 396bd49d..8e44b7c5 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 @@ -40,7 +40,6 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.GuiOpenEvent; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; @@ -53,8 +52,8 @@ public class MinionHelperOverlay { private final MinionHelperManager manager; private final MinionHelperOverlayHover hover; - private LinkedHashMap<String, OverviewLine> cacheRenderMapShift = null; - private LinkedHashMap<String, OverviewLine> cacheRenderMapNoShift = null; + private LinkedHashMap<String, OverviewLine> cacheRenderMap = null; + private boolean showOnlyAvailable = true; public MinionHelperOverlay(MinionHelperManager manager) { this.manager = manager; @@ -67,8 +66,7 @@ public class MinionHelperOverlay { } public void resetCache() { - cacheRenderMapShift = null; - cacheRenderMapNoShift = null; + cacheRenderMap = null; } //TODO use different texture @@ -109,11 +107,11 @@ public class MinionHelperOverlay { } } - private Map<Minion, Long> getMissing(boolean shift) { + private Map<Minion, Long> getMissing() { Map<Minion, Long> prices = new HashMap<>(); for (Minion minion : manager.getAllMinions().values()) { - if (!minion.doesMeetRequirements() && !shift) continue; + if (!minion.doesMeetRequirements() && showOnlyAvailable) continue; if (!minion.isCrafted()) { long price = manager.getPriceCalculation().calculateUpgradeCosts(minion, true); prices.put(minion, price); @@ -154,28 +152,23 @@ public class MinionHelperOverlay { } private LinkedHashMap<String, OverviewLine> getRenderMap() { - boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT); - if (!shift) { - if (cacheRenderMapNoShift != null) return cacheRenderMapNoShift; - } else { - if (cacheRenderMapShift != null) return cacheRenderMapShift; - } - Map<Minion, Long> prices = getMissing(shift); + if (cacheRenderMap != null) return cacheRenderMap; + Map<Minion, Long> prices = getMissing(); LinkedHashMap<String, OverviewLine> renderMap = new LinkedHashMap<>(); + String toggleText = "§eClick to " + (showOnlyAvailable ? "show" : "hide") + " minion upgrades without requirements"; if (prices.isEmpty()) { - renderMap.put("all minions collected!", new OverviewText(Arrays.asList("No minions to craft avaliable!"), () -> { - //TODO formatting - Utils.addChatMessage("you can't craft anything rn!"); - - })); + renderMap.put( + "all minions collected!", + new OverviewText(Arrays.asList("No minions to craft avaliable!", toggleText), this::toggleShowAvailable) + ); } else { renderMap.put( "To craft: " + prices.size(), - //TODO formatting - new OverviewText(Arrays.asList("You can craft " + prices.size() + " more minions!"), () -> { - Utils.addChatMessage("craft them now!"); - }) + new OverviewText( + Arrays.asList("You can craft " + prices.size() + " more minions!", toggleText), + this::toggleShowAvailable + ) ); int i = 0; @@ -205,15 +198,15 @@ public class MinionHelperOverlay { } } - if (shift) { - cacheRenderMapShift = renderMap; - } else { - cacheRenderMapNoShift = renderMap; - } - + cacheRenderMap = renderMap; return renderMap; } + private void toggleShowAvailable() { + showOnlyAvailable = !showOnlyAvailable; + resetCache(); + } + OverviewLine getObjectOverMouse(LinkedHashMap<String, OverviewLine> renderMap) { GuiScreen gui = Minecraft.getMinecraft().currentScreen; if (!(gui instanceof GuiChest)) return null; |