Package com.unciv.ui.utils

Types

AskNumberPopup
Link copied to clipboard
class AskNumberPopup(screen: BaseScreen, label: String, icon: IconCircleGroup, defaultText: String, amountButtons: List<Int>, bounds: IntRange, errorText: String, validate: (input: Int) -> Boolean, actionOnOk: (input: Int) -> Unit) : Popup

Simple class for showing a prompt for a positive integer to the user

AskTextPopup
Link copied to clipboard
class AskTextPopup(screen: BaseScreen, label: String, icon: IconCircleGroup, defaultText: String, errorText: String, maxLength: Int, validate: (input: String) -> Boolean, actionOnOk: (input: String) -> Unit) : Popup

Simple class for showing a prompt for a string to the user

AutoScrollPane
Link copied to clipboard
open class AutoScrollPane(widget: Actor?, style: ScrollPane.ScrollPaneStyle) : ScrollPane
BaseScreen
Link copied to clipboard
open class BaseScreen : Screen
CrashController
Link copied to clipboard
interface CrashController
CrashReportSender
Link copied to clipboard
interface CrashReportSender
ExitGamePopup
Link copied to clipboard
class ExitGamePopup(screen: BaseScreen, force: Boolean) : YesNoPopup

Shortcut to open a YesNoPopup with the exit game question

ExpanderTab
Link copied to clipboard
class ExpanderTab(title: String, fontSize: Int, icon: Actor?, startsOutOpened: Boolean, defaultPad: Float, headerPad: Float, expanderWidth: Float, persistenceID: String?, onChange: () -> Unit?, initContent: (Table) -> Unit?) : Table

A widget with a header that when clicked shows/hides a sub-Table.

Fonts
Link copied to clipboard
object Fonts
IconCircleGroup
Link copied to clipboard
class IconCircleGroup(size: Float, actor: Actor, resizeActor: Boolean, color: Color) : Group
ImageGetter
Link copied to clipboard
object ImageGetter
KeyCharAndCode
Link copied to clipboard
data class KeyCharAndCode(char: Char, code: Int)

Represents a key for use in an InputListener keyTyped() handler

KeyPressDispatcher
Link copied to clipboard
class KeyPressDispatcher(name: String?) : HashMap<KeyCharAndCode, () -> Unit>

A manager for a keyTypedInputListener, based on HashMap. Uses KeyCharAndCode as keys to express bindings for both Ascii and function keys.

LanguageTable
Link copied to clipboard
internal class LanguageTable(language: String, percentComplete: Int) : Table

Represents a row in the Language picker, used both in OptionsPopup and in LanguagePickerScreen

LimitOrientationsHelper
Link copied to clipboard
interface LimitOrientationsHelper

Interface to support managing orientations

MayaCalendar
Link copied to clipboard
object MayaCalendar
NativeBitmapFontData
Link copied to clipboard
class NativeBitmapFontData(fontImplementation: NativeFontImplementation) : BitmapFont.BitmapFontData, Disposable
NativeFontImplementation
Link copied to clipboard
interface NativeFontImplementation
Popup
Link copied to clipboard
open class Popup(screen: BaseScreen) : Table

Base class for all Popups, i.e. Tables that get rendered in the middle of a screen and on top of everything else

Sounds
Link copied to clipboard
object Sounds

Generates Gdx Sound objects from UncivSound ones on demand, only once per key (two UncivSound custom instances with the same filename are considered equal).

TabbedPager
Link copied to clipboard
class TabbedPager(minimumWidth: Float, maximumWidth: Float, minimumHeight: Float, maximumHeight: Float, headerFontSize: Int, headerFontColor: Color, highlightColor: Color, backgroundColor: Color, headerPadding: Float, capacity: Int) : Table

Implements a 'Tabs' widget where different pages can be switched by selecting a header button.

ToastPopup
Link copied to clipboard
class ToastPopup(message: String, screen: BaseScreen, time: Long) : Popup

This is an unobtrusive popup which will close itself after a given amount of time. Default time is two seconds (in milliseconds)

UncivDateFormat
Link copied to clipboard
object UncivDateFormat

Standardize date formatting so dates are presented in a consistent style and all decisions to change date handling are encapsulated here

UncivSlider
Link copied to clipboard
class UncivSlider(min: Float, max: Float, step: Float, vertical: Boolean, plusMinus: Boolean, initial: Float, sound: UncivSound, getTipText: (Float) -> String?, onChange: (Float) -> Unit?) : Table

Modified Gdx Slider

UncivTooltip
Link copied to clipboard
class UncivTooltip<T : Actor>(target: Group, content: T, targetAlign: Int, tipAlign: Int, offset: Vector2, animate: Boolean, forceContentSize: Vector2?) : InputListener

A Replacement for Gdx Tooltip, placement does not follow the mouse.

UnitGroup
Link copied to clipboard
class UnitGroup(unit: MapUnit, size: Float) : Group
WrappableLabel
Link copied to clipboard
class WrappableLabel(text: String, expectedWidth: Float, fontColor: Color, fontSize: Int) : Label

A Label that unlike the original participates correctly in layout Caveat: You still need to turn wrap on after instantiation, doing it here in init leads to hell.

YesNoPopup
Link copied to clipboard
open class YesNoPopup(question: String, action: () -> Unit, screen: BaseScreen, restoreDefault: () -> Unit) : Popup

Variant of Popup pre-populated with one label, plus yes and no buttons

ZoomableScrollPane
Link copied to clipboard
open class ZoomableScrollPane : ScrollPane

Functions

addBorder
Link copied to clipboard
fun Actor.addBorder(size: Float, color: Color, expandCell: Boolean = false): Table
addCell
Link copied to clipboard
fun <T : Actor> Table.addCell(actor: T): Table

Alternative to Table.add that returns the Table instead of the new Cell to allow a different way of chaining

addSeparator
Link copied to clipboard
fun Table.addSeparator(color: Color = Color.WHITE, colSpan: Int = 0, height: Float = 2f): Cell<Image>

Create a horizontal separator as an empty Container with a colored background.

addSeparatorVertical
Link copied to clipboard
fun Table.addSeparatorVertical(color: Color = Color.WHITE, width: Float = 2f): Cell<Image>

Create a vertical separator as an empty Container with a colored background.

center
Link copied to clipboard
fun Actor.center(parent: Actor)
fun Actor.center(parent: Stage)
centerX
Link copied to clipboard
fun Actor.centerX(parent: Actor)
fun Actor.centerX(parent: Stage)
centerY
Link copied to clipboard
fun Actor.centerY(parent: Actor)
fun Actor.centerY(parent: Stage)
clipIndexToBounds
Link copied to clipboard
fun <T> List<T>.clipIndexToBounds(index: Int, extendEnd: Int = 0): Int
closeAllPopups
Link copied to clipboard
fun BaseScreen.closeAllPopups()

Closes all Popups.

closeOneVisiblePopup
Link copied to clipboard
fun BaseScreen.closeOneVisiblePopup(): String?

Closes the topmost visible Popup.

colorFromRGB
Link copied to clipboard
fun colorFromRGB(rgb: List<Int>): Color
fun colorFromRGB(r: Int, g: Int, b: Int): Color
countOpenPopups
Link copied to clipboard
fun BaseScreen.countOpenPopups(): Int

Counts number of visiblePopups.

disable
Link copied to clipboard
fun Button.disable()

Disable a Button by setting its touchable and color properties.

enable
Link copied to clipboard
fun Button.enable()

Enable a Button by setting its touchable and color properties.

enforceValidIndex
Link copied to clipboard
fun <T> List<T>.enforceValidIndex(index: Int)

Make sure an index is valid for this List.

getSeparatorImage
Link copied to clipboard
private fun getSeparatorImage(color: Color): Image

get background Image for a new separator

hasOpenPopups
Link copied to clipboard
fun BaseScreen.hasOpenPopups(): Boolean

Checks if there are visible Popups.

onChange
Link copied to clipboard
fun Actor.onChange(function: () -> Unit): Actor
onClick
Link copied to clipboard
fun Actor.onClick(function: () -> Unit): Actor
fun Actor.onClick(sound: UncivSound = UncivSound.Click, function: () -> Unit)
onClickEvent
Link copied to clipboard
fun Actor.onClickEvent(sound: UncivSound = UncivSound.Click, function: (event: InputEvent?, x: Float, y: Float) -> Unit)

same as onClick, but sends the InputEvent and coordinates along

packIfNeeded
Link copied to clipboard
fun WidgetGroup.packIfNeeded(): WidgetGroup

pack a WidgetGroup if its needsLayout is true.

pad
Link copied to clipboard
fun <T : Actor> Cell<T>.pad(vertical: Float, horizontal: Float): Cell<T>

Shortcut for Cell.pad with top=bottom and left=right

randomWeighted
Link copied to clipboard
fun <T> List<T>.randomWeighted(weights: List<Float>, random: Random = Random): T

Get one random element of a given List.

setFontColor
Link copied to clipboard
fun Label.setFontColor(color: Color): Label

Sets the font color on a Label and returns it to allow chaining

setFontSize
Link copied to clipboard
fun Label.setFontSize(size: Int): Label

Sets the font size on a Label and returns it to allow chaining

stringifyException
Link copied to clipboard
fun Throwable.stringifyException(): String
surroundWithCircle
Link copied to clipboard
fun Actor.surroundWithCircle(size: Float, resizeActor: Boolean = true, color: Color = Color.WHITE): IconCircleGroup
toCheckBox
Link copied to clipboard
fun String.toCheckBox(startsOutChecked: Boolean = false, changeAction: (Boolean) -> Unit? = null): CheckBox

Translate a String and make a CheckBox widget from it.

toLabel
Link copied to clipboard
fun Int.toLabel(): Label

Make a Label widget containing this Int as text

fun String.toLabel(): Label

Translate a String and make a Label widget from it

fun String.toLabel(fontColor: Color = Color.WHITE, fontSize: Int = 18): Label

Translate a String and make a Label widget from it with a specified font color and size

toPercent
Link copied to clipboard
fun Float.toPercent(): Float
fun Int.toPercent(): Float
fun String.toPercent(): Float

Translate a percentage number - e.g. 25 - to the multiplication value - e.g. 1.25f

toPixmap
Link copied to clipboard
fun TextureRegion.toPixmap(): Pixmap

Turn a TextureRegion into a Pixmap.

toTextButton
Link copied to clipboard
fun String.toTextButton(): TextButton

Translate a String and make a TextButton widget from it

withItem
Link copied to clipboard
fun <T> ArrayList<T>.withItem(item: T): ArrayList<T>

Gets a clone of an ArrayList with an additional item

fun <T> HashSet<T>.withItem(item: T): HashSet<T>

Gets a clone of a HashSet with an additional item

withoutItem
Link copied to clipboard
fun <T> ArrayList<T>.withoutItem(item: T): ArrayList<T>

Gets a clone of an ArrayList without a given item

fun <T> HashSet<T>.withoutItem(item: T): HashSet<T>

Gets a clone of a HashSet without a given item

Properties

isEnabled
Link copied to clipboard
var Button.isEnabled: Boolean

Enable or disable a Button by setting its touchable and color properties, or returns the corresponding state.

popups
Link copied to clipboard
val BaseScreen.popups: List<Popup>