diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index a08c309339..0601816813 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -8,7 +8,7 @@ import de.hysky.skyblocker.config.datafixer.ConfigDataFixer; import de.hysky.skyblocker.skyblock.StatusBarTracker; import de.hysky.skyblocker.skyblock.item.tooltip.BackpackPreview; -import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.discord.DiscordRPCManager; import de.hysky.skyblocker.utils.scheduler.MessageScheduler; @@ -66,7 +66,7 @@ public void onInitializeClient() { Scheduler.INSTANCE.scheduleCyclic(Utils::update, 20); Scheduler.INSTANCE.scheduleCyclic(DiscordRPCManager::updateDataAndPresence, 200); Scheduler.INSTANCE.scheduleCyclic(BackpackPreview::tick, 50); - Scheduler.INSTANCE.scheduleCyclic(PlayerListMgr::updateList, 20); + Scheduler.INSTANCE.scheduleCyclic(PlayerListManager::updateList, 20); } /** diff --git a/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java index 890d86aa10..3eed81da63 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java @@ -7,6 +7,7 @@ import de.hysky.skyblocker.skyblock.dwarven.CrystalsHudWidget; import de.hysky.skyblocker.skyblock.dwarven.CarpetHighlighter; import de.hysky.skyblocker.skyblock.dwarven.PowderMiningTracker; +import de.hysky.skyblocker.skyblock.tabhud.widget.CommsWidget; import dev.isxander.yacl3.api.*; import dev.isxander.yacl3.api.controller.ColorControllerBuilder; import de.hysky.skyblocker.skyblock.tabhud.config.WidgetsConfigurationScreen; @@ -42,6 +43,12 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .controller(ConfigUtils::createBooleanController) .build()) + .option(ButtonOption.createBuilder() + .name(Text.translatable("skyblocker.config.mining.dwarvenHud.screen")) + .text(Text.translatable("text.skyblocker.open")) + .action((screen, opt) -> MinecraftClient.getInstance().setScreen(new WidgetsConfigurationScreen(Location.DWARVEN_MINES, CommsWidget.ID, screen))) + .build()) + //Dwarven Mines .group(OptionGroup.createBuilder() .name(Text.translatable("skyblocker.config.mining.dwarvenMines")) diff --git a/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java index 208113efd2..6d18c45175 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java @@ -240,6 +240,25 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig newValue -> config.uiAndVisuals.tabHud.tabHudScale = newValue) .controller(opt -> IntegerSliderControllerBuilder.create(opt).range(10, 200).step(1)) .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.uiAndVisuals.tabHud.showVanillaTabByDefault")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.uiAndVisuals.tabHud.showVanillaTabByDefault.@Tooltip"))) + .binding(defaults.uiAndVisuals.tabHud.showVanillaTabByDefault, + () -> config.uiAndVisuals.tabHud.showVanillaTabByDefault, + newValue -> config.uiAndVisuals.tabHud.showVanillaTabByDefault = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.uiAndVisuals.tabHud.style")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.uiAndVisuals.tabHud.style.@Tooltip[0]"), + Text.translatable("skyblocker.config.uiAndVisuals.tabHud.style.@Tooltip[1]"), + Text.translatable("skyblocker.config.uiAndVisuals.tabHud.style.@Tooltip[2]"), + Text.translatable("skyblocker.config.uiAndVisuals.tabHud.style.@Tooltip[3]"))) + .binding(defaults.uiAndVisuals.tabHud.style, + () -> config.uiAndVisuals.tabHud.style, + newValue -> config.uiAndVisuals.tabHud.style = newValue) + .controller(ConfigUtils::createEnumCyclingListController) + .build()) .option(Option.createBuilder() .name(Text.translatable("skyblocker.config.uiAndVisuals.tabHud.enableHudBackground")) .description(OptionDescription.of(Text.translatable("skyblocker.config.uiAndVisuals.tabHud.enableHudBackground.@Tooltip"))) diff --git a/src/main/java/de/hysky/skyblocker/config/configs/MiningConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/MiningConfig.java index f73f38a9b9..34c594299c 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/MiningConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/MiningConfig.java @@ -175,6 +175,10 @@ public static class Glacite { public boolean autoShareCorpses = false; } + /** + * @deprecated See {@link UIAndVisualsConfig.TabHudStyle}. + */ + @Deprecated public enum DwarvenHudStyle { SIMPLE, FANCY, CLASSIC; diff --git a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java index aaf6e9dfa4..7a6b3f5daa 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java @@ -187,6 +187,12 @@ public static class TabHudConf { @SerialEntry public int tabHudScale = 100; + @SerialEntry + public boolean showVanillaTabByDefault = false; + + @SerialEntry + public TabHudStyle style = TabHudStyle.FANCY; + @SerialEntry public boolean enableHudBackground = true; @@ -203,6 +209,36 @@ public static class TabHudConf { public NameSorting nameSorting = NameSorting.DEFAULT; } + public enum TabHudStyle { + /** + * The minimal style, with no decorations, icons, or custom components, + * rendered in a minimal rectangle background, + * or no background at all if {@link TabHudConf#enableHudBackground} is false. + */ + MINIMAL, + /** + * The simple style, with no decorations, icons, or custom components. + */ + SIMPLE, + /** + * The classic style, with decorations such as icons but no custom components. + */ + CLASSIC, + /** + * The default style, with all custom components and decorations in use. + */ + FANCY; + + public boolean isMinimal() { + return this == MINIMAL; + } + + @Override + public String toString() { + return I18n.translate("skyblocker.config.uiAndVisuals.tabHud.style." + name()); + } + } + @Deprecated public enum NameSorting { DEFAULT, ALPHABETICAL; diff --git a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java index cf4d2060f0..258d6a448f 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -18,7 +18,7 @@ import de.hysky.skyblocker.skyblock.end.TheEnd; import de.hysky.skyblocker.skyblock.slayers.SlayerManager; import de.hysky.skyblocker.skyblock.slayers.boss.demonlord.FirePillarAnnouncer; -import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; import de.hysky.skyblocker.skyblock.waypoint.MythologicalRitual; import de.hysky.skyblocker.utils.Utils; import net.minecraft.client.network.ClientPlayNetworkHandler; @@ -101,7 +101,7 @@ public abstract class ClientPlayNetworkHandlerMixin { @Inject(method = "onPlayerListHeader", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/PlayerListHud;setFooter(Lnet/minecraft/text/Text;)V")) private void skyblocker$updatePlayerListFooter(PlayerListHeaderS2CPacket packet, CallbackInfo ci) { - PlayerListMgr.updateFooter(packet.footer()); + PlayerListManager.updateFooter(packet.footer()); } @WrapWithCondition(method = "onPlayerList", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", remap = false)) diff --git a/src/main/java/de/hysky/skyblocker/mixins/InGameHudMixin.java b/src/main/java/de/hysky/skyblocker/mixins/InGameHudMixin.java index d837311909..a41a27763c 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/InGameHudMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/InGameHudMixin.java @@ -24,7 +24,6 @@ import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.gui.hud.PlayerListHud; import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.RenderTickCounter; import net.minecraft.client.util.Window; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerEntity; @@ -202,6 +201,6 @@ public abstract class InGameHudMixin { @WrapWithCondition(method = "renderPlayerList", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/PlayerListHud;render(Lnet/minecraft/client/gui/DrawContext;ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreboardObjective;)V")) private boolean skyblocker$shouldRenderHud(PlayerListHud playerListHud, DrawContext context, int scaledWindowWidth, Scoreboard scoreboard, ScoreboardObjective objective) { - return !Utils.isOnSkyblock() || !SkyblockerConfigManager.get().uiAndVisuals.tabHud.tabHudEnabled || TabHud.defaultTgl.isPressed() || MinecraftClient.getInstance().currentScreen instanceof WidgetsConfigurationScreen; + return !Utils.isOnSkyblock() || !SkyblockerConfigManager.get().uiAndVisuals.tabHud.tabHudEnabled || TabHud.shouldRenderVanilla() || MinecraftClient.getInstance().currentScreen instanceof WidgetsConfigurationScreen; } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonScore.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonScore.java index a00025d0e6..56ae089de1 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonScore.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonScore.java @@ -7,7 +7,7 @@ import de.hysky.skyblocker.config.configs.DungeonsConfig; import de.hysky.skyblocker.events.DungeonEvents; import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonManager; -import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; import de.hysky.skyblocker.utils.Constants; import de.hysky.skyblocker.utils.ProfileUtils; import de.hysky.skyblocker.utils.Utils; @@ -231,7 +231,7 @@ private static int getTotalRooms() { } private static int getCompletedRooms() { - Matcher matcher = PlayerListMgr.regexAt(43, COMPLETED_ROOMS_PATTERN); + Matcher matcher = PlayerListManager.regexAt(43, COMPLETED_ROOMS_PATTERN); return matcher != null ? Integer.parseInt(matcher.group("rooms")) : 0; } @@ -259,14 +259,14 @@ private static int getDeathScorePenalty() { } private static int getPuzzleCount() { - Matcher matcher = PlayerListMgr.regexAt(47, PUZZLE_COUNT_PATTERN); + Matcher matcher = PlayerListManager.regexAt(47, PUZZLE_COUNT_PATTERN); return matcher != null ? Integer.parseInt(matcher.group("count")) : 0; } private static int getPuzzlePenalty() { int incompletePuzzles = 0; for (int index = 0; index < puzzleCount; index++) { - Matcher puzzleMatcher = PlayerListMgr.regexAt(48 + index, PUZZLES_PATTERN); + Matcher puzzleMatcher = PlayerListManager.regexAt(48 + index, PUZZLES_PATTERN); if (puzzleMatcher == null) break; if (puzzleMatcher.group("state").matches("[✖✦]")) incompletePuzzles++; } @@ -274,13 +274,13 @@ private static int getPuzzlePenalty() { } private static double getSecretsPercentage() { - Matcher matcher = PlayerListMgr.regexAt(44, SECRETS_PATTERN); + Matcher matcher = PlayerListManager.regexAt(44, SECRETS_PATTERN); return matcher != null ? Double.parseDouble(matcher.group("secper")) : 0; } private static int getCrypts() { - Matcher matcher = PlayerListMgr.regexAt(33, CRYPTS_PATTERN); - if (matcher == null) matcher = PlayerListMgr.regexAt(32, CRYPTS_PATTERN); //If class milestone 9 is reached, crypts goes up by 1 + Matcher matcher = PlayerListManager.regexAt(33, CRYPTS_PATTERN); + if (matcher == null) matcher = PlayerListManager.regexAt(32, CRYPTS_PATTERN); //If class milestone 9 is reached, crypts goes up by 1 return matcher != null ? Integer.parseInt(matcher.group("crypts")) : 0; } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/DungeonPlayerManager.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/DungeonPlayerManager.java index 6a5160073d..4c3a0e8c02 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/DungeonPlayerManager.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/DungeonPlayerManager.java @@ -8,7 +8,7 @@ import de.hysky.skyblocker.annotations.Init; import de.hysky.skyblocker.events.DungeonEvents; import de.hysky.skyblocker.skyblock.dungeon.DungeonClass; -import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; import it.unimi.dsi.fastutil.objects.Object2ReferenceMap; import it.unimi.dsi.fastutil.objects.Object2ReferenceOpenHashMap; import net.minecraft.entity.player.PlayerEntity; @@ -51,6 +51,6 @@ private static void reset() { } private static Matcher getPlayerFromTab(@Range(from = 1, to = 5) int index) { - return PlayerListMgr.regexAt(1 + (index - 1) * 4, PLAYER_TAB_PATTERN); + return PlayerListManager.regexAt(1 + (index - 1) * 4, PLAYER_TAB_PATTERN); } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/SecretsTracker.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/SecretsTracker.java index 31d0aba05c..2cf700bb5f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/SecretsTracker.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/SecretsTracker.java @@ -5,7 +5,7 @@ import de.hysky.skyblocker.annotations.Init; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.events.DungeonEvents; -import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; import de.hysky.skyblocker.skyblock.tabhud.widget.DungeonPlayerWidget; import de.hysky.skyblocker.utils.ApiUtils; import de.hysky.skyblocker.utils.Constants; @@ -131,7 +131,7 @@ private static void onMessage(Text text, boolean overlay) { } private static String getPlayerNameAt(int index) { - Matcher matcher = PlayerListMgr.regexAt(1 + (index - 1) * 4, DungeonPlayerWidget.PLAYER_PATTERN); + Matcher matcher = PlayerListManager.regexAt(1 + (index - 1) * 4, DungeonPlayerWidget.PLAYER_PATTERN); return matcher != null ? matcher.group("name") : ""; } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/WishingCompassSolver.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/WishingCompassSolver.java index 4b04430dc5..e7f4a6b7d6 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/WishingCompassSolver.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/WishingCompassSolver.java @@ -2,7 +2,7 @@ import de.hysky.skyblocker.annotations.Init; import de.hysky.skyblocker.config.SkyblockerConfigManager; -import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; import de.hysky.skyblocker.utils.Constants; import de.hysky.skyblocker.utils.Utils; import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; @@ -110,11 +110,11 @@ private static boolean isKingsScentPresent() { return false; } //make sure the data is in tab and if not tell the user - if (PlayerListMgr.getPlayerStringList().stream().noneMatch(entry -> entry.startsWith("Active Effects:"))) { + if (PlayerListManager.getPlayerStringList().stream().noneMatch(entry -> entry.startsWith("Active Effects:"))) { CLIENT.player.sendMessage(Constants.PREFIX.get().append(Text.translatable("skyblocker.config.mining.crystalsWaypoints.wishingCompassSolver.enableTabEffectsMessage")), false); return false; } - return PlayerListMgr.getPlayerStringList().stream().anyMatch(entry -> entry.startsWith("King's Scent")); + return PlayerListManager.getPlayerStringList().stream().anyMatch(entry -> entry.startsWith("King's Scent")); } private static boolean isKeyInInventory() { @@ -131,13 +131,13 @@ private static Boolean isZoneComplete(Zone zone) { } //make sure the data is in tab and if not tell the user - if (PlayerListMgr.getPlayerStringList().stream().noneMatch(entry -> entry.equals("Crystals:"))) { + if (PlayerListManager.getPlayerStringList().stream().noneMatch(entry -> entry.equals("Crystals:"))) { CLIENT.player.sendMessage(Constants.PREFIX.get().append(Text.translatable("skyblocker.config.mining.crystalsWaypoints.wishingCompassSolver.enableTabMessage")), false); return false; } //return if the crystal for a zone is found - Stream displayNameStream = PlayerListMgr.getPlayerStringList().stream(); + Stream displayNameStream = PlayerListManager.getPlayerStringList().stream(); return switch (zone) { case JUNGLE -> displayNameStream.noneMatch(entry -> entry.equals("Amethyst: ✖ Not Found")); case MITHRIL_DEPOSITS -> displayNameStream.noneMatch(entry -> entry.equals("Jade: ✖ Not Found")); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java index 868bf4cfe2..ab37080f6d 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java @@ -6,8 +6,8 @@ import de.hysky.skyblocker.skyblock.itemlist.ItemRepository; import de.hysky.skyblocker.skyblock.tabhud.util.Ico; import de.hysky.skyblocker.skyblock.tabhud.widget.ComponentBasedWidget; +import de.hysky.skyblocker.skyblock.tabhud.widget.component.Components; import de.hysky.skyblocker.skyblock.tabhud.widget.component.PlainTextComponent; -import de.hysky.skyblocker.skyblock.tabhud.widget.component.ProgressComponent; import de.hysky.skyblocker.utils.ItemUtils; import de.hysky.skyblocker.utils.Location; import it.unimi.dsi.fastutil.doubles.DoubleBooleanPair; @@ -96,7 +96,7 @@ public void updateContent() { addSimpleIcoText(Ico.GOLD, "Coins/h: ", Formatting.GOLD, getPriceText(cropItemId, cropsPerMinute)); addSimpleIcoText(cropStack, "Blocks/s: ", Formatting.YELLOW, Integer.toString(FarmingHud.blockBreaks())); //noinspection DataFlowIssue - addComponent(new ProgressComponent(Ico.LANTERN, Text.literal("Farming Level: "), FarmingHud.farmingXpPercentProgress(), Formatting.GOLD.getColorValue())); + addComponent(Components.progressComponent(Ico.LANTERN, Text.literal("Farming Level: "), FarmingHud.farmingXpPercentProgress(), Formatting.GOLD.getColorValue())); addSimpleIcoText(Ico.LIME_DYE, "Farming XP/h: ", Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format((int) FarmingHud.farmingXpPerHour())); Entity cameraEntity = client.getCameraEntity(); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java index 41da74dab3..93fc0c49cf 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java @@ -7,7 +7,7 @@ import de.hysky.skyblocker.annotations.Init; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.events.SkyblockEvents; -import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.scheduler.MessageScheduler; import it.unimi.dsi.fastutil.ints.*; @@ -262,8 +262,8 @@ protected void renderWidget(DrawContext context, int mouseX, int mouseY, float d private void updateInfestedFromTab() { infectedPlots.clear(); - for (int i = 0; i < PlayerListMgr.getPlayerStringList().size(); i++) { - String string = PlayerListMgr.getPlayerStringList().get(i); + for (int i = 0; i < PlayerListManager.getPlayerStringList().size(); i++) { + String string = PlayerListManager.getPlayerStringList().get(i); if (string.startsWith("Plots:")) { String[] split = string.split(":")[1].split(","); for (String s : split) { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/TabHud.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/TabHud.java index 1966304070..aa56e3e24a 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/TabHud.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/TabHud.java @@ -1,6 +1,7 @@ package de.hysky.skyblocker.skyblock.tabhud; import de.hysky.skyblocker.annotations.Init; +import de.hysky.skyblocker.config.SkyblockerConfigManager; import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.minecraft.client.option.KeyBinding; import net.minecraft.client.util.InputUtil; @@ -8,7 +9,7 @@ public class TabHud { public static KeyBinding toggleSecondary; - public static KeyBinding defaultTgl; + private static KeyBinding defaultTgl; @Init public static void init() { @@ -23,4 +24,8 @@ public static void init() { GLFW.GLFW_KEY_M, "key.categories.skyblocker")); } + + public static boolean shouldRenderVanilla() { + return defaultTgl.isPressed() != SkyblockerConfigManager.get().uiAndVisuals.tabHud.showVanillaTabByDefault; + } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsConfigurationScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsConfigurationScreen.java index 71c5b49467..8a0e050980 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsConfigurationScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsConfigurationScreen.java @@ -5,7 +5,7 @@ import de.hysky.skyblocker.skyblock.tabhud.config.entries.WidgetEntry; import de.hysky.skyblocker.skyblock.tabhud.config.preview.PreviewTab; import de.hysky.skyblocker.skyblock.tabhud.screenbuilder.ScreenMaster; -import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; import de.hysky.skyblocker.skyblock.tabhud.widget.HudWidget; import de.hysky.skyblocker.utils.ItemUtils; import de.hysky.skyblocker.utils.Location; @@ -275,7 +275,7 @@ public void removed() { this.handler.onClosed(this.client.player); } handler.removeListener(this); - Scheduler.INSTANCE.schedule(PlayerListMgr::updateList, 1); + Scheduler.INSTANCE.schedule(PlayerListManager::updateList, 1); SkyblockerConfigManager.save(); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/preview/PreviewTab.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/preview/PreviewTab.java index 2cd743ac74..18d608ed1d 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/preview/PreviewTab.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/preview/PreviewTab.java @@ -8,7 +8,7 @@ import de.hysky.skyblocker.skyblock.tabhud.screenbuilder.ScreenMaster; import de.hysky.skyblocker.skyblock.tabhud.screenbuilder.pipeline.PositionRule; import de.hysky.skyblocker.skyblock.tabhud.screenbuilder.pipeline.WidgetPositioner; -import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; import de.hysky.skyblocker.skyblock.tabhud.widget.HudWidget; import de.hysky.skyblocker.skyblock.tabhud.widget.TabHudWidget; import de.hysky.skyblocker.utils.EnumUtils; @@ -197,7 +197,7 @@ public void refreshGrid(ScreenRect tabArea) { private void updatePlayerListFromPreview() { if (mode == Mode.DUNGEON) { - PlayerListMgr.updateDungeons(DungeonsTabPlaceholder.get()); + PlayerListManager.updateDungeons(DungeonsTabPlaceholder.get()); return; } if (!parent.isPreviewVisible() || parent.getHandler() == null) return; @@ -240,7 +240,7 @@ private void updatePlayerListFromPreview() { } } } - PlayerListMgr.updateWidgetsFrom(lines.stream().map(line -> { + PlayerListManager.updateWidgetsFrom(lines.stream().map(line -> { PlayerListEntry playerListEntry = new PlayerListEntry(new GameProfile(UUID.randomUUID(), ""), false); playerListEntry.setDisplayName(line); return playerListEntry; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/screenbuilder/ScreenBuilder.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/screenbuilder/ScreenBuilder.java index 27efe1b85a..24c42d7af7 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/screenbuilder/ScreenBuilder.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/screenbuilder/ScreenBuilder.java @@ -5,7 +5,7 @@ import de.hysky.skyblocker.skyblock.tabhud.screenbuilder.pipeline.PositionRule; import de.hysky.skyblocker.skyblock.tabhud.screenbuilder.pipeline.TopAlignedWidgetPositioner; import de.hysky.skyblocker.skyblock.tabhud.screenbuilder.pipeline.WidgetPositioner; -import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; import de.hysky.skyblocker.skyblock.tabhud.widget.HudWidget; import de.hysky.skyblocker.skyblock.tabhud.widget.TabHudWidget; import de.hysky.skyblocker.utils.Location; @@ -94,7 +94,7 @@ public void positionWidgets(int screenW, int screenH, boolean config) { } } - for (TabHudWidget widget : PlayerListMgr.tabWidgetsToShow) { + for (TabHudWidget widget : PlayerListManager.tabWidgetsToShow) { PositionRule rule = getPositionRule(widget.getInternalID()); widget.setVisible(true); if (rule == null) { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/screenbuilder/ScreenMaster.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/screenbuilder/ScreenMaster.java index c792963693..2517b2e279 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/screenbuilder/ScreenMaster.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/screenbuilder/ScreenMaster.java @@ -11,7 +11,8 @@ import de.hysky.skyblocker.events.SkyblockEvents; import de.hysky.skyblocker.skyblock.tabhud.TabHud; import de.hysky.skyblocker.skyblock.tabhud.screenbuilder.pipeline.PositionRule; -import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; +import de.hysky.skyblocker.skyblock.tabhud.widget.CommsWidget; import de.hysky.skyblocker.skyblock.tabhud.widget.DungeonPlayerWidget; import de.hysky.skyblocker.skyblock.tabhud.widget.HudWidget; import de.hysky.skyblocker.skyblock.tabhud.widget.TabHudWidget; @@ -29,9 +30,12 @@ import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.nio.file.Path; +import java.util.Arrays; import java.util.EnumMap; import java.util.HashMap; import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; public class ScreenMaster { private static final Logger LOGGER = LogUtils.getLogger(); @@ -39,20 +43,12 @@ public class ScreenMaster { private static final int VERSION = 2; private static final Path FILE = SkyblockerMod.CONFIG_DIR.resolve("hud_widgets.json"); - private static Map createBuilderMap() { - EnumMap map = new EnumMap<>(Location.class); - for (Location value : Location.values()) { - map.put(value, new ScreenBuilder(value)); - } - return map; - } - - private static final Map builderMap = createBuilderMap(); + private static final Map BUILDER_MAP = new EnumMap<>(Arrays.stream(Location.values()).collect(Collectors.toMap(Function.identity(), ScreenBuilder::new))); public static final Map widgetInstances = new HashMap<>(); public static ScreenBuilder getScreenBuilder(Location location) { - return builderMap.get(location); + return BUILDER_MAP.get(location); } /** @@ -66,7 +62,7 @@ public static void render(DrawContext context, int w, int h, boolean hud) { MinecraftClient client = MinecraftClient.getInstance(); ScreenBuilder screenBuilder = getScreenBuilder(Utils.getLocation()); if (client.options.playerListKey.isPressed()) { - if (hud || TabHud.defaultTgl.isPressed()) return; + if (hud || TabHud.shouldRenderVanilla()) return; if (TabHud.toggleSecondary.isPressed()) { screenBuilder.run(context, w, h, ScreenLayer.SECONDARY_TAB); } else { @@ -81,7 +77,7 @@ public static void loadConfig() { try (BufferedReader reader = Files.newBufferedReader(FILE)) { JsonObject object = SkyblockerMod.GSON.fromJson(reader, JsonObject.class); JsonObject positions = object.getAsJsonObject("positions"); - for (Map.Entry builderEntry : builderMap.entrySet()) { + for (Map.Entry builderEntry : BUILDER_MAP.entrySet()) { Location location = builderEntry.getKey(); ScreenBuilder screenBuilder = builderEntry.getValue(); if (positions.has(location.id())) { @@ -103,7 +99,7 @@ public static void loadConfig() { public static void saveConfig() { JsonObject output = new JsonObject(); JsonObject positions = new JsonObject(); - for (Map.Entry builderEntry : builderMap.entrySet()) { + for (Map.Entry builderEntry : BUILDER_MAP.entrySet()) { Location location = builderEntry.getKey(); ScreenBuilder screenBuilder = builderEntry.getValue(); JsonObject locationObject = new JsonObject(); @@ -137,12 +133,12 @@ private static void fillDefaultConfig() { for (Location loc : new Location[]{Location.CRYSTAL_HOLLOWS, Location.DWARVEN_MINES}) { screenBuilder = getScreenBuilder(loc); screenBuilder.setPositionRule( - "commissions", + CommsWidget.ID, new PositionRule("screen", PositionRule.Point.DEFAULT, PositionRule.Point.DEFAULT, 5, 5, ScreenMaster.ScreenLayer.HUD) ); screenBuilder.setPositionRule( "powders", - new PositionRule("commissions", new PositionRule.Point(PositionRule.VerticalPoint.BOTTOM, PositionRule.HorizontalPoint.LEFT), PositionRule.Point.DEFAULT, 0, 2, ScreenMaster.ScreenLayer.HUD) + new PositionRule(CommsWidget.ID, new PositionRule.Point(PositionRule.VerticalPoint.BOTTOM, PositionRule.HorizontalPoint.LEFT), PositionRule.Point.DEFAULT, 0, 2, ScreenMaster.ScreenLayer.HUD) ); } @@ -184,7 +180,7 @@ private static void instantiateWidgets() {} public static void addWidgetInstance(HudWidget widget) { HudWidget put = widgetInstances.put(widget.getInternalID(), widget); if (widget instanceof TabHudWidget tabHudWidget) { - PlayerListMgr.tabWidgetInstances.put(tabHudWidget.getHypixelWidgetName(), tabHudWidget); + PlayerListManager.tabWidgetInstances.put(tabHudWidget.getHypixelWidgetName(), tabHudWidget); } if (put != null) LOGGER.warn("[Skyblocker] Duplicate hud widget found: {}", widget); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/util/PlayerListMgr.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/util/PlayerListManager.java similarity index 99% rename from src/main/java/de/hysky/skyblocker/skyblock/tabhud/util/PlayerListMgr.java rename to src/main/java/de/hysky/skyblocker/skyblock/tabhud/util/PlayerListManager.java index d39c5d6c94..c60601e94c 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/util/PlayerListMgr.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/util/PlayerListManager.java @@ -37,7 +37,7 @@ * data every frame, instead, a scheduler is used to update the data this class * is holding periodically. The list is sorted like in the vanilla game. */ -public class PlayerListMgr { +public class PlayerListManager { public static final Logger LOGGER = LoggerFactory.getLogger("Skyblocker Regex"); private static final Pattern PLAYERS_COLUMN_PATTERN = Pattern.compile("(^|\\s*)(Players \\(\\d+\\)|Island|Coop \\(\\d+\\))(\\s*|$)"); @@ -301,7 +301,7 @@ public static String getFooter() { */ public static Matcher regexAt(int idx, Pattern p) { - String str = PlayerListMgr.strAt(idx); + String str = PlayerListManager.strAt(idx); if (str == null) { return null; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/CommsWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/CommsWidget.java index d1bbefe7e9..9b462996c3 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/CommsWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/CommsWidget.java @@ -3,9 +3,9 @@ import de.hysky.skyblocker.annotations.RegisterWidget; import de.hysky.skyblocker.skyblock.dwarven.CommissionLabels; import de.hysky.skyblocker.skyblock.tabhud.util.Ico; +import de.hysky.skyblocker.skyblock.tabhud.widget.component.Component; +import de.hysky.skyblocker.skyblock.tabhud.widget.component.Components; import de.hysky.skyblocker.skyblock.tabhud.widget.component.IcoTextComponent; -import de.hysky.skyblocker.skyblock.tabhud.widget.component.ProgressComponent; -import de.hysky.skyblocker.utils.ColorUtils; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -20,7 +20,7 @@ @RegisterWidget public class CommsWidget extends TabHudWidget { - + public static final String ID = "commissions"; private static final MutableText TITLE = Text.literal("Commissions").formatted(Formatting.DARK_AQUA, Formatting.BOLD); @@ -49,7 +49,7 @@ public void updateContent(List lines) { for (Text line : lines) { Matcher m = COMM_PATTERN.matcher(line.getString()); if (m.matches()) { - ProgressComponent pc; + Component component; String name = m.group("name"); String progress = m.group("progress"); @@ -57,13 +57,13 @@ public void updateContent(List lines) { newCommissionsNames.add(name); if (progress.equals("DONE")) { - pc = new ProgressComponent(Ico.BOOK, Text.of(name), Text.of(progress), 100f, ColorUtils.percentToColor(100)); + component = Components.progressComponent(Ico.BOOK, Text.of(name), Text.of(progress), 100f); commissionDone = true; } else { - float pcnt = Float.parseFloat(progress.substring(0, progress.length() - 1)); - pc = new ProgressComponent(Ico.BOOK, Text.of(name), pcnt, ColorUtils.percentToColor(pcnt)); + float percent = Float.parseFloat(progress.substring(0, progress.length() - 1)); + component = Components.progressComponent(Ico.BOOK, Text.of(name), percent); } - this.addComponent(pc); + this.addComponent(component); } } if (!oldCommissionNames.equals(newCommissionsNames) || oldDone != commissionDone) { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/ComponentBasedWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/ComponentBasedWidget.java index bfa6356791..5b6761fa81 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/ComponentBasedWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/ComponentBasedWidget.java @@ -4,7 +4,7 @@ import com.mojang.logging.LogUtils; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.tabhud.screenbuilder.ScreenBuilder; -import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; import de.hysky.skyblocker.skyblock.tabhud.widget.component.Component; import de.hysky.skyblocker.skyblock.tabhud.widget.component.IcoTextComponent; import de.hysky.skyblocker.skyblock.tabhud.widget.component.PlainTextComponent; @@ -45,6 +45,8 @@ public abstract class ComponentBasedWidget extends HudWidget { static final int BORDER_SZE_W = 4; static final int BORDER_SZE_E = 4; static final int DEFAULT_COL_BG_BOX = 0xc00c0c0c; + // More transparent background for minimal style + static final int MINIMAL_COL_BG_BOX = 0x64000000; private final int color; private final Text title; @@ -110,7 +112,7 @@ public final void renderWidget(DrawContext context, int mouseX, int mouseY, floa if (SkyblockerConfigManager.get().uiAndVisuals.tabHud.enableHudBackground) { GameOptions options = MinecraftClient.getInstance().options; - int textBackgroundColor = options.getTextBackgroundColor(DEFAULT_COL_BG_BOX); + int textBackgroundColor = options.getTextBackgroundColor(SkyblockerConfigManager.get().uiAndVisuals.tabHud.style.isMinimal() ? MINIMAL_COL_BG_BOX : DEFAULT_COL_BG_BOX); context.fill(x + 1, y, x + w - 1, y + h, textBackgroundColor); context.fill(x, y + 1, x + 1, y + h - 1, textBackgroundColor); context.fill(x + w - 1, y + 1, x + w, y + h - 1, textBackgroundColor); @@ -123,12 +125,15 @@ public final void renderWidget(DrawContext context, int mouseX, int mouseY, floa context.drawText(txtRend, title, x + 8, y + 2, this.color, false); - this.drawHLine(context, x + 2, y + 1 + strHeightHalf, 4); - this.drawHLine(context, x + 2 + strAreaWidth + 4, y + 1 + strHeightHalf, w - 4 - 4 - strAreaWidth); - this.drawHLine(context, x + 2, y + h - 2, w - 4); + // Only draw borders if not in minimal mode + if (!SkyblockerConfigManager.get().uiAndVisuals.tabHud.style.isMinimal()) { + this.drawHLine(context, x + 2, y + 1 + strHeightHalf, 4); + this.drawHLine(context, x + 2 + strAreaWidth + 4, y + 1 + strHeightHalf, w - 4 - 4 - strAreaWidth); + this.drawHLine(context, x + 2, y + h - 2, w - 4); - this.drawVLine(context, x + 1, y + 2 + strHeightHalf, h - 4 - strHeightHalf); - this.drawVLine(context, x + w - 2, y + 2 + strHeightHalf, h - 4 - strHeightHalf); + this.drawVLine(context, x + 1, y + 2 + strHeightHalf, h - 4 - strHeightHalf); + this.drawVLine(context, x + w - 2, y + 2 + strHeightHalf, h - 4 - strHeightHalf); + } int yOffs = y + BORDER_SZE_N; @@ -181,7 +186,7 @@ private void drawVLine(DrawContext context, int xpos, int ypos, int height) { */ public static Text simpleEntryText(int idx, String entryName, Formatting contentFmt) { - String src = PlayerListMgr.strAt(idx); + String src = PlayerListManager.strAt(idx); if (src == null) { return null; @@ -207,7 +212,7 @@ public static Text simpleEntryText(String entryContent, String entryName, Format * @return the entry at idx as unformatted Text */ public static Text plainEntryText(int idx) { - String str = PlayerListMgr.strAt(idx); + String str = PlayerListManager.strAt(idx); if (str == null) { return null; } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonBuffWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonBuffWidget.java index bd88d94b12..175dfba537 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonBuffWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonBuffWidget.java @@ -1,7 +1,7 @@ package de.hysky.skyblocker.skyblock.tabhud.widget; import de.hysky.skyblocker.annotations.RegisterWidget; -import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; import de.hysky.skyblocker.skyblock.tabhud.widget.component.PlainTextComponent; import net.minecraft.text.MutableText; import net.minecraft.text.Text; @@ -25,7 +25,7 @@ public DungeonBuffWidget() { @Override public void updateContent(List ignored) { - String footertext = PlayerListMgr.getFooter(); + String footertext = PlayerListManager.getFooter(); if (footertext == null || !footertext.contains("Dungeon Buffs")) { this.addComponent(new PlainTextComponent(Text.literal("No data").formatted(Formatting.GRAY))); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonDeathWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonDeathWidget.java index db94242c46..bbaf8ff86d 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonDeathWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonDeathWidget.java @@ -2,7 +2,7 @@ import de.hysky.skyblocker.annotations.RegisterWidget; import de.hysky.skyblocker.skyblock.tabhud.util.Ico; -import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; import de.hysky.skyblocker.skyblock.tabhud.widget.component.IcoTextComponent; import net.minecraft.text.MutableText; import net.minecraft.text.Text; @@ -30,7 +30,7 @@ public DungeonDeathWidget() { @Override public void updateContent(List ignored) { - Matcher m = PlayerListMgr.regexAt(25, DEATH_PATTERN); + Matcher m = PlayerListManager.regexAt(25, DEATH_PATTERN); if (m == null) { this.addComponent(new IcoTextComponent()); } else { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonDownedWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonDownedWidget.java index c72cf2731c..684bbf3f56 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonDownedWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonDownedWidget.java @@ -2,7 +2,7 @@ import de.hysky.skyblocker.annotations.RegisterWidget; import de.hysky.skyblocker.skyblock.tabhud.util.Ico; -import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; import de.hysky.skyblocker.skyblock.tabhud.widget.component.IcoTextComponent; import net.minecraft.text.MutableText; import net.minecraft.text.Text; @@ -24,7 +24,7 @@ public DungeonDownedWidget() { @Override public void updateContent(List ignored) { - String down = PlayerListMgr.strAt(21); + String down = PlayerListManager.strAt(21); if (down == null) { this.addComponent(new IcoTextComponent()); } else { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonPlayerWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonPlayerWidget.java index 34fb329211..ddda692429 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonPlayerWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonPlayerWidget.java @@ -1,7 +1,7 @@ package de.hysky.skyblocker.skyblock.tabhud.widget; import de.hysky.skyblocker.skyblock.tabhud.util.Ico; -import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; import de.hysky.skyblocker.skyblock.tabhud.widget.component.IcoTextComponent; import de.hysky.skyblocker.skyblock.tabhud.widget.component.PlainTextComponent; import net.minecraft.item.ItemStack; @@ -60,14 +60,14 @@ public DungeonPlayerWidget(int player) { public void updateContent(List ignored) { int start = 1 + (player - 1) * 4; - if (PlayerListMgr.strAt(start) == null) { + if (PlayerListManager.strAt(start) == null) { int idx = player - 1; IcoTextComponent noplayer = new IcoTextComponent(Ico.SIGN, Text.literal(MSGS.get(idx)).formatted(Formatting.GRAY)); this.addComponent(noplayer); return; } - Matcher m = PlayerListMgr.regexAt(start, PLAYER_PATTERN); + Matcher m = PlayerListManager.regexAt(start, PLAYER_PATTERN); if (m == null) { this.addComponent(new IcoTextComponent()); this.addComponent(new IcoTextComponent()); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonPuzzleWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonPuzzleWidget.java index 55e68ac050..7ec4a110dc 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonPuzzleWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonPuzzleWidget.java @@ -2,7 +2,7 @@ import de.hysky.skyblocker.annotations.RegisterWidget; import de.hysky.skyblocker.skyblock.tabhud.util.Ico; -import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; import de.hysky.skyblocker.skyblock.tabhud.widget.component.IcoTextComponent; import net.minecraft.text.MutableText; import net.minecraft.text.Text; @@ -35,7 +35,7 @@ public void updateContent(List ignored) { int pos = 48; while (pos < 60) { - Matcher m = PlayerListMgr.regexAt(pos, PUZZLE_PATTERN); + Matcher m = PlayerListManager.regexAt(pos, PUZZLE_PATTERN); if (m == null) { break; } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonSecretWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonSecretWidget.java index 4c5c392603..b0ebb1f951 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonSecretWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonSecretWidget.java @@ -3,7 +3,7 @@ import de.hysky.skyblocker.annotations.RegisterWidget; import de.hysky.skyblocker.skyblock.dungeon.DungeonScore; import de.hysky.skyblocker.skyblock.tabhud.util.Ico; -import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -27,7 +27,7 @@ public void updateContent(List ignored) { if (!DungeonScore.isDungeonStarted()) { this.addSimpleIcoText(Ico.CHEST, "Secrets:", Formatting.YELLOW, 30); this.addSimpleIcoText(Ico.SKULL, "Crypts:", Formatting.YELLOW, 31); - } else if (PlayerListMgr.regexAt(31, DISCOVERIES) != null) { + } else if (PlayerListManager.regexAt(31, DISCOVERIES) != null) { this.addSimpleIcoText(Ico.CHEST, "Secrets:", Formatting.YELLOW, 32); this.addSimpleIcoText(Ico.SKULL, "Crypts:", Formatting.YELLOW, 33); } else { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonServerWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonServerWidget.java index a4770ed1f4..63948609f6 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonServerWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/DungeonServerWidget.java @@ -2,7 +2,8 @@ import de.hysky.skyblocker.annotations.RegisterWidget; import de.hysky.skyblocker.skyblock.tabhud.util.Ico; -import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; +import de.hysky.skyblocker.skyblock.tabhud.widget.component.Components; import de.hysky.skyblocker.skyblock.tabhud.widget.component.ProgressComponent; import net.minecraft.text.MutableText; import net.minecraft.text.Text; @@ -34,14 +35,13 @@ public void updateContent(List ignored) { this.addSimpleIcoText(Ico.SIGN, "Rooms Visited:", Formatting.DARK_PURPLE, 42); this.addSimpleIcoText(Ico.SIGN, "Rooms Completed:", Formatting.LIGHT_PURPLE, 43); - Matcher m = PlayerListMgr.regexAt(44, SECRET_PATTERN); + Matcher m = PlayerListManager.regexAt(44, SECRET_PATTERN); if (m == null) { this.addComponent(new ProgressComponent()); } else { - ProgressComponent scp = new ProgressComponent(Ico.CHEST, Text.of("Secrets found:"), + this.addComponent(Components.progressComponent(Ico.CHEST, Text.of("Secrets found:"), Float.parseFloat(m.group("secnum")), - Formatting.DARK_PURPLE.getColorValue()); - this.addComponent(scp); + Formatting.DARK_PURPLE.getColorValue())); } this.addSimpleIcoText(Ico.CLOCK, "Time:", Formatting.GOLD, 45); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/EffectWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/EffectWidget.java index c71ae60b70..dc32f17873 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/EffectWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/EffectWidget.java @@ -2,7 +2,7 @@ import de.hysky.skyblocker.annotations.RegisterWidget; import de.hysky.skyblocker.skyblock.tabhud.util.Ico; -import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; import de.hysky.skyblocker.skyblock.tabhud.widget.component.IcoFatTextComponent; import de.hysky.skyblocker.skyblock.tabhud.widget.component.IcoTextComponent; import de.hysky.skyblocker.skyblock.tabhud.widget.component.PlainTextComponent; @@ -46,7 +46,7 @@ private void fetchFromWidget(List lines) { } private void fetchFromFooter() { - String footertext = PlayerListMgr.getFooter(); + String footertext = PlayerListManager.getFooter(); if (footertext == null || !footertext.contains("Active Effects")) { this.addComponent(new IcoTextComponent()); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/ElectionWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/ElectionWidget.java index ed061f8a83..69cd7b05ec 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/ElectionWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/ElectionWidget.java @@ -2,9 +2,9 @@ import de.hysky.skyblocker.annotations.RegisterWidget; import de.hysky.skyblocker.skyblock.tabhud.util.Ico; +import de.hysky.skyblocker.skyblock.tabhud.widget.component.Components; import de.hysky.skyblocker.skyblock.tabhud.widget.component.IcoTextComponent; import de.hysky.skyblocker.skyblock.tabhud.widget.component.PlainTextComponent; -import de.hysky.skyblocker.skyblock.tabhud.widget.component.ProgressComponent; import net.minecraft.item.ItemStack; import net.minecraft.text.MutableText; import net.minecraft.text.Text; @@ -84,9 +84,7 @@ public void updateContent(List lines) { String pcntstr = m.group("pcnt"); float pcnt = Float.parseFloat(pcntstr); Text candidate = Text.literal(mayorname).formatted(COLS[i - 1]); - ProgressComponent pc = new ProgressComponent(MAYOR_DATA.get(mayorname), candidate, pcnt, - COLS[i - 1].getColorValue()); - this.addComponent(pc); + this.addComponent(Components.progressComponent(MAYOR_DATA.get(mayorname), candidate, pcnt, COLS[i - 1].getColorValue())); } else this.addComponent(new PlainTextComponent(lines.get(i))); } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/FireSaleWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/FireSaleWidget.java index a5661fa644..f9d1acb770 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/FireSaleWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/FireSaleWidget.java @@ -2,10 +2,7 @@ import de.hysky.skyblocker.annotations.RegisterWidget; import de.hysky.skyblocker.skyblock.tabhud.util.Ico; -import de.hysky.skyblocker.skyblock.tabhud.widget.component.IcoTextComponent; -import de.hysky.skyblocker.skyblock.tabhud.widget.component.PlainTextComponent; -import de.hysky.skyblocker.skyblock.tabhud.widget.component.ProgressComponent; -import de.hysky.skyblocker.utils.ColorUtils; +import de.hysky.skyblocker.skyblock.tabhud.widget.component.*; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -43,8 +40,7 @@ public void updateContent(List lines) { float total = Float.parseFloat(m.group("total")) * 1000; Text prgressTxt = Text.literal(String.format("%s/%.0f", avail, total)); float pcnt = (Float.parseFloat(avail) / (total)) * 100f; - ProgressComponent pc = new ProgressComponent(Ico.GOLD, itemTxt, prgressTxt, pcnt, ColorUtils.percentToColor(pcnt)); - this.addComponent(pc); + this.addComponent(Components.progressComponent(Ico.GOLD, itemTxt, prgressTxt, pcnt)); } else if (text.getString().toLowerCase() instanceof String s && (s.contains("starts") || s.contains("starting"))) { this.addComponent(new IcoTextComponent(Ico.CLOCK, text)); } else { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/SkillsWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/SkillsWidget.java index 6dd1701321..3cf0a28362 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/SkillsWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/SkillsWidget.java @@ -2,10 +2,7 @@ import de.hysky.skyblocker.annotations.RegisterWidget; import de.hysky.skyblocker.skyblock.tabhud.util.Ico; -import de.hysky.skyblocker.skyblock.tabhud.widget.component.Component; -import de.hysky.skyblocker.skyblock.tabhud.widget.component.IcoFatTextComponent; -import de.hysky.skyblocker.skyblock.tabhud.widget.component.PlainTextComponent; -import de.hysky.skyblocker.skyblock.tabhud.widget.component.ProgressComponent; +import de.hysky.skyblocker.skyblock.tabhud.widget.component.*; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -43,11 +40,9 @@ public void updateContent(List lines) { if (!pcntStr.equals("MAX")) { float pcnt = Float.parseFloat(pcntStr); - progress = new ProgressComponent(Ico.LANTERN, Text.of(skill), - Text.of(pcntStr + "%"), pcnt, Formatting.GOLD.getColorValue()); + progress = Components.progressComponent(Ico.LANTERN, Text.of(skill), pcnt, Formatting.GOLD.getColorValue()); } else { - progress = new IcoFatTextComponent(Ico.LANTERN, Text.of(skill), - Text.literal(pcntStr).formatted(Formatting.RED)); + progress = new IcoFatTextComponent(Ico.LANTERN, Text.of(skill), Text.literal(pcntStr).formatted(Formatting.RED)); } } else { progress = new PlainTextComponent(line); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/component/Components.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/component/Components.java new file mode 100644 index 0000000000..3ed736d261 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/component/Components.java @@ -0,0 +1,55 @@ +package de.hysky.skyblocker.skyblock.tabhud.widget.component; + +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.utils.ColorUtils; +import net.minecraft.item.ItemStack; +import net.minecraft.text.MutableText; +import net.minecraft.text.Text; + +public class Components { + public static Component progressComponent(ItemStack icon, Text description, float percent) { + return switch (SkyblockerConfigManager.get().uiAndVisuals.tabHud.style) { + case MINIMAL, SIMPLE -> new PlainTextComponent(appendColon(description).append(Text.literal(percent + "%").withColor(ColorUtils.percentToColor(percent)))); + case CLASSIC -> new IcoTextComponent(icon, appendColon(description).append(Text.literal(percent + "%").withColor(ColorUtils.percentToColor(percent)))); + case FANCY -> new ProgressComponent(icon, description, percent); + }; + } + + public static Component progressComponent(ItemStack icon, Text description, float percent, int color) { + return switch (SkyblockerConfigManager.get().uiAndVisuals.tabHud.style) { + case MINIMAL, SIMPLE -> new PlainTextComponent(appendColon(description).append(Text.literal(percent + "%").withColor(color))); + case CLASSIC -> new IcoTextComponent(icon, appendColon(description).append(Text.literal(percent + "%").withColor(color))); + case FANCY -> new ProgressComponent(icon, description, percent, color); + }; + } + + public static Component progressComponent(ItemStack icon, Text description, Text bar, float percent) { + return switch (SkyblockerConfigManager.get().uiAndVisuals.tabHud.style) { + case MINIMAL, SIMPLE -> new PlainTextComponent(appendColon(description).append(bar.copy().withColor(ColorUtils.percentToColor(percent)))); + case CLASSIC -> new IcoTextComponent(icon, appendColon(description).append(bar.copy().withColor(ColorUtils.percentToColor(percent)))); + case FANCY -> new ProgressComponent(icon, description, bar, percent); + }; + } + + public static Component progressComponent(ItemStack icon, Text description, Text bar, float percent, int color) { + return switch (SkyblockerConfigManager.get().uiAndVisuals.tabHud.style) { + case MINIMAL, SIMPLE -> new PlainTextComponent(appendColon(description).append(bar.copy().withColor(color))); + case CLASSIC -> new IcoTextComponent(icon, appendColon(description).append(bar.copy().withColor(color))); + case FANCY -> new ProgressComponent(icon, description, bar, percent, color); + }; + } + + /** + * Returns a copy of the given text ending with ": ". + */ + private static MutableText appendColon(Text text) { + String string = text.getString(); + if (string.endsWith(": ")) { + return text.copy(); + } else if (string.endsWith(":")) { + return text.copy().append(" "); + } else { + return text.copy().append(": "); + } + } +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/component/ProgressComponent.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/component/ProgressComponent.java index 3f5f3443f5..cc736e76d8 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/component/ProgressComponent.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/component/ProgressComponent.java @@ -6,6 +6,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.text.Text; import net.minecraft.util.Formatting; +import org.jetbrains.annotations.Nullable; /** @@ -27,8 +28,11 @@ public class ProgressComponent extends Component { private final boolean colorIsBright; private final int barW; - public ProgressComponent(ItemStack ico, Text d, Text b, float pcnt, int color) { - if (d == null || b == null) { + /** + * @see Components#progressComponent(ItemStack, Text, Text, float) + */ + public ProgressComponent(@Nullable ItemStack ico, @Nullable Text description, @Nullable Text bar, float percent, int color) { + if (description == null || bar == null) { this.ico = Ico.BARRIER; this.desc = Text.literal("No data").formatted(Formatting.GRAY); this.bar = Text.literal("---").formatted(Formatting.GRAY); @@ -36,9 +40,9 @@ public ProgressComponent(ItemStack ico, Text d, Text b, float pcnt, int color) { this.color = 0xff000000 | Formatting.DARK_GRAY.getColorValue(); } else { this.ico = (ico == null) ? Ico.BARRIER : ico; - this.desc = d; - this.bar = b; - this.pcnt = Math.clamp(pcnt, 0f, 100f); + this.desc = description; + this.bar = bar; + this.pcnt = Math.clamp(percent, 0f, 100f); this.color = 0xff000000 | color; } @@ -48,8 +52,25 @@ public ProgressComponent(ItemStack ico, Text d, Text b, float pcnt, int color) { this.colorIsBright = ColorUtils.isBright(this.color); } - public ProgressComponent(ItemStack ico, Text text, float pcnt, int color) { - this(ico, text, Text.of(pcnt + "%"), pcnt, color); + /** + * @see Components#progressComponent(ItemStack, Text, Text, float) + */ + public ProgressComponent(@Nullable ItemStack ico, @Nullable Text description, @Nullable Text bar, float percent) { + this(ico, description, bar, percent, ColorUtils.percentToColor(percent)); + } + + /** + * @see Components#progressComponent(ItemStack, Text, float) + */ + public ProgressComponent(@Nullable ItemStack ico, @Nullable Text description, float percent, int color) { + this(ico, description, Text.of(percent + "%"), percent, color); + } + + /** + * @see Components#progressComponent(ItemStack, Text, float) + */ + public ProgressComponent(@Nullable ItemStack ico, @Nullable Text description, float percent) { + this(ico, description, percent, ColorUtils.percentToColor(percent)); } public ProgressComponent() { diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 08ff3e06a8..058b321de4 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -623,10 +623,6 @@ "skyblocker.config.mining.dwarvenHud.enabledCommissions": "Enable Commissions", "skyblocker.config.mining.dwarvenHud.enabledPowder": "Enable Powder", "skyblocker.config.mining.dwarvenHud.screen": "Dwarven HUD Config...", - "skyblocker.config.mining.dwarvenHud.style": "Style for HUD", - "skyblocker.config.mining.dwarvenHud.style.@Tooltip[0]": "Simple: Shows name and percentage.", - "skyblocker.config.mining.dwarvenHud.style.@Tooltip[1]": "\nFancy: Shows name, percentage, progress bar and an icon.", - "skyblocker.config.mining.dwarvenHud.style.@Tooltip[2]": "\nClassic: Shows name and percentage in a very simple box.", "skyblocker.config.mining.dwarvenMines": "Dwarven Mines", "skyblocker.config.mining.dwarvenMines.solveFetchur": "Solve Fetchur", @@ -898,6 +894,17 @@ "skyblocker.config.uiAndVisuals.tabHud.enableHudBackground.@Tooltip": "Enables the background of the non-tab HUD.", "skyblocker.config.uiAndVisuals.tabHud.effectsFooter": "Effects from footer", "skyblocker.config.uiAndVisuals.tabHud.effectsFooter.@Tooltip": "If on, will fetch current effects from the tab footer if the Hypixel Effects Widget is disabled.", + "skyblocker.config.uiAndVisuals.tabHud.showVanillaTabByDefault": "Show Vanilla Tab by Default", + "skyblocker.config.uiAndVisuals.tabHud.showVanillaTabByDefault.@Tooltip": "If on, will show the vanilla tab by default. Press the toggle key to show fancy tab HUD.", + "skyblocker.config.uiAndVisuals.tabHud.style": "Style for fancy HUD and TAB", + "skyblocker.config.uiAndVisuals.tabHud.style.MINIMAL": "Minimal", + "skyblocker.config.uiAndVisuals.tabHud.style.SIMPLE": "Simple", + "skyblocker.config.uiAndVisuals.tabHud.style.CLASSIC": "Classic", + "skyblocker.config.uiAndVisuals.tabHud.style.FANCY": "Fancy", + "skyblocker.config.uiAndVisuals.tabHud.style.@Tooltip[0]": "Minimal: Shows minimal information in simple boxes.\n", + "skyblocker.config.uiAndVisuals.tabHud.style.@Tooltip[1]": "Simple: Shows essential information in normal boxes.\n", + "skyblocker.config.uiAndVisuals.tabHud.style.@Tooltip[2]": "Classic: Shows information with decorations in normal boxes.\n", + "skyblocker.config.uiAndVisuals.tabHud.style.@Tooltip[3]": "Fancy: Shows information formatted in custom components with decorations in normal boxes.\n", "skyblocker.config.uiAndVisuals.tabHud.tabHudEnabled": "Enable fancy tab HUD", "skyblocker.config.uiAndVisuals.tabHud.tabHudScale": "Scale factor of fancy tab HUD", "skyblocker.config.uiAndVisuals.tabHud.tabHudScale.@Tooltip": "Value in %, relative to your vanilla GUI scale",