Skip to content

town_react_util

Source: base/tealdef/game_mechanics/towns/town_react_util.d.tl

Notes

React recipes and label helpers for the town window and town rating icons.

TownReactUtil

record global base/tealdef/game_mechanics/towns/town_react_util.d.tl:3

global record TownReactUtil

Load: local town_react_util = ug_require "/game_mechanics/towns/town_react_util.tl"

Notes

React recipes and label helpers for the town window (game_mechanics/towns/town_react_util.tl).

Fields

Name Type Description
RatingBar Recipe<RatingBarParams> Recipe of a segmented rating bar with an optional icon and rating level label. used 2× in the base game
TownRatingIconWithText Recipe<TownRatingIconWithTextParams> Recipe of a town window tab button with the rating icon, coloured by the current rating level. used 2× in the base game
TownPopulationWidget Recipe<TownDetailsParam> Recipe of the expandable part of the town level card. It shows the experience needed for the next level, the next level's name, the supplies state and the growth rate. used 1× in the base game
TownRatingIcon Recipe<TownRatingIconParams> Recipe of a rating icon coloured by the town's current level of that rating. The level comes from rating.getRatingFnName through useStepStateParallelSimple. used 1× in the base game

Functions

getRatingClass(RatingLevel) : string base/tealdef/game_mechanics/towns/town_react_util.d.tl:4

Call as town_react_util.getRatingClass

Notes

CSS class of a rating level, town-growth-rank-1 for VeryPoor up to town-growth-rank-6 for Excellent.

Parameter Type Description
#1 RatingLevel Rating level.

Returns string: CSS class name.

Used in the base game: 1 time in 1 file

base/content/gui/gui/entity_window/town/town_eow.script.tl:100

class = "font-scale-headline, growth-state," .. town_react_util.getRatingClass(stepState:old().growthLevel),

getStringForTownAuthorityEventFactors(TownAuthorityEventFactors.EventType) : string base/tealdef/game_mechanics/towns/town_react_util.d.tl:5

Call as town_react_util.getStringForTownAuthorityEventFactors

Notes

Localized label of a penalty reason, such as "Removed Trees".

Parameter Type Description
#1 TownAuthorityEventFactors.EventType Penalty reason.

Returns string: Label, or nil for Unknown.

getAdviceForTownAuthorityEventFactors(TownAuthorityEventFactors.EventType, integer) : string base/tealdef/game_mechanics/towns/town_react_util.d.tl:6

Call as town_react_util.getAdviceForTownAuthorityEventFactors

Notes

Localized advice to recover from a penalty, for trees, rocks and severed connections.

Parameter Type Description
#1 TownAuthorityEventFactors.EventType Penalty reason.
#2 integer Number of severed main connections; the severed connection advice needs more than 0.

Returns string: Advice text, or nil for other reasons.

getEditorSupplyDetails() : Recipe<TownReactUtil.TownDetailsParam> base/tealdef/game_mechanics/towns/town_react_util.d.tl:36

Call as town_react_util.getEditorSupplyDetails

Notes

Recipe of the supplies card in the map editor's town window.

Returns Recipe<TownReactUtil.TownDetailsParam>: Recipe taking TownDetailsParam.

Used in the base game: 1 time in 1 file

base/content/gui/gui/entity_window/town/town_eow.script.tl:455

town_react_util.getEditorSupplyDetails(),

GetRatingsDashboard() : {TownInfoTabType : {TownUtil.Rating, Recipe<TownDetailsParam>, string}} base/tealdef/game_mechanics/towns/town_react_util.d.tl:37

Call as town_react_util.GetRatingsDashboard

Notes

Content of the rating tabs of the town window. Each entry has the rating, the recipe of its detail widget and a hint text. Overview has no entry.

Returns {TownInfoTabType : {TownUtil.Rating, Recipe<TownDetailsParam>, string}}: Rating, detail recipe and hint per tab.

Used in the base game: 3 times in 1 file

base/content/gui/gui/entity_window/town/town.tl:672

local ratings = town_react_util.GetRatingsDashboard()

getGrowthLevelText(growthLevel : RatingLevel) : string base/tealdef/game_mechanics/towns/town_react_util.d.tl:49

Call as town_react_util.getGrowthLevelText

Notes

Localized growth text of a growth level, from "Stagnant" (VeryPoor) to "Growing Lightning Fast" (Excellent).

Parameter Type Description
growthLevel RatingLevel Growth level.

Returns string: Localized text.

Used in the base game: 1 time in 1 file

base/content/gui/gui/entity_window/town/town_eow.script.tl:102

text = town_react_util.getGrowthLevelText(stepState:old().growthLevel),

TownReactUtil.TownInfoTabType

enum base/tealdef/game_mechanics/towns/town_react_util.d.tl:8

enum TownInfoTabType

Notes

Tabs of the town window.

Used in the base game: 13 times in 3 files

base/content/gui/gui/entity_window/entity_window_hud.tl:591

entity_window_hud.getTownHudIconPreFilter = function(currentTab : TownReactUtil.TownInfoTabType) : {Engine.ComponentType}
base/content/gui/gui/entity_window/town/town.tl:35
setActiveTab : function(tabType : TownReactUtil.TownInfoTabType)
base/content/gui/gui/entity_window/town/town_eow.script.tl:194
local tabType2title : {TownReactUtil.TownInfoTabType : string} = {

Value Description
"Overview" Overview tab, titled "District Sizes".
"Reputation" Reputation tab.
"Bonuses" Bonuses tab (landmark bonuses).
"Supplies" Supplies tab.
"Traffic" Traffic tab.
"Happiness" Happiness tab.
"Delivery" Delivery time tab.
"Noise" Noise tab.
"Pollution" Pollution tab.

TownReactUtil.RatingBarParams

record base/tealdef/game_mechanics/towns/town_react_util.d.tl:20

record RatingBarParams

Notes

Params of RatingBar.

Used in the base game: 1 time in 1 file

base/content/game_mechanics/game_mechanics/towns/town_react_util.tl:83

town_react_util.RatingBar = react.RegisterRecipe("RatingBar", function(params : TownReactUtil.RatingBarParams) : TreeNodeId

Fields

Name Type Description
icon string Icon path shown when showIcon is true.
tooltip string Tooltip of the icon.
barTooltip string Tooltip of the bar.
value number Rating value between 0 and 1.
maxValue number
numFractions integer Number of bar segments; the base game uses 5.
hideText boolean Hides the rating level label next to the bar.
showIcon boolean Shows icon before the bar.

Functions

onClick() base/tealdef/game_mechanics/towns/town_react_util.d.tl:27

Notes

Called when the bar is clicked; when set, the bar is wrapped in a button.

TownReactUtil.TownDetailsParam

record base/tealdef/game_mechanics/towns/town_react_util.d.tl:32

record TownDetailsParam

Notes

Params of the town window detail widgets.

Used in the base game: 2 times in 1 file

base/content/game_mechanics/game_mechanics/towns/town_react_util.tl:2146

town_react_util.getEditorSupplyDetails = function() : Recipe<TownReactUtil.TownDetailsParam>

Fields

Name Type Description
entity Engine.Entity Town entity.

Functions

setLinesExpandedState(ratingKey : string, value : boolean) base/tealdef/game_mechanics/towns/town_react_util.d.tl:34

Notes

Reports whether the line list of a tab is expanded; the noise and pollution widgets call it.

Parameter Type Description
ratingKey string Tab key, "Noise" or "Pollution".
value boolean True when the list is expanded.

TownReactUtil.TownRatingIconWithTextParams

record base/tealdef/game_mechanics/towns/town_react_util.d.tl:39

record TownRatingIconWithTextParams

Notes

Params of TownRatingIconWithText.

Used in the base game: 1 time in 1 file

base/content/game_mechanics/game_mechanics/towns/town_react_util.tl:2225

town_react_util.TownRatingIconWithText = react.RegisterRecipe("TownRatingIconWithText", function(params : TownReactUtil.TownRatingIconWithTextParams) : TreeNode

Fields

Name Type Description
entity Engine.Entity Town entity.
rating TownUtil.Rating Rating to show.
text string Headline text next to the icon.
tooltip string Tooltip of the icon.
wideIcon boolean Uses the wide layout with a large TownRatingIcon.
activeTab boolean Marks the button as the active tab.

TownReactUtil.TownRatingIconParams

record base/tealdef/game_mechanics/towns/town_react_util.d.tl:53

record TownRatingIconParams

Notes

Params of TownRatingIcon.

Used in the base game: 1 time in 1 file

base/content/game_mechanics/game_mechanics/towns/town_react_util.tl:2208

town_react_util.TownRatingIcon = react.RegisterRecipe("TownRatingIcon", function(params : TownReactUtil.TownRatingIconParams) : TreeNodeId

Fields

Name Type Description
entity Engine.Entity Town entity.
rating TownUtil.Rating Rating to show.
tooltip string Tooltip of the icon.
iconSize IconSize Icon size.

TownReactUtil.TownRatingIconParams.IconSize

enum base/tealdef/game_mechanics/towns/town_react_util.d.tl:54

enum IconSize

Notes

Icon size of TownRatingIcon.

Value Description
"Default" Uses rating.icon.
"Large" Uses rating.iconLarge.