From 5c4798442d6fff5cbfe8c405144278acc81a6c1b Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 12 Jan 2023 18:01:19 +0200 Subject: [PATCH] Notification scroll categories improved --- .../unciv/logic/city/CityExpansionManager.kt | 2 +- .../com/unciv/logic/city/PopulationManager.kt | 4 ++-- .../civilization/CivInfoTransientUpdater.kt | 4 ++-- .../unciv/logic/civilization/Notification.kt | 2 +- .../ruleset/unique/UniqueTriggerActivation.kt | 4 ++-- .../NotificationsOverviewTable.kt | 3 ++- .../ui/worldscreen/NotificationsScroll.kt | 18 ++++++++++++------ .../unciv/ui/worldscreen/unit/UnitActions.kt | 2 +- 8 files changed, 23 insertions(+), 16 deletions(-) diff --git a/core/src/com/unciv/logic/city/CityExpansionManager.kt b/core/src/com/unciv/logic/city/CityExpansionManager.kt index 1ed33018f1..4d44bfa880 100644 --- a/core/src/com/unciv/logic/city/CityExpansionManager.kt +++ b/core/src/com/unciv/logic/city/CityExpansionManager.kt @@ -171,7 +171,7 @@ class CityExpansionManager : IsPartOfGameInfoSerialization { val location = addNewTileWithCulture() if (location != null) { val locations = LocationAction(location, cityInfo.location) - cityInfo.civInfo.addNotification("[" + cityInfo.name + "] has expanded its borders!", locations, NotificationCategory.City, NotificationIcon.Culture) + cityInfo.civInfo.addNotification("[" + cityInfo.name + "] has expanded its borders!", locations, NotificationCategory.Cities, NotificationIcon.Culture) } } } diff --git a/core/src/com/unciv/logic/city/PopulationManager.kt b/core/src/com/unciv/logic/city/PopulationManager.kt index 4f3f55d47e..ad2705611f 100644 --- a/core/src/com/unciv/logic/city/PopulationManager.kt +++ b/core/src/com/unciv/logic/city/PopulationManager.kt @@ -72,7 +72,7 @@ class PopulationManager : IsPartOfGameInfoSerialization { foodStored += food if (food < 0) cityInfo.civInfo.addNotification("[${cityInfo.name}] is starving!", - cityInfo.location, NotificationCategory.City, NotificationIcon.Growth, NotificationIcon.Death) + cityInfo.location, NotificationCategory.Cities, NotificationIcon.Growth, NotificationIcon.Death) if (foodStored < 0) { // starvation! if (population > 1) addPopulation(-1) foodStored = 0 @@ -89,7 +89,7 @@ class PopulationManager : IsPartOfGameInfoSerialization { addPopulation(1) cityInfo.updateCitizens = true cityInfo.civInfo.addNotification("[${cityInfo.name}] has grown!", cityInfo.location, - NotificationCategory.City, NotificationIcon.Growth) + NotificationCategory.Cities, NotificationIcon.Growth) } } diff --git a/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt b/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt index 6b2fafa65e..9184e270b1 100644 --- a/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt +++ b/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt @@ -165,13 +165,13 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo) { for (city in citiesReachedToMediums.keys) if (city !in civInfo.citiesConnectedToCapitalToMediums && city.civInfo == civInfo && city != civInfo.getCapital()!!) civInfo.addNotification("[${city.name}] has been connected to your capital!", - city.location, NotificationCategory.City, NotificationIcon.Gold) + city.location, NotificationCategory.Cities, NotificationIcon.Gold) // This may still contain cities that have just been destroyed by razing - thus the population test for (city in civInfo.citiesConnectedToCapitalToMediums.keys) if (!citiesReachedToMediums.containsKey(city) && city.civInfo == civInfo && city.population.population > 0) civInfo.addNotification("[${city.name}] has been disconnected from your capital!", - city.location, NotificationCategory.City, NotificationIcon.Gold) + city.location, NotificationCategory.Cities, NotificationIcon.Gold) } civInfo.citiesConnectedToCapitalToMediums = citiesReachedToMediums diff --git a/core/src/com/unciv/logic/civilization/Notification.kt b/core/src/com/unciv/logic/civilization/Notification.kt index 3efb7e2d69..1aadf0fed6 100644 --- a/core/src/com/unciv/logic/civilization/Notification.kt +++ b/core/src/com/unciv/logic/civilization/Notification.kt @@ -48,7 +48,7 @@ enum class NotificationCategory{ Units, War, Religion, - City + Cities } /** diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt b/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt index 4087f062b7..2aa63ce686 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt @@ -223,7 +223,7 @@ object UniqueTriggerActivation { civInfo.addNotification( notification, LocationAction(applicableCities.map { it.location }), - NotificationCategory.City, + NotificationCategory.Cities, NotificationIcon.Population ) return applicableCities.any() @@ -240,7 +240,7 @@ object UniqueTriggerActivation { civInfo.addNotification( notificationText, LocationAction(randomCity.location, tile?.position), - NotificationCategory.City, + NotificationCategory.Cities, NotificationIcon.Population ) } diff --git a/core/src/com/unciv/ui/overviewscreen/NotificationsOverviewTable.kt b/core/src/com/unciv/ui/overviewscreen/NotificationsOverviewTable.kt index 2800570766..d1c213b0c1 100644 --- a/core/src/com/unciv/ui/overviewscreen/NotificationsOverviewTable.kt +++ b/core/src/com/unciv/ui/overviewscreen/NotificationsOverviewTable.kt @@ -82,7 +82,8 @@ class NotificationsOverviewTable( val categoryNotifications = notifications.filter { it.category == category.name } if (categoryNotifications.isEmpty()) continue - turnTable.add(category.name.toLabel()).pad(3f).row() + if (category != NotificationCategory.General) + turnTable.add(category.name.toLabel()).pad(3f).row() for (notification in categoryNotifications) { val notificationTable = Table(BaseScreen.skin) diff --git a/core/src/com/unciv/ui/worldscreen/NotificationsScroll.kt b/core/src/com/unciv/ui/worldscreen/NotificationsScroll.kt index bc3e70cad7..0ca3b42fc3 100644 --- a/core/src/com/unciv/ui/worldscreen/NotificationsScroll.kt +++ b/core/src/com/unciv/ui/worldscreen/NotificationsScroll.kt @@ -78,15 +78,21 @@ class NotificationsScroll( val categoryNotifications = reversedNotifications.filter { it.category == category.name } if (categoryNotifications.isEmpty()) continue - notificationsTable.add(Table().apply { - add(ImageGetter.getWhiteDot()).minHeight(2f).width(worldScreen.stage.width/8) - add(category.name.toLabel(fontSize = 20)).pad(3f) - add(ImageGetter.getWhiteDot()).minHeight(2f).width(worldScreen.stage.width/8) - }).row() + val backgroundDrawable = BaseScreen.skinStrings.getUiBackground("WorldScreen/Notification", BaseScreen.skinStrings.roundedEdgeRectangleShape) + + if (category != NotificationCategory.General) + notificationsTable.add(Table().apply { + add(ImageGetter.getWhiteDot()).minHeight(2f).width(worldScreen.stage.width/8) + add(Table().apply { + background = backgroundDrawable + add(category.name.toLabel(fontSize = 30, fontColor = Color.BLACK)) + }).pad(3f) + add(ImageGetter.getWhiteDot()).minHeight(2f).width(worldScreen.stage.width/8) + }).row() for (notification in categoryNotifications) { val listItem = Table() - listItem.background = BaseScreen.skinStrings.getUiBackground("WorldScreen/Notification", BaseScreen.skinStrings.roundedEdgeRectangleShape) + listItem.background = backgroundDrawable val labelWidth = maxEntryWidth - iconSize * notification.icons.size - 10f val label = WrappableLabel(notification.text, labelWidth, Color.BLACK, 30) diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index d658c10210..a025277c9f 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -828,7 +828,7 @@ object UnitActions { for (otherCiv in civsToNotify) otherCiv.addNotification("Your territory has been stolen by [${unit.civInfo}]!", - unit.currentTile.position, NotificationCategory.City, unit.civInfo.civName, NotificationIcon.War) + unit.currentTile.position, NotificationCategory.Cities, unit.civInfo.civName, NotificationIcon.War) } private fun addFortifyActions(actionList: ArrayList, unit: MapUnit, showingAdditionalActions: Boolean) {