diff options
author | Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> | 2024-03-04 13:50:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-04 13:50:39 +0100 |
commit | 10c782ab15e02d8ea1f2da7fae8e46066c1d07d3 (patch) | |
tree | 786f473f42cc876ba2b6d25d3d6d68f6912dbd98 /src | |
parent | f84428a57120f7e2f9d4e73c4f7a1a021dccd96c (diff) | |
download | skyhanni-10c782ab15e02d8ea1f2da7fae8e46066c1d07d3.tar.gz skyhanni-10c782ab15e02d8ea1f2da7fae8e46066c1d07d3.tar.bz2 skyhanni-10c782ab15e02d8ea1f2da7fae8e46066c1d07d3.zip |
Backend: String colored (#1071)
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt index 106743a2c..0874d1cf2 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt @@ -7,12 +7,12 @@ import at.hannibal2.skyhanni.features.chroma.ChromaShaderManager import at.hannibal2.skyhanni.features.chroma.ChromaType import at.hannibal2.skyhanni.utils.ColorUtils import at.hannibal2.skyhanni.utils.ColorUtils.darker -import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderXAligned -import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderYAligned import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.NEUItems.renderOnScreen import at.hannibal2.skyhanni.utils.RenderUtils.HorizontalAlignment import at.hannibal2.skyhanni.utils.RenderUtils.VerticalAlignment +import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderXAligned +import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderYAligned import io.github.moulberry.moulconfig.gui.GuiScreenElementWrapper import io.github.moulberry.notenoughupdates.util.Utils import net.minecraft.client.Minecraft @@ -34,8 +34,8 @@ interface Renderable { val horizontalAlign: HorizontalAlignment val verticalAlign: VerticalAlignment fun isHovered(posX: Int, posY: Int) = currentRenderPassMousePosition?.let { (x, y) -> - x in (posX .. posX + width) - && y in (posY .. posY + height) // TODO: adjust for variable height? + x in (posX..posX + width) + && y in (posY..posY + height) // TODO: adjust for variable height? } ?: false /** @@ -276,6 +276,7 @@ interface Renderable { fun string( text: String, + color: Color = Color.WHITE, horizontalAlign: HorizontalAlignment = HorizontalAlignment.LEFT, verticalAlign: VerticalAlignment = VerticalAlignment.TOP, ) = object : Renderable { @@ -287,7 +288,7 @@ interface Renderable { override val verticalAlign = verticalAlign override fun render(posX: Int, posY: Int) { - Minecraft.getMinecraft().fontRendererObj.drawStringWithShadow("§f$text", 1f, 1f, 0) + Minecraft.getMinecraft().fontRendererObj.drawStringWithShadow(text, 1f, 1f, color.rgb) } } @@ -346,10 +347,20 @@ interface Renderable { ChromaShaderManager.end() } } else { - val (textureX, textureY) = if (texture == SkillProgressBarConfig.TexturedBar.UsedTexture.MATCH_PACK) Pair(0, 64) else Pair(0, 0) + val (textureX, textureY) = if (texture == SkillProgressBarConfig.TexturedBar.UsedTexture.MATCH_PACK) Pair( + 0, + 64 + ) else Pair(0, 0) Minecraft.getMinecraft().renderEngine.bindTexture(ResourceLocation(texture.path)) - Minecraft.getMinecraft().ingameGUI.drawTexturedModalRect(posX, posY, textureX, textureY, width, height) + Minecraft.getMinecraft().ingameGUI.drawTexturedModalRect( + posX, + posY, + textureX, + textureY, + width, + height + ) if (useChroma) { ChromaShaderManager.begin(ChromaType.TEXTURED) @@ -357,7 +368,14 @@ interface Renderable { } else { GlStateManager.color(color.red / 255f, color.green / 255f, color.blue / 255f, 1f) } - Minecraft.getMinecraft().ingameGUI.drawTexturedModalRect(posX, posY, textureX, textureY + height, progress, height) + Minecraft.getMinecraft().ingameGUI.drawTexturedModalRect( + posX, + posY, + textureX, + textureY + height, + progress, + height + ) if (useChroma) { ChromaShaderManager.end() |