mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-21 05:09:25 +07:00
Diplommacy screen and overview trade tab now contain colors of the trading civs
Overview trade tab is now scrollable
This commit is contained in:
@ -1,15 +1,15 @@
|
|||||||
package com.unciv.ui
|
package com.unciv.ui
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||||
import com.badlogic.gdx.utils.Align
|
import com.badlogic.gdx.utils.Align
|
||||||
import com.unciv.UnCivGame
|
import com.unciv.UnCivGame
|
||||||
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
import com.unciv.logic.trade.Trade
|
import com.unciv.logic.trade.Trade
|
||||||
|
import com.unciv.logic.trade.TradeOffersList
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
import kotlin.math.max
|
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
class EmpireOverviewScreen : CameraStageBaseScreen(){
|
class EmpireOverviewScreen : CameraStageBaseScreen(){
|
||||||
@ -49,7 +49,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
val setCurrentTradesButton = TextButton("Trades".tr(),skin)
|
val setCurrentTradesButton = TextButton("Trades".tr(),skin)
|
||||||
setCurrentTradesButton.addClickListener {
|
setCurrentTradesButton.addClickListener {
|
||||||
centerTable.clear()
|
centerTable.clear()
|
||||||
centerTable.add(getTradesTable())
|
centerTable.add(ScrollPane(getTradesTable())).height(stage.height*0.8f) // so it doesn't cover the naviagation buttons
|
||||||
centerTable.pack()
|
centerTable.pack()
|
||||||
centerTable.center(stage)
|
centerTable.center(stage)
|
||||||
}
|
}
|
||||||
@ -76,31 +76,34 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
val tradesTable = Table().apply { defaults().pad(10f) }
|
val tradesTable = Table().apply { defaults().pad(10f) }
|
||||||
for(diplomacy in civInfo.diplomacy.values)
|
for(diplomacy in civInfo.diplomacy.values)
|
||||||
for(trade in diplomacy.trades)
|
for(trade in diplomacy.trades)
|
||||||
tradesTable.add(createTradeTable(trade,diplomacy.otherCivName)).row()
|
tradesTable.add(createTradeTable(trade,diplomacy.otherCiv())).row()
|
||||||
|
|
||||||
return tradesTable
|
return tradesTable
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createTradeTable(trade: Trade, civName:String): Table {
|
private fun createTradeTable(trade: Trade, otherCiv:CivilizationInfo): Table {
|
||||||
val table = Table(skin)
|
val generalTable = Table(skin)
|
||||||
table.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK,0.5f))
|
generalTable.add(createOffersTable(civInfo,trade.ourOffers, trade.theirOffers.size))
|
||||||
table.defaults().pad(10f)
|
generalTable.add(createOffersTable(otherCiv, trade.theirOffers, trade.ourOffers.size))
|
||||||
table.add(civInfo.civName)
|
return generalTable
|
||||||
table.add(civName).row()
|
|
||||||
val ourOffersStrings = trade.ourOffers.map { it.amount.toString()+" "+it.name.tr() +
|
|
||||||
(if (it.duration==0) "" else " ("+it.duration+" {turns})".tr()) }
|
|
||||||
val theirOffersStrings = trade.theirOffers.map { it.amount.toString()+" "+it.name.tr() +
|
|
||||||
(if (it.duration==0) "" else " ("+it.duration+" {turns})".tr()) }
|
|
||||||
for(i in 0 until max(trade.ourOffers.size,trade.theirOffers.size)){
|
|
||||||
if(ourOffersStrings.size>i) table.add(ourOffersStrings[i])
|
|
||||||
else table.add()
|
|
||||||
if(theirOffersStrings.size>i) table.add(theirOffersStrings[i])
|
|
||||||
else table.add()
|
|
||||||
table.row()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun createOffersTable(civ: CivilizationInfo, offersList: TradeOffersList, numberOfOtherSidesOffers: Int): Table {
|
||||||
|
val table = Table()
|
||||||
|
table.defaults().pad(10f)
|
||||||
|
table.background = ImageGetter.getBackground(civ.getNation().getColor())
|
||||||
|
table.add(Label(civ.civName.tr(),skin).setFontColor(civ.getNation().getSecondaryColor())).row()
|
||||||
|
for(offer in offersList){
|
||||||
|
var offerText = offer.amount.toString()+" "+offer.name.tr()
|
||||||
|
if(offer.duration>0)offerText += " ("+offer.duration+" {turns})".tr()
|
||||||
|
table.add(Label(offerText,skin).setFontColor(civ.getNation().getSecondaryColor())).row()
|
||||||
|
}
|
||||||
|
for(i in 1..numberOfOtherSidesOffers - offersList.size)
|
||||||
|
table.add(Label("",skin)).row() // we want both sides of the general table to have the same number of rows
|
||||||
return table
|
return table
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun getHappinessTable(): Table {
|
private fun getHappinessTable(): Table {
|
||||||
val happinessTable = Table(skin)
|
val happinessTable = Table(skin)
|
||||||
happinessTable.defaults().pad(5f)
|
happinessTable.defaults().pad(5f)
|
||||||
|
@ -93,7 +93,6 @@ class PolicyPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen(
|
|||||||
private fun getPolicyButton(policy: Policy, image: Boolean): Button {
|
private fun getPolicyButton(policy: Policy, image: Boolean): Button {
|
||||||
var policyButton = Button(CameraStageBaseScreen.skin)
|
var policyButton = Button(CameraStageBaseScreen.skin)
|
||||||
if (image) {
|
if (image) {
|
||||||
// val policyImage = ImageGetter.getImage("PolicyIcons/" + policy.name.replace(" ", "_") + "_(Civ5).png")
|
|
||||||
val policyImage = ImageGetter.getImage("PolicyIcons/" + policy.name)
|
val policyImage = ImageGetter.getImage("PolicyIcons/" + policy.name)
|
||||||
policyButton.add(policyImage).size(30f)
|
policyButton.add(policyImage).size(30f)
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.unciv.ui.trade
|
package com.unciv.ui.trade
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.*
|
import com.badlogic.gdx.scenes.scene2d.ui.*
|
||||||
import com.unciv.UnCivGame
|
import com.unciv.UnCivGame
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
@ -36,11 +35,12 @@ class DiplomacyScreen():CameraStageBaseScreen(){
|
|||||||
if (!playerCiv.diplomacy.containsKey(civ.civName)) continue
|
if (!playerCiv.diplomacy.containsKey(civ.civName)) continue
|
||||||
val civDiplomacy = playerCiv.diplomacy[civ.civName]!!
|
val civDiplomacy = playerCiv.diplomacy[civ.civName]!!
|
||||||
|
|
||||||
val civTable = Table().apply { background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f)) }
|
val civTable = Table().apply { background = ImageGetter.getBackground(civ.getNation().getColor()) }
|
||||||
civTable.pad(10f)
|
civTable.pad(10f)
|
||||||
civTable.defaults().pad(10f)
|
civTable.defaults().pad(10f)
|
||||||
val peaceWarStatus = civDiplomacy.diplomaticStatus.toString()
|
val peaceWarStatus = civDiplomacy.diplomaticStatus.toString()
|
||||||
civTable.add(Label(civ.civName.tr() + " ({$peaceWarStatus})".tr(), skin).apply { setFont(22); setFontColor(Color.WHITE) }).row()
|
civTable.add(Label(civ.civName.tr() + " ({$peaceWarStatus})".tr(), skin)
|
||||||
|
.apply { setFont(22); setFontColor(civ.getNation().getSecondaryColor()) }).row()
|
||||||
|
|
||||||
val tradeButton = TextButton("Trade".tr(), skin)
|
val tradeButton = TextButton("Trade".tr(), skin)
|
||||||
tradeButton.addClickListener {
|
tradeButton.addClickListener {
|
||||||
|
Reference in New Issue
Block a user