From 75b6600efbd0c7bceacd77cdd2336cc7e1d18048 Mon Sep 17 00:00:00 2001 From: DonkeyBlaster <57310593+DonkeyBlaster@users.noreply.github.com> Date: Wed, 12 Jul 2023 21:56:03 -0700 Subject: [PATCH 1/3] chore: Remove broken quest book --- .../modules/questbook/QuestBookModule.java | 2 +- .../questbook/events/ClientEvents.java | 2 +- .../instances/QuestBookListPage.java | 85 ++++++++++--------- .../questbook/managers/QuestManager.java | 2 +- .../questbook/overlays/ui/QuestsPage.java | 2 +- 5 files changed, 48 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/wynntils/modules/questbook/QuestBookModule.java b/src/main/java/com/wynntils/modules/questbook/QuestBookModule.java index 9e0867ebf..7ddb50dba 100644 --- a/src/main/java/com/wynntils/modules/questbook/QuestBookModule.java +++ b/src/main/java/com/wynntils/modules/questbook/QuestBookModule.java @@ -39,7 +39,7 @@ public void onEnable() { registerKeyBinding("Open HUD configuration", Keyboard.KEY_NONE, "Wynntils", KeyConflictContext.IN_GAME, true, () -> QuestBookPages.HUDCONFIG.getPage().open(true)); registerKeyBinding("Open Menu", Keyboard.KEY_I, "Wynntils", KeyConflictContext.IN_GAME, true, () -> { QuestBookPages.MAIN.getPage().open(true); - QuestManager.readQuestBook(); + //QuestManager.readQuestBook(); }); } diff --git a/src/main/java/com/wynntils/modules/questbook/events/ClientEvents.java b/src/main/java/com/wynntils/modules/questbook/events/ClientEvents.java index 203c489b3..716e0c567 100644 --- a/src/main/java/com/wynntils/modules/questbook/events/ClientEvents.java +++ b/src/main/java/com/wynntils/modules/questbook/events/ClientEvents.java @@ -146,7 +146,7 @@ public void updateQuestBook(TickEvent.ClientTickEvent e) { QuestBookPages.MAIN.getPage().open(true); - QuestManager.readQuestBook(); + //QuestManager.readQuestBook(); } private int tickCounter = 0; diff --git a/src/main/java/com/wynntils/modules/questbook/instances/QuestBookListPage.java b/src/main/java/com/wynntils/modules/questbook/instances/QuestBookListPage.java index 19c63d8da..76dc8fe74 100644 --- a/src/main/java/com/wynntils/modules/questbook/instances/QuestBookListPage.java +++ b/src/main/java/com/wynntils/modules/questbook/instances/QuestBookListPage.java @@ -12,6 +12,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -51,47 +52,49 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) { // Page Text render.drawString(currentPage + " / " + pages, x + 80, y + 88, CommonColors.BLACK, SmartFontRenderer.TextAlignment.MIDDLE, SmartFontRenderer.TextShadow.NONE); - - //Forward and backward button - drawForwardAndBackButtons(x, y, posX, posY, currentPage, pages); - - // Draw all Search Results - if (search.size() > 0) { - List page = search.get(currentPage - 1); - - if (page.size() > 0) { - for (int i = 0; i < page.size(); i++) { - T currentItem = page.get(i); - - if (isHovered(i, posX, posY) && !showAnimation) { - //hovered - drawEntry(currentItem, i, true); - - selectedEntry = currentItem; - //selected is set relative to the page - selected = i; - hoveredText = getHoveredText(selectedEntry); - } else { - if (selected == i) { - selectedEntry = null; - } - - //not hovered - drawEntry(currentItem, i, false); - } - } - } - } else { - String textToDisplay = getEmptySearchString(); - int currentY = 12; - - for (String line : textToDisplay.split("\n")) { - currentY += render.drawSplitString(line, 120, x + 26, y - 95 + currentY, 10, CommonColors.BLACK, SmartFontRenderer.TextAlignment.LEFT_RIGHT, SmartFontRenderer.TextShadow.NONE) * 10 + 2; - } - - updateSearch(); - } - postEntries(mouseX, mouseY, partialTicks); + List textLines = Arrays.asList("The Wynntils quest book is", "no longer available on 1.12.2.", "", "Wynntils 1.12.2 is being", "sunset in favour of newer", "Minecraft versions.", "", "Please download the latest", "version of the mod at", "https://wynntils.com"); + drawTextLines(textLines, x + 10, y - 40, 1); + +// //Forward and backward button +// drawForwardAndBackButtons(x, y, posX, posY, currentPage, pages); + +// // Draw all Search Results +// if (search.size() > 0) { +// List page = search.get(currentPage - 1); +// +// if (page.size() > 0) { +// for (int i = 0; i < page.size(); i++) { +// T currentItem = page.get(i); +// +// if (isHovered(i, posX, posY) && !showAnimation) { +// //hovered +// drawEntry(currentItem, i, true); +// +// selectedEntry = currentItem; +// //selected is set relative to the page +// selected = i; +// hoveredText = getHoveredText(selectedEntry); +// } else { +// if (selected == i) { +// selectedEntry = null; +// } +// +// //not hovered +// drawEntry(currentItem, i, false); +// } +// } +// } +// } else { +// String textToDisplay = getEmptySearchString(); +// int currentY = 12; +// +// for (String line : textToDisplay.split("\n")) { +// currentY += render.drawSplitString(line, 120, x + 26, y - 95 + currentY, 10, CommonColors.BLACK, SmartFontRenderer.TextAlignment.LEFT_RIGHT, SmartFontRenderer.TextShadow.NONE) * 10 + 2; +// } +// +// updateSearch(); +// } +// postEntries(mouseX, mouseY, partialTicks); } ScreenRenderer.endGL(); renderHoveredText(mouseX, mouseY); diff --git a/src/main/java/com/wynntils/modules/questbook/managers/QuestManager.java b/src/main/java/com/wynntils/modules/questbook/managers/QuestManager.java index 276d8d393..4f0bded08 100644 --- a/src/main/java/com/wynntils/modules/questbook/managers/QuestManager.java +++ b/src/main/java/com/wynntils/modules/questbook/managers/QuestManager.java @@ -68,7 +68,7 @@ public static void updateAnalysis(Collection position, boolean } if (immediate) { - readQuestBook(); + //readQuestBook(); } } diff --git a/src/main/java/com/wynntils/modules/questbook/overlays/ui/QuestsPage.java b/src/main/java/com/wynntils/modules/questbook/overlays/ui/QuestsPage.java index 08fd12675..3ff409e06 100644 --- a/src/main/java/com/wynntils/modules/questbook/overlays/ui/QuestsPage.java +++ b/src/main/java/com/wynntils/modules/questbook/overlays/ui/QuestsPage.java @@ -56,7 +56,7 @@ public List getHoveredDescription() { public void open(boolean showAnimation) { super.open(showAnimation); - QuestManager.readQuestBook(); + //QuestManager.readQuestBook(); } @Override From b457763967d9a7cb7b68cf085dd4746185ef6547 Mon Sep 17 00:00:00 2001 From: DonkeyBlaster <57310593+DonkeyBlaster@users.noreply.github.com> Date: Sat, 15 Jul 2023 17:50:08 -0700 Subject: [PATCH 2/3] fix: Allow access to guides and lootruns --- .../instances/QuestBookListPage.java | 96 ++++++++++--------- 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/wynntils/modules/questbook/instances/QuestBookListPage.java b/src/main/java/com/wynntils/modules/questbook/instances/QuestBookListPage.java index 76dc8fe74..fe8dd1c63 100644 --- a/src/main/java/com/wynntils/modules/questbook/instances/QuestBookListPage.java +++ b/src/main/java/com/wynntils/modules/questbook/instances/QuestBookListPage.java @@ -8,6 +8,9 @@ import com.wynntils.core.framework.rendering.ScreenRenderer; import com.wynntils.core.framework.rendering.SmartFontRenderer; import com.wynntils.core.framework.rendering.colors.CommonColors; +import com.wynntils.modules.questbook.overlays.ui.DialoguePage; +import com.wynntils.modules.questbook.overlays.ui.DiscoveriesPage; +import com.wynntils.modules.questbook.overlays.ui.QuestsPage; import net.minecraft.client.gui.ScaledResolution; import java.io.IOException; @@ -50,51 +53,54 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) { { preEntries(mouseX, mouseY, partialTicks); - // Page Text - render.drawString(currentPage + " / " + pages, x + 80, y + 88, CommonColors.BLACK, SmartFontRenderer.TextAlignment.MIDDLE, SmartFontRenderer.TextShadow.NONE); - List textLines = Arrays.asList("The Wynntils quest book is", "no longer available on 1.12.2.", "", "Wynntils 1.12.2 is being", "sunset in favour of newer", "Minecraft versions.", "", "Please download the latest", "version of the mod at", "https://wynntils.com"); - drawTextLines(textLines, x + 10, y - 40, 1); - -// //Forward and backward button -// drawForwardAndBackButtons(x, y, posX, posY, currentPage, pages); - -// // Draw all Search Results -// if (search.size() > 0) { -// List page = search.get(currentPage - 1); -// -// if (page.size() > 0) { -// for (int i = 0; i < page.size(); i++) { -// T currentItem = page.get(i); -// -// if (isHovered(i, posX, posY) && !showAnimation) { -// //hovered -// drawEntry(currentItem, i, true); -// -// selectedEntry = currentItem; -// //selected is set relative to the page -// selected = i; -// hoveredText = getHoveredText(selectedEntry); -// } else { -// if (selected == i) { -// selectedEntry = null; -// } -// -// //not hovered -// drawEntry(currentItem, i, false); -// } -// } -// } -// } else { -// String textToDisplay = getEmptySearchString(); -// int currentY = 12; -// -// for (String line : textToDisplay.split("\n")) { -// currentY += render.drawSplitString(line, 120, x + 26, y - 95 + currentY, 10, CommonColors.BLACK, SmartFontRenderer.TextAlignment.LEFT_RIGHT, SmartFontRenderer.TextShadow.NONE) * 10 + 2; -// } -// -// updateSearch(); -// } -// postEntries(mouseX, mouseY, partialTicks); + if (this instanceof QuestsPage || this instanceof DiscoveriesPage || this instanceof DialoguePage) { + // Page Text + render.drawString(currentPage + " / " + pages, x + 80, y + 88, CommonColors.BLACK, SmartFontRenderer.TextAlignment.MIDDLE, SmartFontRenderer.TextShadow.NONE); + List textLines = Arrays.asList("The Wynntils quest book is", "no longer available on 1.12.2.", "", "Wynntils 1.12.2 is being", "sunset in favour of newer", "Minecraft versions.", "", "Please download the latest", "version of the mod at", "https://wynntils.com"); + drawTextLines(textLines, x + 10, y - 40, 1); + + } else { + //Forward and backward button + drawForwardAndBackButtons(x, y, posX, posY, currentPage, pages); + + // Draw all Search Results + if (search.size() > 0) { + List page = search.get(currentPage - 1); + + if (page.size() > 0) { + for (int i = 0; i < page.size(); i++) { + T currentItem = page.get(i); + + if (isHovered(i, posX, posY) && !showAnimation) { + //hovered + drawEntry(currentItem, i, true); + + selectedEntry = currentItem; + //selected is set relative to the page + selected = i; + hoveredText = getHoveredText(selectedEntry); + } else { + if (selected == i) { + selectedEntry = null; + } + + //not hovered + drawEntry(currentItem, i, false); + } + } + } + } else { + String textToDisplay = getEmptySearchString(); + int currentY = 12; + + for (String line : textToDisplay.split("\n")) { + currentY += render.drawSplitString(line, 120, x + 26, y - 95 + currentY, 10, CommonColors.BLACK, SmartFontRenderer.TextAlignment.LEFT_RIGHT, SmartFontRenderer.TextShadow.NONE) * 10 + 2; + } + + updateSearch(); + } + postEntries(mouseX, mouseY, partialTicks); + } } ScreenRenderer.endGL(); renderHoveredText(mouseX, mouseY); From a271ca17650d59853aaeda3e758afa3d3d279af9 Mon Sep 17 00:00:00 2001 From: DonkeyBlaster <57310593+DonkeyBlaster@users.noreply.github.com> Date: Sun, 16 Jul 2023 02:02:01 -0700 Subject: [PATCH 3/3] feat: Export favorites via command --- .../modules/questbook/QuestBookModule.java | 3 +- .../commands/CommandExportFavorites.java | 60 +++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/wynntils/modules/questbook/commands/CommandExportFavorites.java diff --git a/src/main/java/com/wynntils/modules/questbook/QuestBookModule.java b/src/main/java/com/wynntils/modules/questbook/QuestBookModule.java index 7ddb50dba..e9b134c3d 100644 --- a/src/main/java/com/wynntils/modules/questbook/QuestBookModule.java +++ b/src/main/java/com/wynntils/modules/questbook/QuestBookModule.java @@ -8,11 +8,11 @@ import com.wynntils.core.framework.instances.Module; import com.wynntils.core.framework.interfaces.annotations.ModuleInfo; import com.wynntils.modules.questbook.commands.CommandExportDiscoveries; +import com.wynntils.modules.questbook.commands.CommandExportFavorites; import com.wynntils.modules.questbook.configs.QuestBookConfig; import com.wynntils.modules.questbook.enums.Guides; import com.wynntils.modules.questbook.enums.QuestBookPages; import com.wynntils.modules.questbook.events.ClientEvents; -import com.wynntils.modules.questbook.managers.QuestManager; import com.wynntils.modules.questbook.overlays.hud.TrackedQuestOverlay; import net.minecraftforge.client.settings.KeyConflictContext; import org.lwjgl.input.Keyboard; @@ -31,6 +31,7 @@ public void onEnable() { registerOverlay(new TrackedQuestOverlay(), Priority.HIGHEST); registerCommand(new CommandExportDiscoveries()); + registerCommand(new CommandExportFavorites()); registerKeyBinding("Open Quest Book", Keyboard.KEY_K, "Wynntils", KeyConflictContext.IN_GAME, true, () -> QuestBookPages.QUESTS.getPage().open(true)); registerKeyBinding("Open Discoveries", Keyboard.KEY_U, "Wynntils", KeyConflictContext.IN_GAME, true, () -> QuestBookPages.DISCOVERIES.getPage().open(true)); diff --git a/src/main/java/com/wynntils/modules/questbook/commands/CommandExportFavorites.java b/src/main/java/com/wynntils/modules/questbook/commands/CommandExportFavorites.java new file mode 100644 index 000000000..79670cfc1 --- /dev/null +++ b/src/main/java/com/wynntils/modules/questbook/commands/CommandExportFavorites.java @@ -0,0 +1,60 @@ +/* + * * Copyright © Wynntils - 2022. + */ + +package com.wynntils.modules.questbook.commands; + +import com.wynntils.McIf; +import com.wynntils.core.utils.Utils; +import com.wynntils.modules.utilities.configs.UtilitiesConfig; +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.event.ClickEvent; +import net.minecraftforge.client.IClientCommand; + +import java.util.ArrayList; +import java.util.List; + +public class CommandExportFavorites extends CommandBase implements IClientCommand { + + + @Override + public String getName() { + return "exportfavorites"; + } + + @Override + public boolean allowUsageWithoutPrefix(ICommandSender sender, String message) { + return false; + } + + @Override + public String getUsage(ICommandSender sender) { + return "exportfavorites"; + } + + @Override + public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { + ITextComponent command = new TextComponentString("/exportfavorites"); + command.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/exportfavorites")); + + List combinedList = new ArrayList<>(); + combinedList.addAll(UtilitiesConfig.INSTANCE.favoriteItems); + combinedList.addAll(UtilitiesConfig.INSTANCE.favoriteIngredients); + combinedList.addAll(UtilitiesConfig.INSTANCE.favoritePowders); + combinedList.addAll(UtilitiesConfig.INSTANCE.favoriteEmeraldPouches); + + Utils.copyToClipboard("wynntilsFavorites," + String.join(",", combinedList)); + McIf.player().sendMessage(new TextComponentString(TextFormatting.GREEN + "Copied favorites to clipboard! Open the guide list and click the + button on Artemis to import them.")); + } + + @Override + public int getRequiredPermissionLevel() { + return 0; + } +}