Skip to content

gui_react_util

Source: base/tealdef/gui/main/gui_react_util.d.tl

Notes

General React helpers of the game UI: icon/label indicators (the icon with a number used in HUD icons and entity windows), small layout shortcuts, colour contrast helpers, focus and input-action wrappers, the emote icon, and usePlugins for rendering the plugins of an extension point. Load it with ug_require "/gui/main/gui_react_util.tl".

GuiReactUtil

record global base/tealdef/gui/main/gui_react_util.d.tl:3

global record GuiReactUtil

Load: local gui_react_util = ug_require "/gui/main/gui_react_util.tl"

Notes

General React helpers (indicators, layout shortcuts, focus scopes, plugin rendering).

Fields

Name Type Description
IconLabelIndicator Recipe<IconLabelIndicatorParams> Recipe version of makeContentLabelIndictator. Shows an icon with a label, an optional indicator icon and an optional overlay. used 40× in the base game
FocusNumberInputField Recipe<FocusInputFieldParam<number>> deprecated, use DoubleSpinBox instead used 1× in the base game
FocusTextInputField Recipe<FocusInputFieldParam<string>> deprecated, use TextInputField with "displayOnly" instead used 4× in the base game
FocusTraversalScope Recipe<FocusTraversalScopeParam> Returns layout and registers the navigation input actions (IA_NAV_LEFT, IA_NAV_RIGHT, IA_NAV_UP, IA_NAV_DOWN) for it as focus traversal. used 8× in the base game
InputActionComponent Recipe<InputActionComponentParam> Returns layout and registers the given input action handlers or forwards for it with react.useInputAction. used 1× in the base game
EmoteIcon Recipe<EmoteIconParam> Shows a happy or unhappy face icon, e.g. for passenger happiness or cargo quality. used 6× in the base game
Clipper Recipe<ClipperParam> Returns layout with content clipping switched on (react.setClipContent(true)). used 6× in the base game

Functions

getMouseCursorInteger(mouseCursor : GuiReactUtil.MouseCursor) : integer base/tealdef/gui/main/gui_react_util.d.tl:64

Call as gui_react_util.getMouseCursorInteger

Notes

Converts a MouseCursor name to the integer cursor id.

Parameter Type Description
mouseCursor GuiReactUtil.MouseCursor Cursor name. nil returns 0 (Default).

Returns integer: Integer cursor id, e.g. for mouseCursorOverride of a component.

Example

-- from manager_hud_util.tl
mouseCursorOverride = gui_react_util.getMouseCursorInteger("Default"),
Used in the base game: 42 times in 6 files

base/content/gui/gui/line_vehicle_mgmt/manager_window.tl:254

ctx.setMouseCursor(gui_react_util.getMouseCursorInteger("Default"))
base/content/gui/gui/line_vehicle_mgmt/manager_hud_util.tl:60
mouseCursorOverride = gui_react_util.getMouseCursorInteger("Default"),
base/content/gui/gui/construction/construction_react_util.tl:1484
mouseCursor = gui_react_util.getMouseCursorInteger("Prospection"),
base/content/gui/gui/main/game.tl:422
mouseCursorOverride = gui_react_util.getMouseCursorInteger("Default"),
base/content/gui/gui/construction/tools/marketing_campaign_tool.script.tl:54
mouseCursor = gui_react_util.getMouseCursorInteger("CompanyMechanics"),
base/content/gui/gui/construction/tools/industry_greenify_tool.script.tl:46
mouseCursor = gui_react_util.getMouseCursorInteger("CompanyMechanics"),

isHudLabelMode(labelMode : LabelMode) : boolean base/tealdef/gui/main/gui_react_util.d.tl:115

Call as gui_react_util.isHudLabelMode

Notes

Tells whether a label mode is one of the HUD modes.

Returns boolean: true for HudIconMain and HudIconLayer, otherwise false.

Used in the base game: 1 time in 1 file

base/content/gui/gui/main/cargo_react_util.tl:307

getTendency = params.showTendency and not gui_react_util.isHudLabelMode(params.mode),

makeContentLabelIndictator(params : IconLabelIndicatorParams) : TreeNodeId base/tealdef/gui/main/gui_react_util.d.tl:119

Call as gui_react_util.makeContentLabelIndictator

Notes

Builds an icon/label indicator node, the icon with a number used in HUD icons, cargo lists and entity windows.

Returns TreeNodeId: The indicator node.

Details

The icon is an EmoteIcon if useEmoteWithSatisfaction is set, otherwise one or more image views from iconPath. The name is spelled Indictator in the game files.

Example

-- from hud_icon_toolbox.tl
gui_react_util.makeContentLabelIndictator{
    iconPath = cargo_util.getPassengerCargoIcon(),
    label = lang_util.formatInt(happiness.totalWaiting),
    labelFontColor = fontColor,
    labelMode = "HudIconMain",
    shippingState = "WaitingPassenger",
}
Used in the base game: 5 times in 2 files

base/content/gui/gui/main/hud_icon_toolbox.tl:65

table.insert(subIcons, gui_react_util.makeContentLabelIndictator({
base/content/gui/gui/main/cargo_react_util.tl:243
children[#children + 1] = gui_react_util.makeContentLabelIndictator({

integer2TextLayout(value : integer, tag? : string) : TreeNodeId base/tealdef/gui/main/gui_react_util.d.tl:121

Call as gui_react_util.integer2TextLayout

Notes

Builds a horizontal box with one text view showing value formatted with lang_util.formatInt.

Parameter Type Description
value integer Number to show.
tag? string Value for the text view's meta.tag.

Returns TreeNodeId: The layout node. The text view is focusable (forceFocusable = true) and uses font-scale-body.

Used in the base game: 4 times in 3 files

base/content/gui/gui/line_vehicle_mgmt/manager_window.tl:3998

gui_react_util.integer2TextLayout(rateState:old(), "menu.statistics.line.rateCell"),
base/content/gui/gui/statistics/statistic_lines.tl:229
return gui_react_util.integer2TextLayout(rateState:old(), "menu.statistics.line.rateCell" )
base/content/gui/gui/statistics/statistic_towns.tl:89
return gui_react_util.integer2TextLayout(publicTransportState:old())

group(TreeNodeId) : TreeNodeId base/tealdef/gui/main/gui_react_util.d.tl:133

Call as gui_react_util.group

Notes

Wraps one node in a horizontal builtin.BoxLayout.

Returns TreeNodeId: The box layout node.

textColorForColor(color : Vec4f) : Vec4f base/tealdef/gui/main/gui_react_util.d.tl:134

Call as gui_react_util.textColorForColor

Notes

Returns a text colour with enough contrast on the given background colour.

Returns Vec4f: The darkest neutral colour of default_colors.gres for bright colours (average of RGB above 0.5), otherwise the lightest neutral colour.

Used in the base game: 4 times in 2 files

base/content/gui/gui/line_vehicle_mgmt/line_manager_panel.tl:350

color = gui_react_util.textColorForColor(api.type.Vec4f.new(bubbleColor, 1.0)),
base/content/gui/gui/main/cargo_react_util.tl:757
color = gui_react_util.textColorForColor(color)

foregroundColorClassForColor(color : Vec4f) : GuiReactUtil.ForegroundContrast base/tealdef/gui/main/gui_react_util.d.tl:135

Call as gui_react_util.foregroundColorClassForColor

Notes

Tells whether dark or light foreground fits on the given colour.

Returns GuiReactUtil.ForegroundContrast: Dark if the average of RGB is above 0.5, otherwise Light.

Details

The line manager maps the result to its own style classes for text on line colours.

Used in the base game: 8 times in 1 file

base/content/gui/gui/line_vehicle_mgmt/manager_hud_util.tl:91

.. contrast2FGClass[gui_react_util.foregroundColorClassForColor(lineColor)]

stylingHoverClassForColor(color : Vec4f) : GuiReactUtil.ForegroundContrast base/tealdef/gui/main/gui_react_util.d.tl:136

Call as gui_react_util.stylingHoverClassForColor

Notes

Same check as foregroundColorClassForColor, meant for choosing hover style classes.

Returns GuiReactUtil.ForegroundContrast: Dark if the average of RGB is above 0.5, otherwise Light.

Used in the base game: 4 times in 1 file

base/content/gui/gui/line_vehicle_mgmt/manager_hud_util.tl:92

.. ", " .. contrast2HoverClass[gui_react_util.stylingHoverClassForColor(lineColor)],

makeHorizontalSpacer() : TreeNodeId base/tealdef/gui/main/gui_react_util.d.tl:137

Call as gui_react_util.makeHorizontalSpacer

Notes

Builds an empty component with style class horizontal-spacer.

Returns TreeNodeId

Used in the base game: 121 times in 33 files

base/content/mission/mission/mission_framework/mission_end_window_util.tl:372

gui_react_util.makeHorizontalSpacer(),
base/content/mission/mission/mission_framework/mission_framework_react.tl:353
gui_react_util.makeHorizontalSpacer(),
base/content/gui/gui/map_editor/map_editor.tl:1430
gui_react_util.makeHorizontalSpacer(),
base/content/gui/gui/line_vehicle_mgmt/vehicle_store_window.tl:990
table.insert(vehicleIcons, gui_react_util.makeHorizontalSpacer())
base/content/gui/gui/line_vehicle_mgmt/line_manager_panel.tl:361
gui_react_util.makeHorizontalSpacer(),
base/content/gui/gui/line_vehicle_mgmt/manager_window.tl:2881
gui_react_util.makeHorizontalSpacer(),
… and 27 more files.

makeVerticalSpacer() : TreeNodeId base/tealdef/gui/main/gui_react_util.d.tl:138

Call as gui_react_util.makeVerticalSpacer

Notes

Builds an empty component with style class vertical-spacer.

Returns TreeNodeId

Used in the base game: 38 times in 16 files

base/content/mission/mission/mission_framework/mission_framework_react.tl:313

detailsChildren[#detailsChildren + 1] = gui_react_util.makeVerticalSpacer()
base/content/gui/gui/music_player/music_player.tl:213
} or gui_react_util.makeVerticalSpacer(),
base/content/gui/gui/map_editor/map_editor.tl:821
gui_react_util.makeVerticalSpacer(),
base/content/gui/gui/line_vehicle_mgmt/manager_window.tl:3442
gui_react_util.makeVerticalSpacer(),
base/content/gui/gui/menu/mod_manager_react_util.tl:1644
gui_react_util.makeVerticalSpacer(),
base/content/gui/gui/menu/mission_page_content.tl:122
gui_react_util.makeVerticalSpacer(),
… and 10 more files.

makeHorizontalBox({TreeNodeId}) : TreeNodeId base/tealdef/gui/main/gui_react_util.d.tl:139

Call as gui_react_util.makeHorizontalBox

Notes

Builds a horizontal builtin.BoxLayout with the given children.

Returns TreeNodeId

Used in the base game: 73 times in 8 files

base/content/gui/gui/line_vehicle_mgmt/cargofilter_window.tl:203

return gui_react_util.makeHorizontalBox({
base/content/gui/gui/menu/mod_manager_react_util.tl:629
content = gui_react_util.makeHorizontalBox{
base/content/gui/gui/menu/savegame_react_util.tl:366
content = gui_react_util.makeHorizontalBox{
base/content/gui/gui/menu/mod_selector_page.tl:290
gui_react_util.makeHorizontalBox {
base/content/gui/gui/menu/main_page.tl:28
return gui_react_util.makeHorizontalBox({
base/content/gui/gui/menu/paradox_react_util.tl:213
return gui_react_util.makeHorizontalBox{
… and 2 more files.

makeVerticalBox({TreeNodeId}) : TreeNodeId base/tealdef/gui/main/gui_react_util.d.tl:140

Call as gui_react_util.makeVerticalBox

Notes

Builds a vertical builtin.BoxLayout with the given children.

Returns TreeNodeId

Used in the base game: 37 times in 7 files

base/content/gui/gui/menu/mod_manager_react_util.tl:607

return gui_react_util.makeVerticalBox{
base/content/gui/gui/menu/load_game_page.tl:196
layout = gui_react_util.makeVerticalBox{
base/content/gui/gui/menu/save_game_page.tl:282
layout = gui_react_util.makeVerticalBox{
base/content/gui/gui/menu/new_game_page.tl:206
layout = gui_react_util.makeVerticalBox{
base/content/gui/gui/menu/paradox_react_util.tl:259
return gui_react_util.makeVerticalBox{
base/content/gui/gui/construction/construction.tl:3273
layout = gui_react_util.makeVerticalBox(children)
… and 1 more files.

transformSetUnlessEqual<T>(state : ReactStateT<T>, newValue : T, equals? : (function(T, T) : boolean)) base/tealdef/gui/main/gui_react_util.d.tl:146

Call as gui_react_util.transformSetUnlessEqual

shortcut to state:transform() with an equals call for early-out

Parameter Type Description
state ReactStateT<T> The react state
newValue T The desired value
equals? (function(T, T) : boolean) Optional comparison function (defaults to table_util.deepEquals

usePlugins<ParamType>(ExtensionPoint<ParamType>, detail? : PluginScopeConfig, recipeParam : ParamType) : {TreeNodeId} base/tealdef/gui/main/gui_react_util.d.tl:196

Call as gui_react_util.usePlugins

Notes

Builds the nodes of all plugins registered for an extension point, in their order.

Parameter Type Description
#1 ExtensionPoint<ParamType> The extension point (registered with react.RegisterExtensionPoint...).
detail? PluginScopeConfig Optional refs to the first and last plugin, and fixed nodes to insert.
recipeParam ParamType Parameters passed to every plugin recipe.

Returns {TreeNodeId}: List of plugin nodes, possibly empty.

Details

Call it inside a recipe and place the returned nodes in a layout. Plugins with a condition function are only built when the condition returns true for the recipe parameters. Each plugin recipe is called with recipeParam (for extension points with parameters). With detail.insertHardcoded, fixed nodes of the host recipe are sorted in between the plugins by their order value.

Example

-- from station_group.tl
local pluginWidgets = gui_react_util.usePlugins(station_group_eow.StationGroupEowExtensionPoint, nil, extensionParams)
Used in the base game: 18 times in 17 files

base/content/gui/gui/game_bar/game_bar.tl:54

local radialMenuPlugins = gui_react_util.usePlugins(radial_menu_extension.RadialMenuExtension)
base/content/gui/gui/game_bar/game_bar_widgets.tl:72
local children : {TreeNodeId} = gui_react_util.usePlugins(game_bar_widgets.GameBarInfoDisplayExtension)
base/content/gui/gui/main/main_mod_button_area.tl:13
local children = gui_react_util.usePlugins(main_mod_button_area.MainModButtonAreaExtension)
base/content/gui/gui/main/game.tl:83
local pluginInstances = gui_react_util.usePlugins(mod_entry_point.ModEntryPointExtension)
base/content/gui/gui/entity_window/station_group/station_group.tl:864
local pluginWidgets = gui_react_util.usePlugins(station_group_eow.StationGroupEowExtensionPoint, nil, extensionParams)
base/content/gui/gui/entity_window/maintenance_station/maintenance_station.tl:76
local pluginWidgets = gui_react_util.usePlugins(maintenance_station_eow.MaintenanceStationEowExtensionPoint, {lastRef = lastInScrollAreaRef}, extensionParams)
… and 11 more files.

usePlugins<WrappedRecipe, ParamType>(WrapperExtensionPoint<WrappedRecipe, ParamType>, detail? : PluginScopeConfig, recipeParam : ParamType) : {TreeNodeId} base/tealdef/gui/main/gui_react_util.d.tl:197

Call as gui_react_util.usePlugins

Notes

Builds the nodes of all plugins registered for an extension point, in their order.

Parameter Type Description
#1 WrapperExtensionPoint<WrappedRecipe, ParamType> The extension point (registered with react.RegisterExtensionPoint...).
detail? PluginScopeConfig Optional refs to the first and last plugin, and fixed nodes to insert.
recipeParam ParamType Parameters passed to every plugin recipe.

Returns {TreeNodeId}: List of plugin nodes, possibly empty.

Details

Call it inside a recipe and place the returned nodes in a layout. Plugins with a condition function are only built when the condition returns true for the recipe parameters. Each plugin recipe is called with recipeParam (for extension points with parameters). With detail.insertHardcoded, fixed nodes of the host recipe are sorted in between the plugins by their order value.

Example

-- from station_group.tl
local pluginWidgets = gui_react_util.usePlugins(station_group_eow.StationGroupEowExtensionPoint, nil, extensionParams)
Used in the base game: 18 times in 17 files

base/content/gui/gui/game_bar/game_bar.tl:54

local radialMenuPlugins = gui_react_util.usePlugins(radial_menu_extension.RadialMenuExtension)
base/content/gui/gui/game_bar/game_bar_widgets.tl:72
local children : {TreeNodeId} = gui_react_util.usePlugins(game_bar_widgets.GameBarInfoDisplayExtension)
base/content/gui/gui/main/main_mod_button_area.tl:13
local children = gui_react_util.usePlugins(main_mod_button_area.MainModButtonAreaExtension)
base/content/gui/gui/main/game.tl:83
local pluginInstances = gui_react_util.usePlugins(mod_entry_point.ModEntryPointExtension)
base/content/gui/gui/entity_window/station_group/station_group.tl:864
local pluginWidgets = gui_react_util.usePlugins(station_group_eow.StationGroupEowExtensionPoint, nil, extensionParams)
base/content/gui/gui/entity_window/maintenance_station/maintenance_station.tl:76
local pluginWidgets = gui_react_util.usePlugins(maintenance_station_eow.MaintenanceStationEowExtensionPoint, {lastRef = lastInScrollAreaRef}, extensionParams)
… and 11 more files.

usePlugins(ExtensionPoint0, detail? : PluginScopeConfig) : {TreeNodeId} base/tealdef/gui/main/gui_react_util.d.tl:198

Call as gui_react_util.usePlugins

Notes

Builds the nodes of all plugins registered for an extension point, in their order.

Parameter Type Description
#1 ExtensionPoint0 The extension point (registered with react.RegisterExtensionPoint...).
detail? PluginScopeConfig Optional refs to the first and last plugin, and fixed nodes to insert.

Returns {TreeNodeId}: List of plugin nodes, possibly empty.

Details

Call it inside a recipe and place the returned nodes in a layout. Plugins with a condition function are only built when the condition returns true for the recipe parameters. Each plugin recipe is called with recipeParam (for extension points with parameters). With detail.insertHardcoded, fixed nodes of the host recipe are sorted in between the plugins by their order value.

Example

-- from station_group.tl
local pluginWidgets = gui_react_util.usePlugins(station_group_eow.StationGroupEowExtensionPoint, nil, extensionParams)
Used in the base game: 18 times in 17 files

base/content/gui/gui/game_bar/game_bar.tl:54

local radialMenuPlugins = gui_react_util.usePlugins(radial_menu_extension.RadialMenuExtension)
base/content/gui/gui/game_bar/game_bar_widgets.tl:72
local children : {TreeNodeId} = gui_react_util.usePlugins(game_bar_widgets.GameBarInfoDisplayExtension)
base/content/gui/gui/main/main_mod_button_area.tl:13
local children = gui_react_util.usePlugins(main_mod_button_area.MainModButtonAreaExtension)
base/content/gui/gui/main/game.tl:83
local pluginInstances = gui_react_util.usePlugins(mod_entry_point.ModEntryPointExtension)
base/content/gui/gui/entity_window/station_group/station_group.tl:864
local pluginWidgets = gui_react_util.usePlugins(station_group_eow.StationGroupEowExtensionPoint, nil, extensionParams)
base/content/gui/gui/entity_window/maintenance_station/maintenance_station.tl:76
local pluginWidgets = gui_react_util.usePlugins(maintenance_station_eow.MaintenanceStationEowExtensionPoint, {lastRef = lastInScrollAreaRef}, extensionParams)
… and 11 more files.

usePlugins<WrappedRecipe>(WrapperExtensionPoint0<WrappedRecipe>, detail? : PluginScopeConfig) : {TreeNodeId} base/tealdef/gui/main/gui_react_util.d.tl:199

Call as gui_react_util.usePlugins

Notes

Builds the nodes of all plugins registered for an extension point, in their order.

Parameter Type Description
#1 WrapperExtensionPoint0<WrappedRecipe> The extension point (registered with react.RegisterExtensionPoint...).
detail? PluginScopeConfig Optional refs to the first and last plugin, and fixed nodes to insert.

Returns {TreeNodeId}: List of plugin nodes, possibly empty.

Details

Call it inside a recipe and place the returned nodes in a layout. Plugins with a condition function are only built when the condition returns true for the recipe parameters. Each plugin recipe is called with recipeParam (for extension points with parameters). With detail.insertHardcoded, fixed nodes of the host recipe are sorted in between the plugins by their order value.

Example

-- from station_group.tl
local pluginWidgets = gui_react_util.usePlugins(station_group_eow.StationGroupEowExtensionPoint, nil, extensionParams)
Used in the base game: 18 times in 17 files

base/content/gui/gui/game_bar/game_bar.tl:54

local radialMenuPlugins = gui_react_util.usePlugins(radial_menu_extension.RadialMenuExtension)
base/content/gui/gui/game_bar/game_bar_widgets.tl:72
local children : {TreeNodeId} = gui_react_util.usePlugins(game_bar_widgets.GameBarInfoDisplayExtension)
base/content/gui/gui/main/main_mod_button_area.tl:13
local children = gui_react_util.usePlugins(main_mod_button_area.MainModButtonAreaExtension)
base/content/gui/gui/main/game.tl:83
local pluginInstances = gui_react_util.usePlugins(mod_entry_point.ModEntryPointExtension)
base/content/gui/gui/entity_window/station_group/station_group.tl:864
local pluginWidgets = gui_react_util.usePlugins(station_group_eow.StationGroupEowExtensionPoint, nil, extensionParams)
base/content/gui/gui/entity_window/maintenance_station/maintenance_station.tl:76
local pluginWidgets = gui_react_util.usePlugins(maintenance_station_eow.MaintenanceStationEowExtensionPoint, {lastRef = lastInScrollAreaRef}, extensionParams)
… and 11 more files.

GuiReactUtil.LabelFontColor

enum base/tealdef/gui/main/gui_react_util.d.tl:4

enum LabelFontColor

Notes

Colour of the label of an icon/label indicator. Each value maps to a style class.

Details

Style classes: Default none, Warning warning, Error error-tape, Positive positive, Negative negative, Normal / Inferior / Poor iconlabelindicator-color-normal / -inferior / -poor. The label mode changes some of them: in HudIconMain mode Default and Warning use HUD-specific classes, and in EntityWindow mode Inferior and Poor look like Normal.

Used in the base game: 6 times in 4 files

base/content/gui/gui/layers/layer_public_transport.tl:39

local fontColor : GuiReactUtil.LabelFontColor = "Normal"
base/content/gui/gui/main/gui_react_util.tl:67
local prepareStyleMapping = function(mode : GuiReactUtil.LabelMode) : {GuiReactUtil.LabelFontColor:string}
base/content/gui/gui/main/hud_icon_toolbox.tl:113
local fontColor : GuiReactUtil.LabelFontColor = "Normal"
base/content/gui/gui/main/cargo_react_util.tl:159
local fontColor : GuiReactUtil.LabelFontColor = "Normal"

Value Description
"Default" simple
"Warning" Warning colour (style class warning).
"Error" Error colour (style class error-tape).
"Positive" money
"Negative" Colour for negative money values (style class negative).
"Normal" happiness/quality
"Inferior" Quality or happiness below normal. The cargo helpers use it when some cargo is spoiled.
"Poor" Bad quality or happiness. The cargo helpers use it when more than half of the cargo is spoiled.

GuiReactUtil.LabelMode

enum base/tealdef/gui/main/gui_react_util.d.tl:20

enum LabelMode

Notes

Where an icon/label indicator is shown. Selects the layout, font size and colour classes.

Details

HudIconMain and HudIconLayer use a compact horizontal HUD layout with style class hud-icon-main or hud-icon-layer and font font-scale-title-3; the other modes place the label over the icon and use font-scale-annotation.

Used in the base game: 6 times in 3 files

base/content/gui/gui/main/gui_react_util.tl:52

local getFontScaleClass = function(mode : GuiReactUtil.LabelMode) : string
base/content/gui/gui/main/cargo_react_util.tl:104
local makeCargoTypeIcons = function(params : CargoUtil.CargoTypeInfo, mode : GuiReactUtil.LabelMode, shippingState : GuiReactUtil.ShippingState, showLoadingIndi
base/content/gui/gui/entity_window/vehicle/vehicle_eow.script.tl:851
mode : GuiReactUtil.LabelMode

Value Description
"Default" Standard layout with the label over the icon.
"EntityWindow" Layout for entity windows. Inferior and Poor label colours are shown as Normal.
"EntityWindowPostfix" Layout for extra indicators behind a cargo list in entity windows, e.g. the count of unhappy passengers or delayed deliveries.
"HudIconMain" Compact layout for the main HUD icons above entities. Only in this mode does shippingState tint the background.
"HudIconLayer" Compact layout for HUD icons of map layers.

GuiReactUtil.MouseCursor

enum base/tealdef/gui/main/gui_react_util.d.tl:28

enum MouseCursor

Notes

Names of the mouse cursors. Convert them with getMouseCursorInteger where an integer cursor id is expected.

Details

Default to Resize map to 0-4; the game cursors from Invalid on map to 1001-1027 in declaration order.

Used in the base game: 2 times in 1 file

base/content/gui/gui/main/gui_react_util.tl:9

gui_react_util.getMouseCursorInteger = function(mouseCursor : GuiReactUtil.MouseCursor) : integer

Value Description
"Default" Standard arrow cursor (id 0).
"Text" Text cursor (id 1).
"Link" Link cursor (id 2).
"Wait" Wait cursor (id 3).
"Resize" Resize cursor (id 4).
"Invalid" User
"AddStopValid" Game cursor id 1002.
"AddStopInvalid" Game cursor id 1003.
"Camera" Game cursor id 1004.
"Turn" Game cursor id 1005.
"Raise" Game cursor id 1006.
"TurnRaise" Game cursor id 1007.
"Bulldoze" Game cursor id 1008.
"None" Game cursor id 1009.
"Grab" Game cursor id 1010. Default cursor while dragging (see react.d.tl).
"Lock" Game cursor id 1011.
"Unlock" Game cursor id 1012.
"Config" Game cursor id 1013.
"Cut" Game cursor id 1014.
"Snap" Game cursor id 1015.
"NoSnap" Game cursor id 1016.
"Tangent" Game cursor id 1017.
"Construction" Game cursor id 1018.
"ConstructionTool" Game cursor id 1019.
"Upgrade" Game cursor id 1020.
"TerrainModify" Game cursor id 1021.
"TerrainPaint" Game cursor id 1022.
"PlaceAsset" Game cursor id 1023.
"Rail" Game cursor id 1024.
"StreetStraight" Game cursor id 1025.
"Prospection" Game cursor id 1026.
"CompanyMechanics" Game cursor id 1027.

GuiReactUtil.ForegroundContrast

enum base/tealdef/gui/main/gui_react_util.d.tl:66

enum ForegroundContrast

Notes

Result of the contrast helpers. Tells whether dark or light foreground fits on a given colour.

Used in the base game: 4 times in 2 files

base/content/gui/gui/line_vehicle_mgmt/manager_hud_util.tl:24

local contrast2FGClass<total> : {GuiReactUtil.ForegroundContrast : string} = {
base/content/gui/gui/main/gui_react_util.tl:434
gui_react_util.foregroundColorClassForColor = function(color : Vec4f) : GuiReactUtil.ForegroundContrast

Value Description
"Light" Light foreground; returned for dark colours (average of RGB at most 0.5).
"Dark" Dark foreground; returned for bright colours (average of RGB above 0.5).

GuiReactUtil.ShippingState

enum base/tealdef/gui/main/gui_react_util.d.tl:71

enum ShippingState

Notes

Where shown cargo currently is. Adds a style class to an icon/label indicator.

Details

Style classes: warehouse, waiting-passenger, vehicle, industry-input, industry-output. The base stylesheet uses them in HudIconMain mode to tint the HUD icon background with the matching ShippingState gameplay colour.

Used in the base game: 8 times in 2 files

base/content/gui/gui/main/gui_react_util.tl:105

local shippingStateStyles <total> : {GuiReactUtil.ShippingState : string} = {
base/content/gui/gui/main/cargo_react_util.tl:104
local makeCargoTypeIcons = function(params : CargoUtil.CargoTypeInfo, mode : GuiReactUtil.LabelMode, shippingState : GuiReactUtil.ShippingState, showLoadingIndi

Value Description
"Warehouse" Cargo stored in a warehouse (style class warehouse).
"WaitingPassenger" Passengers waiting at a station (style class waiting-passenger).
"Vehicle" Cargo loaded in a vehicle or on a line (style class vehicle).
"IndustryInput" Cargo in an industry's input stock (style class industry-input).
"IndustryOutput" Cargo in an industry's output stock (style class industry-output).

GuiReactUtil.RichLabel

record base/tealdef/gui/main/gui_react_util.d.tl:79

record RichLabel

Notes

Label made of a text, an icon or emote, and a second text after the icon. Replaces the plain label of an indicator.

Used in the base game: 2 times in 2 files

base/content/gui/gui/layers/layer_public_transport.tl:48

local richLabel : GuiReactUtil.RichLabel = {
base/content/gui/gui/main/cargo_react_util.tl:188
local richLabel : GuiReactUtil.RichLabel

Fields

Name Type Description
text string Text before the icon.
iconPath string Image path of the icon between the two texts.
useEmoteWithSatisfaction EmoteIconParam.Satisfaction If set, an EmoteIcon with this satisfaction is shown instead of iconPath. Only used in the HUD label modes.
textAfterIcon string Text after the icon.

GuiReactUtil.IconLabelIndicatorParams

record base/tealdef/gui/main/gui_react_util.d.tl:86

record IconLabelIndicatorParams

Notes

Parameters of IconLabelIndicator and makeContentLabelIndictator.

Used in the base game: 1 time in 1 file

base/content/gui/gui/main/gui_react_util.tl:330

gui_react_util.IconLabelIndicator = react.RegisterRecipe("IconLabelIndicator", function(params : GuiReactUtil.IconLabelIndicatorParams) : TreeNodeId

Fields

Name Type Description
iconPath string | {string} Image path of the icon, or a list of paths to show several icons side by side.
useEmoteWithSatisfaction EmoteIconParam.Satisfaction If set, an EmoteIcon with this satisfaction is used as the icon instead of iconPath.
label string Text label, usually a number. Ignored when richLabel is set.
richLabel RichLabel Label with text and icon. Takes precedence over label.
labelFontColor LabelFontColor Colour of the label (default Default).
labelMode LabelMode Layout mode; nil behaves like Default.
indicatorIconPath string Image path of a small indicator icon next to the label, e.g. the stock tendency arrows from CargoUtil.getWarehouseCountIndicatorTexture.
tooltip string Tooltip of the label and indicator icon. Also used for the icon when iconTooltip is not set.
iconTooltip string | {string} Tooltip of the icon, or one tooltip per icon when iconPath is a list.
overlay TreeNodeId Node drawn on top of the icon (only in the non-HUD modes).
indicator TreeNodeId Node placed above the indicator, e.g. the loading animation of a vehicle.
shippingState ShippingState Where the cargo is; adds the matching style class.

GuiReactUtil.ContentLabelIndicatorParams

record base/tealdef/gui/main/gui_react_util.d.tl:101

record ContentLabelIndicatorParams

Notes

Variant of IconLabelIndicatorParams with a ready-made content node instead of an icon path.

Details

The module uses this record internally: makeContentLabelIndictator builds the content node from the icon parameters and passes the result on in this form. No public function of the module takes this record.

Fields

Name Type Description
content TreeNodeId Node shown as the icon.
label string Text label. Ignored when richLabel is set.
richLabel RichLabel Label with text and icon.
labelFontColor LabelFontColor Colour of the label.
labelMode LabelMode Layout mode.
labelExtraContent TreeNodeId
indicatorIconPath string Image path of a small indicator icon next to the label.
tooltip string Tooltip of the label and indicator icon.
overlay TreeNodeId Node drawn on top of the content.
indicator TreeNodeId Node placed above the indicator.
shippingState ShippingState Where the cargo is; adds the matching style class.

GuiReactUtil.FocusInputFieldParam

record base/tealdef/gui/main/gui_react_util.d.tl:123

record FocusInputFieldParam<T>

Notes

Parameters of the deprecated FocusNumberInputField and FocusTextInputField recipes.

Used in the base game: 2 times in 1 file

base/content/gui/gui/main/gui_react_util.tl:375

gui_react_util.FocusNumberInputField = react.RegisterRecipe("FocusNumberInputField", function(param : GuiReactUtil.FocusInputFieldParam<number>) : TreeNodeId

Fields

Name Type Description
value T Initial value of the field.
class string Style class of the text field (default font-scale-body). Only read by FocusTextInputField.
maxLength integer Maximum text length. Only read by FocusTextInputField.

Functions

onValueChange(value : T) base/tealdef/gui/main/gui_react_util.d.tl:125

Notes

Called with the entered value when it is accepted (also on focus loss).

onCancel() base/tealdef/gui/main/gui_react_util.d.tl:126

Notes

Called when the input is cancelled.

GuiReactUtil.FocusTraversalScopeParam

record base/tealdef/gui/main/gui_react_util.d.tl:148

record FocusTraversalScopeParam

Notes

Parameters of the FocusTraversalScope recipe.

Used in the base game: 1 time in 1 file

base/content/gui/gui/main/gui_react_util.tl:457

gui_react_util.FocusTraversalScope = react.RegisterRecipe("FocusTraversalScope", function(param : GuiReactUtil.FocusTraversalScopeParam) : TreeNodeId

Fields

Name Type Description
horizontal boolean true lets the left/right navigation inputs move focus inside layout; false blocks them; nil leaves them to the ancestors.
vertical boolean true lets the up/down navigation inputs move focus inside layout; false blocks them; nil leaves them to the ancestors.
allowBubbleUp boolean if focus can't be moved further, allow the input action to be handled by ancestors (default: false)
layout TreeNodeId Node to show inside the scope.

GuiReactUtil.InputActionComponentParam

record base/tealdef/gui/main/gui_react_util.d.tl:157

record InputActionComponentParam

Notes

Parameters of the InputActionComponent recipe.

Used in the base game: 1 time in 1 file

base/content/gui/gui/main/gui_react_util.tl:475

gui_react_util.InputActionComponent = react.RegisterRecipe("InputActionComponent", function(param : GuiReactUtil.InputActionComponentParam) : TreeNodeId

Fields

Name Type Description
iaOrder {string} Names of the input actions to register, in this order.
iaForwards {string : React.IaForward} Forwards by input action name. Used when iaHandlers has no entry for that action.
iaHandlers {string : React.IaHandler} Handlers by input action name.
layout TreeNodeId Node to show.

GuiReactUtil.EmoteIconParam

record base/tealdef/gui/main/gui_react_util.d.tl:166

record EmoteIconParam

Notes

Parameters of the EmoteIcon recipe.

Used in the base game: 1 time in 1 file

base/content/gui/gui/main/gui_react_util.tl:486

gui_react_util.EmoteIcon = react.RegisterRecipe("EmoteIcon", function(param : GuiReactUtil.EmoteIconParam) : TreeNodeId

Fields

Name Type Description
satisfaction Satisfaction Mood to show.
tooltip string Tooltip of the icon.
forceFocusable boolean Passed to the image's meta.forceFocusable.

GuiReactUtil.EmoteIconParam.Satisfaction

enum base/tealdef/gui/main/gui_react_util.d.tl:167

enum Satisfaction

Notes

Mood shown by an emote icon.

Used in the base game: 2 times in 2 files

base/content/gui/gui/main/gui_react_util.tl:487

local iconPathMap<total> : {GuiReactUtil.EmoteIconParam.Satisfaction : string} = {
base/content/gui/gui/entity_window/entity_window_util.tl:1451
local makeSatisfactionState = function() : GuiReactUtil.EmoteIconParam.Satisfaction

Value Description
"Happy" Happy face (symbol_emote_happy_colored.tga).
"Aloof" Unhappy face (symbol_emote_sad_colored.tga, the same image as Sad). The cargo helpers use it for spoiled cargo and unhappy passengers.
"Sad" Unhappy face (symbol_emote_sad_colored.tga).

GuiReactUtil.ClipperParam

record base/tealdef/gui/main/gui_react_util.d.tl:179

record ClipperParam

Notes

Parameters of the Clipper recipe.

Used in the base game: 1 time in 1 file

base/content/gui/gui/main/gui_react_util.tl:506

gui_react_util.Clipper = react.RegisterRecipe("Clipper", function(param : GuiReactUtil.ClipperParam) : TreeNodeId

Fields

Name Type Description
layout TreeNodeId Node whose content is clipped to the component bounds.

GuiReactUtil.PluginScopeConfig

record base/tealdef/gui/main/gui_react_util.d.tl:185

record PluginScopeConfig

Parameter collection for usePlugins()

Used in the base game: 1 time in 1 file

base/content/gui/gui/main/gui_react_util.tl:513

local function usePluginsUntyped(extensionPoint : table, detail? : GuiReactUtil.PluginScopeConfig, ... : any) : { TreeNodeId }

Fields

Name Type Description
firstRef ReactRefWrap if present, filled with a nodeRef to the first (top) plugin
lastRef ReactRefWrap if present, filled with a nodeRef to the last (bottom) plugin
insertHardcoded {integer : {TreeNodeId}} insert subtrees that are not plugins ( {order : {tree}} )