2018-04-11 20:46:00 +00:00
|
|
|
package com.unciv
|
2018-03-02 13:34:24 +00:00
|
|
|
|
|
|
|
import com.badlogic.gdx.Game
|
|
|
|
import com.badlogic.gdx.Gdx
|
|
|
|
import com.unciv.logic.GameInfo
|
2018-05-29 10:05:16 +00:00
|
|
|
import com.unciv.logic.GameSaver
|
2018-05-29 19:01:22 +00:00
|
|
|
import com.unciv.models.gamebasics.GameBasics
|
2018-08-24 09:28:27 +00:00
|
|
|
import com.unciv.ui.NewGameScreen
|
2018-08-14 16:09:58 +00:00
|
|
|
import com.unciv.ui.utils.ImageGetter
|
2018-03-02 13:34:24 +00:00
|
|
|
import com.unciv.ui.worldscreen.WorldScreen
|
|
|
|
|
|
|
|
class UnCivGame : Game() {
|
|
|
|
var gameInfo: GameInfo = GameInfo()
|
2018-06-05 18:58:02 +00:00
|
|
|
lateinit var settings : GameSettings
|
2018-03-02 13:34:24 +00:00
|
|
|
|
2018-06-20 15:30:40 +00:00
|
|
|
/**
|
|
|
|
* This exists so that when debugging we can see the entire map.
|
|
|
|
* Remember to turn this to false before commit and upload!
|
|
|
|
*/
|
2018-10-30 20:37:30 +00:00
|
|
|
val viewEntireMapForDebug = true
|
2018-06-20 15:30:40 +00:00
|
|
|
|
2018-05-31 16:46:11 +00:00
|
|
|
lateinit var worldScreen: WorldScreen
|
2018-05-06 05:55:20 +00:00
|
|
|
|
2018-03-02 13:34:24 +00:00
|
|
|
override fun create() {
|
2018-07-26 10:15:38 +00:00
|
|
|
Current = this
|
2018-08-14 16:09:58 +00:00
|
|
|
Gdx.input.isCatchBackKey=true
|
2018-10-12 12:02:12 +00:00
|
|
|
GameBasics.run { } // just to initialize the GameBasics
|
2018-06-05 18:58:02 +00:00
|
|
|
settings = GameSaver().getGeneralSettings()
|
2018-05-29 10:05:16 +00:00
|
|
|
if (GameSaver().getSave("Autosave").exists()) {
|
2018-10-30 20:37:30 +00:00
|
|
|
try {
|
2018-05-06 05:55:20 +00:00
|
|
|
loadGame("Autosave")
|
2018-10-30 20:37:30 +00:00
|
|
|
} catch (ex: Exception) { // silent fail if we can't read the autosave
|
|
|
|
startNewGame()
|
|
|
|
}
|
2018-03-02 13:34:24 +00:00
|
|
|
}
|
2018-08-05 20:08:50 +00:00
|
|
|
else startNewGame() // screen=LanguagePickerScreen() disabled because of people's negative reviews =(
|
2018-05-06 05:55:20 +00:00
|
|
|
}
|
2018-03-02 13:34:24 +00:00
|
|
|
|
2018-06-05 18:58:02 +00:00
|
|
|
fun loadGame(gameInfo:GameInfo){
|
|
|
|
this.gameInfo = gameInfo
|
2018-07-26 10:15:38 +00:00
|
|
|
if(settings.tutorialsShown.isEmpty() && this.gameInfo.tutorial.isNotEmpty())
|
|
|
|
settings.tutorialsShown.addAll(this.gameInfo.tutorial)
|
|
|
|
|
2018-03-02 13:34:24 +00:00
|
|
|
worldScreen = WorldScreen()
|
|
|
|
setWorldScreen()
|
|
|
|
}
|
|
|
|
|
2018-06-05 18:58:02 +00:00
|
|
|
fun loadGame(gameName:String){
|
|
|
|
loadGame(GameSaver().loadGame( gameName))
|
|
|
|
}
|
|
|
|
|
2018-07-26 10:15:38 +00:00
|
|
|
fun startNewGame() {
|
2018-08-24 09:28:27 +00:00
|
|
|
val newGame = GameStarter().startNewGame(NewGameScreen.NewGameParameters().apply { difficulty="Chieftain" })
|
2018-05-29 19:01:22 +00:00
|
|
|
gameInfo = newGame
|
2018-03-02 13:34:24 +00:00
|
|
|
|
|
|
|
worldScreen = WorldScreen()
|
|
|
|
setWorldScreen()
|
2018-05-06 15:03:49 +00:00
|
|
|
|
2018-03-02 13:34:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fun setWorldScreen() {
|
|
|
|
setScreen(worldScreen)
|
2018-05-31 16:46:11 +00:00
|
|
|
worldScreen.update()
|
|
|
|
Gdx.input.inputProcessor = worldScreen.stage
|
2018-03-02 13:34:24 +00:00
|
|
|
}
|
|
|
|
|
2018-08-14 16:09:58 +00:00
|
|
|
override fun resume() {
|
|
|
|
ImageGetter.refreshAltas()
|
|
|
|
worldScreen = WorldScreen()
|
|
|
|
setWorldScreen()
|
|
|
|
}
|
|
|
|
|
2018-03-02 13:34:24 +00:00
|
|
|
companion object {
|
|
|
|
lateinit var Current: UnCivGame
|
|
|
|
}
|
2018-06-05 18:58:02 +00:00
|
|
|
}
|