More .toTextButton() changes
This commit is contained in:
parent
77a63ce365
commit
cb2e3a1bce
8 changed files with 20 additions and 27 deletions
|
@ -6,11 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
|||
import com.badlogic.gdx.scenes.scene2d.ui.TextField
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.utils.onClick
|
||||
import com.unciv.ui.utils.toLabel
|
||||
import com.unciv.ui.utils.Popup
|
||||
import com.unciv.ui.utils.*
|
||||
|
||||
class CityScreenCityPickerTable(val cityScreen: CityScreen) : Table(){
|
||||
|
||||
|
@ -20,7 +16,7 @@ class CityScreenCityPickerTable(val cityScreen: CityScreen) : Table(){
|
|||
val civInfo = city.civInfo
|
||||
|
||||
if (civInfo.cities.size > 1) {
|
||||
val prevCityButton = TextButton("<", CameraStageBaseScreen.skin)
|
||||
val prevCityButton = "<".toTextButton()
|
||||
prevCityButton.onClick { cityScreen.page(-1) }
|
||||
add(prevCityButton).pad(20f)
|
||||
} else add()
|
||||
|
@ -67,13 +63,13 @@ class CityScreenCityPickerTable(val cityScreen: CityScreen) : Table(){
|
|||
|
||||
|
||||
if (civInfo.cities.size > 1) {
|
||||
val nextCityButton = TextButton(">", CameraStageBaseScreen.skin)
|
||||
val nextCityButton = ">".toTextButton()
|
||||
nextCityButton.onClick { cityScreen.page(1) }
|
||||
add(nextCityButton).pad(20f)
|
||||
} else add()
|
||||
row()
|
||||
|
||||
val exitCityButton = TextButton("Exit city".tr(), CameraStageBaseScreen.skin)
|
||||
val exitCityButton = "Exit city".toTextButton()
|
||||
exitCityButton.labelCell.pad(10f)
|
||||
|
||||
exitCityButton.onClick { cityScreen.exit() }
|
||||
|
|
|
@ -41,7 +41,7 @@ class CityScreenTileTable(val cityScreen: CityScreen): Table(){
|
|||
&& selectedTile in city.tilesInRange){
|
||||
val goldCostOfTile = city.expansion.getGoldCostOfTile(selectedTile)
|
||||
|
||||
val buyTileButton = TextButton("Buy for [$goldCostOfTile] gold".tr(), CameraStageBaseScreen.skin)
|
||||
val buyTileButton = "Buy for [$goldCostOfTile] gold".toTextButton()
|
||||
buyTileButton.onClick(UncivSound.Coin) {
|
||||
city.expansion.buyTile(selectedTile)
|
||||
UncivGame.Current.setScreen(CityScreen(city))
|
||||
|
@ -53,7 +53,7 @@ class CityScreenTileTable(val cityScreen: CityScreen): Table(){
|
|||
innerTable.add("You have [${city.civInfo.gold}] gold".toLabel(Color.YELLOW, 16)).padTop(2f)
|
||||
}
|
||||
if(city.canAcquireTile(selectedTile)) {
|
||||
val acquireTileButton = TextButton("Acquire".tr(), CameraStageBaseScreen.skin)
|
||||
val acquireTileButton = "Acquire".toTextButton()
|
||||
acquireTileButton.onClick {
|
||||
city.expansion.takeOwnership(selectedTile)
|
||||
UncivGame.Current.setScreen(CityScreen(city))
|
||||
|
@ -63,7 +63,7 @@ class CityScreenTileTable(val cityScreen: CityScreen): Table(){
|
|||
|
||||
if(city.workedTiles.contains(selectedTile.position)){
|
||||
if(selectedTile.isLocked()) {
|
||||
val unlockButton = TextButton("Unlock", CameraStageBaseScreen.skin)
|
||||
val unlockButton = "Unlock".toTextButton()
|
||||
unlockButton.onClick {
|
||||
city.lockedTiles.remove(selectedTile.position)
|
||||
update(selectedTile)
|
||||
|
@ -72,7 +72,7 @@ class CityScreenTileTable(val cityScreen: CityScreen): Table(){
|
|||
innerTable.add(unlockButton).row()
|
||||
}
|
||||
else {
|
||||
val lockButton = TextButton("Lock", CameraStageBaseScreen.skin)
|
||||
val lockButton = "Lock".toTextButton()
|
||||
lockButton.onClick {
|
||||
city.lockedTiles.add(selectedTile.position)
|
||||
update(selectedTile)
|
||||
|
|
|
@ -267,7 +267,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
|||
val button: TextButton
|
||||
|
||||
if (isSelectedQueueEntry()) {
|
||||
button = TextButton("Remove from queue".tr(), CameraStageBaseScreen.skin)
|
||||
button = "Remove from queue".toTextButton()
|
||||
if (!UncivGame.Current.worldScreen.isPlayersTurn || city.isPuppet) button.disable()
|
||||
else {
|
||||
button.onClick {
|
||||
|
@ -278,7 +278,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
|||
}
|
||||
}
|
||||
} else {
|
||||
button = TextButton("Add to queue".tr(), CameraStageBaseScreen.skin)
|
||||
button = "Add to queue".toTextButton()
|
||||
if (construction == null
|
||||
|| cityConstructions.isQueueFull()
|
||||
|| !cityConstructions.getConstruction(construction.name).isBuildable(cityConstructions)
|
||||
|
@ -322,7 +322,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
|||
val city = cityScreen.city
|
||||
val cityConstructions = city.cityConstructions
|
||||
|
||||
val button = TextButton("", CameraStageBaseScreen.skin)
|
||||
val button = "".toTextButton()
|
||||
|
||||
if (construction == null || !construction.canBePurchased()
|
||||
) {
|
||||
|
|
|
@ -49,7 +49,7 @@ class MapDownloadPopup(loadMapScreen: LoadMapScreen): Popup(loadMapScreen) {
|
|||
Gdx.app.postRunnable {
|
||||
scrollableMapTable.apply { defaults().pad(10f) }
|
||||
for (downloadableMap in folderList.entries) {
|
||||
val downloadMapButton = TextButton(downloadableMap.name, CameraStageBaseScreen.skin)
|
||||
val downloadMapButton = downloadableMap.name.toTextButton()
|
||||
listOfMaps.add(downloadMapButton)
|
||||
downloadMapButton.onClick {
|
||||
thread(name = "MapDownload") { loadMap(downloadableMap) }
|
||||
|
|
|
@ -67,7 +67,7 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
|
|||
val nationTable = getNationTable(player)
|
||||
playerTable.add(nationTable)
|
||||
|
||||
val playerTypeTextbutton = TextButton(player.playerType.name.tr(), CameraStageBaseScreen.skin)
|
||||
val playerTypeTextbutton = player.playerType.name.toTextButton()
|
||||
playerTypeTextbutton.onClick {
|
||||
if (player.playerType == PlayerType.AI)
|
||||
player.playerType = PlayerType.Human
|
||||
|
@ -98,14 +98,14 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
|
|||
|
||||
playerIdTextfield.addListener { onPlayerIdTextUpdated(); true }
|
||||
val currentUserId = UncivGame.Current.settings.userId
|
||||
val setCurrentUserButton = TextButton("Set current user".tr(), CameraStageBaseScreen.skin)
|
||||
val setCurrentUserButton = "Set current user".toTextButton()
|
||||
setCurrentUserButton.onClick {
|
||||
playerIdTextfield.text = currentUserId
|
||||
onPlayerIdTextUpdated()
|
||||
}
|
||||
playerTable.add(setCurrentUserButton).colspan(3).fillX().pad(5f).row()
|
||||
|
||||
val copyFromClipboardButton = TextButton("Player ID from clipboard".tr(),CameraStageBaseScreen.skin)
|
||||
val copyFromClipboardButton = "Player ID from clipboard".toTextButton()
|
||||
copyFromClipboardButton.onClick {
|
||||
playerIdTextfield.text = Gdx.app.clipboard.contents
|
||||
onPlayerIdTextUpdated()
|
||||
|
|
|
@ -6,10 +6,7 @@ import com.badlogic.gdx.utils.Array
|
|||
import com.unciv.Constants
|
||||
import com.unciv.models.Tutorial
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.utils.Popup
|
||||
import com.unciv.ui.utils.onClick
|
||||
import com.unciv.ui.utils.*
|
||||
|
||||
data class TutorialForRender(val tutorial: Tutorial, val texts: Array<String>)
|
||||
|
||||
|
@ -33,7 +30,7 @@ class TutorialRender(private val screen: CameraStageBaseScreen) {
|
|||
|
||||
tutorialPopup.addGoodSizedLabel(texts[0]).row()
|
||||
|
||||
val button = TextButton(Constants.close.tr(), CameraStageBaseScreen.skin)
|
||||
val button = Constants.close.toTextButton()
|
||||
button.onClick {
|
||||
tutorialPopup.remove()
|
||||
texts.removeIndex(0)
|
||||
|
|
|
@ -48,7 +48,7 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
|||
pack()
|
||||
addActor(getMenuButton()) // needs to be after pack
|
||||
|
||||
val overviewButton = TextButton("Overview".tr(),CameraStageBaseScreen.skin)
|
||||
val overviewButton = "Overview".toTextButton()
|
||||
overviewButton.labelCell.pad(10f)
|
||||
overviewButton.pack()
|
||||
overviewButton.onClick { UncivGame.Current.setScreen(EmpireOverviewScreen(worldScreen.viewingCiv)) }
|
||||
|
|
|
@ -154,7 +154,7 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen)
|
|||
addMusicVolumeSlider()
|
||||
|
||||
if(Gdx.app.type==Application.ApplicationType.Desktop) {
|
||||
val generateTranslationsButton = TextButton("Generate translation files".tr(), CameraStageBaseScreen.skin)
|
||||
val generateTranslationsButton = "Generate translation files".toTextButton()
|
||||
generateTranslationsButton.onClick {
|
||||
val translations = Translations()
|
||||
translations.readAllLanguagesTranslation()
|
||||
|
@ -202,7 +202,7 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen)
|
|||
}
|
||||
innerTable.add(musicVolumeSlider).pad(10f).row()
|
||||
} else {
|
||||
val downloadMusicButton = TextButton("Download music".tr(), CameraStageBaseScreen.skin)
|
||||
val downloadMusicButton = "Download music".toTextButton()
|
||||
innerTable.add(downloadMusicButton).colspan(2).row()
|
||||
val errorTable = Table()
|
||||
innerTable.add(errorTable).colspan(2).row()
|
||||
|
|
Loading…
Reference in a new issue