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

requirements.py (5159B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\market\requirements.py
      2 import carbonui.const as uiconst
      3 from carbon.common.script.util.format import FmtAmt
      4 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      5 from carbonui.primitives.flowcontainer import FlowContainer
      6 from carbonui.primitives.sprite import Sprite
      7 import dogma.const as dconst
      8 from eve.client.script.ui.control.eveLabel import EveLabelSmallBold
      9 from eve.client.script.ui.control.skillBar.skillBar import SkillBar
     10 from eve.client.script.ui.shared.info import infoConst
     11 from eve.common.script.sys.eveCfg import GetActiveShip
     12 import evetypes
     13 import inventorycommon.const as invconst
     14 from expertSystems.client import AssociatedExpertSystemIcon, is_expert_systems_enabled
     15 from inventorycommon.util import IsFittingModule
     16 import localization
     17 ICON_SIZE = 24
     18 
     19 class RequirementsContainer(FlowContainer):
     20     default_name = 'RequirementsContainer'
     21 
     22     def __init__(self, typeID = None, **kwargs):
     23         super(RequirementsContainer, self).__init__(contentSpacing=(2, 2), **kwargs)
     24         self.typeID = typeID
     25         if self.typeID is not None:
     26             self.LoadTypeRequirements(self.typeID)
     27 
     28     def LoadTypeRequirements(self, typeID):
     29         if self.typeID is not None:
     30             self.Flush()
     31         self.typeID = typeID
     32         if typeID is None:
     33             return
     34         categoryID = evetypes.GetCategoryID(typeID)
     35         isSkill = categoryID == invconst.categorySkill
     36         haveSkill = sm.GetService('skills').GetSkill(typeID) is not None
     37         requiredSkills = sm.GetService('clientDogmaStaticSvc').GetRequiredSkills(typeID)
     38         if isSkill and haveSkill:
     39             SkillBar(parent=self, align=uiconst.NOALIGN, skillID=typeID)
     40         elif requiredSkills:
     41             texturePath, hint = sm.GetService('skills').GetRequiredSkillsLevelTexturePathAndHint(requiredSkills.items(), typeID=typeID)
     42             skillIcon = Sprite(name='skillIcon', parent=self, align=uiconst.NOALIGN, width=ICON_SIZE, height=ICON_SIZE, texturePath=texturePath, hint=hint, useSizeFromTexture=False)
     43             if is_expert_systems_enabled():
     44                 AssociatedExpertSystemIcon(parent=self, align=uiconst.NOALIGN, type_id=self.typeID, on_click=lambda : sm.GetService('info').ShowInfo(typeID=typeID, selectTabType=infoConst.TAB_REQUIREMENTS))
     45             skillSvc = sm.GetService('skills')
     46 
     47             def OpenRequirementsInfoTab():
     48                 info = sm.GetService('info')
     49                 info.ShowInfo(typeID, selectTabType=infoConst.TAB_REQUIREMENTS)
     50 
     51             skillIcon.OnClick = OpenRequirementsInfoTab
     52         if IsFittingModule(categoryID):
     53             godma = sm.GetService('godma')
     54             dogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation()
     55             shipID = GetActiveShip()
     56             powerContainer = ContainerAutoSize(name='powerContainer', parent=self, align=uiconst.NOALIGN)
     57             textPadding = 4
     58             modulePowerLoad = godma.GetTypeAttribute(typeID, dconst.attributePower, 0)
     59             powerOutput = dogmaLocation.GetAttributeValue(shipID, dconst.attributePowerOutput) - dogmaLocation.GetAttributeValue(shipID, dconst.attributePowerLoad)
     60             havePower = shipID is not None and powerOutput >= modulePowerLoad
     61             if havePower:
     62                 icon = 'res:/UI/Texture/classes/Market/powerRequirementMet.png'
     63                 hint = 'UI/Market/Marketbase/PowerRequirementMet'
     64             else:
     65                 icon = 'res:/UI/Texture/classes/Market/powerRequirementNotMet.png'
     66                 hint = 'UI/Market/Marketbase/PowerRequirementNotMet'
     67             powerIcon = Sprite(name='powerIcon', parent=powerContainer, align=uiconst.CENTERTOP, texturePath=icon, width=ICON_SIZE, height=ICON_SIZE, ignoreSize=True, hint=localization.GetByLabel(hint))
     68             powerLabel = EveLabelSmallBold(name='powerLabel', parent=powerContainer, align=uiconst.CENTERTOP, top=ICON_SIZE + 2, text=FmtAmt(modulePowerLoad, fmt='ln'), padRight=textPadding)
     69             cpuContainer = ContainerAutoSize(parent=self, align=uiconst.NOALIGN)
     70             moduleCpuLoad = godma.GetTypeAttribute(typeID, dconst.attributeCpu, 0)
     71             cpuOutput = dogmaLocation.GetAttributeValue(shipID, dconst.attributeCpuOutput) - dogmaLocation.GetAttributeValue(shipID, dconst.attributeCpuLoad)
     72             haveCpu = shipID is not None and cpuOutput >= moduleCpuLoad
     73             if haveCpu:
     74                 icon = 'res:/UI/Texture/classes/Market/cpuRequirementMet.png'
     75                 hint = 'UI/Market/Marketbase/CpuRequirementMet'
     76             else:
     77                 icon = 'res:/UI/Texture/classes/Market/cpuRequirementNotMet.png'
     78                 hint = 'UI/Market/Marketbase/CpuRequirementNotMet'
     79             cpuIcon = Sprite(name='cpuIcon', parent=cpuContainer, align=uiconst.CENTERTOP, texturePath=icon, ignoreSize=True, width=ICON_SIZE, height=ICON_SIZE, hint=localization.GetByLabel(hint))
     80             cpuLabel = EveLabelSmallBold(name='cpuLabel', parent=cpuContainer, align=uiconst.CENTERTOP, top=ICON_SIZE + 2, text=FmtAmt(moduleCpuLoad, fmt='ln'), padRight=textPadding)