Exemplo n.º 1
0
 def __init__(self, screen, menuDict, mainMenuControls = [], mainMenuIconControls = [],
              leftArrowControl = 0, rightArrowControl = 0, okButtonControl = 0, highlightedIndex = 2,
              subMenuControls = [], parentMenu = None, activeMenuItem = None, debugEnabled = False):
     self.parentMenu = parentMenu
     self.debugEnabled = debugEnabled
     self.screen = screen
     self.menuDict = menuDict
     self.mainMenuControls = mainMenuControls
     self.mainMenuIconControls = mainMenuIconControls
     self.leftArrowControl = leftArrowControl
     self.rightArrowControl = rightArrowControl
     self.okButtonControl = okButtonControl
     self.subMenuControls = subMenuControls
     if len(self.subMenuControls) > 0:
         self.subMenuEnabled = True
     self.highlightedIndex = highlightedIndex
     if activeMenuItem == None:
         self.activeMenuItem = highlightedIndex
     else:
         self.activeMenuItem = activeMenuItem
     if self.activeMenuItem >= len(self.menuDict):
         if self.debugEnabled:
             debug('small set of menu items: %s >= %s' % (self.activeMenuItem, len(self.menuDict)))
         self.activeMenuItem = int(round(len(self.menuDict) / 2))
     if self.debugEnabled:
         debug('%r' % self)
     self._renderMenu()
     if 'Submenu' in self.menuDict[self.activeMenuItem]:
         self._renderSubmenu()
     GUIHelpers.hide(self.screen, self.leftArrowControl)
     GUIHelpers.hide(self.screen, self.rightArrowControl)
Exemplo n.º 2
0
 def onInit(self):
     self._prepareMenuOptions()
     self.menu = MenuHelper(self, self.menuOptions, self.mainMenuControls, self.mainMenuIconControls, 
                            self.C_MENU_LEFT_ARROW, self.C_MENU_RIGHT_ARROW, self.C_MENU_OK_BUTTON, self.C_MENU_SELECTED_INDEX,
                            self.submenuControls, None, None, True)
     self._showSubMenu()
     GUIHelpers.hide(self, self.C_SUBMENU_VISIBILITY)
     GUIHelpers.hide(self, EpisodeInfo.visibility)
Exemplo n.º 3
0
 def _renderSubmenu(self):
     if self.subMenuEnabled == False:
         return
     for i in range(0, len(self.subMenuControls)):
         try:
             labelBuf = self.menuDict[self.activeMenuItem]['Submenu'][i]['Label']
         except KeyError:
             labelBuf = ''
         GUIHelpers.setLabelText(self.screen, self.subMenuControls[i], labelBuf)
         if self.debugEnabled:
             debug('submenu item: %s' % labelBuf)
Exemplo n.º 4
0
 def _renderMenu(self):
     offset = self.activeMenuItem - (self.highlightedIndex - 1)
     if self.debugEnabled:
         debug('offset: %s' % offset)
     for i in range(0, len(self.mainMenuControls)):
         try:
             try:
                 #Show the icon if there are submenu items
                 if self.debugEnabled:
                     debug('Checking if icon is needed (Submenu in the following): %s' % pprint.pformat(self.menuDict[i + offset]))
                 if 'Submenu' in self.menuDict[i + offset]:
                     GUIHelpers.show(self.screen, self.mainMenuIconControls[i])
                     if self.debugEnabled:
                         debug('Showed icon!')
                 else:
                     GUIHelpers.hide(self.screen, self.mainMenuIconControls[i])
             except:
                 if self.debugEnabled:
                     debug('Failed checking if icon is needed')
                 pass
             if (i + offset) < 0:
                 labelBuf = ''
             else:
                 labelBuf = self.menuDict[i + offset]['Label']
         except (IndexError, KeyError):
             labelBuf = ''
         if i == (self.highlightedIndex - 1):
             try:
                 #Show the right arrow if there are submenu items
                 if self.debugEnabled:
                     debug('Checking if right arrow is needed (Submenu in the following): %s' % pprint.pformat(self.menuDict[i + offset]))
                 if 'Submenu' in self.menuDict[i + offset]:
                     GUIHelpers.show(self.screen, self.rightArrowControl)
                     if self.debugEnabled:
                         debug('Showed right arrow!')
                 else:
                     GUIHelpers.hide(self.screen, self.rightArrowControl)
             except:
                 if self.debugEnabled:
                     debug('Failed checking if right arrow is needed')
                 pass
             try:
                 #Show the left arrow if there is a parent menu
                 if self.debugEnabled:
                     debug('Checking if left arrow is needed (ParentMenu iis of type: MenuHelper) %s' % pprint.pformat(self.parentMenu))
                 if isinstance(self.parentMenu, MenuHelper):
                     GUIHelpers.show(self.screen, self.leftArrowControl)
                     if self.debugEnabled:
                         debug('Showed left arrow!')
                 else:
                     GUIHelpers.hide(self.screen, self.leftArrowControl)
             except:
                 if self.debugEnabled:
                     debug('Failed checking if left arrow is needed')
                 pass
             GUIHelpers.setBoldLabelText(self.screen, self.mainMenuControls[i], labelBuf)
         else:
             GUIHelpers.setLabelText(self.screen, self.mainMenuControls[i], labelBuf)
Exemplo n.º 5
0
 def _showSubMenu(self):
     if 'Submenu' in self.menu.getSelectedMenuItem():
         GUIHelpers.show(self, self.C_SUBMENU_VISIBILITY)
     else:
         GUIHelpers.hide(self, self.C_SUBMENU_VISIBILITY)