Added colors to notifications, depending on the context (attack, culture growth, tech, city growth, etc.)

This commit is contained in:
Yair Morgenstern
2018-05-29 23:43:54 +03:00
parent e1bd1c271e
commit aa0ddd4128
15 changed files with 45 additions and 29 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 902 B

View File

@ -1,5 +1,6 @@
package com.unciv.logic.automation
import com.badlogic.gdx.graphics.Color
import com.unciv.logic.city.CityConstructions
import com.unciv.logic.city.CityInfo
import com.unciv.logic.civilization.CivilizationInfo
@ -101,7 +102,7 @@ class Automation {
}
if (cityInfo.civInfo == cityInfo.civInfo.gameInfo.getPlayerCivilization())
cityInfo.civInfo.addNotification("Work has started on $currentConstruction", cityInfo.location)
cityInfo.civInfo.addNotification("Work has started on $currentConstruction", cityInfo.location, Color.BROWN)
}
}

View File

@ -1,5 +1,6 @@
package com.unciv.logic.automation
import com.badlogic.gdx.graphics.Color
import com.unciv.UnCivGame
import com.unciv.logic.battle.Battle
import com.unciv.logic.battle.CityCombatant
@ -97,7 +98,7 @@ class UnitAutomation{
else {
val unitToAttack = enemyTileToAttack.unit!!
if (unitToAttack.getBaseUnit().unitType == UnitType.Civilian) { // kill
unitToAttack.civInfo.addNotification("Our " + unitToAttack.name + " was destroyed by an enemy " + unit.name + "!", enemyTileToAttack.position)
unitToAttack.civInfo.addNotification("Our " + unitToAttack.name + " was destroyed by an enemy " + unit.name + "!", enemyTileToAttack.position, Color.RED)
enemyTileToAttack.unit = null
unit.movementAlgs().headTowards(enemyTileToAttack)
return

View File

@ -1,5 +1,6 @@
package com.unciv.logic.battle
import com.badlogic.gdx.graphics.Color
import com.unciv.logic.GameInfo
import com.unciv.logic.city.CityInfo
import com.unciv.logic.map.TileInfo
@ -151,7 +152,7 @@ class Battle(val gameInfo:GameInfo) {
if (defender.getUnitType() == UnitType.City) " "+defender.getName()
else " our " + defender.getName()
val notificationString = "An enemy " + attacker.getName() + whatHappenedString + defenderString
gameInfo.getPlayerCivilization().addNotification(notificationString, attackedTile.position)
gameInfo.getPlayerCivilization().addNotification(notificationString, attackedTile.position, Color.RED)
}
@ -174,7 +175,7 @@ class Battle(val gameInfo:GameInfo) {
private fun conquerCity(city: CityInfo, attacker: ICombatant) {
val enemyCiv = city.civInfo
attacker.getCivilization().addNotification("We have conquered the city of ${city.name}!",city.location)
attacker.getCivilization().addNotification("We have conquered the city of ${city.name}!",city.location, Color.RED)
enemyCiv.cities.remove(city)
attacker.getCivilization().cities.add(city)
city.civInfo = attacker.getCivilization()
@ -191,7 +192,7 @@ class Battle(val gameInfo:GameInfo) {
city.cityConstructions.builtBuildings.remove("Palace")
if(enemyCiv.cities.isEmpty()) {
gameInfo.getPlayerCivilization()
.addNotification("The civilization of ${enemyCiv.civName} has been destroyed!", null)
.addNotification("The civilization of ${enemyCiv.civName} has been destroyed!", null, Color.RED)
}
else{
enemyCiv.cities.first().cityConstructions.builtBuildings.add("Palace") // relocate palace

View File

@ -1,5 +1,6 @@
package com.unciv.logic.city
import com.badlogic.gdx.graphics.Color
import com.unciv.logic.automation.Automation
import com.unciv.models.gamebasics.Building
import com.unciv.models.gamebasics.GameBasics
@ -94,7 +95,7 @@ class CityConstructions {
currentConstruction = "lie"
if (!construction.isBuildable(this)) {
// We can't build this building anymore! (Wonder has been built / resource is gone / etc.)
cityInfo.civInfo.addNotification("Cannot continue work on $saveCurrentConstruction", cityInfo.location)
cityInfo.civInfo.addNotification("Cannot continue work on $saveCurrentConstruction", cityInfo.location, Color.BROWN)
Automation().chooseNextConstruction(this)
construction = getConstruction(currentConstruction)
} else
@ -109,10 +110,10 @@ class CityConstructions {
if(construction is Building && construction.isWonder && construction.requiredBuildingInAllCities==null) {
val playerCiv = cityInfo.civInfo.gameInfo.getPlayerCivilization()
val builtLocation = if(playerCiv.exploredTiles.contains(cityInfo.location)) cityInfo.name else "a faraway land"
playerCiv.addNotification("$currentConstruction has been built in $builtLocation", cityInfo.location)
playerCiv.addNotification("$currentConstruction has been built in $builtLocation", cityInfo.location, Color.BROWN)
}
else
cityInfo.civInfo.addNotification(currentConstruction + " has been built in " + cityInfo.name, cityInfo.location)
cityInfo.civInfo.addNotification(currentConstruction + " has been built in " + cityInfo.name, cityInfo.location, Color.BROWN)
Automation().chooseNextConstruction(this)
}

View File

@ -1,5 +1,6 @@
package com.unciv.logic.city
import com.badlogic.gdx.graphics.Color
import com.unciv.logic.automation.Automation
import com.unciv.logic.map.TileInfo
@ -48,7 +49,7 @@ class CityExpansionManager {
cultureStored += culture.toInt()
if (cultureStored >= getCultureToNextTile()) {
addNewTileWithCulture()
cityInfo.civInfo.addNotification(cityInfo.name + " has expanded its borders!", cityInfo.location)
cityInfo.civInfo.addNotification(cityInfo.name + " has expanded its borders!", cityInfo.location, Color.PURPLE)
}
}

View File

@ -1,5 +1,6 @@
package com.unciv.logic.city
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.math.Vector2
import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.map.RoadStatus
@ -94,7 +95,7 @@ class CityInfo {
this.location = cityLocation
civInfo.cities.add(this)
if(civInfo == civInfo.gameInfo.getPlayerCivilization())
civInfo.addNotification("$name has been founded!", cityLocation)
civInfo.addNotification("$name has been founded!", cityLocation, Color.PURPLE)
if (civInfo.policies.isAdopted("Legalism") && civInfo.cities.size <= 4) cityConstructions.addCultureBuilding()
if (civInfo.cities.size == 1) {
cityConstructions.builtBuildings.add("Palace")

View File

@ -1,5 +1,6 @@
package com.unciv.logic.city
import com.badlogic.gdx.graphics.Color
import com.unciv.logic.automation.Automation
import com.unciv.logic.map.TileInfo
import com.unciv.models.stats.Stats
@ -52,7 +53,7 @@ class PopulationManager {
cityInfo.workedTiles.remove(lowestRankedWorkedTile.position)
}
foodStored = 0
cityInfo.civInfo.addNotification(cityInfo.name + " is starving!", cityInfo.location)
cityInfo.civInfo.addNotification(cityInfo.name + " is starving!", cityInfo.location, Color.RED)
}
if (foodStored >= getFoodToNextPopulation())
// growth!
@ -61,7 +62,7 @@ class PopulationManager {
if (cityInfo.buildingUniques.contains("40% of food is carried over after a new citizen is born")) foodStored += (0.4f * getFoodToNextPopulation()).toInt() // Aqueduct special
population++
autoAssignPopulation()
cityInfo.civInfo.addNotification(cityInfo.name + " has grown!", cityInfo.location)
cityInfo.civInfo.addNotification(cityInfo.name + " has grown!", cityInfo.location, Color.GREEN)
}
}

View File

@ -1,5 +1,6 @@
package com.unciv.logic.civilization
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.math.Vector2
import com.unciv.logic.GameInfo
import com.unciv.logic.city.CityInfo
@ -165,7 +166,7 @@ class CivilizationInfo {
fun addGreatPerson(greatPerson: String) {
val randomCity = cities.getRandom()
placeUnitNearTile(cities.getRandom().location, greatPerson)
addNotification("A $greatPerson has been born!", randomCity.location)
addNotification("A $greatPerson has been born!", randomCity.location, Color.GOLD)
}
fun placeUnitNearTile(location: Vector2, unitName: String): MapUnit {
@ -187,9 +188,9 @@ class CivilizationInfo {
return viewablePositions
}
fun addNotification(text: String, location: Vector2?) {
fun addNotification(text: String, location: Vector2?,color: Color) {
if(isPlayerCivilization())
gameInfo.notifications.add(Notification(text, location))
gameInfo.notifications.add(Notification(text, location,color))
}
override fun toString(): String {return civName} // for debug

View File

@ -1,5 +1,7 @@
package com.unciv.logic.civilization
import com.badlogic.gdx.graphics.Color
class GoldenAgeManager {
@Transient
lateinit var civInfo: CivilizationInfo
@ -19,7 +21,7 @@ class GoldenAgeManager {
if (civInfo.buildingUniques.contains("Golden Age length increases +50%")) turnsToGoldenAge *= 1.5
if (civInfo.policies.isAdopted("Freedom Complete")) turnsToGoldenAge *= 1.5
turnsLeftForCurrentGoldenAge += turnsToGoldenAge.toInt()
civInfo.addNotification("You have entered a golden age!", null)
civInfo.addNotification("You have entered a golden age!", null, Color.GOLD)
}
fun endTurn(happiness: Int) {

View File

@ -1,15 +1,18 @@
package com.unciv.logic.civilization
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.math.Vector2
class Notification {
@JvmField var text: String = ""
@JvmField var location: Vector2? = null
var text: String = ""
var location: Vector2? = null
var color:Color = Color.BLACK
internal constructor()
constructor(text: String, location: Vector2?) {
constructor(text: String, location: Vector2?,color: Color) {
this.text = text
this.location = location
this.color=color
}
}

View File

@ -1,6 +1,7 @@
package com.unciv.logic.civilization
import com.badlogic.gdx.graphics.Color
import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.Technology
import com.unciv.models.gamebasics.Unit
@ -55,7 +56,7 @@ class TechManager {
techsInProgress.remove(currentTechnology)
techsToResearch.remove(currentTechnology)
techsResearched.add(currentTechnology)
civInfo.addNotification("Research of $currentTechnology has completed!", null)
civInfo.addNotification("Research of $currentTechnology has completed!", null, Color.BLUE)
val revealedResource = GameBasics.TileResources.values.firstOrNull { currentTechnology == it.revealedBy }
@ -67,7 +68,7 @@ class TechManager {
.firstOrNull { it.isCityCenter() }
if (closestCityTile != null) {
civInfo.addNotification(
revealedResource.name + " revealed near " + closestCityTile.getCity()!!.name, tileInfo.position)
revealedResource.name + " revealed near " + closestCityTile.getCity()!!.name, tileInfo.position, Color.BLUE)
break
}
}

View File

@ -33,7 +33,7 @@ class SaveScreen : PickerScreen() {
val newSave = Table()
val adjectives = listOf("Prancing","Obese","Junior","Senior","Abstract","Discombobulating","Simple","Awkward","Holy",
"Dangerous","Greasy","Stinky","Purple","Majestic","Incomprehensible","Cardboard","Chocolate","Robot","Ninja")
val nouns = listOf("Moose","Pigeon","Weasel","Ferret","Onion","Marshmellow","Crocodile","Inu Shiba",
val nouns = listOf("Moose","Pigeon","Weasel","Ferret","Onion","Marshmallow","Crocodile","Inu Shiba",
"Sandwich","Elephant","Kangaroo","Marmot","Beagle","Dolphin","Fish","Tomato","Duck")
val defaultSaveName = adjectives.getRandom()+" "+nouns.getRandom()
textField.text = defaultSaveName

View File

@ -63,7 +63,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen()
if (isFreeTechPick) {
civTech.techsResearched.add(selectedTech!!.name)
civTech.freeTechs -= 1
civInfo.addNotification("We have stumbled upon the discovery of " + selectedTech!!.name + "!", null)
civInfo.addNotification("We have stumbled upon the discovery of " + selectedTech!!.name + "!", null, Color.BLUE)
if (selectedTech!!.name == civTech.currentTechnology())
civTech.techsToResearch.remove(selectedTech!!.name)
} else

View File

@ -8,6 +8,7 @@ import com.unciv.logic.civilization.Notification
import com.unciv.ui.cityscreen.addClickListener
import com.unciv.ui.utils.CameraStageBaseScreen
import com.unciv.ui.utils.ImageGetter
import com.unciv.ui.utils.setFontColor
class NotificationsScroll(private val notifications: List<Notification>, internal val worldScreen: WorldScreen) : ScrollPane(null) {
private var notificationsTable = Table()
@ -19,14 +20,15 @@ class NotificationsScroll(private val notifications: List<Notification>, interna
internal fun update() {
notificationsTable.clearChildren()
for (notification in notifications) {
val label = Label(notification.text, CameraStageBaseScreen.skin)
label.color = Color.WHITE
val label = Label(notification.text, CameraStageBaseScreen.skin).setFontColor(Color.BLACK)
label.setFontScale(1.2f)
val minitable = Table()
minitable.background(ImageGetter.getDrawable("skin/civTableBackground.png")
.tint(Color(0x004085bf)))
minitable.add(label).pad(5f)
minitable.add(ImageGetter.getImage("OtherIcons/Circle.png")
.apply { color=notification.color }).size(10f).pad(5f)
minitable.background(ImageGetter.getDrawable("skin/civTableBackground.png"))
minitable.add(label).pad(10f)
if (notification.location != null) {
minitable.addClickListener {
@ -41,4 +43,4 @@ class NotificationsScroll(private val notifications: List<Notification>, interna
pack()
}
}
}