Beispiel #1
0
 def _AddInventoryPanel(self, btnGroup):
     self.inventoryPanel = Container(name=INVENTORYPANEL,
                                     parent=self.sr.main)
     self.sr.shipsContainer = Container(parent=self.inventoryPanel,
                                        state=uiconst.UI_HIDDEN,
                                        padding=const.defaultPadding)
     self.sr.itemsContainer = Container(parent=self.inventoryPanel,
                                        state=uiconst.UI_HIDDEN,
                                        padding=const.defaultPadding)
     tabs = [[
         GetByLabel('UI/Station/Ships'), self.sr.shipsContainer, self,
         'lobby_ships'
     ],
             [
                 GetByLabel('UI/Station/Items'), self.sr.itemsContainer,
                 self, 'lobby_items'
             ]]
     self.inventoryTabs = TabGroup(name='inventoryPanel',
                                   parent=self.inventoryPanel,
                                   idx=0)
     self.inventoryTabs.Startup(tabs,
                                'lobbyInventoryPanel',
                                autoselecttab=True,
                                UIIDPrefix='lobbyInventoryPanelTab')
     hint = '<b>%s</b><br>%s' % (
         GetByLabel('Tooltips/StationServices/Hangars'),
         GetByLabel('Tooltips/StationServices/Hangars_description'))
     self.invButton = btnGroup.AddButton(
         INVENTORYPANEL,
         '<center>' + GetByLabel('UI/Station/Lobby/Hangars'),
         self.inventoryPanel,
         btnClass=LobbyToggleButtonGroupButton,
         hint=hint)
 def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     achievementSvc = sm.GetService('achievementSvc')
     isCharacterListening = sm.RemoteSvc(
         'achievementTrackerMgr').IsCharacterIsListening(session.charid)
     if isCharacterListening:
         text = 'This character is listening for broadcasted opportunity changes'
     else:
         text = 'This character is <color=red><b>NOT</b></color> listening for broadcasted opportunity changes'
     EveLabelMedium(parent=self.sr.main,
                    name='listeningLabel',
                    text=text,
                    align=uiconst.TOTOP,
                    padding=(10, 4, 10, 4))
     maintabs = TabGroup(name='tabparent',
                         align=uiconst.TOTOP,
                         height=18,
                         parent=self.sr.main)
     self.mainContainer = AchievementMainContainer(
         align=uiconst.TOALL,
         parent=self.sr.main,
         padding=const.defaultPadding)
     self.conditionsCont = ConditionsContainer(align=uiconst.TOALL,
                                               parent=self.sr.main,
                                               padding=const.defaultPadding)
     tabs = [[
         'Achievements', None, self, 'achievements', self.mainContainer
     ], ['Conditions', None, self, 'conditions', self.conditionsCont]]
     maintabs.Startup(tabs, groupID='achievements', autoselecttab=True)
     self.initData()
 def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     self.browserMyStructures = None
     self.tabs = None
     self.SetWndIcon(self.iconNum, mainTop=-8)
     WndCaptionLabel(text=GetByLabel('UI/Structures/Browser/StructureBrowser'), subcaption=GetByLabel('UI/StructureBrowser/Delayed5Minutes'), parent=self.sr.topParent, align=uiconst.RELATIVE)
     self.controller = sm.GetService('structureControllers').GetStructureBrowserController()
     self.browserCont = Container(name='browserCont', parent=self.sr.main, padding=4)
     self.browserAllStructures = BrowserAllStructures(parent=self.browserCont, structureBrowserController=self.controller, padTop=4)
     if session.corprole & const.corpRoleStationManager:
         self.browserMyStructures = BrowserMyCorpStructures(parent=self.browserCont, padTop=4, structureBrowserController=self.controller)
         tabs = ((GetByLabel('UI/Structures/Browser/AllStructures'),
           self.browserAllStructures,
           None,
           'allStructures',
           None,
           GetByLabel('UI/StructureBrowser/TabAllStructures')), (GetByLabel('UI/Structures/Browser/MyStructures'),
           self.browserMyStructures,
           None,
           'myStructures',
           None,
           GetByLabel('UI/StructureBrowser/TabMyStructures')))
         self.tabs = TabGroup(parent=self.browserCont, tabs=tabs, height=26, labelPadding=12, idx=0, padLeft=0, groupID='StructureBrowser')
     else:
         self.browserAllStructures.LoadPanel()
Beispiel #4
0
 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')
Beispiel #5
0
 def ApplyAttributes(self, attributes):
     Container.ApplyAttributes(self, attributes)
     btns = [(GetByLabel(
         'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/SaveDecorationPermissionChanges'
     ), self.SaveDecorationPermissionsChanges, (), 64),
             (GetByLabel(
                 'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/SetAllDecorationPermissions'
             ), self.SetAllDecorationPermissions, (), 64)]
     self.mainAreaButtons = ContainerAutoSize(align=uiconst.TOBOTTOM,
                                              parent=self)
     ButtonGroup(btns=btns, parent=self.mainAreaButtons, line=False)
     self.decoMedalList = None
     self.decoRankList = None
     self.scroll = Scroll(parent=self, padding=(0, 4, 0, 4))
     self.mydecorationstabs = TabGroup(
         name='tabparent',
         parent=self,
         idx=0,
         tabs=
         [[
             GetByLabel(
                 'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Ranks'),
             self.scroll, self, PANEL_RANKS
         ],
          [
              GetByLabel(
                  'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Medals'),
              self.scroll, self, PANEL_MEDALS
          ],
          [
              GetByLabel(
                  'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Permissions'
              ), self.scroll, self, PANEL_PERMISSIONS
          ]],
         groupID='cs_decorations')
Beispiel #6
0
    def Check(self, updatewnd = 0, autoselecttab = 1, checknone = 0):
        if self is None or self.destroyed:
            return
        myWindows = self.GetWindows()
        if checknone and len(myWindows) == 0:
            self.Close()
            return
        self.SetMinWH()
        tabs = []
        label = ''
        allPinned = True
        allCompact = True
        for wnd in myWindows:
            if wnd is None or wnd.destroyed:
                continue
            tabs.append([wnd.GetCaption(),
             wnd,
             self,
             wnd])
            wnd.HideHeader()
            wnd.HideBackground()
            if not wnd.IsPinned():
                allPinned = False
            if not wnd.IsCompact():
                allCompact = False
            wnd.state = uiconst.UI_PICKCHILDREN
            label = label + wnd.GetCaption() + '-'

        self._SetPinned(allPinned)
        if allCompact:
            self.Compact()
        else:
            self.UnCompact()
        if len(tabs):
            if len(label):
                label = label[:-1]
            self.sr.tabs.Flush()
            maintabs = TabGroup(parent=self.sr.tabs, name='tabparent', groupID=self.name, tabs=tabs, autoselecttab=autoselecttab, padTop=3)
            maintabs.rightMargin = 80
            alltabs = maintabs.GetTabs()
            if alltabs:
                for i in xrange(len(alltabs)):
                    tab = alltabs[i]
                    wnd = myWindows[i]
                    tab.GetMenu = wnd.GetMenu
                    tab.SetIcon(wnd.headerIconNo, 14, getattr(wnd.sr.headerIcon, 'hint', ''), getattr(wnd.sr.headerIcon, 'GetMenu', None))
                    utilMenuFunc = wnd.GetUtilMenuFunc()
                    if utilMenuFunc is not None:
                        tab.SetUtilMenu(utilMenuFunc)
                    if wnd.isBlinking:
                        tab.Blink()

                self.SetCaption(label)
    def Check(self, updatewnd = 0, autoselecttab = 1, checknone = 0):
        if self is None or self.destroyed:
            return
        myWindows = self.GetWindows()
        if checknone and len(myWindows) == 0:
            self.Close()
            return
        self.SetMinWH()
        tabs = []
        label = ''
        allPinned = True
        allCompact = True
        for wnd in myWindows:
            if wnd is None or wnd.destroyed:
                continue
            tabs.append([wnd.GetCaption(),
             wnd,
             self,
             wnd])
            wnd.HideHeader()
            wnd.HideBackground()
            if not wnd.IsPinned():
                allPinned = False
            if not wnd.IsCompact():
                allCompact = False
            wnd.state = uiconst.UI_PICKCHILDREN
            label = label + wnd.GetCaption() + '-'

        self._SetPinned(allPinned)
        if allCompact:
            self.Compact()
        else:
            self.UnCompact()
        if len(tabs):
            if len(label):
                label = label[:-1]
            self.sr.tabs.Flush()
            maintabs = TabGroup(parent=self.sr.tabs, name='tabparent', groupID=self.name, tabs=tabs, autoselecttab=autoselecttab, padTop=3)
            maintabs.rightMargin = 80
            alltabs = maintabs.GetTabs()
            if alltabs:
                for i in xrange(len(alltabs)):
                    tab = alltabs[i]
                    wnd = myWindows[i]
                    tab.GetMenu = wnd.GetMenu
                    tab.SetIcon(wnd.headerIconNo, 14, getattr(wnd.sr.headerIcon, 'hint', ''), getattr(wnd.sr.headerIcon, 'GetMenu', None))
                    utilMenuFunc = wnd.GetUtilMenuFunc()
                    if utilMenuFunc is not None:
                        tab.SetUtilMenu(utilMenuFunc)
                    if wnd.isBlinking:
                        tab.Blink()

                self.SetCaption(label)
Beispiel #8
0
 def ApplyAttributes(self, attributes):
     Container.ApplyAttributes(self, attributes)
     self.scroll = Scroll(parent=self, padding=(0, 4, 0, 4))
     self.scroll.sr.id = 'charsheet_standings'
     self.tabs = TabGroup(
         name='tabparent',
         parent=self,
         idx=0,
         tabs=((GetByLabel(
             'UI/CharacterSheet/CharacterSheetWindow/StandingTabs/LikedBy'
         ), self.scroll, self, 'mystandings_to_positive'), (GetByLabel(
             'UI/CharacterSheet/CharacterSheetWindow/StandingTabs/DislikeBy'
         ), self.scroll, self, 'mystandings_to_negative')),
         groupID='cs_standings')
Beispiel #9
0
 def ConstructUI(self):
     self.hintLabel = EveCaptionMedium(
         parent=self,
         align=uiconst.TOTOP,
         top=50,
         text='<center>%s' %
         GetByLabel('UI/Structures/AccessGroups/CreateGroup'))
     self.innerCont = Container(parent=self, name='innerCont')
     self.nameAndDescCont = NameAndDescCont(name='nameAndDescCont',
                                            parent=self.innerCont,
                                            align=uiconst.TOTOP)
     self.dropCont = DropCont(parent=self.innerCont,
                              align=uiconst.TOTOP,
                              controller=self.controller)
     btnText = GetByLabel('UI/Structures/AccessGroups/AddPublic')
     self.addParent = Container(parent=self.innerCont,
                                align=uiconst.TOBOTTOM,
                                height=32)
     self.addMemberCont = AddPublic(parent=self.addParent,
                                    padBottom=2,
                                    func=self.AddPublicGroup)
     self.addMemberCont = AddMemberCont(parent=self.addParent,
                                        func=self.AddMembers,
                                        padBottom=2,
                                        padRight=4)
     self.groupCont = Container(name='browserCont',
                                parent=self.innerCont,
                                padding=(0, 2, 0, 4))
     self.groupMemberCont = AccessGroupMemberCont(
         name='groupMemberCont',
         parent=self.groupCont,
         controller=self.controller)
     self.auditLogCont = AuditLogCont(name='auditLogCont',
                                      parent=self.groupCont,
                                      controller=self.controller)
     tabs = ((GetByLabel('UI/Structures/AccessGroups/GroupMembers'),
              self.groupMemberCont, None, 'groupMemberCont', None),
             (GetByLabel('UI/Structures/AccessGroups/GroupLogs'),
              self.auditLogCont, None, 'auditLogCont', None))
     self.tabs = TabGroup(parent=self.groupCont,
                          tabs=tabs,
                          height=26,
                          labelPadding=12,
                          idx=0,
                          padLeft=0,
                          groupID='groupMemberConts',
                          callback=self.OnTabSelected,
                          autoselecttab=True)
Beispiel #10
0
class StandingsPanel(Container):
    default_name = 'StandingsPanel'

    def ApplyAttributes(self, attributes):
        Container.ApplyAttributes(self, attributes)
        self.scroll = Scroll(parent=self, padding=(0, 4, 0, 4))
        self.scroll.sr.id = 'charsheet_standings'
        self.tabs = TabGroup(
            name='tabparent',
            parent=self,
            idx=0,
            tabs=((GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/StandingTabs/LikedBy'
            ), self.scroll, self, 'mystandings_to_positive'), (GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/StandingTabs/DislikeBy'
            ), self.scroll, self, 'mystandings_to_negative')),
            groupID='cs_standings')

    def LoadPanel(self, *args):
        self.tabs.AutoSelect()

    def Load(self, key):
        positive = key == 'mystandings_to_positive'
        scrolllist = sm.GetService('standing').GetStandingEntries(
            positive, session.charid)
        self.scroll.Load(contentList=scrolllist)
Beispiel #11
0
 def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     settingCont = Container(parent=self.sr.main, name='settingCont', align=uiconst.TOTOP, height=60)
     isCharacterListening = sm.RemoteSvc('achievementTrackerMgr').IsCharacterIsListening(session.charid)
     if isCharacterListening:
         text = 'This character is listening for broadcasted opportunity changes'
     else:
         text = 'This character is <color=red><b>NOT</b></color> listening for broadcasted opportunity changes'
     listendingLabel = EveLabelMedium(parent=settingCont, name='listendingLabel', text=text, align=uiconst.TOTOP, padLeft=10)
     showOpportunities = settings.user.ui.Get('opportunities_showTemp', False)
     cb = Checkbox(text='Show in info panel', parent=settingCont, configName='opportunities_showTemp', checked=showOpportunities, callback=self.CheckBoxChange, prefstype=('user', 'ui'), align=uiconst.TOTOP, padding=(9, 4, 0, 0))
     self.mainContainer = AchievementMainContainer(align=uiconst.TOALL, parent=self.sr.main)
     self.conditionsCont = ConditionsContainer(align=uiconst.TOALL, parent=self.sr.main)
     self.groupCont = GroupContainer(align=uiconst.TOALL, parent=self.sr.main)
     tabs = [['Achievements',
       None,
       self,
       'achievements',
       self.mainContainer], ['Conditions',
       None,
       self,
       'conditions',
       self.conditionsCont], ['AchievementGroup',
       None,
       self,
       'groups',
       self.groupCont]]
     maintabs = TabGroup(name='tabparent', align=uiconst.TOTOP, height=18, parent=self.sr.main, idx=1, tabs=tabs, groupID='achievements', autoselecttab=True)
     self.initData()
 def ApplyAttributes(self, attributes):
     Container.ApplyAttributes(self, attributes)
     self.callback = attributes.callback
     self.starColorGroups = []
     self.starColorByID = None
     self.loadedTab = None
     self.sr.scroll = Scroll(parent=self)
     self.sr.scroll.sr.id = 'mapspalletescroll'
     self.sr.scroll.OnSelectionChange = self.OnSelectionChange
     self.sr.scroll.HideBackground()
     self.sr.scroll.RemoveActiveFrame()
     starviewstabs = TabGroup(name='tabparent',
                              parent=self,
                              idx=0,
                              padTop=4)
     starviewstabs.Startup(
         [[
             localization.GetByLabel('UI/Map/MapPallet/tabStars'),
             self.sr.scroll, self, 'starview_color'
         ],
          [
              localization.GetByLabel('UI/Map/MapPallet/tabLabels'),
              self.sr.scroll, self, 'mapsettings_labels'
          ],
          [
              localization.GetByLabel('UI/Map/MapPallet/tabMapLines'),
              self.sr.scroll, self, 'mapsettings_lines'
          ],
          [
              localization.GetByLabel('UI/Map/MapPallet/tabSolarSystemMap'),
              self.sr.scroll, self, 'mapsettings_solarsystem'
          ],
          [
              localization.GetByLabel('UI/Map/MapPallet/tabTiles'),
              self.sr.scroll, self, 'mapsettings_tiles'
          ],
          [
              localization.GetByLabel('UI/Map/MapPallet/tabMapAnimation'),
              self.sr.scroll, self, 'mapsettings_other'
          ]],
         'starmaptabs',
         autoselecttab=1)
Beispiel #13
0
 def ApplyAttributes(self, attributes):
     uicontrols.Window.ApplyAttributes(self, attributes)
     self.SetTopparentHeight(0)
     runningTaskletsPanel = RunningTasklets(parent=self.sr.main)
     timesliceWarningsPanel = TimesliceWarnings(parent=self.sr.main)
     TabGroup(parent=self.sr.main,
              groupID='TaskletsGroupID',
              idx=0,
              tabs=(('Running tasklets', runningTaskletsPanel, self.sr.main,
                     'taskletsID1'),
                    ('Timeslice warnings', timesliceWarningsPanel,
                     self.sr.main, 'taskletsID2')))
 def LoadTabs(self):
     self.VerifySelectedProfileIdIsValid()
     profileID = self.structureBrowserController.GetSelectedProfileID()
     self.structeListAndProfileSettingsCont.Flush()
     myStructuresPanel = MyStructuresPanel(
         parent=self.structeListAndProfileSettingsCont,
         allStructuresProfileController=self.allStructuresProfileController,
         structureBrowserController=self.structureBrowserController)
     tabs = [(GetByLabel('UI/StructureBrowser/StructuresWithProfile'),
              myStructuresPanel, None, 'myStructuresPanel', None,
              GetByLabel('UI/StructureBrowser/StructuresWithProfileHint'))]
     if profileID != browserUIConst.ALL_PROFILES:
         self.profileSettings = StructureProfileSettingCont(
             parent=self.structeListAndProfileSettingsCont,
             allStructuresProfileController=self.
             allStructuresProfileController,
             structureBrowserController=self.structureBrowserController)
         profileTab = (
             GetByLabel('UI/StructureBrowser/ProfileSettings'),
             self.profileSettings, None, 'profileSettings', None,
             GetByLabel('UI/StructureBrowser/ProfileSettingsHint'))
         tabs.append(profileTab)
     self.tabs = TabGroup(parent=self.structeListAndProfileSettingsCont,
                          tabs=tabs,
                          height=32,
                          idx=0,
                          padLeft=0,
                          groupID='profile_structuresAndsettings',
                          padTop=0)
     self.profileDescLabel = EveLabelMedium(
         parent=self.structeListAndProfileSettingsCont,
         name='profileDescLabel',
         align=uiconst.TOTOP,
         idx=0)
     self.profileNameLabel = EveCaptionSmall(
         parent=self.structeListAndProfileSettingsCont,
         name='profileNameLabel',
         align=uiconst.TOTOP,
         idx=0)
     self.SetProfileName()
class StructureBrowserWnd(Window):
    default_captionLabelPath = 'UI/Structures/Browser/StructureBrowser'
    descriptionLabelPath = 'UI/Structures/Browser/StructureBrowserDescription'
    default_name = 'Structure Browser'
    default_windowID = 'StructureBrowser'
    default_width = 800
    default_height = 600
    default_iconNum = 'res:/UI/Texture/WindowIcons/structureBrowser.png'
    default_minSize = (600, 450)

    def ApplyAttributes(self, attributes):
        Window.ApplyAttributes(self, attributes)
        self.browserMyStructures = None
        self.tabs = None
        self.SetWndIcon(self.iconNum, mainTop=-8)
        WndCaptionLabel(text=GetByLabel('UI/Structures/Browser/StructureBrowser'), subcaption=GetByLabel('UI/StructureBrowser/Delayed5Minutes'), parent=self.sr.topParent, align=uiconst.RELATIVE)
        self.controller = sm.GetService('structureControllers').GetStructureBrowserController()
        self.browserCont = Container(name='browserCont', parent=self.sr.main, padding=4)
        self.browserAllStructures = BrowserAllStructures(parent=self.browserCont, structureBrowserController=self.controller, padTop=4)
        if session.corprole & const.corpRoleStationManager:
            self.browserMyStructures = BrowserMyCorpStructures(parent=self.browserCont, padTop=4, structureBrowserController=self.controller)
            tabs = ((GetByLabel('UI/Structures/Browser/AllStructures'),
              self.browserAllStructures,
              None,
              'allStructures',
              None,
              GetByLabel('UI/StructureBrowser/TabAllStructures')), (GetByLabel('UI/Structures/Browser/MyStructures'),
              self.browserMyStructures,
              None,
              'myStructures',
              None,
              GetByLabel('UI/StructureBrowser/TabMyStructures')))
            self.tabs = TabGroup(parent=self.browserCont, tabs=tabs, height=26, labelPadding=12, idx=0, padLeft=0, groupID='StructureBrowser')
        else:
            self.browserAllStructures.LoadPanel()

    def ForceProfileSettingsSelected(self):
        if self.tabs:
            self.tabs.AutoSelect()
        if self.browserAllStructures:
            self.browserMyStructures.ForceProfileSettingsSelected()

    def CloseByUser(self, *args):
        browserController = sm.GetService('structureControllers').GetStructureBrowserController()
        if not browserController.PlayerWantsToLeaveProfile():
            return
        browserController.SetProfileChangedValue(False)
        Window.CloseByUser(self, *args)
Beispiel #16
0
class Lobby(Window):
    __guid__ = 'form.Lobby'
    __notifyevents__ = ['OnCharNowInStation',
     'OnCharNoLongerInStation',
     'OnProcessStationServiceItemChange',
     'OnAgentMissionChange',
     'OnStandingSet',
     'OnCorporationChanged',
     'OnCorporationMemberChanged',
     'OnPrimaryViewChanged',
     'OnSetDevice']
    default_windowID = 'lobby'
    default_top = 16
    default_width = 223
    default_captionLabelPath = 'UI/Station/StationServices'
    default_pinned = True
    selectedGroupButtonID = None

    @staticmethod
    def default_height(*args):
        return uicore.desktop.height - 100

    @staticmethod
    def default_left(*args):
        return uicore.desktop.width - Lobby.default_width - 16

    def OnPrimaryViewChanged(self, oldViewInfo, newViewInfo):
        """
        Since the view states happen so late in all transitions we
        need to rehook the function and label to the station mode button.
        """
        self.UpdateCQButton(newViewInfo.name)

    def OnSetDevice(self):
        bottom = self.top + self.height
        if bottom > uicore.desktop.height:
            self.height = max(self.default_minSize[1], uicore.desktop.height - self.top)
        right = self.left + self.width
        if right > uicore.desktop.width:
            self.width = max(self.default_minSize[0], uicore.desktop.width - self.left)

    def ApplyAttributes(self, attributes):
        self.viewState = sm.GetService('viewState')
        if not settings.user.ui.Get('stationservicebtns', 1):
            minWidth = BIGBUTTONSIZE + (BIGBUTTONSIZE + BUTTONGAP) * 3 + 14
            minHeight = 495
        else:
            minWidth = SMALLBUTTONSIZE + (SMALLBUTTONSIZE + BUTTONGAP) * 5 + 10
            minHeight = 470
        self.default_minSize = (minWidth, minHeight)
        Window.ApplyAttributes(self, attributes)
        self.stationSvc = sm.GetService('station')
        self.guestScroll = None
        self.sr.serviceAccessCache = {}
        self.SetWndIcon(None)
        self.HideHeader()
        self.scope = 'station'
        self.MakeUnKillable()
        self.MakeUnstackable()
        self.SetTopparentHeight(0)
        main = self.sr.main
        main.clipChildren = True
        self.corpLogoParent = Container(name='corpLogoParent', align=uiconst.TOTOP, height=160, parent=main)
        self.corpName = CaptionLabel(parent=main, align=uiconst.TOTOP, name='corpName', uppercase=False)
        self.undockparent = Container(name='undockparent', align=uiconst.TOTOP, height=78, parent=main)
        self.AddCQButton(parent=self.undockparent)
        self.AddUndockButton(parent=self.undockparent)
        EveLabelMedium(text=localization.GetByLabel('UI/Station/StationServices'), align=uiconst.TOTOP, parent=main, bold=True, padding=(6, 6, 6, 0))
        self.serviceButtons = FlowContainer(name='serviceButtons', align=uiconst.TOTOP, parent=main, contentSpacing=(BUTTONGAP, BUTTONGAP), padding=(6, 6, 3, 6))
        btnGroup = ToggleButtonGroup(name='btnGroup', parent=main, align=uiconst.TOTOP, height=32, padding=(6, 6, 6, 6), idx=-1, callback=self.OnButtonGroupSelection)
        self.mainButtonGroup = btnGroup
        self.guestsPanel = Container(name=GUESTSPANEL, parent=main, padding=const.defaultPadding)
        self.quickFilter = QuickFilterEdit(name='quickFilterEdit', parent=self.guestsPanel)
        self.quickFilter.ReloadFunction = lambda : self.ShowGuests()
        self.guestScroll = BasicDynamicScroll(parent=self.guestsPanel, padTop=const.defaultPadding + self.quickFilter.height)
        guestSettingsMenu = UtilMenu(menuAlign=uiconst.TOPRIGHT, parent=self.guestsPanel, align=uiconst.TOPRIGHT, GetUtilMenu=self.SettingMenu, texturePath='res:/UI/Texture/SettingsCogwheel.png', width=18, height=18, iconSize=18)
        self.userType = settings.user.ui.Get('guestCondensedUserList', False)
        self.agentsPanel = Container(name=AGENTSPANEL, parent=main, padding=const.defaultPadding)
        self.agentFinderBtn = Button(label=localization.GetByLabel('UI/AgentFinder/AgentFinder'), parent=self.agentsPanel, align=uiconst.CENTERTOP, func=uicore.cmd.OpenAgentFinder)
        self.agentScroll = Scroll(parent=self.agentsPanel, padTop=const.defaultPadding + self.agentFinderBtn.height)
        self.officesPanel = Container(name=OFFICESPANEL, parent=main, padding=const.defaultPadding)
        self.officesButtons = FlowContainer(name='officesButtons', align=uiconst.TOTOP, parent=self.officesPanel, contentSpacing=(4, 4), centerContent=True)
        self.officesScroll = Scroll(parent=self.officesPanel, padTop=const.defaultPadding)
        agentsButton = btnGroup.AddButton(AGENTSPANEL, '<center>' + localization.GetByLabel('UI/Station/Lobby/Agents'), self.agentsPanel, btnClass=LobbyToggleButtonGroupButton, hint=localization.GetByLabel('Tooltips/StationServices/AgentsTab_descrtiption'))
        agentsButton.name = 'stationInformationTabAgents'
        guestsButton = btnGroup.AddButton(GUESTSPANEL, '<center>' + localization.GetByLabel('UI/Station/Lobby/Guests'), self.guestsPanel, btnClass=LobbyToggleButtonGroupButton, hint=localization.GetByLabel('Tooltips/StationServices/GuestsTab_description'))
        guestsButton.counter = CounterBox(parent=guestsButton, align=uiconst.TOPRIGHT, left=2, top=-5)
        self.guestsButton = guestsButton
        btnGroup.AddButton(OFFICESPANEL, '<center>' + localization.GetByLabel('UI/Station/Lobby/Offices'), self.officesPanel, btnClass=LobbyToggleButtonGroupButton, hint=localization.GetByLabel('Tooltips/StationServices/OfficesTab_description'))
        activePanel = settings.user.ui.Get('stationsLobbyTabs', AGENTSPANEL)
        if settings.char.windows.Get('dockshipsanditems', 0):
            self.inventoryPanel = Container(name=INVENTORYPANEL, parent=main)
            self.sr.shipsContainer = Container(parent=self.inventoryPanel, state=uiconst.UI_HIDDEN, padding=const.defaultPadding)
            self.sr.itemsContainer = Container(parent=self.inventoryPanel, state=uiconst.UI_HIDDEN, padding=const.defaultPadding)
            tabs = [[localization.GetByLabel('UI/Station/Ships'),
              self.sr.shipsContainer,
              self,
              'lobby_ships'], [localization.GetByLabel('UI/Station/Items'),
              self.sr.itemsContainer,
              self,
              'lobby_items']]
            self.inventoryTabs = TabGroup(name='inventoryPanel', parent=self.inventoryPanel, idx=0)
            self.inventoryTabs.Startup(tabs, 'lobbyInventoryPanel', autoselecttab=True, UIIDPrefix='lobbyInventoryPanelTab')
            self.invButton = btnGroup.AddButton(INVENTORYPANEL, '<center>' + localization.GetByLabel('UI/Station/Lobby/Hangars'), self.inventoryPanel, btnClass=LobbyToggleButtonGroupButton, hint='<b>%s</b><br>%s' % (localization.GetByLabel('Tooltips/StationServices/Hangars'), localization.GetByLabel('Tooltips/StationServices/Hangars_description')))
        elif activePanel == INVENTORYPANEL:
            activePanel = AGENTSPANEL
        btnGroup.SelectByID(activePanel)
        myDefaultView = 'hangar' if session.userid % 2 == 1 else 'station'
        curView = collections.namedtuple('FakeViewInfo', ['name'])(settings.user.ui.Get('defaultDockingView', myDefaultView))
        self.OnPrimaryViewChanged(curView, curView)
        self.LoadOwnerInfo()
        self.LoadServiceButtons()
        if self.destroyed:
            return
        sm.RegisterNotify(self)
        self.UpdateGuestTabText()

    def OnButtonGroupSelection(self, buttonID):
        settings.user.ui.Set('stationsLobbyTabs', buttonID)
        self.selectedGroupButtonID = buttonID
        if buttonID == AGENTSPANEL:
            self.ShowAgents()
        elif buttonID == GUESTSPANEL:
            self.ShowGuests()
        elif buttonID == OFFICESPANEL:
            self.ShowOffices()
        elif buttonID == INVENTORYPANEL:
            if not len(self.sr.shipsContainer.children):
                self.LayoutShipsAndItems()

    def SettingMenu(self, menuParent):
        showCompact = settings.user.ui.Get('guestCondensedUserList', False)
        menuParent.AddCheckBox(text=localization.GetByLabel('UI/Chat/ShowCompactMemberList'), checked=bool(showCompact), callback=(self.ShowGuests, not showCompact))

    def AddCQButton(self, parent):
        """
        Creates the undock button at the bottom of the lobby
        """
        scale = 1.0
        self.cqCont = Container(name='cqCont', align=uiconst.TOLEFT_PROP, width=0.5, parent=parent, state=uiconst.UI_PICKCHILDREN, padding=3)
        width = 63 * scale
        height = 34 * scale
        self.cqSpriteCont = Container(name='cq', align=uiconst.CENTERTOP, width=width, height=height, top=3, parent=self.cqCont, state=uiconst.UI_NORMAL)
        self.cqSprites = []
        spacing = 30 * scale
        for i in xrange(3):
            s = Sprite(parent=self.cqSpriteCont, texturePath='res:/UI/Texture/classes/Lobby/{0}.png'.format(i + 1), align=uiconst.CENTERTOP, width=-width, height=height, left=0, state=uiconst.UI_DISABLED)
            s.color = COLOR_CQ
            self.cqSprites.insert(0, s)

        self.cqLabel = EveLabelMedium(parent=self.cqCont, align=uiconst.CENTERTOP, top=8 + height, width=100)
        self.UpdateCQButton()
        if gfxsettings.Get(gfxsettings.MISC_LOAD_STATION_ENV):
            self.cqSpriteCont.OnClick = self.OnCQClicked
            self.cqSpriteCont.OnMouseEnter = self.OnCQMouseEnter
            self.cqSpriteCont.OnMouseExit = self.OnCQMouseExit
        else:
            self.cqSpriteCont.hint = localization.GetByLabel('UI/Station/CannotEnterCaptainsQuarters')
            for s in self.cqSprites:
                s.opacity = 0.2

    def OnCQClicked(self, *args):
        self.OnCQMouseExit()
        for i, s in enumerate(self.cqSprites):
            uicore.animations.SpGlowFadeIn(s, glowColor=(0.8, 0.8, 0.1, 0.3), glowExpand=1, loops=1, duration=1.0, curveType=uiconst.ANIM_WAVE, timeOffset=(3 - i) * 0.1)

        if self.IsInCQ():
            self.EnterHangar()
        else:
            self.EnterCQ()

    def OnCQMouseEnter(self, *args):
        self.AnimateCQSprites((0.8, 1, 1))

    def OnCQMouseExit(self, *args):
        self.AnimateCQSprites(COLOR_CQ[:3])

    def AnimateCQSprites(self, endColor):
        for i, s in enumerate(self.cqSprites):
            uicore.animations.SpColorMorphTo(s, startColor=(s.color.r, s.color.g, s.color.b), endColor=endColor, duration=0.1)

    def UpdateCQButton(self, viewName = None):
        isInCQ = False
        if viewName is not None:
            isInCQ = viewName == 'station'
        else:
            isInCQ = self.IsInCQ()
        if isInCQ:
            self.cqLabel.text = '<center>' + localization.GetByLabel('UI/Commands/EnterHangar') + '</center>'
        else:
            self.cqLabel.text = '<center>' + localization.GetByLabel('UI/Commands/EnterCQ') + '</center>'
        self.cqCont.height = self.cqLabel.height + self.cqSpriteCont.height + 6

    def IsInCQ(self):
        viewStateSvc = sm.GetService('viewState')
        currentView = viewStateSvc.GetCurrentView()
        if currentView is not None and currentView.name == 'station':
            return True
        else:
            return False

    def AddUndockButton(self, parent):
        """
        Creates the undock button at the bottom of the lobby
        """
        scale = 1.0
        self.undockCont = Container(name='undockCont', align=uiconst.TORIGHT_PROP, width=0.5, parent=parent, state=uiconst.UI_PICKCHILDREN, padding=3)
        width = 63 * scale
        height = 34 * scale
        self.undockSpriteCont = Container(name='undock', align=uiconst.CENTERTOP, width=width, height=height, top=3, parent=self.undockCont, state=uiconst.UI_NORMAL)
        self.undockSprites = []
        spacing = 30 * scale
        for i in xrange(3):
            s = Sprite(parent=self.undockSpriteCont, texturePath='res:/UI/Texture/classes/Lobby/{0}.png'.format(i + 1), align=uiconst.CENTERTOP, width=width, height=height, left=0, state=uiconst.UI_DISABLED)
            s.color = COLOR_UNDOCK
            self.undockSprites.append(s)

        self.undockLabel = EveLabelMedium(parent=self.undockCont, align=uiconst.CENTERTOP, top=8 + height, width=100)
        self.UpdateUndockButton()
        self.undockCont.height = self.undockLabel.height + height + 6
        self.undockSpriteCont.OnClick = self.OnUndockClicked
        self.undockSpriteCont.OnMouseEnter = self.OnUndockMouseEnter
        self.undockSpriteCont.OnMouseExit = self.OnUndockMouseExit

    def OnUndockClicked(self, *args):
        if sm.GetService('station').PastUndockPointOfNoReturn():
            return
        uthread.new(self.AttemptToUndock).context = 'UndockButtonThread'

    def LockCQButton(self):
        self.cqCont.opacity = 0.5
        self.cqCont.state = uiconst.UI_DISABLED

    def UnlockCQButton(self):
        self.cqCont.opacity = 1.0
        self.cqCont.state = uiconst.UI_NORMAL

    def AttemptToUndock(self):
        exiting = sm.GetService('station').Exit()
        if exiting:
            self.LockCQButton()

    def OnUndockMouseEnter(self, *args):
        self.AnimateUndockSprites((1, 1, 0.8))

    def OnUndockMouseExit(self, *args):
        self.AnimateUndockSprites(COLOR_UNDOCK[:3])

    def AnimateUndockSprites(self, endColor):
        if sm.GetService('station').PastUndockPointOfNoReturn():
            return
        for i, s in enumerate(self.undockSprites):
            uicore.animations.SpColorMorphTo(s, startColor=(s.color.r, s.color.g, s.color.b), endColor=endColor, duration=0.1)

    def SetUndockProgress(self, undockProgress):
        if undockProgress is None:
            self.UpdateUndockButton()
            return
        i = int(undockProgress * 3)
        if i < 3:
            self.UpdateUndockButton()
            uicore.animations.SpGlowFadeIn(self.undockSprites[i], glowColor=(1.0, 1.0, 0.8, 0.2), glowExpand=1, loops=1, duration=0.2)
        else:
            self.undockLabel.text = '<center>' + localization.GetByLabel('UI/Station/UndockingConfirmed') + '</center>'
            for i, s in enumerate(self.undockSprites):
                uicore.animations.StopAllAnimations(s)
                s.glowColor = (0, 0, 0, 0)
                uicore.animations.SpColorMorphTo(s, startColor=(1, 0.8, 0), endColor=(1, 0, 0), loops=1000, duration=1, curveType=uiconst.ANIM_WAVE, timeOffset=i * 0.1 - 0.5, includeAlpha=False)
                uicore.animations.SpGlowFadeIn(s, glowColor=(1.0, 1.0, 0.8, 0.2), glowExpand=1, loops=1000, duration=1, curveType=uiconst.ANIM_WAVE, timeOffset=i * 0.1)

    def UpdateUndockButton(self):
        if self.stationSvc.exitingstation:
            self.undockLabel.text = '<center>' + localization.GetByLabel('UI/Station/AbortUndock') + '</center>'
            self.LockCQButton()
        else:
            self.undockLabel.text = '<center>' + localization.GetByLabel('UI/Neocom/UndockBtn') + '</center>'
            self.UnlockCQButton()

    def EnterCQ(self, *args):
        if self.viewState.HasActiveTransition():
            return
        sm.GetService('cmd').CmdEnterCQ()

    def EnterHangar(self, *args):
        if self.viewState.HasActiveTransition():
            return
        sm.GetService('cmd').CmdEnterHangar()

    def OnScale_(self, *args):
        return
        height = 0
        for each in self.sr.main.children:
            if each.align in (uiconst.TOTOP, uiconst.TOBOTTOM):
                height += each.padTop + each.height + each.padBottom

        height += 160
        self.SetMinSize([self.minsize[0], height])

    def LayoutShipsAndItems(self):
        self.sr.itemsContainer.Flush()
        itemsContainer = invCont.StationItems(name='stationItems', parent=self.sr.itemsContainer, showControls=True, state=uiconst.UI_NORMAL)
        self.sr.shipsContainer.Flush()
        shipsContainer = invCont.StationShips(name='stationShips', parent=self.sr.shipsContainer, showControls=True, state=uiconst.UI_NORMAL)
        self.invButton.OnDropData = itemsContainer.OnDropData
        self.sr.itemsContainer.OnDropData = itemsContainer.OnDropData
        self.sr.shipsContainer.OnDropData = shipsContainer.OnDropData

    def OnProcessStationServiceItemChange(self, stationID, solarSystemID, serviceID, stationServiceItemID, isEnabled):
        if self.destroyed or stationID != eve.session.stationid:
            return
        for icon in self.serviceButtons.children:
            if hasattr(icon, 'stationServiceIDs') and serviceID in icon.stationServiceIDs:
                self.SetServiceButtonState(icon, [serviceID])

    def OnAgentMissionChange(self, actionID, agentID, tutorialID = None):
        """
        When a mission is declined or completed, that might change which agents
        are available, so update that portion of the lobby if it is displayed.
        """
        if self.selectedGroupButtonID == AGENTSPANEL:
            self.ShowAgents()

    def OnCorporationChanged(self, corpID, change):
        blue.pyos.synchro.Yield()
        self.LoadButtons()

    def OnStandingSet(self, fromID, toID, rank):
        """
        Notification that a standing has been set directly (probably from the
        debug admin window).  Might need to update agent availability.
        """
        if self.selectedGroupButtonID == AGENTSPANEL:
            self.ShowAgents()

    def SetServiceButtonState(self, button, serviceIDs):
        for serviceID in serviceIDs:
            currentstate = sm.GetService('station').GetServiceState(serviceID)
            if currentstate is not None:
                if self.sr.serviceAccessCache.has_key(serviceID):
                    del self.sr.serviceAccessCache[serviceID]
                if not currentstate.isEnabled:
                    button.Disable()
                    button.serviceStatus = localization.GetByLabel('UI/Station/Lobby/Disabled')
                    button.serviceEnabled = False
                else:
                    button.Enable()
                    button.serviceStatus = localization.GetByLabel('UI/Station/Lobby/Enabled')
                    button.serviceEnabled = True

    def LoadServiceButtons(self):
        parent = self.serviceButtons
        parent.Flush()
        services = sm.GetService('station').GetStationServiceInfo()
        serviceMask = eve.stationItem.serviceMask
        icon = None
        stationservicebtns = settings.user.ui.Get('stationservicebtns', 1)
        btnsize = BIGBUTTONSIZE
        if stationservicebtns:
            btnsize = SMALLBUTTONSIZE
        haveServices = []
        for service in services:
            hasStationService = False
            combinedServiceMask = sum(service.serviceIDs)
            if serviceMask & combinedServiceMask > 0:
                hasStationService = True
                if service.name == 'navyoffices':
                    if not sm.GetService('facwar').CheckStationElegibleForMilitia():
                        hasStationService = False
                elif service.name == 'securityoffice':
                    if not sm.GetService('securityOfficeSvc').CanAccessServiceInStation(session.stationid2):
                        hasStationService = False
            if hasStationService or -1 in service.serviceIDs:
                haveServices.append(service)

        for service in reversed(haveServices):
            button = BigButton(parent=parent, width=btnsize, height=btnsize, name=service.name, align=uiconst.NOALIGN)
            button.Startup(btnsize, btnsize, iconOpacity=0.75)
            button.cmdStr = service.command
            button.stationServiceIDs = service.serviceIDs
            button.displayName = service.label
            button.OnClick = (self.OnSvcBtnClick, button)
            button.serviceStatus = localization.GetByLabel('UI/Station/Lobby/Enabled')
            button.serviceEnabled = True
            if hasattr(service, 'iconID'):
                button.SetTexturePath(service.iconID)
            else:
                button.SetTexturePath(service.texturePath)
            self.SetServiceButtonState(button, service.serviceIDs)
            button.LoadTooltipPanel = self.LoadServiceButtonTooltipPanel

    def LoadServiceButtonTooltipPanel(self, tooltipPanel, tooltipOwner, *args):
        tooltipPanel.LoadGeneric3ColumnTemplate()
        command = uicore.cmd.commandMap.GetCommandByName(tooltipOwner.cmdStr)
        tooltipPanel.AddCommandTooltip(command)
        if not tooltipOwner.serviceEnabled:
            tooltipPanel.AddLabelMedium(text=localization.GetByLabel('UI/Station/Lobby/Disabled'), color=(1, 0, 0, 1), bold=True, colSpan=tooltipPanel.columns)

    def OnSvcBtnClick(self, btn, *args):
        self.CheckCanAccessService(btn.name)
        sm.GetService('station').LoadSvc(btn.name)

    def CheckCanAccessService(self, serviceName):
        services = sm.GetService('station').GetStationServiceInfo()
        for service in services:
            if service.name == serviceName:
                corpStationMgr = None
                now = blue.os.GetWallclockTime()
                for stationServiceID in service.serviceIDs:
                    doCheck = 1
                    time, result = (None, None)
                    if self.sr.serviceAccessCache.has_key(stationServiceID):
                        time, result = self.sr.serviceAccessCache[stationServiceID]
                        if time + const.MIN * 5 > now:
                            doCheck = 0
                    if doCheck:
                        if corpStationMgr is None:
                            corpStationMgr = sm.GetService('corp').GetCorpStationManager()
                        try:
                            corpStationMgr.DoStandingCheckForStationService(stationServiceID)
                            self.sr.serviceAccessCache[stationServiceID] = (now, None)
                        except Exception as e:
                            self.sr.serviceAccessCache[stationServiceID] = (now, e)
                            sys.exc_clear()

                    time, result = self.sr.serviceAccessCache[stationServiceID]
                    if result is not None:
                        raise result

    def LoadButtons(self):
        if self.destroyed:
            return
        btns = []
        officeExists = sm.GetService('corp').GetOffice() is not None
        canRent = session.corprole & const.corpRoleCanRentOffice == const.corpRoleCanRentOffice
        canMove = session.corprole & const.corpRoleDirector == const.corpRoleDirector
        if canRent and not officeExists:
            rentLabel = localization.GetByLabel('UI/Station/Lobby/RentOffice')
            btns.append([rentLabel, self.RentOffice, None])
        if canMove and officeExists:
            btns.append([localization.GetByLabel('UI/Station/Hangar/UnrentOffice'), self.UnrentOffice, None])
        if canMove:
            isHQHere = sm.GetService('corp').GetCorporation().stationID == session.stationid2
            if not isHQHere:
                hqLabel = localization.GetByLabel('UI/Station/Lobby/MoveHeadquartersHere')
                btns.append([hqLabel, self.SetHQ, None])
            if not officeExists and sm.GetService('corp').HasCorpImpoundedItemsAtStation():
                btns.append([localization.GetByLabel('UI/Inventory/ReleaseItems'), self.ReleaseImpoundedItems, None])
        if sm.GetService('corp').DoesCharactersCorpOwnThisStation():
            mgmtLabel = localization.GetByLabel('UI/Station/Lobby/StationManagement')
            btns.append([mgmtLabel, self.OpenStationManagement, None])
        if self.destroyed:
            return
        self.officesButtons.Flush()
        for label, func, args in btns:
            Button(parent=self.officesButtons, label=label, func=func, args=args, align=uiconst.NOALIGN)

    def ReleaseImpoundedItems(self, *args):
        corpStationMgr = sm.GetService('corp').GetCorpStationManager()
        cost = corpStationMgr.GetQuoteForGettingCorpJunkBack()
        if eve.Message('CrpJunkAcceptCost', {'cost': FmtAmt(cost)}, uiconst.YESNO) != uiconst.ID_YES:
            return
        corpStationMgr.PayForReturnOfCorpJunk(cost)
        sm.GetService('corp').hasImpoundedItemsCacheTime = None
        self.LoadButtons()

    def UnrentOffice(self, *args):
        items = invCtrl.StationCorpHangar(divisionID=None).GetItems()
        asked = False
        if len([ item for item in items if item.ownerID == session.corpid ]):
            asked = True
            if eve.Message('crpUnrentOfficeWithContent', {}, uiconst.YESNO) != uiconst.ID_YES:
                return
        if not asked:
            if eve.Message('crpUnrentOffice', {}, uiconst.YESNO) != uiconst.ID_YES:
                return
        corpStationMgr = sm.GetService('corp').GetCorpStationManager()
        sm.GetService('corp').hasImpoundedItemsCacheTime = None
        corpStationMgr.CancelRentOfOffice()

    def OpenStationManagement(self, *args):
        uthread.new(uicore.cmd.OpenStationManagement)

    def LoadOwnerInfo(self):
        parent = self.corpLogoParent
        parent.Flush()
        corpID = eve.stationItem.ownerID
        size = 128 if CheckCorpID(corpID) else 64
        logo = GetLogoIcon(itemID=corpID, parent=parent, acceptNone=False, state=uiconst.UI_DISABLED, pos=(0,
         8,
         size,
         size), align=uiconst.CENTERTOP)
        InfoIcon(typeID=const.typeCorporation, itemID=corpID, left=const.defaultPadding, top=20, align=uiconst.TOPRIGHT, parent=parent, idx=0)
        self.corpLogoParent.height = logo.top + logo.height
        if not CheckCorpID(corpID):
            self.corpName.text = '<center>' + cfg.eveowners.Get(corpID).name
            self.corpName.display = True
        else:
            self.corpName.display = False

    def ImVisible(self):
        return bool(self.state != uiconst.UI_HIDDEN and not self.IsCollapsed() and not self.IsMinimized())

    def Load(self, key):
        pass

    @telemetry.ZONE_METHOD
    def OnCharNowInStation(self, rec):
        if self.destroyed or not session.stationid2:
            return
        self.UpdateGuestTabText()
        if self.selectedGroupButtonID == GUESTSPANEL:
            charID, corpID, allianceID, warFactionID = rec
            cfg.eveowners.Prime([charID])
            if self.destroyed:
                return
            newcharinfo = cfg.eveowners.Get(charID)
            idx = 0
            for each in self.guestScroll.GetNodes():
                if each.charID == charID:
                    return
                if CaseFoldCompare(each.info.name, newcharinfo.name) > 0:
                    break
                idx += 1

            filteredGuest = None
            guestFilter = self.quickFilter.GetValue()
            if len(guestFilter):
                filteredGuest = NiceFilter(self.quickFilter.QuickFilter, newcharinfo.name)
            if filteredGuest or len(guestFilter) == 0:
                entry = GetListEntry(self.userEntry, {'charID': charID,
                 'info': newcharinfo,
                 'label': newcharinfo.name,
                 'corpID': corpID,
                 'allianceID': allianceID,
                 'warFactionID': warFactionID})
                self.guestScroll.AddNodes(idx, [entry])

    @telemetry.ZONE_METHOD
    def OnCharNoLongerInStation(self, rec):
        if self.destroyed or not session.stationid2:
            return
        self.UpdateGuestTabText()
        charID, corpID, allianceID, warFactionID = rec
        if self.selectedGroupButtonID == GUESTSPANEL:
            for entry in self.guestScroll.GetNodes():
                if entry.charID == charID:
                    self.guestScroll.RemoveNodes([entry])
                    return

    def ShowGuests(self, condensed = None, *args):
        if self.selectedGroupButtonID != GUESTSPANEL:
            return
        if condensed is not None:
            settings.user.ui.Set('guestCondensedUserList', condensed)
        self.SetGuestEntryType()
        guests = sm.GetService('station').GetGuests()
        owners = []
        for charID in guests.keys():
            if charID not in owners:
                owners.append(charID)

        cfg.eveowners.Prime(owners)
        guestsNames = [ KeyVal(name=cfg.eveowners.Get(charID).name, charID=charID) for charID in guests ]
        guestFilter = self.quickFilter.GetValue()
        if len(guestFilter):
            guestsNames = NiceFilter(self.quickFilter.QuickFilter, guestsNames)
        if self.destroyed:
            return
        scrolllist = []
        for guest in guestsNames:
            charID = guest.charID
            corpID, allianceID, warFactionID = guests[charID]
            charinfo = cfg.eveowners.Get(charID)
            scrolllist.append((charinfo.name.lower(), GetListEntry(self.userEntry, {'charID': charID,
              'info': charinfo,
              'label': charinfo.name,
              'corpID': corpID,
              'allianceID': allianceID,
              'warFactionID': warFactionID})))

        scrolllist = SortListOfTuples(scrolllist)
        self.guestScroll.Clear()
        self.guestScroll.AddNodes(0, scrolllist)
        self.UpdateGuestTabText()

    def UpdateGuestTabText(self):
        numGuests = len(sm.GetService('station').GetGuests())
        self.guestsButton.counter.text = numGuests

    def SetGuestEntryType(self):
        if settings.user.ui.Get('guestCondensedUserList', False):
            self.userEntry = 'ChatUserSimple'
        else:
            self.userEntry = 'User'

    def ShowAgents(self):
        try:
            agentsSvc = sm.GetService('agents')
            journalSvc = sm.GetService('journal')
            facWarSvc = sm.StartService('facwar')
            standingSvc = sm.StartService('standing')
            epicArcStatusSvc = sm.RemoteSvc('epicArcStatus')
            if self.selectedGroupButtonID != AGENTSPANEL:
                return
            agentMissions = journalSvc.GetMyAgentJournalDetails()[:1][0]
            agentsInStation = agentsSvc.GetAgentsByStationID()[session.stationid2]
            relevantAgents = []
            missionStateDict = {}
            for each in agentMissions:
                missionState, importantMission, missionType, missionName, agentID, expirationTime, bookmarks, remoteOfferable, remoteCompletable, contentID = each
                agent = agentsSvc.GetAgentByID(agentID)
                missionStateDict[agentID] = missionState
                if missionState not in (const.agentMissionStateAllocated, const.agentMissionStateOffered) or agent.agentTypeID in (const.agentTypeGenericStorylineMissionAgent,
                 const.agentTypeStorylineMissionAgent,
                 const.agentTypeEventMissionAgent,
                 const.agentTypeCareerAgent,
                 const.agentTypeEpicArcAgent):
                    relevantAgents.append(agentID)

            localRelevantAgents = []
            for agent in agentsInStation:
                if agent.agentID in relevantAgents:
                    localRelevantAgents.append(agent.agentID)

            if self.destroyed:
                return
            scrolllist = []
            sortlist = []
            for agentID in relevantAgents:
                if not eve.rookieState or agentID in const.rookieAgentList:
                    if agentID not in localRelevantAgents:
                        missionState = missionStateDict.get(agentID)
                        sortlist.append((cfg.eveowners.Get(agentID).name, GetListEntry('AgentEntry', {'charID': agentID,
                          'missionState': missionState})))

            if sortlist:
                agentLabel = localization.GetByLabel('UI/Station/Lobby/AgentsOfInterest')
                scrolllist.append(GetListEntry('Header', {'label': agentLabel}))
                scrolllist += SortListOfTuples(sortlist)
            unavailableAgents = []
            availableAgents = []
            for agent in agentsInStation:
                if agent.agentID in const.rookieAgentList:
                    continue
                if not eve.rookieState or agent.agentID in const.rookieAgentList:
                    isLimitedToFacWar = False
                    if agent.agentTypeID == const.agentTypeFactionalWarfareAgent and facWarSvc.GetCorporationWarFactionID(agent.corporationID) != session.warfactionid:
                        isLimitedToFacWar = True
                    if agent.agentTypeID in (const.agentTypeResearchAgent,
                     const.agentTypeBasicAgent,
                     const.agentTypeEventMissionAgent,
                     const.agentTypeCareerAgent,
                     const.agentTypeFactionalWarfareAgent):
                        standingIsValid = standingSvc.CanUseAgent(agent.factionID, agent.corporationID, agent.agentID, agent.level, agent.agentTypeID)
                        haveMissionFromAgent = agent.agentID in relevantAgents
                        if not isLimitedToFacWar and (standingIsValid or haveMissionFromAgent):
                            availableAgents.append(agent.agentID)
                        else:
                            unavailableAgents.append(agent.agentID)
                    elif agent.agentTypeID == const.agentTypeEpicArcAgent:
                        standingIsValid = standingSvc.CanUseAgent(agent.factionID, agent.corporationID, agent.agentID, agent.level, agent.agentTypeID)
                        haveMissionFromAgent = agent.agentID in relevantAgents
                        epicAgentAvailable = False
                        if haveMissionFromAgent:
                            epicAgentAvailable = True
                        elif standingIsValid:
                            if agent.agentID in relevantAgents or epicArcStatusSvc.AgentHasEpicMissionsForCharacter(agent.agentID):
                                epicAgentAvailable = True
                        if epicAgentAvailable:
                            availableAgents.append(agent.agentID)
                        else:
                            unavailableAgents.append(agent.agentID)
                    if agent.agentTypeID == const.agentTypeAura:
                        if sm.GetService('experimentClientSvc').IsTutorialEnabled():
                            availableAgents.append(agent.agentID)
                    elif agent.agentTypeID in (const.agentTypeGenericStorylineMissionAgent, const.agentTypeStorylineMissionAgent):
                        if agent.agentID in localRelevantAgents:
                            availableAgents.append(agent.agentID)
                        else:
                            unavailableAgents.append(agent.agentID)

            if availableAgents:
                availableLabel = localization.GetByLabel('UI/Station/Lobby/AvailableToYou')
                scrolllist.append(GetListEntry('Header', {'label': availableLabel}))
                sortlist = []
                for agentID in availableAgents:
                    missionState = missionStateDict.get(agentID)
                    sortlist.append((cfg.eveowners.Get(agentID).name, GetListEntry('AgentEntry', {'charID': agentID,
                      'missionState': missionState})))

                scrolllist += SortListOfTuples(sortlist)
            if unavailableAgents:
                unavailableLabel = localization.GetByLabel('UI/Station/Lobby/NotAvailableToYou')
                scrolllist.append(GetListEntry('Header', {'label': unavailableLabel}))
                sortlist = []
                for agentID in unavailableAgents:
                    missionState = missionStateDict.get(agentID)
                    sortlist.append((cfg.eveowners.Get(agentID).name, GetListEntry('AgentEntry', {'charID': agentID,
                      'missionState': missionState})))

                scrolllist += SortListOfTuples(sortlist)
            if self.destroyed:
                return
            self.agentScroll.Load(fixedEntryHeight=40, contentList=scrolllist)
        except:
            log.LogException()
            sys.exc_clear()

    def InteractWithAgent(self, agentID, *args):
        sm.StartService('agents').InteractWith(agentID)

    def SetHQ(self, *args):
        if sm.GetService('godma').GetType(eve.stationItem.stationTypeID).isPlayerOwnable == 1:
            raise UserError('CanNotSetHQAtPlayerOwnedStation')
        if eve.Message('MoveHQHere', {}, uiconst.YESNO) == uiconst.ID_YES:
            sm.GetService('corp').GetCorpStationManager().MoveCorpHQHere()

    def RentOffice(self, *args):
        if not self.sr.Get('isRentOfficeOpening') or not self.sr.isRentOfficeOpening:
            self.sr.isRentOfficeOpening = 1
            try:
                cost = sm.GetService('corp').GetCorpStationManager().GetQuoteForRentingAnOffice()
                if eve.Message('AskPayOfficeRentalFee', {'cost': cost,
                 'duration': const.rentalPeriodOffice * const.DAY}, uiconst.YESNO) == uiconst.ID_YES:
                    officeID = sm.GetService('corp').GetCorpStationManager().RentOffice(cost)
                    if officeID:
                        office = sm.GetService('corp').GetOffice()
                        invCache = sm.GetService('invCache')
                        invCache.InvalidateLocationCache(officeID)
                        if office is not None:
                            folder = invCache.GetInventoryFromId(office.officeFolderID, locationID=session.stationid2)
                            folder.List()
                            wnd = InventoryWindow.GetIfOpen()
                            if not wnd:
                                InventoryWindow.OpenOrShow()
                uthread.new(self.LoadButtons)
                if self.selectedGroupButtonID == OFFICESPANEL:
                    self.ShowOffices()
            finally:
                self.sr.isRentOfficeOpening = 0

    def ShowShips(self):
        if self.sr.shipsContainer is None:
            return
        self.mainButtonGroup.SelectByID(INVENTORYPANEL)
        self.inventoryTabs.ShowPanel(self.sr.shipsContainer)

    def ShowItems(self):
        if self.sr.itemsContainer is None:
            return
        self.mainButtonGroup.SelectByID(INVENTORYPANEL)
        self.inventoryTabs.ShowPanel(self.sr.itemsContainer)

    def ReloadOfficesIfVisible(self):
        if self.selectedGroupButtonID == OFFICESPANEL:
            self.ShowOffices()

    def ShowOffices(self):
        if self.selectedGroupButtonID != OFFICESPANEL:
            return
        self.LoadButtons()
        corpsWithOffices = sm.GetService('corp').GetCorporationsWithOfficesAtStation()
        cfg.corptickernames.Prime([ c.corporationID for c in corpsWithOffices ])
        scrolllist = []
        for corp in corpsWithOffices:
            data = KeyVal()
            data.corpName = corp.corporationName
            data.corpID = corp.corporationID
            data.corporation = corp
            scrolllist.append((data.corpName.lower(), GetListEntry('OfficeEntry', data=data)))

        scrolllist = SortListOfTuples(scrolllist)
        numUnrentedOffices = self.GetNumberOfUnrentedOffices()
        availOfficesLabel = localization.GetByLabel('UI/Station/Lobby/NumAvailableOffices', numOffices=numUnrentedOffices)
        scrolllist.insert(0, GetListEntry('Header', {'label': availOfficesLabel}))
        if not self.destroyed:
            self.officesScroll.Load(contentList=scrolllist)

    def GetNumberOfUnrentedOffices(self):
        return sm.GetService('corp').GetCorpStationManager().GetNumberOfUnrentedOffices()

    def OnCorporationMemberChanged(self, corporationID, memberID, change):
        if memberID == session.charid:
            self.LoadButtons()

    def StopAllBlinkButtons(self):
        for each in self.serviceButtons.children:
            if hasattr(each, 'Blink'):
                each.Blink(0)

    def BlinkButton(self, whatBtn):
        for each in self.serviceButtons.children:
            if each.name.lower() == whatBtn.lower():
                each.Blink(blinks=40)
Beispiel #17
0
 def ApplyAttributes(self, attributes):
     self.viewState = sm.GetService('viewState')
     if not settings.user.ui.Get('stationservicebtns', 1):
         minWidth = BIGBUTTONSIZE + (BIGBUTTONSIZE + BUTTONGAP) * 3 + 14
         minHeight = 495
     else:
         minWidth = SMALLBUTTONSIZE + (SMALLBUTTONSIZE + BUTTONGAP) * 5 + 10
         minHeight = 470
     self.default_minSize = (minWidth, minHeight)
     Window.ApplyAttributes(self, attributes)
     self.stationSvc = sm.GetService('station')
     self.guestScroll = None
     self.sr.serviceAccessCache = {}
     self.SetWndIcon(None)
     self.HideHeader()
     self.scope = 'station'
     self.MakeUnKillable()
     self.MakeUnstackable()
     self.SetTopparentHeight(0)
     main = self.sr.main
     main.clipChildren = True
     self.corpLogoParent = Container(name='corpLogoParent', align=uiconst.TOTOP, height=160, parent=main)
     self.corpName = CaptionLabel(parent=main, align=uiconst.TOTOP, name='corpName', uppercase=False)
     self.undockparent = Container(name='undockparent', align=uiconst.TOTOP, height=78, parent=main)
     self.AddCQButton(parent=self.undockparent)
     self.AddUndockButton(parent=self.undockparent)
     EveLabelMedium(text=localization.GetByLabel('UI/Station/StationServices'), align=uiconst.TOTOP, parent=main, bold=True, padding=(6, 6, 6, 0))
     self.serviceButtons = FlowContainer(name='serviceButtons', align=uiconst.TOTOP, parent=main, contentSpacing=(BUTTONGAP, BUTTONGAP), padding=(6, 6, 3, 6))
     btnGroup = ToggleButtonGroup(name='btnGroup', parent=main, align=uiconst.TOTOP, height=32, padding=(6, 6, 6, 6), idx=-1, callback=self.OnButtonGroupSelection)
     self.mainButtonGroup = btnGroup
     self.guestsPanel = Container(name=GUESTSPANEL, parent=main, padding=const.defaultPadding)
     self.quickFilter = QuickFilterEdit(name='quickFilterEdit', parent=self.guestsPanel)
     self.quickFilter.ReloadFunction = lambda : self.ShowGuests()
     self.guestScroll = BasicDynamicScroll(parent=self.guestsPanel, padTop=const.defaultPadding + self.quickFilter.height)
     guestSettingsMenu = UtilMenu(menuAlign=uiconst.TOPRIGHT, parent=self.guestsPanel, align=uiconst.TOPRIGHT, GetUtilMenu=self.SettingMenu, texturePath='res:/UI/Texture/SettingsCogwheel.png', width=18, height=18, iconSize=18)
     self.userType = settings.user.ui.Get('guestCondensedUserList', False)
     self.agentsPanel = Container(name=AGENTSPANEL, parent=main, padding=const.defaultPadding)
     self.agentFinderBtn = Button(label=localization.GetByLabel('UI/AgentFinder/AgentFinder'), parent=self.agentsPanel, align=uiconst.CENTERTOP, func=uicore.cmd.OpenAgentFinder)
     self.agentScroll = Scroll(parent=self.agentsPanel, padTop=const.defaultPadding + self.agentFinderBtn.height)
     self.officesPanel = Container(name=OFFICESPANEL, parent=main, padding=const.defaultPadding)
     self.officesButtons = FlowContainer(name='officesButtons', align=uiconst.TOTOP, parent=self.officesPanel, contentSpacing=(4, 4), centerContent=True)
     self.officesScroll = Scroll(parent=self.officesPanel, padTop=const.defaultPadding)
     agentsButton = btnGroup.AddButton(AGENTSPANEL, '<center>' + localization.GetByLabel('UI/Station/Lobby/Agents'), self.agentsPanel, btnClass=LobbyToggleButtonGroupButton, hint=localization.GetByLabel('Tooltips/StationServices/AgentsTab_descrtiption'))
     agentsButton.name = 'stationInformationTabAgents'
     guestsButton = btnGroup.AddButton(GUESTSPANEL, '<center>' + localization.GetByLabel('UI/Station/Lobby/Guests'), self.guestsPanel, btnClass=LobbyToggleButtonGroupButton, hint=localization.GetByLabel('Tooltips/StationServices/GuestsTab_description'))
     guestsButton.counter = CounterBox(parent=guestsButton, align=uiconst.TOPRIGHT, left=2, top=-5)
     self.guestsButton = guestsButton
     btnGroup.AddButton(OFFICESPANEL, '<center>' + localization.GetByLabel('UI/Station/Lobby/Offices'), self.officesPanel, btnClass=LobbyToggleButtonGroupButton, hint=localization.GetByLabel('Tooltips/StationServices/OfficesTab_description'))
     activePanel = settings.user.ui.Get('stationsLobbyTabs', AGENTSPANEL)
     if settings.char.windows.Get('dockshipsanditems', 0):
         self.inventoryPanel = Container(name=INVENTORYPANEL, parent=main)
         self.sr.shipsContainer = Container(parent=self.inventoryPanel, state=uiconst.UI_HIDDEN, padding=const.defaultPadding)
         self.sr.itemsContainer = Container(parent=self.inventoryPanel, state=uiconst.UI_HIDDEN, padding=const.defaultPadding)
         tabs = [[localization.GetByLabel('UI/Station/Ships'),
           self.sr.shipsContainer,
           self,
           'lobby_ships'], [localization.GetByLabel('UI/Station/Items'),
           self.sr.itemsContainer,
           self,
           'lobby_items']]
         self.inventoryTabs = TabGroup(name='inventoryPanel', parent=self.inventoryPanel, idx=0)
         self.inventoryTabs.Startup(tabs, 'lobbyInventoryPanel', autoselecttab=True, UIIDPrefix='lobbyInventoryPanelTab')
         self.invButton = btnGroup.AddButton(INVENTORYPANEL, '<center>' + localization.GetByLabel('UI/Station/Lobby/Hangars'), self.inventoryPanel, btnClass=LobbyToggleButtonGroupButton, hint='<b>%s</b><br>%s' % (localization.GetByLabel('Tooltips/StationServices/Hangars'), localization.GetByLabel('Tooltips/StationServices/Hangars_description')))
     elif activePanel == INVENTORYPANEL:
         activePanel = AGENTSPANEL
     btnGroup.SelectByID(activePanel)
     myDefaultView = 'hangar' if session.userid % 2 == 1 else 'station'
     curView = collections.namedtuple('FakeViewInfo', ['name'])(settings.user.ui.Get('defaultDockingView', myDefaultView))
     self.OnPrimaryViewChanged(curView, curView)
     self.LoadOwnerInfo()
     self.LoadServiceButtons()
     if self.destroyed:
         return
     sm.RegisterNotify(self)
     self.UpdateGuestTabText()
Beispiel #18
0
class DecorationsPanel(Container):
    default_name = 'DecorationsPanel'
    __notifyevents__ = [
        'OnRankChange', 'OnUpdatedMedalsAvailable',
        'OnUpdatedMedalStatusAvailable'
    ]

    def ApplyAttributes(self, attributes):
        Container.ApplyAttributes(self, attributes)
        btns = [(GetByLabel(
            'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/SaveDecorationPermissionChanges'
        ), self.SaveDecorationPermissionsChanges, (), 64),
                (GetByLabel(
                    'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/SetAllDecorationPermissions'
                ), self.SetAllDecorationPermissions, (), 64)]
        self.mainAreaButtons = ContainerAutoSize(align=uiconst.TOBOTTOM,
                                                 parent=self)
        ButtonGroup(btns=btns, parent=self.mainAreaButtons, line=False)
        self.decoMedalList = None
        self.decoRankList = None
        self.scroll = Scroll(parent=self, padding=(0, 4, 0, 4))
        self.mydecorationstabs = TabGroup(
            name='tabparent',
            parent=self,
            idx=0,
            tabs=
            [[
                GetByLabel(
                    'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Ranks'),
                self.scroll, self, PANEL_RANKS
            ],
             [
                 GetByLabel(
                     'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Medals'),
                 self.scroll, self, PANEL_MEDALS
             ],
             [
                 GetByLabel(
                     'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Permissions'
                 ), self.scroll, self, PANEL_PERMISSIONS
             ]],
            groupID='cs_decorations')

    def LoadPanel(self, *args):
        self.mydecorationstabs.AutoSelect()

    def SaveDecorationPermissionsChanges(self):
        promptForDelete = False
        changes = {}
        for entry in self.scroll.GetNodes():
            if entry.panel and hasattr(entry.panel, 'flag'):
                if entry.panel.HasChanged():
                    if entry.panel.flag == 1:
                        promptForDelete = True
                    changes[entry.panel.sr.node.itemID] = entry.panel.flag

        if promptForDelete == False or uicore.Message(
                'DeleteMedalConfirmation', {},
                uiconst.YESNO) == uiconst.ID_YES:
            if len(changes) > 0:
                sm.StartService('medals').SetMedalStatus(changes)
        self.decoMedalList = None

    def SetAllDecorationPermissions(self):
        permissionList = [
            (GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Private'), 2),
            (GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Public'), 3)
        ]
        pickedPermission = ListWnd(
            permissionList,
            'generic',
            GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/SetAllDecorationPermissions'
            ),
            GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/PilotLicense/SaveAllChangesImmediately'
            ),
            windowName='permissionPickerWnd')
        if not pickedPermission:
            return
        permissionID = pickedPermission[1]
        m, _ = sm.StartService('medals').GetMedalsReceived(session.charid)
        myDecos = []
        for each in m:
            if each.status != 1:
                myDecos.append(each.medalID)

        myDecos = list(set(myDecos))
        updateDict = {}
        for decoID in myDecos:
            updateDict[decoID] = permissionID

        if len(updateDict) > 0:
            sm.StartService('medals').SetMedalStatus(updateDict)
            self.decoMedalList = None
            self.ShowMyDecorations('mydecorations_permissions')

    def Load(self, key):
        self.ShowMyDecorations(key)

    def ShowMyDecorations(self, key=None):
        if key == PANEL_RANKS:
            self.ShowMyRanks()
        elif key == PANEL_MEDALS:
            self.ShowMyMedals()
        elif key == PANEL_PERMISSIONS:
            self.ShowMyDecorationPermissions()

    def ShowMyMedals(self, charID=None):
        self.mainAreaButtons.Hide()
        if charID is None:
            charID = session.charid
        if self.decoMedalList is None:
            self.decoMedalList = GetMedalScrollEntries(charID)
        self.scroll.sr.id = 'charsheet_mymedals'
        self.scroll.Load(
            contentList=self.decoMedalList,
            noContentHint=GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/NoMedals'))

    def ShowMyRanks(self):
        self.mainAreaButtons.Hide()
        if self.decoRankList is None:
            scrolllist = []
            characterRanks = sm.StartService(
                'facwar').GetCharacterRankOverview(session.charid)
            for characterRank in characterRanks:
                entry = sm.StartService('info').GetRankEntry(characterRank)
                if entry:
                    scrolllist.append(entry)

            self.decoRankList = scrolllist[:]
        self.scroll.sr.id = 'charsheet_myranks'
        self.scroll.Load(
            contentList=self.decoRankList,
            noContentHint=GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/NoRanks'))

    def ShowMyDecorationPermissions(self):
        self.mainAreaButtons.Show()
        scrollHeaders = [
            GetByLabel('UI/CharacterCreation/FirstName'),
            GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Private'),
            GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Public'),
            GetByLabel('UI/PI/Common/Remove')
        ]
        self.scroll.sr.fixedColumns = {
            GetByLabel('UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Private'):
            60,
            GetByLabel('UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Public'):
            60
        }
        self.scroll.sr.id = 'charsheet_decopermissions'
        self.scroll.Load(contentList=[], headers=scrollHeaders)
        self.scroll.OnColumnChanged = self.OnDecorationPermissionsColumnChanged
        publicDeco = sm.StartService('medals').GetMedalsReceivedWithFlag(
            session.charid, [3])
        privateDeco = sm.StartService('medals').GetMedalsReceivedWithFlag(
            session.charid, [2])
        ppKeys = [each for each in publicDeco.keys() + privateDeco.keys()]
        scrolllist = []
        inMedalList = []
        characterMedals, characterMedalInfo = sm.StartService(
            'medals').GetMedalsReceived(session.charid)
        for characterMedal in characterMedals:
            medalID = characterMedal.medalID
            if medalID not in ppKeys:
                continue
            if medalID in inMedalList:
                continue
            inMedalList.append(medalID)
            details = characterMedalInfo.Filter('medalID')
            if details and details.has_key(medalID):
                details = details.get(medalID)
            entry = self.CreateDecorationPermissionsEntry(characterMedal)
            if entry:
                scrolllist.append(entry)

        self.scroll.Load(contentList=scrolllist,
                         headers=scrollHeaders,
                         noContentHint=GetByLabel('UI/Common/NothingFound'))
        self.OnDecorationPermissionsColumnChanged()

    def CreateDecorationPermissionsEntry(self, data):
        entry = {
            'line': 1,
            'label': data.title + '<t><t><t>',
            'itemID': data.medalID,
            'visibilityFlags': data.status,
            'indent': 3,
            'selectable': 0
        }
        return entries.Get('DecorationPermissions', entry)

    def OnDecorationPermissionsColumnChanged(self, *args, **kwargs):
        for entry in self.scroll.GetNodes():
            if entry.panel and getattr(entry.panel, 'OnColumnChanged', None):
                entry.panel.OnColumnChanged()

    def OnRankChange(self, oldrank, newrank):
        if not session.warfactionid:
            return
        self.decoRankList = None
        if self.display:
            self.LoadPanel()

    def OnUpdatedMedalsAvailable(self):
        self.ReloadMedals()

    def OnUpdatedMedalStatusAvailable(self):
        self.ReloadMedals()

    def ReloadMedals(self):
        self.decoMedalList = None
        if self.display:
            self.LoadPanel()
Beispiel #19
0
class GroupCont(Container):
    def ApplyAttributes(self, attributes):
        self.currentGroupID = None
        Container.ApplyAttributes(self, attributes)
        self.controller = attributes.controller
        self.ChangeSignalConnection(connect=True)
        self.ConstructUI()

    def ChangeSignalConnection(self, connect=True):
        signalAndCallback = [
            (self.controller.on_group_updated, self.UpdateGroup),
            (self.controller.on_group_selected, self.GroupSelected)
        ]
        ChangeSignalConnect(signalAndCallback, connect)

    def ConstructUI(self):
        self.hintLabel = EveCaptionMedium(
            parent=self,
            align=uiconst.TOTOP,
            top=50,
            text='<center>%s' %
            GetByLabel('UI/Structures/AccessGroups/CreateGroup'))
        self.innerCont = Container(parent=self, name='innerCont')
        self.nameAndDescCont = NameAndDescCont(name='nameAndDescCont',
                                               parent=self.innerCont,
                                               align=uiconst.TOTOP)
        self.dropCont = DropCont(parent=self.innerCont,
                                 align=uiconst.TOTOP,
                                 controller=self.controller)
        btnText = GetByLabel('UI/Structures/AccessGroups/AddPublic')
        self.addParent = Container(parent=self.innerCont,
                                   align=uiconst.TOBOTTOM,
                                   height=32)
        self.addMemberCont = AddPublic(parent=self.addParent,
                                       padBottom=2,
                                       func=self.AddPublicGroup)
        self.addMemberCont = AddMemberCont(parent=self.addParent,
                                           func=self.AddMembers,
                                           padBottom=2,
                                           padRight=4)
        self.groupCont = Container(name='browserCont',
                                   parent=self.innerCont,
                                   padding=(0, 2, 0, 4))
        self.groupMemberCont = AccessGroupMemberCont(
            name='groupMemberCont',
            parent=self.groupCont,
            controller=self.controller)
        self.auditLogCont = AuditLogCont(name='auditLogCont',
                                         parent=self.groupCont,
                                         controller=self.controller)
        tabs = ((GetByLabel('UI/Structures/AccessGroups/GroupMembers'),
                 self.groupMemberCont, None, 'groupMemberCont', None),
                (GetByLabel('UI/Structures/AccessGroups/GroupLogs'),
                 self.auditLogCont, None, 'auditLogCont', None))
        self.tabs = TabGroup(parent=self.groupCont,
                             tabs=tabs,
                             height=26,
                             labelPadding=12,
                             idx=0,
                             padLeft=0,
                             groupID='groupMemberConts',
                             callback=self.OnTabSelected,
                             autoselecttab=True)

    def UpdateGroup(self, groupID):
        if groupID == self.currentGroupID:
            self.LoadGroup(groupID)

    def LoadGroup(self, groupID):
        myGroupInfo = self.controller.GetMyGroupInfo(groupID)
        if myGroupInfo is None:
            return
        self.currentGroupID = groupID
        self.dropCont.dropGridCont.SetCurrentGroupID(
            groupID, myGroupInfo.membershipType)
        self.nameAndDescCont.SetNameAndDescription(myGroupInfo.name,
                                                   myGroupInfo.description)

    def Close(self, *args):
        self.ChangeSignalConnection(connect=False)
        Container.Close(self)

    def GroupSelected(self, groupID):
        if groupID is None:
            self.innerCont.display = False
            self.hintLabel.display = True
            return
        self.innerCont.display = True
        self.hintLabel.display = False
        if self.controller.IsGroupCorpOwned(groupID):
            self.dropCont.display = False
            self.addParent.display = False
        else:
            self.dropCont.display = True
            self.addParent.display = True
        self.LoadGroup(groupID)
        if self.tabs.destroyed:
            return
        selectedTabName = self.tabs.GetSelectedArgs()
        if selectedTabName == 'groupMemberCont':
            self.groupMemberCont.LoadGroup(groupID)
        elif selectedTabName == 'auditLogCont':
            self.auditLogCont.LoadGroup(groupID)

    def OnTabSelected(self, tabIdx):
        selectedGroupID = self.controller.GetSelectedGroupID()
        self.GroupSelected(selectedGroupID)

    def AddPublicGroup(self, *args):
        self.controller.AddPublicMember(self.currentGroupID)

    def AddMembers(self, characters):
        members = {
            characterID: ownergroupConst.MEMBERSHIP_TYPE_MEMBER
            for characterID in characters
        }
        self.controller.AddMembers(self.currentGroupID, members)
Beispiel #20
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)
Beispiel #21
0
class LobbyWnd(Window):
    __guid__ = 'form.LobbyWnd'
    __notifyevents__ = [
        'OnCharNowInStation', 'OnCharNoLongerInStation',
        'OnCharacterEnteredStructure', 'OnCharacterLeftStructure',
        'OnProcessStationServiceItemChange', 'OnAgentMissionChange',
        'OnStandingSet', 'OnCorporationChanged', 'OnCorporationMemberChanged',
        'OnPrimaryViewChanged', 'OnSetDevice', 'OnStructureServiceUpdated'
    ]
    default_windowID = 'lobbyWnd'
    default_top = 16
    default_width = 223
    default_captionLabelPath = 'UI/Station/StationServices'
    default_pinned = True
    undockCont = None
    undock_button_is_locked = False
    selectedGroupButtonID = None

    @staticmethod
    def default_height(*args):
        return uicore.desktop.height - 100

    @staticmethod
    def default_left(*args):
        return uicore.desktop.width - LobbyWnd.default_width - 16

    def OnPrimaryViewChanged(self, oldViewInfo, newViewInfo):
        self.UpdateDockedModeBtn(newViewInfo.name)

    def OnSetDevice(self):
        bottom = self.top + self.height
        if bottom > uicore.desktop.height:
            self.height = max(self.default_minSize[1],
                              uicore.desktop.height - self.top)
        right = self.left + self.width
        if right > uicore.desktop.width:
            self.width = max(self.default_minSize[0],
                             uicore.desktop.width - self.left)

    def _SetDefaultMinSize(self):
        def GetMinSize(btnSize, numInRow, padding):
            return btnSize + (btnSize + BUTTONGAP) * numInRow + padding

        btnSize = self.GetServiceBtnSize()
        if not settings.user.ui.Get('stationservicebtns', 1):
            minWidth = GetMinSize(btnSize, 3, 14)
            minHeight = 495
        else:
            minWidth = GetMinSize(btnSize, 5, 10)
            minHeight = 470
        self.default_minSize = (minWidth, minHeight)

    def ApplyAttributes(self, attributes):
        self.viewState = sm.GetService('viewState')
        self.scope = 'station'
        self.userType = settings.user.ui.Get('guestCondensedUserList', False)
        self._SetDefaultMinSize()
        Window.ApplyAttributes(self, attributes)
        self.controller = attributes.controller
        self.SetGuestEntryType()
        self.guestScroll = None
        self.SetWndIcon(None)
        self.HideHeader()
        self.MakeUnKillable()
        self.MakeUnstackable()
        self.SetTopparentHeight(0)
        self.sr.main.clipChildren = True
        self.BuildTopSection()
        self._AddStationServices()
        btnGroup = self._AddPanelToggleBtnCont()
        self._AddGuestPanel()
        self._AddAgentPanel()
        self._AddOfficePanel()
        self._AddToggleBtns()
        activePanel = settings.user.ui.Get('stationsLobbyTabs', AGENTSPANEL)
        if settings.char.windows.Get('dockshipsanditems', 0):
            self._AddInventoryPanel(btnGroup)
        elif activePanel == INVENTORYPANEL:
            activePanel = AGENTSPANEL
        btnGroup.SelectByID(activePanel)
        self._SetCorrectViewState()
        self.LoadOwnerInfo()
        self.LoadServiceButtons()
        if self.destroyed:
            return
        sm.RegisterNotify(self)
        self.UpdateGuestTabText()

    def BuildTopSection(self):
        self.corpLogoParent = Container(name='corpLogoParent',
                                        align=uiconst.TOTOP,
                                        height=160,
                                        parent=self.sr.main)
        self.corpName = CaptionLabel(parent=self.sr.main,
                                     align=uiconst.TOTOP,
                                     name='corpName',
                                     uppercase=False)
        self.undockparent = Container(name='undockparent',
                                      align=uiconst.TOTOP,
                                      height=86,
                                      parent=self.sr.main)
        self.AddDockedModeButton()
        self.AddControlButton()
        self.AddUndockButton()

    def _AddStationServices(self):
        EveLabelMedium(text=GetByLabel('UI/Station/StationServices'),
                       align=uiconst.TOTOP,
                       parent=self.sr.main,
                       bold=True,
                       padding=(6, 6, 6, 0))
        self.serviceButtons = FlowContainer(name='serviceButtons',
                                            align=uiconst.TOTOP,
                                            parent=self.sr.main,
                                            contentSpacing=(BUTTONGAP,
                                                            BUTTONGAP),
                                            padding=(6, 6, 3, 6))

    def _AddGuestPanel(self):
        self.guestsPanel = Container(name=GUESTSPANEL,
                                     parent=self.sr.main,
                                     padding=const.defaultPadding)
        self.quickFilter = QuickFilterEdit(name='quickFilterEdit',
                                           parent=self.guestsPanel)
        self.quickFilter.ReloadFunction = lambda: self.ShowGuests()
        self.guestScroll = BasicDynamicScroll(parent=self.guestsPanel,
                                              padTop=const.defaultPadding +
                                              self.quickFilter.height)
        guestSettingsMenu = UtilMenu(
            menuAlign=uiconst.TOPRIGHT,
            parent=self.guestsPanel,
            align=uiconst.TOPRIGHT,
            GetUtilMenu=self.SettingMenu,
            texturePath='res:/UI/Texture/SettingsCogwheel.png',
            width=18,
            height=18,
            iconSize=18)

    def _AddAgentPanel(self):
        self.agentsPanel = Container(name=AGENTSPANEL,
                                     parent=self.sr.main,
                                     padding=const.defaultPadding)
        self.agentFinderBtn = Button(
            label=GetByLabel('UI/AgentFinder/AgentFinder'),
            parent=self.agentsPanel,
            align=uiconst.CENTERTOP,
            func=uicore.cmd.OpenAgentFinder)
        self.agentScroll = Scroll(parent=self.agentsPanel,
                                  padTop=const.defaultPadding +
                                  self.agentFinderBtn.height)

    def _AddPanelToggleBtnCont(self):
        btnGroup = ToggleButtonGroup(name='btnGroup',
                                     parent=self.sr.main,
                                     align=uiconst.TOTOP,
                                     height=32,
                                     padding=6,
                                     idx=-1,
                                     callback=self.OnButtonGroupSelection,
                                     autoHeight=True)
        self.mainButtonGroup = btnGroup
        return btnGroup

    def _AddToggleBtns(self):
        btnGroup = self.mainButtonGroup
        agentsButton = btnGroup.AddButton(
            AGENTSPANEL,
            '<center>' + GetByLabel('UI/Station/Lobby/Agents'),
            self.agentsPanel,
            btnClass=LobbyToggleButtonGroupButton,
            hint=GetByLabel('Tooltips/StationServices/AgentsTab_descrtiption'))
        agentsButton.name = 'stationInformationTabAgents'
        guestsButton = btnGroup.AddButton(
            GUESTSPANEL,
            '<center>' + GetByLabel('UI/Station/Lobby/Guests'),
            self.guestsPanel,
            btnClass=LobbyToggleButtonGroupButton,
            hint=GetByLabel('Tooltips/StationServices/GuestsTab_description'))
        guestsButton.counter = CounterBox(parent=guestsButton,
                                          align=uiconst.TOPRIGHT,
                                          left=2,
                                          top=-5)
        self.guestsButton = guestsButton
        btnGroup.AddButton(
            OFFICESPANEL,
            '<center>' + GetByLabel('UI/Station/Lobby/Offices'),
            self.officesPanel,
            btnClass=LobbyToggleButtonGroupButton,
            hint=GetByLabel('Tooltips/StationServices/OfficesTab_description'))

    def _AddOfficePanel(self):
        self.officesPanel = Container(name=OFFICESPANEL,
                                      parent=self.sr.main,
                                      padding=const.defaultPadding)
        self.officesButtons = FlowContainer(name='officesButtons',
                                            align=uiconst.TOTOP,
                                            parent=self.officesPanel,
                                            contentSpacing=(4, 4),
                                            centerContent=True)
        self.officesScroll = Scroll(parent=self.officesPanel,
                                    padTop=const.defaultPadding)

    def _AddInventoryPanel(self, btnGroup):
        self.inventoryPanel = Container(name=INVENTORYPANEL,
                                        parent=self.sr.main)
        self.sr.shipsContainer = Container(parent=self.inventoryPanel,
                                           state=uiconst.UI_HIDDEN,
                                           padding=const.defaultPadding)
        self.sr.itemsContainer = Container(parent=self.inventoryPanel,
                                           state=uiconst.UI_HIDDEN,
                                           padding=const.defaultPadding)
        tabs = [[
            GetByLabel('UI/Station/Ships'), self.sr.shipsContainer, self,
            'lobby_ships'
        ],
                [
                    GetByLabel('UI/Station/Items'), self.sr.itemsContainer,
                    self, 'lobby_items'
                ]]
        self.inventoryTabs = TabGroup(name='inventoryPanel',
                                      parent=self.inventoryPanel,
                                      idx=0)
        self.inventoryTabs.Startup(tabs,
                                   'lobbyInventoryPanel',
                                   autoselecttab=True,
                                   UIIDPrefix='lobbyInventoryPanelTab')
        hint = '<b>%s</b><br>%s' % (
            GetByLabel('Tooltips/StationServices/Hangars'),
            GetByLabel('Tooltips/StationServices/Hangars_description'))
        self.invButton = btnGroup.AddButton(
            INVENTORYPANEL,
            '<center>' + GetByLabel('UI/Station/Lobby/Hangars'),
            self.inventoryPanel,
            btnClass=LobbyToggleButtonGroupButton,
            hint=hint)

    def LoadOwnerInfo(self):
        parent = self.corpLogoParent
        parent.Flush()
        corpID = self.controller.GetOwnerID()
        size = 128 if CheckCorpID(corpID) else 64
        logo = GetLogoIcon(itemID=corpID,
                           parent=parent,
                           acceptNone=False,
                           state=uiconst.UI_DISABLED,
                           pos=(0, 8, size, size),
                           align=uiconst.CENTERTOP)
        InfoIcon(typeID=const.typeCorporation,
                 itemID=corpID,
                 left=const.defaultPadding,
                 top=20,
                 align=uiconst.TOPRIGHT,
                 parent=parent,
                 idx=0)
        parent.height = logo.top + logo.height
        if CheckCorpID(corpID):
            self.corpName.display = False
        else:
            self.corpName.text = '<center>' + cfg.eveowners.Get(corpID).name
            self.corpName.display = True

    def GetServiceBtnSize(self):
        stationservicebtns = settings.user.ui.Get('stationservicebtns', 1)
        if stationservicebtns:
            return SMALLBUTTONSIZE
        else:
            return BIGBUTTONSIZE

    def LoadServiceButtons(self):
        parent = self.serviceButtons
        parent.Flush()
        haveServices = self.GetCurrentStationServices()
        btnsize = self.GetServiceBtnSize()
        for serviceInfo in reversed(haveServices):
            button = StationServiceBtn(
                parent=parent,
                pos=(0, 0, btnsize, btnsize),
                name=serviceInfo.name,
                align=uiconst.NOALIGN,
                serviceInfo=serviceInfo,
                callback=self.OnSvcBtnClick,
                serviceStatus=GetByLabel('UI/Station/Lobby/Enabled'),
                serviceEnabled=True)
            self.SetServiceButtonState(button, serviceInfo.serviceID)
            button.LoadTooltipPanel = self.LoadServiceButtonTooltipPanel

    def ReloadServiceButtons(self):
        self.controller.GetServicesInStation()
        for icon in self.serviceButtons.children:
            self.SetServiceButtonState(icon, icon.serviceID)

    def SetServiceButtonState(self, button, serviceID):
        currentstate = self.controller.GetCurrentStateForService(serviceID)
        if currentstate is None:
            return
        self.controller.RemoveServiceFromCache(serviceID)
        if currentstate.isEnabled:
            button.EnableBtn()
        else:
            button.DisableBtn()

    def OnSvcBtnClick(self, btn, *args):
        self.CheckCanAccessService(btn.name)
        sm.GetService('station').LoadSvc(btn.name)

    def CheckCanAccessService(self, serviceName):
        serviceData = stationServiceConst.serviceDataByNameID.get(serviceName)
        if serviceData is None:
            return
        for stationServiceID in serviceData.maskServiceIDs:
            result = self.controller.PerformAndGetErrorForStandingCheck(
                stationServiceID)
            if result is not None:
                raise result

    def LoadServiceButtonTooltipPanel(self, tooltipPanel, tooltipOwner, *args):
        tooltipPanel.LoadGeneric3ColumnTemplate()
        command = uicore.cmd.commandMap.GetCommandByName(tooltipOwner.cmdStr)
        tooltipPanel.AddCommandTooltip(command)
        if not tooltipOwner.serviceEnabled:
            tooltipPanel.AddLabelMedium(
                text=GetByLabel('UI/Station/Lobby/Disabled'),
                color=(1, 0, 0, 1),
                bold=True,
                colSpan=tooltipPanel.columns)

    def GetCurrentStationServices(self):
        return self.controller.GetServicesInStation()

    def _SetCorrectViewState(self):
        myDefaultView = 'hangar' if session.userid % 2 == 1 else 'station'
        curView = collections.namedtuple('FakeViewInfo', ['name'])(
            settings.user.ui.Get('defaultDockingView', myDefaultView))
        self.OnPrimaryViewChanged(curView, curView)

    def OnButtonGroupSelection(self, buttonID):
        settings.user.ui.Set('stationsLobbyTabs', buttonID)
        self.selectedGroupButtonID = buttonID
        if buttonID == AGENTSPANEL:
            self.ShowAgents()
        elif buttonID == GUESTSPANEL:
            self.ShowGuests()
        elif buttonID == OFFICESPANEL:
            self.ShowOffices()
        elif buttonID == INVENTORYPANEL:
            if not len(self.sr.shipsContainer.children):
                self.LayoutShipsAndItems()

    def SettingMenu(self, menuParent):
        showCompact = settings.user.ui.Get('guestCondensedUserList', False)
        menuParent.AddCheckBox(
            text=GetByLabel('UI/Chat/ShowCompactMemberList'),
            checked=bool(showCompact),
            callback=self.ChangeGuestEntryType)

    def ChangeGuestEntryType(self, *args):
        showCompact = settings.user.ui.Get('guestCondensedUserList', False)
        settings.user.ui.Set('guestCondensedUserList', not showCompact)
        self.SetGuestEntryType()
        self.ShowGuests()

    def SetGuestEntryType(self):
        if settings.user.ui.Get('guestCondensedUserList', False):
            self.userEntry = 'ChatUserSimple'
        else:
            self.userEntry = 'User'

    def _GetNumLobbyBtns(self):
        if self.controller.IsControlable():
            return 3
        else:
            return 2

    def AddControlButton(self):
        if not self.controller.IsControlable():
            return
        width = 1.0 / self._GetNumLobbyBtns()
        self.takeControlBtn = ControlBtn(parent=self.undockparent,
                                         name='dockedModeBtn',
                                         padding=3,
                                         callback=self.TakeControl,
                                         width=width)
        self.takeControlBtn.SetBtnLabel(
            GetByLabel('UI/Commands/TakeStructureControl'))
        if not self.controller.CanTakeControl():
            self.takeControlBtn.DisableBtn()

    def TakeControl(self, *args):
        charInControl = self.controller.GetCharInControl()
        if charInControl:
            ConfirmTakeControl.Open(controller=self.controller,
                                    charInControl=charInControl)
        else:
            self.controller.TakeControl()

    def AddDockedModeButton(self):
        width = 1.0 / self._GetNumLobbyBtns()
        self.dockedModeBtn = DockedModeBtn(
            parent=self.undockparent,
            name='dockedModeBtn',
            padding=3,
            callback=self.OnDockModeClicked,
            isMouseOverDisabledFunc=sm.GetService(
                'station').PastUndockPointOfNoReturn(),
            width=width)
        self.UpdateDockedModeBtn()
        if self.controller.IsRestrictedByGraphicsSettings():
            self.dockedModeBtn.DisableBtn()
            textPath = self.controller.GetDisabledDockingModeHint()
            if textPath:
                self.dockedModeBtn.SetBtnHint(GetByLabel(textPath))
        else:
            self.dockedModeBtn.EnableBtn()

    def UpdateDockedModeBtn(self, viewName=None):
        textPath = self.controller.GetDockedModeTextPath(viewName)
        text = '<center>%s</center>' % GetByLabel(textPath)
        self.dockedModeBtn.SetBtnLabel(text)
        self.dockedModeBtn.AdjustBtnHeight()

    def OnDockModeClicked(self, *args):
        self.controller.ChangeDockedMode(self.viewState)

    def OnUndockClicked(self, *args):
        if self.controller.InProcessOfUndocking():
            return
        uthread.new(self.AttemptToUndock).context = 'UndockButtonThread'

    def AddUndockButton(self):
        width = 1.0 / self._GetNumLobbyBtns()
        self.undockBtn = UndockBtn(parent=self.undockparent,
                                   name='undockBtn',
                                   padding=3,
                                   callback=self.OnUndockClicked,
                                   width=width)
        self.UpdateUndockButton()
        self.undockBtn.AdjustBtnHeight()
        if self.undock_button_is_locked:
            self._DisableUndockButton()

    def UpdateUndockButton(self):
        if self.controller.IsExiting():
            text = GetByLabel('UI/Station/AbortUndock')
            self.LockDockedModeButton()
        else:
            text = GetByLabel('UI/Neocom/UndockBtn')
            self.UnlockDockedModeButton()
        self.undockBtn.SetBtnLabel('<center>%s</center>' % text)

    def LockUndockButton(self):
        self.undock_button_is_locked = True
        self._DisableUndockButton()

    def _DisableUndockButton(self):
        if self.undockBtn is not None:
            self.undockBtn.LockBtn()

    def UnlockUndockButton(self):
        self.undock_button_is_locked = False
        self._EnableUndockButton()

    def _EnableUndockButton(self):
        if self.undockBtn is not None:
            self.undockBtn.UnlockBtn()

    def LockDockedModeButton(self, *args):
        self.dockedModeBtn.LockBtn()

    def UnlockDockedModeButton(self, *args):
        self.dockedModeBtn.UnlockBtn()

    def SetUndockProgress(self, undockProgress):
        if undockProgress is None:
            self.UpdateUndockButton()
            return
        i = int(undockProgress * 3)
        if i < 3:
            self.UpdateUndockButton()
            self.undockBtn.AnimateArrow(arrowIdx=i)
        else:
            text = '<center>%s</center>' % GetByLabel(
                'UI/Station/UndockingConfirmed')
            self.undockBtn.StartConfirmedAnimation()

    def UpdateGuestTabText(self):
        numGuests = len(self.controller.GetGuests())
        self.guestsButton.counter.text = numGuests

    def AttemptToUndock(self):
        exiting = self.controller.Undock()
        if exiting:
            self.LockDockedModeButton()

    def LayoutShipsAndItems(self):
        self.sr.itemsContainer.Flush()
        stationItemsClass, stationShipsClass = self.controller.GetStationItemsAndShipsClasses(
        )
        itemID = self.controller.GetItemID()
        itemsContainer = stationItemsClass(name='stationItems',
                                           parent=self.sr.itemsContainer,
                                           showControls=True,
                                           state=uiconst.UI_NORMAL,
                                           itemID=itemID)
        self.sr.shipsContainer.Flush()
        shipsContainer = stationShipsClass(name='stationShips',
                                           parent=self.sr.shipsContainer,
                                           showControls=True,
                                           state=uiconst.UI_NORMAL,
                                           itemID=itemID)
        self.invButton.OnDropData = itemsContainer.OnDropData
        self.sr.itemsContainer.OnDropData = itemsContainer.OnDropData
        self.sr.shipsContainer.OnDropData = shipsContainer.OnDropData

    def ShowOffices(self):
        if self.selectedGroupButtonID != OFFICESPANEL:
            return
        self.LoadButtons()
        corpsWithOffices = self.controller.CorpsWithOffices()
        cfg.corptickernames.Prime([c.corporationID for c in corpsWithOffices])
        scrolllist = []
        for corp in corpsWithOffices:
            corpName = corp.corporationName
            data = KeyVal(corpName=corpName,
                          corpID=corp.corporationID,
                          corporation=corp)
            entry = GetListEntry(data=data, decoClass=OfficeEntry)
            scrolllist.append((corpName.lower(), entry))

        scrolllist = SortListOfTuples(scrolllist)
        numUnrentedOffices = self.controller.GetNumberOfUnrentedOffices()
        if numUnrentedOffices is not None:
            availOfficesLabel = GetByLabel(
                'UI/Station/Lobby/NumAvailableOffices',
                numOffices=numUnrentedOffices)
            scrolllist.insert(
                0, GetListEntry('Header', {'label': availOfficesLabel}))
        if not self.destroyed:
            self.officesScroll.Load(contentList=scrolllist)

    def LoadButtons(self):
        if self.destroyed:
            return
        btns = []
        officeExists = self.controller.DoesOfficeExist()
        canRent = self.controller.CanRent()
        canUnrent = self.controller.CanUnrent()
        canMoveHQ = self.controller.CanMoveHQ()
        hqAllowed = self.controller.IsHqAllowed()
        if canRent and not officeExists:
            rentLabel = GetByLabel('UI/Station/Lobby/RentOffice')
            btns.append([rentLabel, self.RentOffice, None])
        if canUnrent and officeExists:
            btns.append([
                GetByLabel('UI/Station/Hangar/UnrentOffice'),
                self.UnrentOffice, None
            ])
        if canMoveHQ and hqAllowed:
            isHQHere = self.controller.IsMyHQ()
            if not isHQHere:
                hqLabel = GetByLabel('UI/Station/Lobby/MoveHeadquartersHere')
                btns.append([hqLabel, self.SetHQ, None])
            if not officeExists and self.controller.HasCorpImpountedItems():
                btns.append([
                    GetByLabel('UI/Inventory/ReleaseItems'),
                    self.ReleaseImpoundedItems, None
                ])
        if self.controller.MyCorpIsOwner():
            mgmtLabel = GetByLabel('UI/Station/Lobby/StationManagement')
            btns.append([mgmtLabel, self.OpenStationManagement, None])
        if self.destroyed:
            return
        self.officesButtons.Flush()
        for label, func, args in btns:
            Button(parent=self.officesButtons,
                   label=label,
                   func=func,
                   args=args,
                   align=uiconst.NOALIGN)

    def RentOffice(self, *args):
        if self.sr.isRentOfficeOpening:
            return
        self.sr.isRentOfficeOpening = 1
        try:
            cost = self.controller.GetCostForOpeningOffice()
            if eve.Message('AskPayOfficeRentalFee', {
                    'cost': cost,
                    'duration': const.rentalPeriodOffice * const.DAY
            }, uiconst.YESNO) == uiconst.ID_YES:
                officeID = self.controller.RentOffice(cost)
                if officeID:
                    self.InvalidateOfficeInvCache(officeID)
            uthread.new(self.LoadButtons)
            if self.selectedGroupButtonID == OFFICESPANEL:
                self.ShowOffices()
        finally:
            self.sr.isRentOfficeOpening = 0

    def InvalidateOfficeInvCache(self, officeID):
        office = self.controller.GetMyCorpOffice()
        invCache = sm.GetService('invCache')
        invCache.InvalidateLocationCache(officeID)
        if office is not None:
            itemID = self.controller.GetItemID()
            folder = invCache.GetInventoryFromId(office.officeFolderID,
                                                 locationID=itemID)
            folder.List()
            wnd = InventoryWindow.GetIfOpen()
            if not wnd:
                InventoryWindow.OpenOrShow()

    def UnrentOffice(self, *args):
        corpHasItemsInStation = self.controller.CorpHasItemsInstaton()
        if corpHasItemsInStation:
            if eve.Message('crpUnrentOfficeWithContent', {},
                           uiconst.YESNO) != uiconst.ID_YES:
                return
        elif eve.Message('crpUnrentOffice', {},
                         uiconst.YESNO) != uiconst.ID_YES:
            return
        self.controller.UnrentOffice()

    def SetHQ(self, *args):
        self.controller.SetHQ()

    def ReleaseImpoundedItems(self, *args):
        cost = self.controller.GetCostForGettingCorpJunkBack()
        if eve.Message('CrpJunkAcceptCost', {'cost': FmtAmt(cost)},
                       uiconst.YESNO) != uiconst.ID_YES:
            return
        self.controller.ReleaseImpoundedItems(cost)
        self.LoadButtons()

    def OpenStationManagement(self, *args):
        uthread.new(self.controller.OpenStationMgmt)

    def ReloadOfficesIfVisible(self):
        if self.selectedGroupButtonID == OFFICESPANEL:
            self.ShowOffices()

    def _FindAvailableAndUnavailableAgents(self, agentsInStation,
                                           localRelevantAgents,
                                           relevantAgents):
        epicArcStatusSvc = sm.RemoteSvc('epicArcStatus')
        facWarSvc = sm.StartService('facwar')
        standingSvc = sm.StartService('standing')
        unavailableAgents = []
        availableAgents = []
        for agent in agentsInStation:
            if agent.agentID in const.rookieAgentList:
                continue
            isLimitedToFacWar = False
            if agent.agentTypeID == const.agentTypeFactionalWarfareAgent and facWarSvc.GetCorporationWarFactionID(
                    agent.corporationID) != session.warfactionid:
                isLimitedToFacWar = True
            normalAgants = (const.agentTypeResearchAgent,
                            const.agentTypeBasicAgent,
                            const.agentTypeEventMissionAgent,
                            const.agentTypeCareerAgent,
                            const.agentTypeFactionalWarfareAgent)
            if agent.agentTypeID in normalAgants:
                standingIsValid = self._CheckCanUseAgent(agent, standingSvc)
                haveMissionFromAgent = agent.agentID in relevantAgents
                if not isLimitedToFacWar and (standingIsValid
                                              or haveMissionFromAgent):
                    availableAgents.append(agent.agentID)
                else:
                    unavailableAgents.append(agent.agentID)
            elif agent.agentTypeID == const.agentTypeEpicArcAgent:
                standingIsValid = self._CheckCanUseAgent(agent, standingSvc)
                haveMissionFromAgent = agent.agentID in relevantAgents
                epicAgentAvailable = False
                if haveMissionFromAgent:
                    epicAgentAvailable = True
                elif standingIsValid:
                    if agent.agentID in relevantAgents or epicArcStatusSvc.AgentHasEpicMissionsForCharacter(
                            agent.agentID):
                        epicAgentAvailable = True
                if epicAgentAvailable:
                    availableAgents.append(agent.agentID)
                else:
                    unavailableAgents.append(agent.agentID)
            if agent.agentTypeID == const.agentTypeAura:
                if sm.GetService('experimentClientSvc').IsTutorialEnabled():
                    availableAgents.append(agent.agentID)
            elif agent.agentTypeID in (
                    const.agentTypeGenericStorylineMissionAgent,
                    const.agentTypeStorylineMissionAgent):
                if agent.agentID in localRelevantAgents:
                    availableAgents.append(agent.agentID)
                else:
                    unavailableAgents.append(agent.agentID)

        return (availableAgents, unavailableAgents)

    def _CheckCanUseAgent(self, agent, standingSvc):
        return standingSvc.CanUseAgent(agent.factionID, agent.corporationID,
                                       agent.agentID, agent.level,
                                       agent.agentTypeID)

    def ShowAgents(self):
        if self.selectedGroupButtonID != AGENTSPANEL:
            return
        try:
            agentsSvc = sm.GetService('agents')
            journalSvc = sm.GetService('journal')
            agentMissions = journalSvc.GetMyAgentJournalDetails()[:1][0]
            agentsInStation = self.controller.GetAgents()
            relevantAgents = []
            missionStateDict = {}
            for each in agentMissions:
                missionState, importantMission, missionType, missionName, agentID, expirationTime, bookmarks, remoteOfferable, remoteCompletable, contentID = each
                agent = agentsSvc.GetAgentByID(agentID)
                missionStateDict[agentID] = missionState
                onGoingMission = (const.agentMissionStateAllocated,
                                  const.agentMissionStateOffered)
                specialAgents = (const.agentTypeGenericStorylineMissionAgent,
                                 const.agentTypeStorylineMissionAgent,
                                 const.agentTypeEventMissionAgent,
                                 const.agentTypeCareerAgent,
                                 const.agentTypeEpicArcAgent)
                if missionState not in onGoingMission or agent.agentTypeID in specialAgents:
                    relevantAgents.append(agentID)

            localRelevantAgents = []
            for agent in agentsInStation:
                if agent.agentID in relevantAgents:
                    localRelevantAgents.append(agent.agentID)

            if self.destroyed:
                return
            scrolllist = []
            sortlist = []
            for agentID in relevantAgents:
                if not eve.rookieState or agentID in const.rookieAgentList:
                    if agentID not in localRelevantAgents:
                        entryWithSortValue = self.GetAgentEntryWithSortValue(
                            agentID, missionStateDict)
                        sortlist.append(entryWithSortValue)

            if sortlist:
                agentLabel = GetByLabel('UI/Station/Lobby/AgentsOfInterest')
                scrolllist.append(GetListEntry('Header',
                                               {'label': agentLabel}))
                scrolllist += SortListOfTuples(sortlist)
            agentList, unavailableAgents = self._FindAvailableAndUnavailableAgents(
                agentsInStation, localRelevantAgents, relevantAgents)
            agentInfo = [('UI/Station/Lobby/AvailableToYou', agentList),
                         ('UI/Station/Lobby/NotAvailableToYou',
                          unavailableAgents)]
            for labelPath, agentList in agentInfo:
                if agentList:
                    text = GetByLabel(labelPath)
                    scrolllist.append(GetListEntry('Header', {'label': text}))
                    sortlist = []
                    for agentID in agentList:
                        entryWithSortValue = self.GetAgentEntryWithSortValue(
                            agentID, missionStateDict)
                        sortlist.append(entryWithSortValue)

                    scrolllist += SortListOfTuples(sortlist)

            if self.destroyed:
                return
            self.agentScroll.Load(fixedEntryHeight=40, contentList=scrolllist)
        except:
            log.LogException()
            sys.exc_clear()

    def GetAgentEntryWithSortValue(self, agentID, missionStateDict):
        missionState = missionStateDict.get(agentID)
        sortValue = cfg.eveowners.Get(agentID).name
        entry = GetListEntry('AgentEntry', {
            'charID': agentID,
            'missionState': missionState
        })
        return (sortValue, entry)

    def ShowGuests(self, *args):
        if self.selectedGroupButtonID != GUESTSPANEL:
            return
        guests = self.controller.GetGuests()
        ownerIDs = guests.keys()
        cfg.eveowners.Prime(ownerIDs)
        guestFilter = self.quickFilter.GetValue()
        if len(guestFilter):
            filterData = [
                KeyVal(name=cfg.eveowners.Get(charID).name, charID=charID)
                for charID in ownerIDs
            ]
            filterGuests = NiceFilter(self.quickFilter.QuickFilter, filterData)
            ownerIDs = [each.charID for each in filterGuests]
        if self.destroyed:
            return
        scrolllist = []
        for charID in ownerIDs:
            if charID not in guests:
                continue
            corpID, allianceID, warFactionID = guests[charID]
            charinfo = cfg.eveowners.Get(charID)
            sortValue = charinfo.name.lower()
            data = {
                'charID': charID,
                'info': charinfo,
                'label': charinfo.name,
                'corpID': corpID,
                'allianceID': allianceID,
                'warFactionID': warFactionID
            }
            entry = GetListEntry(self.userEntry, data)
            scrolllist.append((sortValue, entry))

        scrolllist = SortListOfTuples(scrolllist)
        self.guestScroll.Clear()
        self.guestScroll.AddNodes(0, scrolllist)
        self.UpdateGuestTabText()

    def OnCharNowInStation(self, rec):
        self.CharacterAdded(*rec)

    def OnCharNoLongerInStation(self, rec):
        self.CharacterRemoved(rec[0])

    def OnCharacterEnteredStructure(self, characterID, corporationID,
                                    allianceID, factionID):
        self.CharacterAdded(characterID, corporationID, allianceID, factionID)

    def OnCharacterLeftStructure(self, characterID):
        self.CharacterRemoved(characterID)

    @telemetry.ZONE_METHOD
    def CharacterAdded(self, characterID, corporationID, allianceID,
                       factionID):
        if not self.IsLobbyBeAvailable():
            return
        self.UpdateGuestTabText()
        if self.selectedGroupButtonID != GUESTSPANEL:
            return
        cfg.eveowners.Prime([characterID])
        if self.destroyed:
            return
        newcharinfo = cfg.eveowners.Get(characterID)
        idx = 0
        for each in self.guestScroll.GetNodes():
            if each.charID == characterID:
                return
            if CaseFoldCompare(each.info.name, newcharinfo.name) > 0:
                break
            idx += 1

        filteredGuest = None
        guestFilter = self.quickFilter.GetValue()
        if len(guestFilter):
            filteredGuest = NiceFilter(self.quickFilter.QuickFilter,
                                       newcharinfo.name)
        if filteredGuest or len(guestFilter) == 0:
            data = {
                'charID': characterID,
                'info': newcharinfo,
                'label': newcharinfo.name,
                'corpID': corporationID,
                'allianceID': allianceID,
                'warFactionID': factionID
            }
            entry = GetListEntry(self.userEntry, data)
            self.guestScroll.AddNodes(idx, [entry])

    @telemetry.ZONE_METHOD
    def CharacterRemoved(self, characterID):
        if not self.IsLobbyBeAvailable():
            return
        self.UpdateGuestTabText()
        if self.selectedGroupButtonID != GUESTSPANEL:
            return
        for entry in self.guestScroll.GetNodes():
            if entry.charID == characterID:
                self.guestScroll.RemoveNodes([entry])
                return

    def IsLobbyBeAvailable(self):
        if self.destroyed:
            return False
        if not (session.stationid2 or IsDockedInStructure()):
            return False
        return True

    def OnProcessStationServiceItemChange(self, stationID, solarSystemID,
                                          maskServiceID, stationServiceItemID,
                                          isEnabled):
        if not self.IsLobbyBeAvailable():
            return
        for icon in self.serviceButtons.children:
            if hasattr(icon, 'maskStationServiceIDs'
                       ) and maskServiceID in icon.maskStationServiceIDs:
                serviceID = stationServiceConst.serviceIdByMaskId[
                    maskServiceID]
                self.SetServiceButtonState(icon, serviceID)

    def OnStructureServiceUpdated(self):
        self.ReloadServiceButtons()

    def OnAgentMissionChange(self, actionID, agentID, tutorialID=None):
        if self.selectedGroupButtonID == AGENTSPANEL:
            self.ShowAgents()

    def OnStandingSet(self, fromID, toID, rank):
        if self.selectedGroupButtonID == AGENTSPANEL:
            self.ShowAgents()

    def OnCorporationChanged(self, corpID, change):
        blue.pyos.synchro.Sleep(750)
        self.LoadButtons()

    def OnCorporationMemberChanged(self, corporationID, memberID, change):
        if memberID == session.charid:
            self.LoadButtons()

    def OnPrimaryViewChanged(self, oldViewInfo, newViewInfo):
        self.UpdateDockedModeBtn(newViewInfo.name)

    def StopAllBlinkButtons(self):
        for each in self.serviceButtons.children:
            if hasattr(each, 'Blink'):
                each.Blink(0)

    def BlinkButton(self, whatBtn):
        for each in self.serviceButtons.children:
            if each.name.lower() == whatBtn.lower():
                each.Blink(blinks=40)
class BrowserMyCorpStructures(Container):
    default_name = 'BrowserMyStructures'

    def ApplyAttributes(self, attributes):
        Container.ApplyAttributes(self, attributes)
        self.structureBrowserController = attributes.structureBrowserController
        self.currentProfileLoaded = None
        self.tabs = None
        self.isInitialized = False

    def OnTabSelect(self):
        self.LoadPanel()

    def LoadPanel(self):
        self.display = True
        if self.isInitialized:
            return
        self.isInitialized = True
        self.allStructuresProfileController = sm.GetService(
            'structureControllers').GetAllStructuresProfileController()
        self.ChangeSignalConnection(connect=True)
        profileParent = DragResizeCont(name='profileParent',
                                       parent=self,
                                       align=uiconst.TOLEFT_PROP,
                                       minSize=0.1,
                                       maxSize=0.5,
                                       defaultSize=0.5,
                                       settingsID='myStructuresSplitter')
        profileListCont = StructureProfiles(
            parent=profileParent,
            allStructuresProfileController=self.allStructuresProfileController,
            structureBrowserController=self.structureBrowserController)
        self.structeListAndProfileSettingsCont = Container(
            name='structureListAndProfileSettingsCont',
            parent=self,
            padding=(4, 0, 4, 4))
        self.LoadTabs()

    def ChangeSignalConnection(self, connect=True):
        signalAndCallback = [
            (self.structureBrowserController.on_profile_selected,
             self.OnProfileSelected),
            (self.allStructuresProfileController.on_profile_saved,
             self.OnProfileSaved),
            (self.structureBrowserController.on_profile_deleted,
             self.OnProfileDeleted),
            (self.structureBrowserController.on_corp_structures_changed,
             self.OnCorpStructuresChanged)
        ]
        ChangeSignalConnect(signalAndCallback, connect)

    def LoadTabs(self):
        self.VerifySelectedProfileIdIsValid()
        profileID = self.structureBrowserController.GetSelectedProfileID()
        self.structeListAndProfileSettingsCont.Flush()
        myStructuresPanel = MyStructuresPanel(
            parent=self.structeListAndProfileSettingsCont,
            allStructuresProfileController=self.allStructuresProfileController,
            structureBrowserController=self.structureBrowserController)
        tabs = [(GetByLabel('UI/StructureBrowser/StructuresWithProfile'),
                 myStructuresPanel, None, 'myStructuresPanel', None,
                 GetByLabel('UI/StructureBrowser/StructuresWithProfileHint'))]
        if profileID != browserUIConst.ALL_PROFILES:
            self.profileSettings = StructureProfileSettingCont(
                parent=self.structeListAndProfileSettingsCont,
                allStructuresProfileController=self.
                allStructuresProfileController,
                structureBrowserController=self.structureBrowserController)
            profileTab = (
                GetByLabel('UI/StructureBrowser/ProfileSettings'),
                self.profileSettings, None, 'profileSettings', None,
                GetByLabel('UI/StructureBrowser/ProfileSettingsHint'))
            tabs.append(profileTab)
        self.tabs = TabGroup(parent=self.structeListAndProfileSettingsCont,
                             tabs=tabs,
                             height=32,
                             idx=0,
                             padLeft=0,
                             groupID='profile_structuresAndsettings',
                             padTop=0)
        self.profileDescLabel = EveLabelMedium(
            parent=self.structeListAndProfileSettingsCont,
            name='profileDescLabel',
            align=uiconst.TOTOP,
            idx=0)
        self.profileNameLabel = EveCaptionSmall(
            parent=self.structeListAndProfileSettingsCont,
            name='profileNameLabel',
            align=uiconst.TOTOP,
            idx=0)
        self.SetProfileName()

    def VerifySelectedProfileIdIsValid(self):
        profileID = self.structureBrowserController.GetSelectedProfileID()
        validProfileIDs = sm.GetService(
            'structureControllers').GetValidProfileIDs()
        isProfileValid = profileID not in validProfileIDs
        if isProfileValid:
            self.structureBrowserController.SelectProfile(
                browserUIConst.ALL_PROFILES, sendSignal=False)
            self.currentProfileLoaded = browserUIConst.ALL_PROFILES

    def ForceProfileSettingsSelected(self):
        if self.tabs:
            self.tabs.AutoSelect()

    def OnProfileSelected(self, profileID):
        self.SetProfileName()
        if self.currentProfileLoaded is None or self._ProfileTypeHasChanged(
                profileID):
            self.LoadTabs()
        self.currentProfileLoaded = profileID

    def _ProfileTypeHasChanged(self, profileID):
        if profileID == self.currentProfileLoaded:
            return False
        if browserUIConst.ALL_PROFILES not in (profileID,
                                               self.currentProfileLoaded):
            return False
        return True

    def OnProfileSaved(self, profileID):
        self.structureBrowserController.SetProfileChangedValue(False)
        self.SetProfileName()

    def OnProfileDeleted(self, profileID, selectedProfileChanged):
        if selectedProfileChanged:
            self.LoadTabs()

    def OnCorpStructuresChanged(self):
        if self.structureBrowserController.GetSelectedTab(
        ) != MyStructuresPanel.TAB_ID:
            return
        self.LoadTabs()

    def SetProfileName(self):
        if self.structureBrowserController.GetSelectedProfileID(
        ) == browserUIConst.ALL_PROFILES:
            name = GetByLabel('UI/Structures/Browser/AnyProfile')
            desc = ''
        else:
            selectedProfileID = self.structureBrowserController.GetSelectedProfileID(
            )
            selectedProfileController = self.allStructuresProfileController.GetSlimProfileController(
                selectedProfileID)
            name = selectedProfileController.GetProfileName()
            desc = selectedProfileController.GetProfileDescription()
        self.profileNameLabel.text = name
        self.profileDescLabel.text = desc
        self.profileNameLabel.display = False
        self.profileDescLabel.display = False

    def Close(self):
        if self.isInitialized:
            self.ChangeSignalConnection(connect=False)
        Container.Close(self)
class Industry(Window):
    __guid__ = 'form.Industry'
    __notifyevents__ = [
        'OnIndustryLeftOrRightKey', 'OnIndustryDropData',
        'OnIndustryRemoveBlueprint', 'OnIndustryJob', 'OnBlueprintReload',
        'OnFacilityReload', 'OnBlueprintEntryDblClicked'
    ]
    default_captionLabelPath = 'UI/Industry/Industry'
    default_descriptionLabelPath = 'UI/Industry/IndustryTooltip'
    default_caption = localization.GetByLabel('UI/Industry/Industry')
    default_windowID = 'industryWnd'
    default_iconNum = 'res:/UI/Texture/WindowIcons/Industry.png'
    default_height = 800
    default_topParentHeight = 0
    default_isStackable = False
    default_minSize = (1004, 650)

    def ApplyAttributes(self, attributes):
        Window.ApplyAttributes(self, attributes)
        blueprintID = attributes.Get('blueprintID', None)
        blueprintTypeID = attributes.Get('blueprintTypeID', None)
        bpData = attributes.Get('bpData', None)
        self.history = HistoryBuffer()
        self.jobData = None
        self.pendingBlueprint = None
        self.loadBlueprintThread = None
        self.topCont = Container(name='topCont',
                                 parent=self.sr.main,
                                 align=uiconst.TOTOP,
                                 height=TOP_HEIGHT,
                                 clipChildren=True)
        self.currView = BaseView(parent=self.topCont,
                                 align=uiconst.TOTOP,
                                 height=VIEW_HEIGHT)
        self.jobsStrip = JobsStrip(parent=self.topCont,
                                   align=uiconst.TOTOP,
                                   padding=(5, -1, 7, 2),
                                   callback=self.OnBlueprintsSelected)
        self.bottomCont = Container(name='bottomCont',
                                    parent=self.sr.main,
                                    controller=self,
                                    height=0.4,
                                    padding=(4, 0, 4, 0),
                                    callback=self.OnBlueprintsSelected)
        cont = ContainerAutoSize(name='historyArrowCont',
                                 parent=self.sr.main,
                                 align=uiconst.TOPRIGHT,
                                 height=16,
                                 left=3,
                                 top=1)
        self.expandViewBtn = ButtonIcon(
            name='expandViewBtn',
            parent=cont,
            align=uiconst.TORIGHT,
            width=16,
            iconSize=7,
            texturePath='res:/UI/Texture/classes/Neocom/arrowDown.png',
            func=self.OnExpandViewBtn)
        self.goForwardBtn = ButtonIcon(
            name='goForwardBtn',
            parent=cont,
            align=uiconst.TORIGHT,
            width=16,
            iconSize=16,
            padRight=5,
            texturePath='res:/UI/Texture/icons/38_16_224.png',
            func=self.OnForward,
            hint=localization.GetByLabel('UI/Control/EveWindow/Next'))
        self.goBackBtn = ButtonIcon(
            name='goBackBtn',
            parent=cont,
            align=uiconst.TORIGHT,
            width=16,
            iconSize=16,
            texturePath='res:/UI/Texture/icons/38_16_223.png',
            func=self.OnBack,
            hint=localization.GetByLabel('UI/Control/EveWindow/Previous'))
        self.browserCont = Container(name='browserCont',
                                     parent=self.bottomCont,
                                     padding=(0, 2, 0, 2))
        self.browserBlueprints = BrowserBlueprints(
            parent=self.browserCont, callback=self.OnBlueprintsSelected)
        self.browserFacilities = BrowserFacilities(
            parent=self.browserCont, callback=self.OnFacilitySelected)
        self.browserJobs = BrowserJobs(parent=self.browserCont,
                                       callback=self.OnJobSelected)
        tabs = ((localization.GetByLabel('UI/Industry/Blueprints'),
                 self.browserBlueprints, None, 'blueprints', None,
                 GetByLabel('UI/Industry/TabBlueprints')),
                (localization.GetByLabel('UI/Industry/Facilities'),
                 self.browserFacilities, None, 'facilities', None,
                 GetByLabel('UI/Industry/TabFacilities')),
                (localization.GetByLabel('UI/Industry/Jobs'), self.browserJobs,
                 None, 'jobs', None, GetByLabel('UI/Industry/TabJobs')))
        self.tabs = TabGroup(parent=self.browserCont,
                             tabs=tabs,
                             height=26,
                             labelPadding=12,
                             idx=0,
                             padLeft=0,
                             groupID='IndustryWindowBrowsers',
                             autoselecttab=not self.IsBrowserCollapsed())
        self.expandBottomBtn = ButtonIcon(
            name='expandBottomBtn',
            parent=self.bottomCont,
            align=uiconst.TOPRIGHT,
            pos=(2, -3, 16, 16),
            iconSize=7,
            texturePath='res:/UI/Texture/classes/Neocom/arrowDown.png',
            func=self.OnExpandBottomBtn)
        if blueprintID or blueprintTypeID:
            self.ShowBlueprint(blueprintID, blueprintTypeID, bpData=bpData)
        if self.IsViewCollapsed():
            self.CollapseView(animate=False)
        else:
            self.expandViewBtn.SetRotation(-pi)
        if self.IsBrowserCollapsed():
            self.CollapseBrowser(animate=False)
        else:
            self.expandBottomBtn.SetRotation(-pi)
        sm.GetService('audio').SendUIEvent('ind_windowOpened')

    def Close(self, *args, **kwargs):
        Window.Close(self, *args, **kwargs)
        if self.jobData:
            sm.GetService('industrySvc').DisconnectJob(self.jobData)

    @telemetry.ZONE_METHOD
    def OnNewJobData(self, branchHistory=True):
        if self.jobData:
            settings.user.ui.Set('IndustryCurrentActivityID',
                                 self.jobData.activityID)
        self.jobsStrip.OnNewJobData(self.jobData)
        self.currView.OnNewJobData(self.jobData)
        self.browserBlueprints.OnNewJobData(self.jobData)
        if branchHistory and self.jobData:
            self.history.Append((self.jobData.blueprintID,
                                 self.jobData.blueprint.blueprintTypeID,
                                 self.jobData.activityID))
            self.UpdateHistoryButtons()

    @telemetry.ZONE_METHOD
    def OnBlueprintsSelected(self,
                             bpData,
                             activityID=None,
                             branchHistory=True):
        self.pendingBlueprint = (bpData, activityID, branchHistory)
        if not self.loadBlueprintThread:
            self.loadBlueprintThread = uthread.new(self._OnBlueprintSelected)

    def _OnBlueprintSelected(self):
        try:
            while self.pendingBlueprint:
                while uicore.uilib.Key(uiconst.VK_UP) or uicore.uilib.Key(
                        uiconst.VK_DOWN):
                    blue.synchro.Yield()

                bpData, activityID, branchHistory = self.pendingBlueprint
                self.pendingBlueprint = None
                if activityID is None:
                    activityID = self._GetDefaultActivityID(bpData)
                if self.jobData and self.jobData.blueprint.IsSameBlueprint(
                        bpData):
                    if activityID == self.jobData.activityID:
                        break
                self.jobData = None
                if bpData.jobID is not None:
                    jobData = sm.GetService('industrySvc').GetJobByID(
                        bpData.jobID)
                    if jobData.status < industry.STATUS_COMPLETED:
                        self.jobData = sm.GetService(
                            'industrySvc').JobDataWithBlueprint(jobData)
                if not self.jobData:
                    self.jobData = self.CreateJob(bpData, activityID)
                if not self.pendingBlueprint:
                    self.browserBlueprints.OnActivitySelected(
                        self.jobData.blueprintID, activityID)
                    self.OnNewJobData(branchHistory)
                blue.synchro.SleepWallclock(500)

        finally:
            self.loadBlueprintThread = None

    @telemetry.ZONE_METHOD
    def OnFacilitySelected(self, facilityData):
        if self.jobData:
            self.jobData.facility = facilityData

    @telemetry.ZONE_METHOD
    def OnJobSelected(self, jobData):
        if jobData.status > industry.STATUS_COMPLETED:
            jobData = sm.GetService('industrySvc').RecreateJob(jobData)
        else:
            jobData = sm.GetService('industrySvc').JobDataWithBlueprint(
                jobData)
        if not jobData:
            return
        self.jobData = jobData
        self.OnNewJobData(jobData)
        self.UpdateBlueprintBrowserActivitySelected()

    @telemetry.ZONE_METHOD
    def UpdateBlueprintBrowserActivitySelected(self):
        if self.jobData:
            self.browserBlueprints.OnActivitySelected(self.jobData.blueprintID,
                                                      self.jobData.activityID)

    def OnBlueprintEntryDblClicked(self):
        if self.IsViewCollapsed():
            self.ExpandView()

    def _GetDefaultActivityID(self, bpData):
        currActivityID = settings.user.ui.Get('IndustryCurrentActivityID',
                                              None)
        if currActivityID in bpData.activities:
            return currActivityID
        for activityID in industry.ACTIVITIES:
            if activityID in bpData.activities:
                return activityID

    @telemetry.ZONE_METHOD
    def CreateJob(self, bpData, activityID):
        return sm.GetService('industrySvc').CreateJob(bpData, activityID,
                                                      bpData.facilityID)

    def ShowBlueprint(self,
                      blueprintID=None,
                      blueprintTypeID=None,
                      activityID=None,
                      branchHistory=True,
                      bpData=None):
        if not bpData:
            if blueprintID:
                bpData = sm.GetService('blueprintSvc').GetBlueprintItem(
                    blueprintID)
            else:
                bpData = sm.GetService('blueprintSvc').GetBlueprintTypeCopy(
                    blueprintTypeID)
        self.OnBlueprintsSelected(bpData,
                                  activityID=activityID,
                                  branchHistory=branchHistory)

    def ShowJob(self, jobID):
        if jobID:
            self.OnJobSelected(sm.GetService('industrySvc').GetJobByID(jobID))

    @classmethod
    def OpenOrShowBlueprint(cls,
                            blueprintID=None,
                            blueprintTypeID=None,
                            bpData=None):
        wnd = cls.GetIfOpen()
        if wnd:
            wnd.Maximize()
            wnd.ShowBlueprint(blueprintID, blueprintTypeID, bpData=bpData)
            if wnd.IsViewCollapsed():
                wnd.ExpandView()
            uicore.registry.SetFocus(wnd)
        else:
            wnd = cls.Open(blueprintID=blueprintID,
                           blueprintTypeID=blueprintTypeID,
                           bpData=bpData)
            wnd.Maximize()

    def OnExpandBottomBtn(self, *args):
        if self.IsBrowserCollapsed():
            self.ExpandBrowser()
        else:
            self.CollapseBrowser()

    def OnExpandViewBtn(self, *args):
        if self.IsViewCollapsed():
            self.ExpandView()
        else:
            self.CollapseView()

    def ExpandView(self, animate=True):
        settings.user.ui.Set('industryWndIsViewCollapsed', False)
        sm.ScatterEvent('OnIndustryViewExpandCollapse')
        self.expandViewBtn.SetRotation(-pi)
        self.expandViewBtn.Disable()
        self.topCont.Show()
        if animate:
            uicore.animations.MorphScalar(self.topCont,
                                          'height',
                                          self.topCont.height,
                                          TOP_HEIGHT,
                                          duration=0.3)
            uicore.animations.FadeIn(self.topCont, duration=0.3, sleep=True)
        else:
            self.topCont.height = TOP_HEIGHT
            self.topCont.opacity = 1.0
        self.expandBottomBtn.Show()
        self.expandViewBtn.Enable()

    def CollapseView(self, animate=True):
        settings.user.ui.Set('industryWndIsViewCollapsed', True)
        sm.ScatterEvent('OnIndustryViewExpandCollapse')
        self.expandViewBtn.Disable()
        self.expandViewBtn.SetRotation(0)
        self.expandBottomBtn.Hide()
        if animate:
            uicore.animations.MorphScalar(self.topCont,
                                          'height',
                                          self.topCont.height,
                                          0,
                                          duration=0.3)
            uicore.animations.FadeOut(self.topCont, duration=0.3, sleep=True)
        else:
            self.topCont.height = 0
            self.topCont.opacity = 0.0
        self.topCont.Hide()
        self.expandViewBtn.Enable()

    def IsViewCollapsed(self):
        return settings.user.ui.Get('industryWndIsViewCollapsed', False)

    def ExpandBrowser(self, animate=True):
        if self.tabs.GetSelectedIdx() is None:
            self.tabs.AutoSelect()
        settings.user.ui.Set('industryWndIsBrowserCollapsed', False)
        self.expandBottomBtn.SetRotation(-pi)
        self.expandBottomBtn.Disable()
        height = settings.user.ui.Get('industryWndExpandedHeight',
                                      self.default_height)
        self.browserCont.Show()
        if animate:
            uicore.animations.MorphScalar(self,
                                          'height',
                                          self.height,
                                          height,
                                          duration=0.3)
            uicore.animations.FadeIn(self.browserCont,
                                     duration=0.3,
                                     sleep=True)
        else:
            self.height = height
            self.browserCont.opacity = 1.0
        self.UnlockHeight()
        self.expandViewBtn.Show()
        self.expandBottomBtn.Enable()

    def CollapseBrowser(self, animate=True):
        if not self.IsBrowserCollapsed():
            settings.user.ui.Set('industryWndExpandedHeight', self.height)
        settings.user.ui.Set('industryWndIsBrowserCollapsed', True)
        self.expandBottomBtn.Disable()
        self.expandBottomBtn.SetRotation(0)
        self.expandViewBtn.Hide()
        if animate:
            uicore.animations.MorphScalar(self,
                                          'height',
                                          self.height,
                                          FIXED_HEIGHT,
                                          duration=0.3)
            uicore.animations.FadeOut(self.browserCont,
                                      duration=0.3,
                                      sleep=True)
        else:
            self.height = FIXED_HEIGHT
            self.browserCont.opacity = 0.0
        self.LockHeight(FIXED_HEIGHT)
        self.browserCont.Hide()
        self.expandBottomBtn.Enable()

    def IsBrowserCollapsed(self):
        return settings.user.ui.Get('industryWndIsBrowserCollapsed', False)

    def OnBack(self):
        historyID = self.history.GoBack()
        if historyID:
            if uicore.uilib.mouseOver != self.goBackBtn:
                self.goBackBtn.Blink()
            self.ShowBlueprint(branchHistory=False, *historyID)
            self.UpdateHistoryButtons()

    def OnForward(self):
        historyID = self.history.GoForward()
        if historyID:
            if uicore.uilib.mouseOver != self.goForwardBtn:
                self.goForwardBtn.Blink()
            self.ShowBlueprint(branchHistory=False, *historyID)
            self.UpdateHistoryButtons()

    def UpdateHistoryButtons(self):
        if self.history.IsBackEnabled():
            self.goBackBtn.Enable()
        else:
            self.goBackBtn.Disable()
        if self.history.IsForwardEnabled():
            self.goForwardBtn.Enable()
        else:
            self.goForwardBtn.Disable()

    def OnMouseWheel(self, *args):
        sm.ScatterEvent('OnIndustryWndMouseWheel')

    def OnClick(self, *args):
        sm.ScatterEvent('OnIndustryWndClick')

    def CloseByUser(self, *args):
        sm.GetService('audio').SendUIEvent('ind_windowClosed')
        Window.CloseByUser(self, *args)

    def _GetCurrentActivities(self):
        """
        Returns available activities for current blueprint correctly sorted
        """
        currActivities = self.jobData.blueprint.activities.keys()
        currActivities = sorted(currActivities,
                                key=lambda x: ACTIVITIES.index(x))
        return currActivities

    def SelectPreviousActivity(self):
        if not self.jobData or self.jobData.IsInstalled():
            return
        currActivities = self._GetCurrentActivities()
        idx = currActivities.index(self.jobData.activityID)
        if idx == 0:
            return
        activityID = currActivities[idx - 1]
        self._SelectActivity(activityID)

    def SelectNextActivity(self):
        if not self.jobData or self.jobData.IsInstalled():
            return
        currActivities = self._GetCurrentActivities()
        idx = currActivities.index(self.jobData.activityID)
        if idx == len(currActivities) - 1:
            return
        activityID = currActivities[idx + 1]
        self._SelectActivity(activityID)

    def _SelectActivity(self, activityID):
        self.browserBlueprints.OnActivitySelected(self.jobData.blueprintID,
                                                  activityID)
        self.OnBlueprintsSelected(self.jobData.blueprint, activityID)

    def OnIndustryLeftOrRightKey(self, key):
        if key == uiconst.VK_LEFT:
            self.SelectPreviousActivity()
        elif key == uiconst.VK_RIGHT:
            self.SelectNextActivity()

    def OnDropData(self, dragSource, dragData):
        if not dragData:
            return
        typeID = itemID = None
        data = dragData[0]
        bpData = getattr(data, 'bpData', None)
        if getattr(data, 'item', None):
            itemID = getattr(data.item, 'itemID', None)
            typeID = data.item.typeID
        else:
            typeID = getattr(data, 'typeID', None)
            itemID = getattr(data, 'itemID', None)
        if itemID or typeID:
            categoryID = cfg.invtypes.Get(typeID).categoryID
            if industryCommon.IsBlueprintCategory(categoryID):
                Industry.OpenOrShowBlueprint(itemID, typeID, bpData)
            else:
                raise UserError('ItemNotBlueprint', {'itemname': typeID})

    def OnIndustryDropData(self, dragSource, dragData):
        self.OnDropData(dragSource, dragData)

    def OnIndustryRemoveBlueprint(self):
        """
        Active blueprint removed by user
        """
        self.jobData = None
        self.OnNewJobData()

    def OnIndustryJob(self, jobID, ownerID, blueprintID, installerID, status,
                      successfulRuns):
        """
        Notification if a job is modified in anyway.
        """
        if self.destroyed:
            return
        if self.jobData and self.jobData.jobID == jobID:
            if status == industry.STATUS_CANCELLED:
                self.jobData = None
            else:
                self.jobData.status = status
                self.jobData.successfulRuns = successfulRuns
            self.OnNewJobData()
        elif self.jobData and self.jobData.blueprintID == blueprintID:
            self.jobData = sm.GetService('industrySvc').GetJobByID(jobID)
            self.OnNewJobData()
        if status in (industry.STATUS_INSTALLED, industry.STATUS_READY):
            if self.tabs.GetSelectedIdx() != TAB_JOBS:
                self.tabs.BlinkPanelByName(
                    localization.GetByLabel('UI/Industry/Jobs'))
        if status == industry.STATUS_INSTALLED:
            if self.tabs.GetSelectedIdx() == TAB_BLUEPRINTS:
                self.browserBlueprints.SetFocus()

    def OnBlueprintReload(self, ownerID):
        """
        If a blueprint changes relating to our current job, just reload.
        """
        if self.jobData and self.jobData.ownerID == ownerID:
            self.Reload()

    def OnFacilityReload(self, facilityID):
        """
        If a facility changes relating to our current job, just reload.
        """
        if self.jobData and self.jobData.facilityID == facilityID:
            self.Reload(force=True)

    def Reload(self, force=False):
        """
        Whatever the industry window is currently displaying at the top, reload all the data and redraw.
        """
        try:
            jobData = self.jobData
            if jobData:
                if force:
                    self.jobData = None
                if jobData.jobID:
                    self.ShowJob(jobData.jobID)
                else:
                    self.ShowBlueprint(
                        blueprintID=jobData.blueprint.blueprintID,
                        blueprintTypeID=jobData.blueprint.blueprintTypeID,
                        activityID=jobData.activityID,
                        bpData=jobData.blueprint)
        except UserError:
            self.OnIndustryRemoveBlueprint()
 def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     blueprintID = attributes.Get('blueprintID', None)
     blueprintTypeID = attributes.Get('blueprintTypeID', None)
     bpData = attributes.Get('bpData', None)
     self.history = HistoryBuffer()
     self.jobData = None
     self.pendingBlueprint = None
     self.loadBlueprintThread = None
     self.topCont = Container(name='topCont',
                              parent=self.sr.main,
                              align=uiconst.TOTOP,
                              height=TOP_HEIGHT,
                              clipChildren=True)
     self.currView = BaseView(parent=self.topCont,
                              align=uiconst.TOTOP,
                              height=VIEW_HEIGHT)
     self.jobsStrip = JobsStrip(parent=self.topCont,
                                align=uiconst.TOTOP,
                                padding=(5, -1, 7, 2),
                                callback=self.OnBlueprintsSelected)
     self.bottomCont = Container(name='bottomCont',
                                 parent=self.sr.main,
                                 controller=self,
                                 height=0.4,
                                 padding=(4, 0, 4, 0),
                                 callback=self.OnBlueprintsSelected)
     cont = ContainerAutoSize(name='historyArrowCont',
                              parent=self.sr.main,
                              align=uiconst.TOPRIGHT,
                              height=16,
                              left=3,
                              top=1)
     self.expandViewBtn = ButtonIcon(
         name='expandViewBtn',
         parent=cont,
         align=uiconst.TORIGHT,
         width=16,
         iconSize=7,
         texturePath='res:/UI/Texture/classes/Neocom/arrowDown.png',
         func=self.OnExpandViewBtn)
     self.goForwardBtn = ButtonIcon(
         name='goForwardBtn',
         parent=cont,
         align=uiconst.TORIGHT,
         width=16,
         iconSize=16,
         padRight=5,
         texturePath='res:/UI/Texture/icons/38_16_224.png',
         func=self.OnForward,
         hint=localization.GetByLabel('UI/Control/EveWindow/Next'))
     self.goBackBtn = ButtonIcon(
         name='goBackBtn',
         parent=cont,
         align=uiconst.TORIGHT,
         width=16,
         iconSize=16,
         texturePath='res:/UI/Texture/icons/38_16_223.png',
         func=self.OnBack,
         hint=localization.GetByLabel('UI/Control/EveWindow/Previous'))
     self.browserCont = Container(name='browserCont',
                                  parent=self.bottomCont,
                                  padding=(0, 2, 0, 2))
     self.browserBlueprints = BrowserBlueprints(
         parent=self.browserCont, callback=self.OnBlueprintsSelected)
     self.browserFacilities = BrowserFacilities(
         parent=self.browserCont, callback=self.OnFacilitySelected)
     self.browserJobs = BrowserJobs(parent=self.browserCont,
                                    callback=self.OnJobSelected)
     tabs = ((localization.GetByLabel('UI/Industry/Blueprints'),
              self.browserBlueprints, None, 'blueprints', None,
              GetByLabel('UI/Industry/TabBlueprints')),
             (localization.GetByLabel('UI/Industry/Facilities'),
              self.browserFacilities, None, 'facilities', None,
              GetByLabel('UI/Industry/TabFacilities')),
             (localization.GetByLabel('UI/Industry/Jobs'), self.browserJobs,
              None, 'jobs', None, GetByLabel('UI/Industry/TabJobs')))
     self.tabs = TabGroup(parent=self.browserCont,
                          tabs=tabs,
                          height=26,
                          labelPadding=12,
                          idx=0,
                          padLeft=0,
                          groupID='IndustryWindowBrowsers',
                          autoselecttab=not self.IsBrowserCollapsed())
     self.expandBottomBtn = ButtonIcon(
         name='expandBottomBtn',
         parent=self.bottomCont,
         align=uiconst.TOPRIGHT,
         pos=(2, -3, 16, 16),
         iconSize=7,
         texturePath='res:/UI/Texture/classes/Neocom/arrowDown.png',
         func=self.OnExpandBottomBtn)
     if blueprintID or blueprintTypeID:
         self.ShowBlueprint(blueprintID, blueprintTypeID, bpData=bpData)
     if self.IsViewCollapsed():
         self.CollapseView(animate=False)
     else:
         self.expandViewBtn.SetRotation(-pi)
     if self.IsBrowserCollapsed():
         self.CollapseBrowser(animate=False)
     else:
         self.expandBottomBtn.SetRotation(-pi)
     sm.GetService('audio').SendUIEvent('ind_windowOpened')