NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

characterSheetWindow.py (20121B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\neocom\characterSheetWindow.py
      2 import telemetry
      3 import eve.client.script.ui.shared.pointerTool.pointerToolConst as pConst
      4 import eveui
      5 import inventorycommon.const as invconst
      6 from carbon.common.script.sys.serviceConst import ROLE_QA
      7 from carbonui import uiconst
      8 from carbonui.primitives.container import Container
      9 from clientsettings.setting import UserSettingBool
     10 from carbonui.uianimations import animations
     11 from carbonui.window.header.tab_navigation import TabNavigationWindowHeader
     12 from carbonui.control.window import Window
     13 from cosmetics.client.character.title.qa.menu import add_window_context_menu
     14 from eve.client.script.ui.shared.neocom.charsheet import PANEL_PLEX, PANEL_SKILLS_HISTORY, PANEL_CHARACTER, PANEL_INTERACTIONS, PANEL_HISTORY, GetPanelName, GetPanelDescription, PANEL_JUMPCLONES, PANEL_ATTRIBUTES, PANEL_SECURITYSTATUS, PANEL_STANDINGS, PANEL_IMPLANTSBOOTERS, PANEL_DECORATIONS, PANEL_HOME_STATION, PANEL_EXPERTSYSTEMS, PANEL_PERSONALIZATION
     15 from eve.client.script.ui.shared.neocom.charsheet.characterPanel import CharacterPanel
     16 from eve.client.script.ui.shared.neocom.charsheet.historyPanel import HistoryPanel
     17 from eve.client.script.ui.shared.neocom.charsheet.interactionsPanel import InteractionsPanel
     18 from eve.client.script.ui.shared.neocom.charsheet.personalizationPanel import PersonalizationPanel
     19 from eve.client.script.ui.shared.neocom.charsheet.plexPanel import PLEXPanel
     20 from eve.client.script.ui.shared.portraitWindow.portraitWindow import PortraitWindow
     21 from eveservices.menu import GetMenuService
     22 from menu import MenuLabel
     23 from uthread2 import start_tasklet
     24 charsheet_expanded_setting = UserSettingBool('charsheetExpanded', True)
     25 PARENT_PANELS = {PANEL_SKILLS_HISTORY: PANEL_HISTORY,
     26  PANEL_JUMPCLONES: PANEL_CHARACTER,
     27  PANEL_ATTRIBUTES: PANEL_CHARACTER,
     28  PANEL_IMPLANTSBOOTERS: PANEL_CHARACTER,
     29  PANEL_SECURITYSTATUS: PANEL_INTERACTIONS,
     30  PANEL_STANDINGS: PANEL_INTERACTIONS,
     31  PANEL_DECORATIONS: PANEL_CHARACTER,
     32  PANEL_HOME_STATION: PANEL_CHARACTER,
     33  PANEL_EXPERTSYSTEMS: PANEL_CHARACTER}
     34 TAB_UNIQUE_NAMES = {PANEL_CHARACTER: pConst.UNIQUE_NAME_CHARSHEET_CHARACTER_TAB,
     35  PANEL_INTERACTIONS: pConst.UNIQUE_NAME_CHARSHEET_INTERACTION_TAB,
     36  PANEL_PLEX: pConst.UNIQUE_NAME_PILOT_SERVICES_TAB,
     37  PANEL_PERSONALIZATION: pConst.UNIQUE_NAME_PERSONALIZATION_TAB}
     38 LEFT_SIDE_WIDTH_EXPANDED = 340
     39 LEFT_SIDE_WIDTH_COLLAPSED = 394
     40 MINSIZE_STACKED = (580, 600)
     41 
     42 class CharacterSheetTabNavigationWindowHeader(TabNavigationWindowHeader):
     43 
     44     def __init__(self, **kwargs):
     45         super(CharacterSheetTabNavigationWindowHeader, self).__init__(**kwargs)
     46 
     47     def mount(self, window):
     48         super(CharacterSheetTabNavigationWindowHeader, self).mount(window)
     49         self._update_element_visibility(window)
     50         window.on_stacked_changed.connect(self._on_stacked_changed)
     51         charsheet_expanded_setting.on_change.connect(self._on_charsheet_expanded_setting_changed)
     52 
     53     def unmount(self, window):
     54         super(CharacterSheetTabNavigationWindowHeader, self).unmount(window)
     55         charsheet_expanded_setting.on_change.disconnect(self._on_charsheet_expanded_setting_changed)
     56 
     57     @staticmethod
     58     def _get_icon_visible(window):
     59         return not (window.collapsed or window.compact) and (charsheet_expanded_setting.is_enabled() or window.stacked)
     60 
     61     def _on_stacked_changed(self, window):
     62         self._update_element_visibility(window)
     63 
     64     def _on_charsheet_expanded_setting_changed(self, value):
     65         self._update_element_visibility()
     66 
     67     def _update_element_visibility(self, window = None):
     68         if window is None:
     69             window = self.window
     70             if not window:
     71                 return
     72         self._update_caption_icon_display(window)
     73         display = charsheet_expanded_setting.is_enabled() or window.stacked
     74         self._line.display = display
     75         self.tab_group.display = display
     76 
     77 
     78 class CharacterSheetWindow(Window):
     79     __guid__ = 'form.CharacterSheet'
     80     default_width = 1235
     81     default_height = 768
     82     default_minSize = (920, 600)
     83     default_maxSize = (1600, 900)
     84     default_left = '__center__'
     85     default_top = '__center__'
     86     default_windowID = 'charactersheet'
     87     default_captionLabelPath = 'UI/CharacterSheet/CharacterSheetWindow/CharacterSheetCaption'
     88     default_descriptionLabelPath = 'Tooltips/Neocom/CharacterSheet_description'
     89     default_iconNum = 'res:/ui/Texture/WindowIcons/charactersheet.png'
     90     default_scope = uiconst.SCOPE_INGAME
     91     default_isCollapseable = False
     92     leftCont = None
     93 
     94     def OnUIRefresh(self):
     95         pass
     96 
     97     @telemetry.ZONE_METHOD
     98     def ApplyAttributes(self, attributes):
     99         from eve.client.script.ui.shared.preview import PreviewCharacterWnd
    100         PreviewCharacterWnd.CloseIfOpen()
    101         panelID = attributes.panelID
    102         self.loading = False
    103         self.skillsPanel = None
    104         self.prevWidth = None
    105         self.animationInProgress = False
    106         self._loadPanelThread = None
    107         self.overviewPanel = None
    108         super(CharacterSheetWindow, self).ApplyAttributes(attributes)
    109         self.ConstructBaseLayout()
    110         self.ConstructCharacterOverview()
    111         self._ConstructTabs()
    112         if not panelID:
    113             panelID = self.GetDefaultPanelID()
    114         self._StartLoadingPanel(panelID)
    115         self._UpdateCharacterSheetExpanded(charsheet_expanded_setting.is_enabled(), animate=False)
    116         self._ConnectSignals()
    117 
    118     def Close(self, setClosed = False, *args, **kwds):
    119         self._StopLoadingPanel()
    120         self._DisconnectSignals()
    121         super(CharacterSheetWindow, self).Close(setClosed, *args, **kwds)
    122 
    123     @eveui.skip_if_destroyed
    124     def _ConnectSignals(self):
    125         charsheet_expanded_setting.on_change.connect(self._on_expanded_setting_changed)
    126         self.on_content_padding_changed.connect(self._on_content_padding_changed)
    127         self.on_header_height_changed.connect(self._on_header_height_changed)
    128         self.on_stacked_changed.connect(self._on_stacked_changed)
    129 
    130     @eveui.skip_if_destroyed
    131     def _DisconnectSignals(self):
    132         charsheet_expanded_setting.on_change.disconnect(self._on_expanded_setting_changed)
    133         self.on_content_padding_changed.disconnect(self._on_content_padding_changed)
    134         self.on_header_height_changed.disconnect(self._on_header_height_changed)
    135         self.on_stacked_changed.disconnect(self._on_stacked_changed)
    136 
    137     @eveui.skip_if_destroyed
    138     def _StartLoadingPanel(self, panelID, autoExpand = False):
    139         self._StopLoadingPanel()
    140         self._loadPanelThread = start_tasklet(self._LoadPanel, panelID, autoExpand)
    141 
    142     def _StopLoadingPanel(self):
    143         if self._loadPanelThread:
    144             self._loadPanelThread.kill()
    145             self._loadPanelThread = None
    146 
    147     @eveui.skip_if_destroyed
    148     def _ConstructTabs(self):
    149         if not self.header or not self.header.tab_group:
    150             return
    151         tabs = self.GetMainTabData()
    152         for tab_data in tabs:
    153             label, panel, _, tab_id, _, hint, _ = tab_data
    154             self.header.tab_group.AddTab(label=label, panel=panel, tabID=tab_id, hint=hint)
    155             tab = self.header.tab_group.GetTabByID(tab_id)
    156             unique_ui_name = TAB_UNIQUE_NAMES.get(tab_id, None)
    157             if unique_ui_name:
    158                 tab.uniqueUiName = unique_ui_name
    159 
    160     @property
    161     def mainTabGroup(self):
    162         if self.header is not None:
    163             return self.header.tab_group
    164 
    165     def Prepare_Header_(self):
    166         self.header = CharacterSheetTabNavigationWindowHeader(on_tab_selected=self.OnMainTabGroup)
    167 
    168     def ConstructBaseLayout(self):
    169         border_left, _, border_right, border_bottom = self.GetWindowBorderSize()
    170         self.leftCont = Container(name='leftCont', parent=self.sr.main, align=uiconst.TOLEFT, alignMode=uiconst.TOPLEFT, padding=self._get_left_cont_padding(), width=LEFT_SIDE_WIDTH_EXPANDED, idx=0)
    171         self.mainCont = Container(name='mainCont', parent=self.sr.main, align=uiconst.TOALL)
    172         self.panelCont = Container(name='panelCont', parent=self.mainCont)
    173         self.characterPanel = CharacterPanel(parent=self.panelCont, state=uiconst.UI_HIDDEN)
    174         self.interactionsPanel = InteractionsPanel(parent=self.panelCont, state=uiconst.UI_HIDDEN)
    175         self.plexPanel = PLEXPanel(parent=self.panelCont, state=uiconst.UI_HIDDEN)
    176         self.personalizationPanel = PersonalizationPanel(parent=self.panelCont, state=uiconst.UI_HIDDEN, emblemsErrorScreenPadding=self.content_padding)
    177         self.historyPanel = HistoryPanel(parent=self.panelCont, state=uiconst.UI_HIDDEN)
    178 
    179     def GetMainTabData(self):
    180         tabData = []
    181         panelsData = [(PANEL_CHARACTER, self.characterPanel, CharacterPanel),
    182          (PANEL_INTERACTIONS, self.interactionsPanel, InteractionsPanel),
    183          (PANEL_PLEX, self.plexPanel, PLEXPanel),
    184          (PANEL_PERSONALIZATION, self.personalizationPanel, PersonalizationPanel),
    185          (PANEL_HISTORY, self.historyPanel, HistoryPanel)]
    186         for panelID, panel, panelClass in panelsData:
    187             tabData.append((GetPanelName(panelID),
    188              panel,
    189              None,
    190              panelID,
    191              None,
    192              GetPanelDescription(panelID),
    193              None))
    194 
    195         return tabData
    196 
    197     def OnMainTabGroup(self, tabID, oldTabID):
    198         settings.char.ui.Set('charSheetSelectedPanel', tabID)
    199 
    200     def GetDefaultPanelID(self):
    201         return settings.char.ui.Get('charSheetSelectedPanel', PANEL_HOME_STATION)
    202 
    203     def ConstructCharacterOverview(self):
    204         from eve.client.script.ui.shared.neocom.charsheet.characterOverviewPanel.characterOverviewPanel import CharacterSheetCharacterOverviewPanel
    205         self.overviewPanel = CharacterSheetCharacterOverviewPanel(parent=self.leftCont, isCharsheetExpanded=charsheet_expanded_setting.is_enabled(), toggleFunc=self.ToggleCharacterSheetExpanded)
    206 
    207     def ToggleCharacterSheetExpanded(self, *args):
    208         self._UpdateCharacterSheetExpanded(not charsheet_expanded_setting.is_enabled())
    209 
    210     @eveui.skip_if_destroyed
    211     def _UpdateCharacterSheetExpanded(self, isExpanded, animate = True):
    212         if self.animationInProgress:
    213             return
    214         charsheet_expanded_setting.set(isExpanded)
    215         if animate:
    216             self.header.opacity = 0.0
    217             animations.FadeTo(self.header, self.header.opacity, 1.0, timeOffset=0.3, duration=0.3)
    218         if isExpanded:
    219             self._SetExpanded(animate)
    220             self.overviewPanel.SetExpanded(animate)
    221         else:
    222             self._SetNotExpanded(animate)
    223             self.overviewPanel.SetNotExpanded(animate)
    224 
    225     def _SetNotExpanded(self, animate):
    226         self.prevWidth = self.width
    227         if animate:
    228             self._AnimateCollapse()
    229         else:
    230             self.mainCont.opacity = 0.0
    231             self.mainCont.Hide()
    232             border_left, _, border_right, border_bottom = self.GetWindowBorderSize()
    233             self.width = LEFT_SIDE_WIDTH_COLLAPSED + border_left + border_right
    234             self._update_header_padding()
    235             self.SetFixedWidth(self.width)
    236             self.leftCont.width = LEFT_SIDE_WIDTH_COLLAPSED
    237 
    238     def _SetExpanded(self, animate):
    239         if self.prevWidth is None:
    240             self.prevWidth = self.width
    241         self.SetFixedWidth(None)
    242         if animate:
    243             self._AnimateExpand()
    244         else:
    245             self.mainCont.opacity = 1.0
    246             self.mainCont.Show()
    247             self._update_header_padding()
    248             self.width = self.prevWidth
    249             self.leftCont.width = LEFT_SIDE_WIDTH_EXPANDED
    250 
    251     def _GetSizeToRegister(self):
    252         w, h = super(CharacterSheetWindow, self)._GetSizeToRegister()
    253         if not charsheet_expanded_setting.is_enabled():
    254             w = None
    255         return (w, h)
    256 
    257     def _AnimateCollapse(self):
    258         self.animationInProgress = True
    259         border_left, _, border_right, border_bottom = self.GetWindowBorderSize()
    260         window_width = LEFT_SIDE_WIDTH_COLLAPSED + border_left + border_right
    261         animations.FadeTo(self.mainCont, startVal=self.mainCont.opacity, endVal=0.0, duration=0.3, timeOffset=0.1)
    262         eveui.animate(self, 'width', end_value=window_width, start_value=self.width, duration=0.3, on_complete=self._OnToggleAnimEnd)
    263         eveui.animate(self.leftCont, 'width', end_value=LEFT_SIDE_WIDTH_COLLAPSED, start_value=self.leftCont.width, duration=0.2)
    264 
    265     def _AnimateExpand(self):
    266         self.animationInProgress = True
    267         self.mainCont.Show()
    268         animations.FadeTo(self.mainCont, startVal=self.mainCont.opacity, endVal=1.0, duration=0.3, timeOffset=0.1)
    269         eveui.animate(self, 'width', end_value=self.prevWidth, start_value=self.width, duration=0.3, on_complete=self._OnToggleAnimEnd)
    270         eveui.animate(self.leftCont, 'width', end_value=LEFT_SIDE_WIDTH_EXPANDED, start_value=self.leftCont.width, duration=0.2)
    271 
    272     def _OnToggleAnimEnd(self):
    273         self.animationInProgress = False
    274         if charsheet_expanded_setting.is_enabled():
    275             self.SetFixedWidth(None)
    276             self._update_header_padding()
    277         else:
    278             self.SetFixedWidth(self.width)
    279             self.mainCont.Hide()
    280 
    281     def GetMinWidth(self):
    282         if charsheet_expanded_setting.is_enabled() or self.leftCont is None:
    283             return super(CharacterSheetWindow, self).GetMinWidth()
    284         else:
    285             return self.leftCont.width
    286 
    287     @eveui.skip_if_destroyed
    288     def _LoadPanel(self, panelID, autoExpand = True):
    289         if panelID in PARENT_PANELS:
    290             parentPanelID = PARENT_PANELS[panelID]
    291             tab = self.mainTabGroup.GetTabByID(parentPanelID)
    292             tab.sr.panel.LoadSubPanel(panelID)
    293             tab.SaveSelectedTabName()
    294             self.mainTabGroup.SelectByID(parentPanelID)
    295         else:
    296             self.mainTabGroup.SelectByID(panelID)
    297         if autoExpand and not charsheet_expanded_setting.is_enabled() and not self.InStack():
    298             self.ToggleCharacterSheetExpanded()
    299 
    300     def GetActivePanelID(self):
    301         return self.mainTabGroup.GetSelectedID()
    302 
    303     def GetActivePanelIDs(self):
    304         parentPanelID = self.GetActivePanelID()
    305         if parentPanelID in PARENT_PANELS.values():
    306             tab = self.mainTabGroup.GetTabByID(parentPanelID)
    307             subPanelID = tab.sr.panel.GetActivePanelID()
    308             return (parentPanelID, subPanelID)
    309         return (parentPanelID, None)
    310 
    311     def HideAllPanels(self):
    312         for panel in self.panelCont.children:
    313             panel.Hide()
    314 
    315     def OpenPortraitWnd(self, *args):
    316         PortraitWindow.CloseIfOpen()
    317         PortraitWindow.Open(charID=session.charid)
    318 
    319     @classmethod
    320     def _OpenPanel(cls, panelID):
    321         wnd = cls.GetIfOpen()
    322         if not wnd:
    323             wnd = cls.Open(panelID=panelID)
    324         wnd.Maximize()
    325         wnd._StartLoadingPanel(panelID)
    326 
    327     @classmethod
    328     def OpenSkillHistory(cls):
    329         return cls._OpenPanel(PANEL_SKILLS_HISTORY)
    330 
    331     @classmethod
    332     def OpenJumpClones(cls):
    333         return cls._OpenPanel(PANEL_JUMPCLONES)
    334 
    335     @classmethod
    336     def ToggleOpenWithPanel(cls, panelID):
    337         wnd = cls.GetIfOpen()
    338         if wnd and panelID in wnd.GetActivePanelIDs():
    339             wnd.Close()
    340         else:
    341             cls._OpenPanel(panelID)
    342 
    343     @classmethod
    344     def OpenImplantsAndBoosters(cls):
    345         return cls._OpenPanel(PANEL_IMPLANTSBOOTERS)
    346 
    347     @classmethod
    348     def OpenSecurityStatus(cls):
    349         return cls._OpenPanel(PANEL_SECURITYSTATUS)
    350 
    351     @classmethod
    352     def OpenPLEX(cls):
    353         return cls._OpenPanel(PANEL_PLEX)
    354 
    355     @classmethod
    356     def OpenStandings(cls):
    357         cls._OpenPanel(PANEL_STANDINGS)
    358 
    359     @classmethod
    360     def OpenDecorations(cls):
    361         cls._OpenPanel(PANEL_DECORATIONS)
    362 
    363     @classmethod
    364     def OpenDecorationsToTitles(cls):
    365         from eve.client.script.ui.shared.neocom.charsheet.decorationsPanel import DecorationsPanel
    366         DecorationsPanel._class_pending_open_titles = True
    367         cls._OpenPanel(PANEL_DECORATIONS)
    368 
    369     @classmethod
    370     def OpenDecorationsToTitle(cls, title_uuid_str):
    371         from eve.client.script.ui.shared.neocom.charsheet.decorationsPanel import DecorationsPanel
    372         DecorationsPanel._class_pending_title_uuid = title_uuid_str
    373         sm.ScatterEvent('OnTitleGrantedNotificationClicked', title_uuid_str)
    374         cls._OpenPanel(PANEL_DECORATIONS)
    375 
    376     @classmethod
    377     def OpenExpertSystems(cls, *args):
    378         cls._OpenPanel(PANEL_EXPERTSYSTEMS)
    379 
    380     @classmethod
    381     def OpenSkillHistoryHilightSkills(cls, skillIDs):
    382         cls.OpenSkillHistory()
    383         sm.ScatterEvent('OnHighlightSkillHistorySkills', skillIDs)
    384 
    385     @classmethod
    386     def OpenHomeStation(cls):
    387         cls._OpenPanel(PANEL_HOME_STATION)
    388 
    389     def DeselectAllNodes(self, wnd):
    390         for node in wnd.sr.scroll.GetNodes():
    391             wnd.sr.scroll._DeselectNode(node)
    392 
    393     def GetMenu(self, *args):
    394         m = Window.GetMenu(self, *args)
    395         m.append((MenuLabel('UI/Commands/ShowInfo'), GetMenuService().ShowInfo, (invconst.typeCharacter, session.charid)))
    396         if session.role & ROLE_QA:
    397             m.AddSeparator()
    398             add_window_context_menu(m)
    399         return m
    400 
    401     def OnStackInsert(self, stack):
    402         self._SetExpanded(animate=False)
    403         self.overviewPanel.avatarHeaderPreview.DisableRender()
    404         self.leftCont.Hide()
    405         self.SetMinSize(MINSIZE_STACKED)
    406         super(CharacterSheetWindow, self).OnStackInsert(stack)
    407 
    408     def OnStackRemove(self, correctpos, dragging, grab):
    409         self.leftCont.Show()
    410         self.overviewPanel.avatarHeaderPreview.EnableRender()
    411         self.SetMinSize(self.default_minSize)
    412         self._UpdateCharacterSheetExpanded(isExpanded=True, animate=False)
    413         super(CharacterSheetWindow, self).OnStackRemove(correctpos, dragging, grab)
    414 
    415     def _GetMinWidth(self):
    416         if self.GetStackID():
    417             return MINSIZE_STACKED[0]
    418         else:
    419             return super(CharacterSheetWindow, self)._GetMinWidth()
    420 
    421     def Minimize(self, animate = True):
    422         if self.overviewPanel is not None:
    423             self.overviewPanel.avatarHeaderPreview.DisableRender()
    424         super(CharacterSheetWindow, self).Minimize(animate)
    425 
    426     def Maximize(self, retainOrder = False, *args, **kwds):
    427         if not self._changing:
    428             super(CharacterSheetWindow, self).Maximize(retainOrder, *args, **kwds)
    429             if self.leftCont.display:
    430                 self.overviewPanel.avatarHeaderPreview.EnableRender()
    431             else:
    432                 self.overviewPanel.avatarHeaderPreview.DisableRender()
    433 
    434     def _on_expanded_setting_changed(self, value):
    435         self._update_left_cont_padding()
    436 
    437     def _on_content_padding_changed(self, window):
    438         self._update_left_cont_padding()
    439 
    440     def _on_header_height_changed(self, header):
    441         self._update_left_cont_padding()
    442 
    443     def _update_left_cont_padding(self):
    444         self.leftCont.padding = self._get_left_cont_padding()
    445 
    446     def _get_left_cont_padding(self):
    447         border_left, border_top, border_right, border_bottom = self.GetWindowBorderSize()
    448         pad_left, pad_top, pad_right, pad_bottom = self.content_padding
    449         header_height = self.header_height
    450         if charsheet_expanded_setting.is_enabled():
    451             final_pad_right = pad_right
    452         else:
    453             final_pad_right = -(border_right + pad_right)
    454         return (-(border_left + pad_left),
    455          -(border_top + pad_top + header_height),
    456          final_pad_right,
    457          -(border_bottom + pad_bottom))
    458 
    459     def _on_stacked_changed(self, window):
    460         self._update_header_padding()
    461 
    462     def _get_header_padding(self):
    463         if self.stacked:
    464             return (0, 0, 0, 0)
    465         expanded = charsheet_expanded_setting.is_enabled()
    466         if expanded:
    467             if self.leftCont:
    468                 return (self.leftCont.width,
    469                  0,
    470                  0,
    471                  0)
    472             else:
    473                 return (0, 0, 0, 0)
    474         else:
    475             return (0, 0, 0, 0)
    476 
    477     @eveui.skip_if_destroyed
    478     def _update_header_padding(self):
    479         if not self.closing:
    480             self.header.padding = self._get_header_padding()