Show CityStateType civilopedia text on CS Nation pages - #15283
Conversation
CityStateType has no Civilopedia category; surface type lore and type-level uniques (except Start bias, already listed via getStartBias) on the nation entry. Co-authored-by: Cursor <cursoragent@cursor.com>
|
UI PR's need screenshots |
| val textList = ArrayList<FormattedLine>() | ||
|
|
||
| val cityStateType = ruleset.cityStateTypes[cityStateType]!! | ||
| textList += FormattedLine("{Type}: {${cityStateType.name}}", header = 4, color = "#"+cityStateType.getColor().toString()) |
There was a problem hiding this comment.
Not yours, but
https://kotlinlang.org/docs/coding-conventions.html#horizontal-whitespace
Also, how often is such a conversion done in the current codebase 🤔 ? The luxury version exists here:
Unciv/core/src/com/unciv/ui/components/widgets/ColorMarkupLabel.kt
Lines 108 to 113 in bcd2a97
And another here:
Might be worth a common extension.
There was a problem hiding this comment.
Good catch on the spacing — fixed.
Also extracted a shared Color.toHexColor() next to colorFromRGB in Scene2dExtensions, and wired Era.getHexColor / ColorMarkupLabel.toMarkup / this call site through it.
| return textList | ||
| } | ||
|
|
||
| @Readonly |
There was a problem hiding this comment.
Pity the @Cache/@LocalState way is blocked here, right?
See also: #15015, where it's done properly.
There was a problem hiding this comment.
Yes — restoring @Readonly fails here because uniquesToCivilopediaTextLines (mutable overload) is not @Readonly. Left a short note pointing at #15015; once the FormattedLineListBuilder lands this is the obvious cleanup.
There was a problem hiding this comment.
If it lands - I was hoping for some -any- feedback before I un-draft it, because converting existing code would be a lengthy chore. But then that was the trigger - seeing how many structurally different generators we cobbled together over time.
…only Co-authored-by: Cursor <cursoragent@cursor.com>
…t bias) Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…ayout) Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
| return textList | ||
| } | ||
|
|
||
| private fun Nation.appendStartBiasLines(textList: MutableList<FormattedLine>, ruleset: Ruleset) { |
There was a problem hiding this comment.
In fact as of the latest version this is Readinly-able! This is exactly the scenario for @Mutated, passing mutation rights on to subfunctions!
https://yairm210.github.io/Purity/usage/advanced-usage/#mutating-input-parameters
|
Tried marking |
Summary
Follow-up to #15271 / review note from @SomeTroglodyte:
CityStateTypeis aRulesetObjectwithcivilopediaText/uniques, but has no Civilopedia category.civilopediaTextand type-leveluniqueson the city-state Nation civilopedia page (NationDescriptions.getCityStateInfo).Start bias […]from the type is not duplicated in the type-unique list — it already appears viaNation.getStartBias, using the same block as major civs (Terrain/…link, chain + terrain icons, civilopedia navigation).Color.toHexColor()helper (review).(Screenshot file is for review only; can drop
_pr_screenshots/before merge.)Test plan
CityStateTypeCivilopediaOnNationTestsTerrain/Coastlink (click opens Coast terrain page)CityStateTypewithcivilopediaText/ non-StartBias unique — both show on a CS of that type