mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-11 11:28:03 +07:00
Diplomacy: City State resource UI, improvement gift effect (#4782)
* CS Resources shown in Diplomacy linked * CS Improvement gift updates resources immediately * CS Improvement gift updates resources immediately - patch1
This commit is contained in:
parent
b8fe46d057
commit
58a3dfdda3
@ -20,8 +20,10 @@ import com.unciv.models.ruleset.ModOptionsConstants
|
||||
import com.unciv.models.ruleset.Quest
|
||||
import com.unciv.models.ruleset.tile.ResourceType
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.civilopedia.CivilopediaScreen
|
||||
import com.unciv.ui.tilegroups.CityButton
|
||||
import com.unciv.ui.utils.*
|
||||
import com.unciv.ui.utils.UncivTooltip.Companion.addTooltip
|
||||
import kotlin.math.floor
|
||||
import kotlin.math.roundToInt
|
||||
import com.unciv.ui.utils.AutoScrollPane as ScrollPane
|
||||
@ -103,15 +105,26 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
|
||||
diplomacyTable.add("{Type}: {${otherCiv.cityStateType}}".toLabel()).row()
|
||||
diplomacyTable.add("{Personality}: {${otherCiv.cityStatePersonality}}".toLabel()).row()
|
||||
|
||||
val resourcesTable = Table()
|
||||
resourcesTable.add("{Resources:} ".toLabel()).padRight(10f)
|
||||
for (supplyList in otherCiv.detailedCivResources) {
|
||||
if (supplyList.resource.resourceType == ResourceType.Bonus)
|
||||
continue
|
||||
resourcesTable.add(ImageGetter.getResourceImage(supplyList.resource.name, 30f)).padRight(5f)
|
||||
resourcesTable.add(supplyList.amount.toLabel()).padRight(20f)
|
||||
if (otherCiv.detailedCivResources.any { it.resource.resourceType != ResourceType.Bonus }) {
|
||||
val resourcesTable = Table()
|
||||
resourcesTable.add("{Resources:} ".toLabel()).padRight(10f)
|
||||
for (supplyList in otherCiv.detailedCivResources) {
|
||||
if (supplyList.resource.resourceType == ResourceType.Bonus)
|
||||
continue
|
||||
val name = supplyList.resource.name
|
||||
val wrapper = Table()
|
||||
val image = ImageGetter.getResourceImage(name, 30f)
|
||||
wrapper.add(image).padRight(5f)
|
||||
wrapper.add(supplyList.amount.toLabel())
|
||||
resourcesTable.add(wrapper).padRight(20f)
|
||||
wrapper.addTooltip(name, 18f)
|
||||
wrapper.onClick {
|
||||
val pedia = CivilopediaScreen(UncivGame.Current.gameInfo.ruleSet, link = "Resource/$name")
|
||||
UncivGame.Current.setScreen(pedia)
|
||||
}
|
||||
}
|
||||
diplomacyTable.add(resourcesTable).row()
|
||||
}
|
||||
diplomacyTable.add(resourcesTable).row()
|
||||
|
||||
otherCiv.updateAllyCivForCityState()
|
||||
val ally = otherCiv.getAllyCiv()
|
||||
@ -196,7 +209,6 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
|
||||
improveTileButton.disable()
|
||||
|
||||
|
||||
|
||||
diplomacyTable.add(improveTileButton).row()
|
||||
if (otherCivDiplomacyManager.diplomaticStatus == DiplomaticStatus.Protector){
|
||||
val revokeProtectionButton = "Revoke Protection".toTextButton()
|
||||
@ -285,16 +297,20 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
|
||||
val improvementGiftTable = getCityStateDiplomacyTableHeader(otherCiv)
|
||||
improvementGiftTable.addSeparator()
|
||||
|
||||
val improvableTiles = otherCiv.getCapital().getImprovableTiles().filterNot {it.getTileResource().resourceType == ResourceType.Bonus}.toList()
|
||||
val improvableTiles = otherCiv.getCapital().getImprovableTiles()
|
||||
.filterNot { it.getTileResource().resourceType == ResourceType.Bonus }.toList()
|
||||
val tileImprovements = otherCiv.gameInfo.ruleSet.tileImprovements.filter { it.value.turnsToBuild != 0 }
|
||||
|
||||
for (improvableTile in improvableTiles){
|
||||
for (tileImprovement in tileImprovements.values){
|
||||
if (improvableTile.canBuildImprovement(tileImprovement, otherCiv) && improvableTile.getTileResource().improvement == tileImprovement.name){
|
||||
if (improvableTile.canBuildImprovement(tileImprovement, otherCiv) &&
|
||||
improvableTile.getTileResource().improvement == tileImprovement.name) {
|
||||
val improveTileButton = "Build [${tileImprovement}] on [${improvableTile.getTileResource()}] (200 Gold)".toTextButton()
|
||||
improveTileButton.onClick {
|
||||
viewingCiv.giveGoldGift(otherCiv, 200)
|
||||
viewingCiv.addGold(-200)
|
||||
improvableTile.stopWorkingOnImprovement()
|
||||
improvableTile.improvement = tileImprovement.name
|
||||
otherCiv.updateDetailedCivResources()
|
||||
rightSideTable.clear()
|
||||
rightSideTable.add(ScrollPane(getCityStateDiplomacyTable(otherCiv)))
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ fun Button.enable() {
|
||||
touchable = Touchable.enabled
|
||||
}
|
||||
/** Enable or disable a [Button] by setting its [touchable][Button.touchable] and [color][Button.color] properties,
|
||||
* or returns the corresponding state. *
|
||||
* or returns the corresponding state.
|
||||
*
|
||||
* Do not confuse with Gdx' builtin [isDisabled][Button.isDisabled] property,
|
||||
* which is more appropriate to toggle On/Off buttons, while this one is good for 'click-to-do-something' buttons.
|
||||
|
@ -152,6 +152,7 @@ class UncivTooltip <T: Actor>(
|
||||
*
|
||||
* Tip is positioned over top right corner, slightly overshooting the receiver widget, longer tip [text]s will extend to the left.
|
||||
*
|
||||
* @param text Automatically translated tooltip text
|
||||
* @param size _Vertical_ size of the entire Tooltip including background
|
||||
* @param always override requirement: presence of physical keyboard
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user