diff --git a/src/net/torvald/terrarum/modulebasegame/ui/Notification.kt b/src/net/torvald/terrarum/modulebasegame/ui/Notification.kt index a3eae9157..7dd257528 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/Notification.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/Notification.kt @@ -48,12 +48,9 @@ class Notification : UICanvas() { } } - private val drawColor = Color(1f, 1f, 1f, 1f) - override fun renderUI(batch: SpriteBatch, camera: Camera) { blendNormalStraightAlpha(batch) - drawColor.a = handler.opacity - fontCol.a = handler.opacity + fontCol.a = handler.opacity * OPACITY val realTextWidth = 12 + if (message.size == 1) App.fontGame.getWidth(message[0]) @@ -63,12 +60,11 @@ class Notification : UICanvas() { // force the UI to the centre of the screen this.posX = (App.scr.width - displayedTextWidth) / 2 - val textHeight = message.size * App.fontGame.lineHeight - batch.color = drawColor - Toolkit.drawBaloon(batch, 0f, -textHeight, displayedTextWidth.toFloat(), textHeight) + + Toolkit.drawBaloon(batch, 0f, -textHeight, displayedTextWidth.toFloat(), textHeight, handler.opacity * OPACITY) batch.color = fontCol message.forEachIndexed { index, s -> @@ -79,7 +75,6 @@ class Notification : UICanvas() { // dunno why, it doesn't work without this. - drawColor.a = 1f fontCol.a = 1f } @@ -111,6 +106,7 @@ class Notification : UICanvas() { companion object { // private int messagesShowingIndex = 0; - val OPEN_CLOSE_TIME = 0.16f + const val OPEN_CLOSE_TIME = 0.16f + const val OPACITY = 0.9f } } diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UITooltip.kt b/src/net/torvald/terrarum/modulebasegame/ui/UITooltip.kt index 269c56ca8..de7dae4b7 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UITooltip.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UITooltip.kt @@ -56,10 +56,11 @@ class UITooltip : UICanvas() { batch.color = tooltipBackCol Toolkit.drawBaloon(batch, - tooltipX - textMarginX, - tooltipY, - tooltipW, - font.lineHeight * msgBuffer.size + tooltipX - textMarginX, + tooltipY, + tooltipW, + font.lineHeight * msgBuffer.size, + Notification.OPACITY ) batch.color = tooltipForeCol diff --git a/src/net/torvald/terrarum/ui/Toolkit.kt b/src/net/torvald/terrarum/ui/Toolkit.kt index 58c96b221..61aa22cc0 100644 --- a/src/net/torvald/terrarum/ui/Toolkit.kt +++ b/src/net/torvald/terrarum/ui/Toolkit.kt @@ -254,7 +254,7 @@ object Toolkit : Disposable { (batch as FlippingSpriteBatch).drawFlipped(fboBlur.colorBufferTexture, x.toFloat(), y.toFloat()) } - fun drawBaloon(batch: SpriteBatch, x: Float, y: Float, w: Float, h: Float) { + fun drawBaloon(batch: SpriteBatch, x: Float, y: Float, w: Float, h: Float, opacity: Float = 1f) { // centre area /*batch.draw(baloonTile.get(1, 1), x, y, w, h) @@ -271,9 +271,9 @@ object Toolkit : Disposable { batch.draw(baloonTile.get(0, 2), x - baloonTile.tileW, y + h)*/ - batch.color = Theme.COL_CELL_FILL_OPAQUE + batch.color = Theme.COL_CELL_FILL_OPAQUE.cpy().mul(1f,1f,1f,opacity) fillArea(batch, x - 4, y - 4, w + 8, h + 8) - batch.color = Theme.COL_INACTIVE + batch.color = Theme.COL_INACTIVE.cpy().mul(1f,1f,1f,opacity) drawBoxBorder(batch, x - 4, y - 4, w + 8, h + 8) }