FormattedLine

class FormattedLine(text: String, link: String, icon: String, extraImage: String, imageSize: Float, size: Int, header: Int, indent: Int, padding: Float, color: String, separator: Boolean, starred: Boolean, centered: Boolean, iconCrossed: Boolean)

Represents a decorated text line with optional linking capability. A line can have text with optional size, color, indent or as header; and up to three icons: link, object, star in that order. Special cases:

  • Standalone image from atlas or from ExtraImages

  • A separator line (separator)

  • Automatic external links (no text but link begins with a URL protocol)

Constructors

FormattedLine
Link copied to clipboard
fun FormattedLine(unique: Unique, indent: Int = 0)

Looks for linkable ruleset objects in Unique parameters and returns a linked FormattedLine if successful, a plain one otherwise

FormattedLine
Link copied to clipboard
fun FormattedLine(text: String = "", link: String = "", icon: String = "", extraImage: String = "", imageSize: Float = Float.NaN, size: Int = Int.MIN_VALUE, header: Int = 0, indent: Int = 0, padding: Float = Float.NaN, color: String = "", separator: Boolean = false, starred: Boolean = false, centered: Boolean = false, iconCrossed: Boolean = false)

Types

Companion
Link copied to clipboard
object Companion

Constants used by FormattedLine

IconDisplay
Link copied to clipboard
enum IconDisplay : Enum<FormattedLine.IconDisplay>

Used only as parameter to FormattedLine.render and MarkupRenderer.render

LinkType
Link copied to clipboard
enum LinkType : Enum<FormattedLine.LinkType>

Link types that can be used for FormattedLine.link

Functions

equals
Link copied to clipboard
open operator fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
open fun hashCode(): Int
hasProtocol
Link copied to clipboard
private fun String.hasProtocol(): Boolean

Extension: determines if a String looks like a link understood by the OS

isEmpty
Link copied to clipboard
fun isEmpty(): Boolean

Returns true if this formatted line will not display anything

isHex
Link copied to clipboard
private fun String.isHex(start: Int, length: Int): Boolean

Extension: determines if a section of a String is composed entirely of hex digits

parseColor
Link copied to clipboard
private fun parseColor(): Color

Parse a json-supplied color string to Color, defaults to defaultColor.

render
Link copied to clipboard
fun render(labelWidth: Float, iconDisplay: FormattedLine.IconDisplay = IconDisplay.All): Actor

Renders the formatted line as a scene2d Actor (currently always a Table)

renderIcon
Link copied to clipboard
private fun renderIcon(table: Table, iconToDisplay: String, iconSize: Float): Int

Place a RuleSet object icon.

toString
Link copied to clipboard
open override fun toString(): String
unsupportedReason
Link copied to clipboard
fun unsupportedReason(): String?

Self-check to potentially support the mod checker

Properties

align
Link copied to clipboard
val align: Int

Translates centered into libGdxAlign value

centered
Link copied to clipboard
val centered: Boolean = false

Centers the line (and turns off wrap)

color
Link copied to clipboard
val color: String

Sets text color, accepts Java names or 6/3-digit web colors (e.g. #FFA040).

displayColor
Link copied to clipboard
val displayColor: Color

Retrieves the parsed Color corresponding to the color property (String)

extraImage
Link copied to clipboard
val extraImage: String

Display an Image instead of text, sized. Can be a path as understood by ImageGetter.getImage or the name of a png or jpg in ExtraImages.

header
Link copied to clipboard
val header: Int = 0

Header level. 1 means double text size and decreases from there.

icon
Link copied to clipboard
val icon: String

Display an Unciv object's icon inline but do not link (format category/entryname).

iconCrossed
Link copied to clipboard
val iconCrossed: Boolean = false

Paint a red X over the icon or link image

iconToDisplay
Link copied to clipboard
private val iconToDisplay: String
imageSize
Link copied to clipboard
val imageSize: Float

Width of the extraImage, height is calculated preserving aspect ratio. Defaults to available width.

indent
Link copied to clipboard
val indent: Int = 0

Indentation: 0 = text will follow icons with a little padding, 1 = aligned to a little more than 3 icons, each step above that adds 30f.

link
Link copied to clipboard
val link: String

Create link: Line gets a 'Link' icon and is linked to either an Unciv object (format category/entryname) or an external URL.

linkType
Link copied to clipboard
val linkType: FormattedLine.LinkType

The type of the link's destination

padding
Link copied to clipboard
val padding: Float

Defines vertical padding between rows, defaults to 5f.

separator
Link copied to clipboard
val separator: Boolean = false

Renders a separator line instead of text. Can be combined only with color and size (line width, default 2)

size
Link copied to clipboard
val size: Int

Text size, defaults to 18. Use size or header but not both.

starred
Link copied to clipboard
val starred: Boolean = false

Decorates text with a star icon - if set, it receives the color instead of the text.

text
Link copied to clipboard
val text: String

Text to display.

textToDisplay
Link copied to clipboard
private val textToDisplay: String

Sources

jvm source
Link copied to clipboard