Fixed Application Not Responding when uploading map

This commit is contained in:
Yair Morgenstern 2019-12-13 14:40:45 +02:00
parent 307bccb7d0
commit 7eda5e9d31

View File

@ -14,6 +14,7 @@ import com.unciv.ui.saves.Gzip
import com.unciv.ui.utils.onClick import com.unciv.ui.utils.onClick
import com.unciv.ui.worldscreen.optionstable.DropBox import com.unciv.ui.worldscreen.optionstable.DropBox
import com.unciv.ui.worldscreen.optionstable.PopupTable import com.unciv.ui.worldscreen.optionstable.PopupTable
import kotlin.concurrent.thread
class MapEditorMenuPopup(mapEditorScreen: MapEditorScreen): PopupTable(mapEditorScreen){ class MapEditorMenuPopup(mapEditorScreen: MapEditorScreen): PopupTable(mapEditorScreen){
init{ init{
@ -64,6 +65,7 @@ class MapEditorMenuPopup(mapEditorScreen: MapEditorScreen): PopupTable(mapEditor
val uploadMapButton = TextButton("Upload map".tr(), skin) val uploadMapButton = TextButton("Upload map".tr(), skin)
uploadMapButton.onClick { uploadMapButton.onClick {
thread {
try { try {
val gzippedMap = Gzip.zip(Json().toJson(mapEditorScreen.tileMap)) val gzippedMap = Gzip.zip(Json().toJson(mapEditorScreen.tileMap))
DropBox().uploadFile("/Maps/" + mapEditorScreen.mapName, gzippedMap) DropBox().uploadFile("/Maps/" + mapEditorScreen.mapName, gzippedMap)
@ -73,8 +75,7 @@ class MapEditorMenuPopup(mapEditorScreen: MapEditorScreen): PopupTable(mapEditor
uploadedSuccessfully.addGoodSizedLabel("Map uploaded successfully!").row() uploadedSuccessfully.addGoodSizedLabel("Map uploaded successfully!").row()
uploadedSuccessfully.addCloseButton() uploadedSuccessfully.addCloseButton()
uploadedSuccessfully.open() uploadedSuccessfully.open()
} } catch (ex: Exception) {
catch(ex:Exception){
remove() remove()
val couldNotUpload = PopupTable(screen) val couldNotUpload = PopupTable(screen)
couldNotUpload.addGoodSizedLabel("Could not upload map!").row() couldNotUpload.addGoodSizedLabel("Could not upload map!").row()
@ -82,6 +83,7 @@ class MapEditorMenuPopup(mapEditorScreen: MapEditorScreen): PopupTable(mapEditor
couldNotUpload.open() couldNotUpload.open()
} }
} }
}
add(uploadMapButton).row() add(uploadMapButton).row()