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
… 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
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
… 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
base/content/gui/gui/entity_window/vehicle/vehicle.tl:586
base/content/gui/gui/entity_window/line/line.tl:202
base/content/game_mechanics/game_mechanics/subventions/subventions_gui.tl:459
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.
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
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
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
base/content/gui/gui/entity_window/animal/animal.tl:11
base/content/gui/gui/entity_window/fun_elements/fun_elements.tl:11
… 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
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
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
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
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.