diff options
| author | Cow <cow@volloeko.de> | 2020-09-24 17:58:17 +0200 |
|---|---|---|
| committer | Cow <cow@volloeko.de> | 2020-09-24 17:58:17 +0200 |
| commit | 7d4f2b900254d961b847f573237e3e6f40bff8e9 (patch) | |
| tree | 8fa85fc9212ffc9b8a16796c682d87667ec294a5 /src/main/java/de/cowtipper/cowlection/search | |
| parent | 705299e37d27d421156a09213e0654d0ab4fb01c (diff) | |
| download | Cowlection-7d4f2b900254d961b847f573237e3e6f40bff8e9.tar.gz Cowlection-7d4f2b900254d961b847f573237e3e6f40bff8e9.tar.bz2 Cowlection-7d4f2b900254d961b847f573237e3e6f40bff8e9.zip | |
Config (gui) rework
- Completely re-done the config gui (`/moo config`)
- Improved SkyBlock dungeon party finder
- Improved SkyBlock dungeon performance overlay
- Improved handling of invalid/missing Hypixel API key
- minor text fixes
Diffstat (limited to 'src/main/java/de/cowtipper/cowlection/search')
| -rw-r--r-- | src/main/java/de/cowtipper/cowlection/search/GuiSearch.java | 45 | ||||
| -rw-r--r-- | src/main/java/de/cowtipper/cowlection/search/LogFilesSearcher.java | 4 |
2 files changed, 29 insertions, 20 deletions
diff --git a/src/main/java/de/cowtipper/cowlection/search/GuiSearch.java b/src/main/java/de/cowtipper/cowlection/search/GuiSearch.java index ed1a1d9..f9b68a1 100644 --- a/src/main/java/de/cowtipper/cowlection/search/GuiSearch.java +++ b/src/main/java/de/cowtipper/cowlection/search/GuiSearch.java @@ -5,6 +5,7 @@ import com.mojang.realmsclient.util.Pair; import de.cowtipper.cowlection.Cowlection; import de.cowtipper.cowlection.config.MooConfig; import de.cowtipper.cowlection.data.LogEntry; +import de.cowtipper.cowlection.util.GuiHelper; import de.cowtipper.cowlection.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.*; @@ -13,11 +14,13 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IChatComponent; -import net.minecraftforge.common.ForgeVersion; +import net.minecraftforge.common.config.ConfigElement; +import net.minecraftforge.common.config.Property; import net.minecraftforge.fml.client.GuiScrollingList; import net.minecraftforge.fml.client.config.GuiButtonExt; import net.minecraftforge.fml.client.config.GuiCheckBox; -import net.minecraftforge.fml.client.config.GuiUtils; +import net.minecraftforge.fml.client.config.GuiConfig; +import net.minecraftforge.fml.client.config.IConfigElement; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.reflect.FieldUtils; @@ -67,6 +70,7 @@ public class GuiSearch extends GuiScreen { private GuiButton buttonSearch; private GuiButton buttonClose; private GuiButton buttonHelp; + private GuiButton buttonSettings; private GuiCheckBox checkboxChatOnly; private GuiCheckBox checkboxMatchCase; private GuiCheckBox checkboxRemoveFormatting; @@ -107,6 +111,9 @@ public class GuiSearch extends GuiScreen { public void initGui() { this.guiTooltips = new ArrayList<>(); + // recalculate start date + this.dateStart = MooConfig.calculateStartDate(); + this.fieldSearchQuery = new GuiTextField(42, this.fontRendererObj, this.width / 2 - 100, 13, 200, 20); this.fieldSearchQuery.setMaxStringLength(255); this.fieldSearchQuery.setText(searchQuery); @@ -131,8 +138,11 @@ public class GuiSearch extends GuiScreen { this.buttonList.add(this.buttonClose = new GuiButtonExt(0, this.width - 25, 3, 22, 20, EnumChatFormatting.RED + "X")); addTooltip(buttonClose, Arrays.asList(EnumChatFormatting.RED + "Close search interface", "" + EnumChatFormatting.GRAY + EnumChatFormatting.ITALIC + "Hint:" + EnumChatFormatting.RESET + " alternatively press ESC")); // help - this.buttonList.add(this.buttonHelp = new GuiButtonExt(1, this.width - 25 - 25, 3, 22, 20, "?")); + this.buttonList.add(this.buttonHelp = new GuiButtonExt(1, this.width - 2 * 25, 3, 22, 20, "?")); addTooltip(buttonHelp, Collections.singletonList(EnumChatFormatting.YELLOW + "Show help")); + // settings + this.buttonList.add(this.buttonSettings = new GuiButtonExt(1, this.width - 3 * 25, 3, 22, 20, "")); + addTooltip(buttonSettings, Collections.singletonList(EnumChatFormatting.YELLOW + "Open Settings")); // chatOnly this.buttonList.add(this.checkboxChatOnly = new GuiCheckBox(21, this.width / 2 - 100, 35, " Chatbox only", chatOnly)); @@ -255,10 +265,11 @@ public class GuiSearch extends GuiScreen { this.guiSearchResults.drawScreen(mouseX, mouseY, partialTicks); super.drawScreen(mouseX, mouseY, partialTicks); + GuiHelper.drawSprite(this.width - 3 * 25 + 2, 3, 36, 18, 500); for (GuiTooltip guiTooltip : guiTooltips) { if (guiTooltip.checkHover(mouseX, mouseY)) { - drawHoveringText(guiTooltip.getText(), mouseX, mouseY, 300); + GuiHelper.drawHoveringText(guiTooltip.getText(), mouseX, mouseY, width, height, 300); // only one tooltip can be displayed at a time: break! break; } @@ -310,10 +321,10 @@ public class GuiSearch extends GuiScreen { } else if (button == buttonHelp) { this.areEntriesSearchResults = false; this.searchResults.clear(); - this.searchResults.add(new LogEntry("" + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + "Initial setup/Configuration " + EnumChatFormatting.GRAY + EnumChatFormatting.ITALIC + "/moo config")); + this.searchResults.add(new LogEntry("" + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + "Initial setup/configuration " + EnumChatFormatting.GRAY + EnumChatFormatting.ITALIC + "'Open Settings' (top right corner)")); this.searchResults.add(new LogEntry(EnumChatFormatting.GOLD + " 1) " + EnumChatFormatting.RESET + "Configure directories that should be scanned for log files (\"Directories with Minecraft log files\")")); this.searchResults.add(new LogEntry(EnumChatFormatting.GOLD + " 2) " + EnumChatFormatting.RESET + "Set default starting date (\"Start date for log file search\")")); - this.searchResults.add(new LogEntry("" + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + "Performing a search " + EnumChatFormatting.GRAY + EnumChatFormatting.ITALIC + "/moo search")); + this.searchResults.add(new LogEntry("" + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + "Performing a search " + EnumChatFormatting.GRAY + EnumChatFormatting.ITALIC + "/moo search [initial search term]")); this.searchResults.add(new LogEntry(EnumChatFormatting.GOLD + " 1) " + EnumChatFormatting.RESET + "Enter search term")); this.searchResults.add(new LogEntry(EnumChatFormatting.GOLD + " 2) " + EnumChatFormatting.RESET + "Adjust start and end date")); this.searchResults.add(new LogEntry(EnumChatFormatting.GOLD + " 3) " + EnumChatFormatting.RESET + "Select desired options (match case, ...)")); @@ -324,6 +335,15 @@ public class GuiSearch extends GuiScreen { this.searchResults.add(new LogEntry(EnumChatFormatting.GOLD + " - " + EnumChatFormatting.YELLOW + "CTRL + A " + EnumChatFormatting.RESET + "to copy all search results")); this.searchResults.add(new LogEntry(EnumChatFormatting.GOLD + " - " + EnumChatFormatting.YELLOW + "Double click search result " + EnumChatFormatting.RESET + "to open corresponding log file in default text editor")); this.guiSearchResults.setResults(searchResults); + } else if (button == buttonSettings) { + List<IConfigElement> logSearchConfigElements = new ArrayList<>(); + for (Property configEntry : Cowlection.getInstance().getConfig().getLogSearchProperties()) { + logSearchConfigElements.add(new ConfigElement(configEntry)); + } + mc.displayGuiScreen(new GuiConfig(this, + logSearchConfigElements, + Cowlection.MODID, "cowlectionLogSearchConfig", false, false, + EnumChatFormatting.GOLD + "Press Done to save changes.")); } } @@ -350,17 +370,6 @@ public class GuiSearch extends GuiScreen { } } - private void drawHoveringText(List<String> textLines, int mouseX, int mouseY, int maxTextWidth) { - if (ForgeVersion.getBuildVersion() < 1808) { - // we're running a forge version from before 24 March 2016 (http://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.8.9.html for reference) - // using mc built-in method - drawHoveringText(textLines, mouseX, mouseY, fontRendererObj); - } else { - // we're on a newer forge version, so we can use the improved tooltip rendering added in 1.8.9-11.15.1.1808 (released 03/24/16 09:25 PM) in this pull request: https://github.com/MinecraftForge/MinecraftForge/pull/2649 - GuiUtils.drawHoveringText(textLines, mouseX, mouseY, width, height, maxTextWidth, fontRendererObj); - } - } - /** * List gui element similar to GuiModList.Info */ @@ -454,7 +463,7 @@ public class GuiSearch extends GuiScreen { int left = width / 2 - stringWidth / 2 - margin; int top = height / 2 - margin; drawRect(left, top, left + stringWidth + 2 * margin, top + fontRendererObj.FONT_HEIGHT + 2 * margin, 0xff000000); - drawCenteredString(fontRendererObj, errorText,/* 2, 30*/width / 2, height / 2, 0xffDD1111); + drawCenteredString(fontRendererObj, errorText, width / 2, height / 2, 0xffDD1111); } else { errorMessage = null; } diff --git a/src/main/java/de/cowtipper/cowlection/search/LogFilesSearcher.java b/src/main/java/de/cowtipper/cowlection/search/LogFilesSearcher.java index 636a46d..2e811ef 100644 --- a/src/main/java/de/cowtipper/cowlection/search/LogFilesSearcher.java +++ b/src/main/java/de/cowtipper/cowlection/search/LogFilesSearcher.java @@ -48,7 +48,7 @@ class LogFilesSearcher { } if (files.isEmpty()) { - throw new FileNotFoundException(EnumChatFormatting.DARK_RED + "ERROR: Couldn't find any Minecraft log files. Please check if the log file directories are set correctly (/moo config)."); + throw new FileNotFoundException(EnumChatFormatting.DARK_RED + "ERROR: Couldn't find any Minecraft log files. Please check if the log file directories are set correctly (Log Search \u27A1 Settings)."); } else { List<LogEntry> searchResults = analyzeFiles(files, searchQuery, chatOnly, matchCase, removeFormatting) .stream().sorted(Comparator.comparing(LogEntry::getTime)).collect(Collectors.toList()); @@ -65,7 +65,7 @@ class LogFilesSearcher { : new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(path.toFile())))))) { // ....log.gz String fileName = path.getFileName().toString(); // 2020-04-20-3.log.gz String date = fileName.equals("latest.log") - ? LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE) + ? DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(Files.getLastModifiedTime(path).toInstant()) : fileName.substring(0, fileName.lastIndexOf('-')); String content; LogEntry logEntry = null; |
