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

panelItemIndustry.py (6105B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\info\panels\panelItemIndustry.py
      2 import evetypes
      3 import localization
      4 from carbonui import uiconst, TextColor
      5 from carbonui.primitives.container import Container
      6 from eve.client.script.ui import eveColor
      7 from eve.client.script.ui.control.entries.header import Header
      8 from eve.client.script.ui.control.entries.item import Item
      9 from eve.client.script.ui.control.entries.util import GetFromClass
     10 from eve.client.script.ui.control.eveScroll import Scroll
     11 from evetypes import TypeNotFoundException
     12 import itemcompression.data as compressiondata
     13 from typematerials.data import get_type_materials_by_id, is_decompressible_gas_type, get_type_randomized_materials_by_id, type_has_randomized_materials, type_has_materials
     14 
     15 class PanelItemIndustry(Container):
     16     typeID = None
     17 
     18     def ApplyAttributes(self, attributes):
     19         Container.ApplyAttributes(self, attributes)
     20         self.typeID = attributes.typeID
     21 
     22     def Load(self):
     23         self.Flush()
     24         entries = []
     25         entries.extend(self._GetBlueprintEntries())
     26         if type_has_materials(self.typeID):
     27             entries.extend(self._GetReprocessingEntries())
     28         elif type_has_randomized_materials(self.typeID):
     29             entries.extend(self._GetRandomizedReprocessingEntries())
     30         entries.extend(self._GetRequiredForEntries())
     31         entries.extend(self._GetCompressionEntries())
     32         scroll = Scroll(parent=self, padding=uiconst.defaultPadding)
     33         scroll.Load(contentList=entries)
     34 
     35     def _GetCompressionEntries(self):
     36         entries = []
     37         if compressiondata.is_compressible_type(self.typeID):
     38             entryHeader = GetFromClass(Header, {'label': localization.GetByLabel('UI/InfoWindow/Subheaders/CompressionOutput')})
     39             entries.append(entryHeader)
     40             compressedTypeID = compressiondata.get_compressed_type_id(self.typeID)
     41             entryItem = GetFromClass(Item, {'label': evetypes.GetName(compressedTypeID),
     42              'typeID': compressedTypeID,
     43              'getIcon': 1})
     44             entries.append(entryItem)
     45         if compressiondata.is_compressed_type(self.typeID):
     46             entryHeader = GetFromClass(Header, {'label': localization.GetByLabel('UI/InfoWindow/Subheaders/CompressionInput')})
     47             entries.append(entryHeader)
     48             for sourceTypeID in compressiondata.get_compression_source_type_ids(self.typeID):
     49                 entryItem = GetFromClass(Item, {'label': evetypes.GetName(sourceTypeID),
     50                  'typeID': sourceTypeID,
     51                  'getIcon': 1})
     52                 entries.append(entryItem)
     53 
     54         return entries
     55 
     56     def _GetRequiredForEntries(self):
     57         entries = []
     58         blueprintIDs = cfg.blueprintsByMaterialTypeIDs.get(self.typeID, None)
     59         if blueprintIDs:
     60             for blueprintID in blueprintIDs:
     61                 try:
     62                     if not evetypes.IsPublished(blueprintID):
     63                         continue
     64                 except TypeNotFoundException:
     65                     continue
     66 
     67                 entries.append(GetFromClass(Item, {'label': evetypes.GetName(blueprintID),
     68                  'typeID': blueprintID,
     69                  'getIcon': 1}))
     70 
     71             entries = sorted(entries, key=self._GetRequiredForSortKey)
     72             if entries:
     73                 entries.insert(0, GetFromClass(Header, {'label': localization.GetByLabel('UI/InfoWindow/TabNames/RequiredFor')}))
     74         return entries
     75 
     76     def _GetRequiredForSortKey(self, entry):
     77         return entry.label
     78 
     79     def _GetReprocessingEntries(self):
     80         entries = []
     81         materials = get_type_materials_by_id(self.typeID)
     82         if materials:
     83             if is_decompressible_gas_type(self.typeID):
     84                 entries.append(GetFromClass(Header, {'label': localization.GetByLabel('UI/InfoWindow/Subheaders/DecompressionOutput')}))
     85             else:
     86                 entries.append(GetFromClass(Header, {'label': localization.GetByLabel('UI/Reprocessing/ReprocessedMaterials')}))
     87             for material in materials:
     88                 typeID = material.materialTypeID
     89                 quantity = material.quantity
     90                 entries.append(GetFromClass(Item, {'label': localization.GetByLabel('UI/InfoWindow/TypeNameWithNumUnits', invType=typeID, qty=quantity),
     91                  'typeID': typeID,
     92                  'getIcon': 1,
     93                  'quantity': quantity}))
     94 
     95         return entries
     96 
     97     def _GetRandomizedReprocessingEntries(self):
     98         entries = []
     99         randomizedMaterials = get_type_randomized_materials_by_id(self.typeID)
    100         if not randomizedMaterials:
    101             return entries
    102         numOutputTypes = len(randomizedMaterials)
    103         if numOutputTypes > 1:
    104             headerText = localization.GetByLabel('UI/Reprocessing/RandomQtyOutputHeader', numOutputTypes=numOutputTypes)
    105         else:
    106             headerText = localization.GetByLabel('UI/Reprocessing/RandomReprocessedMaterials')
    107         entries.append(GetFromClass(Header, {'label': headerText}))
    108         sortedMaterials = sorted(randomizedMaterials, key=lambda x: evetypes.GetName(x.materialTypeID))
    109         for material in sortedMaterials:
    110             typeID = material.materialTypeID
    111             label = localization.GetByLabel('UI/Reprocessing/TypeNameWithMinMaxQtyOutput', typeID=typeID, color=TextColor.NORMAL, minQty=material.quantityMin, maxQty=material.quantityMax)
    112             data = {'label': label,
    113              'typeID': typeID,
    114              'getIcon': 1}
    115             entries.append(GetFromClass(Item, data))
    116 
    117         return entries
    118 
    119     def _GetBlueprintEntries(self):
    120         entries = []
    121         bpData = sm.GetService('blueprintSvc').GetBlueprintByProduct(self.typeID)
    122         if bpData and evetypes.IsPublished(bpData.blueprintTypeID):
    123             entries.append(GetFromClass(Header, {'label': localization.GetByLabel('UI/Industry/Blueprint')}))
    124             entries.append(GetFromClass(Item, {'label': bpData.GetName(),
    125              'typeID': bpData.blueprintTypeID,
    126              'getIcon': 1}))
    127         return entries