Skip to content

content_card

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

Note: collapsible elements should not get extraChildren

Notes

Content cards: the titled boxes that make up entity windows and similar panels. A card has a permanent part, an optional collapsible part that expands on click, and optional callout texts shown next to it on hover or focus.

ContentCard

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

global record ContentCard

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

Notes

Content card recipes and helpers.

Example

-- from sim_person_eow.script.tl
content_card.ContentCard{
    title = _("Locations"),
    recipeAndParamPermanent = content_card.makeRecipeAndParam(
        DestinationsTable,
        { personEntityId = extensionParams.entityId }
    ),
    gameCtx = extensionParams.gameCtx,
    showOnRightSide = extensionParams.showCalloutOnRightSide,
}

Fields

Name Type Description
InfoCalloutWrapper Recipe<CalloutWrapperParam> Wraps content (a recipe plus extra children) and shows calloutText in a callout beside it while it has attention. used 1× in the base game
ContentCard RecipeWithApi<ContentCardParam, ContentCardApi> A titled card with a permanent part, an optional collapsible part and optional callouts. used 98× in the base game

Functions

makeRecipeAndParam<T>(recipe : Recipe<T>, param : T) : RecipeAndParamErased base/tealdef/gui/main/content_card.d.tl:53

Call as content_card.makeRecipeAndParam

Notes

Bundles a recipe and its parameter into a RecipeAndParamErased for a content card.

Returns RecipeAndParamErased

Used in the base game: 61 times in 16 files

base/content/gui/gui/entity_window/entity_window_util.tl:770

recipeAndParamPermanent = content_card.makeRecipeAndParam(
base/content/gui/gui/entity_window/station_group/station_group.tl:874
recipeAndParamPermanent = content_card.makeRecipeAndParam(
base/content/gui/gui/entity_window/maintenance_station/maintenance_station_eow.script.tl:148
recipeAndParamPermanent = content_card.makeRecipeAndParam(
base/content/gui/gui/entity_window/warehouse/warehouse_eow.script.tl:112
recipeAndParamPermanent = content_card.makeRecipeAndParam(
base/content/gui/gui/entity_window/sim_person/sim_person_eow.script.tl:436
recipeAndParamPermanent = content_card.makeRecipeAndParam(
base/content/gui/gui/entity_window/animal/animal_eow.script.tl:48
recipeAndParamPermanent = content_card.makeRecipeAndParam(
… and 10 more files.

makeRecipe0(recipe : Recipe0) : RecipeAndParamErased base/tealdef/gui/main/content_card.d.tl:54

Call as content_card.makeRecipe0

Notes

Bundles a recipe without parameters into a RecipeAndParamErased (with an empty parameter table).

Returns RecipeAndParamErased

Used in the base game: 5 times in 1 file

base/content/gui/gui/game_bar/game_bar_widgets.tl:783

recipeAndParamPermanent = content_card.makeRecipe0(CalendarWeatherControl),

makeContentCardsCollapsibleFunctions(collapsibleCardsState : ReactStateT<{string : boolean}>, onlyOneExpandable : boolean) : function(string, boolean), function(string) base/tealdef/gui/main/content_card.d.tl:55

Call as content_card.makeContentCardsCollapsibleFunctions

Notes

Creates the expand/collapse functions for several content cards that share one state table keyed by card.

Parameter Type Description
collapsibleCardsState ReactStateT<{string : boolean}> React state holding the expanded flag per card key.
onlyOneExpandable boolean When true, expanding one card collapses all others.

Returns function(string, boolean), function(string): setExpanded(key, expanded) and isExpanded(key).

Example

-- from sim_person.tl
local collapsibleCardsState = react.useState({})
local updateCollapsibleState, isExpanded = content_card.makeContentCardsCollapsibleFunctions(collapsibleCardsState, true)
-- per card:
--   setCollapsibleExpanded = function(v) updateCollapsibleState(cardKey, v) end,
--   collapsibleExpanded = isExpanded(cardKey),
Used in the base game: 14 times in 14 files

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

local updateCollapsibleState, isExpanded = content_card.makeContentCardsCollapsibleFunctions(collapsibleCardsState, true)
base/content/gui/gui/entity_window/maintenance_station/maintenance_station.tl:48
local updateCollapsibleState, isExpanded = content_card.makeContentCardsCollapsibleFunctions(collapsibleCardsState, true)
base/content/gui/gui/entity_window/warehouse/warehouse.tl:45
local updateCollapsibleState, isExpanded = content_card.makeContentCardsCollapsibleFunctions(collapsibleCardsState, true)
base/content/gui/gui/entity_window/sim_person/sim_person.tl:125
local updateCollapsibleState, isExpanded = content_card.makeContentCardsCollapsibleFunctions(collapsibleCardsState, true)
base/content/gui/gui/entity_window/animal/animal.tl:32
local updateCollapsibleState, isExpanded = content_card.makeContentCardsCollapsibleFunctions(collapsibleCardsState, true)
base/content/gui/gui/entity_window/vehicle/vehicle.tl:231
local updateCollapsibleState, isExpanded = content_card.makeContentCardsCollapsibleFunctions(collapsibleCardsState, true)
… and 8 more files.

useShowCalloutOnRight(refWindow : ReactRefWrap) : boolean base/tealdef/gui/main/content_card.d.tl:56

Call as content_card.useShowCalloutOnRight

Notes

Hook that returns true while the given window is in the left half of the screen, so callouts should open on its right side.

Returns boolean

Used in the base game: 15 times in 15 files

base/content/gui/gui/game_bar/game_bar_widgets.tl:777

local showOnRightSide = content_card.useShowCalloutOnRight(refSelf)
base/content/gui/gui/entity_window/station_group/station_group.tl:824
local showOnRightSide = content_card.useShowCalloutOnRight(refSelf)
base/content/gui/gui/entity_window/maintenance_station/maintenance_station.tl:45
local showOnRightSide = content_card.useShowCalloutOnRight(refSelf)
base/content/gui/gui/entity_window/warehouse/warehouse.tl:17
local showOnRightSide = content_card.useShowCalloutOnRight(refSelf)
base/content/gui/gui/entity_window/sim_person/sim_person.tl:107
local showOnRightSide = content_card.useShowCalloutOnRight(refSelf)
base/content/gui/gui/entity_window/animal/animal.tl:29
local showOnRightSide = content_card.useShowCalloutOnRight(refSelf)
… and 9 more files.

makeInfoHint(hint : string, addIcon : boolean) : TreeNodeId base/tealdef/gui/main/content_card.d.tl:58

Call as content_card.makeInfoHint

Notes

Creates a small hint text, optionally with an info icon in front of it.

Returns TreeNodeId

Used in the base game: 6 times in 4 files

base/content/gui/gui/entity_window/entity_window_util.tl:1568

content_card.makeInfoHint(noPersonText, true),
base/content/gui/gui/entity_window/town/town.tl:754
content_card.makeInfoHint(params.hint, true),
base/content/gui/gui/entity_window/industry/industry_eow.script.tl:357
content_card.makeInfoHint(
base/content/game_mechanics/game_mechanics/finance/finances_cargo_lifetime.tl:339
content_card.makeInfoHint(

ContentCard.CalloutWrapperParam

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

record CalloutWrapperParam is IRecipeParamWithMeta

Notes

Parameters of InfoCalloutWrapper.

Used in the base game: 1 time in 1 file

base/content/gui/gui/main/content_card.tl:64

content_card.InfoCalloutWrapper = react.RegisterRecipe("InfoCalloutWrapper", function(param : ContentCard.CalloutWrapperParam) : TreeNodeId

Fields

Name Type Description
recipeAndParam ContentCard.RecipeAndParamErased Main content, built from a recipe and its parameter.
extraChildren {TreeNodeId} Note: only use these for elements that are always visible
separatorBetweenExtraChildren boolean When true, a separator is placed between the extraChildren.
calloutText string Text shown in a callout while the content has attention (hover or focus); empty text means no callout.
gameCtx GameContext Game context; its calloutContainerRef is used to open the callout.
showOnRightSide boolean When true, the callout opens to the right of the content, otherwise to the left.
isPermanent boolean Marks the permanent part of a card (adds the card outline and formatting and makes it focusable).
isCollapsibleButton boolean Marks content that is also the expand/collapse button of the card (style class is-button).
hovering boolean Adds the style class hovering.

ContentCard.RecipeAndParamErased

record base/tealdef/gui/main/content_card.d.tl:20

record RecipeAndParamErased

Notes

A recipe together with its parameter, stored without its parameter type; create it with makeRecipeAndParam or makeRecipe0.

Used in the base game: 5 times in 2 files

base/content/gui/gui/main/content_card.tl:191

content_card.makeRecipeAndParam = function<T>(recipe : Recipe<T>, param : T) : ContentCard.RecipeAndParamErased
base/content/gui/gui/entity_window/perk/perk_eow.script.tl:218
local recipeAndParamCollapsible : ContentCard.RecipeAndParamErased

Fields

Name Type Description
recipe Recipe<any> The recipe to call.
param any The parameter passed to the recipe.

ContentCard.ContentCardParam

record base/tealdef/gui/main/content_card.d.tl:25

record ContentCardParam

Notes

Parameters of ContentCard.

Used in the base game: 2 times in 1 file

base/content/gui/gui/main/content_card.tl:207

content_card.ContentCard = react.RegisterRecipe("ContentCard", function(param : ContentCard.ContentCardParam) : TreeNodeId

Fields

Name Type Description
title string Card title, shown as headline above the card; nil for no title.
initialCalloutTextPermanent string Initial callout text of the permanent part; change it later with ContentCardApi.setPermanentCalloutText.
recipeAndParamPermanent RecipeAndParamErased Content of the permanent (always visible) part.
extraChildrenPermanent {TreeNodeId} Additional nodes appended to the permanent part.
separatorBetweenExtraChildren boolean When true, a separator is placed between the extraChildrenPermanent.
hasPermanentFocusables boolean Set to true when the permanent part contains focusable elements, so that they stay focusable although the part is the collapse button.
initialCalloutTextCollapsible string Initial callout text of the collapsible part; change it later with ContentCardApi.setCollapsibleCalloutText.
recipeAndParamCollapsible RecipeAndParamErased Content of the collapsible part, shown only while collapsibleExpanded is true.
collapsibleExpanded boolean Whether the collapsible part is currently expanded; the card itself keeps no expanded state.
gameCtx GameContext Game context, used to open the callouts.
showOnRightSide boolean When true, callouts open to the right of the card (see useShowCalloutOnRight).

Functions

titleOnHoverFocus(isSelected : boolean) base/tealdef/gui/main/content_card.d.tl:27

Notes

Called with true/false when the title gains or loses attention (hover or focus).

setCollapsibleExpanded(boolean) base/tealdef/gui/main/content_card.d.tl:39

Notes

Called with the new expanded state when the user expands or collapses the card (click, or IA_MENU_BACK while expanded).

ContentCard.ContentCardApi

record base/tealdef/gui/main/content_card.d.tl:46

record ContentCardApi

Notes

API of a ContentCard node, available through its node reference.

Used in the base game: 2 times in 2 files

base/content/gui/gui/main/content_card.tl:455

end) as RecipeWithApi<ContentCard.ContentCardParam, ContentCard.ContentCardApi>
base/content/gui/gui/entity_window/town/town.tl:923
local contentCardApi : ContentCard.ContentCardApi = contentCardRef:getApi()

Functions

setPermanentCalloutText(string) base/tealdef/gui/main/content_card.d.tl:47

Notes

Replaces the callout text of the permanent part (nil is ignored).

setCollapsibleCalloutText(string) base/tealdef/gui/main/content_card.d.tl:48

Notes

Replaces the callout text of the collapsible part (nil is ignored).