mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-14 09:48:12 +07:00
Edit startgame screen. (#1950)
Co-authored-by: u-ndefine <41176671+u-ndefine@users.noreply.github.com>
This commit is contained in:
@ -29,11 +29,12 @@ class NewGameScreen: PickerScreen(){
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
setDefaultCloseAction()
|
setDefaultCloseAction()
|
||||||
|
scrollPane.setScrollingDisabled(true,true)
|
||||||
|
|
||||||
val playerPickerTable = PlayerPickerTable(this, newGameParameters)
|
val playerPickerTable = PlayerPickerTable(this, newGameParameters)
|
||||||
val newGameScreenOptionsTable = NewGameScreenOptionsTable(this) { playerPickerTable.update() }
|
val newGameScreenOptionsTable = NewGameScreenOptionsTable(this) { playerPickerTable.update() }
|
||||||
topTable.add(ScrollPane(newGameScreenOptionsTable).apply{setOverscroll(false,false)}).height(topTable.parent.height)
|
topTable.add(ScrollPane(newGameScreenOptionsTable).apply{setOverscroll(false,false)}).height(topTable.parent.height)
|
||||||
topTable.add(playerPickerTable).pad(10f)
|
topTable.add(playerPickerTable).height(topTable.parent.height)
|
||||||
topTable.pack()
|
topTable.pack()
|
||||||
topTable.setFillParent(true)
|
topTable.setFillParent(true)
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class NewGameScreenOptionsTable(val newGameScreen: NewGameScreen, val updatePlay
|
|||||||
add("Map options".toLabel(fontSize = 24)).colspan(2).row()
|
add("Map options".toLabel(fontSize = 24)).colspan(2).row()
|
||||||
addMapTypeSelection()
|
addMapTypeSelection()
|
||||||
|
|
||||||
add("Game options".toLabel(fontSize = 24)).padTop(20f).colspan(2).row()
|
add("Game options".toLabel(fontSize = 24)).colspan(2).row()
|
||||||
addDifficultySelectBox()
|
addDifficultySelectBox()
|
||||||
addGameSpeedSelectBox()
|
addGameSpeedSelectBox()
|
||||||
addEraSelectBox()
|
addEraSelectBox()
|
||||||
|
@ -20,11 +20,11 @@ import java.util.*
|
|||||||
|
|
||||||
class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters: GameParameters): Table() {
|
class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters: GameParameters): Table() {
|
||||||
val playerListTable = Table()
|
val playerListTable = Table()
|
||||||
val nationsPopupWidth = newGameScreen.stage.width / 2.5f
|
val nationsPopupWidth = newGameScreen.stage.width / 2f
|
||||||
|
|
||||||
init {
|
init {
|
||||||
add(ScrollPane(playerListTable)).width(newGameScreen.stage.width/2)
|
top()
|
||||||
.height(newGameScreen.stage.height * 0.6f)
|
add(ScrollPane(playerListTable).apply{setOverscroll(false,false)}).width(newGameScreen.stage.width/2)
|
||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,14 +38,14 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
|
|||||||
}
|
}
|
||||||
if(newGameParameters.players.count() < gameBasics.nations.values.count { it.isMajorCiv() }) {
|
if(newGameParameters.players.count() < gameBasics.nations.values.count { it.isMajorCiv() }) {
|
||||||
playerListTable.add("+".toLabel(Color.BLACK,30).apply { this.setAlignment(Align.center) }
|
playerListTable.add("+".toLabel(Color.BLACK,30).apply { this.setAlignment(Align.center) }
|
||||||
.surroundWithCircle(50f).onClick { newGameParameters.players.add(Player()); update() })
|
.surroundWithCircle(50f).onClick { newGameParameters.players.add(Player()); update() }).pad(10f)
|
||||||
}
|
}
|
||||||
newGameScreen.setNewGameButtonEnabled(newGameParameters.players.size>1)
|
newGameScreen.setNewGameButtonEnabled(newGameParameters.players.size>1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getPlayerTable(player: Player, ruleset: Ruleset): Table {
|
fun getPlayerTable(player: Player, ruleset: Ruleset): Table {
|
||||||
val playerTable = Table()
|
val playerTable = Table()
|
||||||
playerTable.pad(20f)
|
playerTable.pad(5f)
|
||||||
playerTable.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.8f))
|
playerTable.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.8f))
|
||||||
|
|
||||||
val nationTable = getNationTable(player)
|
val nationTable = getNationTable(player)
|
||||||
@ -58,49 +58,43 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
|
|||||||
else player.playerType = PlayerType.AI
|
else player.playerType = PlayerType.AI
|
||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
playerTable.add(playerTypeTextbutton).pad(20f)
|
playerTable.add(playerTypeTextbutton).width(100f).pad(5f)
|
||||||
playerTable.add(TextButton("Remove".tr(), CameraStageBaseScreen.skin)
|
playerTable.add("-".toLabel(Color.BLACK,30).apply { this.setAlignment(Align.center) }
|
||||||
.onClick { newGameParameters.players.remove(player); update() }).row()
|
.surroundWithCircle(40f)
|
||||||
|
.onClick { newGameParameters.players.remove(player); update() }).pad(5f).row()
|
||||||
if(newGameParameters.isOnlineMultiplayer && player.playerType==PlayerType.Human) {
|
if(newGameParameters.isOnlineMultiplayer && player.playerType==PlayerType.Human) {
|
||||||
val playerIdTable = Table()
|
|
||||||
playerIdTable.add("Player ID:".toLabel())
|
|
||||||
|
|
||||||
val playerIdTextfield = TextField(player.playerId, CameraStageBaseScreen.skin)
|
val playerIdTextfield = TextField(player.playerId, CameraStageBaseScreen.skin)
|
||||||
playerIdTable.add(playerIdTextfield).colspan(2)
|
playerIdTextfield.messageText = "Please input Player ID!".tr()
|
||||||
val errorLabel = "Not a valid user id!".toLabel(Color.RED)
|
playerTable.add(playerIdTextfield).colspan(2).fillX().pad(5f)
|
||||||
errorLabel.isVisible=false
|
var errorLabel = "✘".toLabel(Color.RED)
|
||||||
playerIdTable.add(errorLabel)
|
playerTable.add(errorLabel).pad(5f).row()
|
||||||
|
|
||||||
fun onPlayerIdTextUpdated(){
|
fun onPlayerIdTextUpdated(){
|
||||||
try {
|
try {
|
||||||
val uuid = UUID.fromString(playerIdTextfield.text)
|
val uuid = UUID.fromString(playerIdTextfield.text)
|
||||||
player.playerId = playerIdTextfield.text
|
player.playerId = playerIdTextfield.text
|
||||||
errorLabel.isVisible=false
|
errorLabel.apply { setText("✔");setFontColor(Color.GREEN) }
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
errorLabel.isVisible=true
|
errorLabel.apply { setText("✘");setFontColor(Color.RED) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
playerIdTextfield.addListener { onPlayerIdTextUpdated(); true }
|
playerIdTextfield.addListener { onPlayerIdTextUpdated(); true }
|
||||||
|
|
||||||
playerIdTable.row()
|
|
||||||
|
|
||||||
val currentUserId = UncivGame.Current.settings.userId
|
val currentUserId = UncivGame.Current.settings.userId
|
||||||
val setCurrentUserButton = TextButton("Set current user".tr(), CameraStageBaseScreen.skin)
|
val setCurrentUserButton = TextButton("Set current user".tr(), CameraStageBaseScreen.skin)
|
||||||
setCurrentUserButton.onClick {
|
setCurrentUserButton.onClick {
|
||||||
playerIdTextfield.text = currentUserId
|
playerIdTextfield.text = currentUserId
|
||||||
onPlayerIdTextUpdated()
|
onPlayerIdTextUpdated()
|
||||||
}
|
}
|
||||||
playerIdTable.add(setCurrentUserButton)
|
playerTable.add(setCurrentUserButton).colspan(3).fillX().pad(5f).row()
|
||||||
|
|
||||||
val copyFromClipboardButton = TextButton("Player ID from clipboard".tr(),CameraStageBaseScreen.skin)
|
val copyFromClipboardButton = TextButton("Player ID from clipboard".tr(),CameraStageBaseScreen.skin)
|
||||||
copyFromClipboardButton.onClick {
|
copyFromClipboardButton.onClick {
|
||||||
playerIdTextfield.text = Gdx.app.clipboard.contents
|
playerIdTextfield.text = Gdx.app.clipboard.contents
|
||||||
onPlayerIdTextUpdated()
|
onPlayerIdTextUpdated()
|
||||||
}
|
}
|
||||||
playerIdTable.add(copyFromClipboardButton).pad(5f)
|
playerTable.add(copyFromClipboardButton).colspan(3).fillX().pad(5f)
|
||||||
|
|
||||||
playerTable.add(playerIdTable).colspan(playerTable.columns)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return playerTable
|
return playerTable
|
||||||
@ -108,12 +102,13 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
|
|||||||
|
|
||||||
private fun getNationTable(player: Player): Table {
|
private fun getNationTable(player: Player): Table {
|
||||||
val nationTable = Table()
|
val nationTable = Table()
|
||||||
val nationImage = if (player.chosenCiv == "Random") "?".toLabel(Color.BLACK,30)
|
val nationImage = if (player.chosenCiv == "Random") "?".toLabel(Color.WHITE,25)
|
||||||
.apply { this.setAlignment(Align.center) }
|
.apply { this.setAlignment(Align.center) }
|
||||||
.surroundWithCircle(50f)
|
.surroundWithCircle(36f).apply { circle.color = Color.BLACK }
|
||||||
else ImageGetter.getNationIndicator(newGameScreen.ruleset.nations[player.chosenCiv]!!, 50f)
|
.surroundWithCircle(40f,false).apply { circle.color = Color.WHITE }
|
||||||
nationTable.add(nationImage)
|
else ImageGetter.getNationIndicator(newGameScreen.ruleset.nations[player.chosenCiv]!!, 40f)
|
||||||
nationTable.add(player.chosenCiv.toLabel()).pad(20f)
|
nationTable.add(nationImage).pad(5f)
|
||||||
|
nationTable.add(player.chosenCiv.toLabel()).width(230f).pad(5f)
|
||||||
nationTable.touchable = Touchable.enabled
|
nationTable.touchable = Touchable.enabled
|
||||||
nationTable.onClick {
|
nationTable.onClick {
|
||||||
popupNationPicker(player)
|
popupNationPicker(player)
|
||||||
@ -128,9 +123,10 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
|
|||||||
val randomPlayerTable = Table()
|
val randomPlayerTable = Table()
|
||||||
randomPlayerTable.background = ImageGetter.getBackground(Color.BLACK)
|
randomPlayerTable.background = ImageGetter.getBackground(Color.BLACK)
|
||||||
|
|
||||||
randomPlayerTable.add("?".toLabel(Color.BLACK, 30)
|
randomPlayerTable.add("?".toLabel(Color.WHITE, 30)
|
||||||
.apply { this.setAlignment(Align.center) }
|
.apply { this.setAlignment(Align.center) }
|
||||||
.surroundWithCircle(50f)).pad(10f)
|
.surroundWithCircle(45f).apply { circle.color = Color.BLACK }
|
||||||
|
.surroundWithCircle(50f,false).apply { circle.color = Color.WHITE }).pad(10f)
|
||||||
randomPlayerTable.add("Random".toLabel())
|
randomPlayerTable.add("Random".toLabel())
|
||||||
randomPlayerTable.touchable = Touchable.enabled
|
randomPlayerTable.touchable = Touchable.enabled
|
||||||
randomPlayerTable.onClick {
|
randomPlayerTable.onClick {
|
||||||
|
@ -25,7 +25,7 @@ class Fonts {
|
|||||||
"กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำิีึืฺุู฿เแโใไๅๆ็่้๊๋์ํ๎๏๐๑๒๓๔๕๖๗๘๙๚๛" + // Thai
|
"กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำิีึืฺุู฿เแโใไๅๆ็่้๊๋์ํ๎๏๐๑๒๓๔๕๖๗๘๙๚๛" + // Thai
|
||||||
"İıÇŞşĞğ"+ /// turkish
|
"İıÇŞşĞğ"+ /// turkish
|
||||||
"1234567890" +
|
"1234567890" +
|
||||||
"‘?’'“!”(%)[#]{@}/&\\<-+÷×=>®©\$€£¥¢:;,.¡*|«»—∞"
|
"‘?’'“!”(%)[#]{@}/&\\<-+÷×=>®©\$€£¥¢:;,.¡*|«»—∞✘✔"
|
||||||
val charSet = HashSet<Char>()
|
val charSet = HashSet<Char>()
|
||||||
charSet.addAll(defaultText.asIterable())
|
charSet.addAll(defaultText.asIterable())
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user