ResponsePopup is now working like intended (#2089)
This commit is contained in:
parent
73e8b718ab
commit
80ca06afbe
1 changed files with 17 additions and 8 deletions
|
@ -5,16 +5,25 @@ import kotlin.concurrent.thread
|
|||
//Its a popUp which will close itself after a given amount of time
|
||||
//Standard time is one second (in milliseconds)
|
||||
class ResponsePopup (message: String, screen: CameraStageBaseScreen, time: Long = 1000) : Popup(screen){
|
||||
private val visibilityTime = time
|
||||
init {
|
||||
addGoodSizedLabel(message)
|
||||
open()
|
||||
//move it to the top so its not in the middle of the screen
|
||||
//have to be done after open() because open() centers the popup
|
||||
y = screen.stage.height - (height + padTop)
|
||||
}
|
||||
|
||||
private fun startTimer(){
|
||||
thread (name = "ResponsePopup") {
|
||||
val responsePopup = Popup(screen)
|
||||
responsePopup.addGoodSizedLabel(message)
|
||||
responsePopup.open()
|
||||
//move it to the top so its not in the middle of the screen
|
||||
//have to be done after open() because open() centers the popup
|
||||
responsePopup.y = screen.stage.height - (responsePopup.height + responsePopup.padTop)
|
||||
Thread.sleep(time)
|
||||
responsePopup.close()
|
||||
Thread.sleep(visibilityTime)
|
||||
this.close()
|
||||
}
|
||||
}
|
||||
|
||||
override fun setVisible(visible: Boolean) {
|
||||
if (visible)
|
||||
startTimer()
|
||||
super.setVisible(visible)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue