Use .toTextButton() in more places. (#5994)

* Use toTextButton for WorldScreenTopbar "Overview".

* Use toTextButton for AddMultiplayerGameScreen "Paste gameID from clipboard".

* Use toTextButton in MultiplayerScreen.

* Use toTextButton for CityOverviewTable city.name.
This commit is contained in:
will-ca 2022-01-19 04:16:21 -08:00 committed by GitHub
parent b0ffae0da0
commit 19927d89ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 22 deletions

View File

@ -7,17 +7,14 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextField
import com.unciv.logic.IdChecker
import com.unciv.models.translations.tr
import com.unciv.ui.pickerscreens.PickerScreen
import com.unciv.ui.utils.ToastPopup
import com.unciv.ui.utils.enable
import com.unciv.ui.utils.onClick
import com.unciv.ui.utils.toLabel
import com.unciv.ui.utils.*
import java.util.*
class AddMultiplayerGameScreen(backScreen: MultiplayerScreen) : PickerScreen(){
init {
val gameNameTextField = TextField("", skin)
val gameIDTextField = TextField("", skin)
val pasteGameIDButton = TextButton("Paste gameID from clipboard", skin)
val pasteGameIDButton = "Paste gameID from clipboard".toTextButton()
pasteGameIDButton.onClick {
gameIDTextField.text = Gdx.app.clipboard.contents
}
@ -52,4 +49,4 @@ class AddMultiplayerGameScreen(backScreen: MultiplayerScreen) : PickerScreen(){
backScreen.game.setScreen(backScreen)
}
}
}
}

View File

@ -23,24 +23,24 @@ class MultiplayerScreen(previousScreen: BaseScreen) : PickerScreen() {
private val rightSideTable = Table()
private val leftSideTable = Table()
private val editButtonText = "Game settings".tr()
private val addGameText = "Add multiplayer game".tr()
private val copyGameIdText = "Copy game ID".tr()
private val copyUserIdText = "Copy user ID".tr()
private val refreshText = "Refresh list".tr()
private val editButtonText = "Game settings"
private val addGameText = "Add multiplayer game"
private val copyGameIdText = "Copy game ID"
private val copyUserIdText = "Copy user ID"
private val refreshText = "Refresh list"
private val editButton = TextButton(editButtonText, skin).apply { disable() }
private val addGameButton = TextButton(addGameText, skin)
private val copyGameIdButton = TextButton(copyGameIdText, skin).apply { disable() }
private val copyUserIdButton = TextButton(copyUserIdText, skin)
private val refreshButton = TextButton(refreshText, skin)
private val editButton = editButtonText.toTextButton().apply { disable() }
private val addGameButton = addGameText.toTextButton()
private val copyGameIdButton = copyGameIdText.toTextButton().apply { disable() }
private val copyUserIdButton = copyUserIdText.toTextButton()
private val refreshButton = refreshText.toTextButton()
init {
setDefaultCloseAction(previousScreen)
//Help Button Setup
val tab = Table()
val helpButton = TextButton("?", skin)
val helpButton = "?".toTextButton()
helpButton.onClick {
val helpPopup = Popup(this)
helpPopup.addGoodSizedLabel("To create a multiplayer game, check the 'multiplayer' toggle in the New Game screen, and for each human player insert that player's user ID.").row()
@ -181,7 +181,7 @@ class MultiplayerScreen(previousScreen: BaseScreen) : PickerScreen() {
}
}
postCrashHandlingRunnable {
addGameButton.setText(addGameText)
addGameButton.setText(addGameText.tr())
addGameButton.enable()
}
}
@ -364,7 +364,7 @@ class MultiplayerScreen(previousScreen: BaseScreen) : PickerScreen() {
//Reset UI
postCrashHandlingRunnable {
addGameButton.enable()
refreshButton.setText(refreshText)
refreshButton.setText(refreshText.tr())
refreshButton.enable()
unselectGame()
reloadGameListUI()

View File

@ -135,7 +135,7 @@ class CityOverviewTable(private val viewingPlayer: CivilizationInfo, private val
val constructionCells: MutableList<Cell<Label>> = mutableListOf()
for (city in cityList) {
val button = Button(city.name.toLabel(), BaseScreen.skin)
val button = city.name.toTextButton()
button.onClick {
overviewScreen.game.setScreen(CityScreen(city))
}

View File

@ -174,8 +174,7 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
.apply { color = Color.FIREBRICK }
.onClick { worldScreen.game.setScreen(EmpireOverviewScreen(worldScreen.selectedCiv, "Units")) }
val overviewButton = Button(BaseScreen.skin)
overviewButton.add("Overview".toLabel()).pad(10f)
val overviewButton = "Overview".toTextButton()
overviewButton.addTooltip('e')
overviewButton.onClick { worldScreen.game.setScreen(EmpireOverviewScreen(worldScreen.selectedCiv)) }