LUADOC - Farming Simulator 19

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
712function TabbedMenu:addPage(pageFrameElement, position, tabIconFilename, tabIconUVs, enablingPredicateFunction)
713 local pageRoot, actualPosition = self:registerPage(pageFrameElement, position, enablingPredicateFunction)
714 self:addPageTab(pageFrameElement, tabIconFilename, getNormalizedUVs(tabIconUVs))
715
716 local name = pageRoot.title
717 if name == nil then
718 name = self.l10n:getText("ui_" .. pageRoot.name)
719 end
720
721 self.pagingElement:addPage(string.upper(pageRoot.name), pageRoot, name, actualPosition)
722end

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
213function TabbedMenu:addPageTab(frameController, iconFilename, iconUVs)
214 local tab = self.pagingTabTemplate:clone()
215 tab:fadeIn()
216 self.pagingTabList:addElement(tab)
217 self.pageTabs[frameController] = tab
218
219 local tabButton = tab:getDescendantByName(TabbedMenu.PAGE_TAB_TEMPLATE_BUTTON_NAME)
220 tabButton:setImageFilename(nil, iconFilename)
221 tabButton:setImageUVs(nil, iconUVs)
222
223 tabButton.onClickCallback = function()
224 self:onPageClicked(self.activeDetailPage)
225
226 local pageId = self.pagingElement:getPageIdByElement(frameController)
227 local pageMappingIndex = self.pagingElement:getPageMappingIndex(pageId)
228
229 self.pageSelector:setState(pageMappingIndex, true) -- set state with force event
230 end
231end

assignMenuButtonInfo

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

clearMenuButtonActions

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

delete

Description
Definition
delete()
Code
88function TabbedMenu:delete()
89 self.messageCenter:unsubscribeAll(self)
90 self.pagingTabTemplate:delete() -- need to delete the template here because we have unlinked it during setup
91
92 TabbedMenu:superClass().delete(self)
93end

exitMenu

Description
Definition
exitMenu()
Code
112function TabbedMenu:exitMenu()
113 self:changeScreen(nil)
114end

getPageButtonInfo

Description
Get button actions and display information for a given menu page.
Definition
getPageButtonInfo()
Code
596function TabbedMenu:getPageButtonInfo(page)
597 local buttonInfo = TabbedMenu.NO_BUTTON_INFO -- makes all buttons invisible
598
599 if page:getHasCustomMenuButtons() then
600 buttonInfo = page:getMenuButtonInfo()
601 else
602 buttonInfo = self.defaultMenuButtonInfo
603 end
604
605 return buttonInfo
606end

goToPage

Description
Definition
goToPage()
Code
425function TabbedMenu:goToPage(page)
426 local index = self.pagingElement:getPageIndexByElement(page)
427 if index ~= nil then
428 self.pageSelector:setState(index, true)
429 end
430end

makeSelfCallback

Description
Definition
makeSelfCallback()
Code
780function TabbedMenu:makeSelfCallback(func)
781 return function(...)
782 return func(self, ...)
783 end
784end

new

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

onButtonBack

Description
Definition
onButtonBack()
Code
615function TabbedMenu:onButtonBack()
616 self:exitMenu()
617end

onClickActivate

Description
Handle menu activate input event. Bound to save the game.
Definition
onClickActivate()
Code
486function TabbedMenu:onClickActivate()
487 local eventUnused = TabbedMenu:superClass().onClickActivate(self)
488 if eventUnused then
489 eventUnused = self:onMenuActionClick(InputAction.MENU_ACTIVATE)
490 end
491
492 return eventUnused
493end

onClickBack

Description
Handle menu back input event.
Definition
onClickBack()
Code
458function TabbedMenu:onClickBack()
459 local eventUnused = true
460
461 if self.currentPage:requestClose(self.clickBackCallback) then
462 eventUnused = TabbedMenu:superClass().onClickBack(self)
463 if eventUnused then
464 eventUnused = self:onMenuActionClick(InputAction.MENU_BACK)
465 end
466 end
467
468 return eventUnused
469end

onClickCancel

Description
Handle menu cancel input event. Bound to quite the game to the main menu.
Definition
onClickCancel()
Code
474function TabbedMenu:onClickCancel()
475 local eventUnused = TabbedMenu:superClass().onClickCancel(self)
476 if eventUnused then
477 eventUnused = self:onMenuActionClick(InputAction.MENU_CANCEL)
478 end
479
480 return eventUnused
481end

onClickMenuExtra1

Description
Handle menu extra 1 input event. Used for various functions when convenient buttons run out.
Definition
onClickMenuExtra1()
Code
498function TabbedMenu:onClickMenuExtra1()
499 local eventUnused = TabbedMenu:superClass().onClickMenuExtra1(self)
500 if eventUnused then
501 eventUnused = self:onMenuActionClick(InputAction.MENU_EXTRA_1)
502 end
503
504 return eventUnused
505end

onClickMenuExtra2

Description
Handle menu extra 2 input event. Used for various functions when convenient buttons run out.
Definition
onClickMenuExtra2()
Code
510function TabbedMenu:onClickMenuExtra2()
511 local eventUnused = TabbedMenu:superClass().onClickMenuExtra2(self)
512 if eventUnused then
513 eventUnused = self:onMenuActionClick(InputAction.MENU_EXTRA_2)
514 end
515
516 return eventUnused
517end

onClickOk

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

onClickPageSelection

Description
Handle activation of page selection.
Definition
onClickPageSelection()
Code
521function TabbedMenu:onClickPageSelection(state)
522 if self.pagingElement:setPage(state) then
523 self:playSample(GuiSoundPlayer.SOUND_SAMPLES.PAGING)
524 end
525end

onClose

Description
Handle in-game menu closing event.
Definition
onClose()
Code
162function TabbedMenu:onClose(element)
163 if self.currentPage ~= nil then
164 self.currentPage:onFrameClose() -- the current page gets its specific close event first
165 end
166
167 TabbedMenu:superClass().onClose(self)
168
169 if self.performBackgroundBlur then
170 g_depthOfFieldManager:setBlurState(false)
171 end
172
173 self.inputManager:storeEventBindings() -- reset any disabled bindings for page custom input in menu context
174 self:clearMenuButtonActions()
175
176 self.restorePageIndex = self.pageSelector:getState()
177
178 if self.gameState ~= nil then
179 g_currentMission:resetGameState()
180 end
181end

onGuiSetupFinished

Description
Definition
onGuiSetupFinished()
Code
97function TabbedMenu:onGuiSetupFinished()
98 TabbedMenu:superClass().onGuiSetupFinished(self)
99
100 self.clickBackCallback = self:makeSelfCallback(self.onButtonBack)
101
102 -- take the tab template out of the element hierarchy, later we clone it as needed (and delete it separately)
103 self.pagingTabTemplate:unlinkElement()
104
105 self:setupMenuButtonInfo()
106
107 self.header.parent:addElement(self.header) -- re-add (will remove first, does not copy) header as last child to draw on top
108end

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
439function TabbedMenu:onMenuActionClick(menuActionName)
440 local buttonCallback = self.buttonActionCallbacks[menuActionName]
441 if buttonCallback ~= nil and buttonCallback ~= NO_CALLBACK then
442 return buttonCallback() or false
443 end
444
445 return true
446end

onMenuOpened

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

onOpen

Description
Handle in-game menu opening event.
Definition
onOpen()
Code
130function TabbedMenu:onOpen(element)
131 TabbedMenu:superClass().onOpen(self)
132
133 if self.performBackgroundBlur then
134 g_depthOfFieldManager:setBlurState(true)
135 end
136
137 self:playSample(GuiSoundPlayer.SOUND_SAMPLES.PAGING)
138
139 if self.gameState ~= nil then
140 g_gameStateManager:setGameState(self.gameState)
141 end
142
143 -- Disable all focus sounds. We play our own for opening the menu
144 self:setSoundSuppressed(true)
145
146 -- setup menus
147 self:updatePages()
148
149 -- restore last selected page
150 local restorePageMappingIndex = 1
151 if self.restorePageIndex ~= nil then
152 self.pageSelector:setState(self.restorePageIndex, true)
153 end
154
155 self:setSoundSuppressed(false)
156
157 self:onMenuOpened()
158end

onPageChange

Description
Handle changing to another menu page.
Definition
onPageChange()
Code
545function TabbedMenu:onPageChange(pageIndex, pageMappingIndex, element, skipTabVisualUpdate)
546 -- ask the paging element for the current page which is safer than the currentPage reference (may not be initialized)
547 local prevPage = self.pagingElement:getPageElementByIndex(self.currentPageId)
548 prevPage:onFrameClose()
549 prevPage:setVisible(false)
550
551 self.inputManager:storeEventBindings() -- reset any disabled bindings for page custom input in menu context
552
553 local page = self.pagingElement:getPageElementByIndex(pageIndex)
554 self.currentPage = page
555 self.currentPageName = page.name -- store page name for FocusManager GUI context override in update()
556
557 if not skipTabVisualUpdate then
558 self.currentPageId = pageIndex
559
560 -- clear profiles on tabs
561 for _, element in pairs(self.pagingTabList.listItems) do
562 element:applyProfile(TabbedMenu.PROFILE.PAGE_TAB)
563 end
564
565 local activeTab = self.pageTabs[page]
566 if activeTab ~= nil then
567 activeTab:applyProfile(TabbedMenu.PROFILE.PAGE_TAB_ACTIVE)
568 end
569 self:updatePageTabDisplay()
570 end
571
572 page:setVisible(true)
573 page:setSoundSuppressed(true)
574 FocusManager:setGui(page.name)
575 page:setSoundSuppressed(false)
576 page:onFrameOpen()
577
578 self:updateButtonsPanel(page)
579end

onPageClicked

Description
Definition
onPageClicked()
Code
235function TabbedMenu:onPageClicked(oldPage)
236end

onPageNext

Description
Handle next page event.
Definition
onPageNext()
Code
537function TabbedMenu:onPageNext()
538 if self.currentPage:requestClose(self.frameClosePageNextCallback) then
539 TabbedMenu:superClass().onPageNext(self)
540 end
541end

onPagePrevious

Description
Handle previous page event.
Definition
onPagePrevious()
Code
529function TabbedMenu:onPagePrevious()
530 if self.currentPage:requestClose(self.frameClosePagePreviousCallback) then
531 TabbedMenu:superClass().onPagePrevious(self)
532 end
533end

onPageUpdate

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

rebuildTabList

Description
Rebuild page tab list in order.
Definition
rebuildTabList()
Code
248function TabbedMenu:rebuildTabList()
249 for i = #self.pagingTabList.listItems, 1, -1 do
250 local tab = self.pagingTabList.listItems[i]
251 self.pagingTabList:removeElement(tab)
252 end
253
254 for _, page in ipairs(self.pageFrames) do
255 local tab = self.pageTabs[page]
256 if tab:getIsVisible() then
257 self.pagingTabList:addElement(tab)
258 end
259 end
260
261 self.pagingTabList.firstVisibleItem = 1
262end

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
636function TabbedMenu:registerPage(pageFrameElement, position, enablingPredicateFunction)
637 if position == nil then
638 position = #self.pageFrames + 1
639 else
640 position = math.max(1, math.min(#self.pageFrames + 1, position))
641 end
642
643 table.insert(self.pageFrames, position, pageFrameElement)
644 self.pageTypeControllers[pageFrameElement:class()] = pageFrameElement
645 local pageRoot = pageFrameElement:getFirstDescendant()
646 self.pageRoots[pageFrameElement] = pageRoot
647 self.pageEnablingPredicates[pageFrameElement] = enablingPredicateFunction
648
649 pageFrameElement:setVisible(false) -- set invisible at the start to allow visibility-based behavior for pages
650
651 return pageRoot, position
652end

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
736function TabbedMenu:removePage(pageFrameClass)
737 local defaultPage = self.pageTypeControllers[pageFrameClass]
738 if self.defaultPageElementIDs[defaultPage] ~= nil then
739 self:setPageEnabled(pageFrameClass, false)
740 else
741 local needDelete, pageController, pageRoot, pageTab = self:unregisterPage(pageFrameClass)
742 if needDelete then
743 self.pagingElement:removeElement(pageRoot)
744 pageRoot:delete()
745 pageController:delete()
746
747 self.pagingTabList:removeElement(pageTab)
748 pageTab:delete()
749 end
750 end
751end

reset

Description
Definition
reset()
Code
118function TabbedMenu:reset()
119 TabbedMenu:superClass().reset(self)
120
121 self.currentPageId = 1
122 self.currentPageName = ""
123 self.currentPage = nil
124
125 self.restorePageIndex = 1
126end

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
759function TabbedMenu:setPageEnabled(pageFrameClass, isEnabled)
760 local pageController = self.pageTypeControllers[pageFrameClass]
761 if pageController ~= nil then
762 local pageId = self.pagingElement:getPageIdByElement(pageController)
763 self.pagingElement:setPageIdDisabled(pageId, not isEnabled)
764
765 pageController:setDisabled(not isEnabled)
766
767 if not isEnabled then
768 self.disabledPages[pageController] = pageController
769 else
770 self.disabledPages[pageController] = nil
771 end
772
773 self:setPageTabEnabled(pageController, isEnabled)
774 self.pagingTabList:updateItemPositions()
775 end
776end

setPageSelectorTitles

Description
Get page titles from currently visible pages and apply to the selector element.
Definition
setPageSelectorTitles()
Code
412function TabbedMenu:setPageSelectorTitles()
413 local texts = self.pagingElement:getPageTitles()
414
415 self.pageSelector:setTexts(texts)
416 self.pageSelector:setDisabled(#texts == 1)
417
418 -- Update state without triggering any events
419 local id = self.pagingElement:getCurrentPageId()
420 self.pageSelector.state = self.pagingElement:getPageMappingIndex(id)
421end

setPageTabEnabled

Description
Set enabled state of a page tab in the header.
Definition
setPageTabEnabled()
Code
240function TabbedMenu:setPageTabEnabled(pageController, isEnabled)
241 local tab = self.pageTabs[pageController]
242 tab:setDisabled(not isEnabled)
243 tab:setVisible(isEnabled)
244end

setupMenuButtonInfo

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

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
663function TabbedMenu:unregisterPage(pageFrameClass)
664 local pageController = self.pageTypeControllers[pageFrameClass]
665 local pageTab = nil
666 local pageRoot = nil
667 if pageController ~= nil then
668 local pageRemoveIndex = -1
669 for i, page in ipairs(self.pageFrames) do
670 if page == pageController then
671 pageRemoveIndex = i
672 break
673 end
674 end
675
676 table.remove(self.pageFrames, pageRemoveIndex)
677
678 local pageRoot = self.pageRoots[pageController]
679 self.pageRoots[pageController] = nil
680 self.pageTypeControllers[pageFrameClass] = nil
681 self.pageEnablingPredicates[pageController] = nil
682
683 self.pageTabs[pageController] = nil
684 end
685
686 return pageController ~= nil, pageController, pageRoot, pageTab
687end

update

Description
Update the menu state each frame. This uses a state machine approach for the game saving process.
Definition
update()
Code
186function TabbedMenu:update(dt)
187 TabbedMenu:superClass().update(self, dt)
188
189 -- Enforce the current page as the focus context. This is required because dialogs on dialogs (e.g. during saving)
190 -- can break reverting to a valid focus state in this menu.
191 if FocusManager.currentGui ~= self.currentPageName and not g_gui:getIsDialogVisible() then
192 FocusManager:setGui(self.currentPageName)
193 end
194
195 if self.currentPage ~= nil and self.currentPage:isMenuButtonInfoDirty() then
196 self:assignMenuButtonInfo(self.currentPage:getMenuButtonInfo())
197 self.currentPage:clearMenuButtonInfoDirty()
198 end
199end

updateButtonsPanel

Description
Update the buttons panel when a given page is visible.
Definition
updateButtonsPanel()
Code
583function TabbedMenu:updateButtonsPanel(page)
584 -- assign button info anyway to make at least MENU_BACK work in all cases:
585 local buttonInfo = self:getPageButtonInfo(page)
586 self:assignMenuButtonInfo(buttonInfo)
587
588 local pageSize = page:getMainElementSize()
589 local pagePos = page:getMainElementPosition()
590 self.buttonsPanel:setSize(pageSize[1], nil) -- only set width
591 self.buttonsPanel:setAbsolutePosition(pagePos[1], pagePos[2] - self.buttonsPanel.size[2])
592end

updatePageControlVisibility

Description
Definition
updatePageControlVisibility()
Code
321function TabbedMenu:updatePageControlVisibility()
322 local showButtons = #self.pagingTabList.listItems ~= 1
323
324 self.pagingButtonLeft:setVisible(showButtons)
325 self.pagingButtonRight:setVisible(showButtons)
326end

updatePages

Description
Update page enabled states.
Definition
updatePages()
Code
266function TabbedMenu:updatePages()
267 for pageElement, predicate in pairs(self.pageEnablingPredicates) do
268 local pageId = self.pagingElement:getPageIdByElement(pageElement)
269 local enable = self.disabledPages[pageElement] == nil and predicate()
270
271 self.pagingElement:setPageIdDisabled(pageId, not enable)
272 self:setPageTabEnabled(pageElement, enable)
273 end
274
275 self:rebuildTabList()
276 self:updatePageTabDisplay()
277 self:setPageSelectorTitles()
278 self:updatePageControlVisibility()
279end

updatePageTabDisplay

Description
Update page tabs display after any page changes.
Definition
updatePageTabDisplay()
Code
283function TabbedMenu:updatePageTabDisplay()
284 -- center page tabs manually:
285 local width = 0
286 for i = 1, #self.pagingTabList.listItems do
287 width = width + self.pagingTabList.listItemWidth + self.pagingTabList.listItemPadding
288 end
289
290 self.pagingTabList.listItemStartXOffset = (self.pagingTabList.size[1] - width) * 0.5
291 self.pagingTabList:updateItemPositions()
292
293 -- remove frame borders on tabs to avoid visual overlaps, but first reset visibility
294 for i, listItem in ipairs(self.pagingTabList.listItems) do
295 listItem:toggleFrameSide(GuiElement.FRAME_LEFT, true)
296 listItem:toggleFrameSide(GuiElement.FRAME_TOP, true)
297 listItem:toggleFrameSide(GuiElement.FRAME_RIGHT, true)
298 listItem:toggleFrameSide(GuiElement.FRAME_BOTTOM, true)
299 end
300
301 for i, listItem in ipairs(self.pagingTabList.listItems) do
302 local prevItem = self.pagingTabList.listItems[i - 1]
303 local nextItem = self.pagingTabList.listItems[i + 1]
304
305 if listItem.profile == TabbedMenu.PROFILE.PAGE_TAB_ACTIVE then
306 if prevItem ~= nil then
307 prevItem:toggleFrameSide(GuiElement.FRAME_RIGHT, false)
308 end
309
310 if nextItem ~= nil then
311 nextItem:toggleFrameSide(GuiElement.FRAME_LEFT, false)
312 end
313 elseif i > 1 then
314 listItem:toggleFrameSide(GuiElement.FRAME_LEFT, false)
315 end
316 end
317end