musicplayer: actually repositioning the ui

This commit is contained in:
minjaesong
2023-12-25 22:52:49 +09:00
parent 60bc9d54fd
commit 8cbd9dbfff
2 changed files with 9 additions and 7 deletions

View File

@@ -219,6 +219,8 @@ class MusicPlayer(private val ingame: TerrarumIngame) : UICanvas() {
} }
} }
override val mouseUp: Boolean
get() = (relativeMouseX) in -capsuleMosaicSize until width+capsuleMosaicSize && relativeMouseY in 0 until height
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) { override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
batch.end() batch.end()
@@ -226,13 +228,13 @@ class MusicPlayer(private val ingame: TerrarumIngame) : UICanvas() {
batch.begin() batch.begin()
val posX = ((Toolkit.drawWidth - width) / 2).toFloat() posX = ((Toolkit.drawWidth - width) / 2)
val posY = (App.scr.height - App.scr.tvSafeGraphicsHeight - height).toFloat() posY = (App.scr.height - App.scr.tvSafeGraphicsHeight - height)
blendNormalStraightAlpha(batch) blendNormalStraightAlpha(batch)
drawBaloon(batch, posX, posY, width.toFloat(), height - capsuleHeight.toFloat()) drawBaloon(batch, 0f, 0f, width.toFloat(), height - capsuleHeight.toFloat())
drawText(batch, posX, posY) drawText(batch, 0f, 0f)
drawFreqMeter(batch, posX + width - 18, posY + height - (capsuleHeight / 2) + 1) drawFreqMeter(batch, width - 18f, height - (capsuleHeight / 2) + 1f)
batch.color = Color.WHITE batch.color = Color.WHITE
} }
@@ -240,7 +242,7 @@ class MusicPlayer(private val ingame: TerrarumIngame) : UICanvas() {
private fun drawBaloon(batch: SpriteBatch, x: Float, y: Float, width: Float, height: Float) { private fun drawBaloon(batch: SpriteBatch, x: Float, y: Float, width: Float, height: Float) {
val x = x - capsuleMosaicSize val x = x - capsuleMosaicSize
for (k in 0..3 step 3) { for (k in 0..3 step 3) {
batch.color = if (k == 0) colourEdge else colourBack batch.color = if (k == 0) colourEdge else colourBack// (if (mouseUp) Color.MAROON else colourBack)
// top left // top left
batch.draw(baloonTexture.get(k, 0), x, y) batch.draw(baloonTexture.get(k, 0), x, y)

View File

@@ -113,7 +113,7 @@ abstract class UICanvas(
get() = mouseUp && Terrarum.mouseDown get() = mouseUp && Terrarum.mouseDown
private val _mouseUpThis: Boolean private val _mouseUpThis: Boolean
get() = relativeMouseX in 0..width - 1 && relativeMouseY in 0..height - 1 get() = relativeMouseX in 0 until width && relativeMouseY in 0 until height
/** Called by the screen */ /** Called by the screen */
fun update(delta: Float) { fun update(delta: Float) {