diff options
author | Lorenz <lo.scherf@gmail.com> | 2022-08-02 09:42:44 +0200 |
---|---|---|
committer | Lorenz <lo.scherf@gmail.com> | 2022-08-02 09:42:44 +0200 |
commit | 376229d97def549ff577e37cbf1b3fa2d9dd255b (patch) | |
tree | c7e8b62e8a4560a9a509261215eb3bb3efc34d0d /src/main/java/io | |
parent | 602ab5284258708075a18ef6363d28c610e902a3 (diff) | |
download | NotEnoughUpdates-376229d97def549ff577e37cbf1b3fa2d9dd255b.tar.gz NotEnoughUpdates-376229d97def549ff577e37cbf1b3fa2d9dd255b.tar.bz2 NotEnoughUpdates-376229d97def549ff577e37cbf1b3fa2d9dd255b.zip |
renamed the overview logic
Diffstat (limited to 'src/main/java/io')
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/Minion.java | 10 | ||||
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java | 59 | ||||
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java | 20 | ||||
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/renderables/OverviewLine.java (renamed from src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/renderables/RenderableObject.java) | 4 | ||||
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/renderables/OverviewText.java (renamed from src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/renderables/RenderableText.java) | 18 |
5 files changed, 61 insertions, 50 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/Minion.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/Minion.java index e712b134..27e7ac22 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/Minion.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/Minion.java @@ -19,14 +19,15 @@ package io.github.moulberry.notenoughupdates.miscgui.minionhelper; -import io.github.moulberry.notenoughupdates.miscgui.minionhelper.render.renderables.RenderableObject; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.miscgui.minionhelper.render.renderables.OverviewLine; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.requirements.MinionRequirement; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.MinionSource; import java.util.ArrayList; import java.util.List; -public class Minion extends RenderableObject { +public class Minion extends OverviewLine { private final String internalName; private final int tier; private String displayName; @@ -93,4 +94,9 @@ public class Minion extends RenderableObject { public void setMeetRequirements(boolean meetRequirements) { this.meetRequirements = meetRequirements; } + + @Override + public void onClick() { + NotEnoughUpdates.INSTANCE.manager.displayGuiItemRecipe(internalName); + } } 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 cd4762f1..396bd49d 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 @@ -24,9 +24,8 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.miscgui.TrophyRewardOverlay; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.Minion; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager; -import io.github.moulberry.notenoughupdates.miscgui.minionhelper.render.renderables.RenderableObject; -import io.github.moulberry.notenoughupdates.miscgui.minionhelper.render.renderables.RenderableText; -import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.MinionSource; +import io.github.moulberry.notenoughupdates.miscgui.minionhelper.render.renderables.OverviewLine; +import io.github.moulberry.notenoughupdates.miscgui.minionhelper.render.renderables.OverviewText; import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; import io.github.moulberry.notenoughupdates.util.NotificationHandler; import io.github.moulberry.notenoughupdates.util.Utils; @@ -45,6 +44,7 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; +import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; @@ -53,8 +53,8 @@ public class MinionHelperOverlay { private final MinionHelperManager manager; private final MinionHelperOverlayHover hover; - private LinkedHashMap<String, RenderableObject> cacheRenderMapShift = null; - private LinkedHashMap<String, RenderableObject> cacheRenderMapNoShift = null; + private LinkedHashMap<String, OverviewLine> cacheRenderMapShift = null; + private LinkedHashMap<String, OverviewLine> cacheRenderMapNoShift = null; public MinionHelperOverlay(MinionHelperManager manager) { this.manager = manager; @@ -90,7 +90,7 @@ public class MinionHelperOverlay { manager.getApi().setNotifyNoCollectionApi(false); } - LinkedHashMap<String, RenderableObject> renderMap = getRenderMap(); + LinkedHashMap<String, OverviewLine> renderMap = getRenderMap(); hover.renderHover(renderMap); render(event, renderMap); @@ -102,15 +102,10 @@ public class MinionHelperOverlay { if (!manager.isReadyToUse()) return; if (!Mouse.getEventButtonState()) return; - RenderableObject mouseObject = getObjectOverMouse(getRenderMap()); - - if (mouseObject != null) { - if (mouseObject instanceof Minion) { - - event.setCanceled(true); - Minion minion = ((Minion) mouseObject); - NotEnoughUpdates.INSTANCE.manager.displayGuiItemRecipe(minion.getInternalName()); - } + OverviewLine overviewLine = getObjectOverMouse(getRenderMap()); + if (overviewLine != null) { + overviewLine.onClick(); + event.setCanceled(true); } } @@ -127,7 +122,7 @@ public class MinionHelperOverlay { return prices; } - private void render(GuiScreenEvent.BackgroundDrawnEvent event, Map<String, RenderableObject> renderMap) { + private void render(GuiScreenEvent.BackgroundDrawnEvent event, Map<String, OverviewLine> renderMap) { Minecraft minecraft = Minecraft.getMinecraft(); if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return; Gui gui = event.gui; @@ -143,12 +138,12 @@ public class MinionHelperOverlay { FontRenderer fontRendererObj = minecraft.fontRendererObj; int extra = 0; - for (Map.Entry<String, RenderableObject> entry : renderMap.entrySet()) { + for (Map.Entry<String, OverviewLine> entry : renderMap.entrySet()) { String line = entry.getKey(); - RenderableObject renderableObject = entry.getValue(); + OverviewLine overviewLine = entry.getValue(); String prefix = ""; - if (renderableObject instanceof Minion) { - Minion minion = (Minion) renderableObject; + if (overviewLine instanceof Minion) { + Minion minion = (Minion) overviewLine; if (minion == hover.getLastHovered()) { prefix = "§e"; } @@ -158,7 +153,7 @@ public class MinionHelperOverlay { } } - private LinkedHashMap<String, RenderableObject> getRenderMap() { + private LinkedHashMap<String, OverviewLine> getRenderMap() { boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT); if (!shift) { if (cacheRenderMapNoShift != null) return cacheRenderMapNoShift; @@ -167,19 +162,25 @@ public class MinionHelperOverlay { } Map<Minion, Long> prices = getMissing(shift); - LinkedHashMap<String, RenderableObject> renderMap = new LinkedHashMap<>(); + LinkedHashMap<String, OverviewLine> renderMap = new LinkedHashMap<>(); if (prices.isEmpty()) { - renderMap.put("all minions collected!", new RenderableText("You have all the minions available collected! :)")); + renderMap.put("all minions collected!", new OverviewText(Arrays.asList("No minions to craft avaliable!"), () -> { + //TODO formatting + Utils.addChatMessage("you can't craft anything rn!"); + + })); } else { renderMap.put( "To craft: " + prices.size(), - //TODO formulierung - new RenderableText("you can craft that many more minions!") + //TODO formatting + new OverviewText(Arrays.asList("You can craft " + prices.size() + " more minions!"), () -> { + Utils.addChatMessage("craft them now!"); + }) ); int i = 0; //TODO change - int max = 20; + int max = 9; Map<Minion, Long> sort = TrophyRewardOverlay.sortByValue(prices); for (Minion minion : sort.keySet()) { @@ -213,7 +214,7 @@ public class MinionHelperOverlay { return renderMap; } - RenderableObject getObjectOverMouse(LinkedHashMap<String, RenderableObject> renderMap) { + OverviewLine getObjectOverMouse(LinkedHashMap<String, OverviewLine> renderMap) { GuiScreen gui = Minecraft.getMinecraft().currentScreen; if (!(gui instanceof GuiChest)) return null; @@ -231,11 +232,11 @@ public class MinionHelperOverlay { int mouseY = scaledHeight - Mouse.getY() * scaledHeight / Minecraft.getMinecraft().displayHeight - 1; int index = 0; - for (RenderableObject renderableObject : renderMap.values()) { + for (OverviewLine overviewLine : renderMap.values()) { if (mouseX > x && mouseX < x + 130 && mouseY > y + index && mouseY < y + 13 + index) { - return renderableObject; + return overviewLine; } index += 10; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java index c7ae6b53..58c735e2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java @@ -22,8 +22,8 @@ package io.github.moulberry.notenoughupdates.miscgui.minionhelper.render; import com.google.common.collect.ArrayListMultimap; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.Minion; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager; -import io.github.moulberry.notenoughupdates.miscgui.minionhelper.render.renderables.RenderableObject; -import io.github.moulberry.notenoughupdates.miscgui.minionhelper.render.renderables.RenderableText; +import io.github.moulberry.notenoughupdates.miscgui.minionhelper.render.renderables.OverviewLine; +import io.github.moulberry.notenoughupdates.miscgui.minionhelper.render.renderables.OverviewText; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.requirements.CollectionRequirement; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.requirements.MinionRequirement; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.CraftingSource; @@ -53,7 +53,7 @@ public class MinionHelperOverlayHover { this.manager = manager; } - void renderHover(LinkedHashMap<String, RenderableObject> renderMap) { + void renderHover(LinkedHashMap<String, OverviewLine> renderMap) { lastHovered = null; if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return; @@ -64,7 +64,7 @@ public class MinionHelperOverlayHover { int mouseX = Mouse.getX() * scaledWidth / Minecraft.getMinecraft().displayWidth; int mouseY = scaledHeight - Mouse.getY() * scaledHeight / Minecraft.getMinecraft().displayHeight - 1; - RenderableObject mouseObject = overlay.getObjectOverMouse(renderMap); + OverviewLine mouseObject = overlay.getObjectOverMouse(renderMap); if (mouseObject != null) { GlStateManager.pushMatrix(); GlStateManager.scale(2f / scaledresolution.getScaleFactor(), 2f / scaledresolution.getScaleFactor(), 1); @@ -78,15 +78,15 @@ public class MinionHelperOverlayHover { } } - private List<String> getTooltip(RenderableObject renderableObject) { + private List<String> getTooltip(OverviewLine overviewLine) { List<String> lines = new ArrayList<>(); - if (renderableObject instanceof RenderableText) { - RenderableText renderableText = (RenderableText) renderableObject; - lines.addAll(renderableText.getLines()); - } else if (renderableObject instanceof Minion) { + if (overviewLine instanceof OverviewText) { + OverviewText overviewText = (OverviewText) overviewLine; + lines.addAll(overviewText.getLines()); + } else if (overviewLine instanceof Minion) { - Minion minion = (Minion) renderableObject; + Minion minion = (Minion) overviewLine; MinionSource minionSource = minion.getMinionSource(); lastHovered = minion; String displayName = minion.getDisplayName(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/renderables/RenderableObject.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/renderables/OverviewLine.java index 2ba6ca76..85d682b3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/renderables/RenderableObject.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/renderables/OverviewLine.java @@ -19,5 +19,7 @@ package io.github.moulberry.notenoughupdates.miscgui.minionhelper.render.renderables; -public abstract class RenderableObject { +public abstract class OverviewLine { + + public abstract void onClick(); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/renderables/RenderableText.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/renderables/OverviewText.java index b2269b4f..499ca758 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/renderables/RenderableText.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/renderables/OverviewText.java @@ -19,22 +19,24 @@ package io.github.moulberry.notenoughupdates.miscgui.minionhelper.render.renderables; -import java.util.Arrays; import java.util.List; -public class RenderableText extends RenderableObject { +public class OverviewText extends OverviewLine { + private final Runnable clickRunnable; private final List<String> lines; - public RenderableText(List<String> lines) { - this.lines = lines; - } - - public RenderableText(String... lines) { - this(Arrays.asList(lines)); + public OverviewText(List<String> line, Runnable clickRunnable) { + this.lines = line; + this.clickRunnable = clickRunnable; } public List<String> getLines() { return lines; } + + @Override + public void onClick() { + clickRunnable.run(); + } } |