diff options
| author | Cow <cow@volloeko.de> | 2021-02-01 22:30:42 +0100 |
|---|---|---|
| committer | Cow <cow@volloeko.de> | 2021-02-01 22:30:42 +0100 |
| commit | f567357a8f625e63f8418d733604bfed0d265937 (patch) | |
| tree | dac404a556c075cff90d8abbef1fb844de1632c2 /src/main/java/de/cowtipper/cowlection/config | |
| parent | 50113a57f593d0aec94d8627826d95024085345c (diff) | |
| download | Cowlection-f567357a8f625e63f8418d733604bfed0d265937.tar.gz Cowlection-f567357a8f625e63f8418d733604bfed0d265937.tar.bz2 Cowlection-f567357a8f625e63f8418d733604bfed0d265937.zip | |
Added new Dungeon-related config options
- Dungeon Party Finder: Parties with specific classes can now *always* be marked as 'unideal'
- Dungeon Performance Overlay: added an alternative text border option
Diffstat (limited to 'src/main/java/de/cowtipper/cowlection/config')
3 files changed, 188 insertions, 56 deletions
diff --git a/src/main/java/de/cowtipper/cowlection/config/MooConfig.java b/src/main/java/de/cowtipper/cowlection/config/MooConfig.java index 85b55b1..c422236 100644 --- a/src/main/java/de/cowtipper/cowlection/config/MooConfig.java +++ b/src/main/java/de/cowtipper/cowlection/config/MooConfig.java @@ -90,7 +90,7 @@ public class MooConfig { public static int dungOverlayPositionX; public static int dungOverlayPositionY; public static int dungOverlayGuiScale; - public static boolean dungOverlayTextShadow; + private static String dungOverlayTextBorder; private static String dungPartyFinderPlayerLookup; public static boolean dungPartyFullLookup; public static boolean dungPartyFinderPartyLookup; @@ -98,11 +98,11 @@ public class MooConfig { public static int dungClassMin; private static String dungMarkPartiesWithCarry; private static String dungMarkPartiesWithHyperion; - private static boolean dungFilterPartiesWithArcherDupes; - private static boolean dungFilterPartiesWithBerserkDupes; - private static boolean dungFilterPartiesWithHealerDupes; - private static boolean dungFilterPartiesWithMageDupes; - private static boolean dungFilterPartiesWithTankDupes; + private static String dungMarkPartiesWithArcher; + private static String dungMarkPartiesWithBerserk; + private static String dungMarkPartiesWithHealer; + private static String dungMarkPartiesWithMage; + private static String dungMarkPartiesWithTank; private static Configuration cfg = null; private static final List<MooConfigCategory> configCategories = new ArrayList<>(); @@ -115,14 +115,18 @@ public class MooConfig { this.main = main; cfg = configuration; - if (cfg.getLoadedConfigVersion() == null || !cfg.getLoadedConfigVersion().equals(cfg.getDefinedConfigVersion())) { - updateConfig(cfg.getLoadedConfigVersion()); + String oldLoadedConfigVersion = cfg.getLoadedConfigVersion(); + boolean configVersionChanged = oldLoadedConfigVersion == null || !oldLoadedConfigVersion.equals(cfg.getDefinedConfigVersion()); + if (configVersionChanged) { + updateConfigPreInit(oldLoadedConfigVersion); } - initConfig(); + if (configVersionChanged) { + updateConfigPostInit(oldLoadedConfigVersion); + } } - private void updateConfig(String oldVersion) { + private void updateConfigPreInit(String oldVersion) { if (oldVersion == null) { // config of Cowlection v1.8.9-0.10.2 and older @@ -146,6 +150,34 @@ public class MooConfig { } } + private void updateConfigPostInit(String oldVersion) { + if ("1".equals(oldVersion)) { + // config of Cowlection v1.8.9-0.12.0 and older + ConfigCategory sbDungCategory = cfg.getCategory("skyblockdungeons"); + if (sbDungCategory.containsKey("dungOverlayTextShadow")) { + boolean dungOverlayTextShadow = sbDungCategory.get("dungOverlayTextShadow").getBoolean(); + if (!dungOverlayTextShadow) { + sbDungCategory.get("dungOverlayTextBorder").set("no border"); + } + sbDungCategory.remove("dungOverlayTextShadow"); + } + + for (String dungClass : new String[]{"Archer", "Berserk", "Healer", "Mage", "Tank"}) { + String configKey = "dungFilterPartiesWith" + dungClass + "Dupes"; + if (sbDungCategory.containsKey(configKey)) { + boolean filterPartiesWithX = sbDungCategory.get(configKey).getBoolean(); + String configKeyNew = "dungMarkPartiesWith" + dungClass; + if (filterPartiesWithX) { + sbDungCategory.get(configKeyNew).set("if duplicated"); + } + sbDungCategory.remove(configKey); + } + } + cfg.save(); + syncFromFile(); + } + } + private void initConfig() { syncFromFile(); MinecraftForge.EVENT_BUS.register(new ConfigEventHandler()); @@ -456,8 +488,8 @@ public class MooConfig { MooConfigGui.showDungeonPerformanceOverlayUntil = System.currentTimeMillis() + 500; }); - Property propDungOverlayTextShadow = subCat.addConfigEntry(cfg.get(configCat.getConfigName(), - "dungOverlayTextShadow", true, "Dungeon performance overlay GUI scale")); + Property propDungOverlayTextBorder = subCat.addConfigEntry(cfg.get(configCat.getConfigName(), + "dungOverlayTextBorder", "drop shadow", "Dungeon performance overlay text border", new String[]{"drop shadow", "full outline", "no border"})); // Sub-Category: Party Finder subCat = configCat.addSubCategory("Dungeon Party Finder"); @@ -500,25 +532,25 @@ public class MooConfig { new String[]{"suitable " + EnumChatFormatting.GREEN + "⬛", "unideal " + EnumChatFormatting.GOLD + "⬛", "block " + EnumChatFormatting.RED + "⬛", "do not mark"}), new MooConfigPreview(new MooChatComponent("Marked with: " + EnumChatFormatting.AQUA + "hyper").gray())); - Property propDungFilterPartiesWithArcherDupes = subCat.addConfigEntry(cfg.get(configCat.getConfigName(), - "dungFilterPartiesWithArcherDupes", true, "Mark parties with duplicated Archer class?"), - new MooConfigPreview(new MooChatComponent("Marked with: " + EnumChatFormatting.GOLD + "²⁺" + EnumChatFormatting.YELLOW + "A").gray())); + Property propDungMarkPartiesWithArcher = subCat.addConfigEntry(cfg.get(configCat.getConfigName(), + "dungMarkPartiesWithArcher", "if duplicated", "Mark parties with Archer class?", new String[]{"always", "if duplicated", "do not mark"}), + new MooConfigPreview(DataHelper.DungeonClass.ARCHER)); - Property propDungFilterPartiesWithBerserkDupes = subCat.addConfigEntry(cfg.get(configCat.getConfigName(), - "dungFilterPartiesWithBerserkDupes", false, "Mark parties with duplicated Berserk class?"), - new MooConfigPreview(new MooChatComponent("Marked with: " + EnumChatFormatting.GOLD + "²⁺" + EnumChatFormatting.YELLOW + "B").gray())); + Property propDungMarkPartiesWithBerserk = subCat.addConfigEntry(cfg.get(configCat.getConfigName(), + "dungMarkPartiesWithBerserk", "do not mark", "Mark parties with Berserk class?", new String[]{"always", "if duplicated", "do not mark"}), + new MooConfigPreview(DataHelper.DungeonClass.BERSERK)); - Property propDungFilterPartiesWithHealerDupes = subCat.addConfigEntry(cfg.get(configCat.getConfigName(), - "dungFilterPartiesWithHealerDupes", false, "Mark parties with duplicated Healer class?"), - new MooConfigPreview(new MooChatComponent("Marked with: " + EnumChatFormatting.GOLD + "²⁺" + EnumChatFormatting.YELLOW + "H").gray())); + Property propDungMarkPartiesWithHealer = subCat.addConfigEntry(cfg.get(configCat.getConfigName(), + "dungMarkPartiesWithHealer", "do not mark", "Mark parties with Healer class?", new String[]{"always", "if duplicated", "do not mark"}), + new MooConfigPreview(DataHelper.DungeonClass.HEALER)); - Property propDungFilterPartiesWithMageDupes = subCat.addConfigEntry(cfg.get(configCat.getConfigName(), - "dungFilterPartiesWithMageDupes", false, "Mark parties with duplicated Mage class?"), - new MooConfigPreview(new MooChatComponent("Marked with: " + EnumChatFormatting.GOLD + "²⁺" + EnumChatFormatting.YELLOW + "M").gray())); + Property propDungMarkPartiesWithMage = subCat.addConfigEntry(cfg.get(configCat.getConfigName(), + "dungMarkPartiesWithMage", "do not mark", "Mark parties with Mage class?", new String[]{"always", "if duplicated", "do not mark"}), + new MooConfigPreview(DataHelper.DungeonClass.MAGE)); - Property propDungFilterPartiesWithTankDupes = subCat.addConfigEntry(cfg.get(configCat.getConfigName(), - "dungFilterPartiesWithTankDupes", false, "Mark parties with duplicated Tank class?"), - new MooConfigPreview(new MooChatComponent("Marked with: " + EnumChatFormatting.GOLD + "²⁺" + EnumChatFormatting.YELLOW + "T").gray())); + Property propDungMarkPartiesWithTank = subCat.addConfigEntry(cfg.get(configCat.getConfigName(), + "dungMarkPartiesWithTank", "do not mark", "Mark parties with Tank class?", new String[]{"always", "if duplicated", "do not mark"}), + new MooConfigPreview(DataHelper.DungeonClass.TANK)); boolean modifiedMooCmdAlias = false; String mooCmdAliasPreChange = mooCmdAlias; @@ -566,7 +598,7 @@ public class MooConfig { dungOverlayPositionX = propDungOverlayPositionX.getInt(); dungOverlayPositionY = propDungOverlayPositionY.getInt(); dungOverlayGuiScale = propDungOverlayGuiScale.getInt(); - dungOverlayTextShadow = propDungOverlayTextShadow.getBoolean(); + dungOverlayTextBorder = propDungOverlayTextBorder.getString(); dungPartyFinderPlayerLookup = propDungPartyFinderPlayerLookup.getString(); dungPartyFullLookup = propDungPartyFullLookup.getBoolean(); dungPartyFinderPartyLookup = propDungPartyFinderPartyLookup.getBoolean(); @@ -574,11 +606,11 @@ public class MooConfig { dungClassMin = propDungClassMin.getInt(); dungMarkPartiesWithCarry = propDungMarkPartiesWithCarry.getString(); dungMarkPartiesWithHyperion = propDungMarkPartiesWithHyperion.getString(); - dungFilterPartiesWithArcherDupes = propDungFilterPartiesWithArcherDupes.getBoolean(); - dungFilterPartiesWithBerserkDupes = propDungFilterPartiesWithBerserkDupes.getBoolean(); - dungFilterPartiesWithHealerDupes = propDungFilterPartiesWithHealerDupes.getBoolean(); - dungFilterPartiesWithMageDupes = propDungFilterPartiesWithMageDupes.getBoolean(); - dungFilterPartiesWithTankDupes = propDungFilterPartiesWithTankDupes.getBoolean(); + dungMarkPartiesWithArcher = propDungMarkPartiesWithArcher.getString(); + dungMarkPartiesWithBerserk = propDungMarkPartiesWithBerserk.getString(); + dungMarkPartiesWithHealer = propDungMarkPartiesWithHealer.getString(); + dungMarkPartiesWithMage = propDungMarkPartiesWithMage.getString(); + dungMarkPartiesWithTank = propDungMarkPartiesWithTank.getString(); if (!StringUtils.equals(mooCmdAliasPreChange, mooCmdAlias)) { @@ -630,7 +662,7 @@ public class MooConfig { propDungOverlayPositionX.set(dungOverlayPositionX); propDungOverlayPositionY.set(dungOverlayPositionY); propDungOverlayGuiScale.set(dungOverlayGuiScale); - propDungOverlayTextShadow.set(dungOverlayTextShadow); + propDungOverlayTextBorder.set(dungOverlayTextBorder); propDungPartyFinderPlayerLookup.set(dungPartyFinderPlayerLookup); propDungPartyFullLookup.set(dungPartyFullLookup); propDungPartyFinderPartyLookup.set(dungPartyFinderPartyLookup); @@ -638,11 +670,11 @@ public class MooConfig { propDungClassMin.set(dungClassMin); propDungMarkPartiesWithCarry.set(dungMarkPartiesWithCarry); propDungMarkPartiesWithHyperion.set(dungMarkPartiesWithHyperion); - propDungFilterPartiesWithArcherDupes.set(dungFilterPartiesWithArcherDupes); - propDungFilterPartiesWithBerserkDupes.set(dungFilterPartiesWithBerserkDupes); - propDungFilterPartiesWithHealerDupes.set(dungFilterPartiesWithHealerDupes); - propDungFilterPartiesWithMageDupes.set(dungFilterPartiesWithMageDupes); - propDungFilterPartiesWithTankDupes.set(dungFilterPartiesWithTankDupes); + propDungMarkPartiesWithArcher.set(dungMarkPartiesWithArcher); + propDungMarkPartiesWithBerserk.set(dungMarkPartiesWithBerserk); + propDungMarkPartiesWithHealer.set(dungMarkPartiesWithHealer); + propDungMarkPartiesWithMage.set(dungMarkPartiesWithMage); + propDungMarkPartiesWithTank.set(dungMarkPartiesWithTank); if (saveToFile && cfg.hasChanged()) { boolean isPlayerIngame = Minecraft.getMinecraft().thePlayer != null; @@ -793,6 +825,18 @@ public class MooConfig { return dungItemToolTipToggleKeyBinding > 0 && Keyboard.isKeyDown(dungItemToolTipToggleKeyBinding); } + public static Setting getDungOverlayTextBorder() { + switch (dungOverlayTextBorder) { + case "drop shadow": + return Setting.TEXT; + case "full outline": + return Setting.ALWAYS; + default: + // everything else: "no border" + return Setting.DISABLED; + } + } + public static Setting getDungPartyFinderPlayerLookupDisplay() { return Setting.get(dungPartyFinderPlayerLookup); } @@ -819,20 +863,35 @@ public class MooConfig { } } - public static boolean filterDungPartiesWithDupes(DataHelper.DungeonClass dungeonClass) { + public static Setting filterDungPartiesWithDupes(DataHelper.DungeonClass dungeonClass) { + String setting; switch (dungeonClass) { case ARCHER: - return dungFilterPartiesWithArcherDupes; + setting = dungMarkPartiesWithArcher; + break; case BERSERK: - return dungFilterPartiesWithBerserkDupes; + setting = dungMarkPartiesWithBerserk; + break; case HEALER: - return dungFilterPartiesWithHealerDupes; + setting = dungMarkPartiesWithHealer; + break; case MAGE: - return dungFilterPartiesWithMageDupes; + setting = dungMarkPartiesWithMage; + break; case TANK: - return dungFilterPartiesWithTankDupes; + setting = dungMarkPartiesWithTank; + break; default: - return false; + setting = "do not mark"; + break; + } + switch (setting) { + case "always": + return Setting.ALWAYS; + case "if duplicated": + return Setting.SPECIAL; + default: // do not mark + return Setting.DISABLED; } } diff --git a/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigCategoryScrolling.java b/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigCategoryScrolling.java index 4ffa9f0..7e8f3eb 100644 --- a/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigCategoryScrolling.java +++ b/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigCategoryScrolling.java @@ -134,7 +134,12 @@ public class MooConfigCategoryScrolling extends GuiListExtended { EnumChatFormatting.GOLD + "Press Done to save changes. " + EnumChatFormatting.RED + "Requires a game restart to take effect!")))); continue; } else if (configEntry.getValidValues() != null && configEntry.getValidValues().length > 0) { - this.listEntries.add(new CycleConfigEntry(configEntry)); + if ("dungOverlayTextBorder".equals(configEntry.getName())) { + // special case: Dung Performance Overlay: show preview on button click + this.listEntries.add(new DungCycleConfigEntry(configEntry)); + } else { + this.listEntries.add(new CycleConfigEntry(configEntry)); + } continue; } } @@ -671,6 +676,18 @@ public class MooConfigCategoryScrolling extends GuiListExtended { } } + private class DungCycleConfigEntry extends CycleConfigEntry { + private DungCycleConfigEntry(Property property) { + super(property); + } + + @Override + protected void changeConfigEntryButtonPressed() { + super.changeConfigEntryButtonPressed(); + MooConfigGui.showDungeonPerformanceOverlayUntil = System.currentTimeMillis() + 3000; + } + } + private class CycleConfigEntry extends ButtonConfigEntry { protected final int beforeIndex; protected final int defaultIndex; diff --git a/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigPreview.java b/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigPreview.java index 32fb6d9..675c392 100644 --- a/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigPreview.java +++ b/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigPreview.java @@ -1,5 +1,7 @@ package de.cowtipper.cowlection.config.gui; +import de.cowtipper.cowlection.config.MooConfig; +import de.cowtipper.cowlection.data.DataHelper; import de.cowtipper.cowlection.util.MooChatComponent; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -40,6 +42,11 @@ public class MooConfigPreview { this.items = items; } + public MooConfigPreview(PreviewChatRunnable previewRunnable) { + this.type = Type.RUNNABLE; + this.previewRunnable = previewRunnable; + } + public MooConfigPreview(String sound, float volume, float pitch) { this.type = Type.RUNNABLE_ON_HOVER; previewRunnable = () -> { @@ -49,6 +56,26 @@ public class MooConfigPreview { }; } + public MooConfigPreview(DataHelper.DungeonClass dungeonClass) { + this(new MooConfigPreview.PreviewChatRunnable() { + @Override + public IChatComponent getText() { + String markWith; + switch (MooConfig.filterDungPartiesWithDupes(dungeonClass)) { + case ALWAYS: + markWith = "" + EnumChatFormatting.WHITE + dungeonClass.getShortName(); + break; + case SPECIAL: + markWith = EnumChatFormatting.GOLD + "²⁺" + EnumChatFormatting.YELLOW + dungeonClass.getShortName(); + break; + default: // disabled/"do not mark": + markWith = "" + EnumChatFormatting.DARK_GRAY + EnumChatFormatting.ITALIC + "not marked"; + } + return new MooChatComponent("Marked with: " + markWith).gray(); + } + }); + } + public void drawPreview(int x, int y, int mouseX, int mouseY, boolean enablePreview) { switch (type) { case ITEM: @@ -57,8 +84,11 @@ public class MooConfigPreview { case CHAT: drawChatPreview(x, y, mouseX, mouseY, enablePreview); break; + case RUNNABLE: + drawButtonWithRunnablePreview(x, y, mouseX, mouseY, false); + break; case RUNNABLE_ON_HOVER: - drawButtonWithRunnablePreview(x, y, mouseX, mouseY, enablePreview); + drawButtonWithRunnablePreview(x, y, mouseX, mouseY, true); break; default: // do nothing @@ -187,22 +217,48 @@ public class MooConfigPreview { return new MooChatComponent(name).darkGreen().setHover(new MooChatComponent(gameMode).yellow().appendFreshSibling(new MooChatComponent("Online for " + onlineTime).white())); } - private void drawButtonWithRunnablePreview(int x, int y, int mouseX, int mouseY, boolean enablePreview) { + private void drawButtonWithRunnablePreview(int x, int y, int mouseX, int mouseY, boolean checkHover) { FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; int currentX = x + 15; int chatY = y + 20 / 2 - fontRenderer.FONT_HEIGHT / 2; - String previewText = "(hover me to preview)"; - fontRenderer.drawStringWithShadow(previewText, currentX, chatY, 0xffffffff); - if (nextPreviewAt < Minecraft.getSystemTime() - && mouseY >= chatY && mouseY <= chatY + fontRenderer.FONT_HEIGHT - && mouseX > currentX && mouseX < currentX + fontRenderer.getStringWidth(previewText)) { - nextPreviewAt = Minecraft.getSystemTime() + 3000; + if (previewRunnable instanceof PreviewChatRunnable) { + ((PreviewChatRunnable) previewRunnable).setPos(x, y); previewRunnable.run(); + } else { + String previewText = "(hover me to preview)"; + fontRenderer.drawStringWithShadow(previewText, currentX, chatY, 0xffffffff); + if (checkHover && nextPreviewAt < Minecraft.getSystemTime() + && mouseY >= chatY && mouseY <= chatY + fontRenderer.FONT_HEIGHT + && mouseX > currentX && mouseX < currentX + fontRenderer.getStringWidth(previewText)) { + nextPreviewAt = Minecraft.getSystemTime() + 3000; + previewRunnable.run(); + } + } + } + + public abstract static class PreviewChatRunnable implements Runnable { + private int x; + private int y; + + public void setPos(int x, int y) { + this.x = x; + this.y = y; + } + + public abstract IChatComponent getText(); + + @Override + public void run() { + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; + int currentX = x + 15; + int chatY = y + 20 / 2 - fontRenderer.FONT_HEIGHT / 2; + + fontRenderer.drawStringWithShadow(getText().getFormattedText(), currentX, chatY, 0xffffffff); } } private enum Type { - CHAT, ITEM, RUNNABLE_ON_HOVER + CHAT, ITEM, RUNNABLE, RUNNABLE_ON_HOVER } } |
