mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-10 07:48:31 +07:00
Add victory type choice on new game screen
This commit is contained in:

committed by
Yair Morgenstern

parent
120ae8b253
commit
56ff436f94
@ -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
|
||||
|
||||
|
@ -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{
|
||||
|
@ -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>()
|
||||
|
Reference in New Issue
Block a user