mirror of
https://github.com/yairm210/Unciv.git
synced 2024-12-23 01:24:26 +07:00
Removed some more static usages
This commit is contained in:
parent
d184a829a2
commit
0aeee8d974
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user