mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-22 02:07:43 +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:
parent
03029e8b99
commit
c97c20c94f
@ -1,15 +1,15 @@
|
||||
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.ScrollPane
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.trade.Trade
|
||||
import com.unciv.logic.trade.TradeOffersList
|
||||
import com.unciv.ui.utils.*
|
||||
import kotlin.math.max
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class EmpireOverviewScreen : CameraStageBaseScreen(){
|
||||
@ -49,7 +49,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
||||
val setCurrentTradesButton = TextButton("Trades".tr(),skin)
|
||||
setCurrentTradesButton.addClickListener {
|
||||
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.center(stage)
|
||||
}
|
||||
@ -76,31 +76,34 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
||||
val tradesTable = Table().apply { defaults().pad(10f) }
|
||||
for(diplomacy in civInfo.diplomacy.values)
|
||||
for(trade in diplomacy.trades)
|
||||
tradesTable.add(createTradeTable(trade,diplomacy.otherCivName)).row()
|
||||
tradesTable.add(createTradeTable(trade,diplomacy.otherCiv())).row()
|
||||
|
||||
return tradesTable
|
||||
}
|
||||
|
||||
private fun createTradeTable(trade: Trade, civName:String): Table {
|
||||
val table = Table(skin)
|
||||
table.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK,0.5f))
|
||||
private fun createTradeTable(trade: Trade, otherCiv:CivilizationInfo): Table {
|
||||
val generalTable = Table(skin)
|
||||
generalTable.add(createOffersTable(civInfo,trade.ourOffers, trade.theirOffers.size))
|
||||
generalTable.add(createOffersTable(otherCiv, trade.theirOffers, trade.ourOffers.size))
|
||||
return generalTable
|
||||
}
|
||||
|
||||
private fun createOffersTable(civ: CivilizationInfo, offersList: TradeOffersList, numberOfOtherSidesOffers: Int): Table {
|
||||
val table = Table()
|
||||
table.defaults().pad(10f)
|
||||
table.add(civInfo.civName)
|
||||
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()
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
private fun getHappinessTable(): Table {
|
||||
val happinessTable = Table(skin)
|
||||
happinessTable.defaults().pad(5f)
|
||||
|
@ -93,7 +93,6 @@ class PolicyPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen(
|
||||
private fun getPolicyButton(policy: Policy, image: Boolean): Button {
|
||||
var policyButton = Button(CameraStageBaseScreen.skin)
|
||||
if (image) {
|
||||
// val policyImage = ImageGetter.getImage("PolicyIcons/" + policy.name.replace(" ", "_") + "_(Civ5).png")
|
||||
val policyImage = ImageGetter.getImage("PolicyIcons/" + policy.name)
|
||||
policyButton.add(policyImage).size(30f)
|
||||
} else {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.unciv.ui.trade
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.ui.utils.*
|
||||
@ -36,11 +35,12 @@ class DiplomacyScreen():CameraStageBaseScreen(){
|
||||
if (!playerCiv.diplomacy.containsKey(civ.civName)) continue
|
||||
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.defaults().pad(10f)
|
||||
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)
|
||||
tradeButton.addClickListener {
|
||||
|
Loading…
Reference in New Issue
Block a user