Skip to content

selector_react_util

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

Notes

The default entity selector of the game view: picking entities with the mouse (hover highlight, tooltips, selecting an entity opens its window), the HUD icon configuration that goes with it, and the gamepad inspector tool.

SelectorReactUtil

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

global record SelectorReactUtil

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

Notes

Default entity selector, action descriptors and the inspector tool of the game view.

Fields

Name Type Description
defaultHudIconFilter {Engine.ComponentType} Component types whose entities get HUD icons by default (transport vehicles, industries, warehouses, station groups, towns, base nodes, subconstructions).
defaultHudIconFilterTvCarrier {Carrier} Carriers of transport vehicles that get HUD icons by default (road, rail, tram, air, water).
DefaultSelectorComp Recipe<DefaultSelectorCompParams> Focusable placeholder node used by InspectorSelector; takes focus on mount in inspector mode.
InspectorSelector Recipe<DefaultSelectorCompParams> Recipe behind InspectorTool. While active (gamepad), it sets the selector action in inspector mode; IA_INSPECTOR or IA_ABORT close it. used 1× in the base game
InspectorTool ToolReactUtil.DelegatingToolDefinition<InspectorToolParam, InspectorToolParamInternal> Delegating tool (name "Inspector") for picking entities with the gamepad; push it with tool_react_util.firePushToolEvent{tool = selector_react_util.InspectorTool}. used 2× in the base game

Functions

makeDefaultSelector(refRC : ReactRefWrapApiT<Builtin.RendererComponentParam, Builtin.RenderComponentAPI>, selectedEntityRef : ReactRefT<Engine.Entity>, allowStacking? : boolean, filters? : ReactRefT<GameContext.Filters>, invertedSelectionColors? : boolean) : TreeNodeId base/tealdef/gui/main/selector_react_util.d.tl:23

Call as selector_react_util.makeDefaultSelector

Notes

Creates the default builtin.Selector of the game view.

Parameter Type Description
refRC ReactRefWrapApiT<Builtin.RendererComponentParam, Builtin.RenderComponentAPI> Renderer component in which entities are picked.
selectedEntityRef ReactRefT<Engine.Entity> Ref that receives the hovered entity (used by the tooltips).
allowStacking? boolean Whether a selected entity's window is stacked onto the open ones; nil means "stack in gamepad mode".
filters? ReactRefT<GameContext.Filters> Optional game context filters; a non-empty selectorEntityFilter limits which entities can be picked.
invertedSelectionColors? boolean Uses the dark selection colours.

Returns TreeNodeId

Details

Selecting an entity fires the React event selectEntity (which opens the entity window) and the GUI script event select on mainView (plus select-world for terrain/water picks); clicking a marker fires selectMarker. Edges and base nodes without a configurable switch or traffic light cannot be picked.

Used in the base game: 9 times in 9 files

base/content/gui/gui/layers/layer_passenger_flow.tl:209

selector_react_util.makeDefaultSelector(param.toolParam.gameCtx.rendererComponent, selectedEntityRef, true, nil, true),
base/content/gui/gui/layers/layer_infrastructure.tl:193
selector_react_util.makeDefaultSelector(param.toolParam.gameCtx.rendererComponent, selectedEntityRef, true, nil, true),
base/content/gui/gui/layers/layer_civilization.tl:111
selector_react_util.makeDefaultSelector(param.toolParam.gameCtx.rendererComponent, selectedEntityRef, true, nil, true),
base/content/gui/gui/layers/layer_cargo_flow.tl:345
selector_react_util.makeDefaultSelector(param.toolParam.gameCtx.rendererComponent, selectedEntityRef, true, nil, true),
base/content/gui/gui/layers/layer_noise.tl:205
selector_react_util.makeDefaultSelector(param.toolParam.gameCtx.rendererComponent, selectedEntityRef, true, nil, true),
base/content/gui/gui/layers/layer_traffic.tl:157
selector_react_util.makeDefaultSelector(param.toolParam.gameCtx.rendererComponent, selectedEntityRef, true, nil, true),
… and 3 more files.

makeDefaultSelectorTooltips(selectedEntityRef : ReactRefT<Engine.Entity>) : TreeNodeId base/tealdef/gui/main/selector_react_util.d.tl:24

Call as selector_react_util.makeDefaultSelectorTooltips

Notes

Creates the action tooltip that shows the default entity tooltip for the entity in selectedEntityRef.

Returns TreeNodeId

Used in the base game: 1 time in 1 file

base/content/gui/gui/entity_window/station_group/station_group.tl:956

selector_react_util.makeDefaultSelectorTooltips(selectedEntityRef),

makeDefaultSelectorIfMouse(refRC : ReactRefWrapApiT<Builtin.RendererComponentParam, Builtin.RenderComponentAPI>, selectedEntityRef : ReactRefT<Engine.Entity>, invertedSelectionColors? : boolean) : TreeNodeId base/tealdef/gui/main/selector_react_util.d.tl:25

Call as selector_react_util.makeDefaultSelectorIfMouse

Notes

Like makeDefaultSelector, but returns nil in gamepad mode.

Returns TreeNodeId

Used in the base game: 11 times in 11 files

base/content/gui/gui/statistics/statistics.tl:447

selector_react_util.makeDefaultSelectorIfMouse(toolParam.gameCtx.rendererComponent, selectedEntityRef),
base/content/gui/gui/entity_window/station_group/station_group.tl:955
selector_react_util.makeDefaultSelectorIfMouse(params.gameCtx.rendererComponent, selectedEntityRef),
base/content/gui/gui/entity_window/maintenance_station/maintenance_station.tl:168
selector_react_util.makeDefaultSelectorIfMouse(params.gameCtx.rendererComponent, selectedEntityRef),
base/content/gui/gui/entity_window/vehicle/vehicle.tl:585
selector_react_util.makeDefaultSelectorIfMouse(params.gameCtx.rendererComponent, selectedEntityRef),
base/content/gui/gui/entity_window/town/town.tl:1085
selector_react_util.makeDefaultSelectorIfMouse(params.entityWindowParams.gameCtx.rendererComponent, selectedEntityRef),
base/content/gui/gui/entity_window/town_building/town_building.tl:480
selector_react_util.makeDefaultSelectorIfMouse(params.gameCtx.rendererComponent, selectedEntityRef),
… and 5 more files.

makeDefaultSelectorTooltipsIfMouse(selectedEntityRef : ReactRefT<Engine.Entity>) : TreeNodeId base/tealdef/gui/main/selector_react_util.d.tl:26

Call as selector_react_util.makeDefaultSelectorTooltipsIfMouse

Notes

Like makeDefaultSelectorTooltips, but returns nil in gamepad mode.

Returns TreeNodeId

Used in the base game: 4 times in 4 files

base/content/gui/gui/entity_window/maintenance_station/maintenance_station.tl:169

selector_react_util.makeDefaultSelectorTooltipsIfMouse(selectedEntityRef),
base/content/gui/gui/entity_window/vehicle/vehicle.tl:586
selector_react_util.makeDefaultSelectorTooltipsIfMouse(selectedEntityRef),
base/content/gui/gui/entity_window/line/line.tl:202
selector_react_util.makeDefaultSelectorTooltipsIfMouse(selectedEntityRef),
base/content/game_mechanics/game_mechanics/subventions/subventions_gui.tl:459
selector_react_util.makeDefaultSelectorTooltipsIfMouse(selectedEntityRef),

makeDefaultSelectorCombinedFn(params : DefaultSelectorCompParams) : function() : TreeNodeId base/tealdef/gui/main/selector_react_util.d.tl:28

Call as selector_react_util.makeDefaultSelectorCombinedFn

Notes

Returns an action function that builds the HUD icon configuration, the default selector and its tooltips in one action descriptor.

Returns function() : TreeNodeId

Details

The selector part is left out while the React event preventReactSelector is in effect (until allowReactSelector). HUD icons respect the HUD filter saved in the GUI save data.

Used in the base game: 1 time in 1 file

base/content/gui/gui/entity_window/view_manager.tl:57

local actionFn = selector_react_util.makeDefaultSelectorCombinedFn{refRC = gameCtx.rendererComponent, gameCtx = gameCtx}

makeDefaultSelectorAction(gameCtx : GameContext, layerConfig? : LayerConfig, horizontalPromptList? : boolean, makeCustomActionDescriptorChild? : (function() : TreeNodeId), invertedSelectionColors? : boolean) : function() : TreeNodeId base/tealdef/gui/main/selector_react_util.d.tl:30

Call as selector_react_util.makeDefaultSelectorAction

Notes

Returns the standard action function for windows and tools that keep the normal entity selection active. The action has the HUD icons, the default selector and its tooltips.

Parameter Type Description
gameCtx GameContext Game context.
layerConfig? LayerConfig Optional layer configuration added to the action descriptor.
horizontalPromptList? boolean Shows the input prompts in a horizontal list.
makeCustomActionDescriptorChild? (function() : TreeNodeId) Optional; builds an extra child of the action descriptor.
invertedSelectionColors? boolean Uses the dark selection colours.

Returns function() : TreeNodeId: A function for setActionFn that returns the action descriptor.

Example

-- from sim_person.tl (an entity window)
params.setActionFn(selector_react_util.makeDefaultSelectorAction(params.gameCtx, nil, true))
Used in the base game: 9 times in 9 files

base/content/gui/gui/layers/layer_hud_filter.tl:231

param.setActionFn(selector_react_util.makeDefaultSelectorAction(param.toolParam.gameCtx, nil, true))
base/content/gui/gui/map_editor/map_editor.tl:2720
param.setActionFn(selector_react_util.makeDefaultSelectorAction(toolParam.gameCtx, nil, true))
base/content/gui/gui/entity_window/warehouse/warehouse.tl:96
params.setActionFn(selector_react_util.makeDefaultSelectorAction(params.gameCtx, layerConfig, true))
base/content/gui/gui/entity_window/sim_person/sim_person.tl:171
params.setActionFn(selector_react_util.makeDefaultSelectorAction(params.gameCtx, nil, true))
base/content/gui/gui/entity_window/animal/animal.tl:11
params.setActionFn(selector_react_util.makeDefaultSelectorAction(params.gameCtx, nil, true))
base/content/gui/gui/entity_window/fun_elements/fun_elements.tl:11
params.setActionFn(selector_react_util.makeDefaultSelectorAction(params.gameCtx, nil, true))
… and 3 more files.

makeDefaultSelectorActionIfMouse(gameCtx : GameContext, layerConfig? : LayerConfig, horizontalPromptList? : boolean, makeCustomActionDescriptorChild? : (function() : TreeNodeId), invertedSelectionColors? : boolean) : function() : TreeNodeId base/tealdef/gui/main/selector_react_util.d.tl:31

Call as selector_react_util.makeDefaultSelectorActionIfMouse

Notes

Like makeDefaultSelectorAction, but leaves out the selector and its tooltips in gamepad mode.

Returns function() : TreeNodeId

Used in the base game: 2 times in 2 files

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

param.setActionFn(selector_react_util.makeDefaultSelectorActionIfMouse(param.gameCtx, nil, nil, getArrow))
base/content/gui/gui/construction/construction.tl:4434
return selector_react_util.makeDefaultSelectorActionIfMouse(params.gameCtx)()

SelectorReactUtil.DefaultSelectorCompParams

record base/tealdef/gui/main/selector_react_util.d.tl:4

record DefaultSelectorCompParams

Notes

Parameters of DefaultSelectorComp, InspectorSelector and makeDefaultSelectorCombinedFn.

Used in the base game: 3 times in 1 file

base/content/gui/gui/main/selector_react_util.tl:185

selector_react_util.DefaultSelectorComp = react.RegisterRecipe("DefaultSelectorComp", function(params : SelectorReactUtil.DefaultSelectorCompParams) : TreeNodeI

Fields

Name Type Description
meta Meta Meta data of the node.
refRC ReactRefWrapApiT<Builtin.RendererComponentParam, Builtin.RenderComponentAPI> Reference to the renderer component (3D view) in which entities are picked.
inspectorMode boolean Inspector mode (gamepad); shows a crosshair and the terrain circle at the focused selection, and the component takes focus on mount.
gameCtx GameContext Game context; supplies the notification cache and the selector filters.
invertedSelectionColors boolean Uses the dark (inverted) selection colours of SelectionGuiConfig.

SelectorReactUtil.InspectorToolParam

record base/tealdef/gui/main/selector_react_util.d.tl:12

record InspectorToolParam

Notes

Public tool parameter of InspectorTool (empty).

Used in the base game: 2 times in 1 file

base/content/gui/gui/main/selector_react_util.tl:284

tool_react_util.onPushToolEvent(selector_react_util.InspectorTool, function(evtParam : ToolReactUtil.PushToolEventParam<SelectorReactUtil.InspectorToolParam, Se

SelectorReactUtil.InspectorToolParamInternal

record base/tealdef/gui/main/selector_react_util.d.tl:15

record InspectorToolParamInternal

empty

Used in the base game: 9 times in 1 file

base/content/gui/gui/main/selector_react_util.tl:284

tool_react_util.onPushToolEvent(selector_react_util.InspectorTool, function(evtParam : ToolReactUtil.PushToolEventParam<SelectorReactUtil.InspectorToolParam, Se

Functions

activate(setActionFn : function((function() : TreeNodeId), ?string)) base/tealdef/gui/main/selector_react_util.d.tl:16

Notes

Activates the inspector selector; receives the tool stack's setActionFn.

deactivate() base/tealdef/gui/main/selector_react_util.d.tl:17

Notes

Deactivates the inspector selector and clears its action.