From 4987798be687f371adad0c0ba1e2b70b115c6aa3 Mon Sep 17 00:00:00 2001 From: Song Minjae Date: Fri, 10 Mar 2017 02:14:58 +0900 Subject: [PATCH] message notificator bug fixed where it would only work properly for first time Former-commit-id: 640b113cb242ec572f17654feaa8b9be52c333c3 --- src/net/torvald/terrarum/ui/MessageWindow.kt | 2 +- src/net/torvald/terrarum/ui/Notification.kt | 21 +++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/net/torvald/terrarum/ui/MessageWindow.kt b/src/net/torvald/terrarum/ui/MessageWindow.kt index 9fa08ac92..3f8af2935 100644 --- a/src/net/torvald/terrarum/ui/MessageWindow.kt +++ b/src/net/torvald/terrarum/ui/MessageWindow.kt @@ -38,7 +38,7 @@ constructor(override var width: Int, isBlackVariant: Boolean) : UICanvas { else { segmentLeft = Image("./assets/graphics/gui/message_black_left.tga") segmentRight = Image("./assets/graphics/gui/message_black_right.tga") - segmentBody = Image("./assets/graphics/gui/message_black_body.tga") + segmentBody = Image("./assets/graphics/gui/message_black_body.tga") // keep width=2 or greater; no width 1 !! } uiFont = GameFontImpl() height = segmentLeft!!.height diff --git a/src/net/torvald/terrarum/ui/Notification.kt b/src/net/torvald/terrarum/ui/Notification.kt index 18a5e6b2b..434945146 100644 --- a/src/net/torvald/terrarum/ui/Notification.kt +++ b/src/net/torvald/terrarum/ui/Notification.kt @@ -10,8 +10,7 @@ import org.newdawn.slick.SlickException /** * Created by minjaesong on 16-01-23. */ -class Notification @Throws(SlickException::class) -constructor() : UICanvas { +class Notification : UICanvas { private val SHOWUP_MAX = 15000 @@ -26,7 +25,7 @@ constructor() : UICanvas { ) private var displayTimer = 0 - internal var message: Array = Array(MessageWindow.MESSAGES_DISPLAY, { i -> ""}) + internal var message: Array = Array(MessageWindow.MESSAGES_DISPLAY, { "" }) override var openCloseTime: Int = MessageWindow.OPEN_CLOSE_TIME @@ -39,8 +38,10 @@ constructor() : UICanvas { if (handler!!.isOpened) displayTimer += delta - if (displayTimer >= visibleTime) + if (displayTimer >= visibleTime) { handler!!.setAsClose() + displayTimer = 0 + } } override fun render(gc: GameContainer, g: Graphics) { @@ -48,23 +49,19 @@ constructor() : UICanvas { } override fun doOpening(gc: GameContainer, delta: Int) { - handler!!.opacity = FastMath.interpolateLinear(handler!!.openCloseCounter.toFloat() / openCloseTime.toFloat(), - 0f, 1f - ) + UICanvas.doOpeningFade(handler, openCloseTime) } override fun doClosing(gc: GameContainer, delta: Int) { - handler!!.opacity = FastMath.interpolateLinear(handler!!.openCloseCounter.toFloat() / openCloseTime.toFloat(), - 1f, 0f - ) + UICanvas.doClosingFade(handler, openCloseTime) } override fun endOpening(gc: GameContainer, delta: Int) { - handler!!.opacity = 1f + UICanvas.endOpeningFade(handler) } override fun endClosing(gc: GameContainer, delta: Int) { - handler!!.opacity = 0f + UICanvas.endClosingFade(handler) } override fun processInput(gc: GameContainer, delta: Int, input: Input) {