Add victory type choice on new game screen

This commit is contained in:
david.enrique
2019-06-13 23:37:48 +02:00
committed by Yair Morgenstern
parent 120ae8b253
commit 56ff436f94
4 changed files with 55 additions and 3 deletions

View File

@ -218,7 +218,7 @@
}
"Neutral":{
Italian:"Neutrale"
Italian:"Neutrale"
French:"Neutre"
Simplified_Chinese:"泛泛之交"
Portuguese:"Neutra" // relation=relação relação is in feminine so therefore neutral(= neutro/neutra) deve ser feminino

View File

@ -120,6 +120,22 @@
French:"Pas de barbare"
}
"Victory conditions": {
French: "Conditions de victoire"
}
"Scientific": {
French: "Scientifique"
}
"Domination": {
French: "Conquete"
},
"Cultural": {
French: "Culturelle"
}
////////////// Save and load game

View File

@ -10,6 +10,7 @@ import com.unciv.logic.map.MapType
import com.unciv.logic.map.TileInfo
import com.unciv.logic.map.TileMap
import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.VictoryType
import java.util.*
import kotlin.collections.ArrayList
@ -23,6 +24,7 @@ class GameParameters{
var mapType= MapType.Perlin
var noBarbarians=false
var mapFileName :String?=null
var victoryTypes :ArrayList<VictoryType> = VictoryType.values().toCollection(ArrayList()) // By default, all victory types
}
class GameStarter{

View File

@ -11,6 +11,7 @@ import com.unciv.logic.GameInfo
import com.unciv.logic.GameSaver
import com.unciv.logic.map.MapType
import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.VictoryType
import com.unciv.models.gamebasics.tr
import com.unciv.ui.pickerscreens.PickerScreen
import com.unciv.ui.utils.disable
@ -73,10 +74,9 @@ class NewGameScreen: PickerScreen(){
newGameOptionsTable.skin = skin
addMapTypeSizeAndFile(newGameOptionsTable)
addNumberOfHumansAndEnemies(newGameOptionsTable)
addDifficultySelectBox(newGameOptionsTable)
addVictoryTypeCheckboxes(newGameOptionsTable)
val noBarbariansCheckbox = CheckBox("No barbarians".tr(),skin)
noBarbariansCheckbox.isChecked=newGameParameters.noBarbarians
@ -226,6 +226,40 @@ class NewGameScreen: PickerScreen(){
newGameOptionsTable.add(difficultySelectBox).pad(10f).row()
}
private fun addVictoryTypeCheckboxes(newGameOptionsTable: Table) {
newGameOptionsTable.add("{Victory conditions}:".tr()).colspan(2).row()
// Create a checkbox for each VictoryType existing
var i=0
VictoryType.values().forEach{
val victoryCheckbox = CheckBox(it.name.tr(),skin)
victoryCheckbox.name=it.name
victoryCheckbox.isChecked=newGameParameters.victoryTypes.contains(it)
victoryCheckbox.addListener(object : ChangeListener() {
override fun changed(event: ChangeEvent?, actor: Actor?) {
// If the checkbox is checked, adds the victoryType else remove it
if(victoryCheckbox.isChecked){
newGameParameters.victoryTypes.add(it)
} else {
newGameParameters.victoryTypes.remove(it)
}
}
})
i++
if(i%2==0) {
// New row only each two checkboxes
newGameOptionsTable.add(victoryCheckbox)
.left() // Left alignment
.pad(10f).row()
} else {
newGameOptionsTable.add(victoryCheckbox)
.left() // Left alignment
}
}
}
private fun getMapFileSelectBox(): SelectBox<String> {
val mapFileSelectBox = SelectBox<String>(skin)
val mapNames = Array<String>()