Show UnitTypes in Civilopedia (#8729)

* Show UnitTypes in Civilopedia

* Show UnitTypes in Civilopedia - polish
This commit is contained in:
SomeTroglodyte
2023-02-25 19:40:59 +01:00
committed by GitHub
parent 5d74689b19
commit 5d80f50d93
16 changed files with 298 additions and 233 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 501 KiB

After

Width:  |  Height:  |  Size: 509 KiB

View File

@ -99,10 +99,8 @@ Requires at least one of the following: = Benötigt eine der folgenden Vorrausse
Requires all of the following: = Benötigt folgende Vorraussetzungen:
Leads to [techName] = [techName] kann nun erforscht werden
Leads to: = Ermöglicht die Erforschung von:
# Requires translation!
Enables: =
# Requires translation!
Disables: =
Enables: = Ermöglicht:
Disables: = Deaktiviert:
Current construction = Aktuelle Produktion
Construction queue = Produktionswarteschlange
@ -1417,6 +1415,7 @@ Turns until barbarians enter player tiles = Züge bis Barbaren Spielerfelder bet
Gold reward for clearing barbarian camps = Gold-Belohnung für das Räumen von Barbarenlagern
# Other civilopedia things
Nations = Nationen
Available for [unitTypes] = Verfügbar für [unitTypes]
Available for: = Verfügbar für:
@ -1443,7 +1442,7 @@ Faith cost modifier: [amount]%☮ = Glaubenskosten-Modifikator: [amount]%☮
Improvement build length modifier: [amount]%⏳ = Baudauer-Verbessserungen-Modifikator: [amount]%⏳
Diplomatic deal duration: [amount] turns⏳ = Diplomatische Handelsdauer: [amount] turns⏳
Gold gift influence gain modifier: [amount]%¤ = Erhaltener-Einfluss-durch-Goldgeschenk-Modifikator: [amount]%¤
City-state tribute scaling interval: [amount] turns⏳ = Skalierungszeitraum für den Tribut der Stadtstaaten: [amount] turns
City-state tribute scaling interval: [amount] turns⏳ = Skalierungszeitraum für den Tribut der Stadtstaaten: [amount] Runden
Barbarian spawn modifier: [amount]%† = Erscheinen-von-Barbaren-Modifikator: [amount]%†
Golden age length modifier: [amount]%⌣ = Länge-Goldenes-Zeitalter-Modifikator: [amount]%⌣
Adjacent city religious pressure: [amount]☮ = Religiöser Druck zu benachbarten Städten: [amount]☮
@ -1453,11 +1452,13 @@ Pillaging this improvement yields [stats] = Plünderung dieser Verbesserung ergi
Pillaging this improvement yields approximately [stats] = Plünderung dieser Verbesserung ergibt ungefähr [stats]
Needs removal of terrain features to be built = Benötigt die Entfernung von Geländefunktionen um gebaut werden zu können
Unit type = Einheitentyp
Units: = Einheiten:
Unit types = Einheitentypen
Domain: [param] = Domäne: [param]
Toggle UI (World Screen only) = Oberfläche umschalten (Nur die Weltansicht)
# Policies
Adopt = Verabschieden
Completed = Vollständig
On adoption = Beim Verabschieden
@ -2084,8 +2085,7 @@ upon founding a city = bei der Gründung einer Stadt
upon discovering a Natural Wonder = bei der Entdeckung eines Naturwunders
upon constructing [buildingFilter] = beim Bau von [buildingFilter]
upon constructing [buildingFilter] [cityFilter] = beim Bau von [buildingFilter] [cityFilter]
# Requires translation!
upon gaining a [baseUnitFilter] unit =
upon gaining a [baseUnitFilter] unit = nach Erhalt einer [baseUnitFilter] Einheit
upon founding a Pantheon = bei der Gründung eines Pantheons
upon founding a Religion = bei der Gründung einer Religion
upon enhancing a Religion = bei der Verbesserung einer Religion
@ -6239,4 +6239,3 @@ Enemy military land units block tiles they are standing on. Enemy military naval
City Blockade = Blockade einer Stadt
One of your cities is under a naval blockade! When all adjacent water tiles of a coastal city are blocked - city loses harbor connection to all other cities, including capital. Make sure to de-blockade cities by deploying friendly military naval units to fight off invaders. = Eine deiner Städte steht unter einer Seeblockade! Wenn alle angrenzenden Wasserfelder einer Küstenstadt blockiert sind, verliert die Stadt die Hafenverbindung zu allen anderen Städten, einschließlich der Hauptstadt. Stelle sicher, dass du die Blockade aufhebst, indem du befreundete militärische Marineeinheiten einsetzt, um Eindringlinge abzuwehren.

View File

@ -1415,6 +1415,7 @@ Turns until barbarians enter player tiles =
Gold reward for clearing barbarian camps =
# Other civilopedia things
Nations =
Available for [unitTypes] =
Available for: =
@ -1451,11 +1452,13 @@ Pillaging this improvement yields [stats] =
Pillaging this improvement yields approximately [stats] =
Needs removal of terrain features to be built =
Unit type =
Units: =
Unit types =
Domain: [param] =
Toggle UI (World Screen only) =
# Policies
Adopt =
Completed =
On adoption =

View File

@ -22,7 +22,7 @@ object BaseUnitDescriptions {
for (promotion in baseUnit.promotions)
infoList += promotion.tr()
if (baseUnit.replacementTextForUniques != "") infoList += baseUnit.replacementTextForUniques
else for (unique in baseUnit.uniqueObjects) if(!unique.hasFlag(UniqueFlag.HiddenToUsers))
else for (unique in baseUnit.uniqueObjects) if (!unique.hasFlag(UniqueFlag.HiddenToUsers))
infoList += unique.text.tr()
return infoList.joinToString()
}
@ -61,9 +61,12 @@ object BaseUnitDescriptions {
return lines.joinToString("\n")
}
fun getCivilopediaTextLines(baseUnit: BaseUnit, ruleset: Ruleset): List<FormattedLine> {
fun getCivilopediaTextLines(baseUnit: BaseUnit, ruleset: Ruleset): List<FormattedLine> {
val textList = ArrayList<FormattedLine>()
textList += FormattedLine("{Unit type}: ${baseUnit.unitType.tr()}")
// Don't call baseUnit.getType() here - coming from the main menu baseUnit isn't fully initialized
val unitTypeLink = ruleset.unitTypes[baseUnit.unitType]?.makeLink() ?: ""
textList += FormattedLine("{Unit type}: ${baseUnit.unitType.tr()}", unitTypeLink)
val stats = ArrayList<String>()
if (baseUnit.strength != 0) stats += "${baseUnit.strength}${Fonts.strength}"
@ -187,4 +190,39 @@ object BaseUnitDescriptions {
return textList
}
fun UnitType.getUnitTypeCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
fun getDomainLines() = sequence<FormattedLine> {
yield(FormattedLine("{Unit types}:", header = 4))
val myMovementType = getMovementType()
for (unitType in ruleset.unitTypes.values) {
if (unitType.getMovementType() != myMovementType) continue
if (!unitType.isUsed(ruleset)) continue
yield(FormattedLine(unitType.name, unitType.makeLink()))
}
}
fun getUnitTypeLines() = sequence<FormattedLine> {
getMovementType()?.let {
val color = when (it) {
UnitMovementType.Land -> "#ffc080"
UnitMovementType.Water -> "#80d0ff"
UnitMovementType.Air -> "#e0e0ff"
}
yield(FormattedLine("Domain: [${it.name}]", "UnitType/Domain: [${it.name}]", color = color))
yield(FormattedLine(separator = true))
}
yield(FormattedLine("Units:", header = 4))
for (unit in ruleset.units.values) {
if (unit.unitType != name) continue
yield(FormattedLine(unit.name, unit.makeLink()))
}
if (uniqueObjects.isNotEmpty()) {
yield(FormattedLine(separator = true))
for (unique in uniqueObjects) {
if (unique.hasFlag(UniqueFlag.HiddenToUsers)) continue
yield(FormattedLine(unique))
}
}
}
return (if (name.startsWith("Domain: ")) getDomainLines() else getUnitTypeLines()).toList()
}
}

View File

@ -1,7 +1,9 @@
package com.unciv.models.ruleset.unit
import com.unciv.models.ruleset.Ruleset
import com.unciv.models.ruleset.RulesetObject
import com.unciv.models.ruleset.unique.UniqueTarget
import com.unciv.models.ruleset.unit.BaseUnitDescriptions.getUnitTypeCivilopediaTextLines
enum class UnitLayer { // The layer in which the unit moves
@ -21,7 +23,7 @@ class UnitType() : RulesetObject() {
private val unitMovementType: UnitMovementType? by lazy { if (movementType == null) null else UnitMovementType.valueOf(movementType!!) }
override fun getUniqueTarget() = UniqueTarget.UnitType
override fun makeLink() = "" // No own category on Civilopedia screen
override fun makeLink() = "UnitType/$name"
constructor(name: String, domain: String? = null) : this() {
this.name = name
@ -46,9 +48,25 @@ class UnitType() : RulesetObject() {
}
}
override fun getCivilopediaTextLines(ruleset: Ruleset) = getUnitTypeCivilopediaTextLines(ruleset)
override fun getSortGroup(ruleset: Ruleset): Int {
return if (name.startsWith("Domain: ")) 1 else 2
}
fun isUsed(ruleset: Ruleset) = ruleset.units.values.any { it.unitType == name }
companion object {
val City = UnitType("City", "Land")
fun getCivilopediaIterator(ruleset: Ruleset): Collection<UnitType> {
return UnitMovementType.values().map {
// Create virtual UnitTypes to describe the movement domains - Civilopedia only.
// It is important that the name includes the [] _everywhere_
// (here, CivilopediaImageGetters, links, etc.) so translation comes as cheap as possible.
UnitType("Domain: [${it.name}]", it.name)
} + ruleset.unitTypes.values.filter {
it.isUsed(ruleset)
}
}
}
}

View File

@ -9,10 +9,12 @@ import com.unciv.logic.map.tile.Tile
import com.unciv.models.ruleset.Ruleset
import com.unciv.models.ruleset.tile.Terrain
import com.unciv.models.ruleset.tile.TerrainType
import com.unciv.models.ruleset.unit.UnitMovementType
import com.unciv.ui.images.ImageGetter
import com.unciv.ui.components.tilegroups.TileGroup
import com.unciv.ui.components.tilegroups.TileSetStrings
import com.unciv.ui.components.KeyCharAndCode
import com.unciv.ui.components.extensions.setSize
import com.unciv.ui.components.extensions.surroundWithCircle
import java.io.File
@ -91,6 +93,13 @@ object CivilopediaImageGetters {
val belief = { name: String, size: Float ->
ImageGetter.getReligionPortrait(name, size)
}
val unitType = { name: String, size: Float ->
val path = UnitMovementType.values().firstOrNull { "Domain: [${it.name}]" == name }
?.let {"UnitTypeIcons/Domain${it.name}" }
?: "UnitTypeIcons/$name"
if (ImageGetter.imageExists(path)) ImageGetter.getImage(path).apply { setSize(size) }
else null
}
}
/** Enum used as keys for Civilopedia "pages" (categories).
@ -137,6 +146,11 @@ enum class CivilopediaCategories (
KeyCharAndCode('U'),
"OtherIcons/Shield"
),
UnitType ("Unit types", false,
CivilopediaImageGetters.unitType,
KeyCharAndCode('U'),
"UnitTypeIcons/UnitTypes"
),
Nation ("Nations", false,
CivilopediaImageGetters.nation,
KeyCharAndCode('N'),
@ -183,7 +197,7 @@ enum class CivilopediaCategories (
"OtherIcons/Timer"
);
fun getByOffset(offset: Int) = values()[(ordinal + count + offset) % count]
private fun getByOffset(offset: Int) = values()[(ordinal + count + offset) % count]
fun nextForKey(key: KeyCharAndCode): CivilopediaCategories {
for (i in 1..count) {

View File

@ -13,6 +13,7 @@ import com.unciv.models.ruleset.Belief
import com.unciv.models.ruleset.Ruleset
import com.unciv.models.ruleset.unique.IHasUniques
import com.unciv.models.ruleset.unique.UniqueType
import com.unciv.models.ruleset.unit.UnitType
import com.unciv.models.stats.INamed
import com.unciv.models.translations.tr
import com.unciv.ui.images.IconTextButton
@ -206,6 +207,7 @@ class CivilopediaScreen(
CivilopediaCategories.Terrain -> ruleset.terrains.values
CivilopediaCategories.Improvement -> ruleset.tileImprovements.values
CivilopediaCategories.Unit -> ruleset.units.values
CivilopediaCategories.UnitType -> UnitType.getCivilopediaIterator(ruleset)
CivilopediaCategories.Nation -> ruleset.nations.values.filter { !it.isSpectator() }
CivilopediaCategories.Technology -> ruleset.technologies.values
CivilopediaCategories.Promotion -> ruleset.unitPromotions.values

View File

@ -177,6 +177,7 @@ class FormattedLine (
yield(CivilopediaCategories.Improvement to ruleSet.tileImprovements)
yield(CivilopediaCategories.Resource to ruleSet.tileResources)
yield(CivilopediaCategories.Nation to ruleSet.nations)
yield(CivilopediaCategories.UnitType to ruleSet.unitTypes)
yield(CivilopediaCategories.Unit to ruleSet.units)
yield(CivilopediaCategories.Technology to ruleSet.technologies)
yield(CivilopediaCategories.Building to ruleSet.buildings.filter { !it.value.isAnyWonder() })

View File

@ -620,7 +620,7 @@ Unless otherwise specified, all the following are from [the Noun Project](https:
- [Move](https://thenounproject.com/search/?q=move&i=790952) By Sandra for Mobility
- [accuracy](https://thenounproject.com/search/?q=accuracy&i=2017348) By vigtographics for Targeting
- [location](https://thenounproject.com/search/?q=location&i=2858979) by Humantech for Accuracy
- [Plane](https://thenounproject.com/search/?q=plane&i=1875398) By Tran Minh Villageois for Interception
- [Plane](https://thenounproject.com/search/?q=plane&i=1875398) By Tran Minh Villageois for Interception / Domain Air
- [Hammer](https://thenounproject.com/search/?q=hammer&i=854936) by Thengakola for Air Repair
- [Hook](https://thenounproject.com/search/?q=hook&i=738678) By Yeong Rong Kim for Boarding Party
- [Leaf](https://thenounproject.com/search/?q=Leaf&i=1627477) By Paul Verhulst for Indirect Fire
@ -633,7 +633,7 @@ Unless otherwise specified, all the following are from [the Noun Project](https:
- Icon for Flight Deck is made by [JackRainy](https://github.com/JackRainy)
- Icon for Armor Plating is made by [JackRainy](https://github.com/JackRainy)
- [Slingshot](https://thenounproject.com/term/slingshot/9106/) by James Keuning for Slinger Withdraw
- [Anchor](https://thenounproject.com/term/anchor/676586) by Gregor Cresnar for Amphibious
- [Anchor](https://thenounproject.com/term/anchor/676586) by Gregor Cresnar for Amphibious / Domain Water
- [survival knife](https://thenounproject.com/search/?q=survival&i=2663392) by b faris for Survivalism
- [Shamrock](https://thenounproject.com/term/shamrock/358507/) By P Thanga Vignesh for Pictish Courage
- [home sweet home](https://thenounproject.com/term/home-sweet-home/3817166/) By Silviu Ojog for Home Sweet Home
@ -694,7 +694,8 @@ Unless otherwise specified, all the following are from [the Noun Project](https:
- [Magnifying Glass](https://thenounproject.com/term/magnifying-glass/1311/) by John Caserta for Mod filter
- [tick](https://thenounproject.com/term/tick/3968142/) by Adrien Coquet on Nation picker
- [people](https://thenounproject.com/term/people/458671) by Wilson Joseph as base for Civilopedia category Nations
- [Mountains ](https://thenounproject.com/term/mountains/15616/) by Andrew J. Young as base for Civilopedia category Terrains
- [Mountains ](https://thenounproject.com/term/mountains/15616/) by Andrew J. Young as base for Civilopedia category Terrains / Domain Land
- Civilopedia category UnitTypes icon done by [SomeTroglodyte](https://github.com/SomeTroglodyte) from sources cited for Interception, Cavalry and Longbowman
- [File:Maya.svg](https://en.wikipedia.org/wiki/File:Maya.svg) for Mayan numerals
- [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.
@ -717,51 +718,7 @@ Unless otherwise specified, all the following are from [the Noun Project](https:
- [Funny christmas vector](https://www.freepik.com/free-vector/reindeer-santa-hat-peeping-out_1430479.htm) by katemangostar
- [Santa beard vector](https://www.freepik.com/free-vector/positive-santa-ringing-bell-waving-hand_3636285.htm) by katemangostar
- [Funny christmas vector](https://www.freepik.com/free-vector/snowman-wearing-santa-hat-scarf-mittens_3636292.htm) by katemangostar
- [Circle](https://thenounproject.com/term/circle/1841891/) By Aybige
- [Arrow](https://thenounproject.com/term/arrow/18123/) By Joe Mortell for movement
- [Swap](https://thenounproject.com/search/?q=swap&i=1259600) By iconomania for swapping units
- [Connection](https://thenounproject.com/search/?q=connection&i=1521886) By Travis Avery
- [Skull](https://thenounproject.com/search/?q=Skull&i=1030702) By Vladimir Belochkin for disbanding units
- [Crosshair](https://thenounproject.com/search/?q=crosshairs&i=916030) By Bakunetsu Kaito for selecting enemies to attack
- [City](https://thenounproject.com/search/?q=city&i=571332) By Felix Westphal
- [Fire](https://thenounproject.com/search/?q=Fire&i=96564) By Lloyd Humphreys for "city being razed" icon
- [Sleep](https://thenounproject.com/search/?q=sleep&i=1760085) By Saeful Muslim
- [Banner](https://thenounproject.com/term/banner/866282/) By Emir Palavan for embarked units
- [Arrow](https://thenounproject.com/term/arrow/18123/) By uzeir syarief for moving between idle units
- [Replace](https://thenounproject.com/search/?q=replace&i=17858) By Mike Rowe for switching tiles between cities
- [Resistance](https://thenounproject.com/term/revolution/1315305/) By HeadsOfBirds
- [Viking Hat](https://thenounproject.com/search/?q=pillage&i=185405) By my name is mud for pillaging improvements
- [Aim](https://thenounproject.com/search/?q=aim&i=2034920) By Kaviashri for ranged strength
- [Capitol](https://thenounproject.com/search/?q=capitol&i=160031) By Loren Klein for City-States
- [Aircraft](https://thenounproject.com/search/?q=aircraft&i=1629000) By Tom Fricker for aircraft icon in city button
- [radar scan](https://thenounproject.com/search/?q=range&i=1500234) By icon 54 for Range
- [short range radar](https://thenounproject.com/search/?q=air%20range&i=2612731) by Vectors Point for Intercept range
- [AirSweep](https://thenounproject.com/icon/jet-134340/) by Creative Stall for Air Sweep icon
- [Puppet](https://thenounproject.com/search/?q=puppet&i=285735) By Ben Davis for puppeted cities
- [City](https://thenounproject.com/search/?q=city&i=1765370) By Muhajir ila Robbi in the Icon center
- [Lock](https://thenounproject.com/search/?q=lock&i=3217613) by Vadim Solomakhin for locked tiles
- [Hourglass](https://thenounproject.com/search/?q=hourglass&i=142268) by I Create Stuff for the 'Turn' icon
- [Shield](https://thenounproject.com/search/?q=shield&i=813568) by Gregor Cresnar for Religious Strength
- [skill sword flame](https://thenounproject.com/term/skill-sword-flame/2360212/) by Maxicons) for Remove Heresy
- [Pencil](https://thenounproject.com/search/?q=pencil&i=4195852) by Muhamad Aldi Maulana for Enter Text Prompt Button / Pencil
- [Parchment](https://thenounproject.com/term/parchment/1516378/) by hans draiman for Cultured City-States
- [connection](https://thenounproject.com/term/connection/1365233/) by Popular for Mercantile City-States
- [crossed sword](https://thenounproject.com/term/crossed-sword/2427559/) by ProSymbols for Militaristic City-States
- [ship helm](https://thenounproject.com/term/ship-helm/2170591/) by Vectors Market for Maritime City-States
- [Magnifying Glass](https://thenounproject.com/term/magnifying-glass/1311/) by John Caserta for Mod filter
- [tick](https://thenounproject.com/term/tick/3968142/) by Adrien Coquet on Nation picker
- [people](https://thenounproject.com/term/people/458671) by Wilson Joseph as base for Civilopedia category Nations
- [Mountains ](https://thenounproject.com/term/mountains/15616/) by Andrew J. Young as base for Civilopedia category Terrains
- [File:Maya.svg](https://en.wikipedia.org/wiki/File:Maya.svg) for Mayan numerals
- [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
- [turn right](https://thenounproject.com/icon/turn-right-1920867/) by Alice Design for Resource Overview
- [Tyrannosaurus Rex](https://thenounproject.com/icon/tyrannosaurus-rex-4130976/) by Amethyst Studio for Civilopedia Eras header
- [Timer](https://www.flaticon.com/free-icons/timer) created by Gregor Cresnar Premium - Flaticon
- [Political Science](https://www.flaticon.com/premium-icon/political-science_5403775) created by Hilmy Abiyyu A. - Flaticon
- [Question](https://thenounproject.com/icon/question-1157126/) created by Aneeque Ahmed for Question Icon

View File

@ -23,7 +23,7 @@ You will need to supply the graphics for new elements - a new unit needs its ico
- Promotions can be named "Something I" (or " II" or " III"). The suffix will be removed and painted as little stars, only the base `UnitPromotionIcons/Something.png` will be loaded.
- The special rules for promotions can be combined, e.g. "`[Warrior] ability III`" will fall back to the Warrior unit icon and paint 3 Stars on it.
Additionally, there there are two kinds of images where the game has display capability but does not supply graphics itself, as described in the next paragraphs:
Additionally, there there are some kinds of images where the game has display capability but does not supply graphics itself, as described in the next paragraphs:
### Adding custom Fonts
@ -57,6 +57,11 @@ Portraits and backgrounds work best if they are full RGB square, between 100x100
For example, [here](https://github.com/vegeta1k95/Civ-5-Icons) is mod showing how to add custom portraits, which can complement the base game.
### Adding icons for Unit Types
The Unit Types as defined in [UnitTypes.json](../Other/Unit-related-JSON-files#unittypesjson) have no icons in the base game, but Civilopedia can decorate their entries if you supply images named 'Images/UnitTypeIcons/<UnitType>.png'.
(while you're at it, you may override the default icon for the Unit Type _category header_ - it's 'UnitTypes.png' in the same folder, or the icons used for the movement domains - 'DomainLand', 'DomainWater', 'DomainAir')
## Sounds
Standard values are below. The sounds themselves can be found [here](/sounds).