Пример #1
0
    def getText(self, callingWindow, itmContext):
        sDP = DmgPatternSvc.getInstance()
        sFit = Fit.getInstance()
        fitID = self.mainFrame.getActiveFit()
        self.fit = sFit.getFit(fitID)

        builtinPatterns = sDP.getBuiltinDamagePatternList()
        userPatterns = sorted(sDP.getUserDamagePatternList(),
                              key=lambda p: smartSort(p.fullName))
        # Order here is important: patterns with duplicate names from the latter will overwrite
        # patterns from the former
        self.patterns = sorted(
            chain(builtinPatterns, userPatterns),
            key=lambda p: p.fullName not in ["Uniform", "Selected Ammo"])

        self.patternEventMap = {}
        self.items = (OrderedDict(), OrderedDict())
        for pattern in self.patterns:
            container = self.items
            for categoryName in pattern.hierarchy:
                categoryName = _t(
                    categoryName) if pattern.builtin else categoryName
                container = container[1].setdefault(
                    categoryName, (OrderedDict(), OrderedDict()))
            shortName = _t(
                pattern.shortName) if pattern.builtin else pattern.shortName
            container[0][shortName] = pattern

        return list(self.items[0].keys()) + list(self.items[1].keys())
Пример #2
0
 def _getPatterns(self):
     sDP = DmgPatternSvc.getInstance()
     builtinPatterns = sDP.getBuiltinDamagePatternList()
     userPatterns = sorted(sDP.getUserDamagePatternList(),
                           key=lambda p: smartSort(p.fullName))
     # Order here is important: patterns with duplicate names from the latter will overwrite
     # patterns from the former
     patterns = sorted(
         chain(builtinPatterns, userPatterns),
         key=lambda p: p.fullName not in ["Uniform", "Selected Ammo"])
     return patterns
Пример #3
0
    def getSubMenu(self, callingWindow, context, rootMenu, i, pitem):
        sTR = svc_TargetProfile.getInstance()
        profiles = list(
            chain(sTR.getBuiltinTargetProfileList(),
                  sTR.getUserTargetProfileList()))
        profiles.sort(key=lambda p: smartSort(p.fullName))

        self.profileEventMap = {}
        items = (OrderedDict(), OrderedDict())
        for profile in profiles:
            container = items
            for categoryName in profile.hierarchy:
                categoryName = _t(
                    categoryName) if profile.builtin else categoryName
                container = container[1].setdefault(
                    categoryName, (OrderedDict(), OrderedDict()))
            shortName = _t(
                profile.shortName) if profile.builtin else profile.shortName
            container[0][shortName] = profile

        # Category as menu item - expands further
        msw = "wxMSW" in wx.PlatformInfo

        def makeMenu(container, parentMenu, first=False):
            menu = wx.Menu()
            if first:
                mitem, checked = self._addProfile(
                    rootMenu if msw else parentMenu, None, _t('No Profile'))
                menu.Append(mitem)
                mitem.Check(checked)
                if len(container[0]) > 0 or len(container[1]) > 0:
                    menu.AppendSeparator()
            for name, pattern in container[0].items():
                menuItem, checked = self._addProfile(
                    rootMenu if msw else parentMenu, pattern, name)
                menu.Append(menuItem)
                menuItem.Check(checked)
            for name, subcontainer in container[1].items():
                menuItem = self._addCategory(rootMenu if msw else parentMenu,
                                             name)
                subMenu = makeMenu(subcontainer, menu)
                menuItem.SetSubMenu(subMenu)
                menu.Append(menuItem)
            menu.Bind(wx.EVT_MENU, self.handleResistSwitch)
            return menu

        subMenu = makeMenu(items, rootMenu, first=True)
        return subMenu
Пример #4
0
    def getSubMenu(self, callingWindow, context, rootMenu, i, pitem):
        self.callingWindow = callingWindow
        sTR = svc_TargetProfile.getInstance()
        profiles = list(
            chain(sTR.getBuiltinTargetProfileList(),
                  sTR.getUserTargetProfileList()))
        profiles.sort(key=lambda p: smartSort(p.fullName))

        self.eventProfileMap = {}
        items = (OrderedDict(), OrderedDict())
        for profile in profiles:
            container = items
            for categoryName in profile.hierarchy:
                container = container[1].setdefault(
                    categoryName, (OrderedDict(), OrderedDict()))
            container[0][profile.shortName] = profile

        # Category as menu item - expands further
        msw = "wxMSW" in wx.PlatformInfo

        def makeMenu(container, parentMenu, first=False):
            menu = wx.Menu()
            if first:
                idealProfile = TargetProfile.getIdeal()
                mitem = self._addProfile(rootMenu if msw else parentMenu,
                                         idealProfile, idealProfile.fullName)
                menu.Append(mitem)
            for name, pattern in container[0].items():
                menuItem = self._addProfile(rootMenu if msw else parentMenu,
                                            pattern, name)
                menu.Append(menuItem)
            for name, subcontainer in container[1].items():
                menuItem = self._addCategory(rootMenu if msw else parentMenu,
                                             name)
                subMenu = makeMenu(subcontainer, menu)
                menuItem.SetSubMenu(subMenu)
                menu.Append(menuItem)
            menu.Bind(wx.EVT_MENU, self.handleProfileAdd)
            return menu

        subMenu = makeMenu(items, rootMenu, first=True)
        return subMenu