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

itemBtns.py (6308B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\tooltip\itemBtns.py
      2 import evetypes
      3 from carbonui.control.button import Button
      4 from eve.client.script.ui.shared.industry import submitButton
      5 from eve.client.script.ui.shared.neocom import skillConst
      6 from inventorycommon import const as invconst
      7 from eve.client.script.ui.services.menuSvcExtras import menuFunctions
      8 from localization import GetByLabel
      9 from carbonui import uiconst
     10 
     11 class TrainNowButton(submitButton.PrimaryButton):
     12     default_name = 'TrainNowButton'
     13 
     14     def ApplyAttributes(self, attributes):
     15         super(TrainNowButton, self).ApplyAttributes(attributes)
     16         self.typeID = attributes.typeID
     17         self.required = attributes.required
     18         self._isFinished = False
     19         self.UpdateState()
     20 
     21     def IsActive(self):
     22         return not self._isFinished
     23 
     24     def ClickFunc(self, *args):
     25         self.Disable()
     26         try:
     27             sm.GetService('skillqueue').AddSkillAndRequirementsToQueue(self.typeID)
     28             self._isFinished = True
     29         except Exception:
     30             self.Enable()
     31 
     32         self.UpdateState()
     33 
     34     def GetColor(self):
     35         if self._isFinished:
     36             return (1.0, 1.0, 1.0, 0.3)
     37         else:
     38             return skillConst.COLOR_SKILL_2
     39 
     40     def GetText(self):
     41         if self._isFinished:
     42             skills = GetMissingRequiredSkills(self.typeID)
     43             skillCount = len(skills)
     44             if evetypes.GetCategoryID(self.typeID) == invconst.categorySkill:
     45                 skillCount += 1
     46             return GetByLabel('UI/SkillQueue/SkillsQueued', skillCount=skillCount)
     47         else:
     48             return GetByLabel('UI/SkillQueue/AddToQueue')
     49 
     50 
     51 class InjectSkillButton(submitButton.PrimaryButton):
     52     default_name = 'InjectSkillButton'
     53 
     54     def ApplyAttributes(self, attributes):
     55         super(InjectSkillButton, self).ApplyAttributes(attributes)
     56         self._item = attributes.item
     57         self._injected = False
     58         self.UpdateState()
     59 
     60     def ClickFunc(self, *args):
     61         self.Disable()
     62         try:
     63             sm.GetService('skills').InjectSkillIntoBrain([self._item])
     64             self._injected = True
     65         except Exception:
     66             self.Enable()
     67             raise
     68 
     69         self.UpdateState()
     70 
     71     def IsActive(self):
     72         return not self._injected
     73 
     74     def GetColor(self):
     75         if self._injected:
     76             return (1.0, 1.0, 1.0, 0.3)
     77         else:
     78             return skillConst.COLOR_SKILL_2
     79 
     80     def GetText(self):
     81         if self._injected:
     82             return GetByLabel('UI/SkillQueue/SkillInjected')
     83         else:
     84             return GetByLabel('UI/SkillQueue/InjectSkill')
     85 
     86 
     87 class ActivateSkinButton(submitButton.PrimaryButton):
     88     default_name = 'ActivateSkinButton'
     89 
     90     def ApplyAttributes(self, attributes):
     91         super(ActivateSkinButton, self).ApplyAttributes(attributes)
     92         self._item = attributes.item
     93         self._injected = False
     94         self.UpdateState()
     95 
     96     def ClickFunc(self, *args):
     97         self.Disable()
     98         try:
     99             menuFunctions.ActivateShipSkinLicense([[self._item.itemID, self._item.typeID]])
    100             self._injected = True
    101         except Exception:
    102             self.Enable()
    103             raise
    104 
    105         self.UpdateState()
    106 
    107     def IsActive(self):
    108         return not self._injected
    109 
    110     def GetColor(self):
    111         if self._injected:
    112             return (1.0, 1.0, 1.0, 0.3)
    113         else:
    114             return skillConst.COLOR_SKILL_2
    115 
    116     def GetText(self):
    117         return GetByLabel('UI/Commands/ActivateSkinLicense')
    118 
    119 
    120 class ActivateAndApplySkinButton(submitButton.PrimaryButton):
    121     default_name = 'ActivateAndApplySkinButton'
    122 
    123     def ApplyAttributes(self, attributes):
    124         self._can_apply = attributes.can_apply
    125         attributes['enabled'] = self._can_apply
    126         super(ActivateAndApplySkinButton, self).ApplyAttributes(attributes)
    127         self._item = attributes.item
    128         self._injected = False
    129         self.UpdateState()
    130 
    131     def UpdateIsEnabledByState(self):
    132         if self._can_apply:
    133             self.Enable()
    134         else:
    135             self.Disable()
    136 
    137     def ClickFunc(self, *args):
    138         self.Disable()
    139         try:
    140             menuFunctions.ActivateShipSkinLicenseAndApply(self._item.itemID, self._item.typeID)
    141             self._injected = True
    142         except Exception:
    143             self.Enable()
    144             raise
    145 
    146         self.UpdateState()
    147 
    148     def IsActive(self):
    149         if not self._can_apply:
    150             return False
    151         return not self._injected
    152 
    153     def GetColor(self):
    154         if not self.enabled or self._injected:
    155             return (1.0, 1.0, 1.0, 0.3)
    156         else:
    157             return skillConst.COLOR_SKILL_2
    158 
    159     def GetText(self):
    160         if not self._can_apply:
    161             return GetByLabel('UI/Commands/ActivateAndApplySkinLicenseDisabled')
    162         return GetByLabel('UI/Commands/ActivateAndApplySkinLicense')
    163 
    164 
    165 class ConsumeSkinDesignComponentButton(submitButton.PrimaryButton):
    166     default_name = 'ConsumeSkinDesignComponentButton'
    167 
    168     def ApplyAttributes(self, attributes):
    169         super(ConsumeSkinDesignComponentButton, self).ApplyAttributes(attributes)
    170         self._item = attributes.item
    171         self._isConsumed = False
    172         self.UpdateState()
    173 
    174     def ClickFunc(self, *args):
    175         self.Disable()
    176         try:
    177             menuFunctions.ConsumeSkinDesignComponent([(self._item.itemID, self._item.typeID, self._item.stacksize)])
    178             self._isConsumed = True
    179         except Exception:
    180             self.Enable()
    181             raise
    182 
    183         self.UpdateState()
    184 
    185     def IsActive(self):
    186         return not self._isConsumed
    187 
    188     def GetColor(self):
    189         if self._isConsumed:
    190             return (1.0, 1.0, 1.0, 0.3)
    191         else:
    192             return skillConst.COLOR_SKILL_2
    193 
    194     def GetText(self):
    195         return GetByLabel('UI/Inventory/ItemActions/ConsumeSkinDesignComponentItem')
    196 
    197     def GetHint(self):
    198         return GetByLabel('UI/Personalization/ShipSkins/SKINR/Store/ActivateNowHint')
    199 
    200 
    201 def GetMissingRequiredSkills(typeID):
    202     required = sm.GetService('skills').GetSkillsMissingToUseItemRecursive(typeID)
    203     inQueue = sm.GetService('skills').GetMaxSkillLevelsInQueue()
    204     missing = [ (s, l) for s, l in required.iteritems() if inQueue.get(s, 0) < l ]
    205     return missing