LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

TabbedMenu

Description
Number of menu buttons which can be modified by pages.
Parent
ScreenElement
Functions

addPage

Description
Add a page frame to be displayed in the menu at runtime. The page will be part of the in-game menu until restarting the game or removing the page again.
Definition
addPage(table pageFrameElement, int position, string tabIconFilename, table tabIconUVs, function enablingPredicateFunction)
Arguments
tablepageFrameElementFrameElement instance which is used as a page.
intpositionPosition index of added page, starting from left at 1 going to right.
stringtabIconFilenamePath to the texture file which contains the icon for the page tab in the header
tabletabIconUVsUV array for the tab icon. Format: {x, y, width, height} in pixels on the texture.
functionenablingPredicateFunction[optional] A function which returns the current enabling state of the page at any time. If the function returns true, the page should be enabled. If no argument is given, the page is always enabled.
Code
795function TabbedMenu:addPage(pageFrameElement, position, tabIconFilename, tabIconUVs, enablingPredicateFunction)
796 local pageRoot, actualPosition = self:registerPage(pageFrameElement, position, enablingPredicateFunction)
797 self:addPageTab(pageFrameElement, tabIconFilename, GuiUtils.getUVs(tabIconUVs))
798
799 local name = pageRoot.title
800 if name == nil then
801 name = self.l10n:getText("ui_" .. pageRoot.name)
802 end
803
804 self.pagingElement:addPage(string.upper(pageRoot.name), pageRoot, name, actualPosition)
805end

addPageTab

Description
Add a page tab in the menu header. Call this synchronously with TabbedMenu:registerPage() to ensure a correct order of pages and tabs.
Definition
addPageTab()
Code
235function TabbedMenu:addPageTab(frameController, iconFilename, iconUVs)
236 local tab = self.pagingTabTemplate:clone()
237 tab:fadeIn()
238 self.pagingTabList:addElement(tab)
239 self.pageTabs[frameController] = tab
240
241 local tabButton = tab:getDescendantByName(TabbedMenu.PAGE_TAB_TEMPLATE_BUTTON_NAME)
242 tabButton:setImageFilename(nil, iconFilename)
243 tabButton:setImageUVs(nil, iconUVs)
244
245 tabButton.onClickCallback = function()
246 self:onPageClicked(self.activeDetailPage)
247
248 local pageId = self.pagingElement:getPageIdByElement(frameController)
249 local pageMappingIndex = self.pagingElement:getPageMappingIndex(pageId)
250
251 self.pageSelector:setState(pageMappingIndex, true) -- set state with force event
252 end
253end

assignMenuButtonInfo

Description
Assign menu button information to the in-game menu buttons.
Definition
assignMenuButtonInfo()
Code
348function TabbedMenu:assignMenuButtonInfo(menuButtonInfo)
349 self:clearMenuButtonActions()
350
351 for i, button in ipairs(self.menuButton) do
352 local info = menuButtonInfo[i]
353 local hasInfo = info ~= nil
354 button:setVisible(hasInfo)
355
356 -- Do not show actions when the game is paused unless specified
357 if hasInfo and info.inputAction ~= nil and InputAction[info.inputAction] ~= nil then
358 button:setInputAction(info.inputAction)
359
360 local buttonText = info.text
361 if buttonText == nil and self.defaultMenuButtonInfoByActions[info.inputAction] ~= nil then
362 buttonText = self.defaultMenuButtonInfoByActions[info.inputAction].text
363 end
364 button:setText(buttonText)
365
366 local buttonClickCallback = info.callback or self.defaultButtonActionCallbacks[info.inputAction] or NO_CALLBACK
367
368 if GS_IS_MOBILE_VERSION then
369 if info.profile ~= nil then
370 button:applyProfile(info.profile)
371 else
372 button:applyProfile("buttonBack")
373 end
374 end
375
376 local sound = GuiSoundPlayer.SOUND_SAMPLES.CLICK
377 if info.inputAction == InputAction.MENU_BACK then
378 sound = GuiSoundPlayer.SOUND_SAMPLES.BACK
379 end
380
381 if info.clickSound ~= nil and info.clickSound ~= sound then
382 sound = info.clickSound
383
384 -- We need to activate the sound by hand so that it is also played for gamepad and keyboard input
385 -- as those are not triggered by the button
386 local oldButtonClickCallback = buttonClickCallback
387 buttonClickCallback = function (...)
388 self:playSample(sound)
389 self:setNextScreenClickSoundMuted()
390
391 return oldButtonClickCallback(...)
392 end
393
394 -- Deactivate sound on button to prevent double-sounds
395 button:setClickSound(GuiSoundPlayer.SOUND_SAMPLES.NONE)
396 else
397 button:setClickSound(sound)
398 end
399
400 local showForGameState = GS_IS_MOBILE_VERSION or (not self.paused or info.showWhenPaused)
401 local showForCurrentState = showForGameState or info.inputAction == InputAction.MENU_BACK
402
403 local disabled = info.disabled or not showForCurrentState
404 if not disabled then
405 if not TabbedMenu.DEFAULT_BUTTON_ACTIONS[info.inputAction] then
406 local _, eventId = self.inputManager:registerActionEvent(info.inputAction, InputBinding.NO_EVENT_TARGET, buttonClickCallback, false, true, false, true)
407 table.insert(self.customButtonEvents, eventId) -- store event ID to remove again on page change
408 else
409 self.buttonActionCallbacks[info.inputAction] = buttonClickCallback
410 end
411 end
412
413 button.onClickCallback = buttonClickCallback
414 button:setDisabled(disabled)
415 end
416 end
417
418 -- make sure that menu exit is always possible:
419 if self.buttonActionCallbacks[InputAction.MENU_BACK] == nil then
420 self.buttonActionCallbacks[InputAction.MENU_BACK] = self.clickBackCallback
421 end
422
423 self.buttonsPanel:invalidateLayout()
424end

clearMenuButtonActions

Description
Clear menu button actions, events and callbacks.
Definition
clearMenuButtonActions()
Code
335function TabbedMenu:clearMenuButtonActions()
336 for k in pairs(self.buttonActionCallbacks) do
337 self.buttonActionCallbacks[k] = nil
338 end
339
340 for i in ipairs(self.customButtonEvents) do
341 self.inputManager:removeActionEvent(self.customButtonEvents[i])
342 self.customButtonEvents[i] = nil
343 end
344end

delete

Description
Definition
delete()
Code
93function TabbedMenu:delete()
94 self.messageCenter:unsubscribeAll(self)
95 self.pagingTabTemplate:delete() -- need to delete the template here because we have unlinked it during setup
96
97 for _, tab in pairs(self.pageTabs) do
98 tab:delete()
99 end
100
101 TabbedMenu:superClass().delete(self)
102end

exitMenu

Description
Definition
exitMenu()
Code
125function TabbedMenu:exitMenu()
126 self:changeScreen(nil)
127end

getPageButtonInfo

Description
Get button actions and display information for a given menu page.
Definition
getPageButtonInfo()
Code
668function TabbedMenu:getPageButtonInfo(page)
669 local buttonInfo
670
671 if page:getHasCustomMenuButtons() then
672 buttonInfo = page:getMenuButtonInfo()
673 else
674 buttonInfo = self.defaultMenuButtonInfo
675 end
676
677 return buttonInfo
678end

goToPage

Description
Definition
goToPage()
Code
441function TabbedMenu:goToPage(page, muteSound)
442 local oldMute = self.muteSound
443 self.muteSound = muteSound
444
445 local index = self.pagingElement:getPageMappingIndexByElement(page)
446 if index ~= nil then
447 self.pageSelector:setState(index, true)
448 end
449
450 self.muteSound = oldMute
451end

makeSelfCallback

Description
Definition
makeSelfCallback()
Code
863function TabbedMenu:makeSelfCallback(func)
864 return function(...)
865 return func(self, ...)
866 end
867end

new

Description
Definition
new()
Code
51function TabbedMenu.new(target, customMt, messageCenter, l10n, inputManager)
52 local self = ScreenElement.new(target, customMt or TabbedMenu_mt)
53
54 self:registerControls(TabbedMenu.CONTROLS)
55
56 self.messageCenter = messageCenter
57 self.l10n = l10n
58 self.inputManager = inputManager
59
60 self.pageFrames = {} -- FrameElement instances array in order of display
61 self.pageTabs = {} -- Page tabs in the header, {FrameElement -> ListItemElement}
62 self.pageTypeControllers = {} -- Mapping of page FrameElement sub-classes to the controller instances
63 self.pageRoots = {} -- Mapping of page controller instances to their original root GuiElements
64 self.pageEnablingPredicates = {} -- Mapping of page controller instances to enabling predicate functions (if return true -> enable)
65 self.disabledPages = {} -- hash of disabled paging controllers to avoid re-activation in updatePages()
66 self.pageToTabIndex = {}
67
68 self.currentPageId = 1
69 self.currentPageName = "" -- currently active page name for focus context setting
70 self.currentPage = nil -- current page controller reference
71
72 self.restorePageIndex = 1 -- memorized menu page mapping index (initialize on index 1 for the map overview)
73 self.restorePageScrollIndex = 1
74
75 self.buttonActionCallbacks = {} -- InputAction name -> function
76 self.defaultButtonActionCallbacks = {} -- InputAction name -> function
77 self.defaultMenuButtonInfoByActions = {}
78 self.customButtonEvents = {} -- array of event IDs from InputBinding
79
80 self.clickBackCallback = NO_CALLBACK
81
82 self.frameClosePageNextCallback = self:makeSelfCallback(self.onPageNext)
83 self.frameClosePagePreviousCallback = self:makeSelfCallback(self.onPagePrevious)
84
85 -- Subclass configuration
86 self.performBackgroundBlur = false
87
88 return self
89end

onButtonBack

Description
Definition
onButtonBack()
Code
687function TabbedMenu:onButtonBack()
688 self:exitMenu()
689end

onClickActivate

Description
Handle menu activate input event. Bound to save the game.
Definition
onClickActivate()
Code
513function TabbedMenu:onClickActivate()
514 local eventUnused = TabbedMenu:superClass().onClickActivate(self)
515 if eventUnused then
516 eventUnused = self:onMenuActionClick(InputAction.MENU_ACTIVATE)
517 end
518
519 return eventUnused
520end

onClickBack

Description
Handle menu back input event.
Definition
onClickBack()
Code
485function TabbedMenu:onClickBack()
486 local eventUnused = true
487
488 if self.currentPage:requestClose(self.clickBackCallback) then
489 eventUnused = TabbedMenu:superClass().onClickBack(self)
490 if eventUnused then
491 eventUnused = self:onMenuActionClick(InputAction.MENU_BACK)
492 end
493 end
494
495 return eventUnused
496end

onClickCancel

Description
Handle menu cancel input event. Bound to quite the game to the main menu.
Definition
onClickCancel()
Code
501function TabbedMenu:onClickCancel()
502 local eventUnused = TabbedMenu:superClass().onClickCancel(self)
503 if eventUnused then
504 eventUnused = self:onMenuActionClick(InputAction.MENU_CANCEL)
505 end
506
507 return eventUnused
508end

onClickMenuExtra1

Description
Handle menu extra 1 input event. Used for various functions when convenient buttons run out.
Definition
onClickMenuExtra1()
Code
525function TabbedMenu:onClickMenuExtra1()
526 local eventUnused = TabbedMenu:superClass().onClickMenuExtra1(self)
527 if eventUnused then
528 eventUnused = self:onMenuActionClick(InputAction.MENU_EXTRA_1)
529 end
530
531 return eventUnused
532end

onClickMenuExtra2

Description
Handle menu extra 2 input event. Used for various functions when convenient buttons run out.
Definition
onClickMenuExtra2()
Code
537function TabbedMenu:onClickMenuExtra2()
538 local eventUnused = TabbedMenu:superClass().onClickMenuExtra2(self)
539 if eventUnused then
540 eventUnused = self:onMenuActionClick(InputAction.MENU_EXTRA_2)
541 end
542
543 return eventUnused
544end

onClickOk

Description
Handle menu confirmation input event.
Definition
onClickOk()
Code
477function TabbedMenu:onClickOk()
478 -- do not call the super class event here so we can always handle this event any way we need
479 local eventUnused = self:onMenuActionClick(InputAction.MENU_ACCEPT)
480 return eventUnused
481end

onClickPageSelection

Description
Handle activation of page selection.
Definition
onClickPageSelection()
Code
548function TabbedMenu:onClickPageSelection(state)
549 -- Mobile uses the header for paging within the frame
550 if self.pagingElement:setPage(state) and not self.muteSound then
551 self:playSample(GuiSoundPlayer.SOUND_SAMPLES.PAGING)
552 end
553end

onClose

Description
Handle in-game menu closing event.
Definition
onClose()
Code
178function TabbedMenu:onClose(element)
179 if self.currentPage ~= nil then
180 self.currentPage:onFrameClose() -- the current page gets its specific close event first
181 end
182
183 TabbedMenu:superClass().onClose(self)
184
185 if self.performBackgroundBlur then
186 g_depthOfFieldManager:popArea()
187 end
188
189 self.inputManager:storeEventBindings() -- reset any disabled bindings for page custom input in menu context
190 self:clearMenuButtonActions()
191
192 self.restorePageIndex = self.pageSelector:getState()
193 self.restorePageScrollIndex = self.pagingTabList.firstVisibleItem
194
195 if self.gameState ~= nil then
196 g_currentMission:resetGameState()
197 end
198end

onGuiSetupFinished

Description
Definition
onGuiSetupFinished()
Code
106function TabbedMenu:onGuiSetupFinished()
107 TabbedMenu:superClass().onGuiSetupFinished(self)
108
109 self.clickBackCallback = self:makeSelfCallback(self.onButtonBack)
110
111 -- take the tab template out of the element hierarchy, later we clone it as needed (and delete it separately)
112 self.pagingTabTemplate:unlinkElement()
113
114 self:setupMenuButtonInfo()
115
116 self.header.parent:addElement(self.header) -- re-add (will remove first, does not copy) header as last child to draw on top
117
118 if self.pagingElement.profile == "uiInGameMenuPaging" then
119 self.pagingElement:setSize(1 - self.header.absSize[1])
120 end
121end

onMenuActionClick

Description
Handle a menu action click by calling one of the menu button callbacks.
Definition
onMenuActionClick()
Return Values
boolTrueif no callback was present and no action was taken, false otherwise
Code
466function TabbedMenu:onMenuActionClick(menuActionName)
467 local buttonCallback = self.buttonActionCallbacks[menuActionName]
468 if buttonCallback ~= nil and buttonCallback ~= NO_CALLBACK then
469 return buttonCallback() or false
470 end
471
472 return true
473end

onMenuOpened

Description
Called when opening the menu, after changing the page
Definition
onMenuOpened()
Code
693function TabbedMenu:onMenuOpened()
694end

onOpen

Description
Handle in-game menu opening event.
Definition
onOpen()
Code
144function TabbedMenu:onOpen(element)
145 TabbedMenu:superClass().onOpen(self)
146
147 if self.performBackgroundBlur then
148 g_depthOfFieldManager:pushArea(0, 0, 1, 1)
149 end
150
151 if not self.muteSound then
152 self:playSample(GuiSoundPlayer.SOUND_SAMPLES.PAGING)
153 end
154
155 if self.gameState ~= nil then
156 g_gameStateManager:setGameState(self.gameState)
157 end
158
159 -- Disable all focus sounds. We play our own for opening the menu
160 self:setSoundSuppressed(true)
161
162 -- setup menus
163 self:updatePages()
164
165 -- restore last selected page
166 if self.restorePageIndex ~= nil then
167 self.pageSelector:setState(self.restorePageIndex, true)
168 self.pagingTabList:scrollTo(self.restorePageScrollIndex)
169 end
170
171 self:setSoundSuppressed(false)
172
173 self:onMenuOpened()
174end

onPageChange

Description
Handle changing to another menu page.
Definition
onPageChange()
Code
585function TabbedMenu:onPageChange(pageIndex, pageMappingIndex, element, skipTabVisualUpdate)
586 -- ask the paging element for the current page which is safer than the currentPage reference (may not be initialized)
587 local prevPage = self.pagingElement:getPageElementByIndex(self.currentPageId)
588
589 prevPage:onFrameClose()
590 prevPage:setVisible(false)
591
592 self.inputManager:storeEventBindings() -- reset any disabled bindings for page custom input in menu context
593
594 local page = self.pagingElement:getPageElementByIndex(pageIndex)
595 self.currentPage = page
596 self.currentPageName = page.name -- store page name for FocusManager GUI context override in update()
597
598 if not skipTabVisualUpdate then
599 local oldIndex = self.pageToTabIndex[self.currentPageId]
600 self.currentPageId = pageIndex
601
602 local listIndex = self.pageToTabIndex[pageIndex]
603 if listIndex ~= nil then
604 local direction = MathUtil.sign(listIndex - oldIndex)
605 self.pagingTabList:setSelectedIndex(listIndex, true, direction)
606 end
607 end
608
609 page:setVisible(true)
610 page:setSoundSuppressed(true)
611 FocusManager:setGui(page.name)
612 page:setSoundSuppressed(false)
613 page:onFrameOpen()
614
615 self:updateButtonsPanel(page)
616 self:updateTabDisplay()
617end

onPageClicked

Description
Definition
onPageClicked()
Code
257function TabbedMenu:onPageClicked(oldPage)
258end

onPageNext

Description
Handle next page event.
Definition
onPageNext()
Code
571function TabbedMenu:onPageNext()
572 if GS_IS_MOBILE_VERSION then
573 if self.currentPage:getHasNextPage() then
574 self.currentPage:onNextPage()
575 end
576 else
577 if self.currentPage:requestClose(self.frameClosePageNextCallback) then
578 TabbedMenu:superClass().onPageNext(self)
579 end
580 end
581end

onPagePrevious

Description
Handle previous page event.
Definition
onPagePrevious()
Code
557function TabbedMenu:onPagePrevious()
558 if GS_IS_MOBILE_VERSION then
559 if self.currentPage:getHasPreviousPage() then
560 self.currentPage:onPreviousPage()
561 end
562 else
563 if self.currentPage:requestClose(self.frameClosePagePreviousCallback) then
564 TabbedMenu:superClass().onPagePrevious(self)
565 end
566 end
567end

onPageUpdate

Description
Handle a page being disabled.
Definition
onPageUpdate()
Code
682function TabbedMenu:onPageUpdate()
683end

rebuildTabList

Description
Rebuild page tab list in order.
Definition
rebuildTabList()
Code
270function TabbedMenu:rebuildTabList()
271 self.pageToTabIndex = {}
272
273 -- removeAllitems does not work... so we do it manually
274 for i = #self.pagingTabList.listItems, 1, -1 do
275 local tab = self.pagingTabList.listItems[i]
276 self.pagingTabList:removeElement(tab)
277 end
278
279 for i, page in ipairs(self.pageFrames) do
280 local tab = self.pageTabs[page]
281
282 local pageId = self.pagingElement:getPageIdByElement(page)
283 local enabled = not self.pagingElement:getIsPageDisabled(pageId)
284
285 -- Add any enabled item. List will scroll for us to keep selection in view
286 if enabled then
287 self.pagingTabList:addElement(tab)
288 self.pageToTabIndex[i] = #self.pagingTabList.listItems
289 end
290 end
291
292 self.pagingTabList.firstVisibleItem = 1
293
294
295 local listIndex = self.pageToTabIndex[self.currentPageId]
296 if listIndex ~= nil then
297 local direction = 0--MathUtil.sign(listIndex - oldIndex)
298 self.pagingTabList:setSelectedIndex(listIndex, true, direction)
299 end
300end

registerPage

Description
Register a page frame element in the menu. This does not add the page to the paging component of the menu.
Definition
registerPage(table pageFrameElement, int position, function enablingPredicateFunction)
Arguments
tablepageFrameElementPage FrameElement instance
intposition[optional] Page position index in menu
functionenablingPredicateFunction[optional] A function which returns the current enabling state of the page at any time. If the function returns true, the page should be enabled. If no argument is given, the page is always enabled.
Code
719function TabbedMenu:registerPage(pageFrameElement, position, enablingPredicateFunction)
720 if position == nil then
721 position = #self.pageFrames + 1
722 else
723 position = math.max(1, math.min(#self.pageFrames + 1, position))
724 end
725
726 table.insert(self.pageFrames, position, pageFrameElement)
727 self.pageTypeControllers[pageFrameElement:class()] = pageFrameElement
728 local pageRoot = pageFrameElement.elements[1]
729 self.pageRoots[pageFrameElement] = pageRoot
730 self.pageEnablingPredicates[pageFrameElement] = enablingPredicateFunction
731
732 pageFrameElement:setVisible(false) -- set invisible at the start to allow visibility-based behavior for pages
733
734 return pageRoot, position
735end

removePage

Description
Remove a page from the menu at runtime by its class type. The removed page is also deleted, including all of its children. Note that this method removes the page for an entire game run, because the UI is loaded on game start. If you only need to disable a page, use TabbedMenu:setPageEnabled() instead. The method will not remove game default pages, but only disable them.
Definition
removePage(table pageFrameClass)
Arguments
tablepageFrameClassClass table of a FrameElement sub-class
Code
819function TabbedMenu:removePage(pageFrameClass)
820 local defaultPage = self.pageTypeControllers[pageFrameClass]
821 if self.defaultPageElementIDs[defaultPage] ~= nil then
822 self:setPageEnabled(pageFrameClass, false)
823 else
824 local needDelete, pageController, pageRoot, pageTab = self:unregisterPage(pageFrameClass)
825 if needDelete then
826 self.pagingElement:removeElement(pageRoot)
827 pageRoot:delete()
828 pageController:delete()
829
830 self.pagingTabList:removeElement(pageTab)
831 pageTab:delete()
832 end
833 end
834end

reset

Description
Definition
reset()
Code
131function TabbedMenu:reset()
132 TabbedMenu:superClass().reset(self)
133
134 self.currentPageId = 1
135 self.currentPageName = ""
136 self.currentPage = nil
137
138 self.restorePageIndex = 1
139 self.restorePageScrollIndex = 1
140end

setPageEnabled

Description
Set the enabled state of a page identified by its controller class type. This will also set the controller's state, so it can react to being enabled/disabled. The setting will persist through calls to TabbedMenu:reset() and must be reverted manually, if necessary.
Definition
setPageEnabled(table pageFrameClass, bool isEnabled)
Arguments
tablepageFrameClassClass table of a FrameElement sub-class
boolisEnabledTrue for enabled, false for disabled
Code
842function TabbedMenu:setPageEnabled(pageFrameClass, isEnabled)
843 local pageController = self.pageTypeControllers[pageFrameClass]
844 if pageController ~= nil then
845 local pageId = self.pagingElement:getPageIdByElement(pageController)
846 self.pagingElement:setPageIdDisabled(pageId, not isEnabled)
847
848 pageController:setDisabled(not isEnabled)
849
850 if not isEnabled then
851 self.disabledPages[pageController] = pageController
852 else
853 self.disabledPages[pageController] = nil
854 end
855
856 self:setPageTabEnabled(pageController, isEnabled)
857 self.pagingTabList:updateItemPositions()
858 end
859end

setPageSelectorTitles

Description
Get page titles from currently visible pages and apply to the selector element.
Definition
setPageSelectorTitles()
Code
428function TabbedMenu:setPageSelectorTitles()
429 local texts = self.pagingElement:getPageTitles()
430
431 self.pageSelector:setTexts(texts)
432 self.pageSelector:setDisabled(#texts == 1)
433
434 -- Update state without triggering any events
435 local id = self.pagingElement:getCurrentPageId()
436 self.pageSelector.state = self.pagingElement:getPageMappingIndex(id)
437end

setPageTabEnabled

Description
Set enabled state of a page tab in the header.
Definition
setPageTabEnabled()
Code
262function TabbedMenu:setPageTabEnabled(pageController, isEnabled)
263 local tab = self.pageTabs[pageController]
264 tab:setDisabled(not isEnabled)
265 tab:setVisible(isEnabled)
266end

setupMenuButtonInfo

Description
Setup the menu buttons. Override to initialize
Definition
setupMenuButtonInfo()
Code
229function TabbedMenu:setupMenuButtonInfo()
230end

unregisterPage

Description
Unregister a page frame element identified by class from the menu. This does not remove the page from the paging component of the menu or the corresponding page tab from the header.
Definition
unregisterPage(table pageFrameClass)
Arguments
tablepageFrameClassFrameElement descendant class of a page which was previously registered
Return Values
boolTrueif there was a page of the given class and it was unregistered
tableUnregisteredpage controller instance or nil
tableUnregisteredpage root GuiElement instance or nil
tableUnregisteredpage tab ListElement instance of nil
Code
746function TabbedMenu:unregisterPage(pageFrameClass)
747 local pageController = self.pageTypeControllers[pageFrameClass]
748 local pageTab = nil
749 local pageRoot = nil
750 if pageController ~= nil then
751 local pageRemoveIndex = -1
752 for i, page in ipairs(self.pageFrames) do
753 if page == pageController then
754 pageRemoveIndex = i
755 break
756 end
757 end
758
759 table.remove(self.pageFrames, pageRemoveIndex)
760
761 pageRoot = self.pageRoots[pageController]
762 self.pageRoots[pageController] = nil
763 self.pageTypeControllers[pageFrameClass] = nil
764 self.pageEnablingPredicates[pageController] = nil
765
766 self.pageTabs[pageController] = nil
767 end
768
769 return pageController ~= nil, pageController, pageRoot, pageTab
770end

update

Description
Update the menu state each frame. This uses a state machine approach for the game saving process.
Definition
update()
Code
203function TabbedMenu:update(dt)
204 TabbedMenu:superClass().update(self, dt)
205
206 -- Enforce the current page as the focus context. This is required because dialogs on dialogs (e.g. during saving)
207 -- can break reverting to a valid focus state in this menu.
208 if FocusManager.currentGui ~= self.currentPageName and not g_gui:getIsDialogVisible() then
209 FocusManager:setGui(self.currentPageName)
210 end
211
212 if self.currentPage ~= nil then
213 if self.currentPage:isMenuButtonInfoDirty() then
214 self:assignMenuButtonInfo(self.currentPage:getMenuButtonInfo())
215 self.currentPage:clearMenuButtonInfoDirty()
216 end
217 if self.currentPage:isTabbingMenuVisibleDirty() then
218 self:updatePagingVisibility(self.currentPage:getTabbingMenuVisible())
219 end
220 end
221end

updateButtonsPanel

Description
Update the buttons panel when a given page is visible.
Definition
updateButtonsPanel()
Code
628function TabbedMenu:updateButtonsPanel(page)
629 -- assign button info anyway to make at least MENU_BACK work in all cases:
630 local buttonInfo = self:getPageButtonInfo(page)
631 self:assignMenuButtonInfo(buttonInfo)
632end

updatePageControlVisibility

Description
Definition
updatePageControlVisibility()
Code
326function TabbedMenu:updatePageControlVisibility()
327 local showButtons = #self.pagingTabList.listItems ~= 1
328
329 self.pagingButtonLeft:setVisible(showButtons)
330 self.pagingButtonRight:setVisible(showButtons)
331end

updatePages

Description
Update page enabled states.
Definition
updatePages()
Code
304function TabbedMenu:updatePages()
305 for pageElement, predicate in pairs(self.pageEnablingPredicates) do
306 local pageId = self.pagingElement:getPageIdByElement(pageElement)
307 local enable = self.disabledPages[pageElement] == nil and predicate()
308
309 self.pagingElement:setPageIdDisabled(pageId, not enable)
310 self:setPageTabEnabled(pageElement, enable)
311 end
312
313 self:rebuildTabList()
314 self:updatePageTabDisplay()
315 self:setPageSelectorTitles()
316 self:updatePageControlVisibility()
317end

updatePageTabDisplay

Description
Update page tabs display after any page changes.
Definition
updatePageTabDisplay()
Code
321function TabbedMenu:updatePageTabDisplay()
322end

updatePagingVisibility

Description
Definition
updatePagingVisibility()
Code
455function TabbedMenu:updatePagingVisibility(visible)
456 self.header:setVisible(visible)
457end