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

recipeUtil.py (4398B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\inflight\itemTrader\recipeUtil.py
      2 from collections import defaultdict
      3 import eveicon
      4 import evetypes
      5 from carbonui import TextColor
      6 from carbonui.primitives.sprite import Sprite
      7 from carbonui.util.sortUtil import SortListOfTuples
      8 from eve.common.script.util.eveFormat import FmtISK
      9 from localization import GetByLabel
     10 import carbonui.const as uiconst
     11 
     12 def LoadRecipeTooltipPanel(tooltipPanel, recipe):
     13     tooltipPanel.LoadStandardSpacing()
     14     tooltipPanel.columns = 2
     15     displayName = recipe.displayName
     16     if displayName:
     17         tooltipPanel.AddTextBodyLabel(text=displayName, bold=True, colSpan=tooltipPanel.columns)
     18     tooltipPanel.AddTextBodyLabel(text=GetByLabel('UI/Inflight/SpaceComponents/ItemTrader/RequiredItems'), colSpan=tooltipPanel.columns)
     19     if recipe.inputIsk:
     20         Sprite(parent=tooltipPanel, align=uiconst.CENTERLEFT, pos=(0, 0, 20, 20), texturePath=eveicon.isk)
     21         tooltipPanel.AddTextDetailsLabel(text=FmtISK(recipe.inputIsk))
     22         tooltipPanel.FillRow()
     23     for typeID, quantity in recipe.inputItems.iteritems():
     24         typeIcon = Sprite(parent=tooltipPanel, align=uiconst.CENTERLEFT, pos=(0, 0, 20, 20))
     25         sm.GetService('photo').GetIconByType(typeIcon, typeID)
     26         tooltipPanel.AddTextDetailsLabel(text=str(quantity) + ' ' + evetypes.GetName(typeID))
     27         tooltipPanel.FillRow()
     28 
     29     tooltipPanel.AddTextBodyLabel(text=GetByLabel('UI/Inflight/SpaceComponents/ItemTrader/DeliveredItems'), colSpan=tooltipPanel.columns)
     30     for typeID, quantity in recipe.outputItems.iteritems():
     31         typeIcon = Sprite(parent=tooltipPanel, align=uiconst.CENTERLEFT, pos=(0, 0, 20, 20))
     32         sm.GetService('photo').GetIconByType(typeIcon, typeID)
     33         tooltipPanel.AddTextDetailsLabel(text=str(quantity) + ' ' + evetypes.GetName(typeID))
     34         tooltipPanel.FillRow()
     35 
     36 
     37 GROUP_SHIP_BLUEPRINTS = 'SHIP_BLUEPRINTS'
     38 GROUP_MODULES_AMMO = 'MODULES_AMMO'
     39 GROUP_SKINR = 'SKINR'
     40 GROUP_SKILLBOOKS = 'SKILLBOOKS'
     41 GROUP_DRONES = 'DRONES'
     42 GROUP_SKINS = 'SKINS'
     43 GROUP_BOOSTERS = 'BOOSTERS'
     44 GROUP_BACKGROUNDS = 'BACKGROUNDS'
     45 GROUP_MUTAPLASMIDS = 'MUTAPLASMIDS'
     46 _recipeGroupLabelPathByGroupID = {None: 'UI/Inflight/SpaceComponents/ItemTrader/GroupMisc',
     47  GROUP_SHIP_BLUEPRINTS: 'UI/Inflight/SpaceComponents/ItemTrader/GroupShipBlueprints',
     48  GROUP_MODULES_AMMO: 'UI/Inflight/SpaceComponents/ItemTrader/GroupModulesAndAmmoBlueprints',
     49  GROUP_SKINR: 'UI/Inflight/SpaceComponents/ItemTrader/GroupSkinrComponents',
     50  GROUP_SKILLBOOKS: 'UI/Inflight/SpaceComponents/ItemTrader/GroupSkillbooks',
     51  GROUP_DRONES: 'UI/Inflight/SpaceComponents/ItemTrader/GroupDrones',
     52  GROUP_SKINS: 'UI/Inflight/SpaceComponents/ItemTrader/GroupSkins',
     53  GROUP_BOOSTERS: 'UI/Inflight/SpaceComponents/ItemTrader/GroupBoosters',
     54  GROUP_BACKGROUNDS: 'UI/Inflight/SpaceComponents/ItemTrader/GroupBackgrounds',
     55  GROUP_MUTAPLASMIDS: 'UI/Inflight/SpaceComponents/ItemTrader/GroupMutaplasmids'}
     56 _recipeGroupTexturepathByGroupID = {GROUP_SHIP_BLUEPRINTS: eveicon.spaceship_command,
     57  GROUP_MODULES_AMMO: eveicon.gunnery,
     58  GROUP_SKINR: eveicon.skinr,
     59  GROUP_SKILLBOOKS: eveicon.skill_book,
     60  GROUP_DRONES: eveicon.drones,
     61  GROUP_SKINS: eveicon.skins,
     62  GROUP_BOOSTERS: eveicon.heal_first_aid,
     63  GROUP_BACKGROUNDS: eveicon.user,
     64  GROUP_MUTAPLASMIDS: eveicon.abyssal_deadspace}
     65 
     66 def GetRecipeGroupName(groupID):
     67     return GetByLabel(_recipeGroupLabelPathByGroupID.get(groupID, 'UI/Inflight/SpaceComponents/ItemTrader/GroupMisc'))
     68 
     69 
     70 def GetRecipeGroupTexturepath(groupID):
     71     return _recipeGroupTexturepathByGroupID.get(groupID)
     72 
     73 
     74 def GetSortedRecipeGroupsAndData(allRecipes):
     75     recipeDataByGroups = defaultdict(list)
     76     for recipe in allRecipes:
     77         name, sortValue = recipe.GetRecipeNameAndSortValue()
     78         data = {'recipe': recipe,
     79          'label': name,
     80          'sortValue': sortValue,
     81          'sublevel': 1,
     82          'line': 1,
     83          'labelColor': TextColor.SECONDARY}
     84         recipeDataByGroups[recipe.groupID].append(data)
     85 
     86     for recipeDataList in recipeDataByGroups.itervalues():
     87         recipeDataList.sort(key=lambda x: x['sortValue'])
     88 
     89     forSorting = []
     90     for groupID, recipeDataList in recipeDataByGroups.iteritems():
     91         groupName = GetRecipeGroupName(groupID)
     92         forSorting.append((groupName.lower(), (groupName, recipeDataList)))
     93 
     94     return SortListOfTuples(forSorting)