Ejemplo n.º 1
0
class MapViewColorModeSettingButton(MapViewSettingButton):
    def ReloadSettingValue(self):
        self.SetTexturePath(ICON_ROOT + 'spectrumIcon.png')

    def LoadTooltipPanel(self, tooltipPanel, *args):
        if uicore.uilib.leftbtn:
            return
        tooltipPanel.columns = 1
        tooltipPanel.cellPadding = 2
        tooltipPanel.state = uiconst.UI_NORMAL
        scrollPosition = settings.user.ui.Get('mapViewColorModeScrollPosition',
                                              0.0)
        self.scroll = Scroll(parent=tooltipPanel,
                             align=uiconst.TOPLEFT,
                             width=COLORMODE_MENU_WIDTH,
                             height=COLORMODE_MENU_HEIGHT)
        self.scroll.OnUpdatePosition = self.OnScrollPositionChanged
        scrollEntries = self.GetColorModeOptions()
        self.scroll.Load(contentList=scrollEntries, scrollTo=scrollPosition)

    def Close(self, *args):
        MapViewSettingButton.Close(self, *args)

    def OnScrollPositionChanged(self, *args, **kwargs):
        settings.user.ui.Set('mapViewColorModeScrollPosition',
                             self.scroll.GetScrollProportion())

    def GetScrollEntries(self, options, settingsKey=None, sublevel=0):
        currentActive = GetMapViewSetting(self.settingGroupKey)
        scrollList = []
        for label, settingValue in options:
            config = [
                self.settingGroupKey, settingValue, label,
                currentActive == settingValue
            ]
            entry = self.AddCheckBox(config,
                                     None,
                                     self.settingGroupKey,
                                     sublevel=sublevel)
            scrollList.append(entry)

        return scrollList

    def GetGroupScrollEntry(self, groupID, groupLabel, groupData):
        id = ('mapviewsettings', groupID)
        data = {
            'GetSubContent': self.GetSubContent,
            'label': groupLabel,
            'id': id,
            'groupItems': groupData,
            'iconMargin': 32,
            'showlen': 0,
            'state': 'locked',
            'BlockOpenWindow': 1,
            'key': groupID,
            'showicon': 'hide'
        }
        return [listentry.Get('Group', data)]

    def GetSubContent(self, data, newitems=0):
        for entry in self.scroll.GetNodes():
            if entry.__guid__ != 'listentry.Group' or entry.id == data.id:
                continue
            if entry.open:
                if entry.panel:
                    entry.panel.Toggle()
                else:
                    uicore.registry.SetListGroupOpenState(entry.id, 0)
                    entry.scroll.PrepareSubContent(entry)

        return self.GetScrollEntries(data.groupItems)

    def AddCheckBox(self,
                    config,
                    scrolllist,
                    group=None,
                    usecharsettings=0,
                    sublevel=0):
        cfgname, retval, desc, default = config
        data = {}
        data['label'] = desc
        data['checked'] = default
        data['cfgname'] = cfgname
        data['retval'] = retval
        data['group'] = group
        data['OnChange'] = self.OnCheckBoxChange
        data['usecharsettings'] = usecharsettings
        data['entryWidth'] = COLORMODE_MENU_WIDTH
        data['decoClass'] = MapViewCheckbox
        scrollNode = ScrollEntryNode(**data)
        if scrolllist is not None:
            scrolllist.append(scrollNode)
        else:
            return scrollNode

    def OnCheckBoxChange(self, checkbox):
        key = checkbox.data['key']
        val = checkbox.data['retval']
        if val is None:
            val = checkbox.checked
        if checkbox.data.get('usecharsettings', 0):
            settings.char.ui.Set(key, val)
        else:
            settings.user.ui.Set(key, val)
        if self.callback:
            self.callback(self.settingGroupKey, val)

    def GetColorModeOptions(self):
        ret = [
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsActual'),
                STARMODE_REAL
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsSecurity'),
                STARMODE_SECURITY
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsRegion'),
                STARMODE_REGION
            ],
            [
                localization.GetByLabel(
                    'UI/Map/MapPallet/cbStarsDedDeadspace'), STARMODE_DUNGEONS
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsDedAgents'),
                STARMODE_DUNGEONSAGENTS
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsIncursion'),
                STARMODE_INCURSION
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsAdvoidance'),
                STARMODE_AVOIDANCE
            ]
        ]
        if eve.session.role & ROLE_GML:
            ret.append([
                localization.GetByLabel('UI/Map/MapPallet/cbStarsIncursionGM'),
                STARMODE_INCURSIONGM
            ])
        ret.sort()
        scrollEntries = self.GetScrollEntries(ret)
        for groupLabel, groupID, loadFunction in self.GetColorModeGroups():
            scrollEntries += self.GetGroupScrollEntry(groupID, groupLabel,
                                                      loadFunction())

        return scrollEntries

    def GetPersonalColorModeOptions(self):
        ret = [
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsMyAssets'),
                STARMODE_ASSETS
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsIVisited'),
                STARMODE_VISITED
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsCargoLeagal'),
                STARMODE_CARGOILLEGALITY
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsPIScanRange'),
                STARMODE_PISCANRANGE
            ]
        ]
        if (const.corpRoleAccountant
                | const.corpRoleJuniorAccountant) & eve.session.corprole != 0:
            ret += [[
                localization.GetByLabel('UI/Map/MapPallet/cbStarsCorpOffices'),
                STARMODE_CORPOFFICES
            ],
                    [
                        localization.GetByLabel(
                            'UI/Map/MapPallet/cbStarsCorpImpounded'),
                        STARMODE_CORPIMPOUNDED
                    ],
                    [
                        localization.GetByLabel(
                            'UI/Map/MapPallet/cbStarsCorpProperty'),
                        STARMODE_CORPPROPERTY
                    ],
                    [
                        localization.GetByLabel(
                            'UI/Map/MapPallet/cbStarsCorpDeliveries'),
                        STARMODE_CORPDELIVERIES
                    ]]
        ret += [
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsCorpMembers'),
                STARMODE_FRIENDS_CORP
            ],
            [
                localization.GetByLabel(
                    'UI/Map/MapPallet/cbStarsFleetMembers'),
                STARMODE_FRIENDS_FLEET
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsMyAgents'),
                STARMODE_FRIENDS_AGENT
            ]
        ]
        ret.append([
            localization.GetByLabel('UI/Map/MapPallet/cbStarsMyColonies'),
            STARMODE_MYCOLONIES
        ])
        ret.sort()
        return ret

    def GetPlanetsOptions(self):
        ret = []
        for planetTypeID in maputils.PLANET_TYPES:
            ret.append((cfg.invtypes.Get(planetTypeID).typeName,
                        (STARMODE_PLANETTYPE, planetTypeID)))

        ret.sort()
        return ret

    def GetIndustryOptions(self):
        ret = [
            [
                localization.GetByLabel(
                    'UI/Map/MapPallet/cbStarsByJobsStartedLast24Hours'),
                STARMODE_JOBS24HOUR
            ],
            [
                localization.GetByLabel(
                    'UI/Map/MapPallet/cbStarsByManufacturingJobsStartedLast24Hours'
                ), STARMODE_MANUFACTURING_JOBS24HOUR
            ],
            [
                localization.GetByLabel(
                    'UI/Map/MapPallet/cbStarsByResearchTimeJobsStartedLast24Hours'
                ), STARMODE_RESEARCHTIME_JOBS24HOUR
            ],
            [
                localization.GetByLabel(
                    'UI/Map/MapPallet/cbStarsByResearchMaterialJobsStartedLast24Hours'
                ), STARMODE_RESEARCHMATERIAL_JOBS24HOUR
            ],
            [
                localization.GetByLabel(
                    'UI/Map/MapPallet/cbStarsByCopyJobsStartedLast24Hours'),
                STARMODE_COPY_JOBS24HOUR
            ],
            [
                localization.GetByLabel(
                    'UI/Map/MapPallet/cbStarsByInventionJobsStartedLast24Hours'
                ), STARMODE_INVENTION_JOBS24HOUR
            ],
            [
                localization.GetByLabel(
                    'UI/Map/MapPallet/cbStarsByManufacturingIndustryCostModifier'
                ), STARMODE_INDUSTRY_MANUFACTURING_COST_INDEX
            ],
            [
                localization.GetByLabel(
                    'UI/Map/MapPallet/cbStarsByResearchTimeIndustryCostModifier'
                ), STARMODE_INDUSTRY_RESEARCHTIME_COST_INDEX
            ],
            [
                localization.GetByLabel(
                    'UI/Map/MapPallet/cbStarsByResearchMaterialIndustryCostModifier'
                ), STARMODE_INDUSTRY_RESEARCHMATERIAL_COST_INDEX
            ],
            [
                localization.GetByLabel(
                    'UI/Map/MapPallet/cbStarsByCopyIndustryCostModifier'),
                STARMODE_INDUSTRY_COPY_COST_INDEX
            ],
            [
                localization.GetByLabel(
                    'UI/Map/MapPallet/cbStarsByInventionIndustryCostModifier'),
                STARMODE_INDUSTRY_INVENTION_COST_INDEX
            ]
        ]
        ret.sort()
        return ret

    def GetServicesOptions(self):
        ret = [
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsClone'),
                STARMODE_SERVICE_Cloning
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsFactory'),
                STARMODE_SERVICE_Factory
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsFitting'),
                STARMODE_SERVICE_Fitting
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsInsurance'),
                STARMODE_SERVICE_Insurance
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsLaboratory'),
                STARMODE_SERVICE_Laboratory
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsRepair'),
                STARMODE_SERVICE_RepairFacilities
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsMilitia'),
                STARMODE_SERVICE_NavyOffices
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsRefinery'),
                STARMODE_SERVICE_ReprocessingPlant
            ],
            [
                localization.GetByLabel(
                    'UI/Map/MapPallet/StarmodeSecurityOffices'),
                STARMODE_SERVICE_SecurityOffice
            ]
        ]
        ret.sort()
        return ret

    def GetStatisticsOptions(self):
        ret = [
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsPilots30Min'),
                STARMODE_PLAYERCOUNT
            ],
            [
                localization.GetByLabel(
                    'UI/Map/MapPallet/cbStarsPilotsDocked'),
                STARMODE_PLAYERDOCKED
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsJumps'),
                STARMODE_JUMPS1HR
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsDestroyed'),
                STARMODE_SHIPKILLS1HR
            ],
            [
                localization.GetByLabel(
                    'UI/Map/MapPallet/cbStarsDestroyed24H'),
                STARMODE_SHIPKILLS24HR
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsPoded1H'),
                STARMODE_PODKILLS1HR
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsPoded24H'),
                STARMODE_PODKILLS24HR
            ],
            [
                localization.GetByLabel(
                    'UI/Map/MapPallet/cbStarsNPCDestroyed'),
                STARMODE_FACTIONKILLS1HR
            ],
            [
                localization.GetByLabel(
                    'UI/Map/MapPallet/cbStarsStationCount'),
                STARMODE_STATIONCOUNT
            ],
            [
                localization.GetByLabel('UI/Map/MapPallet/cbStarsCynosuarl'),
                STARMODE_CYNOSURALFIELDS
            ]
        ]
        ret.sort()
        return ret

    def GetColorModeGroups(self):
        colorModeGroups = [
            (localization.GetByLabel('UI/Map/MapPallet/hdrStarsMyInformation'),
             'Personal', self.GetPersonalColorModeOptions),
            (localization.GetByLabel('UI/Map/MapPallet/hdrStarsServices'),
             'Services', self.GetServicesOptions),
            (localization.GetByLabel('UI/Map/MapPallet/hdrStarsStatistics'),
             'Statistics', self.GetStatisticsOptions),
            (localization.GetByLabel('UI/Map/MapPallet/hdrStarsPlanets'),
             'Planets', self.GetPlanetsOptions),
            (localization.GetByLabel('UI/Map/MapPallet/hdrStarsIndustry'),
             'Industry', self.GetIndustryOptions)
        ]
        colorModeGroups.sort()
        return colorModeGroups
Ejemplo n.º 2
0
class SkillsPanel(Container):
    default_name = 'SkillsPanel'
    __notifyevents__ = [
        'OnAttribute', 'OnGodmaItemChange', 'OnSkillQueueRefreshed',
        'OnFreeSkillPointsChanged_Local', 'OnSkillsChanged',
        'OnSkillQueueChanged'
    ]

    def ApplyAttributes(self, attributes):
        Container.ApplyAttributes(self, attributes)
        sm.RegisterNotify(self)
        self.ConstructTopCont()
        if not IsSkillInjectorBannerDismissed():
            SkillInjectorBanner(parent=self,
                                align=uiconst.TOTOP,
                                padding=(4, 4, 4, 4))
        self.scroll = Scroll(parent=self, padding=(0, 4, 0, 4))
        self.scroll.sr.id = 'charsheet_skills'
        self.skilltabs = TabGroup(
            name='tabparent',
            parent=self,
            idx=0,
            tabs=
            [[
                GetByLabel(
                    'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/Skills'),
                self.scroll, self, PANEL_SKILLS_SKILLS
            ],
             [
                 GetByLabel(
                     'UI/CharacterSheet/CharacterSheetWindow/CertTabs/Certificates'
                 ), self.scroll, self, PANEL_SKILLS_CERTIFICATES
             ],
             [
                 GetByLabel(
                     'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/History'
                 ), self.scroll, self, PANEL_SKILLS_HISTORY
             ]],
            groupID='cs_skills',
            UIIDPrefix='characterSheetTab')

    def ConstructTopCont(self):
        self.topCont = Container(name='topCont',
                                 parent=self,
                                 align=uiconst.TOTOP,
                                 height=24)
        UtilMenu(parent=self.topCont,
                 align=uiconst.CENTERLEFT,
                 menuAlign=uiconst.BOTTOMLEFT,
                 GetUtilMenu=self.GetSkillSettingsMenu,
                 texturePath='res:/UI/Texture/SettingsCogwheel.png',
                 width=16,
                 height=16,
                 iconSize=18)
        self.quickFilter = QuickFilterEdit(parent=self.topCont,
                                           align=uiconst.CENTERLEFT,
                                           width=80,
                                           left=18)
        self.quickFilter.ReloadFunction = self.QuickFilterReload
        btn = Button(
            parent=self.topCont,
            align=uiconst.CENTERRIGHT,
            label=GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/OpenTrainingQueue'
            ),
            func=self.OpenSkillQueueWindow,
            name='characterSheetOpenTrainingQueue')

    def OpenSkillQueueWindow(self, *args):
        uicore.cmd.OpenSkillQueueWindow()

    def SelectTab(self, panelID):
        self.skilltabs.SelectByID(panelID)

    def LoadPanel(self):
        self.ResetQuickFilter(triggerCallback=False)
        self.skilltabs.AutoSelect()

    def ResetQuickFilter(self, triggerCallback=True):
        self.quickFilter.SetValue('', docallback=triggerCallback)

    def ShowMySkillHistory(self):
        def GetPts(lvl):
            return charskills.GetSPForLevelRaw(stc, lvl)

        self.topCont.Hide()
        self.scroll.sr.id = 'charsheet_skillhistory'
        rs = sm.GetService('skills').GetSkillHistory()
        scrolllist = []
        actions = {
            const.skillEventClonePenalty:
            GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/SkillClonePenalty'
            ),
            const.skillEventTrainingStarted:
            GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/SkillTrainingStarted'
            ),
            const.skillEventTrainingComplete:
            GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/SkillTrainingComplete'
            ),
            const.skillEventTrainingCancelled:
            GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/SkillTrainingCanceled'
            ),
            const.skillEventGMGive:
            GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/GMGiveSkill'
            ),
            const.skillEventQueueTrainingCompleted:
            GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/SkillTrainingComplete'
            ),
            const.skillEventFreeSkillPointsUsed:
            GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/SkillPointsApplied'
            ),
            const.skillEventSkillExtracted:
            GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/SkillLevelExtracted'
            )
        }
        for r in rs:
            skill = sm.GetService('skills').GetSkill(r.skillTypeID)
            if skill:
                stc = skill.skillRank
                levels = [
                    0,
                    GetPts(1),
                    GetPts(2),
                    GetPts(3),
                    GetPts(4),
                    GetPts(5)
                ]
                level = 5
                for i in range(len(levels)):
                    if levels[i] > r.absolutePoints:
                        level = i - 1
                        break

                data = KeyVal()
                data.label = FmtDate(r.logDate, 'ls') + '<t>'
                data.label += evetypes.GetName(r.skillTypeID) + '<t>'
                data.label += actions.get(
                    r.eventTypeID, GetByLabel('UI/Generic/Unknown')) + '<t>'
                data.label += FormatNumeric(level)
                data.Set('sort_%s' % GetByLabel('UI/Common/Date'), r.logDate)
                data.id = r.skillTypeID
                data.level = level
                data.GetMenu = self.GetItemMenu
                data.MenuFunction = self.GetItemMenu
                data.OnDblClick = (self.DblClickShowInfo, data)
                addItem = entries.Get('Generic', data=data)
                scrolllist.append(addItem)

        self.scroll.Load(
            contentList=scrolllist,
            headers=[
                GetByLabel('UI/Common/Date'),
                GetByLabel(
                    'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/Skill'),
                GetByLabel(
                    'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/Action'),
                GetByLabel(
                    'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/Level')
            ],
            noContentHint=GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/NoRecordsFound'
            ),
            reversesort=True)

    def GetItemMenu(self, entry, *args):
        return [(GetByLabel('UI/Common/ShowInfo'), self.ShowInfo,
                 (entry.sr.node.id, 1))]

    def ShowInfo(self, *args):
        skillID = args[0]
        sm.StartService('info').ShowInfo(skillID, None)

    def DblClickShowInfo(self, otherSelf, nodeData):
        skillTypeID = getattr(nodeData, 'id', None)
        if skillTypeID is not None:
            self.ShowInfo(skillTypeID)

    @telemetry.ZONE_METHOD
    def Load(self, key):
        if key == PANEL_SKILLS_SKILLS:
            self.ShowMySkills(force=True)
            LogOpenCharacterSkills()
        elif key == PANEL_SKILLS_CERTIFICATES:
            self.ShowCertificates()
        elif key == PANEL_SKILLS_HISTORY:
            self.ShowMySkillHistory()

    def ShowCertificates(self):
        self.topCont.Show()
        showOnlyMine = settings.user.ui.Get('charsheet_showOnlyMyCerts', False)
        scrolllist = []
        myCategories = sm.GetService(
            'certificates').GetMyCertificatesByCategoryID()
        allCategories = sm.GetService(
            'certificates').GetAllCertificatesByCategoryID()
        if showOnlyMine:
            visibleCategories = myCategories
        else:
            visibleCategories = allCategories
        myFilter = self.quickFilter.GetValue()
        for groupID, certificates in visibleCategories.iteritems():
            if len(myFilter):
                certificates = NiceFilter(self.FilterCertificates,
                                          certificates[:])
            if len(certificates) == 0:
                continue
            label = GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/CertTabs/CertificateGroupWithCount',
                groupName=evetypes.GetGroupNameByGroup(groupID),
                certificatesCompleted=len(myCategories[groupID]),
                certificatesTotal=len(allCategories[groupID]))
            data = {
                'GetSubContent': self.GetCertSubContent,
                'label': label,
                'groupItems': certificates,
                'id': ('charsheetGroups_cat', groupID),
                'sublevel': 0,
                'showlen': 0,
                'showicon': 'hide',
                'state': 'locked',
                'forceOpen': bool(myFilter)
            }
            scrolllist.append(entries.Get('Group', data))

        scrolllist = localization.util.Sort(scrolllist, key=lambda x: x.label)
        self.scroll.sr.id = 'charsheet_mycerts'
        contentHint = GetByLabel(
            'UI/CharacterSheet/CharacterSheetWindow/CertTabs/NoCertificatesFound'
        )
        self.scroll.Load(contentList=scrolllist, noContentHint=contentHint)

    def FilterCertificates(self, certificate):
        filterVal = self.quickFilter.GetValue().lower()
        return certificate.GetName().lower().find(filterVal) + 1

    def GetCertSubContent(self, dataX, *args):
        toggleGroups = settings.user.ui.Get(
            'charsheet_toggleOneCertGroupAtATime', 1)
        if toggleGroups and not dataX.forceOpen:
            dataWnd = Window.GetIfOpen(windowID=unicode(dataX.id))
            if not dataWnd:
                for entry in self.scroll.GetNodes():
                    if entry.__guid__ != 'listentry.Group' or entry.id == dataX.id:
                        continue
                    if entry.open:
                        if entry.panel:
                            entry.panel.Toggle()
                        else:
                            uicore.registry.SetListGroupOpenState(entry.id, 0)
                            entry.scroll.PrepareSubContent(entry)

        entries = self.GetCertificateEntries(dataX)
        return entries

    def GetCertificateEntries(self, data, *args):
        scrolllist = [self.CreateCertificateEntry(d) for d in data.groupItems]
        return localization.util.Sort(scrolllist, key=lambda x: x.label)

    def CreateCertificateEntry(self, certificate, *args):
        level = certificate.GetLevel()
        certificate = KeyVal(
            label=certificate.GetName(),
            certID=certificate.certificateID,
            level=level,
            iconID='res:/UI/Texture/Classes/Certificates/level%sSmall.png' %
            level)
        return entries.Get(data=certificate, decoClass=CertEntryBasic)

    @telemetry.ZONE_METHOD
    def ShowMySkills(self, force=False):
        if not force and self.skilltabs.GetSelectedID() != PANEL_SKILLS_SKILLS:
            return
        self.topCont.Show()
        advancedView = settings.user.ui.Get('charsheet_showSkills',
                                            'trained') in ('mytrainable',
                                                           'alltrainable')
        groups = sm.GetService('skills').GetSkillGroups(advancedView)
        scrolllist = []
        skillCount = sm.GetService('skills').GetSkillCount()
        skillPoints = sm.StartService('skills').GetFreeSkillPoints()
        if skillPoints > 0:
            text = '<color=0xFF00FF00>' + GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/UnAllocatedSkillPoints',
                skillPoints=skillPoints) + '</color>'
            hint = GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/ApplySkillHint'
            )
            scrolllist.append(entries.Get('Text', {
                'text': text,
                'hint': hint
            }))
        currentSkillPoints = 0
        for group, skills, untrained, intraining, inqueue, points in groups:
            currentSkillPoints += points

        skillText = GetByLabel(
            'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/YouCurrentlyHaveSkills',
            numSkills=skillCount,
            currentSkillPoints=currentSkillPoints)
        scrolllist.append(entries.Get('Text', {'text': skillText}))

        @telemetry.ZONE_METHOD
        def Published(skill):
            return evetypes.IsPublished(skill.typeID)

        for group, skills, untrained, intraining, inqueue, points in groups:
            untrained = filter(Published, untrained)
            if not len(skills) and not advancedView:
                continue
            tempList = []
            if advancedView and settings.user.ui.Get(
                    'charsheet_showSkills', 'trained') == 'mytrainable':
                for utrained in untrained[:]:
                    isSkillReqMet = sm.GetService(
                        'skills').IsSkillRequirementMet(utrained.typeID)
                    isTrialRestricted = sm.GetService(
                        'skills').IsTrialRestricted(utrained.typeID)
                    if isSkillReqMet and not isTrialRestricted:
                        tempList.append(utrained)

                combinedSkills = skills[:] + tempList[:]
                if not len(skills) and tempList == []:
                    continue
            if settings.user.ui.Get('charsheet_showSkills',
                                    'trained') == 'alltrainable':
                combinedSkills = skills[:] + untrained[:]
            numInQueueLabel = ''
            label = None
            if len(inqueue):
                if len(intraining):
                    labelPath = 'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/SkillsInQueueTraining'
                else:
                    labelPath = 'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/SkillsInQueue'
                numInQueueLabel = GetByLabel(labelPath,
                                             skillsInQueue=len(inqueue))
            if advancedView:
                label = GetByLabel(
                    'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/SkillGroupOverviewAdvanced',
                    groupName=group.groupName,
                    skills=len(skills),
                    totalSkills=len(combinedSkills),
                    points=points,
                    skillsInQueue=numInQueueLabel)
            else:
                label = GetByLabel(
                    'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/SkillGroupOverviewSimple',
                    groupName=group.groupName,
                    skills=len(skills),
                    points=points,
                    skillsInQueue=numInQueueLabel)
                combinedSkills = skills[:]
            if settings.user.ui.Get('charsheet_hideLevel5Skills',
                                    False) == True:
                for skill in skills:
                    if skill.skillLevel == 5:
                        combinedSkills.remove(skill)

            if settings.user.ui.Get('charsheet_hideUntrainedSkills',
                                    False) == True:
                combinedSkills = filter(lambda s: s.skillPoints > 0,
                                        combinedSkills)
            myFilter = self.quickFilter.GetValue()
            if len(myFilter):
                combinedSkills = NiceFilter(self.quickFilter.QuickFilter,
                                            combinedSkills)
            if len(combinedSkills) == 0:
                continue
            data = {
                'GetSubContent': self.GetSubContent,
                'DragEnterCallback': self.OnGroupDragEnter,
                'DeleteCallback': self.OnGroupDeleted,
                'MenuFunction': self.GetMenu,
                'label': label,
                'groupItems': combinedSkills,
                'inqueue': inqueue,
                'id': ('myskills', group.groupID),
                'tabs': [],
                'state': 'locked',
                'showicon': 'hide',
                'showlen': 0,
                'forceOpen': bool(myFilter)
            }
            scrolllist.append(entries.Get('Group', data))

        scrolllist.append(entries.Get('Space', {'height': 64}))
        pos = self.scroll.GetScrollProportion()
        self.scroll.sr.id = 'charsheet_myskills'
        self.scroll.Load(contentList=scrolllist, headers=[], scrollTo=pos)

    @telemetry.ZONE_METHOD
    def GetSubContent(self, data, *args):
        scrolllist = []
        skillQueueSvc = sm.GetService('skillqueue')
        skillqueue = skillQueueSvc.GetServerQueue()
        skillqueue = {(x.trainingTypeID, x.trainingToLevel): idx
                      for idx, x in enumerate(skillqueue)}
        mySkills = sm.GetService('skills').GetSkills()
        skillsInQueue = data.inqueue
        skillInTraining = skillQueueSvc.SkillInTraining()
        toggleGroups = settings.user.ui.Get(
            'charsheet_toggleOneSkillGroupAtATime', 1)
        if toggleGroups and not data.forceOpen:
            dataWnd = Window.GetIfOpen(unicode(data.id))
            if not dataWnd:
                for entry in self.scroll.GetNodes():
                    if entry.__guid__ != 'listentry.Group' or entry.id == data.id:
                        continue
                    if entry.open:
                        if entry.panel:
                            entry.panel.Toggle()
                        else:
                            uicore.registry.SetListGroupOpenState(entry.id, 0)
                            entry.scroll.PrepareSubContent(entry)

        skillsInGroup = localization.util.Sort(
            data.groupItems, key=lambda x: evetypes.GetName(x.typeID))
        for skill in skillsInGroup:
            inQueue = None
            if skill.typeID in skillsInQueue:
                for i in xrange(5, skill.skillLevel, -1):
                    if (skill.typeID, i) in skillqueue:
                        inQueue = i
                        break

            inTraining = 0
            if skillInTraining and skill.typeID == skillInTraining.typeID:
                inTraining = 1
            data = {
                'invtype': skill.typeID,
                'skill': skill,
                'trained': skill.typeID in mySkills,
                'plannedInQueue': inQueue,
                'skillID': skill.typeID,
                'inTraining': inTraining
            }
            scrolllist.append(entries.Get('SkillEntry', data))

        return scrolllist

    def OnGroupDeleted(self, ids):
        pass

    def OnGroupDragEnter(self, group, drag):
        pass

    def GetMenu(self, *args):
        return []

    def QuickFilterReload(self):
        self._ReloadSkillTabs()

    def _ReloadSkillTabs(self):
        tabID = self.skilltabs.GetSelectedID()
        if tabID == PANEL_SKILLS_SKILLS:
            self.ShowMySkills()
        elif tabID == PANEL_SKILLS_CERTIFICATES:
            self.ShowCertificates()
        elif tabID == PANEL_SKILLS_HISTORY:
            uthread.new(self.ShowMySkillHistory)

    def OnAttribute(self, attributeName, item, value):
        if attributeName == 'skillPoints':
            self._ReloadSkillTabs()

    def OnGodmaItemChange(self, item, change):
        if const.ixFlag in change and item.categoryID == const.categorySkill:
            self._ReloadSkillTabs()

    def OnSkillQueueRefreshed(self):
        self._ReloadSkillTabs()

    def OnFreeSkillPointsChanged_Local(self):
        self._ReloadSkillTabs()

    def OnSkillsChanged(self, *args):
        self._ReloadSkillTabs()

    def OnSkillQueueChanged(self):
        self._ReloadSkillTabs()

    def GetSkillSettingsMenu(self, menuParent):
        if self.skilltabs.GetSelectedID() == PANEL_SKILLS_SKILLS:
            return self.GetSkillSkillSettingsMenu(menuParent)
        else:
            return self.GetSkillCertSettingsMenu(menuParent)

    def GetSkillSkillSettingsMenu(self, menuParent):
        menuParent.AddRadioButton(text=localization.GetByLabel(
            'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/ShowOnlyCurrentSkills'
        ),
                                  checked=settings.user.ui.Get(
                                      'charsheet_showSkills',
                                      'trained') == 'trained',
                                  callback=self.SetShowSkillsTrained)
        menuParent.AddRadioButton(text=localization.GetByLabel(
            'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/ShowOnlyTrainableSkills'
        ),
                                  checked=settings.user.ui.Get(
                                      'charsheet_showSkills',
                                      'trained') == 'mytrainable',
                                  callback=self.SetShowSkillsMyTrainable)
        menuParent.AddRadioButton(text=localization.GetByLabel(
            'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/ShowAllSkills'),
                                  checked=settings.user.ui.Get(
                                      'charsheet_showSkills',
                                      'trained') == 'alltrainable',
                                  callback=self.SetShowSkillsAll)
        menuParent.AddDivider()
        menuParent.AddCheckBox(text=localization.GetByLabel(
            'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/HighlightPartiallyTrainedSkills'
        ),
                               checked=settings.user.ui.Get(
                                   'charsheet_hilitePartiallyTrainedSkills',
                                   False),
                               callback=self.
                               ToggleHighlightPartiallyTrainedSkills)
        menuParent.AddCheckBox(text=localization.GetByLabel(
            'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/ToggleOneSkillGroupAtATime'
        ),
                               checked=settings.user.ui.Get(
                                   'charsheet_toggleOneSkillGroupAtATime',
                                   False),
                               callback=self.ToggleOneSkillGroup)
        menuParent.AddCheckBox(text=localization.GetByLabel(
            'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/HideLvl5'),
                               checked=settings.user.ui.Get(
                                   'charsheet_hideLevel5Skills', False),
                               callback=self.ToggleHideLevel5Skills)
        menuParent.AddCheckBox(text=localization.GetByLabel(
            'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/HideUntrained'),
                               checked=settings.user.ui.Get(
                                   'charsheet_hideUntrainedSkills', False),
                               callback=self.ToggleHideUntrainedSkills)

    def SetShowSkillsTrained(self):
        settings.user.ui.Set('charsheet_showSkills', 'trained')
        self.ShowMySkills()

    def SetShowSkillsMyTrainable(self):
        settings.user.ui.Set('charsheet_showSkills', 'mytrainable')
        self.ShowMySkills()

    def SetShowSkillsAll(self):
        settings.user.ui.Set('charsheet_showSkills', 'alltrainable')
        self.ShowMySkills()

    def ToggleHighlightPartiallyTrainedSkills(self):
        current = settings.user.ui.Get(
            'charsheet_hilitePartiallyTrainedSkills', False)
        settings.user.ui.Set('charsheet_hilitePartiallyTrainedSkills',
                             not current)
        self.ShowMySkills()

    def ToggleOneSkillGroup(self):
        current = settings.user.ui.Get('charsheet_toggleOneSkillGroupAtATime',
                                       False)
        settings.user.ui.Set('charsheet_toggleOneSkillGroupAtATime',
                             not current)
        self.ShowMySkills()

    def ToggleHideLevel5Skills(self):
        current = settings.user.ui.Get('charsheet_hideLevel5Skills', False)
        settings.user.ui.Set('charsheet_hideLevel5Skills', not current)
        self.ShowMySkills()

    def ToggleHideUntrainedSkills(self):
        current = settings.user.ui.Get('charsheet_hideUntrainedSkills', False)
        settings.user.ui.Set('charsheet_hideUntrainedSkills', not current)
        self.ShowMySkills()

    def GetSkillCertSettingsMenu(self, menuParent):
        menuParent.AddCheckBox(text=localization.GetByLabel(
            'UI/CharacterSheet/CharacterSheetWindow/SkillTabs/ToggleShowOnlyMyCertificates'
        ),
                               checked=settings.user.ui.Get(
                                   'charsheet_showOnlyMyCerts', False),
                               callback=self.ToggleShowOnlyMyCerts)
        menuParent.AddCheckBox(text=localization.GetByLabel(
            'UI/CharacterSheet/CharacterSheetWindow/CertTabs/ToggleOneCertificationGroupAtATime'
        ),
                               checked=settings.user.ui.Get(
                                   'charsheet_toggleOneCertGroupAtATime',
                                   True),
                               callback=self.ToggleOneCertGroup)

    def ToggleShowOnlyMyCerts(self):
        current = settings.user.ui.Get('charsheet_showOnlyMyCerts', False)
        settings.user.ui.Set('charsheet_showOnlyMyCerts', not current)
        self.ShowCertificates()

    def ToggleOneCertGroup(self):
        current = settings.user.ui.Get('charsheet_toggleOneCertGroupAtATime',
                                       True)
        settings.user.ui.Set('charsheet_toggleOneCertGroupAtATime',
                             not current)
        self.ShowCertificates()

    def HighlightSkillHistorySkills(self, skillTypeIds):
        self.DeselectAllNodes()
        blue.pyos.synchro.SleepWallclock(500)
        skillTypeIds = skillTypeIds[:]
        for node in self.scroll.GetNodes():
            recordKey = (node.id, node.level)
            if recordKey in skillTypeIds:
                self.scroll._SelectNode(node)
                skillTypeIds.remove(recordKey)

    def DeselectAllNodes(self):
        for node in self.scroll.GetNodes():
            self.scroll._DeselectNode(node)
Ejemplo n.º 3
0
class MapViewColorModeSettingButton(MapViewSettingButton):
    def ReloadSettingValue(self):
        self.SetTexturePath(ICON_ROOT + 'spectrumIcon.png')

    def LoadTooltipPanel(self, tooltipPanel, *args):
        if uicore.uilib.leftbtn:
            return
        tooltipPanel.columns = 1
        tooltipPanel.cellPadding = 2
        tooltipPanel.state = uiconst.UI_NORMAL
        tooltipPanel.AddLabelSmall(
            text=localization.GetByLabel('UI/Map/ColorMapBy'),
            bold=True,
            cellPadding=(8, 4, 4, 2))
        divider = LineThemeColored(align=uiconst.TOTOP,
                                   state=uiconst.UI_DISABLED,
                                   height=1,
                                   padding=(1, 1, 1, 0),
                                   opacity=0.3)
        tooltipPanel.AddCell(divider, cellPadding=(0, 0, 0, 0))
        if eve.session.role & service.ROLE_GML:
            Button(parent=tooltipPanel,
                   label='Debug Run All',
                   func=self.DebugRunAll,
                   align=uiconst.CENTER)
        tooltipPanel.AddLabelSmall(
            text=localization.GetByLabel('UI/Map/RecentColorBy'),
            cellPadding=(8, 4, 4, 2))
        self.recentLayoutGrid = LayoutGrid(columns=1, parent=tooltipPanel)
        self.LoadRecentColorModes()
        divider = LineThemeColored(align=uiconst.TOTOP,
                                   state=uiconst.UI_DISABLED,
                                   height=1,
                                   padding=(1, 1, 1, 0),
                                   opacity=0.3)
        tooltipPanel.AddCell(divider, cellPadding=(0, 0, 0, 0))
        self.scroll = Scroll(parent=tooltipPanel,
                             align=uiconst.TOPLEFT,
                             width=COLORMODE_MENU_WIDTH,
                             height=COLORMODE_MENU_HEIGHT)
        self.scroll.OnUpdatePosition = self.OnScrollPositionChanged
        self.LoadColorModes()

    def DebugRunAll(self, *args):
        print 'DebugRunAll'
        for groupLabel, groupID, loadFunction in self.GetColorModeGroups():
            colorModes = loadFunction()
            for colorMode in colorModes:
                print ' -', colorMode, GetFormatFunctionLabel(colorMode)
                SetMapViewSetting(VIEWMODE_COLOR_SETTINGS, colorMode,
                                  self.mapViewID)
                if self.callback:
                    self.callback(self.settingGroupKey, colorMode)
                blue.synchro.Sleep(500)

    def Close(self, *args):
        MapViewSettingButton.Close(self, *args)

    def OnScrollPositionChanged(self, *args, **kwargs):
        settings.char.ui.Set(
            'mapViewColorModeScrollPosition_%s' % self.mapViewID,
            self.scroll.GetScrollProportion())

    def GetScrollEntries(self, options, settingsKey=None, sublevel=0):
        currentActive = GetMapViewSetting(self.settingGroupKey, self.mapViewID)
        scrollList = []
        for colorMode in options:
            label = GetFormatFunctionLabel(colorMode)
            if not label:
                continue
            config = [
                self.settingGroupKey, colorMode, label,
                currentActive == colorMode
            ]
            entry = self.AddCheckBox(config,
                                     None,
                                     self.settingGroupKey,
                                     sublevel=sublevel)
            scrollList.append(entry)

        return scrollList

    def GetGroupScrollEntry(self, groupID, groupLabel, groupData):
        import listentry
        id = ('mapviewsettings', groupID)
        data = {
            'GetSubContent': self.GetSubContent,
            'label': groupLabel,
            'id': id,
            'groupItems': groupData,
            'iconMargin': 32,
            'showlen': 0,
            'state': 'locked',
            'BlockOpenWindow': 1,
            'key': groupID,
            'showicon': 'hide'
        }
        return listentry.Get('Group', data)

    def GetSubContent(self, data, newitems=0):
        for entry in self.scroll.GetNodes():
            if entry.__guid__ != 'listentry.Group' or entry.id == data.id:
                continue
            if entry.open:
                if entry.panel:
                    entry.panel.Toggle()
                else:
                    uicore.registry.SetListGroupOpenState(entry.id, 0)
                    entry.scroll.PrepareSubContent(entry)

        return self.GetScrollEntries(data.groupItems)

    def AddCheckBox(self, config, scrolllist, group=None, sublevel=0):
        cfgname, retval, desc, default = config
        data = {}
        data['label'] = desc
        data['checked'] = default
        data['cfgname'] = cfgname
        data['retval'] = retval
        data['group'] = group
        data['OnChange'] = self.OnColorModeScrollCheckBoxChange
        data['entryWidth'] = COLORMODE_MENU_WIDTH
        data['decoClass'] = MapViewCheckbox
        scrollNode = ScrollEntryNode(**data)
        if scrolllist is not None:
            scrolllist.append(scrollNode)
        else:
            return scrollNode

    def OnColorModeScrollCheckBoxChange(self, checkbox):
        key = checkbox.data['key']
        val = checkbox.data['retval']
        if val is None:
            val = checkbox.checked
        self._SetColorMode(key, val)
        self.RegisterRecentColorMode(val)
        self.LoadRecentColorModes()

    def OnColorModeCheckBoxChange(self, checkbox):
        key = checkbox.data['config']
        val = checkbox.data['value']
        if val is None:
            val = checkbox.checked
        self._SetColorMode(key, val)
        self.LoadColorModes()

    def _SetColorMode(self, key, val):
        SetMapViewSetting(key, val, self.mapViewID)
        if self.callback:
            self.callback(self.settingGroupKey, val)

    def GetColorModeOptions(self):
        scrollEntries = []
        for groupLabel, groupID, loadFunction in self.GetColorModeGroups():
            groupEntry = self.GetGroupScrollEntry(groupID, groupLabel,
                                                  loadFunction())
            scrollEntries.append((groupLabel.lower(), groupEntry))

        return [entry for sortLabel, entry in sorted(scrollEntries)]

    def RegisterRecentColorMode(self, colorMode):
        current = GetMapViewSetting(VIEWMODE_COLOR_RECENT, self.mapViewID)
        if colorMode in current:
            return
        current.insert(0, colorMode)
        current = current[:VIEWMODE_COLOR_RECENT_MAX]
        SetMapViewSetting(VIEWMODE_COLOR_RECENT, current, self.mapViewID)

    def GetRecentColorModes(self):
        return GetMapViewSetting(VIEWMODE_COLOR_RECENT, self.mapViewID)

    def LoadColorModes(self):
        scrollPosition = settings.char.ui.Get(
            'mapViewColorModeScrollPosition_%s' % self.mapViewID, 0.0)
        scrollEntries = self.GetColorModeOptions()
        self.scroll.Load(contentList=scrollEntries, scrollTo=scrollPosition)

    def LoadRecentColorModes(self):
        if self.destroyed:
            return
        self.recentLayoutGrid.Flush()
        ret = self.GetRecentColorModes()
        currentActive = GetMapViewSetting(VIEWMODE_COLOR_SETTINGS,
                                          self.mapViewID)
        for colorMode in ret:
            label = GetFormatFunctionLabel(colorMode)
            if not label:
                continue
            checkBox = Checkbox(align=uiconst.TOPLEFT,
                                text=label,
                                checked=colorMode == currentActive,
                                wrapLabel=True,
                                callback=self.OnColorModeCheckBoxChange,
                                configName=VIEWMODE_COLOR_SETTINGS,
                                groupname=VIEWMODE_COLOR_SETTINGS,
                                retval=colorMode,
                                prefstype=None,
                                width=COLORMODE_MENU_WIDTH - 10)
            self.recentLayoutGrid.AddCell(cellObject=checkBox,
                                          cellPadding=(5, 0, 5, 0))

    def GetNPCOptions(self):
        ret = [STARMODE_DUNGEONS, STARMODE_DUNGEONSAGENTS, STARMODE_INCURSION]
        if eve.session.role & ROLE_GML:
            ret.append(STARMODE_INCURSIONGM)
        return ret

    def GetCorporationOptions(self):
        ret = [STARMODE_FRIENDS_CORP]
        if (const.corpRoleAccountant
                | const.corpRoleJuniorAccountant) & eve.session.corprole != 0:
            ret += [
                STARMODE_CORPOFFICES, STARMODE_CORPIMPOUNDED,
                STARMODE_CORPPROPERTY, STARMODE_CORPDELIVERIES
            ]
        return ret

    def GetPersonalColorModeOptions(self):
        ret = [
            STARMODE_ASSETS, STARMODE_VISITED, STARMODE_CARGOILLEGALITY,
            STARMODE_PISCANRANGE, STARMODE_FRIENDS_FLEET,
            STARMODE_FRIENDS_AGENT, STARMODE_MYCOLONIES, STARMODE_AVOIDANCE
        ]
        return ret

    def GetPlanetsOptions(self):
        ret = []
        for planetTypeID in maputils.PLANET_TYPES:
            ret.append((STARMODE_PLANETTYPE, planetTypeID))

        return ret

    def GetIndustryOptions(self):
        ret = [
            STARMODE_JOBS24HOUR, STARMODE_MANUFACTURING_JOBS24HOUR,
            STARMODE_RESEARCHTIME_JOBS24HOUR,
            STARMODE_RESEARCHMATERIAL_JOBS24HOUR, STARMODE_COPY_JOBS24HOUR,
            STARMODE_INVENTION_JOBS24HOUR,
            STARMODE_INDUSTRY_MANUFACTURING_COST_INDEX,
            STARMODE_INDUSTRY_RESEARCHTIME_COST_INDEX,
            STARMODE_INDUSTRY_RESEARCHMATERIAL_COST_INDEX,
            STARMODE_INDUSTRY_COPY_COST_INDEX,
            STARMODE_INDUSTRY_INVENTION_COST_INDEX
        ]
        return ret

    def GetServicesOptions(self):
        ret = [
            STARMODE_STATION_SERVICE_CLONING, STARMODE_STATION_SERVICE_FACTORY,
            STARMODE_STATION_SERVICE_FITTING,
            STARMODE_STATION_SERVICE_INSURANCE,
            STARMODE_STATION_SERVICE_LABORATORY,
            STARMODE_STATION_SERVICE_REPAIRFACILITIES,
            STARMODE_STATION_SERVICE_NAVYOFFICES,
            STARMODE_STATION_SERVICE_REPROCESSINGPLANT,
            STARMODE_STATION_SERVICE_SECURITYOFFICE
        ]
        return ret

    def GetStatisticsOptions(self):
        ret = [
            STARMODE_REAL, STARMODE_SECURITY, STARMODE_REGION,
            STARMODE_PLAYERCOUNT, STARMODE_PLAYERDOCKED, STARMODE_JUMPS1HR,
            STARMODE_SHIPKILLS1HR, STARMODE_SHIPKILLS24HR,
            STARMODE_PODKILLS1HR, STARMODE_PODKILLS24HR,
            STARMODE_FACTIONKILLS1HR, STARMODE_STATIONCOUNT,
            STARMODE_CYNOSURALFIELDS
        ]
        return ret

    def GetFactionalWarfareOptions(self):
        ret = [(STARMODE_MILITIA, STARMODE_FILTER_FACWAR_ENEMY)]
        for factionID in sm.StartService('facwar').GetWarFactions():
            ret.append((STARMODE_MILITIA, factionID))

        ret.append(STARMODE_MILITIAKILLS1HR)
        ret.append(STARMODE_MILITIAKILLS24HR)
        return ret

    def GetSovereigntyDevelopmentIndicesOptions(self):
        ret = [
            STARMODE_INDEX_STRATEGIC, STARMODE_INDEX_MILITARY,
            STARMODE_INDEX_INDUSTRY
        ]
        return ret

    def GetSovereigntyOptions(self):
        ret = [
            STARMODE_FACTION, STARMODE_SOV_STANDINGS,
            (STARMODE_FACTIONEMPIRE, STARMODE_FILTER_EMPIRE),
            STARMODE_INDEX_STRATEGIC, STARMODE_INDEX_MILITARY,
            STARMODE_INDEX_INDUSTRY, STARMODE_SOV_CHANGE, STARMODE_SOV_GAIN,
            STARMODE_SOV_LOSS, STARMODE_OUTPOST_GAIN, STARMODE_OUTPOST_LOSS,
            STARMODE_STATION_FREEPORT
        ]
        return ret

    def GetColorModeGroups(self):
        colorModeGroups = [
            (localization.GetByLabel('UI/Map/MapColorPersonal'), 'Personal',
             self.GetPersonalColorModeOptions),
            (localization.GetByLabel('UI/Map/MapPallet/hdrStarsServices'),
             'Services', self.GetServicesOptions),
            (localization.GetByLabel('UI/Map/MapColorGeography'), 'Statistics',
             self.GetStatisticsOptions),
            (localization.GetByLabel('UI/Map/MapColorNPC'), 'NPCActivity',
             self.GetNPCOptions),
            (localization.GetByLabel('UI/Map/MapColorCorporation'),
             'Corporation', self.GetCorporationOptions),
            (localization.GetByLabel('UI/Map/MapPallet/hdrStarsPlanets'),
             'Planets', self.GetPlanetsOptions),
            (localization.GetByLabel('UI/Map/MapPallet/hdrStarsIndustry'),
             'Industry', self.GetIndustryOptions),
            (localization.GetByLabel(
                'UI/Map/MapPallet/hdrStarsSovereigntyFacWar'),
             'FactionalWarfare', self.GetFactionalWarfareOptions),
            (localization.GetByLabel('UI/Map/MapPallet/hdrStarsSovereignty'),
             'Sovereignty', self.GetSovereigntyOptions)
        ]
        return colorModeGroups
Ejemplo n.º 4
0
class CombatLogPanel(Container):
    default_name = 'KillsPanel'
    __notifyevents__ = []

    def ApplyAttributes(self, attributes):
        Container.ApplyAttributes(self, attributes)
        sm.RegisterNotify(self)
        self.killentries = 25
        self.topCont = Container(name='combatlogpanel', parent=self, align=uiconst.TOTOP, padTop=const.defaultPadding)
        combatValues = ((GetByLabel('UI/Corporations/Wars/Killmails/ShowKills'), 0), (GetByLabel('UI/Corporations/Wars/Killmails/ShowLosses'), 1))
        selectedCombatType = settings.user.ui.Get('CombatLogCombo', 0)
        self.combatCombo = Combo(parent=self.topCont, name='combo', select=selectedCombatType, align=uiconst.TOPLEFT, left=1, callback=self.OnCombatChange, options=combatValues, idx=0, adjustWidth=True)
        self.sr.combatSetting = Checkbox(parent=self.topCont, align=uiconst.TOPLEFT, pos=(0,
         self.combatCombo.height + const.defaultPadding,
         300,
         14), configName='charsheet_condensedcombatlog', text=GetByLabel('UI/CharacterSheet/CharacterSheetWindow/KillsTabs/CondensedCombatLog'), checked=settings.user.ui.Get('charsheet_condensedcombatlog', 0), callback=self.CheckBoxChange)
        self.killReportQuickFilter = QuickFilterEdit(parent=self.topCont, left=const.defaultPadding, align=uiconst.TOPRIGHT, width=150)
        self.killReportQuickFilter.ReloadFunction = self.ReloadKillReports
        self.topCont.height = self.combatCombo.height + self.sr.combatSetting.height + const.defaultPadding
        self.btnContainer = Container(name='pageBtnContainer', parent=self, align=uiconst.TOBOTTOM, idx=0, padBottom=4)
        btn = GetBigButton(size=22, where=self.btnContainer, left=4, top=0)
        btn.SetAlign(uiconst.CENTERRIGHT)
        btn.hint = GetByLabel('UI/CharacterSheet/CharacterSheetWindow/KillsTabs/ViewMore')
        btn.sr.icon.LoadIcon('ui_23_64_2')
        btn = GetBigButton(size=22, where=self.btnContainer, left=4, top=0)
        btn.SetAlign(uiconst.CENTERLEFT)
        btn.hint = GetByLabel('UI/CharacterSheet/CharacterSheetWindow/KillsTabs/ViewPrevious')
        btn.sr.icon.LoadIcon('ui_23_64_1')
        self.btnContainer.height = max([ c.height for c in self.btnContainer.children ])
        self.scroll = Scroll(parent=self, padding=(0, 4, 0, 4))

    def CheckBoxChange(self, checkbox):
        if checkbox.name == 'charsheet_condensedcombatlog':
            settings.user.ui.Set('charsheet_condensedcombatlog', checkbox.checked)
            self.ShowKills()

    def OnCombatChange(self, *args):
        selected = self.combatCombo.GetValue()
        settings.user.ui.Set('CombatLogCombo', selected)
        self.combatPageNum = 0
        if selected == 0:
            self.ShowCombatKills()
        else:
            self.ShowCombatLosses()

    def LoadPanel(self, *args):
        self.ShowKills()

    def ShowKillsEx(self, recent, func, combatType, pageNum):
        if combatType == 'kills':
            prevType = self.prevKillIDs
        else:
            prevType = self.prevLossIDs
        filterText = self.killReportQuickFilter.GetValue().lower()
        scrolllist, headers = GetCombatEntries(recent, filterText=filterText)
        for c in self.btnContainer.children:
            c.state = uiconst.UI_HIDDEN

        self.btnContainer.state = uiconst.UI_HIDDEN
        killIDs = [ k.killID for k in recent ]
        prevbtn = self.btnContainer.children[1]
        nextbtn = self.btnContainer.children[0]
        if pageNum > 0:
            self.btnContainer.state = uiconst.UI_NORMAL
            prevbtn.state = uiconst.UI_NORMAL
            if combatType == 'kills':
                pageIndex = min(pageNum, len(self.prevKillIDs) - 1)
                prevType = self.prevKillIDs[pageIndex - 1]
            else:
                pageIndex = min(pageNum, len(self.prevLossIDs) - 1)
                prevType = self.prevLossIDs[pageIndex - 1]
            prevbtn.OnClick = (func, prevType, -1)
        maxKillIDs = max(killIDs) + 1 if killIDs else 0
        if combatType == 'kills' and pageNum + 1 > len(self.prevKillIDs):
            self.prevKillIDs.append(maxKillIDs)
        elif pageNum + 1 > len(self.prevLossIDs):
            self.prevLossIDs.append(maxKillIDs)
        if len(recent) >= self.killentries:
            self.btnContainer.state = uiconst.UI_NORMAL
            nextbtn.state = uiconst.UI_NORMAL
            nextbtn.OnClick = (func, min(killIDs), 1)
        isCondensed = settings.user.ui.Get('charsheet_condensedcombatlog', 0)
        if isCondensed:
            self.scroll.sr.id = 'charsheet_kills'
        else:
            self.scroll.sr.id = 'charsheet_kills2'
        noContentHintText = ''
        if combatType == 'kills':
            noContentHintText = GetByLabel('UI/CharacterSheet/CharacterSheetWindow/KillsTabs/NoKillsFound')
        elif combatType == 'losses':
            noContentHintText = GetByLabel('UI/CharacterSheet/CharacterSheetWindow/KillsTabs/NoLossesFound')
        pos = self.scroll.GetScrollProportion()
        self.scroll.Load(contentList=scrolllist, headers=headers, scrollTo=pos, noContentHint=noContentHintText)

    def ShowCombatKills(self, startFrom = None, pageChange = 0, *args):
        recent = sm.GetService('info').GetKillsRecentKills(self.killentries, startFrom)
        self.combatPageNum = max(0, self.combatPageNum + pageChange)
        self.ShowKillsEx(recent, self.ShowCombatKills, 'kills', pageNum=self.combatPageNum)

    def ShowCombatLosses(self, startFrom = None, pageChange = 0, *args):
        recent = sm.GetService('info').GetKillsRecentLosses(self.killentries, startFrom)
        self.combatPageNum = max(0, self.combatPageNum + pageChange)
        self.ShowKillsEx(recent, self.ShowCombatLosses, 'losses', pageNum=self.combatPageNum)

    def ShowKills(self):
        self.prevKillIDs = []
        self.prevLossIDs = []
        self.combatPageNum = 0
        selectedCombatType = settings.user.ui.Get('CombatLogCombo', 0)
        if selectedCombatType == 0:
            self.ShowCombatKills()
        else:
            self.ShowCombatLosses()

    def ReloadKillReports(self):
        combatSetting = settings.user.ui.Get('CombatLogCombo', 0)
        offset = None
        if combatSetting == 0:
            if self.prevKillIDs and self.combatPageNum:
                offset = self.prevKillIDs[self.combatPageNum]
            self.ShowCombatKills(offset)
        else:
            if self.prevLossIDs and self.combatPageNum:
                offset = self.prevLossIDs[self.combatPageNum]
            self.ShowCombatLosses(offset)