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

baseFitting.py (10486B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\fittingScreen\baseFitting.py
      2 import dogma.data as dogma_data
      3 from eve.client.script.ui.shared.fitting.fittingUtil import GetBaseShapeSize, GetTypeAttributesByID, FITKEYS, EatSignalChangingErrors, GetBaseShapeYOffset
      4 from eve.client.script.ui.shared.fittingScreen.fittingCenter import FittingCenter
      5 from eve.client.script.ui.shared.fitting.slotAdder import HardpointAdder
      6 from shipfitting.fittingWarnings import GetColorForLevel
      7 from signals.signalUtil import ChangeSignalConnect
      8 from shipfitting.fittingStuff import GetSlotTypeForType
      9 from localization import GetByLabel, GetByMessageID
     10 from carbonui.primitives.container import Container
     11 import carbonui.const as uiconst
     12 import dogma.const as dogmaConst
     13 from carbonui.uicore import uicore
     14 
     15 class FittingCont(Container):
     16     __notifyevents__ = ['OnStartSlotLinkingMode', 'OnResetSlotLinkingMode', 'OnSkillsChanged']
     17     __guid__ = 'baseFitting'
     18     default_width = 640
     19     default_height = 640
     20     default_align = uiconst.CENTER
     21     default_state = uiconst.UI_PICKCHILDREN
     22 
     23     def ApplyAttributes(self, attributes):
     24         Container.ApplyAttributes(self, attributes)
     25         sm.RegisterNotify(self)
     26         self.controller = attributes.controller
     27         self.isDelayedAnim = False
     28         self.menuSlots = {}
     29         self.lastAddition = (0.0, 0.0, 0.0)
     30         self.updateStatsThread = None
     31         self.updateStatsArgs = (None, None)
     32         self.slots = attributes.get('serviceSlots', {})
     33         self.controller.WaitForShip()
     34         self.SetSizeVariables()
     35         self.fittingCenter = FittingCenter(parent=self, idx=0, controller=self.controller, top=GetBaseShapeYOffset())
     36         self.slots.update(self.fittingCenter.GetSlots())
     37         self.AddTurretAndLauncherMarkers()
     38         self.UpdateStats()
     39         self.ChangeSignalConnection(connect=True)
     40         uicore.animations.FadeTo(self, 0.0, 1.0, duration=1.0)
     41 
     42     def ChangeSignalConnection(self, connect = True):
     43         signalAndCallback = [(self.controller.on_new_itemID, self.UpdateStats),
     44          (self.controller.on_stats_changed, self.UpdateStats),
     45          (self.controller.on_item_ghost_fitted, self.HiliteMatchingSlot),
     46          (self.controller.on_warning_display_changed, self.HiliteProblematicSlots)]
     47         ChangeSignalConnect(signalAndCallback, connect)
     48 
     49     def SetSizeVariables(self):
     50         baseShapeSize = GetBaseShapeSize()
     51         self.width = baseShapeSize
     52         self.height = baseShapeSize
     53         self.top = -35
     54 
     55     def AddTurretAndLauncherMarkers(self):
     56         cX = GetBaseShapeSize() / 2
     57         cY = GetBaseShapeSize() / 2 + GetBaseShapeYOffset()
     58         turretAdder = HardpointAdder(const.attributeTurretSlotsLeft, cX, cY, isleftSide=True)
     59         turretAdder.AddIcon(self, 'res:/UI/Texture/classes/Fitting/iconTurretHardpoint.png', self.LoadTooltipPanelForTurret)
     60         turretAdder.AddMarkers(self)
     61         self.turretSlots = turretAdder.slots
     62         launcherAdder = HardpointAdder(const.attributeLauncherSlotsLeft, cX, cY)
     63         launcherAdder.AddIcon(self, 'res:/UI/Texture/classes/Fitting/iconLauncherHardpoint.png', self.LoadTooltipPanelForLauncher)
     64         launcherAdder.AddMarkers(self)
     65         self.launcherSlots = launcherAdder.slots
     66 
     67     def LoadTooltipPanelForTurret(self, tooltipPanel, *args):
     68         turretsFitted = self.controller.GetNumTurretsFitted()
     69         turretSlotsLeft = self.controller.GetNumTurretHardpointsLeft()
     70         counterText = GetByLabel('Tooltips/FittingWindow/TurretHardPointBubbles_description', hardpointsUsed=int(turretsFitted), hardpointsTotal=int(turretsFitted + turretSlotsLeft))
     71         return self.LoadTooltipPanelForTurretsAndLaunchers(tooltipPanel, const.attributeTurretSlotsLeft, counterText)
     72 
     73     def LoadTooltipPanelForLauncher(self, tooltipPanel, *args):
     74         turretsFitted = self.controller.GetNumLaunchersFitted()
     75         turretSlotsLeft = self.controller.GetNumLauncherHardpointsLeft()
     76         counterText = GetByLabel('Tooltips/FittingWindow/LauncherHardPointBubbles_description', hardpointsUsed=int(turretsFitted), hardpointsTotal=int(turretsFitted + turretSlotsLeft))
     77         return self.LoadTooltipPanelForTurretsAndLaunchers(tooltipPanel, const.attributeLauncherSlotsLeft, counterText)
     78 
     79     def LoadTooltipPanelForTurretsAndLaunchers(self, tooltipPanel, attributeID, counterText):
     80         attribute = dogma_data.get_attribute(attributeID)
     81         headerText = GetByMessageID(attribute.tooltipTitleID)
     82         descriptionText = GetByMessageID(attribute.tooltipDescriptionID)
     83         tooltipPanel.LoadGeneric2ColumnTemplate()
     84         tooltipPanel.AddLabelMedium(text=headerText, bold=True)
     85         tooltipPanel.AddLabelMedium(text=counterText, bold=True, align=uiconst.TOPRIGHT, cellPadding=(20, 0, 0, 0))
     86         tooltipPanel.AddLabelMedium(text=descriptionText, wrapWidth=200, colSpan=tooltipPanel.columns, color=(0.6, 0.6, 0.6, 1))
     87 
     88     def ShowAddition(self, h, m, l):
     89         if (h, m, l) == self.lastAddition:
     90             return
     91         self.lastAddition = (h, m, l)
     92         numHi = self.controller.GetNumHiSlots()
     93         numMed = self.controller.GetNumMedSlots()
     94         numLow = self.controller.GetNumLowSlots()
     95         for i, totalslots in enumerate((numHi, numMed, numLow)):
     96             add = [h, m, l][i]
     97             modslots = add + totalslots
     98             for sidx in xrange(8):
     99                 flag = getattr(const, 'flag%sSlot%s' % (FITKEYS[i], sidx))
    100                 slot = self.slots[flag]
    101                 if sidx < modslots:
    102                     if sidx >= totalslots:
    103                         slot.ColorUnderlay((1.0, 1.0, 0.0))
    104                         slot.Hilite(1)
    105                         slot.opacity = 1.0
    106                     else:
    107                         slot.ColorUnderlay()
    108                         if slot.state == uiconst.UI_DISABLED:
    109                             slot.opacity = 0.25
    110                         else:
    111                             slot.opacity = 1.0
    112                 elif sidx >= totalslots:
    113                     slot.ColorUnderlay()
    114                     if slot.state == uiconst.UI_DISABLED:
    115                         slot.opacity = 0.25
    116                     else:
    117                         slot.opacity = 1.0
    118                 else:
    119                     slot.ColorUnderlay((1.0, 0.0, 0.0))
    120                     slot.Hilite(1)
    121                     slot.opacity = 1.0
    122 
    123     def OnStartSlotLinkingMode(self, typeID, *args):
    124         for flag, icon in self.slots.iteritems():
    125             if getattr(icon, 'module', None):
    126                 if icon.module.typeID != typeID:
    127                     if hasattr(icon, 'color'):
    128                         icon.linkDragging = 1
    129                         icon.opacity = 0.1
    130 
    131     def OnResetSlotLinkingMode(self, *args):
    132         for flag, icon in self.slots.iteritems():
    133             if getattr(icon, 'module', None):
    134                 if getattr(icon, 'linkDragging', None):
    135                     icon.linkDragging = 0
    136                     if hasattr(icon, 'color'):
    137                         icon.opacity = 1.0
    138 
    139     def HiliteMatchingSlot(self):
    140         hiliteSlotFlag = None
    141         powerType = None
    142         ghostTypeID = self.controller.GetPreviewFittedTypeID()
    143         if ghostTypeID:
    144             for attribute in dogma_data.get_type_attributes(ghostTypeID):
    145                 if attribute.attributeID == const.attributeSubSystemSlot:
    146                     hiliteSlotFlag = int(attribute.value)
    147                     break
    148 
    149             if hiliteSlotFlag is None:
    150                 if dogma_data.has_type_effects(ghostTypeID):
    151                     powerType = GetSlotTypeForType(ghostTypeID)
    152         for slot in self.slots.itervalues():
    153             slot.HiliteIfMatching(hiliteSlotFlag, powerType, ghostTypeID)
    154 
    155     def HiliteProblematicSlots(self, warningSlotDict):
    156         for slot in self.slots.itervalues():
    157             warningLevel = warningSlotDict.get(slot.controller.GetFlagID(), None)
    158             color = GetColorForLevel(warningLevel)
    159             slot.SetFittingWarningColor(color)
    160 
    161     def AddToSlotsWithMenu(self, slot):
    162         self.menuSlots[slot] = 1
    163 
    164     def ClearSlotsWithMenu(self):
    165         for slot in self.menuSlots.iterkeys():
    166             slot.HideUtilButtons()
    167             slot.HideCpuAndPowergrid()
    168 
    169         self.menuSlots = {}
    170 
    171     def UpdateStats(self, *args):
    172         if not self.controller.CurrentShipIsLoaded():
    173             return
    174         self.UpdateShipHardpoints()
    175         self.UpdateSlotAddition()
    176 
    177     def UpdateSlotAddition(self):
    178         typeID = self.controller.GetPreviewFittedTypeID()
    179         typeAttributesByID = GetTypeAttributesByID(typeID)
    180         lowSlotAddition, medSlotAddition, hiSlotAddition = self.controller.GetSlotAdditionInfo(typeAttributesByID)
    181         hiSlotAddition += typeAttributesByID.get(dogmaConst.attributeHiSlotModifier, 0.0)
    182         medSlotAddition += typeAttributesByID.get(dogmaConst.attributeMedSlotModifier, 0.0)
    183         lowSlotAddition += typeAttributesByID.get(dogmaConst.attributeLowSlotModifier, 0.0)
    184         self.ShowAddition(hiSlotAddition, medSlotAddition, lowSlotAddition)
    185 
    186     def UpdateShipHardpoints(self):
    187         typeID = self.controller.GetPreviewFittedTypeID()
    188         launchersFitted, turretsFitted = self.controller.GetNumTurretsAndLaunchersFitted()
    189         typeAttributesByID = GetTypeAttributesByID(typeID)
    190         turretAddition, launcherAddition = self.controller.GetHardpointAdditionInfo(typeAttributesByID)
    191         turretSlotsLeft = self.controller.dogmaLocation.GetAttributeValue(self.controller.GetItemID(), const.attributeTurretSlotsLeft)
    192         launcherSlotsLeft = self.controller.dogmaLocation.GetAttributeValue(self.controller.GetItemID(), const.attributeLauncherSlotsLeft)
    193         hardpointSlotInfo = [(self.turretSlots,
    194           turretSlotsLeft,
    195           turretsFitted,
    196           turretAddition,
    197           self.LoadTooltipPanelForTurret), (self.launcherSlots,
    198           launcherSlotsLeft,
    199           launchersFitted,
    200           launcherAddition,
    201           self.LoadTooltipPanelForLauncher)]
    202         for slotSet, slotsLeft, slotsFitted, slotsAddition, tooltipLoadFunc in hardpointSlotInfo:
    203             for i, slot in enumerate(slotSet):
    204                 slot.ModifyLook(i, slotsLeft, slotsFitted, slotsAddition)
    205                 slot.LoadTooltipPanel = tooltipLoadFunc
    206 
    207     def Close(self):
    208         with EatSignalChangingErrors(errorMsg='FittingGhost'):
    209             self.ChangeSignalConnection(connect=False)
    210         Container.Close(self)