diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt | 40 | ||||
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/RoundedRectangleOutlineShader.kt | 30 |
2 files changed, 58 insertions, 12 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt index 50a51042b..2454946f5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt @@ -5,11 +5,8 @@ import at.hannibal2.skyhanni.data.GuiEditManager import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsX import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsY import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getDummySize -import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.alignmentConfig -import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.backgroundConfig -import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.config +import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.RenderUtils -import at.hannibal2.skyhanni.utils.SpecialColour import io.github.moulberry.notenoughupdates.util.Utils import net.minecraft.client.Minecraft import net.minecraft.client.gui.ScaledResolution @@ -19,7 +16,10 @@ import org.lwjgl.opengl.GL11 class RenderBackground { fun renderBackground() { - val position = config.position + val alignmentConfig = CustomScoreboard.alignmentConfig + val backgroundConfig = CustomScoreboard.backgroundConfig + val outlineConfig = backgroundConfig.outline + val position = CustomScoreboard.config.position val border = backgroundConfig.borderSize val x = position.getAbsX() @@ -36,14 +36,17 @@ class RenderBackground { alignmentConfig.alignRight || alignmentConfig.alignCenterVertically ) { + var newX = if (alignmentConfig.alignRight) scaledWidth - elementWidth - (border * 2) else x + val newY = if (alignmentConfig.alignCenterVertically) scaledHeight / 2 - elementHeight / 2 else y + + if (outlineConfig.enabled) { + newX -= outlineConfig.thickness / 2 + } + position.set( Position( - if (alignmentConfig.alignRight) - scaledWidth - elementWidth - (border * 2) - else x, - if (alignmentConfig.alignCenterVertically) - scaledHeight / 2 - elementHeight / 2 - else y, + newX, + newY, position.getScale(), position.isCenter ) @@ -76,9 +79,22 @@ class RenderBackground { y - border, elementWidth + border * 3, elementHeight + border * 2, - SpecialColour.specialToChromaRGB(backgroundConfig.color), + backgroundConfig.color.toChromaColor().rgb, backgroundConfig.roundedCornerSmoothness ) + if (outlineConfig.enabled) { + RenderUtils.drawRoundRectOutline( + x - border, + y - border, + elementWidth + border * 3, + elementHeight + border * 2, + outlineConfig.colorTop.toChromaColor().rgb, + outlineConfig.colorBottom.toChromaColor().rgb, + outlineConfig.thickness, + backgroundConfig.roundedCornerSmoothness, + outlineConfig.blur + ) + } } } GL11.glDepthMask(true) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/RoundedRectangleOutlineShader.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/RoundedRectangleOutlineShader.kt new file mode 100644 index 000000000..ea8770081 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/RoundedRectangleOutlineShader.kt @@ -0,0 +1,30 @@ +package at.hannibal2.skyhanni.features.misc + +import at.hannibal2.skyhanni.utils.shader.Shader +import at.hannibal2.skyhanni.utils.shader.Uniform +import net.minecraft.client.Minecraft + +object RoundedRectangleOutlineShader : Shader("rounded_rect_outline", "rounded_rect_outline") { + + val INSTANCE: RoundedRectangleOutlineShader + get() = this + + var scaleFactor: Float = 0f + var radius: Float = 0f + var halfSize: FloatArray = floatArrayOf(0f, 0f) + var centerPos: FloatArray = floatArrayOf(0f, 0f) + set(value) { + field = floatArrayOf(value[0], Minecraft.getMinecraft().displayHeight - value[1]) + } + var borderThickness: Float = 5f + var borderBlur: Float = 0.3f + + override fun registerUniforms() { + registerUniform(Uniform.UniformType.FLOAT, "scaleFactor") { scaleFactor } + registerUniform(Uniform.UniformType.FLOAT, "radius") { radius } + registerUniform(Uniform.UniformType.VEC2, "halfSize") { halfSize } + registerUniform(Uniform.UniformType.VEC2, "centerPos") { centerPos } + registerUniform(Uniform.UniformType.FLOAT, "borderThickness") { borderThickness } + registerUniform(Uniform.UniformType.FLOAT, "borderBlur") { borderBlur } + } +}
\ No newline at end of file |
