mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 22:37:02 -04:00
Added "Buy tile" option to cities
This commit is contained in:
parent
52740ff28f
commit
5710001715
@ -21,8 +21,8 @@ android {
|
|||||||
applicationId "com.unciv.game"
|
applicationId "com.unciv.game"
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 138
|
versionCode 139
|
||||||
versionName "2.8.6"
|
versionName "2.8.7"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
@ -70,7 +70,7 @@ class Automation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getMinDistanceBetweenCities(civ1:CivilizationInfo,civ2:CivilizationInfo): Float {
|
fun getMinDistanceBetweenCities(civ1:CivilizationInfo,civ2:CivilizationInfo): Int {
|
||||||
return civ1.cities.map { city -> civ2.cities.map { it.getCenterTile().arialDistanceTo(city.getCenterTile()) }.min()!! }.min()!!
|
return civ1.cities.map { city -> civ2.cities.map { it.getCenterTile().arialDistanceTo(city.getCenterTile()) }.min()!! }.min()!!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,22 @@ class CityExpansionManager {
|
|||||||
return Math.round(cultureToNextTile).toInt()
|
return Math.round(cultureToNextTile).toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun buyTile(tileInfo: TileInfo){
|
||||||
|
val goldCost = getGoldCostOfTile(tileInfo)
|
||||||
|
class NotEnoughGoldToBuyTileException : Exception()
|
||||||
|
if(cityInfo.civInfo.gold<goldCost) throw NotEnoughGoldToBuyTileException()
|
||||||
|
cityInfo.civInfo.gold -= goldCost
|
||||||
|
takeOwnership(tileInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getGoldCostOfTile(tileInfo: TileInfo): Int {
|
||||||
|
val baseCost = 50
|
||||||
|
val numTilesClaimed= cityInfo.tiles.size - 7
|
||||||
|
val distanceFromCenter = tileInfo.arialDistanceTo(cityInfo.getCenterTile())
|
||||||
|
val cost = baseCost * (distanceFromCenter-1) + numTilesClaimed*5
|
||||||
|
return cost
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fun chooseNewTileToOwn(): TileInfo? {
|
fun chooseNewTileToOwn(): TileInfo? {
|
||||||
for (i in 2..5) {
|
for (i in 2..5) {
|
||||||
|
@ -208,10 +208,14 @@ class MapUnit {
|
|||||||
fun moveToTile(otherTile: TileInfo) {
|
fun moveToTile(otherTile: TileInfo) {
|
||||||
if(otherTile==getTile()) return // already here!
|
if(otherTile==getTile()) return // already here!
|
||||||
val distanceToTiles = getDistanceToTiles()
|
val distanceToTiles = getDistanceToTiles()
|
||||||
|
|
||||||
|
class YouCantGetThereFromHereException : Exception()
|
||||||
if (!distanceToTiles.containsKey(otherTile))
|
if (!distanceToTiles.containsKey(otherTile))
|
||||||
throw Exception("You can't get there from here!")
|
throw YouCantGetThereFromHereException()
|
||||||
|
|
||||||
|
class CantEnterThisTileException : Exception()
|
||||||
if(!canMoveTo(otherTile))
|
if(!canMoveTo(otherTile))
|
||||||
throw Exception("Can't enter this tile!")
|
throw CantEnterThisTileException()
|
||||||
if(otherTile.isCityCenter() && otherTile.getOwner()!=civInfo) throw Exception("This is an enemy city, you can't go here!")
|
if(otherTile.isCityCenter() && otherTile.getOwner()!=civInfo) throw Exception("This is an enemy city, you can't go here!")
|
||||||
|
|
||||||
currentMovement -= distanceToTiles[otherTile]!!
|
currentMovement -= distanceToTiles[otherTile]!!
|
||||||
|
@ -244,5 +244,5 @@ open class TileInfo {
|
|||||||
return city!=null && city.workedTiles.contains(position)
|
return city!=null && city.workedTiles.contains(position)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun arialDistanceTo(otherTile:TileInfo) = abs(position.x-otherTile.position.x) + abs(position.y-otherTile.position.y)
|
fun arialDistanceTo(otherTile:TileInfo): Int = (abs(position.x-otherTile.position.x) + abs(position.y-otherTile.position.y)).toInt()
|
||||||
}
|
}
|
@ -34,7 +34,8 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
|
|||||||
offers.add(TradeOffer(city.name, TradeType.City, 0, 1))
|
offers.add(TradeOffer(city.name, TradeType.City, 0, 1))
|
||||||
|
|
||||||
val civsWeKnowAndTheyDont = civInfo.diplomacy.values.map { it.otherCiv() }
|
val civsWeKnowAndTheyDont = civInfo.diplomacy.values.map { it.otherCiv() }
|
||||||
.filter { !otherCivilization.diplomacy.containsKey(it.civName) && it != otherCivilization }
|
.filter { !otherCivilization.diplomacy.containsKey(it.civName)
|
||||||
|
&& it != otherCivilization && !it.isBarbarianCivilization() }
|
||||||
for(thirdCiv in civsWeKnowAndTheyDont){
|
for(thirdCiv in civsWeKnowAndTheyDont){
|
||||||
offers.add(TradeOffer("Introduction to " + thirdCiv.civName, TradeType.Introduction, 0,1))
|
offers.add(TradeOffer("Introduction to " + thirdCiv.civName, TradeType.Introduction, 0,1))
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import com.unciv.UnCivGame
|
|||||||
import com.unciv.models.gamebasics.GameBasics
|
import com.unciv.models.gamebasics.GameBasics
|
||||||
import com.unciv.models.gamebasics.ICivilopedia
|
import com.unciv.models.gamebasics.ICivilopedia
|
||||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||||
import com.unciv.ui.utils.addClickListener
|
import com.unciv.ui.utils.onClick
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class CivilopediaScreen : CameraStageBaseScreen() {
|
class CivilopediaScreen : CameraStageBaseScreen() {
|
||||||
@ -27,7 +27,7 @@ class CivilopediaScreen : CameraStageBaseScreen() {
|
|||||||
label.setWrap(true)
|
label.setWrap(true)
|
||||||
|
|
||||||
val goToGameButton = TextButton("Return \r\nto game", CameraStageBaseScreen.skin)
|
val goToGameButton = TextButton("Return \r\nto game", CameraStageBaseScreen.skin)
|
||||||
goToGameButton.addClickListener {
|
goToGameButton.onClick {
|
||||||
game.setWorldScreen()
|
game.setWorldScreen()
|
||||||
dispose()
|
dispose()
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ class CivilopediaScreen : CameraStageBaseScreen() {
|
|||||||
val nameListClickListener = {
|
val nameListClickListener = {
|
||||||
if(nameList.selected!=null) label.setText(nameList.selected.description)
|
if(nameList.selected!=null) label.setText(nameList.selected.description)
|
||||||
}
|
}
|
||||||
nameList.addClickListener (nameListClickListener)
|
nameList.onClick (nameListClickListener)
|
||||||
|
|
||||||
nameList.style = List.ListStyle(nameList.style)
|
nameList.style = List.ListStyle(nameList.style)
|
||||||
nameList.style.fontColorSelected = Color.BLACK
|
nameList.style.fontColorSelected = Color.BLACK
|
||||||
@ -70,7 +70,7 @@ class CivilopediaScreen : CameraStageBaseScreen() {
|
|||||||
for (btn in buttons) btn.isChecked = false
|
for (btn in buttons) btn.isChecked = false
|
||||||
button.isChecked = true
|
button.isChecked = true
|
||||||
}
|
}
|
||||||
button.addClickListener(buttonClicked)
|
button.onClick(buttonClicked)
|
||||||
if (first) {// Fake-click the first button so that the user sees results immediately
|
if (first) {// Fake-click the first button so that the user sees results immediately
|
||||||
first = false
|
first = false
|
||||||
buttonClicked()
|
buttonClicked()
|
||||||
|
@ -21,7 +21,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
val centerTable=Table().apply { defaults().pad(20f) }
|
val centerTable=Table().apply { defaults().pad(20f) }
|
||||||
|
|
||||||
val closeButton = TextButton("Close".tr(), skin)
|
val closeButton = TextButton("Close".tr(), skin)
|
||||||
closeButton.addClickListener { UnCivGame.Current.setWorldScreen() }
|
closeButton.onClick { UnCivGame.Current.setWorldScreen() }
|
||||||
closeButton.y = stage.height - closeButton.height - 5
|
closeButton.y = stage.height - closeButton.height - 5
|
||||||
topTable.add(closeButton)
|
topTable.add(closeButton)
|
||||||
|
|
||||||
@ -33,11 +33,11 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
centerTable.center(stage)
|
centerTable.center(stage)
|
||||||
}
|
}
|
||||||
setCities()
|
setCities()
|
||||||
setCityInfoButton.addClickListener(setCities)
|
setCityInfoButton.onClick(setCities)
|
||||||
topTable.add(setCityInfoButton)
|
topTable.add(setCityInfoButton)
|
||||||
|
|
||||||
val setStatsInfoButton = TextButton("Stats".tr(),skin)
|
val setStatsInfoButton = TextButton("Stats".tr(),skin)
|
||||||
setStatsInfoButton.addClickListener {
|
setStatsInfoButton.onClick {
|
||||||
centerTable.clear()
|
centerTable.clear()
|
||||||
centerTable.add(getHappinessTable())
|
centerTable.add(getHappinessTable())
|
||||||
centerTable.add(getGoldTable())
|
centerTable.add(getGoldTable())
|
||||||
@ -47,7 +47,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
topTable.add(setStatsInfoButton)
|
topTable.add(setStatsInfoButton)
|
||||||
|
|
||||||
val setCurrentTradesButton = TextButton("Trades".tr(),skin)
|
val setCurrentTradesButton = TextButton("Trades".tr(),skin)
|
||||||
setCurrentTradesButton.addClickListener {
|
setCurrentTradesButton.onClick {
|
||||||
centerTable.clear()
|
centerTable.clear()
|
||||||
centerTable.add(ScrollPane(getTradesTable())).height(stage.height*0.8f) // so it doesn't cover the naviagation buttons
|
centerTable.add(ScrollPane(getTradesTable())).height(stage.height*0.8f) // so it doesn't cover the naviagation buttons
|
||||||
centerTable.pack()
|
centerTable.pack()
|
||||||
@ -56,7 +56,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
topTable.add(setCurrentTradesButton)
|
topTable.add(setCurrentTradesButton)
|
||||||
|
|
||||||
val setUnitsButton = TextButton("Units".tr(),skin)
|
val setUnitsButton = TextButton("Units".tr(),skin)
|
||||||
setUnitsButton .addClickListener {
|
setUnitsButton .onClick {
|
||||||
centerTable.clear()
|
centerTable.clear()
|
||||||
centerTable.add(getUnitTable())
|
centerTable.add(getUnitTable())
|
||||||
centerTable.pack()
|
centerTable.pack()
|
||||||
|
@ -9,7 +9,7 @@ import com.unciv.UnCivGame
|
|||||||
import com.unciv.models.gamebasics.GameBasics
|
import com.unciv.models.gamebasics.GameBasics
|
||||||
import com.unciv.ui.pickerscreens.PickerScreen
|
import com.unciv.ui.pickerscreens.PickerScreen
|
||||||
import com.unciv.ui.utils.ImageGetter
|
import com.unciv.ui.utils.ImageGetter
|
||||||
import com.unciv.ui.utils.addClickListener
|
import com.unciv.ui.utils.onClick
|
||||||
import com.unciv.ui.utils.enable
|
import com.unciv.ui.utils.enable
|
||||||
import com.unciv.ui.utils.tr
|
import com.unciv.ui.utils.tr
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ class LanguagePickerScreen: PickerScreen(){
|
|||||||
.sortedByDescending { it.percentComplete } )
|
.sortedByDescending { it.percentComplete } )
|
||||||
|
|
||||||
languageTables.forEach {
|
languageTables.forEach {
|
||||||
it.addClickListener {
|
it.onClick {
|
||||||
chosenLanguage = it.language
|
chosenLanguage = it.language
|
||||||
rightSideButton.enable()
|
rightSideButton.enable()
|
||||||
update()
|
update()
|
||||||
@ -70,7 +70,7 @@ class LanguagePickerScreen: PickerScreen(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
rightSideButton.setText("Pick language".tr())
|
rightSideButton.setText("Pick language".tr())
|
||||||
rightSideButton.addClickListener {
|
rightSideButton.onClick {
|
||||||
UnCivGame.Current.settings.language = chosenLanguage
|
UnCivGame.Current.settings.language = chosenLanguage
|
||||||
UnCivGame.Current.settings.save()
|
UnCivGame.Current.settings.save()
|
||||||
UnCivGame.Current.startNewGame()
|
UnCivGame.Current.startNewGame()
|
||||||
|
@ -21,7 +21,7 @@ class LoadScreen : PickerScreen() {
|
|||||||
val saveTable = Table()
|
val saveTable = Table()
|
||||||
|
|
||||||
val deleteSaveButton = TextButton("Delete save".tr(), CameraStageBaseScreen.skin)
|
val deleteSaveButton = TextButton("Delete save".tr(), CameraStageBaseScreen.skin)
|
||||||
deleteSaveButton .addClickListener {
|
deleteSaveButton .onClick {
|
||||||
GameSaver().deleteSave(selectedSave)
|
GameSaver().deleteSave(selectedSave)
|
||||||
UnCivGame.Current.screen = LoadScreen()
|
UnCivGame.Current.screen = LoadScreen()
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ class LoadScreen : PickerScreen() {
|
|||||||
rightSideButton.setText("Load game".tr())
|
rightSideButton.setText("Load game".tr())
|
||||||
saves.forEach {
|
saves.forEach {
|
||||||
val textButton = TextButton(it,skin)
|
val textButton = TextButton(it,skin)
|
||||||
textButton.addClickListener {
|
textButton.onClick {
|
||||||
selectedSave=it
|
selectedSave=it
|
||||||
|
|
||||||
var textToSet = it
|
var textToSet = it
|
||||||
@ -58,7 +58,7 @@ class LoadScreen : PickerScreen() {
|
|||||||
val rightSideTable = Table()
|
val rightSideTable = Table()
|
||||||
val loadFromClipboardButton = TextButton("Load copied data".tr(),skin)
|
val loadFromClipboardButton = TextButton("Load copied data".tr(),skin)
|
||||||
val errorLabel = Label("",skin).setFontColor(Color.RED)
|
val errorLabel = Label("",skin).setFontColor(Color.RED)
|
||||||
loadFromClipboardButton.addClickListener {
|
loadFromClipboardButton.onClick {
|
||||||
try{
|
try{
|
||||||
val clipboardContentsString = Gdx.app.clipboard.contents
|
val clipboardContentsString = Gdx.app.clipboard.contents
|
||||||
val decoded = Gzip.decompress(Gzip.decoder(clipboardContentsString))
|
val decoded = Gzip.decompress(Gzip.decoder(clipboardContentsString))
|
||||||
@ -75,7 +75,7 @@ class LoadScreen : PickerScreen() {
|
|||||||
rightSideTable.add(deleteSaveButton)
|
rightSideTable.add(deleteSaveButton)
|
||||||
topTable.add(rightSideTable)
|
topTable.add(rightSideTable)
|
||||||
|
|
||||||
rightSideButton.addClickListener {
|
rightSideButton.onClick {
|
||||||
UnCivGame.Current.loadGame(selectedSave)
|
UnCivGame.Current.loadGame(selectedSave)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class NewGameScreen: PickerScreen(){
|
|||||||
background=ImageGetter.getBackground(nation.getColor().apply { a=0.5f })
|
background=ImageGetter.getBackground(nation.getColor().apply { a=0.5f })
|
||||||
add(Label(nation.name, skin).apply { setFontColor(nation.getSecondaryColor())}).row()
|
add(Label(nation.name, skin).apply { setFontColor(nation.getSecondaryColor())}).row()
|
||||||
add(Label(getUniqueLabel(nation), skin).apply { setWrap(true);setFontColor(nation.getSecondaryColor())}).width(width)
|
add(Label(getUniqueLabel(nation), skin).apply { setWrap(true);setFontColor(nation.getSecondaryColor())}).width(width)
|
||||||
addClickListener { newGameParameters.nation=nation.name; onClick() }
|
onClick { newGameParameters.nation=nation.name; onClick() }
|
||||||
touchable=Touchable.enabled
|
touchable=Touchable.enabled
|
||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
@ -142,7 +142,7 @@ class NewGameScreen: PickerScreen(){
|
|||||||
|
|
||||||
rightSideButton.enable()
|
rightSideButton.enable()
|
||||||
rightSideButton.setText("Start game!".tr())
|
rightSideButton.setText("Start game!".tr())
|
||||||
rightSideButton.addClickListener {
|
rightSideButton.onClick {
|
||||||
Gdx.input.inputProcessor = null // remove input processing - nothing will be clicked!
|
Gdx.input.inputProcessor = null // remove input processing - nothing will be clicked!
|
||||||
rightSideButton.disable()
|
rightSideButton.disable()
|
||||||
rightSideButton.setText("Working...".tr())
|
rightSideButton.setText("Working...".tr())
|
||||||
|
@ -10,7 +10,7 @@ import com.badlogic.gdx.utils.Json
|
|||||||
import com.unciv.UnCivGame
|
import com.unciv.UnCivGame
|
||||||
import com.unciv.logic.GameSaver
|
import com.unciv.logic.GameSaver
|
||||||
import com.unciv.ui.pickerscreens.PickerScreen
|
import com.unciv.ui.pickerscreens.PickerScreen
|
||||||
import com.unciv.ui.utils.addClickListener
|
import com.unciv.ui.utils.onClick
|
||||||
import com.unciv.ui.utils.enable
|
import com.unciv.ui.utils.enable
|
||||||
import com.unciv.ui.utils.getRandom
|
import com.unciv.ui.utils.getRandom
|
||||||
import com.unciv.ui.utils.tr
|
import com.unciv.ui.utils.tr
|
||||||
@ -33,7 +33,7 @@ class SaveScreen : PickerScreen() {
|
|||||||
val saves = GameSaver().getSaves()
|
val saves = GameSaver().getSaves()
|
||||||
saves.forEach {
|
saves.forEach {
|
||||||
val textButton = TextButton(it, skin)
|
val textButton = TextButton(it, skin)
|
||||||
textButton.addClickListener {
|
textButton.onClick {
|
||||||
textField.text = it
|
textField.text = it
|
||||||
}
|
}
|
||||||
currentSaves.add(textButton).pad(5f).row()
|
currentSaves.add(textButton).pad(5f).row()
|
||||||
@ -55,7 +55,7 @@ class SaveScreen : PickerScreen() {
|
|||||||
newSave.add(textField).width(300f).pad(10f).row()
|
newSave.add(textField).width(300f).pad(10f).row()
|
||||||
|
|
||||||
val copyJsonButton = TextButton("Copy game info".tr(),skin)
|
val copyJsonButton = TextButton("Copy game info".tr(),skin)
|
||||||
copyJsonButton.addClickListener {
|
copyJsonButton.onClick {
|
||||||
val json = Json().toJson(game.gameInfo)
|
val json = Json().toJson(game.gameInfo)
|
||||||
val base64Gzip = Gzip.encoder(Gzip.compress(json))
|
val base64Gzip = Gzip.encoder(Gzip.compress(json))
|
||||||
Gdx.app.clipboard.contents = base64Gzip
|
Gdx.app.clipboard.contents = base64Gzip
|
||||||
@ -66,7 +66,7 @@ class SaveScreen : PickerScreen() {
|
|||||||
topTable.pack()
|
topTable.pack()
|
||||||
|
|
||||||
rightSideButton.setText("Save game".tr())
|
rightSideButton.setText("Save game".tr())
|
||||||
rightSideButton.addClickListener {
|
rightSideButton.onClick {
|
||||||
GameSaver().saveGame(UnCivGame.Current.gameInfo, textField.text)
|
GameSaver().saveGame(UnCivGame.Current.gameInfo, textField.text)
|
||||||
UnCivGame.Current.setWorldScreen()
|
UnCivGame.Current.setWorldScreen()
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
|||||||
import com.unciv.UnCivGame
|
import com.unciv.UnCivGame
|
||||||
import com.unciv.models.gamebasics.GameBasics
|
import com.unciv.models.gamebasics.GameBasics
|
||||||
import com.unciv.ui.pickerscreens.PickerScreen
|
import com.unciv.ui.pickerscreens.PickerScreen
|
||||||
import com.unciv.ui.utils.addClickListener
|
import com.unciv.ui.utils.onClick
|
||||||
import com.unciv.ui.utils.enable
|
import com.unciv.ui.utils.enable
|
||||||
import com.unciv.ui.utils.tr
|
import com.unciv.ui.utils.tr
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ class VictoryScreen : PickerScreen() {
|
|||||||
rightSideButton.isVisible=true
|
rightSideButton.isVisible=true
|
||||||
closeButton.isVisible=false
|
closeButton.isVisible=false
|
||||||
rightSideButton.enable()
|
rightSideButton.enable()
|
||||||
rightSideButton.addClickListener { UnCivGame.Current.startNewGame() }
|
rightSideButton.onClick { UnCivGame.Current.startNewGame() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun scienceVictoryColumn():Table{
|
fun scienceVictoryColumn():Table{
|
||||||
|
@ -9,7 +9,7 @@ import com.unciv.models.stats.Stat
|
|||||||
import com.unciv.models.stats.Stats
|
import com.unciv.models.stats.Stats
|
||||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||||
import com.unciv.ui.utils.ImageGetter.getImage
|
import com.unciv.ui.utils.ImageGetter.getImage
|
||||||
import com.unciv.ui.utils.addClickListener
|
import com.unciv.ui.utils.onClick
|
||||||
import com.unciv.ui.utils.setFont
|
import com.unciv.ui.utils.setFont
|
||||||
|
|
||||||
|
|
||||||
@ -79,11 +79,11 @@ class BuildingsTable(private val cityScreen: CityScreen) : Table() {
|
|||||||
val specialist = getImage(imageName)
|
val specialist = getImage(imageName)
|
||||||
specialist.setSize(50f, 50f)
|
specialist.setSize(50f, 50f)
|
||||||
if (!isFilled) specialist.color = Color.GRAY
|
if (!isFilled) specialist.color = Color.GRAY
|
||||||
specialist.addClickListener( {
|
specialist.onClick( {
|
||||||
val cityInfo = cityScreen.city
|
val cityInfo = cityScreen.city
|
||||||
when {
|
when {
|
||||||
isFilled -> cityInfo.population.buildingsSpecialists[building]!!.add(stat,-1f) //unassign
|
isFilled -> cityInfo.population.buildingsSpecialists[building]!!.add(stat,-1f) //unassign
|
||||||
cityInfo.population.getFreePopulation() == 0 -> return@addClickListener
|
cityInfo.population.getFreePopulation() == 0 -> return@onClick
|
||||||
else -> {
|
else -> {
|
||||||
if (!cityInfo.population.buildingsSpecialists.containsKey(building))
|
if (!cityInfo.population.buildingsSpecialists.containsKey(building))
|
||||||
cityInfo.population.buildingsSpecialists[building] = Stats()
|
cityInfo.population.buildingsSpecialists[building] = Stats()
|
||||||
|
@ -102,11 +102,12 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
private fun updateTileGroups() {
|
private fun updateTileGroups() {
|
||||||
val nextTile = city.expansion.chooseNewTileToOwn()
|
val nextTile = city.expansion.chooseNewTileToOwn()
|
||||||
for (HG in tileGroups) {
|
for (tileGroup in tileGroups) {
|
||||||
HG.update()
|
|
||||||
if(HG.tileInfo == nextTile){
|
tileGroup.update()
|
||||||
HG.showCircle(Color.PURPLE)
|
if(tileGroup.tileInfo == nextTile){
|
||||||
HG.setColor(0f,0f,0f,0.7f)
|
tileGroup.showCircle(Color.PURPLE)
|
||||||
|
tileGroup.setColor(0f,0f,0f,0.7f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +120,7 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
|||||||
val civInfo = city.civInfo
|
val civInfo = city.civInfo
|
||||||
if (civInfo.cities.size > 1) {
|
if (civInfo.cities.size > 1) {
|
||||||
val prevCityButton = TextButton("<", CameraStageBaseScreen.skin)
|
val prevCityButton = TextButton("<", CameraStageBaseScreen.skin)
|
||||||
prevCityButton.addClickListener {
|
prevCityButton.onClick {
|
||||||
val indexOfCity = civInfo.cities.indexOf(city)
|
val indexOfCity = civInfo.cities.indexOf(city)
|
||||||
val indexOfNextCity = if (indexOfCity == 0) civInfo.cities.size - 1 else indexOfCity - 1
|
val indexOfNextCity = if (indexOfCity == 0) civInfo.cities.size - 1 else indexOfCity - 1
|
||||||
game.screen = CityScreen(civInfo.cities[indexOfNextCity])
|
game.screen = CityScreen(civInfo.cities[indexOfNextCity])
|
||||||
@ -145,7 +146,7 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
if (civInfo.cities.size > 1) {
|
if (civInfo.cities.size > 1) {
|
||||||
val nextCityButton = TextButton(">", CameraStageBaseScreen.skin)
|
val nextCityButton = TextButton(">", CameraStageBaseScreen.skin)
|
||||||
nextCityButton.addClickListener {
|
nextCityButton.onClick {
|
||||||
val indexOfCity = civInfo.cities.indexOf(city)
|
val indexOfCity = civInfo.cities.indexOf(city)
|
||||||
val indexOfNextCity = if (indexOfCity == civInfo.cities.size - 1) 0 else indexOfCity + 1
|
val indexOfNextCity = if (indexOfCity == civInfo.cities.size - 1) 0 else indexOfCity + 1
|
||||||
game.screen = CityScreen(civInfo.cities[indexOfNextCity])
|
game.screen = CityScreen(civInfo.cities[indexOfNextCity])
|
||||||
@ -157,12 +158,12 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
if(!city.isBeingRazed) {
|
if(!city.isBeingRazed) {
|
||||||
val razeCityButton = TextButton("Raze city".tr(), skin)
|
val razeCityButton = TextButton("Raze city".tr(), skin)
|
||||||
razeCityButton.addClickListener { city.isBeingRazed=true; update() }
|
razeCityButton.onClick { city.isBeingRazed=true; update() }
|
||||||
cityPickerTable.add(razeCityButton).colspan(cityPickerTable.columns)
|
cityPickerTable.add(razeCityButton).colspan(cityPickerTable.columns)
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
val stopRazingCityButton = TextButton("Stop razing city".tr(), skin)
|
val stopRazingCityButton = TextButton("Stop razing city".tr(), skin)
|
||||||
stopRazingCityButton.addClickListener { city.isBeingRazed=false; update() }
|
stopRazingCityButton.onClick { city.isBeingRazed=false; update() }
|
||||||
cityPickerTable.add(stopRazingCityButton).colspan(cityPickerTable.columns)
|
cityPickerTable.add(stopRazingCityButton).colspan(cityPickerTable.columns)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +174,7 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
private fun updateGoToWorldButton() {
|
private fun updateGoToWorldButton() {
|
||||||
goToWorldButton.clearListeners()
|
goToWorldButton.clearListeners()
|
||||||
goToWorldButton.addClickListener {
|
goToWorldButton.onClick {
|
||||||
game.setWorldScreen()
|
game.setWorldScreen()
|
||||||
game.worldScreen.tileMapHolder.setCenterPosition(city.location)
|
game.worldScreen.tileMapHolder.setCenterPosition(city.location)
|
||||||
dispose()
|
dispose()
|
||||||
@ -191,36 +192,38 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
for (tileInfo in cityInfo.getCenterTile().getTilesInDistance(5)) {
|
for (tileInfo in cityInfo.getCenterTile().getTilesInDistance(5)) {
|
||||||
if (!city.civInfo.exploredTiles.contains(tileInfo.position)) continue // Don't even bother to display it.
|
if (!city.civInfo.exploredTiles.contains(tileInfo.position)) continue // Don't even bother to display it.
|
||||||
val group = CityTileGroup(cityInfo, tileInfo)
|
val tileGroup = CityTileGroup(cityInfo, tileInfo)
|
||||||
group.addClickListener {
|
val tilesInRange = city.getTilesInRange()
|
||||||
|
|
||||||
|
// this needs to happen on pdate, because we can buy tiles, which changes the definition of the bought tiles...
|
||||||
|
if (tileInfo.getCity()!=city) { // outside of city
|
||||||
|
tileGroup.setColor(0f, 0f, 0f, 0.3f)
|
||||||
|
tileGroup.yieldGroup.isVisible = false
|
||||||
|
} else if(tileInfo !in tilesInRange){ // within city but not close enough to be workable
|
||||||
|
tileGroup.yieldGroup.isVisible = false
|
||||||
|
}
|
||||||
|
else if (!tileInfo.isCityCenter() && tileGroup.populationImage==null) { // workable
|
||||||
|
tileGroup.addPopulationIcon()
|
||||||
|
tileGroup.populationImage!!.onClick {
|
||||||
|
if (!tileInfo.isWorked() && city.population.getFreePopulation() > 0)
|
||||||
|
city.workedTiles.add(tileInfo.position)
|
||||||
|
else if (tileInfo.isWorked()) city.workedTiles.remove(tileInfo.position)
|
||||||
|
city.cityStats.update()
|
||||||
|
update()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tileGroup.onClick {
|
||||||
selectedTile = tileInfo
|
selectedTile = tileInfo
|
||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
|
||||||
val tilesInRange = city.getTilesInRange()
|
|
||||||
if (tileInfo.getCity()!=city) { // outside of city
|
|
||||||
group.setColor(0f, 0f, 0f, 0.3f)
|
|
||||||
group.yieldGroup.isVisible = false
|
|
||||||
} else if(tileInfo !in tilesInRange){ // within city but not close enough to be workable
|
|
||||||
group.yieldGroup.isVisible = false
|
|
||||||
}
|
|
||||||
else if (!tileInfo.isCityCenter()) { // workable
|
|
||||||
group.addPopulationIcon()
|
|
||||||
group.populationImage!!.addClickListener {
|
|
||||||
if (!tileInfo.isWorked() && cityInfo.population.getFreePopulation() > 0)
|
|
||||||
cityInfo.workedTiles.add(tileInfo.position)
|
|
||||||
else if (tileInfo.isWorked()) cityInfo.workedTiles.remove(tileInfo.position)
|
|
||||||
cityInfo.cityStats.update()
|
|
||||||
update()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val positionalVector = HexMath().Hex2WorldCoords(tileInfo.position.cpy().sub(cityInfo.location))
|
val positionalVector = HexMath().Hex2WorldCoords(tileInfo.position.cpy().sub(cityInfo.location))
|
||||||
val groupSize = 50
|
val groupSize = 50
|
||||||
group.setPosition(stage.width / 2 + positionalVector.x * 0.8f * groupSize.toFloat(),
|
tileGroup.setPosition(stage.width / 2 + positionalVector.x * 0.8f * groupSize.toFloat(),
|
||||||
stage.height / 2 + positionalVector.y * 0.8f * groupSize.toFloat())
|
stage.height / 2 + positionalVector.y * 0.8f * groupSize.toFloat())
|
||||||
tileGroups.add(group)
|
tileGroups.add(tileGroup)
|
||||||
allTiles.addActor(group)
|
allTiles.addActor(tileGroup)
|
||||||
}
|
}
|
||||||
|
|
||||||
val scrollPane = ScrollPane(allTiles)
|
val scrollPane = ScrollPane(allTiles)
|
||||||
@ -251,19 +254,30 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
private fun updateTileTable() {
|
private fun updateTileTable() {
|
||||||
if (selectedTile == null) return
|
if (selectedTile == null) return
|
||||||
|
val tile = selectedTile!!
|
||||||
tileTable.clearChildren()
|
tileTable.clearChildren()
|
||||||
|
|
||||||
val stats = selectedTile!!.getTileStats(city, city.civInfo)
|
val stats = tile.getTileStats(city, city.civInfo)
|
||||||
tileTable.pad(20f)
|
tileTable.pad(20f)
|
||||||
tileTable.columnDefaults(0).padRight(10f)
|
tileTable.columnDefaults(0).padRight(10f)
|
||||||
|
|
||||||
tileTable.add(Label(selectedTile!!.toString(), CameraStageBaseScreen.skin)).colspan(2)
|
tileTable.add(Label(tile.toString(), CameraStageBaseScreen.skin)).colspan(2)
|
||||||
tileTable.row()
|
tileTable.row()
|
||||||
|
|
||||||
|
val statsTable = Table()
|
||||||
for (entry in stats.toHashMap().filterNot { it.value==0f }) {
|
for (entry in stats.toHashMap().filterNot { it.value==0f }) {
|
||||||
tileTable.add(ImageGetter.getStatIcon(entry.key.toString())).size(20f).align(Align.right)
|
statsTable.add(ImageGetter.getStatIcon(entry.key.toString())).size(20f).align(Align.right)
|
||||||
tileTable.add(Label(Math.round(entry.value).toString() + "", CameraStageBaseScreen.skin)).align(Align.left)
|
statsTable.add(Label(Math.round(entry.value).toString() + "", CameraStageBaseScreen.skin)).align(Align.left)
|
||||||
tileTable.row()
|
statsTable.row()
|
||||||
|
}
|
||||||
|
tileTable.add(statsTable).row()
|
||||||
|
|
||||||
|
if(tile.getOwner()==null && tile.neighbors.any{it.getCity()==city}){
|
||||||
|
val goldCostOfTile = city.expansion.getGoldCostOfTile(tile)
|
||||||
|
val buyTileButton = TextButton("Buy for [$goldCostOfTile] gold".tr(),skin)
|
||||||
|
buyTileButton.onClick { city.expansion.buyTile(tile); game.screen = CityScreen(city); dispose() }
|
||||||
|
if(goldCostOfTile>city.civInfo.gold) buyTileButton.disable()
|
||||||
|
tileTable.add(buyTileButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
tileTable.pack()
|
tileTable.pack()
|
||||||
|
@ -51,7 +51,7 @@ class CityStatsTable(val cityScreen: CityScreen) : Table(){
|
|||||||
buildingPickButton.add(ImageGetter.getConstructionImage(city.cityConstructions.currentConstruction))
|
buildingPickButton.add(ImageGetter.getConstructionImage(city.cityConstructions.currentConstruction))
|
||||||
.size(40f).padRight(5f)
|
.size(40f).padRight(5f)
|
||||||
buildingPickButton.add(Label(buildingText , CameraStageBaseScreen.skin).setFontColor(Color.WHITE))
|
buildingPickButton.add(Label(buildingText , CameraStageBaseScreen.skin).setFontColor(Color.WHITE))
|
||||||
buildingPickButton.addClickListener {
|
buildingPickButton.onClick {
|
||||||
UnCivGame.Current.screen = ConstructionPickerScreen(city)
|
UnCivGame.Current.screen = ConstructionPickerScreen(city)
|
||||||
cityScreen.dispose()
|
cityScreen.dispose()
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ class CityStatsTable(val cityScreen: CityScreen) : Table(){
|
|||||||
row()
|
row()
|
||||||
val buildingGoldCost = construction.getGoldCost(city.civInfo.policies.getAdoptedPolicies())
|
val buildingGoldCost = construction.getGoldCost(city.civInfo.policies.getAdoptedPolicies())
|
||||||
val buildingBuyButton = TextButton("Buy for [$buildingGoldCost] gold".tr(), CameraStageBaseScreen.skin)
|
val buildingBuyButton = TextButton("Buy for [$buildingGoldCost] gold".tr(), CameraStageBaseScreen.skin)
|
||||||
buildingBuyButton.addClickListener {
|
buildingBuyButton.onClick {
|
||||||
city.cityConstructions.purchaseBuilding(city.cityConstructions.currentConstruction)
|
city.cityConstructions.purchaseBuilding(city.cityConstructions.currentConstruction)
|
||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import com.unciv.logic.city.SpecialConstruction
|
|||||||
import com.unciv.models.gamebasics.GameBasics
|
import com.unciv.models.gamebasics.GameBasics
|
||||||
import com.unciv.ui.cityscreen.CityScreen
|
import com.unciv.ui.cityscreen.CityScreen
|
||||||
import com.unciv.ui.utils.ImageGetter
|
import com.unciv.ui.utils.ImageGetter
|
||||||
import com.unciv.ui.utils.addClickListener
|
import com.unciv.ui.utils.onClick
|
||||||
import com.unciv.ui.utils.setFontColor
|
import com.unciv.ui.utils.setFontColor
|
||||||
import com.unciv.ui.utils.tr
|
import com.unciv.ui.utils.tr
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ class ConstructionPickerScreen(val city: CityInfo) : PickerScreen() {
|
|||||||
val productionTextButton = Button(skin)
|
val productionTextButton = Button(skin)
|
||||||
productionTextButton.add(ImageGetter.getConstructionImage(production)).size(40f).padRight(5f)
|
productionTextButton.add(ImageGetter.getConstructionImage(production)).size(40f).padRight(5f)
|
||||||
productionTextButton.add(Label(buttonText,skin).setFontColor(Color.WHITE))
|
productionTextButton.add(Label(buttonText,skin).setFontColor(Color.WHITE))
|
||||||
productionTextButton.addClickListener {
|
productionTextButton.onClick {
|
||||||
selectedProduction = production
|
selectedProduction = production
|
||||||
pick(rightSideButtonText)
|
pick(rightSideButtonText)
|
||||||
descriptionLabel.setText(description)
|
descriptionLabel.setText(description)
|
||||||
@ -34,7 +34,7 @@ class ConstructionPickerScreen(val city: CityInfo) : PickerScreen() {
|
|||||||
val civInfo = game.gameInfo.getPlayerCivilization()
|
val civInfo = game.gameInfo.getPlayerCivilization()
|
||||||
|
|
||||||
closeButton.clearListeners() // Don't go back to the world screen, unlike the other picker screens!
|
closeButton.clearListeners() // Don't go back to the world screen, unlike the other picker screens!
|
||||||
closeButton.addClickListener {
|
closeButton.onClick {
|
||||||
game.screen = CityScreen(this@ConstructionPickerScreen.city)
|
game.screen = CityScreen(this@ConstructionPickerScreen.city)
|
||||||
dispose()
|
dispose()
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ class ConstructionPickerScreen(val city: CityInfo) : PickerScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rightSideButton.setText("Pick construction".tr())
|
rightSideButton.setText("Pick construction".tr())
|
||||||
rightSideButton.addClickListener {
|
rightSideButton.onClick {
|
||||||
city.cityConstructions.currentConstruction = selectedProduction!!
|
city.cityConstructions.currentConstruction = selectedProduction!!
|
||||||
city.cityStats.update() // Because maybe we set/removed the science or gold production options.
|
city.cityStats.update() // Because maybe we set/removed the science or gold production options.
|
||||||
game.screen = CityScreen(this@ConstructionPickerScreen.city)
|
game.screen = CityScreen(this@ConstructionPickerScreen.city)
|
||||||
|
@ -7,7 +7,7 @@ import com.unciv.UnCivGame
|
|||||||
import com.unciv.models.gamebasics.GameBasics
|
import com.unciv.models.gamebasics.GameBasics
|
||||||
import com.unciv.models.gamebasics.unit.BaseUnit
|
import com.unciv.models.gamebasics.unit.BaseUnit
|
||||||
import com.unciv.ui.utils.ImageGetter
|
import com.unciv.ui.utils.ImageGetter
|
||||||
import com.unciv.ui.utils.addClickListener
|
import com.unciv.ui.utils.onClick
|
||||||
import com.unciv.ui.utils.setFontColor
|
import com.unciv.ui.utils.setFontColor
|
||||||
|
|
||||||
class GreatPersonPickerScreen : PickerScreen() {
|
class GreatPersonPickerScreen : PickerScreen() {
|
||||||
@ -22,7 +22,7 @@ class GreatPersonPickerScreen : PickerScreen() {
|
|||||||
button.add(ImageGetter.getUnitIcon(unit.name)).size(30f).pad(10f)
|
button.add(ImageGetter.getUnitIcon(unit.name)).size(30f).pad(10f)
|
||||||
button.add(Label(unit.name, skin).setFontColor(Color.WHITE)).pad(10f)
|
button.add(Label(unit.name, skin).setFontColor(Color.WHITE)).pad(10f)
|
||||||
button.pack()
|
button.pack()
|
||||||
button.addClickListener {
|
button.onClick {
|
||||||
theChosenOne = unit
|
theChosenOne = unit
|
||||||
pick("Get " +unit.name)
|
pick("Get " +unit.name)
|
||||||
descriptionLabel.setText(unit.baseDescription)
|
descriptionLabel.setText(unit.baseDescription)
|
||||||
@ -30,7 +30,7 @@ class GreatPersonPickerScreen : PickerScreen() {
|
|||||||
topTable.add(button).pad(10f)
|
topTable.add(button).pad(10f)
|
||||||
}
|
}
|
||||||
|
|
||||||
rightSideButton.addClickListener {
|
rightSideButton.onClick {
|
||||||
val civInfo = UnCivGame.Current.gameInfo.getPlayerCivilization()
|
val civInfo = UnCivGame.Current.gameInfo.getPlayerCivilization()
|
||||||
civInfo.placeUnitNearTile(civInfo.cities[0].location, theChosenOne!!.name)
|
civInfo.placeUnitNearTile(civInfo.cities[0].location, theChosenOne!!.name)
|
||||||
civInfo.greatPeople.freeGreatPeople--
|
civInfo.greatPeople.freeGreatPeople--
|
||||||
|
@ -8,7 +8,7 @@ import com.unciv.logic.map.TileInfo
|
|||||||
import com.unciv.models.gamebasics.GameBasics
|
import com.unciv.models.gamebasics.GameBasics
|
||||||
import com.unciv.models.gamebasics.tile.TileImprovement
|
import com.unciv.models.gamebasics.tile.TileImprovement
|
||||||
import com.unciv.ui.utils.ImageGetter
|
import com.unciv.ui.utils.ImageGetter
|
||||||
import com.unciv.ui.utils.addClickListener
|
import com.unciv.ui.utils.onClick
|
||||||
import com.unciv.ui.utils.setFontColor
|
import com.unciv.ui.utils.setFontColor
|
||||||
import com.unciv.ui.utils.tr
|
import com.unciv.ui.utils.tr
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ class ImprovementPickerScreen(tileInfo: TileInfo) : PickerScreen() {
|
|||||||
val civInfo = game.gameInfo.getPlayerCivilization()
|
val civInfo = game.gameInfo.getPlayerCivilization()
|
||||||
|
|
||||||
rightSideButton.setText("Pick improvement")
|
rightSideButton.setText("Pick improvement")
|
||||||
rightSideButton.addClickListener {
|
rightSideButton.onClick {
|
||||||
tileInfo.startWorkingOnImprovement(selectedImprovement!!, civInfo)
|
tileInfo.startWorkingOnImprovement(selectedImprovement!!, civInfo)
|
||||||
game.setWorldScreen()
|
game.setWorldScreen()
|
||||||
dispose()
|
dispose()
|
||||||
@ -39,7 +39,7 @@ class ImprovementPickerScreen(tileInfo: TileInfo) : PickerScreen() {
|
|||||||
improvementButton.add(Label(improvement.name + " - " + improvement.getTurnsToBuild(civInfo) + " {turns}".tr(),skin)
|
improvementButton.add(Label(improvement.name + " - " + improvement.getTurnsToBuild(civInfo) + " {turns}".tr(),skin)
|
||||||
.setFontColor(Color.WHITE)).pad(10f)
|
.setFontColor(Color.WHITE)).pad(10f)
|
||||||
|
|
||||||
improvementButton.addClickListener {
|
improvementButton.onClick {
|
||||||
selectedImprovement = improvement
|
selectedImprovement = improvement
|
||||||
pick(improvement.name)
|
pick(improvement.name)
|
||||||
descriptionLabel.setText(improvement.description)
|
descriptionLabel.setText(improvement.description)
|
||||||
|
@ -16,7 +16,7 @@ open class PickerScreen : CameraStageBaseScreen() {
|
|||||||
internal var splitPane: SplitPane
|
internal var splitPane: SplitPane
|
||||||
|
|
||||||
init {
|
init {
|
||||||
closeButton.addClickListener {
|
closeButton.onClick {
|
||||||
game.setWorldScreen()
|
game.setWorldScreen()
|
||||||
dispose()
|
dispose()
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ class PolicyPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen(
|
|||||||
}
|
}
|
||||||
else onBackButtonClicked { UnCivGame.Current.setWorldScreen(); dispose() }
|
else onBackButtonClicked { UnCivGame.Current.setWorldScreen(); dispose() }
|
||||||
|
|
||||||
rightSideButton.addClickListener {
|
rightSideButton.onClick {
|
||||||
civInfo.policies.adopt(pickedPolicy!!)
|
civInfo.policies.adopt(pickedPolicy!!)
|
||||||
|
|
||||||
// If we've moved to another screen in the meantime (great person pick, victory screen) ignore this
|
// If we've moved to another screen in the meantime (great person pick, victory screen) ignore this
|
||||||
@ -106,7 +106,7 @@ class PolicyPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen(
|
|||||||
{
|
{
|
||||||
policyButton.color = Color.GRAY
|
policyButton.color = Color.GRAY
|
||||||
}
|
}
|
||||||
policyButton.addClickListener { pickPolicy(policy) }
|
policyButton.onClick { pickPolicy(policy) }
|
||||||
policyButton.pack()
|
policyButton.pack()
|
||||||
return policyButton
|
return policyButton
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ class PromotionPickerScreen(mapUnit: MapUnit) : PickerScreen() {
|
|||||||
init {
|
init {
|
||||||
onBackButtonClicked { UnCivGame.Current.setWorldScreen(); dispose() }
|
onBackButtonClicked { UnCivGame.Current.setWorldScreen(); dispose() }
|
||||||
rightSideButton.setText("Pick promotion")
|
rightSideButton.setText("Pick promotion")
|
||||||
rightSideButton.addClickListener {
|
rightSideButton.onClick {
|
||||||
mapUnit.promotions.addPromotion(selectedPromotion!!.name)
|
mapUnit.promotions.addPromotion(selectedPromotion!!.name)
|
||||||
if(mapUnit.promotions.canBePromoted()) game.screen = PromotionPickerScreen(mapUnit)
|
if(mapUnit.promotions.canBePromoted()) game.screen = PromotionPickerScreen(mapUnit)
|
||||||
else game.setWorldScreen()
|
else game.setWorldScreen()
|
||||||
@ -40,7 +40,7 @@ class PromotionPickerScreen(mapUnit: MapUnit) : PickerScreen() {
|
|||||||
.setFontColor(Color.WHITE)).pad(10f)
|
.setFontColor(Color.WHITE)).pad(10f)
|
||||||
if(unitHasPromotion) promotionButton.color = Color.GREEN
|
if(unitHasPromotion) promotionButton.color = Color.GREEN
|
||||||
|
|
||||||
promotionButton.addClickListener {
|
promotionButton.onClick {
|
||||||
selectedPromotion = promotion
|
selectedPromotion = promotion
|
||||||
rightSideButton.setText(promotion.name)
|
rightSideButton.setText(promotion.name)
|
||||||
if(isPromotionAvailable && !unitHasPromotion) rightSideButton.enable()
|
if(isPromotionAvailable && !unitHasPromotion) rightSideButton.enable()
|
||||||
|
@ -9,7 +9,7 @@ import com.unciv.logic.civilization.TechManager
|
|||||||
import com.unciv.models.gamebasics.GameBasics
|
import com.unciv.models.gamebasics.GameBasics
|
||||||
import com.unciv.models.gamebasics.tech.Technology
|
import com.unciv.models.gamebasics.tech.Technology
|
||||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||||
import com.unciv.ui.utils.addClickListener
|
import com.unciv.ui.utils.onClick
|
||||||
import com.unciv.ui.utils.disable
|
import com.unciv.ui.utils.disable
|
||||||
import com.unciv.ui.utils.tr
|
import com.unciv.ui.utils.tr
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@ -59,7 +59,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen()
|
|||||||
else {
|
else {
|
||||||
val TB = TextButton("", CameraStageBaseScreen.skin)
|
val TB = TextButton("", CameraStageBaseScreen.skin)
|
||||||
techNameToButton[tech.name] = TB
|
techNameToButton[tech.name] = TB
|
||||||
TB.addClickListener {
|
TB.onClick {
|
||||||
selectTechnology(tech)
|
selectTechnology(tech)
|
||||||
}
|
}
|
||||||
topTable.add(TB)
|
topTable.add(TB)
|
||||||
@ -71,7 +71,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen()
|
|||||||
setButtonsInfo()
|
setButtonsInfo()
|
||||||
|
|
||||||
rightSideButton.setText("Pick a tech".tr())
|
rightSideButton.setText("Pick a tech".tr())
|
||||||
rightSideButton.addClickListener {
|
rightSideButton.onClick {
|
||||||
if (isFreeTechPick) {
|
if (isFreeTechPick) {
|
||||||
civTech.techsResearched.add(selectedTech!!.name)
|
civTech.techsResearched.add(selectedTech!!.name)
|
||||||
civTech.freeTechs -= 1
|
civTech.freeTechs -= 1
|
||||||
|
@ -88,7 +88,7 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
|||||||
val label = Label(cityButtonText, CameraStageBaseScreen.skin)
|
val label = Label(cityButtonText, CameraStageBaseScreen.skin)
|
||||||
label.setFontColor(city.civInfo.getNation().getSecondaryColor())
|
label.setFontColor(city.civInfo.getNation().getSecondaryColor())
|
||||||
if (city.civInfo.isPlayerCivilization())
|
if (city.civInfo.isPlayerCivilization())
|
||||||
label.addClickListener {
|
label.onClick {
|
||||||
UnCivGame.Current.screen = CityScreen(city)
|
UnCivGame.Current.screen = CityScreen(city)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class DiplomacyScreen():CameraStageBaseScreen(){
|
|||||||
|
|
||||||
|
|
||||||
val closeButton = TextButton("Close".tr(), skin)
|
val closeButton = TextButton("Close".tr(), skin)
|
||||||
closeButton.addClickListener { UnCivGame.Current.setWorldScreen() }
|
closeButton.onClick { UnCivGame.Current.setWorldScreen() }
|
||||||
closeButton.y = stage.height - closeButton.height - 10
|
closeButton.y = stage.height - closeButton.height - 10
|
||||||
closeButton.x = 10f
|
closeButton.x = 10f
|
||||||
stage.addActor(closeButton) // This must come after the split pane so it will be above, that the button will be clickable
|
stage.addActor(closeButton) // This must come after the split pane so it will be above, that the button will be clickable
|
||||||
@ -44,7 +44,7 @@ class DiplomacyScreen():CameraStageBaseScreen(){
|
|||||||
.apply { setFont(22); setFontColor(civ.getNation().getSecondaryColor()) }).row()
|
.apply { setFont(22); setFontColor(civ.getNation().getSecondaryColor()) }).row()
|
||||||
|
|
||||||
val tradeButton = TextButton("Trade".tr(), skin)
|
val tradeButton = TextButton("Trade".tr(), skin)
|
||||||
tradeButton.addClickListener {
|
tradeButton.onClick {
|
||||||
rightSideTable.clear()
|
rightSideTable.clear()
|
||||||
rightSideTable.add(TradeTable(civ, stage){updateLeftSideTable()})
|
rightSideTable.add(TradeTable(civ, stage){updateLeftSideTable()})
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ class DiplomacyScreen():CameraStageBaseScreen(){
|
|||||||
declareWarButton.disable()
|
declareWarButton.disable()
|
||||||
declareWarButton.setText(declareWarButton.text.toString() + " ($turnsToPeaceTreaty)")
|
declareWarButton.setText(declareWarButton.text.toString() + " ($turnsToPeaceTreaty)")
|
||||||
}
|
}
|
||||||
declareWarButton.addClickListener {
|
declareWarButton.onClick {
|
||||||
civDiplomacy.declareWar()
|
civDiplomacy.declareWar()
|
||||||
updateLeftSideTable()
|
updateLeftSideTable()
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
|||||||
import com.unciv.logic.trade.TradeOffersList
|
import com.unciv.logic.trade.TradeOffersList
|
||||||
import com.unciv.logic.trade.TradeType
|
import com.unciv.logic.trade.TradeType
|
||||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||||
import com.unciv.ui.utils.addClickListener
|
import com.unciv.ui.utils.onClick
|
||||||
import com.unciv.ui.utils.disable
|
import com.unciv.ui.utils.disable
|
||||||
import com.unciv.ui.utils.tr
|
import com.unciv.ui.utils.tr
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
@ -31,7 +31,7 @@ class OffersList(val offers: TradeOffersList, val correspondingOffers: TradeOffe
|
|||||||
if(offer.type== TradeType.Gold) 50
|
if(offer.type== TradeType.Gold) 50
|
||||||
else 1
|
else 1
|
||||||
if(offer.amount>0)
|
if(offer.amount>0)
|
||||||
tb.addClickListener {
|
tb.onClick {
|
||||||
val amountTransferred = min(amountPerClick, offer.amount)
|
val amountTransferred = min(amountPerClick, offer.amount)
|
||||||
offers += offer.copy(amount = -amountTransferred)
|
offers += offer.copy(amount = -amountTransferred)
|
||||||
correspondingOffers += offer.copy(amount = amountTransferred)
|
correspondingOffers += offer.copy(amount = amountTransferred)
|
||||||
|
@ -8,7 +8,7 @@ import com.unciv.UnCivGame
|
|||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
import com.unciv.logic.trade.TradeLogic
|
import com.unciv.logic.trade.TradeLogic
|
||||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||||
import com.unciv.ui.utils.addClickListener
|
import com.unciv.ui.utils.onClick
|
||||||
import com.unciv.ui.utils.tr
|
import com.unciv.ui.utils.tr
|
||||||
|
|
||||||
class TradeTable(val otherCivilization: CivilizationInfo, stage: Stage, onTradeComplete: () -> Unit): Table(CameraStageBaseScreen.skin){
|
class TradeTable(val otherCivilization: CivilizationInfo, stage: Stage, onTradeComplete: () -> Unit): Table(CameraStageBaseScreen.skin){
|
||||||
@ -27,7 +27,7 @@ class TradeTable(val otherCivilization: CivilizationInfo, stage: Stage, onTradeC
|
|||||||
|
|
||||||
lowerTable.add(tradeText).colspan(2).row()
|
lowerTable.add(tradeText).colspan(2).row()
|
||||||
|
|
||||||
offerButton.addClickListener {
|
offerButton.onClick {
|
||||||
if(offerButton.text.toString() == "Offer trade".tr()) {
|
if(offerButton.text.toString() == "Offer trade".tr()) {
|
||||||
if(tradeLogic.currentTrade.theirOffers.size==0 && tradeLogic.currentTrade.ourOffers.size==0){
|
if(tradeLogic.currentTrade.theirOffers.size==0 && tradeLogic.currentTrade.ourOffers.size==0){
|
||||||
tradeText.setText("There's nothing on the table.".tr())
|
tradeText.setText("There's nothing on the table.".tr())
|
||||||
|
@ -99,7 +99,7 @@ open class CameraStageBaseScreen : Screen {
|
|||||||
tutorialTexts.removeAt(0)
|
tutorialTexts.removeAt(0)
|
||||||
tutorialTable.add(label).pad(10f).row()
|
tutorialTable.add(label).pad(10f).row()
|
||||||
val button = TextButton("Close".tr(), skin)
|
val button = TextButton("Close".tr(), skin)
|
||||||
button.addClickListener {
|
button.onClick {
|
||||||
tutorialTable.remove()
|
tutorialTable.remove()
|
||||||
if (!tutorialTexts.isEmpty())
|
if (!tutorialTexts.isEmpty())
|
||||||
displayTutorial()
|
displayTutorial()
|
||||||
@ -238,7 +238,7 @@ fun Label.setFont(size:Int): Label {
|
|||||||
return this // for chaining
|
return this // for chaining
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Actor.addClickListener(function: () -> Unit) {
|
fun Actor.onClick(function: () -> Unit) {
|
||||||
this.addListener(object : ClickListener() {
|
this.addListener(object : ClickListener() {
|
||||||
override fun clicked(event: InputEvent?, x: Float, y: Float) {
|
override fun clicked(event: InputEvent?, x: Float, y: Float) {
|
||||||
function()
|
function()
|
||||||
|
@ -11,7 +11,7 @@ import com.unciv.logic.HexMath
|
|||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.ui.utils.ImageGetter
|
import com.unciv.ui.utils.ImageGetter
|
||||||
import com.unciv.ui.utils.addClickListener
|
import com.unciv.ui.utils.onClick
|
||||||
|
|
||||||
class Minimap(val tileMapHolder: TileMapHolder) : ScrollPane(null){
|
class Minimap(val tileMapHolder: TileMapHolder) : ScrollPane(null){
|
||||||
val allTiles = Group()
|
val allTiles = Group()
|
||||||
@ -37,7 +37,7 @@ class Minimap(val tileMapHolder: TileMapHolder) : ScrollPane(null){
|
|||||||
hex.setSize(groupSize,groupSize)
|
hex.setSize(groupSize,groupSize)
|
||||||
hex.setPosition(positionalVector.x * 0.5f * groupSize,
|
hex.setPosition(positionalVector.x * 0.5f * groupSize,
|
||||||
positionalVector.y * 0.5f * groupSize)
|
positionalVector.y * 0.5f * groupSize)
|
||||||
hex.addClickListener {
|
hex.onClick {
|
||||||
tileMapHolder.setCenterPosition(tileInfo.position)
|
tileMapHolder.setCenterPosition(tileInfo.position)
|
||||||
setScrollToTileMapHolder()
|
setScrollToTileMapHolder()
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ class NotificationsScroll(internal val worldScreen: WorldScreen) : ScrollPane(nu
|
|||||||
minitable.add(label).pad(3f).padRight(10f)
|
minitable.add(label).pad(3f).padRight(10f)
|
||||||
|
|
||||||
if (notification.location != null) {
|
if (notification.location != null) {
|
||||||
minitable.addClickListener {
|
minitable.onClick {
|
||||||
worldScreen.tileMapHolder.setCenterPosition(notification.location!!)
|
worldScreen.tileMapHolder.setCenterPosition(notification.location!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import com.unciv.logic.map.TileInfo
|
|||||||
import com.unciv.logic.map.TileMap
|
import com.unciv.logic.map.TileMap
|
||||||
import com.unciv.models.gamebasics.unit.UnitType
|
import com.unciv.models.gamebasics.unit.UnitType
|
||||||
import com.unciv.ui.tilegroups.WorldTileGroup
|
import com.unciv.ui.tilegroups.WorldTileGroup
|
||||||
import com.unciv.ui.utils.addClickListener
|
import com.unciv.ui.utils.onClick
|
||||||
import com.unciv.ui.utils.center
|
import com.unciv.ui.utils.center
|
||||||
import com.unciv.ui.utils.colorFromRGB
|
import com.unciv.ui.utils.colorFromRGB
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
for (tileInfo in tileMap.values) {
|
for (tileInfo in tileMap.values) {
|
||||||
val group = WorldTileGroup(tileInfo)
|
val group = WorldTileGroup(tileInfo)
|
||||||
|
|
||||||
group.addClickListener {
|
group.onClick {
|
||||||
worldScreen.displayTutorials("TileClicked")
|
worldScreen.displayTutorials("TileClicked")
|
||||||
if(overlayActor!=null) overlayActor!!.remove()
|
if(overlayActor!=null) overlayActor!!.remove()
|
||||||
selectedTile = tileInfo
|
selectedTile = tileInfo
|
||||||
@ -50,7 +50,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
// moveHereGroup.addActor(ImageGetter.getImage("OtherIcons/Circle").apply { width = size; height = size })
|
// moveHereGroup.addActor(ImageGetter.getImage("OtherIcons/Circle").apply { width = size; height = size })
|
||||||
// moveHereGroup.addActor(ImageGetter.getStatIcon("Movement").apply { width = size / 2; height = size / 2; center(moveHereGroup) })
|
// moveHereGroup.addActor(ImageGetter.getStatIcon("Movement").apply { width = size / 2; height = size / 2; center(moveHereGroup) })
|
||||||
// if(selectedUnit.currentMovement>0)
|
// if(selectedUnit.currentMovement>0)
|
||||||
// moveHereGroup.addClickListener { selectedUnit.movementAlgs().headTowards(tileInfo);worldScreen.update() }
|
// moveHereGroup.onClick { selectedUnit.movementAlgs().headTowards(tileInfo);worldScreen.update() }
|
||||||
// else moveHereGroup.color.a=0.5f
|
// else moveHereGroup.color.a=0.5f
|
||||||
// addAboveGroup(group, moveHereGroup).apply { width = size; height = size }
|
// addAboveGroup(group, moveHereGroup).apply { width = size; height = size }
|
||||||
// }
|
// }
|
||||||
|
@ -49,7 +49,7 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
tileMapHolder.addTiles()
|
tileMapHolder.addTiles()
|
||||||
|
|
||||||
techButton.addClickListener {
|
techButton.onClick {
|
||||||
game.screen = TechPickerScreen(civInfo)
|
game.screen = TechPickerScreen(civInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||||||
.any()) {
|
.any()) {
|
||||||
displayTutorials("OtherCivEncountered")
|
displayTutorials("OtherCivEncountered")
|
||||||
val btn = TextButton("Diplomacy".tr(), skin)
|
val btn = TextButton("Diplomacy".tr(), skin)
|
||||||
btn.addClickListener { UnCivGame.Current.screen = DiplomacyScreen() }
|
btn.onClick { UnCivGame.Current.screen = DiplomacyScreen() }
|
||||||
diplomacyButtonWrapper.add(btn)
|
diplomacyButtonWrapper.add(btn)
|
||||||
}
|
}
|
||||||
diplomacyButtonWrapper.pack()
|
diplomacyButtonWrapper.pack()
|
||||||
@ -166,18 +166,18 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
private fun createNextTurnButton(): TextButton {
|
private fun createNextTurnButton(): TextButton {
|
||||||
val nextTurnButton = TextButton("Next turn".tr(), CameraStageBaseScreen.skin)
|
val nextTurnButton = TextButton("Next turn".tr(), CameraStageBaseScreen.skin)
|
||||||
nextTurnButton.addClickListener {
|
nextTurnButton.onClick {
|
||||||
if (civInfo.tech.freeTechs != 0) {
|
if (civInfo.tech.freeTechs != 0) {
|
||||||
game.screen = TechPickerScreen(true, civInfo)
|
game.screen = TechPickerScreen(true, civInfo)
|
||||||
return@addClickListener
|
return@onClick
|
||||||
} else if (civInfo.policies.shouldOpenPolicyPicker) {
|
} else if (civInfo.policies.shouldOpenPolicyPicker) {
|
||||||
game.screen = PolicyPickerScreen(civInfo)
|
game.screen = PolicyPickerScreen(civInfo)
|
||||||
civInfo.policies.shouldOpenPolicyPicker = false
|
civInfo.policies.shouldOpenPolicyPicker = false
|
||||||
return@addClickListener
|
return@onClick
|
||||||
}
|
}
|
||||||
else if (civInfo.tech.currentTechnology() == null && civInfo.cities.isNotEmpty()) {
|
else if (civInfo.tech.currentTechnology() == null && civInfo.cities.isNotEmpty()) {
|
||||||
game.screen = TechPickerScreen(civInfo)
|
game.screen = TechPickerScreen(civInfo)
|
||||||
return@addClickListener
|
return@onClick
|
||||||
}
|
}
|
||||||
|
|
||||||
bottomBar.unitTable.currentlyExecutingAction = null
|
bottomBar.unitTable.currentlyExecutingAction = null
|
||||||
|
@ -47,7 +47,7 @@ class WorldScreenTopBar(val screen: WorldScreen) : Table() {
|
|||||||
addActor(getMenuButton()) // needs to be after pack
|
addActor(getMenuButton()) // needs to be after pack
|
||||||
|
|
||||||
val button = TextButton("Overview".tr(),CameraStageBaseScreen.skin)
|
val button = TextButton("Overview".tr(),CameraStageBaseScreen.skin)
|
||||||
button.addClickListener { UnCivGame.Current.screen = EmpireOverviewScreen() }
|
button.onClick { UnCivGame.Current.screen = EmpireOverviewScreen() }
|
||||||
button.center(this)
|
button.center(this)
|
||||||
button.x = screen.stage.width-button.width-10
|
button.x = screen.stage.width-button.width-10
|
||||||
addActor(button)
|
addActor(button)
|
||||||
@ -93,7 +93,7 @@ class WorldScreenTopBar(val screen: WorldScreen) : Table() {
|
|||||||
val menuButton = ImageGetter.getImage("OtherIcons/MenuIcon.png")
|
val menuButton = ImageGetter.getImage("OtherIcons/MenuIcon.png")
|
||||||
.apply { setSize(50f, 50f) }
|
.apply { setSize(50f, 50f) }
|
||||||
menuButton.color = Color.WHITE
|
menuButton.color = Color.WHITE
|
||||||
menuButton.addClickListener {
|
menuButton.onClick {
|
||||||
if(screen.stage.actors.none { it is WorldScreenOptionsTable })
|
if(screen.stage.actors.none { it is WorldScreenOptionsTable })
|
||||||
screen.stage.addActor(WorldScreenOptionsTable())
|
screen.stage.addActor(WorldScreenOptionsTable())
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
|||||||
|
|
||||||
if(attackableEnemy==null || !attacker.unit.canAttack()) attackButton.disable()
|
if(attackableEnemy==null || !attacker.unit.canAttack()) attackButton.disable()
|
||||||
else {
|
else {
|
||||||
attackButton.addClickListener {
|
attackButton.onClick {
|
||||||
attacker.unit.moveToTile(attackableEnemy.tileToAttackFrom)
|
attacker.unit.moveToTile(attackableEnemy.tileToAttackFrom)
|
||||||
battle.attack(attacker, defender)
|
battle.attack(attacker, defender)
|
||||||
worldScreen.update()
|
worldScreen.update()
|
||||||
|
@ -18,7 +18,7 @@ open class PopupTable: Table(){
|
|||||||
|
|
||||||
fun addButton(text:String, action:()->Unit){
|
fun addButton(text:String, action:()->Unit){
|
||||||
val button = TextButton(text.tr(), CameraStageBaseScreen.skin).apply { color= ImageGetter.getBlue() }
|
val button = TextButton(text.tr(), CameraStageBaseScreen.skin).apply { color= ImageGetter.getBlue() }
|
||||||
button.addClickListener(action)
|
button.onClick(action)
|
||||||
add(button).row()
|
add(button).row()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -31,8 +31,8 @@ class YesNoPopupTable(question:String, action:()->Unit,
|
|||||||
val skin = CameraStageBaseScreen.skin
|
val skin = CameraStageBaseScreen.skin
|
||||||
add(Label(question, skin)).colspan(2).row()
|
add(Label(question, skin)).colspan(2).row()
|
||||||
|
|
||||||
add(TextButton("No".tr(), skin).apply { addClickListener { close() } })
|
add(TextButton("No".tr(), skin).apply { onClick { close() } })
|
||||||
add(TextButton("Yes".tr(), skin).apply { addClickListener { close(); action() } })
|
add(TextButton("Yes".tr(), skin).apply { onClick { close(); action() } })
|
||||||
pack()
|
pack()
|
||||||
center(screen.stage)
|
center(screen.stage)
|
||||||
screen.stage.addActor(this)
|
screen.stage.addActor(this)
|
||||||
|
@ -3,7 +3,7 @@ package com.unciv.ui.worldscreen.unit
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||||
import com.unciv.ui.utils.addClickListener
|
import com.unciv.ui.utils.onClick
|
||||||
import com.unciv.ui.worldscreen.TileMapHolder
|
import com.unciv.ui.worldscreen.TileMapHolder
|
||||||
|
|
||||||
class IdleUnitButton internal constructor(internal val unitTable: UnitTable,
|
class IdleUnitButton internal constructor(internal val unitTable: UnitTable,
|
||||||
@ -13,7 +13,7 @@ class IdleUnitButton internal constructor(internal val unitTable: UnitTable,
|
|||||||
fun getTilesWithIdleUnits() = tileMapHolder.tileMap.values
|
fun getTilesWithIdleUnits() = tileMapHolder.tileMap.values
|
||||||
.filter { it.hasIdleUnit() && it.getUnits().first().owner == unitTable.worldScreen.civInfo.civName }
|
.filter { it.hasIdleUnit() && it.getUnits().first().owner == unitTable.worldScreen.civInfo.civName }
|
||||||
init {
|
init {
|
||||||
addClickListener {
|
onClick {
|
||||||
val tilesWithIdleUnits = getTilesWithIdleUnits()
|
val tilesWithIdleUnits = getTilesWithIdleUnits()
|
||||||
|
|
||||||
val tileToSelect: TileInfo
|
val tileToSelect: TileInfo
|
||||||
|
@ -59,7 +59,7 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
actionButton.add(Label(unitAction.name.tr(),CameraStageBaseScreen.skin)
|
actionButton.add(Label(unitAction.name.tr(),CameraStageBaseScreen.skin)
|
||||||
.setFontColor(Color.WHITE)).pad(5f)
|
.setFontColor(Color.WHITE)).pad(5f)
|
||||||
actionButton.pack()
|
actionButton.pack()
|
||||||
actionButton.addClickListener({ unitAction.action(); UnCivGame.Current.worldScreen.update() })
|
actionButton.onClick({ unitAction.action(); UnCivGame.Current.worldScreen.update() })
|
||||||
if (!unitAction.canAct) actionButton.disable()
|
if (!unitAction.canAct) actionButton.disable()
|
||||||
return actionButton
|
return actionButton
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
for(promotion in selectedUnit!!.promotions.promotions)
|
for(promotion in selectedUnit!!.promotions.promotions)
|
||||||
promotionsTable.add(ImageGetter.getPromotionIcon(promotion)).size(20f)
|
promotionsTable.add(ImageGetter.getPromotionIcon(promotion)).size(20f)
|
||||||
|
|
||||||
unitDescriptionLabel.addClickListener { worldScreen.tileMapHolder.setCenterPosition(selectedUnit!!.getTile().position) }
|
unitDescriptionLabel.onClick { worldScreen.tileMapHolder.setCenterPosition(selectedUnit!!.getTile().position) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pack()
|
pack()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user