toast popup not screen blocking again (#3709)

This commit is contained in:
GGGuenni 2021-03-18 11:47:40 +01:00 committed by GitHub
parent 57b1a01e2c
commit 1a4051fa3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,21 +3,25 @@ package com.unciv.ui.utils
import com.badlogic.gdx.Gdx
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 ToastPopup (message: String, screen: CameraStageBaseScreen, time: Long = 1000) : Popup(screen){
private val visibilityTime = time
/**
* This is an unobtrusive popup which will close itself after a given amount of time.
* Default time is two seconds (in milliseconds)
*/
class ToastPopup (message: String, screen: CameraStageBaseScreen, val time: Long = 2000) : Popup(screen){
init {
//Make this popup unobtrusive
setFillParent(false)
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)
y = screen.stage.height - (height + 20f)
}
private fun startTimer(){
thread (name = "ResponsePopup") {
Thread.sleep(visibilityTime)
Thread.sleep(time)
Gdx.app.postRunnable { this.close() }
}
}