Can start a new game from within a game, to copy over the game's parameters

This commit is contained in:
Yair Morgenstern 2020-04-22 17:16:24 +03:00
parent b59cc8ab4f
commit 286ef707c2
3 changed files with 47 additions and 34 deletions

View File

@ -84,7 +84,9 @@ class MenuScreen: CameraStageBaseScreen() {
val quickstartTable = getTableBlock("Quickstart","OtherIcons/Quickstart") { startNewGame() }
table.add(quickstartTable).row()
val newGameButton = getTableBlock("Start new game","OtherIcons/New") { game.setScreen(NewGameScreen(this)) }
val newGameButton = getTableBlock("Start new game","OtherIcons/New") {
game.setScreen(NewGameScreen(this))
}
table.add(newGameButton).row()
if (GameSaver.getSaves(false).any()) {

View File

@ -69,6 +69,12 @@ class NewGameScreen(previousScreen:CameraStageBaseScreen, currentGame:GameInfo?=
thread(name="NewGame") {
// Creating a new game can take a while and we don't want ANRs
newGameThread()
}
}
}
private fun newGameThread() {
try {
newGame = GameStarter.startNewGame(newGameParameters, mapParameters)
if (newGameParameters.isOnlineMultiplayer) {
@ -103,8 +109,6 @@ class NewGameScreen(previousScreen:CameraStageBaseScreen, currentGame:GameInfo?=
}
Gdx.graphics.requestRendering()
}
}
}
fun setNewGameButtonEnabled(bool:Boolean){
if(bool) rightSideButton.enable()

View File

@ -41,6 +41,13 @@ class WorldScreenMenuPopup(val worldScreen: WorldScreen) : Popup(worldScreen) {
}.size(width,height)
addSeparator()
addSquareButton("Start new game".tr()){
worldScreen.game.setScreen(NewGameScreen(worldScreen, worldScreen.gameInfo))
close()
}.size(width,height)
addSeparator()
addSquareButton("Victory status".tr()){
worldScreen.game.setScreen(VictoryScreen(worldScreen))
close()