v1.1 - More UI responsiveness, increased download buffer

This commit is contained in:
ceikry 2021-07-16 10:19:25 -05:00
parent dee36e793b
commit 8fd259183b
5 changed files with 56 additions and 18 deletions

View file

@ -50,8 +50,30 @@ object MainWindow : JFrame("2009scape Launcher") {
val loadingFrame = JLabel(ImageIcon(javaClass.getResource("/loadingFrame.png")))
playButton.isEnabled = true
playButton.onClick {
if(Updater.checkUpdate()) Updater.runUpdate()
else Runtime.getRuntime().exec("java -jar " + Settings.SAVE_DIR + File.separator + Settings.SAVE_NAME, null, File(System.getProperty("user.home"))).also { exitProcess(0) }
val t = Thread {
val oldText = loadingLabel.text
loadingLabel.text = "Checking for updates"
playButton.isEnabled = false
var counter = 0
var dotCounter = 0
while(Updater.status == Updater.UpdateStatus.CHECKING){
if(counter++ % 5 == 0){
dotCounter++
loadingLabel.text = "Checking for updates${".".repeat((dotCounter % 4) + 1)}"
}
Thread.sleep(50L)
}
if(Updater.remoteMD5 != "-1" && Updater.remoteMD5 != Updater.localMD5){
println("Update required, running update...")
loadingLabel.text = oldText
Updater.runUpdate()
} else {
loadingLabel.text = oldText
playButton.isEnabled = true
launchClient()
}
}.start()
Thread { Updater.checkUpdate() }.start()
}
loadingFrame.placeAt(96,MainWindow.height - 35, 704, 35)
loadingBar.placeAt(103, MainWindow.height - 33, 695, 31)