mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-10 23:37:31 +07:00
toast popup not screen blocking again (#3709)
This commit is contained in:
parent
57b1a01e2c
commit
1a4051fa3f
@ -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() }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user