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

planetaryProduction.py (5178B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\info\panels\planetaryProduction.py
      2 import evetypes
      3 from carbonui.primitives.container import Container
      4 from eve.client.script.ui.control import entries
      5 from eve.client.script.ui.control.entries.header import Header, Subheader
      6 from eve.client.script.ui.control.entries.item import Item
      7 from eve.client.script.ui.control.entries.space import Space
      8 from eve.client.script.ui.control.entries.text import Text
      9 from eve.client.script.ui.control.entries.util import GetFromClass
     10 from eve.client.script.ui.control.eveScroll import Scroll
     11 from eve.client.script.ui.shared.planet import planetCommon
     12 from eve.client.script.ui.shared.planet.planetSchematicItemEntry import PlanetSchematicItemEntry
     13 from eve.common.lib import appConst as const
     14 from fsdBuiltData.common.planet import get_planet_type_ids_for_resource_type_id
     15 from fsdBuiltData.common.planet import get_schematic_types
     16 from localization import GetByLabel
     17 from utillib import KeyVal
     18 
     19 class PanelPlanetaryProduction(Container):
     20 
     21     def ApplyAttributes(self, attributes):
     22         Container.ApplyAttributes(self, attributes)
     23         self.typeID = attributes.typeID
     24         self.isInitialized = False
     25 
     26     def Load(self):
     27         if self.isInitialized:
     28             return
     29         self.scroll = Scroll(name='scroll', parent=self, padding=const.defaultPadding)
     30         scrolllist = self.GetScrollList()
     31         self.scroll.Load(fixedEntryHeight=27, contentList=scrolllist)
     32         self.isInitialized = True
     33 
     34     def GetScrollList(self):
     35         return self.GetSchematicScrolllist() + self.GetExtractedByScrolllist() + self.GetRequiredForScrolllist()
     36 
     37     def GetSchematicScrolllist(self):
     38         inputs, outputs = self._GetSchematicInputsAndOutputs()
     39         scrolllist = []
     40         if inputs and outputs:
     41             scrolllist.append(GetFromClass(Header, {'label': GetByLabel('UI/PI/Common/Schematic')}))
     42             schematic = planetCommon.GetSchematicDataForID(self.GetSchematicID())
     43             text = planetCommon.GetSchematicCycleTimeText(schematic)
     44             scrolllist.append(GetFromClass(Text, {'text': text}))
     45             text = planetCommon.GetSchematicOutputVolumeText(schematic)
     46             scrolllist.append(GetFromClass(Text, {'text': text}))
     47             scrolllist.append(GetFromClass(Subheader, {'label': GetByLabel('UI/PI/Common/SchematicInput')}))
     48             for data in inputs:
     49                 scrolllist.append(GetFromClass(PlanetSchematicItemEntry, data))
     50 
     51             scrolllist.append(GetFromClass(Subheader, {'label': GetByLabel('UI/PI/Common/OutputProduct')}))
     52             for data in outputs:
     53                 scrolllist.append(GetFromClass(PlanetSchematicItemEntry, data))
     54 
     55         return scrolllist
     56 
     57     def _GetSchematicInputsAndOutputs(self):
     58         schematicID = self.GetSchematicID()
     59         inputs = []
     60         outputs = []
     61         for typeID, typeInfo in get_schematic_types(schematicID, {}).iteritems():
     62             label = GetByLabel('UI/PI/Common/ItemAmount', itemName=planetCommon.GetProductNameAndTier(typeID), amount=typeInfo.quantity)
     63             data = KeyVal(label=label, typeID=typeID, itemID=None, getIcon=1, quantity=typeInfo.quantity, selectable=False)
     64             if typeInfo.isInput:
     65                 inputs.append(data)
     66             else:
     67                 outputs.append(data)
     68 
     69         return (inputs, outputs)
     70 
     71     def GetSchematicID(self):
     72         schematicID = planetCommon.GetSchematicByOutput(self.typeID)
     73         return schematicID
     74 
     75     def GetExtractedByScrolllist(self):
     76         scrolllist = []
     77         extractedByScrolllist = self._GetExtractableOnScrollList()
     78         if len(extractedByScrolllist) > 0:
     79             scrolllist.append(GetFromClass(Header, {'label': GetByLabel('UI/InfoWindow/ExtractableOnPlanet')}))
     80             scrolllist.extend(extractedByScrolllist)
     81         return scrolllist
     82 
     83     def GetRequiredForScrolllist(self):
     84         scrolllist = []
     85         scrolllist.append(GetFromClass(Space, {'height': 10}))
     86         consumingSchematicLines = self._GetRequiredForScrolllist()
     87         if len(consumingSchematicLines) > 0:
     88             scrolllist.append(GetFromClass(Header, {'label': GetByLabel('UI/InfoWindow/TabNames/RequiredFor')}))
     89             scrolllist.extend(consumingSchematicLines)
     90         return scrolllist
     91 
     92     def _GetRequiredForScrolllist(self):
     93         scrolllist = []
     94         for typeID in planetCommon.GetRequiredForItems(self.typeID):
     95             entry = GetFromClass(PlanetSchematicItemEntry, {'itemID': None,
     96              'typeID': typeID,
     97              'label': planetCommon.GetProductNameAndTier(typeID),
     98              'getIcon': 1,
     99              'selectable': False})
    100             scrolllist.append(entry)
    101 
    102         return scrolllist
    103 
    104     def _GetExtractableOnScrollList(self):
    105         scrolllist = []
    106         for planetTypeID in get_planet_type_ids_for_resource_type_id(self.typeID, []):
    107             scrolllist.append(GetFromClass(Item, {'itemID': None,
    108              'typeID': planetTypeID,
    109              'selectable': False,
    110              'label': evetypes.GetName(planetTypeID),
    111              'getIcon': 1}))
    112 
    113         return scrolllist