Skip to content

statistics_react_util

Source: base/tealdef/gui/statistics/statistics_react_util.d.tl

Notes

Helpers shared by the statistics tabs (filter bars, search field, cargo columns, problem column), loaded with ug_require "/gui/statistics/statistics_react_util.tl".

StatisticsReactUtil

record global base/tealdef/gui/statistics/statistics_react_util.d.tl:3

global record StatisticsReactUtil

Load: local statistics_react_util = ug_require "/gui/statistics/statistics_react_util.tl"

Notes

Helpers for the statistics tabs.

Fields

Name Type Description
ProblemsCell Recipe<Builtin.TableCellParam> Table cell showing a warning icon (with the count if there are several) for the "Problem" notifications of the row's entity. Clicking it runs the notification's click action. used 6× in the base game

Functions

calculateCargoColumnData(cargoTypeInfos : {CargoUtil.CargoTypeInfo}) : CargoColumnData base/tealdef/gui/statistics/statistics_react_util.d.tl:17

Call as statistics_react_util.calculateCargoColumnData

Notes

Sums cargo type infos into column data. Values of -1 (unknown) are skipped.

Returns CargoColumnData

calculateCargoColumnDataForVehicle(vehicleEntity : Engine.Entity) : CargoColumnData base/tealdef/gui/statistics/statistics_react_util.d.tl:18

Call as statistics_react_util.calculateCargoColumnDataForVehicle

Notes

Calculates the column data of a vehicle from the cargo types it carries or can carry.

Parameter Type Description
vehicleEntity Engine.Entity Entity id of the vehicle.

Returns CargoColumnData

Used in the base game: 8 times in 1 file

base/content/gui/gui/statistics/statistic_vehicles.tl:110

return statistics_react_util.calculateCargoColumnDataForVehicle(entity)

calculateCargoColumnDataForLine(lineEntity : Engine.Entity) : CargoColumnData base/tealdef/gui/statistics/statistics_react_util.d.tl:19

Call as statistics_react_util.calculateCargoColumnDataForLine

Notes

Calculates the column data of a line from the cargo types of its vehicles.

Parameter Type Description
lineEntity Engine.Entity Entity id of the line.

Returns CargoColumnData

Used in the base game: 10 times in 2 files

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

return statistics_react_util.calculateCargoColumnDataForLine(params.lineEntity).demand
base/content/gui/gui/statistics/statistic_lines.tl:99
return statistics_react_util.calculateCargoColumnDataForLine(entity).supply

getStationGroupType(Engine.Entity) : StationGroupType base/tealdef/gui/statistics/statistics_react_util.d.tl:21

Call as statistics_react_util.getStationGroupType

Notes

Determines whether a station group has passenger stations, cargo stations or both.

Parameter Type Description
#1 Engine.Entity Entity id of the station group.

Returns StationGroupType: The type, or nil if the group has neither.

Used in the base game: 3 times in 1 file

base/content/gui/gui/statistics/statistic_stations.tl:97

return statistics_react_util.getStationGroupType(entity)

createFocusBar(children : {TreeNodeId}, focusFilters? : function(), defocusFilter? : function(), iaCompRef? : ReactRefWrap, withoutHint? : boolean) : TreeNodeId base/tealdef/gui/statistics/statistics_react_util.d.tl:30

Call as statistics_react_util.createFocusBar

Notes

Wraps buttons in a horizontal filter bar that can be focused with the IA_OPTION2 input action and left with IA_OPTION2 or IA_BACK.

Parameter Type Description
children {TreeNodeId} Buttons of the bar.
focusFilters? function() Called by IA_OPTION2 to focus the bar.
defocusFilter? function() Called by IA_OPTION2 or IA_BACK while the bar has focus.
iaCompRef? ReactRefWrap Reference for the bar's input action component.
withoutHint? boolean If set, no keybinding hint is shown.

Returns TreeNodeId

Used in the base game: 1 time in 1 file

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

statistics_react_util.createFocusBar({builtin.ToggleButton{

createCarrierCategoryFilter({StatisticsRecipeParams.Category}, StatisticsRecipeParams.OnlyVisible, oldState : (function() : FilterState), transformState : function(function(FilterState) : FilterState), focusFilters? : function(), defocusFilter? : function(), iaCompRef? : ReactRefWrap) : TreeNodeId base/tealdef/gui/statistics/statistics_react_util.d.tl:32

Call as statistics_react_util.createCarrierCategoryFilter

Notes

Creates the filter bar of a tab with a toggle button per category and, if an OnlyVisible kind is given, the "show only visible" toggle.

Parameter Type Description
#1 {StatisticsRecipeParams.Category} Categories of the tab.
#2 StatisticsRecipeParams.OnlyVisible Object kind for the "show only visible" toggle, or nil.
oldState (function() : FilterState) Returns the current filter state.
transformState function(function(FilterState) : FilterState) Applies a change to the filter state.
focusFilters? function() See createFocusBar.
defocusFilter? function() See createFocusBar.
iaCompRef? ReactRefWrap See createFocusBar.

Returns TreeNodeId

Used in the base game: 2 times in 2 files

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

child = statistics_react_util.createCarrierCategoryFilter(
base/content/gui/gui/statistics/statistics.tl:571
filterBar = statistics_react_util.createCarrierCategoryFilter(currentTabFilterConfig.categories, currentTabFilterConfig.onlyVisible, oldState, transform, focusF

createSearchField(value : string, set : function(string), focusNode : ReactRefWrap) : TreeNodeId base/tealdef/gui/statistics/statistics_react_util.d.tl:34

Call as statistics_react_util.createSearchField

Notes

Creates the search text field of a tab.

Parameter Type Description
value string Current text.
set function(string) Called with the text while typing.
focusNode ReactRefWrap Node that gets focus when input is cancelled.

Returns TreeNodeId

Used in the base game: 2 times in 2 files

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

not params.commonParams.gamepadInputModeState:old() and statistics_react_util.createSearchField(
base/content/gui/gui/statistics/statistics.tl:551
searchField = statistics_react_util.createSearchField(currentTabFilterState.search, set, nil)

createFocusDummyForGamepad() : TreeNodeId base/tealdef/gui/statistics/statistics_react_util.d.tl:35

Call as statistics_react_util.createFocusDummyForGamepad

Notes

Creates an empty, focusable component, used as table cell content so that gamepad focus can move through empty cells.

Returns TreeNodeId

Used in the base game: 14 times in 5 files

base/content/gui/gui/statistics/statistic_depots.tl:39

} or statistics_react_util.createFocusDummyForGamepad(),
base/content/gui/gui/statistics/statistic_lines.tl:54
} or statistics_react_util.createFocusDummyForGamepad(),
base/content/gui/gui/statistics/statistic_stations.tl:54
(townState:old() ~= -1) and line_react_util.NameTextView{ entity = townState:old(), locationButton = true } or statistics_react_util.createFocusDummyForGamepad(
base/content/gui/gui/statistics/statistic_industries.tl:102
content = statistics_react_util.createFocusDummyForGamepad()
base/content/gui/gui/statistics/statistic_vehicles.tl:90
content = statistics_react_util.createFocusDummyForGamepad()

compareProblemsLess(notificationsState : {Engine.Entity : {integer}}, entity1 : Engine.Entity, entity2 : Engine.Entity) : boolean base/tealdef/gui/statistics/statistics_react_util.d.tl:42

Call as statistics_react_util.compareProblemsLess

Notes

Sort comparison for the problems column. An entity with fewer "Problem" notifications sorts first.

Parameter Type Description
notificationsState {Engine.Entity : {integer}} Persisting notification ids per entity.
entity1 Engine.Entity First entity.
entity2 Engine.Entity Second entity.

Returns boolean

getProblemsCompareValue(notificationsState : {Engine.Entity : {integer}}, entity : Engine.Entity) : {integer, {integer}} base/tealdef/gui/statistics/statistics_react_util.d.tl:45

Call as statistics_react_util.getProblemsCompareValue

get value usable to for sorting (so that number of notifiaction is most significant)

Returns {integer, {integer}}

Used in the base game: 6 times in 6 files

base/content/gui/gui/statistics/statistic_warehouses.tl:317

return statistics_react_util.getProblemsCompareValue(tableState:old().notificationsState or {}, warehouseEntity)
base/content/gui/gui/statistics/statistic_lines.tl:400
return statistics_react_util.getProblemsCompareValue(tableState:old().notificationsState or {}, lineEntity)
base/content/gui/gui/statistics/statistic_stations.tl:278
return statistics_react_util.getProblemsCompareValue(tableState:old().notificationsState or {}, stationGroupEntity)
base/content/gui/gui/statistics/statistic_industries.tl:401
return statistics_react_util.getProblemsCompareValue(tableState:old().notificationsState or {}, warehouseEntity)
base/content/gui/gui/statistics/statistic_towns.tl:493
return statistics_react_util.getProblemsCompareValue(tableState:old().notificationsState or {}, lineEntity)
base/content/gui/gui/statistics/statistic_vehicles.tl:355
return statistics_react_util.getProblemsCompareValue(tableState:old().notificationsState or {}, vehicleEntity)

getCarrierFilterFromCategories(allCategories : {StatisticsRecipeParams.Category}, activeCategories : {integer : boolean}) : {Carrier} base/tealdef/gui/statistics/statistics_react_util.d.tl:49

Call as statistics_react_util.getCarrierFilterFromCategories

Notes

Collects the carriers of the enabled categories.

Parameter Type Description
allCategories {StatisticsRecipeParams.Category} Categories of the tab.
activeCategories {integer : boolean} Enabled categories, by index.

Returns {Carrier}: The carriers, or nil if no category is enabled or an enabled category has no carrier.

Used in the base game: 8 times in 6 files

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

local allowedCarriers = statistics_react_util.getCarrierFilterFromCategories(filterCategories, filterShowCategories)
base/content/gui/gui/statistics/statistic_depots.tl:238
local allowedCarriers  = statistics_react_util.getCarrierFilterFromCategories(categories, params.filterShowCategories)
base/content/gui/gui/statistics/statistic_lines.tl:317
local allowedCarriers = statistics_react_util.getCarrierFilterFromCategories(categories, params.filterShowCategories)
base/content/gui/gui/statistics/statistic_stations.tl:342
local allowedCarriers  = statistics_react_util.getCarrierFilterFromCategories(categories, params.filterShowCategories)
base/content/gui/gui/statistics/statistics.tl:304
carriers = statistics_react_util.getCarrierFilterFromCategories(filterConfig.categories, filterState.category)
base/content/gui/gui/statistics/statistic_vehicles.tl:424
local allowedCarriers  = statistics_react_util.getCarrierFilterFromCategories(categories, params.filterShowCategories)

areCarriersContainedInTransportModes(transportModes : {TransportMode : boolean}, carriers : {Carrier}) : boolean base/tealdef/gui/statistics/statistics_react_util.d.tl:51

Call as statistics_react_util.areCarriersContainedInTransportModes

Notes

Checks whether any of the enabled transport modes corresponds to one of the given carriers.

Parameter Type Description
transportModes {TransportMode : boolean} Transport modes mapped to whether they are enabled.
carriers {Carrier} Carriers to look for.

Returns boolean

Used in the base game: 7 times in 3 files

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

if not allowedCarriers or statistics_react_util.areCarriersContainedInTransportModes(depot.transportModes, allowedCarriers) then
base/content/gui/gui/statistics/statistic_depots.tl:241
if not statistics_react_util.areCarriersContainedInTransportModes(vehicleDepot.transportModes, allowedCarriers) then
base/content/gui/gui/statistics/statistics.tl:379
return statistics_react_util.areCarriersContainedInTransportModes(vehicleDepot.transportModes, carriers)

StatisticsReactUtil.StationGroupType

enum base/tealdef/gui/statistics/statistics_react_util.d.tl:4

enum StationGroupType

Notes

Kind of a station group, by the stations it contains.

Used in the base game: 5 times in 2 files

base/content/gui/gui/statistics/statistic_stations.tl:80

local getStationGroupTypeLabel = function(groupType : StatisticsReactUtil.StationGroupType) : string
base/content/gui/gui/statistics/statistics_react_util.tl:13
statistics_react_util.getStationGroupType = function(entity : Engine.Entity) : StatisticsReactUtil.StationGroupType

Value Description
"Passenger" Only passenger stations.
"Cargo" Only cargo stations.
"Mixed" Both passenger and cargo stations.

StatisticsReactUtil.CargoColumnData

record base/tealdef/gui/statistics/statistics_react_util.d.tl:10

record CargoColumnData

Notes

Summed load figures for the Load, Capacity, Utilization and Satisfaction columns.

Used in the base game: 15 times in 4 files

base/content/gui/gui/statistics/statistic_warehouses.tl:118

local calculateCargoColumnDataFromEntity = function(entity: Engine.Entity) : StatisticsReactUtil.CargoColumnData
base/content/gui/gui/statistics/statistics_react_util.tl:194
statistics_react_util.calculateCargoColumnData = function(cargoTypeInfos : {cargo_util.CargoTypeInfo}) : StatisticsReactUtil.CargoColumnData
base/content/gui/gui/statistics/statistic_towns.tl:147
local calculateCargoColumnData = function(cargoData : {CargoInfo}) : StatisticsReactUtil.CargoColumnData
base/content/gui/gui/statistics/statistic_vehicles.tl:109
local calculateCargoColumnDataForVehicleState = function() : StatisticsReactUtil.CargoColumnData

Fields

Name Type Description
supply integer Sum of the cargo counts (load).
demand integer Sum of the capacities.
coverage number supply / demand (utilization); 0 if supply is 0.
averageQuality number Mean of the known average qualities of the cargo types.

StatisticsReactUtil.FilterState

record base/tealdef/gui/statistics/statistics_react_util.d.tl:23

record FilterState

Notes

Filter settings of one statistics tab.

Used in the base game: 33 times in 3 files

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

filterState : ReactStateT<StatisticsReactUtil.FilterState>
base/content/gui/gui/statistics/statistics.tl:31
storeFilterStates : function({StatisticsRecipeParams.TabKey : StatisticsReactUtil.FilterState})
base/content/gui/gui/statistics/statistics_react_util.tl:124
oldState : (function() : StatisticsReactUtil.FilterState),

Fields

Name Type Description
category {integer : boolean} Enabled category buttons, by category index.
onlyVisible boolean Whether the "show only visible" toggle is on.
search string Search text.
initialSortColumn {integer, boolean} Sort column as {columnIndex, ascending}.

StatisticsReactUtil.UserParam

record base/tealdef/gui/statistics/statistics_react_util.d.tl:37

record UserParam

Notes

User parameter that the statistics tables pass to their cells.

Used in the base game: 8 times in 8 files

base/content/gui/gui/statistics/statistic_warehouses.tl:350

local userParam : StatisticsReactUtil.UserParam = {
base/content/gui/gui/statistics/statistic_depots.tl:209
local userParam : StatisticsReactUtil.UserParam = {
base/content/gui/gui/statistics/statistic_lines.tl:422
local userParam : StatisticsReactUtil.UserParam = {
base/content/gui/gui/statistics/statistic_stations.tl:312
local userParam : StatisticsReactUtil.UserParam = {
base/content/gui/gui/statistics/statistics_react_util.tl:348
local userParam = params.userParam as StatisticsReactUtil.UserParam
base/content/gui/gui/statistics/statistic_industries.tl:429
local userParam : StatisticsReactUtil.UserParam = {
… and 2 more files.

Fields

Name Type Description
notificationState {Engine.Entity : {integer}} Persisting notification ids per entity.

Functions

deleteLineFeedback(message : string, mode : string, dialogData : FeedbackListUtil.FeedbackDialogParam, id : number) base/tealdef/gui/statistics/statistics_react_util.d.tl:38

No description in the game files yet.