Skip to content

Commit

Permalink
Merge pull request #454 from Reco1I/combo-scale
Browse files Browse the repository at this point in the history
Fix hit object number scale not being applied properly
  • Loading branch information
Rian8337 authored Nov 18, 2024
2 parents 677770d + 97b9815 commit 4af52e8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
38 changes: 34 additions & 4 deletions src/com/reco1l/andengine/text/TextureFont.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,41 @@ open class TextureFont(private val characters: MutableMap<Char, TextureRegion>)
}
}

/**
* The scale of the textures on the x-axis.
*/
var textureScaleX = 1f
set(value) {
if (field != value) {
field = value
isTextDirty = true
}
}

/**
* The scale of the textures on the y-axis.
*/
var textureScaleY = 1f
set(value) {
if (field != value) {
field = value
isTextDirty = true
}
}


private val textureRegions = mutableListOf<TextureRegion>()


private var isTextDirty = true


fun setTextureScale(scale: Float) {
textureScaleX = scale
textureScaleY = scale
}


override fun onManagedDraw(pGL: GL10, pCamera: Camera) {

if (isTextDirty) {
Expand All @@ -64,11 +92,13 @@ open class TextureFont(private val characters: MutableMap<Char, TextureRegion>)
for (i in text.indices) {

val textureRegion = characters[text[i]] ?: continue
val textureWidth = textureRegion.width * textureScaleX
val textureHeight = textureRegion.height * textureScaleY

textureRegions.add(textureRegion)

contentWidth += textureRegion.width + spacing
contentHeight = max(contentHeight, textureRegion.height.toFloat())
contentWidth += textureWidth + spacing
contentHeight = max(contentHeight, textureHeight)
}

contentWidth -= spacing
Expand All @@ -90,8 +120,8 @@ open class TextureFont(private val characters: MutableMap<Char, TextureRegion>)
for (i in textureRegions.indices) {

val texture = textureRegions[i]
val textureWidth = texture.width.toFloat()
val textureHeight = texture.height.toFloat()
val textureWidth = texture.width * textureScaleX
val textureHeight = texture.height * textureScaleY

gl.glPushMatrix()
gl.glTranslatef(offsetX, 0f, 0f)
Expand Down
2 changes: 1 addition & 1 deletion src/com/reco1l/osu/playfield/CirclePiece.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class NumberedCirclePiece(circleTexture: String, overlayTexture: String) : Circl
}

fun setNumberScale(value: Float) {
number.setScale(value)
number.setTextureScale(value)
}

}

0 comments on commit 4af52e8

Please sign in to comment.