mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-30 23:41:03 -04:00
Resolved #3186 - Diplomacy overview displays war/peace status and not relationship level.
This commit is contained in:
parent
43bef4d88d
commit
33270baea2
@ -73,6 +73,35 @@ class EmpireOverviewScreen(private var viewingPlayer:CivilizationInfo, defaultPa
|
|||||||
|
|
||||||
val setDiplomacyButton = "Diplomacy".toTextButton()
|
val setDiplomacyButton = "Diplomacy".toTextButton()
|
||||||
setDiplomacyButton.onClick {
|
setDiplomacyButton.onClick {
|
||||||
|
setDiplomacyTable()
|
||||||
|
}
|
||||||
|
topTable.add(setDiplomacyButton)
|
||||||
|
|
||||||
|
val setResourcesButton = "Resources".toTextButton()
|
||||||
|
val setResources = {
|
||||||
|
centerTable.clear()
|
||||||
|
centerTable.add(ScrollPane(getResourcesTable())).size(stage.width * 0.8f, stage.height * 0.8f)
|
||||||
|
centerTable.pack()
|
||||||
|
}
|
||||||
|
clicks["Resources"] = setResources
|
||||||
|
setResourcesButton.onClick(setResources)
|
||||||
|
topTable.add(setResourcesButton)
|
||||||
|
if (viewingPlayer.detailedCivResources.isEmpty())
|
||||||
|
setResourcesButton.disable()
|
||||||
|
|
||||||
|
topTable.pack()
|
||||||
|
|
||||||
|
clicks[defaultPage]?.invoke()
|
||||||
|
|
||||||
|
val table = Table()
|
||||||
|
table.add(topTable).row()
|
||||||
|
table.addSeparator()
|
||||||
|
table.add(centerTable).height(stage.height - topTable.height).expand().row()
|
||||||
|
table.setFillParent(true)
|
||||||
|
stage.addActor(table)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setDiplomacyTable() {
|
||||||
centerTable.clear()
|
centerTable.clear()
|
||||||
val relevantCivs = viewingPlayer.gameInfo.civilizations.filter { !it.isBarbarian() && !it.isCityState() }
|
val relevantCivs = viewingPlayer.gameInfo.civilizations.filter { !it.isBarbarian() && !it.isCityState() }
|
||||||
val playerKnowsAndUndefeatedCivs = relevantCivs.filter { playerKnows(it) && !it.isDefeated() }
|
val playerKnowsAndUndefeatedCivs = relevantCivs.filter { playerKnows(it) && !it.isDefeated() }
|
||||||
@ -114,31 +143,6 @@ class EmpireOverviewScreen(private var viewingPlayer:CivilizationInfo, defaultPa
|
|||||||
centerTable.add(civTableScrollPane.addBorder(2f, Color.WHITE)).pad(10f)
|
centerTable.add(civTableScrollPane.addBorder(2f, Color.WHITE)).pad(10f)
|
||||||
centerTable.pack()
|
centerTable.pack()
|
||||||
}
|
}
|
||||||
topTable.add(setDiplomacyButton)
|
|
||||||
|
|
||||||
val setResourcesButton = "Resources".toTextButton()
|
|
||||||
val setResources = {
|
|
||||||
centerTable.clear()
|
|
||||||
centerTable.add(ScrollPane(getResourcesTable())).size(stage.width * 0.8f, stage.height * 0.8f)
|
|
||||||
centerTable.pack()
|
|
||||||
}
|
|
||||||
clicks["Resources"] = setResources
|
|
||||||
setResourcesButton.onClick(setResources)
|
|
||||||
topTable.add(setResourcesButton)
|
|
||||||
if (viewingPlayer.detailedCivResources.isEmpty())
|
|
||||||
setResourcesButton.disable()
|
|
||||||
|
|
||||||
topTable.pack()
|
|
||||||
|
|
||||||
clicks[defaultPage]?.invoke()
|
|
||||||
|
|
||||||
val table = Table()
|
|
||||||
table.add(topTable).row()
|
|
||||||
table.addSeparator()
|
|
||||||
table.add(centerTable).height(stage.height - topTable.height).expand().row()
|
|
||||||
table.setFillParent(true)
|
|
||||||
stage.addActor(table)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setStats() {
|
private fun setStats() {
|
||||||
game.settings.addCompletedTutorialTask("See your stats breakdown")
|
game.settings.addCompletedTutorialTask("See your stats breakdown")
|
||||||
@ -393,8 +397,7 @@ class EmpireOverviewScreen(private var viewingPlayer:CivilizationInfo, defaultPa
|
|||||||
|
|
||||||
for (civ in relevantCivs.filter { playerKnows(it) && !it.isDefeated() })
|
for (civ in relevantCivs.filter { playerKnows(it) && !it.isDefeated() })
|
||||||
for (diplomacy in civ.diplomacy.values.filter {
|
for (diplomacy in civ.diplomacy.values.filter {
|
||||||
it.otherCiv().isMajorCiv()
|
it.otherCiv().isMajorCiv() && playerKnows(it.otherCiv()) && !it.otherCiv().isDefeated()
|
||||||
&& playerKnows(it.otherCiv()) && !it.otherCiv().isDefeated()
|
|
||||||
}) {
|
}) {
|
||||||
val civGroup = civGroups[civ.civName]!!
|
val civGroup = civGroups[civ.civName]!!
|
||||||
val otherCivGroup = civGroups[diplomacy.otherCivName]!!
|
val otherCivGroup = civGroups[diplomacy.otherCivName]!!
|
||||||
@ -405,8 +408,7 @@ class EmpireOverviewScreen(private var viewingPlayer:CivilizationInfo, defaultPa
|
|||||||
val statusLine = ImageGetter.getLine(civGroup.x + civGroup.width / 2, civGroup.y + civGroup.height / 2,
|
val statusLine = ImageGetter.getLine(civGroup.x + civGroup.width / 2, civGroup.y + civGroup.height / 2,
|
||||||
otherCivGroup.x + otherCivGroup.width / 2, otherCivGroup.y + otherCivGroup.height / 2, 2f)
|
otherCivGroup.x + otherCivGroup.width / 2, otherCivGroup.y + otherCivGroup.height / 2, 2f)
|
||||||
|
|
||||||
val diplomacyLevel = diplomacy.diplomaticModifiers.values.sum()
|
statusLine.color = if (diplomacy.diplomaticStatus == DiplomaticStatus.Peace) Color.GREEN else Color.RED
|
||||||
statusLine.color = getColorForDiplomacyLevel(diplomacyLevel)
|
|
||||||
|
|
||||||
civLines[civ.civName]!!.add(statusLine)
|
civLines[civ.civName]!!.add(statusLine)
|
||||||
|
|
||||||
@ -449,17 +451,6 @@ class EmpireOverviewScreen(private var viewingPlayer:CivilizationInfo, defaultPa
|
|||||||
selectedLines.forEach { it.isVisible = !it.isVisible }
|
selectedLines.forEach { it.isVisible = !it.isVisible }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getColorForDiplomacyLevel(value: Float): Color {
|
|
||||||
|
|
||||||
var amplitude = min(1.0f,abs(value)/80) // 80 = RelationshipLevel.Ally
|
|
||||||
val shade = max(0.5f - amplitude, 0.0f)
|
|
||||||
amplitude = max(amplitude, 0.5f)
|
|
||||||
|
|
||||||
return Color( if (sign(value) < 0) amplitude else shade,
|
|
||||||
if (sign(value) > 0) amplitude else shade,
|
|
||||||
shade,1.0f)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private fun getResourcesTable(): Table {
|
private fun getResourcesTable(): Table {
|
||||||
val resourcesTable = Table().apply { defaults().pad(10f) }
|
val resourcesTable = Table().apply { defaults().pad(10f) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user