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

infoWindow.py (8049B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\info\infoWindow.py
      2 import sys
      3 import blue
      4 import dogma.data
      5 import eveicon
      6 import localization
      7 from carbonui import uiconst
      8 from carbonui.primitives.container import Container
      9 from carbonui.primitives.sprite import Sprite
     10 from carbonui.uicore import uicore
     11 from carbonui.window.control.action import WindowMenuAction, WindowActionImportance
     12 from eve.client.script.ui.control import eveIcon, eveLabel
     13 from eve.client.script.ui.control.entries.generic import Generic
     14 from eve.client.script.ui.inflight.shipModuleButton.attributeValueRowContainer import AttributeValueRowContainer
     15 from menu import MenuLabel
     16 from .baseInfoWindow import BaseInfoWindow
     17 MINWIDTH = 480
     18 
     19 class InfoWindow(BaseInfoWindow):
     20     __guid__ = 'form.infowindow'
     21     __notifyevents__ = ['OnBountyPlaced', 'OnSkillsChanged']
     22     default_width = 500
     23     default_height = 600
     24     default_name = 'infoWindow'
     25     default_windowID = 'infowindow'
     26     default_iconNum = 'res:/ui/Texture/WindowIcons/info.png'
     27     default_scope = uiconst.SCOPE_INGAME
     28     info_content = None
     29 
     30     def __init__(self, info_type, **kwargs):
     31         if info_type is None:
     32             raise Exception('InfoWindow info_type is None')
     33         self.info_content = info_type()
     34         super(InfoWindow, self).__init__(**kwargs)
     35 
     36     def change_info_content(self, new_info_type):
     37         self._stop_reconstruct_thread()
     38         self.info_content = new_info_type()
     39 
     40     def _OnResize(self, *args):
     41         if self.info_content:
     42             self.info_content.on_resize(args)
     43 
     44     def ConstructLayout(self):
     45         self.GetMainArea().Flush()
     46         self.info_content.construct_layout(window_main_area=self.GetMainArea(), header_parent=self.sr.headerParent, content=self.content, compact=self.compact)
     47 
     48     def GetCustomHeaderButtons(self):
     49         return [WindowMenuAction(window=self, icon=eveicon.navigate_forward, label=localization.GetByLabel('UI/Control/EveWindow/Next'), callback=self.OnForward, ui_name='ForwardButton', enabled_check=lambda window: window.history.IsForwardEnabled(), importance=WindowActionImportance.content), WindowMenuAction(window=self, icon=eveicon.navigate_back, label=localization.GetByLabel('UI/Control/EveWindow/Previous'), callback=self.OnBack, ui_name='BackButton', enabled_check=lambda window: window.history.IsBackEnabled(), importance=WindowActionImportance.content)]
     50 
     51     def ConstructWindowHeader(self):
     52         self.info_content.construct_window_header(self)
     53 
     54     def OnBack(self, *args):
     55         if self.isLoading:
     56             return
     57         self.UpdateHistoryData(self.GetHistoryData())
     58         self.NavigateHistory(self.history.GoBack())
     59 
     60     def OnForward(self, *args):
     61         if self.isLoading:
     62             return
     63         self.UpdateHistoryData(self.GetHistoryData())
     64         self.NavigateHistory(self.history.GoForward())
     65 
     66     def NavigateHistory(self, history_window_data):
     67         if history_window_data is None:
     68             return
     69         info_svc = sm.GetService('info')
     70         history_info_class = info_svc.GetInfoWindowContentClass(history_window_data[0], history_window_data[1])
     71         history_info_type = info_svc.GetEnumForInfoWindowType(history_info_class)
     72         if history_info_type == self.info_content.info_type:
     73             self._stop_reconstruct_thread()
     74             self._ReconstructInfoWindow(typeID=history_window_data[0], itemID=history_window_data[1], rec=history_window_data[2], parentID=history_window_data[3], abstractinfo=history_window_data[4], branchHistory=False)
     75         else:
     76             info_svc.ShowInfo(typeID=history_window_data[0], itemID=history_window_data[1], rec=history_window_data[2], parentID=history_window_data[3], abstractinfo=history_window_data[4], traversingHistory=True)
     77 
     78     def UpdateWindowMinSize(self, width):
     79         height = 0
     80         min_size = self.info_content.get_window_min_size(width, height)
     81         self.SetMinSize(min_size)
     82 
     83     def _ReconstructInfoWindow(self, typeID, itemID = None, rec = None, parentID = None, abstractinfo = None, branchHistory = True, selectTabType = None, params = None):
     84         try:
     85             self.ShowLoad()
     86             self.isLoading = True
     87             self.HideError()
     88             if self.top == uicore.desktop.height:
     89                 self.Maximize()
     90             self.info_content.header_icon = self.sr.header_icon
     91             width_requirements = self.info_content.reconstruct_info_window(typeID, itemID, rec, parentID, abstractinfo, selectTabType, params)
     92             if self.info_content.update_window_controls:
     93                 self.update_window_controls()
     94             self.SetCaption(self.info_content.update_caption())
     95             width_requirements.insert(0, MINWIDTH)
     96             width = max(width_requirements)
     97             self.UpdateWindowMinSize(width)
     98             super(InfoWindow, self)._ReconstructInfoWindow(typeID, itemID, rec, parentID, abstractinfo, branchHistory, selectTabType, params)
     99         except BadArgs as e:
    100             self.ShowError(e.args)
    101             sys.exc_clear()
    102         finally:
    103             self.HideLoad()
    104             self.isLoading = False
    105 
    106         self.reconstruct_thread = None
    107         uicore.registry.SetFocus(self)
    108 
    109     def ShowError(self, args):
    110         self.info_content.show_error(args)
    111 
    112     def HideError(self):
    113         self.info_content.hide_error(self.IsCollapsed())
    114 
    115     def GetHistoryData(self):
    116         return (self.info_content.type_id,
    117          self.info_content.item_id,
    118          self.info_content.rec,
    119          self.info_content.parent_id,
    120          self.info_content.abstract_info)
    121 
    122     def GetMenuMoreOptions(self):
    123         menu_data = super(InfoWindow, self).GetMenuMoreOptions()
    124         menu_data += self.info_content.get_action_menu(self.info_content.item_id, self.info_content.type_id, self.info_content.rec)
    125         return menu_data
    126 
    127 
    128 class BadArgs(RuntimeError):
    129 
    130     def __init__(self, msgID, kwargs = None):
    131         RuntimeError.__init__(self, msgID, kwargs or {})
    132 
    133 
    134 class AttributeRowEntry(Generic):
    135 
    136     def Startup(self, *args):
    137         Generic.Startup(self, *args)
    138         self.sr.label.display = False
    139         self.rowLabel = eveLabel.EveLabelMedium(parent=self, text='', align=uiconst.TOTOP, padLeft=8, padTop=3)
    140         self.spriteCont = Container(parent=self, name='spriteCont', align=uiconst.TOLEFT, width=32)
    141         self.sprite = Sprite(parent=self.spriteCont, name='rowSprite', pos=(0, 0, 32, 32), align=uiconst.CENTER)
    142         self.damageContainer = AttributeValueRowContainer(parent=self, padding=(2, 2, 0, 2), align=uiconst.TOALL, height=0, doWidthAdjustments=True, loadOnStartup=False)
    143 
    144     def Load(self, node):
    145         node.selectable = False
    146         itemID = node.itemID
    147         labelText = localization.GetByLabel(node.labelPath) if node.labelPath else ''
    148         self.rowLabel.text = labelText
    149         modifiedAttributesDict = node.modifiedAttributesDict
    150         self.damageContainer.Load(node.attributeValues, mouseExitFunc=self.OnMouseExit, onClickFunc=node.OnClickAttr, modifiedAttributesDict=modifiedAttributesDict, itemID=itemID)
    151         if node.texturePath:
    152             self.sprite.LoadTexture(node.texturePath)
    153         else:
    154             self.spriteCont.display = False
    155 
    156     def GetHeight(self, *args):
    157         node, width = args
    158         node.height = 50
    159         return node.height
    160 
    161     def OnMouseExit(self, *args):
    162         if uicore.uilib.mouseOver.IsUnder(self):
    163             return
    164         Generic.OnMouseExit(self, *args)
    165 
    166     def GetMenu(self):
    167         return [(MenuLabel('UI/Common/Copy'), self.CopyText)]
    168 
    169     def CopyText(self):
    170         text = self.GetCopyData(self.sr.node)
    171         blue.pyos.SetClipboardData(text)
    172 
    173     @classmethod
    174     def GetCopyData(cls, node):
    175         attributeTextList = []
    176         for attributeID, value in node.attributeValues:
    177             displayName = dogma.data.get_attribute_display_name(attributeID)
    178             text = '%s\t%s' % (displayName, value)
    179             attributeTextList.append(text)
    180 
    181         return '\n'.join(attributeTextList)