Skip to content

menu_category_util

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

Notes

Filtering of selectable objects (bridges, tunnels, street types, ...) by menu category. Filter categories are menu_filter_category resources; objects carry a menuCategory in their metadata. Includes the filter panel, the object picker and helpers that list the objects available in a given year.

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

global record MenuCategoryUtil

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

Notes

Menu category filtering helpers and recipes.

Fields

Name Type Description
CategoryFilterPanel Recipe<CategoryFilterPanelParam> Row of toggle buttons, one per filter category; hidden when the only categories are "*" and one other. used 2× in the base game
ObjectFilterBox Recipe<ObjectFilterBoxParam> Object picker. It shows a category filter panel above a flow of toggle buttons with the objects' icons (and speed limit, if any). used 1× in the base game
FilterObjectsCalloutButton Recipe<ObjectsCalloutButtonParam> Button showing the icon of the current object that opens an ObjectFilterBox in a callout. used 1× in the base game

Functions

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

record FilterCategory

Notes

A filter category, as defined by a menu_filter_category resource.

Example

-- gui/construction/menu/filter_categories/bridge_suspension.res.lua
function data()
    return {
        type = "menu_filter_category",
        data = {
            category = "bridge_suspension",
            icon = resolve("bridge_suspension.tga"),
            name = _("Suspension"),
            order = 16300,
        }
    }
end
Used in the base game: 23 times in 3 files

base/content/gui/gui/construction/construction.tl:45

getMenuCategoryData : function(category : string) : MenuCategoryUtil.FilterCategory
base/content/gui/gui/construction/construction_react_util.tl:2782
local categoryData : {string : MenuCategoryUtil.FilterCategory} = menu_category_util.fetchMenuFilterCategories()
base/content/gui/gui/main/menu_category_util.tl:8
menu_category_util.fetchMenuFilterCategories = function() : {string : MenuCategoryUtil.FilterCategory}

Fields

Name Type Description
category string Category key, referenced by the filterCategories of an object's menu category; "*" stands for all.
name string Display name (tooltip of the filter button).
order number Sort order; lower values come first.
icon string Icon path of the filter button.

record base/tealdef/gui/main/menu_category_util.d.tl:14

record CategoryFilterPanelParam

Notes

Parameters of CategoryFilterPanel.

Used in the base game: 1 time in 1 file

base/content/gui/gui/main/menu_category_util.tl:45

menu_category_util.CategoryFilterPanel = react.RegisterRecipe("CategoryFilterPanel", function(param : MenuCategoryUtil.CategoryFilterPanelParam) : TreeNodeId

Fields

Name Type Description
categories {MenuCategoryUtil.FilterCategory} Categories to show, one toggle button each.
selection {boolean} Selected state per entry of categories.

Functions

record base/tealdef/gui/main/menu_category_util.d.tl:23

record FilterObject

Notes

An object that can be picked in an ObjectFilterBox (usually created by getAvailableObjectsSorted).

Used in the base game: 25 times in 4 files

base/content/gui/gui/construction/construction.tl:970

local index = table_util.arrayFindIf(objects, function(object : MenuCategoryUtil.FilterObject) : boolean
base/content/gui/gui/construction/construction_react_util.tl:306
: function() : {MenuCategoryUtil.FilterObject}, integer
base/content/gui/gui/main/menu_category_util.tl:94
local filterObjectLess = function(a : MenuCategoryUtil.FilterObject, b : MenuCategoryUtil.FilterObject) : boolean
base/content/gui/gui/entity_window/bridge_and_tunnel.tl:9
local getAvailableObjects = function(rep : ResTypeRep<integer, BridgeType>, objectType : MenuCategoryUtil.ObjectType, stripInfo : UtilParallelStrip.StripInfo) :

Fields

Name Type Description
id integer must be unique within a provided set!
name string Display name (from the object's description).
iconPath string Icon path (from the object's description).
availability ModelMetadata.Availability Years in which the object is available; used for sorting and the year check.
menuCategory ModelMetadata.MenuCategory Menu category metadata of the object; its filterCategories decide in which filter categories it appears, the order of its first category decides the sort order.
speedLimit number optional
carriers {Carrier} optional
isAutoSelectable boolean optional

record base/tealdef/gui/main/menu_category_util.d.tl:34

record ObjectFilterBoxParam

Notes

Parameters of ObjectFilterBox.

Used in the base game: 3 times in 1 file

base/content/gui/gui/main/menu_category_util.tl:173

menu_category_util.ObjectFilterBox = react.RegisterRecipe("ObjectFilterBox", function(param : MenuCategoryUtil.ObjectFilterBoxParam) : TreeNodeId

Fields

Name Type Description
objectsSorted {FilterObject} All objects to choose from, already sorted.
currentObjectId integer Id of the selected object; when it is not in the list, the first object is selected via onSelectionChange.
tooltip string Tooltip of the button of FilterObjectsCalloutButton.

Functions

record base/tealdef/gui/main/menu_category_util.d.tl:43

record ObjectsCalloutButtonParam

Notes

Parameters of FilterObjectsCalloutButton.

Used in the base game: 1 time in 1 file

base/content/gui/gui/main/menu_category_util.tl:367

menu_category_util.FilterObjectsCalloutButton = react.RegisterRecipe("FilterObjectsCalloutButton", function(param : MenuCategoryUtil.ObjectsCalloutButtonParam) 

Fields

Name Type Description
filterBoxParam ObjectFilterBoxParam Parameters of the object picker shown in the callout.
gameCtx GameContext Game context; its callout container is used.

enum base/tealdef/gui/main/menu_category_util.d.tl:49

enum ObjectType

Notes

Kinds of objects for which createNoObject can create a "none" entry.

Used in the base game: 4 times in 3 files

base/content/gui/gui/construction/construction_react_util.tl:305

local makeFilterObjectsFn = function(rep : ResTypeRep<integer, table>, carrier : Carrier, objectType : MenuCategoryUtil.ObjectType, laneConfigs : {LaneConfig})
base/content/gui/gui/main/menu_category_util.tl:403
menu_category_util.createNoObject = function(objectType : MenuCategoryUtil.ObjectType) : MenuCategoryUtil.FilterObject
base/content/gui/gui/entity_window/bridge_and_tunnel.tl:9
local getAvailableObjects = function(rep : ResTypeRep<integer, BridgeType>, objectType : MenuCategoryUtil.ObjectType, stripInfo : UtilParallelStrip.StripInfo) :

Value Description
"Bridge" Bridge type ("No Bridge").
"Tunnel" Tunnel type ("No Tunnel").
"RailroadCrossing" Railroad crossing type; createNoObject currently returns nil for it.