mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 22:37:02 -04:00
Can now pick Random civ in player picker
This commit is contained in:
parent
cf7cf562fa
commit
c992995b6f
@ -9,10 +9,9 @@ import com.unciv.models.gamebasics.Translations
|
|||||||
import com.unciv.models.gamebasics.tr
|
import com.unciv.models.gamebasics.tr
|
||||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||||
import com.unciv.ui.utils.ImageGetter
|
import com.unciv.ui.utils.ImageGetter
|
||||||
import com.unciv.ui.utils.onClick
|
|
||||||
import com.unciv.ui.utils.toLabel
|
import com.unciv.ui.utils.toLabel
|
||||||
|
|
||||||
class NationTable(val nation: Nation, width:Float, onClick:()->Unit)
|
class NationTable(val nation: Nation, width:Float)
|
||||||
: Table(CameraStageBaseScreen.skin) {
|
: Table(CameraStageBaseScreen.skin) {
|
||||||
private val innerTable = Table()
|
private val innerTable = Table()
|
||||||
|
|
||||||
@ -27,7 +26,6 @@ class NationTable(val nation: Nation, width:Float, onClick:()->Unit)
|
|||||||
innerTable.add(titleTable).row()
|
innerTable.add(titleTable).row()
|
||||||
|
|
||||||
innerTable.add(getUniqueLabel(nation).apply { setWrap(true) }).width(width)
|
innerTable.add(getUniqueLabel(nation).apply { setWrap(true) }).width(width)
|
||||||
onClick { onClick() }
|
|
||||||
touchable = Touchable.enabled
|
touchable = Touchable.enabled
|
||||||
add(innerTable)
|
add(innerTable)
|
||||||
}
|
}
|
||||||
|
@ -111,24 +111,45 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
|
|||||||
nationTable.add(player.chosenCiv.toLabel()).pad(20f)
|
nationTable.add(player.chosenCiv.toLabel()).pad(20f)
|
||||||
nationTable.touchable = Touchable.enabled
|
nationTable.touchable = Touchable.enabled
|
||||||
nationTable.onClick {
|
nationTable.onClick {
|
||||||
val nationsPopup = PopupTable(newGameScreen)
|
popupNationPicker(player)
|
||||||
val nationListTable = Table()
|
|
||||||
for (nation in GameBasics.Nations.values.filter { !it.isCityState() && it.name != "Barbarians" }) {
|
|
||||||
if (player.chosenCiv != nation.name && newGameParameters.players.any { it.chosenCiv == nation.name })
|
|
||||||
continue
|
|
||||||
|
|
||||||
nationListTable.add(NationTable(nation, halfWidth) {
|
|
||||||
player.chosenCiv = nation.name
|
|
||||||
nationsPopup.close()
|
|
||||||
update()
|
|
||||||
}).pad(10f).width(halfWidth).row()
|
|
||||||
}
|
|
||||||
nationsPopup.add(ScrollPane(nationListTable)).height(newGameScreen.stage.height * 0.8f)
|
|
||||||
nationsPopup.open()
|
|
||||||
update()
|
|
||||||
}
|
}
|
||||||
return nationTable
|
return nationTable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun popupNationPicker(player: Player) {
|
||||||
|
val nationsPopup = PopupTable(newGameScreen)
|
||||||
|
val nationListTable = Table()
|
||||||
|
|
||||||
|
val randomPlayerTable = Table()
|
||||||
|
randomPlayerTable.background = ImageGetter.getBackground(Color.BLACK)
|
||||||
|
|
||||||
|
randomPlayerTable.add("?".toLabel(Color.BLACK, 30)
|
||||||
|
.apply { this.setAlignment(Align.center) }
|
||||||
|
.surroundWithCircle(50f)).pad(10f)
|
||||||
|
randomPlayerTable.add("Random".toLabel())
|
||||||
|
randomPlayerTable.touchable = Touchable.enabled
|
||||||
|
randomPlayerTable.onClick {
|
||||||
|
player.chosenCiv = "Random"
|
||||||
|
nationsPopup.close()
|
||||||
|
update()
|
||||||
|
}
|
||||||
|
nationListTable.add(randomPlayerTable).pad(10f).width(halfWidth).row()
|
||||||
|
|
||||||
|
|
||||||
|
for (nation in GameBasics.Nations.values.filter { !it.isCityState() && it.name != "Barbarians" }) {
|
||||||
|
if (player.chosenCiv != nation.name && newGameParameters.players.any { it.chosenCiv == nation.name })
|
||||||
|
continue
|
||||||
|
|
||||||
|
nationListTable.add(NationTable(nation, halfWidth).onClick {
|
||||||
|
player.chosenCiv = nation.name
|
||||||
|
nationsPopup.close()
|
||||||
|
update()
|
||||||
|
}).pad(10f).width(halfWidth).row()
|
||||||
|
}
|
||||||
|
nationsPopup.add(ScrollPane(nationListTable)).height(newGameScreen.stage.height * 0.8f)
|
||||||
|
nationsPopup.open()
|
||||||
|
update()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user