menu_icon_react_util¶
Source: base/tealdef/gui/menu/menu_icon_react_util.d.tl
Notes
Building blocks of the main menu pages (buttons, image cards, paged card grids, page frame, hint panel), loaded with ug_require "/gui/menu/menu_icon_react_util.tl".
MenuIconReactUtil¶
record global base/tealdef/gui/menu/menu_icon_react_util.d.tl:3
global record MenuIconReactUtil
Load: local menu_icon_react_util = ug_require "/gui/menu/menu_icon_react_util.tl"
Notes
Layout helpers and recipes for main menu pages.
Fields
| Name | Type | Description |
|---|---|---|
CardButton |
Recipe<CardButtonParams> |
Large menu button with cycling background images and a label at the bottom. used 3× in the base game |
HintWidget |
RecipeWithApi<HintWidgetParam, HintWidgetApi> |
Panel showing the title and description of the hint for the hovered item of the selected tab. used 6× in the base game |
HintImage |
RecipeWithApi<HintWidgetParam, HintWidgetApi> |
Default hint image of the settings pages. Its API functions do nothing. used 3× in the base game |
Functions
makeButton(text : string, onClick : function(), classes : string, enabled? : boolean, tooltip? : string, ref? : ReactRefWrap, textColorClass? : string, buttonClass? : string) : TreeNodeId base/tealdef/gui/menu/menu_icon_react_util.d.tl:21
Call as menu_icon_react_util.makeButton
Notes
Creates a text button.
| Parameter | Type | Description |
|---|---|---|
text |
string |
Button text. |
onClick |
function() |
Click handler. |
classes |
string |
Style classes of the button. |
enabled? |
boolean |
Whether the button is enabled. |
tooltip? |
string |
Tooltip text. |
ref? |
ReactRefWrap |
Optional node reference for the button. |
textColorClass? |
string |
Additional style class of the text. |
buttonClass? |
string |
Additional style class of the button, for example primary or secondary. |
Returns TreeNodeId
makeSecondaryButton(text : string, onClick : function(), classes? : string, enabled? : boolean, tooltip? : string, ref? : ReactRefWrap) : TreeNodeId base/tealdef/gui/menu/menu_icon_react_util.d.tl:31
Call as menu_icon_react_util.makeSecondaryButton
Notes
Creates a text button with the secondary style class (see makeButton).
Returns TreeNodeId
Used in the base game: 7 times in 4 files
base/content/gui/gui/menu/savegame_react_util.tl:1215
base/content/gui/gui/menu/advanced_settings.tl:578
base/content/gui/gui/menu/settings_page.tl:1510
base/content/gui/gui/menu/mod_selector_page.tl:296
makePrimaryButton(text : string, onClick : function(), classes? : string, enabled? : boolean, tooltip? : string, ref? : ReactRefWrap) : TreeNodeId base/tealdef/gui/menu/menu_icon_react_util.d.tl:39
Call as menu_icon_react_util.makePrimaryButton
Notes
Creates a text button with the primary style class (see makeButton).
Returns TreeNodeId
Used in the base game: 3 times in 3 files
base/content/gui/gui/menu/new_game_or_map_settings_page.tl:610
base/content/gui/gui/menu/savegame_react_util.tl:1138
base/content/gui/gui/menu/mod_selector_page.tl:293
makeCardButton(text : string, onClick : function(), onAttention : function(x : number, y : number), tooltip : string, images : {string | Builtin.ImageViewParam}, initialImageIndex : integer, imageSwapOffsetSeconds? : number, displayDurationSeconds? : number, class? : string, extraChildren? : {TreeNodeId}, enabled? : boolean) : TreeNodeId base/tealdef/gui/menu/menu_icon_react_util.d.tl:47
Call as menu_icon_react_util.makeCardButton
Notes
Creates a CardButton whose bottom label shows text as main card title.
Returns TreeNodeId
makeTabWidget(elements : {TreeNodeId}, maxNumPerPage : integer, makeEmptyElem : (function(last : boolean) : TreeNodeId), numRows : integer, selectedTabState : ReactStateT<integer>, ref? : ReactRefWrap) : TreeNodeId base/tealdef/gui/menu/menu_icon_react_util.d.tl:60
Call as menu_icon_react_util.makeTabWidget
Notes
Arranges elements in a grid of numRows rows with maxNumPerPage elements each. If they do not fit on one page, the pages become tabs with dot indicators, chevron buttons and mouse-wheel paging.
| Parameter | Type | Description |
|---|---|---|
elements |
{TreeNodeId} |
Elements to arrange. |
maxNumPerPage |
integer |
Number of elements per row. |
makeEmptyElem |
(function(last : boolean) : TreeNodeId) |
Creates the filler for empty cells; last is true for the last cell of a row. |
numRows |
integer |
Number of rows per page (default 2). |
selectedTabState |
ReactStateT<integer> |
State holding the index of the shown page. |
ref? |
ReactRefWrap |
Optional node reference. |
Returns TreeNodeId
Used in the base game: 3 times in 3 files
base/content/gui/gui/menu/campaign_page.tl:250
table.insert(tabs, menu_icon_react_util.makeTabWidget(cards, campaign and maxMissionsPerPage or maxCampaignsPerPage, function( lastElem : boolean ) : TreeNodeId
base/content/gui/gui/menu/releasenotes_window.tl:63
} or menu_icon_react_util.makeTabWidget(elements, 1, releasenotes_util.createEmpty, releaseNotes.infoItemsPerPage, tabIndexState, toSelect)
base/content/gui/gui/menu/new_game_page.tl:115
makePage(commonParams : CommonMenuParams, text : string, back : function(), centerItem : TreeNodeId, extra : {TreeNodeId}, campaignBriefingScreen? : boolean) : TreeNodeId base/tealdef/gui/menu/menu_icon_react_util.d.tl:68
Call as menu_icon_react_util.makePage
Notes
Creates the frame of a menu page with a background canvas, an optional centred item and a top bar with title and back button.
| Parameter | Type | Description |
|---|---|---|
commonParams |
CommonMenuParams |
Common parameters of the menu page. |
text |
string |
Page title; no top bar is created if nil. |
back |
function() |
Called by the back button and the IA_MENU_BACK input action. |
centerItem |
TreeNodeId |
Item placed in the centre of the page. |
extra |
{TreeNodeId} |
Additional floating layout children. |
campaignBriefingScreen? |
boolean |
Whether to use the campaign briefing style for the top bar. |
Returns TreeNodeId
Used in the base game: 15 times in 12 files
base/content/gui/gui/menu/new_game_or_map_settings_page.tl:1020
base/content/gui/gui/menu/campaign_page.tl:22
base/content/gui/gui/menu/license_page.tl:116
base/content/gui/gui/menu/load_game_page.tl:81
base/content/gui/gui/menu/mod_manager_page.tl:313
base/content/gui/gui/menu/settings_page.tl:2160
… and 6 more files.
makeCardLabelBottomComponent(textTitle : string, textDescription : string, textRight : string, postTitleChild : TreeNodeId, mainTitleCard : boolean) : TreeNodeId base/tealdef/gui/menu/menu_icon_react_util.d.tl:77
Call as menu_icon_react_util.makeCardLabelBottomComponent
Notes
Creates the bottom label of a card with title, optional description and optional right-aligned text on an effect background.
| Parameter | Type | Description |
|---|---|---|
textTitle |
string |
Title text. |
textDescription |
string |
Optional description below the title. |
textRight |
string |
Optional text on the right. |
postTitleChild |
TreeNodeId |
Optional element placed after the title. |
mainTitleCard |
boolean |
Whether to use the large title font of main cards. |
Returns TreeNodeId
makeMainOuterCard(addSpacer : boolean, children : {TreeNodeId}) : TreeNodeId base/tealdef/gui/menu/menu_icon_react_util.d.tl:85
Call as menu_icon_react_util.makeMainOuterCard
Notes
Wraps elements in the vertical main-outer-card container, optionally with a top spacer.
Returns TreeNodeId
Used in the base game: 8 times in 7 files
base/content/gui/gui/menu/new_game_or_map_settings_page.tl:1026
base/content/gui/gui/menu/load_game_page.tl:92
base/content/gui/gui/menu/mod_manager_page.tl:317
base/content/gui/gui/menu/settings_page.tl:2164
base/content/gui/gui/menu/achievements_page.tl:22
base/content/gui/gui/menu/save_game_page.tl:309
… and 1 more files.
makeTabAnalogue(headerChildren : {TreeNodeId}, bodyChildren : {TreeNodeId}) : TreeNodeId base/tealdef/gui/menu/menu_icon_react_util.d.tl:89
Call as menu_icon_react_util.makeTabAnalogue
Notes
Creates a container that looks like a tab widget, with a horizontal header row and a vertical body.
Returns TreeNodeId
Used in the base game: 3 times in 3 files
base/content/gui/gui/menu/load_game_page.tl:223
base/content/gui/gui/menu/achievements_page.tl:25
base/content/gui/gui/menu/save_game_page.tl:312
MenuIconReactUtil.CardButtonParams¶
record base/tealdef/gui/menu/menu_icon_react_util.d.tl:4
record CardButtonParams
Notes
Parameters of CardButton.
Used in the base game: 1 time in 1 file
base/content/gui/gui/menu/menu_icon_react_util.tl:75
Fields
| Name | Type | Description |
|---|---|---|
bottomComponent |
TreeNodeId |
Content of the label at the bottom of the card, for example from makeCardLabelBottomComponent. |
tooltip |
string |
Tooltip of the card. |
images |
{string | Builtin.ImageViewParam} |
Background images (paths or image view parameters). With more than one image they are shown in turn with a cross-fade. |
initialImageIndex |
integer |
Index of the first image to show (default 1). |
imageSwapOffsetSeconds |
number |
Time offset of the image cycle in seconds, to keep several cards from switching at the same moment (default 0). |
displayDurationSeconds |
number |
Time each image is shown, in seconds (default 24). |
class |
string |
Style class of the card (default small-card); main-menu-card is always added. |
extraChildren |
{TreeNodeId} |
Additional floating layout children placed on the card. |
localKey |
string |
Local key of the card button. |
enabled |
boolean |
Whether the card is enabled. |
clipper |
boolean |
Whether to clip the images to the card. |
Functions
onClick() base/tealdef/gui/menu/menu_icon_react_util.d.tl:6
Notes
Called when the card is clicked.
onAttention(x : number, y : number) base/tealdef/gui/menu/menu_icon_react_util.d.tl:7
Notes
Called when the card gets attention (hover or focus), with a position on the card (from the node's getPosition) for placing a popup next to it.
MenuIconReactUtil.HintWidgetParam¶
record base/tealdef/gui/menu/menu_icon_react_util.d.tl:94
record HintWidgetParam
Notes
Parameters of HintWidget and HintImage.
Used in the base game: 5 times in 2 files
base/content/gui/gui/menu/menu_icon_react_util.tl:761
menu_icon_react_util.HintWidget = react.RegisterRecipe("HintWidget", function(param : MenuIconReactUtil.HintWidgetParam) : TreeNodeId
base/content/gui/gui/menu/settings_page.tl:1539
Fields
| Name | Type | Description |
|---|---|---|
tabId2Hints |
{any : {Data}} |
integer|number|string |
selectedTab |
any |
integer|number|string |
placeHolderHint |
Data |
Hint shown when no item is hovered or the tab has no hints. |
MenuIconReactUtil.HintWidgetParam.Data¶
record base/tealdef/gui/menu/menu_icon_react_util.d.tl:95
record Data
Notes
Text of one hint.
Used in the base game: 11 times in 4 files
base/content/gui/gui/menu/new_game_or_map_settings_page.tl:753
base/content/gui/gui/menu/advanced_settings.tl:70
base/content/gui/gui/menu/settings_page.tl:1563
base/content/gui/gui/main/script_param_util.tl:605
Fields
| Name | Type | Description |
|---|---|---|
title |
string |
Hint title. |
description |
string |
Hint text. |
imagePath |
string |
Image of the hint; set by the settings page but not displayed by HintWidget or HintImage. |
MenuIconReactUtil.HintWidgetApi¶
record base/tealdef/gui/menu/menu_icon_react_util.d.tl:105
record HintWidgetApi
Notes
API of HintWidget for setting the hovered item.
Used in the base game: 3 times in 2 files
base/content/gui/gui/menu/menu_icon_react_util.tl:808
base/content/gui/gui/menu/settings_page.tl:1539
Functions
getHovered() : integer base/tealdef/gui/menu/menu_icon_react_util.d.tl:106
Notes
Returns the index of the hovered item (0 for none).
Returns integer
setHovered(index : integer) base/tealdef/gui/menu/menu_icon_react_util.d.tl:107
Notes
Sets the index of the hovered item, whose hint is then shown.