Better icons for notifications (there's a lot of work to do here)

This commit is contained in:
Yair Morgenstern 2021-03-19 15:38:14 +02:00
parent 4c260ca954
commit d515955b30
8 changed files with 33 additions and 21 deletions

View File

@ -304,16 +304,17 @@ class CityConstructions {
validateConstructionQueue() // if we've build e.g. the Great Lighthouse, then Lighthouse is no longer relevant in the queue
val buildingIcon = "BuildingIcons/${construction.name}"
if (construction is Building && construction.isWonder) {
cityInfo.civInfo.popupAlerts.add(PopupAlert(AlertType.WonderBuilt, construction.name))
for (civ in cityInfo.civInfo.gameInfo.civilizations) {
if (civ.exploredTiles.contains(cityInfo.location))
civ.addNotification("[${construction.name}] has been built in [${cityInfo.name}]", cityInfo.location, Color.BROWN)
civ.addNotification("[${construction.name}] has been built in [${cityInfo.name}]", cityInfo.location, NotificationIcon.Construction, buildingIcon)
else
civ.addNotification("[${construction.name}] has been built in a faraway land", "BuildingIcons/${construction.name}")
civ.addNotification("[${construction.name}] has been built in a faraway land", buildingIcon)
}
} else
cityInfo.civInfo.addNotification("[${construction.name}] has been built in [" + cityInfo.name + "]", cityInfo.location, NotificationIcon.Construction)
cityInfo.civInfo.addNotification("[${construction.name}] has been built in [" + cityInfo.name + "]", cityInfo.location, NotificationIcon.Construction, buildingIcon)
}
fun addBuilding(buildingName: String) {

View File

@ -52,7 +52,7 @@ class PopulationManager {
fun nextTurn(food: Int) {
foodStored += food
if (food < 0)
cityInfo.civInfo.addNotification("[${cityInfo.name}] is starving!", cityInfo.location, Color.RED)
cityInfo.civInfo.addNotification("[${cityInfo.name}] is starving!", cityInfo.location, NotificationIcon.Growth, "OtherIcons/DisbandUnit")
if (foodStored < 0) { // starvation!
if (population > 1) population--
foodStored = 0

View File

@ -553,9 +553,8 @@ class CivilizationInfo {
addNotification(text, color, LocationAction(locations))
}
fun addNotification(text: String, location: Vector2?, notificationIcon: String) {
val locations = if (location != null) listOf(location) else emptyList()
addNotification(text, LocationAction(locations), notificationIcon)
fun addNotification(text: String, location: Vector2, vararg notificationIcons: String) {
addNotification(text, LocationAction(listOf(location)), *notificationIcons)
}

View File

@ -241,7 +241,7 @@ class TechManager {
}
updateTransientBooleans()
civInfo.addNotification("Research of [$techName] has completed!", Color.BLUE, TechAction(techName))
civInfo.addNotification("Research of [$techName] has completed!", TechAction(techName), NotificationIcon.Science, techName )
civInfo.popupAlerts.add(PopupAlert(AlertType.TechResearched, techName))
val currentEra = civInfo.getEra()

View File

@ -307,8 +307,8 @@ class DiplomacyManager() {
trades.remove(trade)
val otherCivTrades = otherCiv().getDiplomacyManager(civInfo).trades
otherCivTrades.removeAll { it.equals(trade.reverse()) }
civInfo.addNotification("One of our trades with [$otherCivName] has been cut short", NotificationIcon.Trade)
otherCiv().addNotification("One of our trades with [${civInfo.civName}] has been cut short", NotificationIcon.Trade)
civInfo.addNotification("One of our trades with [$otherCivName] has been cut short", NotificationIcon.Trade, otherCivName)
otherCiv().addNotification("One of our trades with [${civInfo.civName}] has been cut short", NotificationIcon.Trade, civInfo.civName)
civInfo.updateDetailedCivResources()
}
}
@ -487,11 +487,11 @@ class DiplomacyManager() {
onWarDeclared()
otherCivDiplomacy.onWarDeclared()
otherCiv.addNotification("[${civInfo.civName}] has declared war on us!", NotificationIcon.War)
otherCiv.addNotification("[${civInfo.civName}] has declared war on us!", NotificationIcon.War, civInfo.civName)
otherCiv.popupAlerts.add(PopupAlert(AlertType.WarDeclaration, civInfo.civName))
getCommonKnownCivs().forEach {
it.addNotification("[${civInfo.civName}] has declared war on [${otherCiv().civName}]!", NotificationIcon.War)
it.addNotification("[${civInfo.civName}] has declared war on [$otherCivName]!", civInfo.civName, NotificationIcon.War, otherCivName)
}
otherCivDiplomacy.setModifier(DiplomaticModifiers.DeclaredWarOnUs, -20f)
@ -618,10 +618,10 @@ class DiplomacyManager() {
setFlag(DiplomacyFlags.DeclarationOfFriendship, 30)
otherCivDiplomacy().setFlag(DiplomacyFlags.DeclarationOfFriendship, 30)
if (otherCiv().playerType == PlayerType.Human)
otherCiv().addNotification("[${civInfo.civName}] and [${otherCiv().civName}] have signed the Declaration of Friendship!", null, Color.WHITE)
otherCiv().addNotification("[${civInfo.civName}] and [$otherCivName] have signed the Declaration of Friendship!", null, Color.WHITE)
for (thirdCiv in getCommonKnownCivs().filter { it.isMajorCiv() }) {
thirdCiv.addNotification("[${civInfo.civName}] and [${otherCiv().civName}] have signed the Declaration of Friendship!", null, Color.WHITE)
thirdCiv.addNotification("[${civInfo.civName}] and [$otherCivName] have signed the Declaration of Friendship!", null, Color.WHITE)
thirdCiv.getDiplomacyManager(civInfo).setFriendshipBasedModifier()
}
}

View File

@ -628,7 +628,7 @@ class MapUnit {
actions.add {
val tech = researchableAncientEraTechs.random(tileBasedRandom).name
civInfo.tech.addTechnology(tech)
civInfo.addNotification("We have discovered the lost technology of [$tech] in the ruins!", tile.position, NotificationIcon.Science)
civInfo.addNotification("We have discovered the lost technology of [$tech] in the ruins!", tile.position, NotificationIcon.Science, tech)
}

View File

@ -285,7 +285,9 @@ object ImageGetter {
return iconGroup
}
fun getTechIconGroup(techName: String, circleSize: Float): Group {
fun getTechIconGroup(techName: String, circleSize: Float) = getTechIcon(techName).surroundWithCircle(circleSize)
fun getTechIcon(techName: String): Image {
val techIconColor = when (ruleset.technologies[techName]!!.era()) {
Constants.ancientEra -> colorFromRGB(255, 87, 35)
Constants.classicalEra -> colorFromRGB(233, 31, 99)
@ -298,7 +300,6 @@ object ImageGetter {
else -> Color.WHITE.cpy()
}
return getImage("TechIcons/$techName").apply { color = techIconColor.lerp(Color.BLACK, 0.6f) }
.surroundWithCircle(circleSize)
}
fun getProgressBarVertical(width: Float, height: Float, percentComplete: Float, progressColor: Color, backgroundColor: Color): Table {

View File

@ -2,6 +2,7 @@ package com.unciv.ui.worldscreen
import com.unciv.ui.utils.AutoScrollPane as ScrollPane
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.Touchable
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.unciv.logic.civilization.Notification
@ -33,11 +34,21 @@ class NotificationsScroll(internal val worldScreen: WorldScreen) : ScrollPane(nu
val label = notification.text.toLabel(Color.BLACK, 30)
val listItem = Table()
if (notification.icons.isNotEmpty())
for(icon in notification.icons)
listItem.add(ImageGetter.getImage(icon)).size(20f).padRight(5f)
val iconSize = 20f
if (notification.icons.isNotEmpty()) {
val ruleset = worldScreen.gameInfo.ruleSet
for (icon in notification.icons) {
val image: Actor = when {
ruleset.technologies.containsKey(icon) -> ImageGetter.getTechIcon(icon)
ruleset.nations.containsKey(icon) -> ImageGetter.getNationIndicator(ruleset.nations[icon]!!, iconSize)
ruleset.units.containsKey(icon) -> ImageGetter.getUnitIcon(icon)
else -> ImageGetter.getImage(icon)
}
listItem.add(image).size(iconSize).padRight(5f)
}
}
else if(notification.color!=null) listItem.add(ImageGetter.getCircle()
.apply { color = notification.color }).size(20f).padRight(5f)
.apply { color = notification.color }).size(iconSize).padRight(5f)
listItem.background = ImageGetter.getRoundedEdgeTableBackground().apply { setScale(0.5f) }
listItem.add(label)