WLTK decorations (#6253)

* WLTK decoration png's and atlas

* UncivTooltip anchor to stage so tips won't get clipped by some ScrollPane

* Empire Overview Cities add WLTK column

* Make WLTK line on CityScreen stats box link to Civilopedia

* Make Civilopedia return to previous screen for _both_ ESC/Back and the Close Button

* Revive Civilopedia links in WorldScreen.TileInfoTable

* Festive decoration for WLTK day on CityScreen
This commit is contained in:
SomeTroglodyte 2022-03-05 19:10:03 +01:00 committed by GitHub
parent 20f34eb5f5
commit fb7cb707e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 193 additions and 133 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

@ -613,268 +613,240 @@ BuildingIcons/Research Lab
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/SS Booster
rotate: false
xy: 1624, 1574
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/SS Cockpit
rotate: false
xy: 1840, 1790
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/SS Engine
rotate: false
xy: 328, 170
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/SS Stasis Chamber
rotate: false
xy: 544, 386
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Satrap's Court
rotate: false
xy: 868, 710
xy: 436, 278
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Seaport
rotate: false
xy: 1192, 1034
xy: 760, 602
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Shrine
rotate: false
xy: 1516, 1358
xy: 1084, 932
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Sistine Chapel
rotate: false
xy: 1732, 1575
xy: 1300, 1142
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Solar Plant
rotate: false
xy: 436, 170
xy: 1624, 1466
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Spaceship Factory
rotate: false
xy: 544, 278
xy: 1732, 1575
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Stable
rotate: false
xy: 760, 494
xy: 328, 62
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Stadium
rotate: false
xy: 868, 602
xy: 436, 170
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Statue of Liberty
rotate: false
xy: 976, 710
xy: 544, 278
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Statue of Zeus
rotate: false
xy: 1084, 824
xy: 652, 386
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Stele
rotate: false
xy: 1300, 1034
xy: 868, 602
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Stock Exchange
rotate: false
xy: 1408, 1142
xy: 976, 710
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Stone Works
rotate: false
xy: 1516, 1250
xy: 1084, 824
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Stonehenge
rotate: false
xy: 1624, 1358
xy: 1192, 926
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Sydney Opera House
rotate: false
xy: 436, 62
xy: 1516, 1250
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Taj Mahal
rotate: false
xy: 544, 170
xy: 1624, 1358
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Temple
rotate: false
xy: 760, 386
xy: 1840, 1574
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Temple of Artemis
rotate: false
xy: 868, 494
xy: 436, 62
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Terracotta Army
rotate: false
xy: 1084, 716
xy: 652, 278
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/The Great Library
rotate: false
xy: 1192, 818
xy: 760, 386
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/The Great Lighthouse
rotate: false
xy: 1300, 926
xy: 868, 494
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/The Louvre
rotate: false
xy: 1408, 1034
xy: 976, 602
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/The Oracle
rotate: false
xy: 1516, 1142
xy: 1084, 716
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/The Pyramids
rotate: false
xy: 1624, 1250
xy: 1192, 818
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Theatre
rotate: false
xy: 1732, 1359
xy: 1300, 926
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/United Nations
rotate: false
xy: 868, 386
xy: 1840, 1466
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/University
rotate: false
xy: 976, 494
xy: 544, 62
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Utopia Project
rotate: false
xy: 1084, 608
xy: 652, 170
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Walls
rotate: false
xy: 1192, 710
xy: 1084, 608
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Walls of Babylon
rotate: false
xy: 1300, 818
xy: 1192, 710
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Wat
rotate: false
xy: 1732, 1251
xy: 1624, 1141
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Water Mill
rotate: false
xy: 1840, 1358
xy: 1732, 1251
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Windmill
rotate: false
xy: 760, 170
xy: 1840, 1358
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Workshop
rotate: false
xy: 1084, 500
xy: 868, 278
size: 100, 100
orig: 100, 100
offset: 0, 0
@ -888,105 +860,105 @@ MayaCalendar/0
index: -1
MayaCalendar/1
rotate: false
xy: 1456, 868
xy: 1348, 760
size: 13, 50
orig: 13, 50
offset: 0, 0
index: -1
MayaCalendar/10
rotate: false
xy: 1358, 760
xy: 1250, 652
size: 21, 50
orig: 21, 50
offset: 0, 0
index: -1
MayaCalendar/11
rotate: false
xy: 1840, 1300
xy: 1732, 1193
size: 35, 50
orig: 35, 50
offset: 0, 0
index: -1
MayaCalendar/12
rotate: false
xy: 868, 220
xy: 1840, 1300
size: 35, 50
orig: 35, 50
offset: 0, 0
index: -1
MayaCalendar/13
rotate: false
xy: 976, 328
xy: 760, 112
size: 35, 50
orig: 35, 50
offset: 0, 0
index: -1
MayaCalendar/14
rotate: false
xy: 1084, 442
xy: 868, 220
size: 35, 50
orig: 35, 50
offset: 0, 0
index: -1
MayaCalendar/15
rotate: false
xy: 1192, 544
xy: 976, 328
size: 30, 50
orig: 30, 50
offset: 0, 0
index: -1
MayaCalendar/16
rotate: false
xy: 1408, 868
xy: 1300, 760
size: 40, 50
orig: 40, 50
offset: 0, 0
index: -1
MayaCalendar/17
rotate: false
xy: 1516, 976
xy: 1408, 868
size: 40, 50
orig: 40, 50
offset: 0, 0
index: -1
MayaCalendar/18
rotate: false
xy: 1624, 1084
xy: 1516, 976
size: 40, 50
orig: 40, 50
offset: 0, 0
index: -1
MayaCalendar/19
rotate: false
xy: 1732, 1193
xy: 1624, 1083
size: 40, 50
orig: 40, 50
offset: 0, 0
index: -1
MayaCalendar/2
rotate: false
xy: 1564, 976
xy: 1456, 868
size: 13, 50
orig: 13, 50
offset: 0, 0
index: -1
MayaCalendar/3
rotate: false
xy: 1672, 1084
xy: 1564, 976
size: 13, 50
orig: 13, 50
offset: 0, 0
index: -1
MayaCalendar/4
rotate: false
xy: 1780, 1193
xy: 1672, 1083
size: 13, 50
orig: 13, 50
offset: 0, 0
index: -1
MayaCalendar/5
rotate: false
xy: 1883, 1300
xy: 1775, 1193
size: 10, 50
orig: 10, 50
offset: 0, 0
@ -1007,14 +979,14 @@ MayaCalendar/7
index: -1
MayaCalendar/8
rotate: false
xy: 710, 111
xy: 1084, 492
size: 25, 50
orig: 25, 50
offset: 0, 0
index: -1
MayaCalendar/9
rotate: false
xy: 1300, 702
xy: 1142, 550
size: 25, 50
orig: 25, 50
offset: 0, 0
@ -1035,18 +1007,39 @@ MayaCalendar/Katun
index: -1
MayaCalendar/Maya
rotate: false
xy: 652, 111
xy: 1084, 550
size: 50, 50
orig: 50, 50
offset: 0, 0
index: -1
MayaCalendar/Tun
rotate: false
xy: 1300, 760
xy: 1192, 652
size: 50, 50
orig: 50, 50
offset: 0, 0
index: -1
OtherIcons/WLTK 1
rotate: false
xy: 760, 278
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
OtherIcons/WLTK 2
rotate: false
xy: 868, 386
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
OtherIcons/WLTK LR
rotate: false
xy: 976, 494
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/African Forest Elephant
rotate: false
xy: 4, 1898
@ -1735,196 +1728,196 @@ UnitIcons/Rocket Artillery
index: -1
UnitIcons/SS Booster
rotate: false
xy: 1732, 1683
xy: 1624, 1574
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/SS Cockpit
rotate: false
xy: 220, 62
xy: 1732, 1683
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/SS Engine
rotate: false
xy: 436, 278
xy: 1840, 1790
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/SS Stasis Chamber
rotate: false
xy: 652, 494
xy: 220, 62
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Samurai
rotate: false
xy: 760, 602
xy: 328, 170
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Scout
rotate: false
xy: 976, 818
xy: 544, 386
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Sea Beggar
rotate: false
xy: 1084, 932
xy: 652, 494
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Settler
rotate: false
xy: 1300, 1142
xy: 868, 710
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Ship of the Line
rotate: false
xy: 1408, 1250
xy: 976, 818
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Sipahi
rotate: false
xy: 1624, 1466
xy: 1192, 1034
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Skirmisher
rotate: false
xy: 1840, 1682
xy: 1408, 1250
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Slinger
rotate: false
xy: 328, 62
xy: 1516, 1358
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Spearman
rotate: false
xy: 652, 386
xy: 1840, 1682
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Stealth Bomber
rotate: false
xy: 1192, 926
xy: 760, 494
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Submarine
rotate: false
xy: 1732, 1467
xy: 1300, 1034
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Swordsman
rotate: false
xy: 1840, 1574
xy: 1408, 1142
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Tank
rotate: false
xy: 652, 278
xy: 1732, 1467
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Tercio
rotate: false
xy: 976, 602
xy: 544, 170
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Trebuchet
rotate: false
xy: 1840, 1466
xy: 1408, 1034
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Triplane
rotate: false
xy: 544, 62
xy: 1516, 1142
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Trireme
rotate: false
xy: 652, 169
xy: 1624, 1249
size: 100, 101
orig: 100, 101
offset: 0, 0
index: -1
UnitIcons/Turtle Ship
rotate: false
xy: 760, 278
xy: 1732, 1359
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/War Chariot
rotate: false
xy: 1408, 926
xy: 1300, 818
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/War Elephant
rotate: false
xy: 1516, 1034
xy: 1408, 926
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Warrior
rotate: false
xy: 1624, 1142
xy: 1516, 1034
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Work Boats
rotate: false
xy: 868, 278
xy: 652, 62
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Worker
rotate: false
xy: 976, 386
xy: 760, 170
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Zero
rotate: false
xy: 1192, 602
xy: 976, 386
size: 100, 100
orig: 100, 100
offset: 0, 0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 744 KiB

After

Width:  |  Height:  |  Size: 748 KiB

View File

@ -2,6 +2,7 @@ package com.unciv.ui.cityscreen
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.ui.Image
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.utils.Align
import com.unciv.UncivGame
@ -22,6 +23,9 @@ class CityScreen(
companion object {
/** Distance from stage edges to floating widgets */
const val posFromEdge = 5f
/** Size of the decoration icons shown besides the raze button */
const val wltkIconSize = 40f
}
/** Toggles or adds/removes all state changing buttons */
@ -176,6 +180,14 @@ class CityScreen(
private fun updateAnnexAndRazeCityButton() {
razeCityButtonHolder.clear()
fun addWltkIcon(name: String, apply: Image.()->Unit = {}) =
razeCityButtonHolder.add(ImageGetter.getImage(name).apply(apply)).size(wltkIconSize)
if (city.isWeLoveTheKingDayActive()) {
addWltkIcon("OtherIcons/WLTK LR") { color = Color.GOLD }
addWltkIcon("OtherIcons/WLTK 1") { color = Color.FIREBRICK }.padRight(10f)
}
if (city.isPuppet) {
val annexCityButton = "Annex city".toTextButton()
annexCityButton.labelCell.pad(10f)
@ -184,7 +196,7 @@ class CityScreen(
update()
}
if (!canChangeState) annexCityButton.disable()
razeCityButtonHolder.add(annexCityButton).colspan(cityPickerTable.columns)
razeCityButtonHolder.add(annexCityButton) //.colspan(cityPickerTable.columns)
} else if (!city.isBeingRazed) {
val razeCityButton = "Raze city".toTextButton()
razeCityButton.labelCell.pad(10f)
@ -192,14 +204,24 @@ class CityScreen(
if (!canChangeState || !city.canBeDestroyed())
razeCityButton.disable()
razeCityButtonHolder.add(razeCityButton).colspan(cityPickerTable.columns)
razeCityButtonHolder.add(razeCityButton) //.colspan(cityPickerTable.columns)
} else {
val stopRazingCityButton = "Stop razing city".toTextButton()
stopRazingCityButton.labelCell.pad(10f)
stopRazingCityButton.onClick { city.isBeingRazed = false; update() }
if (!canChangeState) stopRazingCityButton.disable()
razeCityButtonHolder.add(stopRazingCityButton).colspan(cityPickerTable.columns)
razeCityButtonHolder.add(stopRazingCityButton) //.colspan(cityPickerTable.columns)
}
if (city.isWeLoveTheKingDayActive()) {
addWltkIcon("OtherIcons/WLTK 2") { color = Color.FIREBRICK }.padLeft(10f)
addWltkIcon("OtherIcons/WLTK LR") {
color = Color.GOLD
scaleX = -scaleX
originX = wltkIconSize * 0.5f
}
}
razeCityButtonHolder.pack()
val centerX = if (!isPortrait()) stage.width / 2
else constructionsTable.getUpperWidth().let { it + (stage.width - cityStatsTable.width - it) / 2 }

View File

@ -38,7 +38,6 @@ class CityScreenTileTable(private val cityScreen: CityScreen): Table() {
innerTable.pad(5f)
innerTable.add( MarkupRenderer.render(selectedTile.toMarkup(city.civInfo), iconDisplay = IconDisplay.None) {
// Sorry, this will leave the city screen
UncivGame.Current.setScreen(CivilopediaScreen(city.getRuleset(), cityScreen, link = it))
} )
innerTable.row()

View File

@ -1,12 +1,16 @@
package com.unciv.ui.cityscreen
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.ui.Label
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.utils.Align
import com.unciv.UncivGame
import com.unciv.logic.city.CityFlags
import com.unciv.models.ruleset.unique.UniqueType
import com.unciv.models.stats.Stat
import com.unciv.models.translations.tr
import com.unciv.ui.civilopedia.CivilopediaScreen
import com.unciv.ui.utils.*
import kotlin.math.ceil
import kotlin.math.round
@ -80,20 +84,31 @@ class CityStatsTable(val cityScreen: CityScreen): Table() {
innerTable.add(unassignedPopString.toLabel()).row()
innerTable.add(turnsToExpansionString.toLabel()).row()
innerTable.add(turnsToPopString.toLabel()).row()
val tableWithIcons = Table()
tableWithIcons.defaults().pad(2f)
if (cityInfo.isInResistance()) {
tableWithIcons.add(ImageGetter.getImage("StatIcons/Resistance")).size(20f)
tableWithIcons.add("In resistance for another [${cityInfo.getFlag(CityFlags.Resistance)}] turns".toLabel()).row()
}
if (cityInfo.isWeLoveTheKingDayActive()) {
tableWithIcons.add(ImageGetter.getStatIcon("Food")).size(20f)
tableWithIcons.add("We Love The King Day for another [${cityInfo.getFlag(CityFlags.WeLoveTheKing)}] turns".toLabel()).row()
} else if (cityInfo.demandedResource != "") {
tableWithIcons.add(ImageGetter.getResourceImage(cityInfo.demandedResource, 20f)).padRight(5f)
tableWithIcons.add("Demanding [${cityInfo.demandedResource}]".toLabel()).left().row()
val (wltkIcon: Actor?, wltkLabel: Label?) = when {
cityInfo.isWeLoveTheKingDayActive() ->
ImageGetter.getStatIcon("Food") to
"We Love The King Day for another [${cityInfo.getFlag(CityFlags.WeLoveTheKing)}] turns".toLabel(Color.LIME)
cityInfo.demandedResource.isNotEmpty() ->
ImageGetter.getResourceImage(cityInfo.demandedResource, 20f) to
"Demanding [${cityInfo.demandedResource}]".toLabel(Color.CORAL)
else -> null to null
}
if (wltkLabel != null) {
tableWithIcons.add(wltkIcon!!).size(20f).padRight(5f)
wltkLabel.onClick {
UncivGame.Current.setScreen(CivilopediaScreen(cityInfo.getRuleset(), cityScreen, link = "We Love The King Day"))
}
tableWithIcons.add(wltkLabel).row()
}
innerTable.add(tableWithIcons).row()
}

View File

@ -239,7 +239,7 @@ class CivilopediaScreen(
val goToGameButton = Constants.close.toTextButton()
goToGameButton.onClick {
game.setWorldScreen()
game.setScreen(previousScreen)
dispose()
}

View File

@ -1,18 +1,20 @@
package com.unciv.ui.overviewscreen
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.ui.Button
import com.badlogic.gdx.scenes.scene2d.ui.Cell
import com.badlogic.gdx.scenes.scene2d.ui.Label
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.utils.Align
import com.unciv.Constants
import com.unciv.logic.city.CityFlags
import com.unciv.logic.city.CityInfo
import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.models.stats.Stat
import com.unciv.models.translations.tr
import com.unciv.ui.cityscreen.CityScreen
import com.unciv.ui.utils.*
import com.unciv.ui.utils.UncivTooltip.Companion.addTooltip
import kotlin.math.max
import kotlin.math.roundToInt
@ -62,6 +64,11 @@ class CityOverviewTable(private val viewingPlayer: CivilizationInfo, private val
for (name in columnsNames) {
addSortIcon(name)
}
val wltkSortIcon: IconCircleGroup = ImageGetter.getImage("OtherIcons/WLTK 2")
.apply { color = Color.BLACK }
.surroundWithCircle(iconSize, color = Color.TAN)
wltkSortIcon.addTooltip("We Love The King Day", 18f, tipAlign = Align.center )
addSortIcon("WLTK", wltkSortIcon)
cityInfoTableIcons.pack()
// Prepare middle third: cityInfoScrollPane (a ScrollPane containing cityInfoTableDetails)
@ -78,7 +85,7 @@ class CityOverviewTable(private val viewingPlayer: CivilizationInfo, private val
// place the button for sorting by city name on top of the cities names
// by sizing the filler to: subtract width of other columns and one cell padding from overall width
val headingFillerWidth = max(0f, cityInfoTableDetails.width - (iconSize + 2*paddingHorz) * (numHeaderCells-1) - 2*paddingHorz)
val headingFillerWidth = max(0f, cityInfoTableDetails.width - (iconSize + 2*paddingHorz) * numHeaderCells - 2*paddingHorz)
headerFillerCell.width(headingFillerWidth)
cityInfoTableIcons.width = cityInfoTableDetails.width
@ -94,6 +101,7 @@ class CityOverviewTable(private val viewingPlayer: CivilizationInfo, private val
if (stat == Stat.Food || stat == Stat.Production) cityInfoTableTotal.add() // an intended empty space
else cityInfoTableTotal.add(viewingPlayer.cities.sumOf { getStatOfCity(it, stat) }.toLabel()).myAlign(Align.center)
}
cityInfoTableTotal.add(viewingPlayer.cities.count { it.isWeLoveTheKingDayActive() }.toLabel()).myAlign(Align.center)
cityInfoTableTotal.pack()
// Stack cityInfoTableIcons, cityInfoScrollPane, and cityInfoTableTotal vertically
@ -125,6 +133,7 @@ class CityOverviewTable(private val viewingPlayer: CivilizationInfo, private val
val stat = Stat.valueOf(sortType)
getStatOfCity(city1, stat) - getStatOfCity(city2, stat)
}
sortType == "WLTK" -> city1.isWeLoveTheKingDayActive().compareTo(city2.isWeLoveTheKingDayActive())
else -> city2.name.tr().compareTo(city1.name.tr())
}
}
@ -142,7 +151,7 @@ class CityOverviewTable(private val viewingPlayer: CivilizationInfo, private val
}
citiesTable.add(button)
if (city.cityConstructions.currentConstructionFromQueue.length > 0) {
if (city.cityConstructions.currentConstructionFromQueue.isNotEmpty()) {
citiesTable.add(ImageGetter.getConstructionImage(city.cityConstructions.currentConstructionFromQueue).surroundWithCircle(iconSize*0.8f)).padRight(paddingHorz)
} else {
citiesTable.add()
@ -156,6 +165,21 @@ class CityOverviewTable(private val viewingPlayer: CivilizationInfo, private val
if (!column.isStat()) continue
citiesTable.add(getStatOfCity(city, Stat.valueOf(column)).toLabel()).myAlign(Align.center)
}
when {
city.isWeLoveTheKingDayActive() -> {
val image = ImageGetter.getImage("OtherIcons/WLTK 1").surroundWithCircle(iconSize, color = Color.CLEAR)
image.addTooltip("[${city.getFlag(CityFlags.WeLoveTheKing)}] turns", 18f, tipAlign = Align.topLeft)
citiesTable.add(image)
}
city.demandedResource.isNotEmpty() -> {
val image = ImageGetter.getResourceImage(city.demandedResource, iconSize*0.7f)
image.addTooltip("Demanding [${city.demandedResource}]", 18f, tipAlign = Align.topLeft)
citiesTable.add(image).padLeft(iconSize*0.3f)
}
else -> citiesTable.add()
}
citiesTable.row()
}

View File

@ -23,7 +23,6 @@ import com.unciv.models.translations.tr
* @param forceContentSize Force virtual [content] width/height for alignment calculation
* - because Gdx auto layout reports wrong dimensions on scaled actors.
*/
@Suppress("unused") // reported incorrectly even when a use is right here in the Companion
class UncivTooltip <T: Actor>(
val target: Group,
val content: T,
@ -53,6 +52,8 @@ class UncivTooltip <T: Actor>(
//region show, hide and positioning
/** Show the Tooltip ([immediate]ly or begin the animation). _Can_ be called programmatically. */
fun show(immediate: Boolean = false) {
if (target.stage == null) return
val useAnimation = animate && !immediate
if (state == TipState.Shown || state == TipState.Showing && useAnimation || !target.hasParent()) return
if (state == TipState.Showing || state == TipState.Hiding) {
@ -60,10 +61,11 @@ class UncivTooltip <T: Actor>(
state = TipState.Hidden
container.remove()
}
val pos = target.localToParentCoordinates(target.getEdgePoint(targetAlign)).add(offset)
val pos = target.localToStageCoordinates(target.getEdgePoint(targetAlign)).add(offset)
container.run {
val originX = getOriginX(contentWidth,tipAlign)
val originY = getOriginY(contentHeight,tipAlign)
val originX = getOriginX(contentWidth, tipAlign)
val originY = getOriginY(contentHeight, tipAlign)
setOrigin(originX, originY)
setPosition(pos.x - originX, pos.y - originY)
if (useAnimation) {
@ -76,7 +78,8 @@ class UncivTooltip <T: Actor>(
setScale(1f)
}
}
target.parent.addActor(container)
target.stage.addActor(container)
if (useAnimation) {
state = TipState.Showing
container.addAction(Actions.sequence(
@ -155,8 +158,9 @@ class UncivTooltip <T: Actor>(
* @param text Automatically translated tooltip text
* @param size _Vertical_ size of the entire Tooltip including background
* @param always override requirement: presence of physical keyboard
* @param tipAlign Point on the Tooltip to align with the top right of the [target]
*/
fun Group.addTooltip(text: String, size: Float = 26f, always: Boolean = false) {
fun Group.addTooltip(text: String, size: Float = 26f, always: Boolean = false, tipAlign: Int = Align.top) {
if (!(always || KeyPressDispatcher.keyboardAvailable) || text.isEmpty()) return
val label = text.toLabel(ImageGetter.getBlue(), 38)
@ -183,7 +187,7 @@ class UncivTooltip <T: Actor>(
labelWithBackground,
forceContentSize = Vector2(size * widthHeightRatio, size),
offset = Vector2(-size/4, size/4),
tipAlign = Align.top
tipAlign = tipAlign
))
}

View File

@ -6,6 +6,7 @@ import com.badlogic.gdx.utils.Align
import com.unciv.UncivGame
import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.map.TileInfo
import com.unciv.ui.civilopedia.CivilopediaScreen
import com.unciv.ui.civilopedia.FormattedLine.IconDisplay
import com.unciv.ui.civilopedia.MarkupRenderer
import com.unciv.ui.utils.BaseScreen
@ -24,8 +25,7 @@ class TileInfoTable(private val viewingCiv :CivilizationInfo) : Table(BaseScreen
if (tile != null && (UncivGame.Current.viewEntireMapForDebug || viewingCiv.exploredTiles.contains(tile.position)) ) {
add(getStatsTable(tile))
add( MarkupRenderer.render(tile.toMarkup(viewingCiv), padding = 0f, iconDisplay = IconDisplay.None) {
// We need to pass the current screen here to get this to work and I can't be bothered now
// UncivGame.Current.setScreen(CivilopediaScreen(viewingCiv.gameInfo.ruleSet, link = it))
UncivGame.Current.setScreen(CivilopediaScreen(viewingCiv.gameInfo.ruleSet, UncivGame.Current.worldScreen, link = it))
} ).pad(5f).row()
if (UncivGame.Current.viewEntireMapForDebug)
add(tile.position.run { "(${x.toInt()},${y.toInt()})" }.toLabel()).colspan(2).pad(5f)

View File

@ -674,6 +674,9 @@ Unless otherwise specified, all the following are from [the Noun Project](https:
* [East side of stela C, Quirigua](https://en.wikipedia.org/wiki/File:East_side_of_stela_C,_Quirigua.PNG) for Mayan calendar symbols
* [Footprints](https://thenounproject.com/icon/footprints-1393611/) by Abdul Wahhab for movement overlay toggle, slightly modified. Currently unused.
* Arrows.svg by Intralexical (@will-ca), CC0.
* [favor](https://thenounproject.com/icon/favor-1029350/) by MICHAEL G BROWN for WLTK marker on City Overview
* [Party](https://thenounproject.com/icon/party-1784941/) by Adrien Coquet for WLTK header on City Overview
* [Party](https://thenounproject.com/icon/party-2955155/) by Lars Meiertoberens as additional WLKT decoration
## Main menu