Solved Application Not Responding errors when saving large games

This commit is contained in:
Yair Morgenstern
2019-12-12 20:27:46 +02:00
parent f8b822eeb3
commit acf91b4e12
5 changed files with 10 additions and 27 deletions

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd">
<module>
<source path="com/unciv/game" />
</module>

View File

@ -12,6 +12,7 @@ import com.unciv.ui.pickerscreens.PickerScreen
import com.unciv.ui.utils.enable
import com.unciv.ui.utils.onClick
import com.unciv.ui.utils.toLabel
import kotlin.concurrent.thread
class SaveGameScreen : PickerScreen() {
@ -55,8 +56,11 @@ class SaveGameScreen : PickerScreen() {
rightSideButton.setText("Save game".tr())
rightSideButton.onClick {
GameSaver().saveGame(UncivGame.Current.gameInfo, textField.text)
UncivGame.Current.setWorldScreen()
rightSideButton.setText("Saving...".tr())
thread{
GameSaver().saveGame(UncivGame.Current.gameInfo, textField.text)
UncivGame.Current.setWorldScreen()
}
}
rightSideButton.enable()
}

View File

@ -13,6 +13,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener
import com.badlogic.gdx.utils.viewport.ExtendViewport
import com.unciv.UncivGame
import com.unciv.models.gamebasics.tr
import kotlin.concurrent.thread
open class CameraStageBaseScreen : Screen {
@ -128,7 +129,7 @@ fun Actor.center(parent:Stage){ centerX(parent); centerY(parent)}
fun Actor.onClickEvent(sound: String = "click", function: (event: InputEvent?, x: Float, y: Float) -> Unit) {
this.addListener(object : ClickListener() {
override fun clicked(event: InputEvent?, x: Float, y: Float) {
if (sound != "") Sounds.play(sound)
if (sound != "") thread{Sounds.play(sound)}
function(event, x, y)
}
})