Removed some more static usages

This commit is contained in:
Yair Morgenstern 2021-03-21 21:04:11 +02:00
parent d184a829a2
commit 0aeee8d974
6 changed files with 11 additions and 11 deletions

View File

@ -171,7 +171,7 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
}
override fun pause() {
if (this::gameInfo.isInitialized) GameSaver.autoSave(this.gameInfo)
if (isGameInfoInitialized()) GameSaver.autoSave(this.gameInfo)
super.pause()
}
@ -187,7 +187,7 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
val threadList = Array(numThreads) { _ -> Thread() }
Thread.enumerate(threadList)
if (::gameInfo.isInitialized){
if (isGameInfoInitialized()){
val autoSaveThread = threadList.firstOrNull { it.name == "Autosave" }
if (autoSaveThread != null && autoSaveThread.isAlive) {
// auto save is already in progress (e.g. started by onPause() event)

View File

@ -80,7 +80,7 @@ class MapDownloadPopup(loadMapScreen: SaveAndLoadMapScreen): Popup(loadMapScreen
MapSaver.saveMap(downloadableMap.name, mapObject)
// creating a screen is a GL task
Gdx.app.postRunnable { UncivGame.Current.setScreen(MapEditorScreen(mapObject)) }
Gdx.app.postRunnable { screen.game.setScreen(MapEditorScreen(mapObject)) }
} catch (ex: Exception) {
print(ex)

View File

@ -63,7 +63,7 @@ class NewMapScreen(val mapParameters: MapParameters = MapParameters()) : PickerS
Gdx.app.postRunnable {
val mapEditorScreen = MapEditorScreen(generatedMap!!)
mapEditorScreen.ruleset = ruleset
UncivGame.Current.setScreen(mapEditorScreen)
game.setScreen(mapEditorScreen)
}
} catch (exception: Exception) {

View File

@ -37,7 +37,7 @@ class SaveAndLoadMapScreen(mapToSave: TileMap?, save:Boolean = false) : PickerSc
MapSaver.saveMap(mapNameTextField.text, mapToSave)
Gdx.app.postRunnable {
Gdx.input.inputProcessor = null // This is to stop ANRs happening here, until the map editor screen sets up.
UncivGame.Current.setScreen(MapEditorScreen(mapToSave))
game.setScreen(MapEditorScreen(mapToSave))
dispose()
}
} catch (ex: Exception) {
@ -63,7 +63,7 @@ class SaveAndLoadMapScreen(mapToSave: TileMap?, save:Boolean = false) : PickerSc
val map = MapSaver.loadMap(chosenMap!!)
Gdx.app.postRunnable {
Gdx.input.inputProcessor = null // This is to stop ANRs happening here, until the map editor screen sets up.
UncivGame.Current.setScreen(MapEditorScreen(map))
game.setScreen(MapEditorScreen(map))
dispose()
}
}
@ -105,7 +105,7 @@ class SaveAndLoadMapScreen(mapToSave: TileMap?, save:Boolean = false) : PickerSc
val clipboardContentsString = Gdx.app.clipboard.contents.trim()
val decoded = Gzip.unzip(clipboardContentsString)
val loadedMap = MapSaver.mapFromJson(decoded)
UncivGame.Current.setScreen(MapEditorScreen(loadedMap))
game.setScreen(MapEditorScreen(loadedMap))
} catch (ex: Exception) {
couldNotLoadMapLabel.isVisible = true
}
@ -117,7 +117,7 @@ class SaveAndLoadMapScreen(mapToSave: TileMap?, save:Boolean = false) : PickerSc
deleteButton.onClick {
YesNoPopup("Are you sure you want to delete this map?", {
chosenMap!!.delete()
UncivGame.Current.setScreen(SaveAndLoadMapScreen(mapToSave))
game.setScreen(SaveAndLoadMapScreen(mapToSave))
}, this).open()
}
rightSideTable.add(deleteButton).row()

View File

@ -18,7 +18,7 @@ import kotlin.math.round
class ImprovementPickerScreen(val tileInfo: TileInfo, val onAccept: ()->Unit) : PickerScreen() {
private var selectedImprovement: TileImprovement? = null
val currentPlayerCiv = game.gameInfo.getCurrentPlayerCivilization()
val currentPlayerCiv = tileInfo.tileMap.gameInfo.getCurrentPlayerCivilization()
fun accept(improvement: TileImprovement?) {
if (improvement == null) return

View File

@ -21,8 +21,8 @@ class PlayerReadyScreen(gameInfo: GameInfo, currentPlayerCiv: CivilizationInfo)
table.onClick {
Gdx.app.postRunnable { // To avoid ANRs on Android when the creation of the worldscreen takes more than 500ms
UncivGame.Current.worldScreen = WorldScreen(gameInfo, currentPlayerCiv)
UncivGame.Current.setWorldScreen()
game.worldScreen = WorldScreen(gameInfo, currentPlayerCiv)
game.setWorldScreen()
}
}
table.setFillParent(true)