diff options
author | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2021-08-22 16:28:33 +0200 |
---|---|---|
committer | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2021-08-22 16:28:33 +0200 |
commit | 6899df634766e2a8666ac7f45cac1008da140c4e (patch) | |
tree | d322bc4ce07e2efaf6fa703e0cb063b13b836833 | |
parent | 2ee79cb1767dab9550a87ca5208452758a100932 (diff) | |
download | NotEnoughUpdates-6899df634766e2a8666ac7f45cac1008da140c4e.tar.gz NotEnoughUpdates-6899df634766e2a8666ac7f45cac1008da140c4e.tar.bz2 NotEnoughUpdates-6899df634766e2a8666ac7f45cac1008da140c4e.zip |
Mines of Divan overlay
6 files changed, 313 insertions, 20 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 8c668da0..4f565fa6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -838,6 +838,8 @@ public class NEUEventListener { } if(unformatted.startsWith("[NPC] Professor Robot: ") || unformatted.startsWith(" ")) OverlayManager.automatonOverlay.message(unformatted); + else if(unformatted.startsWith("[NPC] Keeper of ")) + OverlayManager.divanMinesOverlay.message(unformatted); } public static boolean drawingGuiScreen = false; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java index 3aca1041..380ca674 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -87,6 +87,9 @@ public class NEUConfig extends Config { return; case 10: editOverlay(activeConfigCategory, OverlayManager.automatonOverlay, mining.automatonOverlayPosition); + return; + case 11: + editOverlay(activeConfigCategory, OverlayManager.automatonOverlay, mining.divanMinesOverlayPosition); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java index 3d5c0b09..e8f06eca 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java @@ -291,6 +291,132 @@ public class Mining { @ConfigAccordionId(id = 5)
public int automatonMissingColor = 12;
+ @ConfigOption(
+ name = "Mines of Divan overlay",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 6)
+ public boolean divanMinesOverlayAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enabled",
+ desc = "Enables the Mines of Divan overlay."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 6)
+ public boolean divanMinesOverlay = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Position",
+ desc = "Change the position of the AMines of Divan overlay."
+ )
+ @ConfigEditorButton(
+ runnableId = 11,
+ buttonText = "Edit"
+ )
+ @ConfigAccordionId(id = 6)
+ public Position divanMinesOverlayPosition = new Position(200, 0);
+
+ @Expose
+ @ConfigOption(
+ name = "Style",
+ desc = "Change the style of the Mines of Divan overlay."
+ )
+ @ConfigEditorDropdown(
+ values = {"Background", "No Shadow", "Shadow", "Full Shadow"}
+ )
+ @ConfigAccordionId(id = 6)
+ public int divanMinesOverlayStyle = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Show Icons",
+ desc = "Show icons in the overlay that represent the part."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 6)
+ public boolean divanMinesIcons = true;
+
+
+ @Expose
+ @ConfigOption(
+ name = "Hide Done",
+ desc = "Don't show parts you've given to the Keepers."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 6)
+ public boolean divanMinesHideDone = false;
+
+ @ConfigOption(
+ name = "Colours",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 7)
+ @ConfigAccordionId(id = 6)
+ public boolean divanMinesColourAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Part colour",
+ desc = "Change the colour of the part text."
+
+ )
+ @ConfigEditorDropdown(
+ values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
+ )
+ @ConfigAccordionId(id = 7)
+ public int divanMinesPartColor = 3;
+
+ @Expose
+ @ConfigOption(
+ name = "Ready colour",
+ desc = "Change the colour when the part is given to the Keepers."
+
+ )
+ @ConfigEditorDropdown(
+ values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
+ )
+ @ConfigAccordionId(id = 7)
+ public int divanMinesDoneColor = 10;
+
+ @Expose
+ @ConfigOption(
+ name = "In Inventory Color",
+ desc = "Change the colour when the part is in the inventory."
+
+ )
+ @ConfigEditorDropdown(
+ values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
+ )
+ @ConfigAccordionId(id = 7)
+ public int divanMinesInventoryColor = 14;
+
+ @Expose
+ @ConfigOption(
+ name = "In Storage Color",
+ desc = "Change the colour when the part is in the storage."
+
+ )
+ @ConfigEditorDropdown(
+ values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
+ )
+ @ConfigAccordionId(id = 7)
+ public int divanMinesStorageColor = 14;
+
+ @Expose
+ @ConfigOption(
+ name = "Missing Color",
+ desc = "Change the colour when the part is missing."
+
+ )
+ @ConfigEditorDropdown(
+ values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
+ )
+ @ConfigAccordionId(id = 7)
+ public int divanMinesMissingColor = 12;
+
@Expose
@ConfigOption(
name = "Puzzler Solver",
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AutomatonOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AutomatonOverlay.java index bbdb4786..e214b1c0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AutomatonOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AutomatonOverlay.java @@ -7,7 +7,6 @@ import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import org.lwjgl.util.vector.Vector2f; @@ -93,25 +92,31 @@ public class AutomatonOverlay extends TextOverlay { items.put(item, false); } } else if (message.startsWith("[NPC] Professor Robot: ")) { - if (message.equals("[NPC] Professor Robot: That's not one of the components I need! Bring me one of the missing components:")) { - items.replaceAll((k, v) -> true); - } else if (message.equals("[NPC] Professor Robot: You've brought me all of the components!")) { - items.replaceAll((k, v) -> false); - } else { - Matcher giveMatcher = givePattern.matcher(message); - Matcher notFinalMatcher = notFinalPattern.matcher(message); - if (giveMatcher.matches()) { - String item = giveMatcher.group("part"); - if (items.containsKey(item)) { - items.put(item, true); - } - } else if (notFinalMatcher.matches()) { - String item = notFinalMatcher.group("part"); - if (items.containsKey(item)) { - items.replaceAll((k, v) -> true); - items.put(item, false); + switch (message) { + case "[NPC] Professor Robot: That's not one of the components I need! Bring me one of the missing components:": + items.replaceAll((k, v) -> true); + break; + case "[NPC] Professor Robot: You've brought me all of the components!": + case "[NPC] Professor Robot: You haven't placed the Sapphire Crystal yet!": + case "[NPC] Professor Robot: You have already placed the Sapphire Crystal!": + items.replaceAll((k, v) -> false); + break; + default: + Matcher giveMatcher = givePattern.matcher(message); + Matcher notFinalMatcher = notFinalPattern.matcher(message); + if (giveMatcher.matches()) { + String item = giveMatcher.group("part"); + if (items.containsKey(item)) { + items.put(item, true); + } + } else if (notFinalMatcher.matches()) { + String item = notFinalMatcher.group("part"); + if (items.containsKey(item)) { + items.replaceAll((k, v) -> true); + items.put(item, false); + } } - } + break; } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/DivanMinesOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/DivanMinesOverlay.java new file mode 100644 index 00000000..d6ec1d98 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/DivanMinesOverlay.java @@ -0,0 +1,143 @@ +package io.github.moulberry.notenoughupdates.overlays; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.core.config.Position; +import io.github.moulberry.notenoughupdates.miscfeatures.StorageManager; +import io.github.moulberry.notenoughupdates.util.SBInfo; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import org.lwjgl.util.vector.Vector2f; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Supplier; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class DivanMinesOverlay extends TextOverlay { + private static final HashMap<String, Boolean> items; + private static final Minecraft mc = Minecraft.getMinecraft(); + private final StorageManager storageManager = StorageManager.getInstance(); + private final Pattern notFoundPattern = Pattern.compile("\\[NPC] Keeper of \\w+: Talk to me when you have found a (?<item>[a-z-A-Z ]+)!"); + private final Pattern foundPattern = Pattern.compile("\\[NPC] Keeper of \\w+: (Excellent! You have returned the|You have already restored this Dwarf's) (?<item>[a-z-A-Z ]+)(!| to its rightful place!)"); + private final Pattern resetPattern = Pattern.compile("\\[NPC] Keeper of \\w+: (You haven't placed the Jade Crystal yet!|You found all of the items! Behold\\.\\.\\. the Jade Crystal!|You have already placed the Jade Crystal!)"); + + static { + items = new HashMap<>(); + items.put("Scavenged Lapis Sword", false); + items.put("Scavenged Golden Hammer", false); + items.put("Scavenged Diamond Axe", false); + items.put("Scavenged Emerald Hammer", false); + } + + public DivanMinesOverlay(Position position, Supplier<List<String>> dummyStrings, Supplier<TextOverlayStyle> styleSupplier) { + super(position, dummyStrings, styleSupplier); + } + + @Override + public void update() { + overlayStrings = null; + if (!NotEnoughUpdates.INSTANCE.config.mining.divanMinesOverlay || SBInfo.getInstance().getLocation() == null || + !SBInfo.getInstance().getLocation().equals("crystal_hollows") || !SBInfo.getInstance().location.equals("Mines of Divan")) + return; + + overlayStrings = new ArrayList<>(); + HashMap<String, String> states = new HashMap<>(); + for (String key : items.keySet()) { + Boolean has = items.get(key); + if (has) + states.put(key, EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.divanMinesDoneColor] + "Done"); + } + for (ItemStack item : mc.thePlayer.inventory.mainInventory) { + if (item != null) { + String name = Utils.cleanColour(item.getDisplayName()); + if (!states.containsKey(name)) { + states.put(name, EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.divanMinesInventoryColor] + "In Inventory"); + } + } + } + for (Map.Entry<Integer, Integer> entry : storageManager.storageConfig.displayToStorageIdMap.entrySet()) { + int storageId = entry.getValue(); + StorageManager.StoragePage page = storageManager.getPage(storageId, false); + if (page != null && page.rows > 0) { + for (ItemStack item : page.items) { + if (item != null) { + String name = Utils.cleanColour(item.getDisplayName()); + if (!states.containsKey(name)) { + states.put(name, EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.divanMinesStorageColor] + "In Storage"); + } + } + } + } + } + for (String key : items.keySet()) { + if (!NotEnoughUpdates.INSTANCE.config.mining.divanMinesHideDone || !items.get(key)) { + if (!states.containsKey(key)) + states.put(key, EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.divanMinesMissingColor] + "Missing"); + overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.divanMinesPartColor] + key + ": " + states.get(key)); + } + } + } + + public void message(String message) { + Matcher foundMatcher = foundPattern.matcher(message); + Matcher notFoundMatcher = notFoundPattern.matcher(message); + Matcher resetMatcher = resetPattern.matcher(message); + System.out.println(message); + if (foundMatcher.matches() && items.containsKey(foundMatcher.group("item"))) { + items.put(foundMatcher.group("item"), true); + } else if (notFoundMatcher.matches() && items.containsKey(notFoundMatcher.group("item"))) { + items.put(notFoundMatcher.group("item"), false); + } else if (resetMatcher.matches()) { + items.replaceAll((k, v) -> false); + } + } + + @Override + protected void renderLine(String line, Vector2f position, boolean dummy) { + if (!NotEnoughUpdates.INSTANCE.config.mining.divanMinesIcons) return; + GlStateManager.enableDepth(); + + ItemStack icon = null; + String cleaned = Utils.cleanColour(line); + String beforeColon = cleaned.split(":")[0]; + switch (beforeColon) { + case "Scavenged Lapis Sword": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("DWARVEN_LAPIS_SWORD")); + break; + case "Scavenged Golden Hammer": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("DWARVEN_GOLD_HAMMER")); + break; + case "Scavenged Diamond Axe": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("DWARVEN_DIAMOND_AXE")); + break; + case "Scavenged Emerald Hammer": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("DWARVEN_EMERALD_HAMMER")); + break; + } + + if (icon != null) { + GlStateManager.pushMatrix(); + GlStateManager.translate(position.x, position.y, 0); + GlStateManager.scale(0.5f, 0.5f, 1f); + Utils.drawItemStack(icon, 0, 0); + GlStateManager.popMatrix(); + + position.x += 12; + } + + super.renderLine(line, position, dummy); + } + + @Override + protected Vector2f getSize(List<String> strings) { + if (NotEnoughUpdates.INSTANCE.config.mining.divanMinesIcons) + return super.getSize(strings).translate(12, 0); + return super.getSize(strings); + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java index a08eef1e..0aa0d273 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java @@ -17,6 +17,7 @@ public class OverlayManager { public static TimersOverlay timersOverlay; public static BonemerangOverlay bonemerangOverlay; public static AutomatonOverlay automatonOverlay; + public static DivanMinesOverlay divanMinesOverlay; public static final List<TextOverlay> textOverlays = new ArrayList<>(); static { @@ -135,13 +136,26 @@ public class OverlayManager { } return TextOverlayStyle.BACKGROUND; }); - + List<String> divanMinesOverlayDummy = Lists.newArrayList( + "\u00a73Scavenged Lapis Sword: \u00a7aDone", + "\u00a73Scavenged Golden Hammer: \u00a7eIn Storage", + "\u00a73Scavenged Diamond Axe: \u00a7eIn Inventory", + "\u00a73Scavenged Emerald Hammer: \u00a7cMissing" + ); + divanMinesOverlay = new DivanMinesOverlay(NotEnoughUpdates.INSTANCE.config.mining.divanMinesOverlayPosition, () -> divanMinesOverlayDummy, () -> { + int style = NotEnoughUpdates.INSTANCE.config.mining.divanMinesOverlayStyle; + if(style >= 0 && style < TextOverlayStyle.values().length) { + return TextOverlayStyle.values()[style]; + } + return TextOverlayStyle.BACKGROUND; + }); textOverlays.add(miningOverlay); textOverlays.add(farmingOverlay); textOverlays.add(petInfoOverlay); textOverlays.add(bonemerangOverlay); textOverlays.add(automatonOverlay); + textOverlays.add(divanMinesOverlay); } } |