mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-24 22:59:34 +07:00
ResponsePopup is now working like intended (#2089)
This commit is contained in:
@ -5,16 +5,25 @@ import kotlin.concurrent.thread
|
|||||||
//Its a popUp which will close itself after a given amount of time
|
//Its a popUp which will close itself after a given amount of time
|
||||||
//Standard time is one second (in milliseconds)
|
//Standard time is one second (in milliseconds)
|
||||||
class ResponsePopup (message: String, screen: CameraStageBaseScreen, time: Long = 1000) : Popup(screen){
|
class ResponsePopup (message: String, screen: CameraStageBaseScreen, time: Long = 1000) : Popup(screen){
|
||||||
|
private val visibilityTime = time
|
||||||
init {
|
init {
|
||||||
thread (name = "ResponsePopup") {
|
addGoodSizedLabel(message)
|
||||||
val responsePopup = Popup(screen)
|
open()
|
||||||
responsePopup.addGoodSizedLabel(message)
|
|
||||||
responsePopup.open()
|
|
||||||
//move it to the top so its not in the middle of the screen
|
//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
|
//have to be done after open() because open() centers the popup
|
||||||
responsePopup.y = screen.stage.height - (responsePopup.height + responsePopup.padTop)
|
y = screen.stage.height - (height + padTop)
|
||||||
Thread.sleep(time)
|
|
||||||
responsePopup.close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun startTimer(){
|
||||||
|
thread (name = "ResponsePopup") {
|
||||||
|
Thread.sleep(visibilityTime)
|
||||||
|
this.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setVisible(visible: Boolean) {
|
||||||
|
if (visible)
|
||||||
|
startTimer()
|
||||||
|
super.setVisible(visible)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user