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

View File

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