mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-22 10:54:19 -04:00
Table and colors for diplomatic relations between human players in diplomacy screen. (#13437)
* change politics diagram line colors * defensive pact color only for major civs * update comment * remove unneeded line * color DoF between human players in diagram * human relationship table and colors * fix spelling typo * fix colors consistency in table
This commit is contained in:
parent
a35de18455
commit
79fb4b4d59
@ -5,10 +5,12 @@ import com.badlogic.gdx.scenes.scene2d.ui.SplitPane
|
||||
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.Constants
|
||||
import com.unciv.GUI
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.civilization.Civilization
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomacyManager
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticModifiers
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
|
||||
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
||||
import com.unciv.logic.trade.Trade
|
||||
@ -139,7 +141,8 @@ class DiplomacyScreen(
|
||||
|
||||
val civIndicator = ImageGetter.getNationPortrait(civ.nation, nationIconSize)
|
||||
|
||||
val relationLevel = civ.getDiplomacyManager(viewingCiv)!!.relationshipLevel()
|
||||
val diplomacy = civ.getDiplomacyManager(viewingCiv)!!
|
||||
val relationLevel = diplomacy.relationshipLevel()
|
||||
val relationshipIcon = if (civ.isCityState && relationLevel == RelationshipLevel.Ally)
|
||||
ImageGetter.getImage("OtherIcons/Star")
|
||||
.surroundWithCircle(size = 30f, color = relationLevel.color).apply {
|
||||
@ -147,7 +150,10 @@ class DiplomacyScreen(
|
||||
}
|
||||
else
|
||||
ImageGetter.getCircle(
|
||||
color = if (viewingCiv.isAtWarWith(civ)) Color.RED else relationLevel.color,
|
||||
color = if (civ.isHuman() && viewingCiv.isHuman()) getHumanRelationshipColor(diplomacy)
|
||||
else if (diplomacy.diplomaticStatus == DiplomaticStatus.DefensivePact) Color.PURPLE
|
||||
else if (civ.isAtWarWith(viewingCiv)) Color.RED
|
||||
else relationLevel.color,
|
||||
size = 30f
|
||||
)
|
||||
civIndicator.addActor(relationshipIcon)
|
||||
@ -219,6 +225,51 @@ class DiplomacyScreen(
|
||||
return tradeTable
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for updateLeftSideTable for human vs human player only
|
||||
* @param otherCivDiplomacyManager Other human player [DiplomacyManager]
|
||||
* @return Relationship color between two human players
|
||||
*/
|
||||
private fun getHumanRelationshipColor(otherCivDiplomacyManager: DiplomacyManager): Color {
|
||||
return if (otherCivDiplomacyManager.diplomaticStatus == DiplomaticStatus.DefensivePact)
|
||||
Color.PURPLE
|
||||
else if (otherCivDiplomacyManager.hasModifier(DiplomaticModifiers.DeclarationOfFriendship))
|
||||
RelationshipLevel.Friend.color
|
||||
else if (otherCivDiplomacyManager.diplomaticStatus == DiplomaticStatus.War) Color.RED
|
||||
else RelationshipLevel.Neutral.color
|
||||
}
|
||||
|
||||
/**
|
||||
* @param otherCivDiplomacyManager Other human player [DiplomacyManager]
|
||||
* @return Relationship [Table] for human vs human player only
|
||||
*/
|
||||
internal fun getHumanRelationshipTable(otherCivDiplomacyManager: DiplomacyManager): Table {
|
||||
val relationshipTable = Table()
|
||||
val relationshipColor: Color
|
||||
val relationshipText: String
|
||||
|
||||
if (otherCivDiplomacyManager.diplomaticStatus == DiplomaticStatus.DefensivePact) {
|
||||
relationshipText = Constants.defensivePact
|
||||
relationshipColor = Color.GREEN
|
||||
}
|
||||
else if (otherCivDiplomacyManager.hasModifier(DiplomaticModifiers.DeclarationOfFriendship)) {
|
||||
relationshipText = RelationshipLevel.Friend.name
|
||||
relationshipColor = Color.GREEN
|
||||
}
|
||||
else if (otherCivDiplomacyManager.diplomaticStatus == DiplomaticStatus.War) {
|
||||
relationshipText = RelationshipLevel.Enemy.name
|
||||
relationshipColor = Color.RED
|
||||
}
|
||||
else {
|
||||
relationshipText = RelationshipLevel.Neutral.name
|
||||
relationshipColor = RelationshipLevel.Neutral.color
|
||||
}
|
||||
|
||||
relationshipTable.add("{Our relationship}: ".toLabel())
|
||||
relationshipTable.add(relationshipText.toLabel(relationshipColor)).row()
|
||||
return relationshipTable
|
||||
}
|
||||
|
||||
internal fun getRelationshipTable(otherCivDiplomacyManager: DiplomacyManager): Table {
|
||||
val relationshipTable = Table()
|
||||
|
||||
|
@ -85,7 +85,9 @@ class MajorCivDiplomacyTable(private val diplomacyScreen: DiplomacyScreen) {
|
||||
if (otherCiv.getCapital() != null && viewingCiv.hasExplored(otherCiv.getCapital()!!.getCenterTile()))
|
||||
diplomacyTable.add(diplomacyScreen.getGoToOnMapButton(otherCiv)).row()
|
||||
|
||||
if (!otherCiv.isHuman()) { // human players make their own choices
|
||||
if (otherCiv.isHuman())
|
||||
diplomacyTable.add(diplomacyScreen.getHumanRelationshipTable(otherCivDiplomacyManager)).row()
|
||||
else {
|
||||
diplomacyTable.add(diplomacyScreen.getRelationshipTable(otherCivDiplomacyManager)).row()
|
||||
diplomacyTable.add(getDiplomacyModifiersTable(otherCivDiplomacyManager)).row()
|
||||
val promisesTable = getPromisesTable(diplomacyManager, otherCivDiplomacyManager)
|
||||
|
@ -13,6 +13,7 @@ import com.unciv.Constants
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.civilization.Civilization
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomacyFlags
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticModifiers
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
|
||||
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
||||
import com.unciv.logic.map.HexMath
|
||||
@ -498,10 +499,12 @@ class GlobalPoliticsOverviewTable(
|
||||
statusLine.color = if (diplomacy.diplomaticStatus == DiplomaticStatus.War) Color.RED
|
||||
// Color defensive pact for major civs only
|
||||
else if (diplomacy.diplomaticStatus == DiplomaticStatus.DefensivePact
|
||||
&& !(diplomacy.civInfo.isCityState || diplomacy.otherCiv().isCityState)) Color.PURPLE
|
||||
&& !(civ.isCityState || otherCiv.isCityState)) Color.PURPLE
|
||||
else if (civ.isHuman() && otherCiv.isHuman() && diplomacy.hasModifier(DiplomaticModifiers.DeclarationOfFriendship))
|
||||
RelationshipLevel.Friend.color
|
||||
// Test for alliance with city state
|
||||
else if ((diplomacy.civInfo.isCityState && diplomacy.civInfo.getAllyCivName() == diplomacy.otherCivName)
|
||||
|| (otherCiv.isCityState && otherCiv.getAllyCivName() == diplomacy.civInfo.civName)) RelationshipLevel.Ally.color
|
||||
else if ((civ.isCityState && civ.getAllyCivName() == diplomacy.otherCivName)
|
||||
|| (otherCiv.isCityState && otherCiv.getAllyCivName() == civ.civName)) RelationshipLevel.Ally.color
|
||||
// Else the color depends on opinion between major civs, OR city state relationship with major civ
|
||||
else diplomacy.relationshipLevel().color
|
||||
|
||||
@ -511,7 +514,6 @@ class GlobalPoliticsOverviewTable(
|
||||
addActorAt(0, statusLine)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user