mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-11 00:08:58 +07:00
Removed some more static usages
This commit is contained in:
@ -171,7 +171,7 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun pause() {
|
override fun pause() {
|
||||||
if (this::gameInfo.isInitialized) GameSaver.autoSave(this.gameInfo)
|
if (isGameInfoInitialized()) GameSaver.autoSave(this.gameInfo)
|
||||||
super.pause()
|
super.pause()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
|
|||||||
val threadList = Array(numThreads) { _ -> Thread() }
|
val threadList = Array(numThreads) { _ -> Thread() }
|
||||||
Thread.enumerate(threadList)
|
Thread.enumerate(threadList)
|
||||||
|
|
||||||
if (::gameInfo.isInitialized){
|
if (isGameInfoInitialized()){
|
||||||
val autoSaveThread = threadList.firstOrNull { it.name == "Autosave" }
|
val autoSaveThread = threadList.firstOrNull { it.name == "Autosave" }
|
||||||
if (autoSaveThread != null && autoSaveThread.isAlive) {
|
if (autoSaveThread != null && autoSaveThread.isAlive) {
|
||||||
// auto save is already in progress (e.g. started by onPause() event)
|
// 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)
|
MapSaver.saveMap(downloadableMap.name, mapObject)
|
||||||
|
|
||||||
// creating a screen is a GL task
|
// 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) {
|
} catch (ex: Exception) {
|
||||||
print(ex)
|
print(ex)
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class NewMapScreen(val mapParameters: MapParameters = MapParameters()) : PickerS
|
|||||||
Gdx.app.postRunnable {
|
Gdx.app.postRunnable {
|
||||||
val mapEditorScreen = MapEditorScreen(generatedMap!!)
|
val mapEditorScreen = MapEditorScreen(generatedMap!!)
|
||||||
mapEditorScreen.ruleset = ruleset
|
mapEditorScreen.ruleset = ruleset
|
||||||
UncivGame.Current.setScreen(mapEditorScreen)
|
game.setScreen(mapEditorScreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
|
@ -37,7 +37,7 @@ class SaveAndLoadMapScreen(mapToSave: TileMap?, save:Boolean = false) : PickerSc
|
|||||||
MapSaver.saveMap(mapNameTextField.text, mapToSave)
|
MapSaver.saveMap(mapNameTextField.text, mapToSave)
|
||||||
Gdx.app.postRunnable {
|
Gdx.app.postRunnable {
|
||||||
Gdx.input.inputProcessor = null // This is to stop ANRs happening here, until the map editor screen sets up.
|
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()
|
dispose()
|
||||||
}
|
}
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
@ -63,7 +63,7 @@ class SaveAndLoadMapScreen(mapToSave: TileMap?, save:Boolean = false) : PickerSc
|
|||||||
val map = MapSaver.loadMap(chosenMap!!)
|
val map = MapSaver.loadMap(chosenMap!!)
|
||||||
Gdx.app.postRunnable {
|
Gdx.app.postRunnable {
|
||||||
Gdx.input.inputProcessor = null // This is to stop ANRs happening here, until the map editor screen sets up.
|
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()
|
dispose()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,7 +105,7 @@ class SaveAndLoadMapScreen(mapToSave: TileMap?, save:Boolean = false) : PickerSc
|
|||||||
val clipboardContentsString = Gdx.app.clipboard.contents.trim()
|
val clipboardContentsString = Gdx.app.clipboard.contents.trim()
|
||||||
val decoded = Gzip.unzip(clipboardContentsString)
|
val decoded = Gzip.unzip(clipboardContentsString)
|
||||||
val loadedMap = MapSaver.mapFromJson(decoded)
|
val loadedMap = MapSaver.mapFromJson(decoded)
|
||||||
UncivGame.Current.setScreen(MapEditorScreen(loadedMap))
|
game.setScreen(MapEditorScreen(loadedMap))
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
couldNotLoadMapLabel.isVisible = true
|
couldNotLoadMapLabel.isVisible = true
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ class SaveAndLoadMapScreen(mapToSave: TileMap?, save:Boolean = false) : PickerSc
|
|||||||
deleteButton.onClick {
|
deleteButton.onClick {
|
||||||
YesNoPopup("Are you sure you want to delete this map?", {
|
YesNoPopup("Are you sure you want to delete this map?", {
|
||||||
chosenMap!!.delete()
|
chosenMap!!.delete()
|
||||||
UncivGame.Current.setScreen(SaveAndLoadMapScreen(mapToSave))
|
game.setScreen(SaveAndLoadMapScreen(mapToSave))
|
||||||
}, this).open()
|
}, this).open()
|
||||||
}
|
}
|
||||||
rightSideTable.add(deleteButton).row()
|
rightSideTable.add(deleteButton).row()
|
||||||
|
@ -18,7 +18,7 @@ import kotlin.math.round
|
|||||||
|
|
||||||
class ImprovementPickerScreen(val tileInfo: TileInfo, val onAccept: ()->Unit) : PickerScreen() {
|
class ImprovementPickerScreen(val tileInfo: TileInfo, val onAccept: ()->Unit) : PickerScreen() {
|
||||||
private var selectedImprovement: TileImprovement? = null
|
private var selectedImprovement: TileImprovement? = null
|
||||||
val currentPlayerCiv = game.gameInfo.getCurrentPlayerCivilization()
|
val currentPlayerCiv = tileInfo.tileMap.gameInfo.getCurrentPlayerCivilization()
|
||||||
|
|
||||||
fun accept(improvement: TileImprovement?) {
|
fun accept(improvement: TileImprovement?) {
|
||||||
if (improvement == null) return
|
if (improvement == null) return
|
||||||
|
@ -21,8 +21,8 @@ class PlayerReadyScreen(gameInfo: GameInfo, currentPlayerCiv: CivilizationInfo)
|
|||||||
|
|
||||||
table.onClick {
|
table.onClick {
|
||||||
Gdx.app.postRunnable { // To avoid ANRs on Android when the creation of the worldscreen takes more than 500ms
|
Gdx.app.postRunnable { // To avoid ANRs on Android when the creation of the worldscreen takes more than 500ms
|
||||||
UncivGame.Current.worldScreen = WorldScreen(gameInfo, currentPlayerCiv)
|
game.worldScreen = WorldScreen(gameInfo, currentPlayerCiv)
|
||||||
UncivGame.Current.setWorldScreen()
|
game.setWorldScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
table.setFillParent(true)
|
table.setFillParent(true)
|
||||||
|
Reference in New Issue
Block a user