diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2023-10-07 11:43:32 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-07 02:43:32 +0200 |
commit | 24c8ce90e3925a397975b617eedf796ae52208ae (patch) | |
tree | 8ebdc6eab934f2ba6ebb5ef904212840ebfd5d3d /src/main/java/at/hannibal2/skyhanni/features/misc | |
parent | 9c2df723b49cf47f9e8a76b08a90ce9874456944 (diff) | |
download | skyhanni-24c8ce90e3925a397975b617eedf796ae52208ae.tar.gz skyhanni-24c8ce90e3925a397975b617eedf796ae52208ae.tar.bz2 skyhanni-24c8ce90e3925a397975b617eedf796ae52208ae.zip |
Feature: Compact tab list (from sba but better) (#459)
Added Advanced Tab List #459
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc')
23 files changed, 491 insertions, 17 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/BestiaryData.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/BestiaryData.kt index 6b33e0b47..211641694 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/BestiaryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/BestiaryData.kt @@ -46,7 +46,7 @@ object BestiaryData { ) @SubscribeEvent - fun onBackgroundDraw(event: GuiRenderEvent.ChestBackgroundRenderEvent) { + fun onBackgroundDraw(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) { if (!isEnabled()) return if (inInventory) { config.position.renderStringsAndItems( diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ChestValue.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ChestValue.kt index 51fa9f685..70c6e8025 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ChestValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ChestValue.kt @@ -44,7 +44,7 @@ class ChestValue { private val inInventory get() = InventoryUtils.openInventoryName().removeColor().isValidStorage() @SubscribeEvent - fun onBackgroundDraw(event: GuiRenderEvent.ChestBackgroundRenderEvent) { + fun onBackgroundDraw(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) { if (!isEnabled()) return if (InventoryUtils.openInventoryName() == "") return if (inInventory) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ChickenHeadTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ChickenHeadTimer.kt index e5ce90ae8..c43f1f623 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ChickenHeadTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ChickenHeadTimer.kt @@ -46,7 +46,7 @@ class ChickenHeadTimer { } @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!isEnabled()) return if (!hasChickenHead) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionTracker.kt index fb74409ab..ebc00c989 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionTracker.kt @@ -196,7 +196,7 @@ class CollectionTracker { } @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!LorenzUtils.inSkyBlock) return SkyHanniMod.feature.misc.collectionCounterPos.renderStringsAndItems(display, posLabel = "Collection Tracker") diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt index c747e5e28..aac4aff7a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt @@ -61,7 +61,7 @@ class CurrentPetDisplay { @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!LorenzUtils.inSkyBlock) return if (RiftAPI.inRift()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt index eb78def01..40b6abed1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt @@ -25,7 +25,7 @@ class CustomTextBox { private fun String.format() = replace("&", "§").split("\\n").toList() @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!config.enabled) return if (!LorenzUtils.inSkyBlock) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNodeTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNodeTracker.kt index 0600229de..d07ae0ef2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNodeTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNodeTracker.kt @@ -127,7 +127,7 @@ class EnderNodeTracker { } @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!config.enabled) return if (!isInTheEnd()) return config.position.renderStringsAndItems(display, posLabel = "Ender Node Tracker") @@ -236,4 +236,4 @@ class EnderNodeTracker { } return newList } -} +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt index 6a77f9fe9..21e28319d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt @@ -149,7 +149,7 @@ class FrozenTreasureTracker { } @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!config.enabled) return if (!onJerryWorkshop()) return if (config.onlyInCave && !inGlacialCave()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt index d6d73c3ce..52ca8a3d1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt @@ -38,7 +38,7 @@ class MovementSpeedDisplay { } @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!isEnabled()) return config.playerMovementSpeedPos.renderString(display, posLabel = "Movement Speed") diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt index e214fc140..ba71aeb9e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt @@ -212,7 +212,7 @@ class NonGodPotEffectDisplay { } @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!isEnabled()) return if (RiftAPI.inRift()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt index 6e6aa029f..bcee7863f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt @@ -28,7 +28,7 @@ class TimeFeatures { } @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!LorenzUtils.inSkyBlock) return if (config.realTime) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt index 684f97ba5..375238dc3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt @@ -84,7 +84,7 @@ class TpsCounter { } @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!LorenzUtils.inSkyBlock) return if (!config.tpsDisplay) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/RenderColumn.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/RenderColumn.kt new file mode 100644 index 000000000..2ee1e3442 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/RenderColumn.kt @@ -0,0 +1,18 @@ +package at.hannibal2.skyhanni.features.misc.compacttablist + +class RenderColumn { + + val lines = mutableListOf<TabLine>() + + fun size(): Int { + return lines.size + } + + fun addLine(line: TabLine) { + lines.add(line) + } + + fun getMaxWidth(): Int { + return lines.maxOfOrNull { it.getWidth() } ?: 0 + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabColumn.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabColumn.kt new file mode 100644 index 000000000..d1e930a09 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabColumn.kt @@ -0,0 +1,17 @@ +package at.hannibal2.skyhanni.features.misc.compacttablist + + +class TabColumn(val columnTitle: String) { + val lines = mutableListOf<String>() + val sections = mutableListOf<TabSection>() + + fun addLine(line: String) { + lines.add(line) + } + + fun addSection(section: TabSection) { + sections.add(section) + } + + fun size() = lines.size + 1 +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabLine.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabLine.kt new file mode 100644 index 000000000..315ea1556 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabLine.kt @@ -0,0 +1,18 @@ +package at.hannibal2.skyhanni.features.misc.compacttablist + +import net.minecraft.client.Minecraft + +class TabLine(var text: String, var type: TabStringType) { + + fun getWidth(): Int { + val mc = Minecraft.getMinecraft() + var width = mc.fontRendererObj.getStringWidth(text) + if (type === TabStringType.PLAYER) { + width += 8 + 2 // Player head + } + if (type === TabStringType.TEXT) { + width += 4 + } + return width + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt new file mode 100644 index 000000000..4eb60dda1 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt @@ -0,0 +1,222 @@ +package at.hannibal2.skyhanni.features.misc.compacttablist + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.mixins.transformers.AccessorGuiPlayerTabOverlay +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.StringUtils.removeResets +import at.hannibal2.skyhanni.utils.StringUtils.trimWhiteSpaceAndResets +import at.hannibal2.skyhanni.utils.TabListData +import net.minecraft.client.Minecraft +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +// heavily inspired by SBA code +object TabListReader { + var hypixelAdvertisingString = "HYPIXEL.NET" + private val godPotPattern = "You have a God Potion active! (?<timer>[\\w ]+)".toPattern() + private val activeEffectPattern = "Active Effects(?:§.)*(?:\\n(?:§.)*§7.+)*".toPattern() + private val effectCountPattern = "You have (?<effectCount>[0-9]+) active effect".toPattern() + private val cookiePattern = "Cookie Buff(?:§.)*(?:\\n(§.)*§7.+)*".toPattern() + private val dungeonBuffPattern = "Dungeon Buffs(?:§.)*(?:\\n(§.)*§7.+)*".toPattern() + private val upgradesPattern = "(?<firstPart>§e[A-Za-z ]+)(?<secondPart> §f[\\w ]+)".toPattern() + private val tabListSPattern = "(?i)§S".toPattern() + + val renderColumns = mutableListOf<RenderColumn>() + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!event.isMod(5)) return + if (!SkyHanniMod.feature.misc.compactTabList.enabled) return + + var tabLines = TabListData.getTabList() + + if (tabLines.size < 80) return + + tabLines = tabLines.subList(0, 80) + + val columns = parseColumns(tabLines) + val footerColumn = parseFooterAsColumn() + + if (footerColumn != null) { + columns.add(footerColumn) + } + + parseSections(columns) + + renderColumns.clear() + val renderColumn = RenderColumn() + renderColumns.add(renderColumn) + combineColumnsToRender(columns, renderColumn) + } + + private fun parseColumns(fullTabList: List<String>): MutableList<TabColumn> { + val columns = mutableListOf<TabColumn>() + + for (entry in fullTabList.indices step 20) { + val title = fullTabList[entry].trimWhiteSpaceAndResets() + var column = getColumnFromName(columns, title) + + if (column == null) { + column = TabColumn(title) + columns.add(column) + } + + for (columnEntry in (entry + 1) until fullTabList.size.coerceAtMost(entry + 20)) { + column.addLine(fullTabList[columnEntry]) + } + } + return columns + } + + private fun parseFooterAsColumn(): TabColumn? { + val tabList = Minecraft.getMinecraft().ingameGUI.tabList as AccessorGuiPlayerTabOverlay + + if (tabList.footer_skyhanni == null) { + return null + } + + val column = TabColumn("§2§lOther") + + var footer = tabListSPattern.matcher(tabList.footer_skyhanni.formattedText).replaceAll("") + + var matcher = godPotPattern.matcher(tabList.footer_skyhanni.unformattedText) + if (matcher.find()) { + footer = activeEffectPattern.matcher(footer).replaceAll("Active Effects:\n§cGod Potion§r: ${matcher.group("timer")}") + } else { + matcher = effectCountPattern.matcher(tabList.footer_skyhanni.unformattedText) + footer = if (matcher.find()) { + activeEffectPattern.matcher(footer).replaceAll("Active Effects: §r§e" + matcher.group("effectCount")) + } else { + activeEffectPattern.matcher(footer).replaceAll("Active Effects: §r§e0") + } + } + + matcher = cookiePattern.matcher(footer) + if (matcher.find() && matcher.group().contains("Not active!")) { + footer = matcher.replaceAll("Cookie Buff \n§r§7Not Active") + } + + matcher = dungeonBuffPattern.matcher(footer) + if (matcher.find() && matcher.group().contains("No Buffs active.")) { + footer = matcher.replaceAll("Dungeon Buffs \n§r§7None Found") + } + + for (line in footer.split("\n")) { + if (line.contains(hypixelAdvertisingString)) continue + + var newLine = line + matcher = upgradesPattern.matcher(newLine.removeResets()) + + if (matcher.matches()) { + var firstPart = matcher.group("firstPart").trimWhiteSpaceAndResets() + if (!firstPart.contains("§l")) { + firstPart = " $firstPart" + } + column.addLine(firstPart) + + newLine = matcher.group("secondPart") + } + + newLine = newLine.trimWhiteSpaceAndResets() + if (!newLine.contains("§l")) { + newLine = " $newLine" + } + column.addLine(newLine) + } + + return column + } + + private fun getColumnFromName(columns: List<TabColumn>, name: String): TabColumn? { + for (tabColumn in columns) { + if (name == tabColumn.columnTitle) { + return tabColumn + } + } + return null + } + + private fun parseSections(columns: MutableList<TabColumn>) { + for (column in columns) { + var currentTabSection: TabSection? = null + for (line in column.lines) { + if (line.trimWhiteSpaceAndResets().isEmpty()) { + currentTabSection = null + continue + } + + if (currentTabSection == null) { + column.addSection(TabSection(column).also { currentTabSection = it }) + } + + currentTabSection?.addLine(line) + } + } + } + + private fun combineColumnsToRender(columns: MutableList<TabColumn>, firstColumn: RenderColumn) { + var firstColumnCopy = firstColumn + var lastTitle: String? = null + + for (column in columns) { + for (section in column.sections) { + var sectionSize = section.size() + + var needsTitle = false + if (lastTitle != section.columnValue.columnTitle) { + needsTitle = true + sectionSize++ + } + + var currentCount = firstColumnCopy.size() + + if (sectionSize >= TabListRenderer.maxLines / 2) { + if (currentCount >= TabListRenderer.maxLines) { + renderColumns.add(RenderColumn().also { firstColumnCopy = it }) + currentCount = 1 + } else { + if (firstColumnCopy.size() > 0) { + firstColumnCopy.addLine(TabLine("", TabStringType.TEXT)) + } + } + + if (needsTitle) { + lastTitle = section.columnValue.columnTitle + firstColumnCopy.addLine(TabLine(lastTitle, TabStringType.TITLE)) + currentCount++ + } + + for (line in section.lines) { + if (currentCount >= TabListRenderer.maxLines) { + renderColumns.add(RenderColumn().also { firstColumnCopy = it }) + currentCount = 1 + } + + firstColumnCopy.addLine(TabLine(line, TabStringType.fromLine(line))) + currentCount++ + } + } else { + if (currentCount + sectionSize > TabListRenderer.maxLines) { + renderColumns.add(RenderColumn().also { firstColumnCopy = it }) + } else { + if (firstColumnCopy.size() > 0) { + firstColumnCopy.addLine(TabLine("", TabStringType.TEXT)) + } + } + + if (needsTitle) { + lastTitle = section.columnValue.columnTitle + firstColumnCopy.addLine(TabLine(lastTitle, TabStringType.TITLE)) + } + + for (line in section.lines) { + firstColumnCopy.addLine(TabLine(line, TabStringType.fromLine(line))) + } + } + } + } + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt new file mode 100644 index 000000000..ea850f6e2 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt @@ -0,0 +1,157 @@ +package at.hannibal2.skyhanni.features.misc.compacttablist + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.mixins.transformers.AccessorGuiPlayerTabOverlay +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.Gui +import net.minecraft.client.gui.ScaledResolution +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.entity.player.EnumPlayerModelParts +import net.minecraftforge.client.event.RenderGameOverlayEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object TabListRenderer { + private val config get() = SkyHanniMod.feature.misc.compactTabList + + const val maxLines = 22 + private const val lineHeight = 8 + 1 + private const val padding = 3 + private const val columnSpacing = 6 + + @SubscribeEvent + fun onRenderOverlay(event: RenderGameOverlayEvent.Pre) { + if (!LorenzUtils.inSkyBlock) return + if (event.type != RenderGameOverlayEvent.ElementType.PLAYER_LIST) return + if (!config.enabled) return + event.isCanceled = true + + val columns = TabListReader.renderColumns + + if (columns.isEmpty()) return + + var maxLines = 0 + var totalWidth = 0 - columnSpacing + + for (column in columns) { + maxLines = maxLines.coerceAtLeast(column.size()) + totalWidth += column.getMaxWidth() + columnSpacing + } + + var totalHeight = maxLines * lineHeight + val tabList = Minecraft.getMinecraft().ingameGUI.tabList as AccessorGuiPlayerTabOverlay + + var header = listOf<String>() + if (tabList.header_skyhanni != null) { + header = tabList.header_skyhanni.formattedText.split("\n").toMutableList() + header.removeIf { line -> !line.contains(TabListReader.hypixelAdvertisingString) } + if (config.hideAdverts) { + header = listOf() + } else { + totalHeight += header.size * lineHeight + padding + } + } + + var footer = listOf<String>() + if (tabList.footer_skyhanni != null) { + footer = tabList.footer_skyhanni.formattedText.split("\n").toMutableList() + footer.removeIf { line -> !line.contains(TabListReader.hypixelAdvertisingString) } + if (config.hideAdverts) { + footer = listOf() + } else { + totalHeight += footer.size * lineHeight + padding + } + } + + val minecraft = Minecraft.getMinecraft() + val scaledResolution = ScaledResolution(minecraft) + val screenWidth = scaledResolution.scaledWidth / 2 + val x = screenWidth - totalWidth / 2 + val y = 10 + + Gui.drawRect( + x - columnSpacing, + y - padding, + screenWidth + totalWidth / 2 + columnSpacing, + 10 + totalHeight + padding, + -0x80000000 + ) + + var headerY = y + if (header.isNotEmpty()) { + for (line in header) { + minecraft.fontRendererObj.drawStringWithShadow( + line, + x + totalWidth / 2f - minecraft.fontRendererObj.getStringWidth(line) / 2f, + headerY.toFloat(), + 0xFFFFFF + ) + headerY += 8 + 1 + } + } + + var middleX = x + for (column in columns) { + var middleY = if (config.hideAdverts) headerY else headerY + padding + 2 + + Gui.drawRect( + middleX - padding + 1, + middleY - padding + 1, + middleX + column.getMaxWidth() + padding - 2, + middleY + column.size() * lineHeight + padding - 2, + 0x20AAAAAA + ) + + for (tabLine in column.lines) { + val savedX = middleX + + if (tabLine.type == TabStringType.PLAYER) { + val pLayerInfo = minecraft.netHandler.getPlayerInfo(TabStringType.usernameFromLine(tabLine.text)) + if (pLayerInfo != null) { + val player = minecraft.theWorld.getPlayerEntityByUUID(pLayerInfo.gameProfile.id) + + minecraft.textureManager.bindTexture(pLayerInfo.locationSkin) + GlStateManager.color(1f, 1f, 1f, 1f) + Gui.drawScaledCustomSizeModalRect(middleX, middleY, 8f, 8f, 8, 8, 8, 8, 64.0f, 64.0f) + if (player != null && player.isWearing(EnumPlayerModelParts.HAT)) { + Gui.drawScaledCustomSizeModalRect(middleX, middleY, 40.0f, 8f, 8, 8, 8, 8, 64.0f, 64.0f) + } + } + middleX += 8 + 2 + } + + if (tabLine.type == TabStringType.TITLE) { + minecraft.fontRendererObj.drawStringWithShadow( + tabLine.text, + middleX + column.getMaxWidth() / 2f - tabLine.getWidth() / 2f, + middleY.toFloat(), + 0xFFFFFF + ) + } else { + minecraft.fontRendererObj.drawStringWithShadow( + tabLine.text, + middleX.toFloat(), + middleY.toFloat(), + 0xFFFFFF + ) + } + middleY += lineHeight + middleX = savedX + } + middleX += column.getMaxWidth() + columnSpacing + } + + if (footer.isNotEmpty()) { + var footerY = y + totalHeight - footer.size * lineHeight + padding / 2 + 1 + for (line in footer) { + minecraft.fontRendererObj.drawStringWithShadow( + line, + x + totalWidth / 2f - minecraft.fontRendererObj.getStringWidth(line) / 2f, + footerY.toFloat(), + -0x1 + ) + footerY += lineHeight + } + } + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabSection.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabSection.kt new file mode 100644 index 000000000..9754235fb --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabSection.kt @@ -0,0 +1,11 @@ +package at.hannibal2.skyhanni.features.misc.compacttablist + +class TabSection(val columnValue: TabColumn) { + val lines = mutableListOf<String>() + + fun addLine(line: String) { + lines.add(line) + } + + fun size() = lines.size +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabStringType.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabStringType.kt new file mode 100644 index 000000000..344a21ae1 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabStringType.kt @@ -0,0 +1,31 @@ +package at.hannibal2.skyhanni.features.misc.compacttablist + +import at.hannibal2.skyhanni.utils.StringUtils.removeColor + +enum class TabStringType { + TITLE, + SUB_TITLE, + TEXT, + PLAYER; + + companion object { + private val usernamePattern = "^\\[(?<sblevel>\\d+)] (?:\\[\\w+] )?(?<username>\\w+)".toPattern() + + fun fromLine(line: String): TabStringType { + val strippedLine: String = line.removeColor() + if (strippedLine.startsWith(" ")) { + return TEXT + } + return if (usernamePattern.matcher(strippedLine).find()) { + PLAYER + } else { + SUB_TITLE + } + } + + fun usernameFromLine(input: String): String { + val usernameMatcher = usernamePattern.matcher(input.removeColor()) + return if (usernameMatcher.find()) usernameMatcher.group("username") else input + } + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt index 5999b3c62..8c2287720 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt @@ -97,7 +97,7 @@ object GhostCounter { private val VOLTA = "VOLTA".asInternalName() @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!isEnabled()) return if (config.onlyOnMist && !inMist) return config.position.renderStringsAndItems( diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt index 94d5b4eeb..4ec2dbf99 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt @@ -94,7 +94,7 @@ object EstimatedItemValue { } @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.ChestBackgroundRenderEvent) { + fun onRenderOverlay(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) { if (!LorenzUtils.inSkyBlock) return if (!config.estimatedIemValueEnabled) return if (!OSUtils.isKeyHeld(config.estimatedItemValueHotkey) && !config.estimatedIemValueAlwaysEnabled) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt index fab56b5af..d393fdd7f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt @@ -144,7 +144,7 @@ object TrevorFeatures { } @SubscribeEvent(priority = EventPriority.LOWEST) - fun renderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + fun renderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!config.trapperCooldownGui) return if (!onFarmingIsland()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorTracker.kt index 52bb0f392..7a4213a64 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorTracker.kt @@ -119,7 +119,7 @@ object TrevorTracker { } @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!shouldDisplay()) return config.position.renderStringsAndItems(display, posLabel = "Frozen Treasure Tracker") } |