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

itemIcon.py (6651B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\control\itemIcon.py
      2 from carbon.client.script.environment.AudioUtil import PlaySound
      3 from carbonui import const as uiconst
      4 from carbonui.primitives.container import Container
      5 from carbonui.primitives.sprite import Sprite
      6 from carbonui.util.various_unsorted import GetWindowAbove
      7 from eve.client.script.ui.control.eveIcon import Icon
      8 import evetypes
      9 import trinity
     10 from eve.client.script.ui.shared.cloneGrade import cloneStateUtil
     11 from eve.common.script.util.eveFormat import FmtISK
     12 from inventorycommon.typeHelpers import GetAveragePrice
     13 from localization import GetByLabel
     14 from omega.client.clone_grade_svc import get_clone_grade_svc
     15 from utillib import KeyVal
     16 from eveservices.menu import GetMenuService
     17 
     18 class ItemIcon(Container):
     19     default_align = uiconst.TOPLEFT
     20     default_state = uiconst.UI_NORMAL
     21     default_width = 32
     22     default_height = 32
     23     default_showOmegaOverlay = True
     24     isDragObject = True
     25     __notifyevents__ = ['OnSubscriptionChanged']
     26 
     27     def ApplyAttributes(self, attributes):
     28         Container.ApplyAttributes(self, attributes)
     29         self.typeID = attributes.typeID
     30         self.itemID = attributes.Get('itemID', None)
     31         self.bpData = attributes.Get('bpData', False)
     32         self.isCopy = attributes.Get('isCopy', False)
     33         self.showOmegaOverlay = attributes.Get('showOmegaOverlay', self.default_showOmegaOverlay)
     34         self.showPrice = attributes.Get('showPrice', False)
     35         textureSecondaryPath = attributes.Get('textureSecondaryPath', None)
     36         self.omegaOverlay = None
     37         self.techIcon = Sprite(name='techIcon', parent=self, width=16, height=16)
     38         self.icon = Icon(parent=self, align=uiconst.TOALL, state=uiconst.UI_DISABLED, textureSecondaryPath=textureSecondaryPath, spriteEffect=trinity.TR2_SFX_MODULATE if textureSecondaryPath else trinity.TR2_SFX_COPY)
     39         self.SetTypeID(self.typeID, self.bpData)
     40         sm.RegisterNotify(self)
     41 
     42     def OnSubscriptionChanged(self):
     43         self.UpdateOmegaOverlay()
     44 
     45     def SetTypeIDandItemID(self, typeID, itemID, bpData = None, isCopy = None):
     46         self.itemID = itemID
     47         self.SetTypeID(typeID, bpData, isCopy)
     48 
     49     def SetTypeID(self, typeID, bpData = None, isCopy = None):
     50         self.typeID = typeID
     51         self.bpData = bpData
     52         if isCopy is not None:
     53             self.isCopy = isCopy
     54         self.icon.LoadIconByTypeID(typeID, size=min(self.width, self.height), ignoreSize=True, isCopy=self.IsBlueprintCopy())
     55         from eve.client.script.ui.util.uix import GetTechLevelIconPathAndHint
     56         texturePath, hint = GetTechLevelIconPathAndHint(typeID)
     57         if texturePath:
     58             self.techIcon.texturePath = texturePath
     59             self.techIcon.hint = hint
     60             self.techIcon.Show()
     61         else:
     62             self.techIcon.Hide()
     63         self.isUnlockedWithExpertSystem = sm.GetService('skills').IsUnlockedWithExpertSystem(self.typeID)
     64         self.UpdateOmegaOverlay()
     65 
     66     def SetTexturePath(self, texturePath):
     67         self.icon.texturePath = texturePath
     68         self.techIcon.Hide()
     69         self.HideOmegaOverlay()
     70 
     71     def UpdateOmegaOverlay(self):
     72         if self.showOmegaOverlay and self.typeID:
     73             if get_clone_grade_svc().is_restricted_for_alpha(self.typeID) and not get_clone_grade_svc().is_omega_with_grace_period():
     74                 self.ShowOmegaOverlay()
     75             else:
     76                 self.HideOmegaOverlay()
     77 
     78     def HideOmegaOverlay(self):
     79         if self.omegaOverlay:
     80             self.omegaOverlay.Hide()
     81 
     82     def _isUnlockedWithExpertSystems(self):
     83         return sm.GetService('skills').IsUnlockedWithExpertSystem(self.typeID)
     84 
     85     def ShowOmegaOverlay(self):
     86         if self._isUnlockedWithExpertSystems():
     87             return
     88         if not self.omegaOverlay:
     89             from eve.client.script.ui.shared.cloneGrade.omegaCloneOverlayIcon import OmegaCloneOverlayIcon
     90             wndID = self.GetWindowAboveID()
     91             self.omegaOverlay = OmegaCloneOverlayIcon(parent=self, align=uiconst.TOALL, idx=1, iconSize=int(0.7 * self.width), origin=wndID, reason=self.typeID)
     92         self.omegaOverlay.state = uiconst.UI_DISABLED
     93 
     94     def GetWindowAboveID(self):
     95         wndAbove = GetWindowAbove(self)
     96         if wndAbove:
     97             return wndAbove.windowID
     98 
     99     def IsBlueprintCopy(self):
    100         if self.isCopy:
    101             return True
    102         if not self.bpData:
    103             return False
    104         return not self.bpData.original
    105 
    106     def GetMenu(self):
    107         self.SetBpDataForCopy()
    108         return GetMenuService().GetMenuFromItemIDTypeID(self.itemID, self.typeID, includeMarketDetails=True, abstractInfo=KeyVal(fullBlueprintData=self.bpData))
    109 
    110     def OnClick(self):
    111         PlaySound(uiconst.SOUND_BUTTON_CLICK)
    112         self.SetBpDataForCopy()
    113         sm.GetService('info').ShowInfo(self.typeID, self.itemID, abstractinfo=KeyVal(fullBlueprintData=self.bpData))
    114 
    115     def SetBpDataForCopy(self):
    116         if self.isCopy and not self.bpData:
    117             self.bpData = sm.GetService('blueprintSvc').GetBlueprintTypeCopy(self.typeID, original=False)
    118 
    119     def GetHint(self):
    120         if self.typeID:
    121             name = evetypes.GetName(self.typeID)
    122             description = evetypes.GetDescription(self.typeID)
    123             ret = u'<b>%s</b>' % name
    124             if description:
    125                 ret += u'\n%s' % description
    126             if self.showPrice:
    127                 price = GetAveragePrice(self.typeID)
    128                 if price:
    129                     ret += '\n\n%s' % GetByLabel('UI/SkillTrading/EstimatedPrice', price=FmtISK(price, False))
    130             return ret
    131 
    132     def GetDragData(self):
    133         return [KeyVal(__guid__='uicls.GenericDraggableForTypeID', typeID=self.typeID, label=evetypes.GetName(self.typeID), bpData=self.bpData, isCopy=self.IsBlueprintCopy())]
    134 
    135     def OnMouseEnter(self, *args):
    136         if self.IsOmegaOverlayVisible():
    137             self.omegaOverlay.OnMouseEnter()
    138 
    139     def OnMouseExit(self, *args):
    140         if self.IsOmegaOverlayVisible():
    141             self.omegaOverlay.OnMouseExit()
    142 
    143     def LoadTooltipPanel(self, tooltipPanel, *args):
    144         if self.IsOmegaOverlayVisible() and not get_clone_grade_svc().is_omega_with_grace_period():
    145             cloneStateUtil.LoadTooltipPanel(tooltipPanel, origin=self.GetWindowAboveID(), reason=self.typeID)
    146         else:
    147             tooltipPanel.LoadGeneric1ColumnTemplate()
    148         import expertSystems.client
    149         expertSystems.add_type_unlocked_by_expert_systems(tooltipPanel, self.typeID)
    150 
    151     def IsOmegaOverlayVisible(self):
    152         return self.omegaOverlay and self.omegaOverlay.display