Skip to content

callout_react_util

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

Notes

Recipes for callouts (small popups anchored to a node): a toggle button that opens a callout while it is pressed, and a default wrapper that draws callout content with an arrow. Callouts are shown by the callout container (CalloutApi), usually the one in GameContext.calloutContainerRef.

CalloutReactUtil

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

global record CalloutReactUtil

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

Notes

Recipes for toggle buttons that open callouts, and a default callout frame.

Fields

Name Type Description
ToggleCalloutButton Recipe<ToggleCalloutButtonParamsT<IRecipeParamWithMeta>> Toggle button that opens a callout with the given recipe while it is pressed. used 8× in the base game
DefaultCalloutWrapper Recipe<DefaultCalloutWrapperParamsT<IRecipeParamWithMeta>> Draws the content of recipe in a box with style class callout-content and a downward arrow below it. used 3× in the base game

CalloutReactUtil.ToggleCalloutButtonParamsT

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

record ToggleCalloutButtonParamsT<R is IRecipeParamWithMeta>

Notes

Parameters of the ToggleCalloutButton recipe.

Details

R is the parameter type of the recipe shown inside the callout.

Used in the base game: 4 times in 3 files

base/content/gui/gui/menu/mod_selector_page.tl:1566

as ReactRefWrapApiT<callout_react_util.ToggleCalloutButtonParamsT<IRecipeParamWithMeta>, callout_react_util.ToggleCalloutButtonApi>
base/content/gui/gui/main/callout_react_util.tl:62
callout_react_util.ToggleCalloutButton = react.RegisterRecipe("ToggleCalloutButton", function(params : CalloutReactUtil.ToggleCalloutButtonParamsT<IRecipeParamW
base/content/gui/gui/main/script_param_util.tl:234
as ReactRefWrapApiT<callout_react_util.ToggleCalloutButtonParamsT<IRecipeParamWithMeta>, callout_react_util.ToggleCalloutButtonApi>

Fields

Name Type Description
gameCtx GameContext Game context. Its calloutContainerRef is used when calloutContainerRef is not set.
button TreeNodeId Node shown as the content of the toggle button.
toggleButtonClass string Style class of the toggle button.
calloutContainerRef ReactRefWrapApi0<CalloutApi> Callout container to open the callout in. If nil, gameCtx.calloutContainerRef is used.
recipe Recipe<R> Recipe that builds the callout content.
recipeParam R Parameters passed to recipe.
anchor Vec2f Anchor point of the callout content, relative to its own size (0..1 per axis).
gravity Vec2f Point on the toggle button, relative to its size (0..1 per axis), where the callout is placed.
tooltip string Tooltip of the toggle button.

Functions

getPositionFn() : Vec2f base/tealdef/gui/main/callout_react_util.d.tl:16

overrides automatic placement

Returns Vec2f

recipeParamCompareFn(R, R) : boolean base/tealdef/gui/main/callout_react_util.d.tl:17

overrides default compare

Returns boolean

onOpenedChanged(boolean) base/tealdef/gui/main/callout_react_util.d.tl:19

Notes

Called with true when the callout opens and with false when it closes.

onValueChange(integer) base/tealdef/gui/main/callout_react_util.d.tl:21

Notes

If set, called with the toggle button's new value (0 or 1) instead of the default open/close handling.

Details

Without this callback, pressing the button opens the callout and releasing it closes it. With it, the recipe does not open or close the callout on clicks; the callback replaces that logic.

CalloutReactUtil.ToggleCalloutButtonApi

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

record ToggleCalloutButtonApi

Notes

API that ToggleCalloutButton provides through react.provideApi.

Used in the base game: 3 times in 2 files

base/content/gui/gui/menu/mod_selector_page.tl:1566

as ReactRefWrapApiT<callout_react_util.ToggleCalloutButtonParamsT<IRecipeParamWithMeta>, callout_react_util.ToggleCalloutButtonApi>
base/content/gui/gui/main/script_param_util.tl:234
as ReactRefWrapApiT<callout_react_util.ToggleCalloutButtonParamsT<IRecipeParamWithMeta>, callout_react_util.ToggleCalloutButtonApi>

Functions

close() base/tealdef/gui/main/callout_react_util.d.tl:26

Notes

Closes the callout and resets the toggle button if the callout is open.

CalloutReactUtil.DefaultCalloutWrapperParamsT

record base/tealdef/gui/main/callout_react_util.d.tl:30

record DefaultCalloutWrapperParamsT<R is IRecipeParamWithMeta> is IRecipeParamWithMeta

Notes

Parameters of the DefaultCalloutWrapper recipe.

Used in the base game: 2 times in 2 files

base/content/gui/gui/main/callout_react_util.tl:198

callout_react_util.DefaultCalloutWrapper = react.RegisterRecipe("DefaultCalloutWrapper", function(params : CalloutReactUtil.DefaultCalloutWrapperParamsT<IRecipe
base/content/game_mechanics/game_mechanics/celebrations/celebration_react_util.tl:20
local CelebrationCalloutWrapper = react.RegisterRecipe("CelebrationCalloutWrapper", function(param : CalloutReactUtil.DefaultCalloutWrapperParamsT<IRecipeParamW

Fields

Name Type Description
recipe Recipe<R> Recipe that builds the content inside the callout frame.
recipeParam R Parameters passed to recipe.