Exemple #1
0
    def getSubMenu(self, context, rootMenu, i, pitem):
        msw = True if "wxMSW" in wx.PlatformInfo else False
        self.context = context
        self.fitMenuItemIds = {}

        sub = wx.Menu()

        if len(self.__class__.commandFits) < 15:
            for fit in sorted(self.__class__.commandFits, key=lambda x: x.name):
                menuItem = self.addFit(rootMenu if msw else sub, fit, True)
                sub.Append(menuItem)
        else:
            typeDict = {}

            for fit in self.__class__.commandFits:
                shipName = fit.ship.item.name
                if shipName not in typeDict:
                    typeDict[shipName] = []
                typeDict[shipName].append(fit)

            for ship in sorted(typeDict.keys()):
                shipItem = wx.MenuItem(sub, ContextMenuUnconditional.nextID(), ship)
                grandSub = wx.Menu()
                shipItem.SetSubMenu(grandSub)

                for fit in sorted(typeDict[ship], key=lambda x: x.name):
                    fitItem = self.addFit(rootMenu if msw else grandSub, fit, False)
                    grandSub.Append(fitItem)

                sub.Append(shipItem)

        return sub
Exemple #2
0
    def getSubMenu(self, callingWindow, context, rootMenu, i, pitem):
        self.fitLookup = {}
        self.context = context
        self.callingWindow = callingWindow
        sFit = Fit.getInstance()

        m = wx.Menu()

        # If on Windows we need to bind out events into the root menu, on other
        # platforms they need to go to our sub menu
        if "wxMSW" in wx.PlatformInfo:
            bindmenu = rootMenu
        else:
            bindmenu = m

        for page in self.mainFrame.fitMultiSwitch._pages:
            if isinstance(page, BlankPage):
                continue
            fit = sFit.getFit(page.activeFitID, basic=True)
            id = ContextMenuUnconditional.nextID()
            mitem = wx.MenuItem(rootMenu, id,
                                "{}: {}".format(fit.ship.item.name, fit.name))
            bindmenu.Bind(wx.EVT_MENU, self.handleSelection, mitem)
            self.fitLookup[id] = fit
            m.Append(mitem)

        return m
Exemple #3
0
    def getSubMenu(self, context, rootMenu, i, pitem):
        msw = True if "wxMSW" in wx.PlatformInfo else False
        self.context = context
        self.fitMenuItemIds = {}

        sub = wx.Menu()

        if len(self.__class__.commandFits) < 15:
            for fit in sorted(self.__class__.commandFits,
                              key=lambda x: x.name):
                menuItem = self.addFit(rootMenu if msw else sub, fit, True)
                sub.Append(menuItem)
        else:
            typeDict = {}

            for fit in self.__class__.commandFits:
                shipName = fit.ship.item.name
                if shipName not in typeDict:
                    typeDict[shipName] = []
                typeDict[shipName].append(fit)

            for ship in sorted(typeDict.keys()):
                shipItem = wx.MenuItem(sub, ContextMenuUnconditional.nextID(),
                                       ship)
                grandSub = wx.Menu()
                shipItem.SetSubMenu(grandSub)

                for fit in sorted(typeDict[ship], key=lambda x: x.name):
                    fitItem = self.addFit(rootMenu if msw else grandSub, fit,
                                          False)
                    grandSub.Append(fitItem)

                sub.Append(shipItem)

        return sub
Exemple #4
0
 def addFit(self, menu, fit, includeShip=False):
     label = fit.name if not includeShip else "({}) {}".format(fit.ship.item.name, fit.name)
     id = ContextMenuUnconditional.nextID()
     self.fitMenuItemIds[id] = fit
     menuItem = wx.MenuItem(menu, id, label)
     menu.Bind(wx.EVT_MENU, self.handleSelection, menuItem)
     return menuItem
Exemple #5
0
 def addMode(self, menu, mode):
     label = mode.item.name.rsplit()[-2]
     id = ContextMenuUnconditional.nextID()
     self.modeIds[id] = mode
     menuItem = wx.MenuItem(menu, id, label, kind=wx.ITEM_RADIO)
     menu.Bind(wx.EVT_MENU, self.handleMode, menuItem)
     return menuItem
Exemple #6
0
 def addFit(self, menu, fit, includeShip=False):
     label = fit.name if not includeShip else "({}) {}".format(
         fit.ship.item.name, fit.name)
     id = ContextMenuUnconditional.nextID()
     self.fitMenuItemIds[id] = fit
     menuItem = wx.MenuItem(menu, id, label)
     menu.Bind(wx.EVT_MENU, self.handleSelection, menuItem)
     return menuItem
Exemple #7
0
    def addProfile(self, rootMenu, profile):
        id = ContextMenuUnconditional.nextID()
        name = getattr(profile, '_name', profile.name)

        self.profileIds[id] = profile
        item = wx.MenuItem(rootMenu, id, name)
        rootMenu.Bind(wx.EVT_MENU, self.handleProfileAdd, item)

        return item
Exemple #8
0
    def getSubMenu(self, callingWindow, context, rootMenu, i, pitem):
        self.profileIds = {}
        self.subMenus = OrderedDict()
        self.singles = []

        sub = wx.Menu()
        for profile in self.profiles:
            start, end = profile.name.find('['), profile.name.find(']')
            if start is not -1 and end is not -1:
                currBase = profile.name[start + 1:end]
                name = profile.name[end + 1:].strip()
                if not name:
                    self.singles.append(profile)
                    continue
                # set helper attr
                setattr(profile, '_name', name)
                if currBase not in self.subMenus:
                    self.subMenus[currBase] = []
                self.subMenus[currBase].append(profile)
            else:
                self.singles.append(profile)
        # Add reset
        msw = 'wxMSW' in wx.PlatformInfo
        mitem, checked = self.addProfile(rootMenu if msw else sub, None)
        sub.Append(mitem)
        mitem.Check(checked)
        sub.AppendSeparator()

        # Single items, no parent
        for profile in self.singles:
            mitem, checked = self.addProfile(rootMenu if msw else sub, profile)
            sub.Append(mitem)
            mitem.Check(checked)

        # Items that have a parent
        for menuName, profiles in list(self.subMenus.items()):
            # Create parent item for root menu that is simply name of parent
            item = wx.MenuItem(rootMenu, ContextMenuUnconditional.nextID(),
                               menuName)

            # Create menu for child items
            grandSub = wx.Menu()

            # Apply child menu to parent item
            item.SetSubMenu(grandSub)

            # Append child items to child menu
            for profile in profiles:
                mitem, checked = self.addProfile(rootMenu if msw else grandSub,
                                                 profile)
                grandSub.Append(mitem)
                mitem.Check(checked)
            sub.Append(item)  # finally, append parent item to root menu

        return sub
Exemple #9
0
    def _addProfile(self, parentMenu, profile, name):
        id = ContextMenuUnconditional.nextID()
        self.profileEventMap[id] = profile
        menuItem = wx.MenuItem(parentMenu, id, name, kind=wx.ITEM_CHECK)
        parentMenu.Bind(wx.EVT_MENU, self.handleResistSwitch, menuItem)

        # determine active profile
        sFit = Fit.getInstance()
        fitID = self.mainFrame.getActiveFit()
        checked = sFit.getFit(fitID).targetProfile is profile
        return menuItem, checked
Exemple #10
0
 def processFlat(data, root, sub):
     for swData in sorted(data, key=lambda tpl: tpl[2]):
         wxid = ContextMenuUnconditional.nextID()
         swObj, swName, swClass = swData
         self.idmap[wxid] = (swObj, swName)
         subItem = wx.MenuItem(sub, wxid, swClass)
         if msw:
             root.Bind(wx.EVT_MENU, self.handleSelection, subItem)
         else:
             sub.Bind(wx.EVT_MENU, self.handleSelection, subItem)
         sub.Append(subItem)
Exemple #11
0
    def _addPattern(self, parentMenu, pattern, name):
        id = ContextMenuUnconditional.nextID()
        self.patternEventMap[id] = pattern
        menuItem = wx.MenuItem(parentMenu, id, name, kind=wx.ITEM_CHECK)
        parentMenu.Bind(wx.EVT_MENU, self.handlePatternSwitch, menuItem)

        # determine active pattern
        sFit = Fit.getInstance()
        fitID = self.mainFrame.getActiveFit()
        fit = sFit.getFit(fitID)
        checked = fit.damagePattern is pattern if fit else False
        return menuItem, checked
Exemple #12
0
    def getSubMenu(self, context, rootMenu, i, pitem):
        msw = True if "wxMSW" in wx.PlatformInfo else False
        self.patternIds = {}
        self.subMenus = OrderedDict()
        self.singles = []

        sub = wx.Menu()
        for pattern in self.patterns:
            start, end = pattern.name.find('['), pattern.name.find(']')
            if start is not -1 and end is not -1:
                currBase = pattern.name[start + 1:end]
                # set helper attr
                setattr(pattern, "_name", pattern.name[end + 1:].strip())
                if currBase not in self.subMenus:
                    self.subMenus[currBase] = []
                self.subMenus[currBase].append(pattern)
            else:
                self.singles.append(pattern)

        sub.Append(self.addPattern(rootMenu if msw else sub,
                                   None))  # Add reset
        sub.AppendSeparator()

        # Single items, no parent
        for pattern in self.singles:
            sub.Append(self.addPattern(rootMenu if msw else sub, pattern))

        # Items that have a parent
        for menuName, patterns in list(self.subMenus.items()):
            # Create parent item for root menu that is simply name of parent
            item = wx.MenuItem(rootMenu, ContextMenuUnconditional.nextID(),
                               menuName)

            # Create menu for child items
            grandSub = wx.Menu()
            # sub.Bind(wx.EVT_MENU, self.handleResistSwitch)

            # Apply child menu to parent item
            item.SetSubMenu(grandSub)

            # Append child items to child menu
            for pattern in patterns:
                grandSub.Append(
                    self.addPattern(rootMenu if msw else grandSub, pattern))
            sub.Append(item)  # finally, append parent item to root menu

        return sub
Exemple #13
0
    def addProfile(self, rootMenu, profile):
        id = ContextMenuUnconditional.nextID()
        name = getattr(profile, '_name',
                       profile.name) if profile is not None else 'No Profile'

        self.profileIds[id] = profile
        item = wx.MenuItem(rootMenu, id, name, kind=wx.ITEM_CHECK)
        rootMenu.Bind(wx.EVT_MENU, self.handleResistSwitch, item)

        # determine active profile
        sFit = Fit.getInstance()
        fitID = self.mainFrame.getActiveFit()
        f = sFit.getFit(fitID)
        tr = f.targetProfile

        checked = tr == profile

        return item, checked
Exemple #14
0
    def getSubMenu(self, context, rootMenu, i, pitem):
        msw = True if "wxMSW" in wx.PlatformInfo else False
        self.patternIds = {}
        self.subMenus = OrderedDict()
        self.singles = []

        sub = wx.Menu()
        for pattern in self.patterns:
            start, end = pattern.name.find('['), pattern.name.find(']')
            if start is not -1 and end is not -1:
                currBase = pattern.name[start + 1:end]
                # set helper attr
                setattr(pattern, "_name", pattern.name[end + 1:].strip())
                if currBase not in self.subMenus:
                    self.subMenus[currBase] = []
                self.subMenus[currBase].append(pattern)
            else:
                self.singles.append(pattern)

        sub.Append(self.addPattern(rootMenu if msw else sub, None))  # Add reset
        sub.AppendSeparator()

        # Single items, no parent
        for pattern in self.singles:
            sub.Append(self.addPattern(rootMenu if msw else sub, pattern))

        # Items that have a parent
        for menuName, patterns in list(self.subMenus.items()):
            # Create parent item for root menu that is simply name of parent
            item = wx.MenuItem(rootMenu, ContextMenuUnconditional.nextID(), menuName)

            # Create menu for child items
            grandSub = wx.Menu()
            # sub.Bind(wx.EVT_MENU, self.handleResistSwitch)

            # Apply child menu to parent item
            item.SetSubMenu(grandSub)

            # Append child items to child menu
            for pattern in patterns:
                grandSub.Append(self.addPattern(rootMenu if msw else grandSub, pattern))
            sub.Append(item)  # finally, append parent item to root menu

        return sub
Exemple #15
0
    def getSubMenu(self, callingWindow, context, rootMenu, i, pitem):
        m = wx.Menu()
        bindmenu = rootMenu if "wxMSW" in wx.PlatformInfo else m

        sIS = s_ImplantSets.getInstance()
        implantSets = sIS.getImplantSetList()

        self.context = context
        self.callingWindow = callingWindow

        self.idmap = {}

        for set in sorted(implantSets, key=lambda i: i.name):
            id = ContextMenuUnconditional.nextID()
            mitem = wx.MenuItem(rootMenu, id, set.name)
            bindmenu.Bind(wx.EVT_MENU, self.handleSelection, mitem)
            self.idmap[id] = set
            m.Append(mitem)

        return m
Exemple #16
0
 def getSubMenu(self, callingWindow, context, rootMenu, i, pitem):
     m = wx.Menu()
     if "wxMSW" in wx.PlatformInfo:
         bindmenu = rootMenu
     else:
         bindmenu = m
     self.idOptionMap = {}
     optionMap = OrderedDict([
         (GraphDpsDroneMode.auto, _t('Auto')),
         (GraphDpsDroneMode.followTarget, _t('Stick to Target')),
         (GraphDpsDroneMode.followAttacker, _t('Stick to Attacker'))
     ])
     for option, label in optionMap.items():
         menuId = ContextMenuUnconditional.nextID()
         item = wx.MenuItem(m, menuId, label, kind=wx.ITEM_CHECK)
         bindmenu.Bind(wx.EVT_MENU, self.handleModeSwitch, item)
         m.Append(item)
         item.Check(option == self.settings.get('mobileDroneMode'))
         self.idOptionMap[menuId] = option
     return m
Exemple #17
0
    def addPattern(self, rootMenu, pattern):
        id = ContextMenuUnconditional.nextID()
        name = getattr(pattern, "_name", pattern.name) if pattern is not None else "No Profile"

        self.patternIds[id] = pattern
        item = wx.MenuItem(rootMenu, id, name)
        rootMenu.Bind(wx.EVT_MENU, self.handleResistSwitch, item)

        # set pattern attr to menu item
        item.pattern = pattern

        # determine active pattern
        sFit = Fit.getInstance()
        fitID = self.mainFrame.getActiveFit()
        f = sFit.getFit(fitID)
        tr = f.targetResists

        if tr == pattern:
            bitmap = BitmapLoader.getBitmap("state_active_small", "gui")
            item.SetBitmap(bitmap)
        return item
    def addPattern(self, rootMenu, pattern):
        id = ContextMenuUnconditional.nextID()
        name = getattr(pattern, "_name", pattern.name) if pattern is not None else "No Profile"

        self.patternIds[id] = pattern
        menuItem = wx.MenuItem(rootMenu, id, name, kind=wx.ITEM_CHECK)
        rootMenu.Bind(wx.EVT_MENU, self.handlePatternSwitch, menuItem)

        # set pattern attr to menu item
        menuItem.pattern = pattern

        # determine active pattern
        sFit = Fit.getInstance()
        fitID = self.mainFrame.getActiveFit()
        fit = sFit.getFit(fitID)
        if fit:
            dp = fit.damagePattern
            checked = dp is pattern
        else:
            checked = False
        return menuItem, checked
Exemple #19
0
    def addPattern(self, rootMenu, pattern):
        id = ContextMenuUnconditional.nextID()
        name = getattr(pattern, "_name",
                       pattern.name) if pattern is not None else "No Profile"

        self.patternIds[id] = pattern
        item = wx.MenuItem(rootMenu, id, name)
        rootMenu.Bind(wx.EVT_MENU, self.handleResistSwitch, item)

        # set pattern attr to menu item
        item.pattern = pattern

        # determine active pattern
        sFit = Fit.getInstance()
        fitID = self.mainFrame.getActiveFit()
        f = sFit.getFit(fitID)
        tr = f.targetResists

        if tr == pattern:
            bitmap = BitmapLoader.getBitmap("state_active_small", "gui")
            item.SetBitmap(bitmap)
        return item
Exemple #20
0
 def _addSet(self, parentMenu, profile, name):
     id = ContextMenuUnconditional.nextID()
     self.eventSetMap[id] = profile
     menuItem = wx.MenuItem(parentMenu, id, name)
     parentMenu.Bind(wx.EVT_MENU, self.handleSelection, menuItem)
     return menuItem
 def _addEffect(self, parentMenu, typeID, name):
     id = ContextMenuUnconditional.nextID()
     self.idmap[id] = typeID
     menuItem = wx.MenuItem(parentMenu, id, name)
     parentMenu.Bind(wx.EVT_MENU, self.handleSelection, menuItem)
     return menuItem
 def _addGroup(self, parentMenu, name):
     id = ContextMenuUnconditional.nextID()
     menuItem = wx.MenuItem(parentMenu, id, name)
     parentMenu.Bind(wx.EVT_MENU, self.handleSelection, menuItem)
     return menuItem
Exemple #23
0
 def addOption(self, menu, optionLabel):
     id = ContextMenuUnconditional.nextID()
     self.optionIds[id] = optionLabel
     menuItem = wx.MenuItem(menu, id, optionLabel, kind=wx.ITEM_CHECK)
     menu.Bind(wx.EVT_MENU, self.handleMode, menuItem)
     return menuItem
Exemple #24
0
 def _addProfile(self, parentMenu, profile, name):
     id = ContextMenuUnconditional.nextID()
     self.profileEventMap[id] = profile
     menuItem = wx.MenuItem(parentMenu, id, name)
     parentMenu.Bind(wx.EVT_MENU, self.handleProfileAdd, menuItem)
     return menuItem
Exemple #25
0
 def _addSeparator(self, m, text):
     id_ = ContextMenuUnconditional.nextID()
     m.Append(id_, '─ %s ─' % text)
     m.Enable(id_, False)
Exemple #26
0
 def _addCategory(self, parentMenu, name):
     id = ContextMenuUnconditional.nextID()
     menuItem = wx.MenuItem(parentMenu, id, name)
     parentMenu.Bind(wx.EVT_MENU, self.handleProfileAdd, menuItem)
     return menuItem
Exemple #27
0
 def addOption(self, menu, optionLabel):
     id = ContextMenuUnconditional.nextID()
     self.optionIds[id] = optionLabel
     menuItem = wx.MenuItem(menu, id, optionLabel, kind=wx.ITEM_CHECK)
     menu.Bind(wx.EVT_MENU, self.handleMode, menuItem)
     return menuItem