Skip to content

Commit

Permalink
feat: transparency/opacity slider without configuration atm
Browse files Browse the repository at this point in the history
  • Loading branch information
opZywl committed Jan 11, 2025
1 parent f2a68c9 commit 02fc422
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ abstract class Style : MinecraftInstance {
glPushMatrix()

glEnable(GL_TEXTURE_2D)
glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glEnable(GL_ALPHA_TEST)
glAlphaFunc(GL_GREATER, 0f)

glBindTexture(GL_TEXTURE_2D, textureID)

Expand All @@ -126,11 +130,14 @@ abstract class Style : MinecraftInstance {
glEnd()

glDisable(GL_TEXTURE_2D)
glDisable(GL_BLEND)
glDisable(GL_ALPHA_TEST)

glPopMatrix()
glPopAttrib()
}


fun clickSound() {
mc.playSound("gui.button.press".asResourceLocation())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ abstract class Component {
glPushMatrix()

glEnable(GL_TEXTURE_2D)
glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glEnable(GL_ALPHA_TEST)
glAlphaFunc(GL_GREATER, 0f)

glBindTexture(GL_TEXTURE_2D, textureID)

Expand All @@ -122,11 +126,14 @@ abstract class Component {
glEnd()

glDisable(GL_TEXTURE_2D)
glDisable(GL_BLEND)
glDisable(GL_ALPHA_TEST)

glPopMatrix()
glPopAttrib()
}


fun <T> Value<T>.setAndSaveValueOnButtonRelease(new: T) {
set(new, false)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ fun Float.withGCD() = (this / getFixedAngleDelta()).roundToInt() * getFixedAngle
* Prevents possible NaN / (-) Infinity results.
*/
infix fun Int.safeDiv(b: Int) = if (b == 0) 0f else this.toFloat() / b.toFloat()
infix fun Int.safeDivInt(b: Int) = if (b == 0) 0 else this / b
infix fun Float.safeDiv(b: Float) = if (b == 0f) 0f else this / b

fun Double.ceilInt() = MathHelper.ceiling_double_int(this)
Expand Down

0 comments on commit 02fc422

Please sign in to comment.