construction_react_util¶
Source: base/tealdef/gui/construction/construction_react_util.d.tl
Notes
Helper module of the construction menu (::/gui/construction/construction_react_util.tl). Builds the
menu entries from the resource repositories (constructions, streets, tracks, modules, terrain
materials, construction_tool resources, edge decorations), converts script parameters into menu
parameters and creates the parameters of the construction action.
StampData¶
record global base/tealdef/gui/construction/construction_react_util.d.tl:3
global record StampData
Notes
Data of a stamp resource, a heightmap stamp for the terrain heightmap tool.
Example
Fields
| Name | Type | Description |
|---|---|---|
heightmap |
string |
Heightmap image of the stamp. |
icon |
string |
Icon shown for the stamp in the tool's "Heightmap" parameter. |
ConstructionReactUtil¶
record global base/tealdef/gui/construction/construction_react_util.d.tl:8
global record ConstructionReactUtil
Load: local construction_react_util = ug_require "::/gui/construction/construction_react_util.tl" as ConstructionReactUtil
Notes
Helper module of the construction menu. Load it with ug_require "::/gui/construction/construction_react_util.tl".
Fields
| Name | Type | Description |
|---|---|---|
SimpleTooltipRecipe |
Recipe<ConstructionReactUtil.SimpleTooltipRecipeParams> |
Recipe of a simple action tooltip with a message line and an optional cost line.In game Cost: {cost} used 4× in the base game |
Functions
getConstructionDefinitions() : {ConstructionDefinition} base/tealdef/gui/construction/construction_react_util.d.tl:44
Call as construction_react_util.getConstructionDefinitions(…)
Notes
Creates menu entries for all constructions and meta constructions; constructions with templates get one entry per template.
Returns {ConstructionDefinition}
Details
Constructions without a menu category are skipped. Edge object constructions become ACTION_STREET_TERMINAL_BUILDER entries, all others ACTION_CONSTRUCTION_BUILDER.
convertScriptParamsToMenuParams(descParams : {ScriptParam}, filterByPostconstructionModifiable? : boolean) : {ConstructionMenuParam} base/tealdef/gui/construction/construction_react_util.d.tl:45
Call as construction_react_util.convertScriptParamsToMenuParams(…)
Notes
Converts script parameters of a construction description into menu parameters.
| Parameter | Type | Description |
|---|---|---|
descParams |
{ScriptParam} |
Script parameters. |
filterByPostconstructionModifiable? |
boolean |
Keeps only parameters flagged postConstructionModifiable. |
Returns {ConstructionMenuParam}
getPerksProspectionDefinitions() : {ConstructionDefinition} base/tealdef/gui/construction/construction_react_util.d.tl:46
Call as construction_react_util.getPerksProspectionDefinitions(…)
Notes
Creates the prospection perk entries from the company_exploration resources (with required tags) of the current economy.
In game Prospect for Resources: {cargoType}
· Prospect for unexploited occurrences of resource "{cargoType}" near a specific town.
· Start Prospecting Here
Returns {ConstructionDefinition}
getModuleDefinitions() : {ConstructionDefinition} base/tealdef/gui/construction/construction_react_util.d.tl:47
Call as construction_react_util.getModuleDefinitions(…)
Notes
Creates ACTION_MODULE_BUILDER entries for all modules that have a menu category.
Returns {ConstructionDefinition}
getStreetDefinitions(tramOnly? : boolean) : {ConstructionDefinition} base/tealdef/gui/construction/construction_react_util.d.tl:48
Call as construction_react_util.getStreetDefinitions(…)
Notes
Creates street builder entries for all street templates of road type STREET.
In game Straight Road
· Curved Road
· Replace Road
| Parameter | Type | Description |
|---|---|---|
tramOnly? |
boolean |
Returns only tram-only roads. |
Returns {ConstructionDefinition}
getStreetToolsHudIcons(depotType : ConstructionActionHudIconConstructionType) : ConstructionActionHudIcons base/tealdef/gui/construction/construction_react_util.d.tl:49
Call as construction_react_util.getStreetToolsHudIcons(…)
Notes
HUD icon configuration for street tools (industries, towns, stations, depots, warehouses).
| Parameter | Type | Description |
|---|---|---|
depotType |
ConstructionActionHudIconConstructionType |
Carrier filter for depot icons. |
Returns ConstructionActionHudIcons
Used in the base game: 6 times in 6 files
base/content/gui/gui/construction/tools/bus_lane_tool.script.tl:31
base/content/gui/gui/construction/tools/crosswalk_modifier_tool.script.tl:30
base/content/gui/gui/construction/tools/lane_modifier_tool.script.tl:45
base/content/gui/gui/construction/tools/player_owned_tool.script.tl:25
base/content/gui/gui/construction/tools/traffic_light_tool.script.tl:21
base/content/gui/gui/construction/tools/tram_track_tool.script.tl:60
getTrackDefinitions() : {ConstructionDefinition} base/tealdef/gui/construction/construction_react_util.d.tl:50
Call as construction_react_util.getTrackDefinitions(…)
Notes
Creates track builder entries for all street templates of road type TRACK, sorted by speed.
In game Track Builder Mode
· Build Track
· Replace Track
Returns {ConstructionDefinition}
getMaterialsDefinitions(terrainToolData : ConstructionToolParam.TerrainToolData, includeEraser : boolean) : {ConstructionDefinition} base/tealdef/gui/construction/construction_react_util.d.tl:51
Call as construction_react_util.getMaterialsDefinitions(…)
Notes
Creates terrain painter entries for all terrain materials, sorted by their order.
In game Eraser Tool
· Erase the terrain painting and restore the default material.
| Parameter | Type | Description |
|---|---|---|
terrainToolData |
ConstructionToolParam.TerrainToolData |
Size data for the brush parameters. |
includeEraser |
boolean |
Adds the material eraser entry (resIndex 0). |
Returns {ConstructionDefinition}
forEachDefinition(fn : function(definition : ConstructionDefinition), repository : ConstructionActionRepository) base/tealdef/gui/construction/construction_react_util.d.tl:55
Call as construction_react_util.forEachDefinition(…)
SLOW!
makeItemDisabledCache(allDefinitions : {ConstructionDefinition}) : ItemDisableCache base/tealdef/gui/construction/construction_react_util.d.tl:57
Call as construction_react_util.makeItemDisabledCache(…)
Notes
Creates the cache for checkItemDisabledDefault and checkItemRemainingNum from all menu entries.
Returns ItemDisableCache
checkItemDisabledDefault(ConstructionDefinition, cache : ItemDisableCache) : ItemDisableReason base/tealdef/gui/construction/construction_react_util.d.tl:58
Call as construction_react_util.checkItemDisabledDefault(…)
Notes
Checks the company permits of an entry.
Returns ItemDisableReason: The reason the entry is disabled, or nil if it is usable.
checkItemRemainingNum(definition : ConstructionDefinition, cache : ItemDisableCache) : integer | nil base/tealdef/gui/construction/construction_react_util.d.tl:59
Call as construction_react_util.checkItemRemainingNum(…)
Notes
Returns how many uses of an entry's company permit remain, or nil if not limited.
Returns integer | nil
makeUndergroundParam(stepValueFn : (function(value : integer, direction : integer, precise : boolean) : integer), checkEnabledFn? : (function(params : {string : number}) : ConstructionMenuParam.CheckEnabledResult), defaultUnderground? : boolean) : ConstructionMenuParam base/tealdef/gui/construction/construction_react_util.d.tl:61
Call as construction_react_util.makeUndergroundParam(…)
Notes
Creates the toolbar parameter undergroundMode ("Underground", Yes/No) that shows and snaps only to underground objects. Its value is preserved across categories.
| Parameter | Type | Description |
|---|---|---|
stepValueFn |
(function(value : integer, direction : integer, precise : boolean) : integer) |
Step function of the parameter. |
checkEnabledFn? |
(function(params : {string : number}) : ConstructionMenuParam.CheckEnabledResult) |
Enabled check of the parameter. |
defaultUnderground? |
boolean |
Makes "Yes" the default. |
Returns ConstructionMenuParam
Used in the base game: 7 times in 7 files
base/content/gui/gui/construction/tools/bus_lane_tool.script.tl:27
construction_react_util.makeUndergroundParam(function(value : integer, __ : integer, __ : boolean) : integer
base/content/gui/gui/construction/tools/crosswalk_modifier_tool.script.tl:26
construction_react_util.makeUndergroundParam(function(value : integer, __ : integer, __ : boolean) : integer
base/content/gui/gui/construction/tools/lane_modifier_tool.script.tl:40
construction_react_util.makeUndergroundParam(function(value : integer, __ : integer, __ : boolean) : integer
base/content/gui/gui/construction/tools/player_owned_tool.script.tl:21
construction_react_util.makeUndergroundParam(function(value : integer, __ : integer, __ : boolean) : integer
base/content/gui/gui/construction/tools/rail_electrification_tool.script.tl:18
construction_react_util.makeUndergroundParam(function(value : integer, __ : integer, ___ : boolean) : integer
base/content/gui/gui/construction/tools/traffic_light_tool.script.tl:17
… and 1 more files.
getBrushConstructionParams(args : ConstructionReactUtil.BrushConstructionArgs) : {ConstructionMenuParam} base/tealdef/gui/construction/construction_react_util.d.tl:81
Call as construction_react_util.getBrushConstructionParams(…)
Notes
Creates the toolbar parameters of a brush tool (size, strength, rotation, brush shape and the optional parameters selected in args).
In game Brush Mode
· Brush Size
· Strength
Returns {ConstructionMenuParam}
Used in the base game: 6 times in 5 files
base/content/gui/gui/construction/tools/asset_eraser_tool.script.tl:24
base/content/gui/gui/construction/tools/mixed_assets.script.tl:66
base/content/gui/gui/construction/tools/terrain_painter_eraser_tool.script.tl:23
base/content/gui/gui/construction/tools/terrain_tools.script.tl:6
base/content/gui/gui/construction/tools/vegetation_eraser_tool.script.tl:24
getMenuCategories(repository : ConstructionActionRepository) : {ConstructionMenu : {{ConstructionMenuCategory, {ConstructionDefinition}}}} base/tealdef/gui/construction/construction_react_util.d.tl:83
Call as construction_react_util.getMenuCategories(…)
Notes
Groups all menu entries by construction menu tab and menu_category, sorted by category order and entry order.
Returns {ConstructionMenu : {{ConstructionMenuCategory, {ConstructionDefinition}}}}: For each menu tab, a list of {category, definitions} pairs.
getConstructionActionRepository(terrainToolData : ConstructionToolParam.TerrainToolData, hasHeightMapTextureTool : boolean) : ConstructionActionRepository base/tealdef/gui/construction/construction_react_util.d.tl:85
Call as construction_react_util.getConstructionActionRepository(…)
Notes
Creates the repository with all heightmap stamps, ordered cargo types and land-use cargo types.
Returns ConstructionActionRepository
getActionParams(definition : ConstructionDefinition, params : {string : number}, repository : ConstructionActionRepository, isGamepadMode : boolean, refParams : ReactRefWrapApiT<any, ConstructionMenuParamsAPI>, entity : Engine.Entity, accessNotificationCacheFn : (function(Engine.Entity) : {Notification}), sublistParamsApi : ReactRefWrapApiT<any, ConstructionMenuParamsAPI>, disableLayersIA : boolean) : ConstructionMenuActionParams base/tealdef/gui/construction/construction_react_util.d.tl:86
Call as construction_react_util.getActionParams(…)
Notes
Creates the construction action, HUD icon and layer parameters for a menu entry and its current parameter values, including the input action handlers of its toolbar parameters.
In game Brush Mode
· Reputation: -{value} {townsString}
· Underground Mode
| Parameter | Type | Description |
|---|---|---|
definition |
ConstructionDefinition |
|
params |
{string : number} |
|
repository |
ConstructionActionRepository |
|
isGamepadMode |
boolean |
|
refParams |
ReactRefWrapApiT<any, ConstructionMenuParamsAPI> |
|
entity |
Engine.Entity |
|
accessNotificationCacheFn |
(function(Engine.Entity) : {Notification}) |
|
sublistParamsApi |
ReactRefWrapApiT<any, ConstructionMenuParamsAPI> |
|
disableLayersIA |
boolean |
When true, the layer ridge input action of the construction menu is not registered. The construction window passes gameCtx.disableFeatures:get()["Layers"]. |
Returns ConstructionMenuActionParams
Very slow -> Do not use! If needed, get allCompanyDefinitionsCacheRef from game.tl
getAllCompanyDefinitions(terrainToolData : ConstructionToolParam.TerrainToolData) : {ConstructionDefinition} base/tealdef/gui/construction/construction_react_util.d.tl:92
Call as construction_react_util.getAllCompanyDefinitions(…)
No description in the game files yet.
Returns {ConstructionDefinition}
constructIcon(icon : IconWithAvailability, locked : boolean) : TreeNodeId base/tealdef/gui/construction/construction_react_util.d.tl:94
Call as construction_react_util.constructIcon(…)
Notes
Creates the icon node of a menu entry (the year-dependent or locked icon if applicable).
Returns TreeNodeId
Used in the base game: 3 times in 2 files
base/content/game_mechanics/game_mechanics/company/company.tl:159
base/content/gui/gui/construction/construction.tl:354
mergeLayerConfig(fromConstructionItem : LayerConfig, preferredLayerConfig : LayerConfig) : LayerConfig base/tealdef/gui/construction/construction_react_util.d.tl:96
Call as construction_react_util.mergeLayerConfig(…)
Notes
Returns the preferred layer configuration (the one chosen in the layers menu) if set, otherwise the configuration of the construction entry.
Returns LayerConfig
makeWhiteScreen(layerConfig : LayerConfig, layerColors : LayerColors) base/tealdef/gui/construction/construction_react_util.d.tl:97
Call as construction_react_util.makeWhiteScreen(…)
Notes
Sets a color pass on the layer configuration that renders the scene in the neutral construction fallback colors.
RegisterCustomSelectorBasedActionRecipe<P>(recipeName : string, outerParams : RegisterCustomSelectorBasedActionRecipeParams<P>) : Recipe<ConstructionCustomActionParams<P>> base/tealdef/gui/construction/construction_react_util.d.tl:100
Call as construction_react_util.RegisterCustomSelectorBasedActionRecipe(…)
Notes
Registers a custom action recipe that lets the player pick an entity on the map, with tooltip, cursor and HUD icons. The base game uses it for the prospection, marketing and industry greenification perks.
| Parameter | Type | Description |
|---|---|---|
recipeName |
string |
Name of the recipe. |
outerParams |
RegisterCustomSelectorBasedActionRecipeParams<P> |
Callbacks and selector filter. |
Returns Recipe<ConstructionCustomActionParams<P>>: A recipe for ConstructionCustomAction.recipe.
Example
-- abridged from base/content/gui/gui/construction/tools/industry_greenify_tool.script.tl
local IndustryGreenifyRecipe = construction_react_util.RegisterCustomSelectorBasedActionRecipe("IndustryGreenifyAction", {
onHover = function(__, entity : Engine.Entity) : SelectorBasedActionHoverResult
return {
param = {
recipe = construction_react_util.SimpleTooltipRecipe,
param = { message = { message = _("Select an Industry to Greenify") } },
},
mouseCursor = gui_react_util.getMouseCursorInteger("CompanyMechanics"),
}
end,
onSelect = function(params : ConstructionCustomActionParams<string>, entity : Engine.Entity)
-- send a command for the selected entity
end,
filter = componentFilter(api.type.ComponentType.INDUSTRY),
})
Used in the base game: 2 times in 2 files
base/content/gui/gui/construction/tools/industry_greenify_tool.script.tl:16
local IndustryGreenifyRecipe = construction_react_util.RegisterCustomSelectorBasedActionRecipe("IndustryGreenifyAction", {
base/content/gui/gui/construction/tools/marketing_campaign_tool.script.tl:23
ConstructionReactUtil.ItemDisableCache¶
record base/tealdef/gui/construction/construction_react_util.d.tl:9
record ItemDisableCache
Notes
Cached company data used to decide whether menu entries are locked or used up; create it with makeItemDisabledCache.
Used in the base game: 12 times in 3 files
base/content/gui/gui/construction/construction.tl:113
base/content/gui/gui/construction/construction_desc_react_util.tl:440
local getNumberOfAvailablePermitsFromCache = function(permitKey : ResName, cache : ConstructionReactUtil.ItemDisableCache) : integer
base/content/gui/gui/construction/construction_react_util.tl:1163
Fields
| Name | Type | Description |
|---|---|---|
company |
CompanyUtil.ConstructionDisableCacheData |
Company permit data of all entries. |
ConstructionReactUtil.ItemDisableReason¶
record base/tealdef/gui/construction/construction_react_util.d.tl:13
record ItemDisableReason
Notes
Why a menu entry is disabled.
Used in the base game: 3 times in 2 files
base/content/gui/gui/construction/construction.tl:3731
local disabledReason : ConstructionReactUtil.ItemDisableReason = params.itemDisableCacheRef and construction_react_util.checkItemDisabledDefault(definition, par
base/content/gui/gui/construction/construction_react_util.tl:1183
Fields
ConstructionReactUtil.ConstructionMenuSetTabEventParam¶
record base/tealdef/gui/construction/construction_react_util.d.tl:19
record ConstructionMenuSetTabEventParam
Notes
Parameter of the GUI event constructionMenuSetTab, which opens a construction menu tab.
Used in the base game: 3 times in 1 file
base/content/gui/gui/construction/construction.tl:2811
Fields
| Name | Type | Description |
|---|---|---|
tabIndex |
integer |
Index of the tab to open. |
allowStacking |
boolean |
Passed to the tool stack when the construction tool is pushed. |
sublistId |
string |
Id of the sub tab to select. |
ConstructionReactUtil.ConstructionMenuSelectConstructionEventParam¶
record base/tealdef/gui/construction/construction_react_util.d.tl:25
record ConstructionMenuSelectConstructionEventParam
Notes
Parameter of the GUI event constructionMenuSelectTabForConstruction, which opens the menu tab containing a construction.
Example
Used in the base game: 2 times in 2 files
base/content/game_mechanics/game_mechanics/notifications/types/con_availability.script.tl:35
base/content/gui/gui/construction/construction.tl:4910
Fields
| Name | Type | Description |
|---|---|---|
resName |
ResName |
Resource name of the entry to find; an entry available in the current year is preferred. |
ConstructionReactUtil.SimpleTooltipRecipeParams¶
record base/tealdef/gui/construction/construction_react_util.d.tl:29
record SimpleTooltipRecipeParams
Notes
Parameters of SimpleTooltipRecipe.
Used in the base game: 4 times in 3 files
base/content/gui/gui/construction/construction_react_util.tl:1208
construction_react_util.SimpleTooltipRecipe = react.RegisterRecipe("SimpleTooltipRecipe", function(params : ConstructionReactUtil.SimpleTooltipRecipeParams) : T
base/content/gui/gui/construction/tools/industry_greenify_tool.script.tl:28
base/content/gui/gui/construction/tools/marketing_campaign_tool.script.tl:35
Fields
| Name | Type | Description |
|---|---|---|
message |
MessageGoodOrBad |
Message line. |
cost |
integer |
Cost in game currency; adds a "Cost" line, shown as bad when the player cannot afford it. |
ConstructionReactUtil.SimpleTooltipRecipeParams.MessageGoodOrBad¶
record base/tealdef/gui/construction/construction_react_util.d.tl:30
record MessageGoodOrBad
Notes
A tooltip message with its style.
Used in the base game: 2 times in 1 file
base/content/gui/gui/construction/construction_react_util.tl:1209
Fields
ConstructionReactUtil.DefinitionWithFilterCategories¶
record base/tealdef/gui/construction/construction_react_util.d.tl:39
record DefinitionWithFilterCategories
Notes
A menu entry together with the filter categories of one of its menu categories.
Fields
| Name | Type | Description |
|---|---|---|
definition |
ConstructionDefinition |
The menu entry. |
filterCategories |
{string} |
Filter categories of the entry in that menu category. |
ConstructionReactUtil.BrushConstructionArgs¶
record base/tealdef/gui/construction/construction_react_util.d.tl:64
record BrushConstructionArgs
Notes
Options for getBrushConstructionParams.
Used in the base game: 1 time in 1 file
base/content/gui/gui/construction/construction_react_util.tl:2891
Fields