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.
MenuCategoryUtil¶
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
filterCategoryLess(a : FilterCategory, b : FilterCategory) : boolean base/tealdef/gui/main/menu_category_util.d.tl:11
Call as menu_category_util.filterCategoryLess
Notes
Sort comparator for filter categories. "*" comes first, then sorting is by order, name and category.
Returns boolean
Used in the base game: 2 times in 2 files
base/content/gui/gui/construction/construction.tl:2315
base/content/gui/gui/construction/construction_react_util.tl:2789
fetchMenuFilterCategories() : {string : FilterCategory} base/tealdef/gui/main/menu_category_util.d.tl:12
Call as menu_category_util.fetchMenuFilterCategories
Notes
Loads all menu_filter_category resources.
Returns {string : FilterCategory}: The filter categories, keyed by category.
Used in the base game: 2 times in 2 files
base/content/gui/gui/construction/construction.tl:4330
base/content/gui/gui/construction/construction_react_util.tl:2782
createNoObject(objectType : ObjectType) : FilterObject base/tealdef/gui/main/menu_category_util.d.tl:54
Call as menu_category_util.createNoObject
Notes
Creates the "No Bridge" or "No Tunnel" entry (id -1, always available, sorted first).
Returns FilterObject: The entry, or nil for object types without such an entry.
Used in the base game: 2 times in 2 files
base/content/gui/gui/construction/construction_react_util.tl:310
base/content/gui/gui/entity_window/bridge_and_tunnel.tl:11
getIds(objects : {MenuCategoryUtil.FilterObject}) : {integer} base/tealdef/gui/main/menu_category_util.d.tl:56
Call as menu_category_util.getIds
Notes
Returns the ids of the given objects, in the same order.
Returns {integer}
getAvailableObjectsSorted(rep : ResTypeRep<integer, table>, year : integer, previousId? : integer) : {FilterObject} base/tealdef/gui/main/menu_category_util.d.tl:62
Call as menu_category_util.getAvailableObjectsSorted
get all objects based on rep which are available at the given year, sorted by the types inherent MenuCategory order
| Parameter | Type | Description |
|---|---|---|
rep |
ResTypeRep<integer, table> |
repository |
year |
integer |
year in-game |
previousId? |
integer |
optional id of the object which was previously selected, if it is available it will be included in the result regardless of the current year |
Returns {FilterObject}
MenuCategoryUtil.FilterCategory¶
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
Used in the base game: 23 times in 3 files
base/content/gui/gui/construction/construction.tl:45
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
Fields
MenuCategoryUtil.CategoryFilterPanelParam¶
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
Fields
| Name | Type | Description |
|---|---|---|
categories |
{MenuCategoryUtil.FilterCategory} |
Categories to show, one toggle button each. |
selection |
{boolean} |
Selected state per entry of categories. |
Functions
updateSelection(index : integer, isSelected : boolean) base/tealdef/gui/main/menu_category_util.d.tl:16
Notes
Called with the 1-based index of a category and its new selected state when the user toggles it.
isListEmpty() : boolean base/tealdef/gui/main/menu_category_util.d.tl:18
Notes
Returns whether the filtered list is empty; while it is, IA_OPTION2 cannot leave the panel.
Returns boolean
giveUpFocus() base/tealdef/gui/main/menu_category_util.d.tl:19
Notes
Called on IA_OPTION2 or IA_MENU_BACK to move the focus away from the panel (e.g. back to the object list).
MenuCategoryUtil.FilterObject¶
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
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
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 |
MenuCategoryUtil.ObjectFilterBoxParam¶
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
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
onSelectionChange(selectedObjectId : integer) base/tealdef/gui/main/menu_category_util.d.tl:37
Notes
Called with the id of the newly selected object.
onFilterChange(filteredObjectIds : {integer}) base/tealdef/gui/main/menu_category_util.d.tl:38
Notes
Called with the ids of the objects that pass the category filter after it changed.
MenuCategoryUtil.ObjectsCalloutButtonParam¶
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
Fields
| Name | Type | Description |
|---|---|---|
filterBoxParam |
ObjectFilterBoxParam |
Parameters of the object picker shown in the callout. |
gameCtx |
GameContext |
Game context; its callout container is used. |
MenuCategoryUtil.ObjectType¶
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
| Value | Description |
|---|---|
"Bridge" |
Bridge type ("No Bridge"). |
"Tunnel" |
Tunnel type ("No Tunnel"). |
"RailroadCrossing" |
Railroad crossing type; createNoObject currently returns nil for it. |