mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-16 18:59:15 +07:00
toast popup not screen blocking again (#3709)
This commit is contained in:
@ -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() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user