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

serviceCont.py (8346B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\fittingScreen\serviceCont.py
      2 import carbonui.const as uiconst
      3 import dogma.data as dogma_data
      4 import evetypes
      5 import inventorycommon.const as invConst
      6 from carbonui.primitives.container import Container
      7 from carbonui.primitives.sprite import Sprite
      8 from dogma.const import effectRigSlot
      9 from eve.client.script.ui.control.eveIcon import Icon
     10 from eve.client.script.ui.control.eveLabel import EveLabelMedium
     11 from eve.client.script.ui.inflight.shipModuleButton.moduleButtonTooltip import TooltipModuleWrapper
     12 from eve.client.script.ui.shared.fitting.baseSlot import FittingSlotBase
     13 from eve.client.script.ui.shared.fitting.fittingUtil import EatSignalChangingErrors, GetScaleFactor
     14 from eve.client.script.ui.shared.fitting.utilBtns import FittingUtilBtn
     15 from localization import GetByLabel
     16 from player_messaging.client.ui_message import prompt_player_fsd_dialog
     17 from signals.signalUtil import ChangeSignalConnect
     18 
     19 class FittingServiceSlot(FittingSlotBase):
     20     __guid__ = 'FittingServiceSlot'
     21     SLOT_SIZE = 48
     22     default_align = uiconst.BOTTOMLEFT
     23     default_height = SLOT_SIZE
     24     default_width = SLOT_SIZE
     25     isDragObject = True
     26     underlayTexturePath = 'res:/UI/Texture/classes/Fitting/stationServiceSlotFrame.png'
     27     slotPassiveTexturePath = 'res:/UI/Texture/classes/Fitting/slotPassive_Structure.png'
     28     slotActiveTexturePath = 'res:/UI/Texture/classes/Fitting/serviceSlotGlowOuter2.png'
     29 
     30     def ApplyAttributes(self, attributes):
     31         FittingSlotBase.ApplyAttributes(self, attributes)
     32         self.UpdateFitting()
     33 
     34     def ConstructFlagAndUnderlay(self):
     35         self.sr.underlay = Sprite(bgParent=self, name='underlay', state=uiconst.UI_DISABLED, padding=(0, 0, 0, 0), texturePath=self.underlayTexturePath)
     36         self.flagIcon = Icon(parent=self, name='flagIcon', align=uiconst.CENTER, state=uiconst.UI_DISABLED, width=self.width, height=self.height)
     37 
     38     def ConstructModuleSlotFill(self):
     39         if self.moduleSlotFill:
     40             return
     41         self.moduleSlotFill = Sprite(parent=self, name='moduleSlotFill', align=uiconst.TOALL, state=uiconst.UI_DISABLED, padding=(0, 0, 0, 0), texturePath=self.slotActiveTexturePath, color=(1, 1, 1, 0.5))
     42         self.moduleSlotFill.display = False
     43 
     44     def ConstructWarningFill(self):
     45         if self.warningFill and not self.warningFill.destroyed:
     46             return
     47         self.warningFill = Sprite(parent=self, name='moduleSlotFill', align=uiconst.TOALL, state=uiconst.UI_DISABLED, padding=(-4, -4, -4, -4), texturePath=self.slotPassiveTexturePath, color=(1.0, 0.35, 0.0))
     48         self.warningFill.display = False
     49 
     50     def ConstructSkillSprite(self):
     51         if self.skillSprite:
     52             return
     53         self.skillSprite = Sprite(parent=self, name='skillSprite', align=uiconst.TOALL, state=uiconst.UI_DISABLED, padding=(-8, -4, -8, -4), texturePath='res:/UI/Texture/classes/Fitting/slotGlowInner.png', color=(1, 1, 1, 0.5))
     54         self.skillSprite.display = False
     55 
     56     def UpdateFitting(self):
     57         if not self.controller.SlotExists() and not self.controller.GetModuleOrPreview():
     58             self.DisableSlot()
     59             return
     60         self.EnableSlot()
     61         self.SetDragState()
     62         self.PrepareUtilButtons()
     63         iconSize = int(self.SLOT_SIZE * GetScaleFactor())
     64         self.flagIcon.SetSize(iconSize, iconSize)
     65         if self.controller.GetModule() or self.controller.IsModulePreviewModule():
     66             moduleItem = self.controller.GetModuleOrPreview()
     67             self.flagIcon.LoadIconByTypeID(moduleItem.typeID, ignoreSize=True)
     68         else:
     69             slotIcon = 'res:/UI/Texture/classes/Fitting/stationServiceSlot.png'
     70             self.flagIcon.LoadIcon(slotIcon, ignoreSize=True)
     71         if self.controller.GetModule():
     72             self.tooltipPanelClassInfo = TooltipModuleWrapper()
     73             modulehint = evetypes.GetName(self.controller.GetModuleTypeID())
     74             if not self.controller.SlotExists():
     75                 modulehint = GetByLabel('UI/Fitting/SlotDoesNotExist')
     76             self.hint = modulehint
     77         else:
     78             self.tooltipPanelClassInfo = None
     79             self.hint = self._emptyHint
     80         if not self.hilitedFromMathing:
     81             self.Hilite(0)
     82         self.UpdateOnlineDisplay()
     83         self.UpdateStatusDisplay()
     84         self.UpdateGhostFittingIcons(self.controller.GetModule())
     85 
     86     def OnDropData(self, dragObj, nodes):
     87         self.controller.OnDropData(dragObj, nodes)
     88 
     89     def AddItem(self, item, sourceLocation = None):
     90         pass
     91 
     92     def OnClick(self, *args):
     93         return self.controller.OnClick(self)
     94 
     95     def OnMouseEnter(self, *args):
     96         if self.controller.GetModule() is not None:
     97             self.ShowUtilButtons()
     98             self.ShowCpuAndPowergrid()
     99         else:
    100             self.hint = self._emptyHint
    101             self.Hilite(1)
    102             prompt_player_fsd_dialog('ListEntryEnter')
    103 
    104     def OnMouseExit(self, *args):
    105         if not self.controller.GetModule():
    106             self.Hilite(0)
    107         self.HideCpuAndPowergrid()
    108 
    109     def PrepareUtilButtons(self):
    110         for btn in self.utilButtons:
    111             btn.Close()
    112 
    113         self.utilButtons = []
    114         if not self.controller.GetModule():
    115             return
    116         btns = self.GetUtilBtns()
    117         i = 0
    118         for btnData in btns:
    119             left = int(self.left + self.width / 2.0 - 8)
    120             top = self.height + 20 + i * 16
    121             utilBtn = FittingUtilBtn(parent=self.parent, icon=btnData.iconPath, left=left, top=top, btnData=btnData, mouseOverFunc=self.ShowUtilButtons, align=uiconst.BOTTOMLEFT, controller=self.controller)
    122             if btnData.onlineBtn == 1:
    123                 self.sr.onlineButton = utilBtn
    124             self.utilButtons.append(utilBtn)
    125             i += 1
    126 
    127     def GetUtilBtns(self):
    128         btns = []
    129         isRig = False
    130         for effect in dogma_data.get_type_effects(self.controller.GetModuleTypeID()):
    131             if effect.effectID == effectRigSlot:
    132                 isRig = True
    133                 break
    134 
    135         isOnlinable = self.controller.IsOnlineable()
    136         if isRig:
    137             btns += self.GetRigsBtns()
    138         else:
    139             btns = self.GetModuleBtns(isOnlinable)
    140         return btns
    141 
    142     def ShowCpuAndPowergrid(self):
    143         self.controller.GetCpuAndPowergridUsage()
    144 
    145     def HideCpuAndPowergrid(self):
    146         self.controller.HideCpuAndPowergridUsage()
    147 
    148 
    149 class FittingServiceCont(Container):
    150     SLOT_CLASS = FittingServiceSlot
    151     default_name = 'FittingServiceCont'
    152     default_height = 70
    153     default_width = 300
    154     default_align = uiconst.CENTERBOTTOM
    155     default_top = 4
    156 
    157     def ApplyAttributes(self, attributes):
    158         Container.ApplyAttributes(self, attributes)
    159         self.controller = attributes.controller
    160         self.slotsByFlagID = {}
    161         scaleFactor = GetScaleFactor()
    162         slotWidth = int(round(44.0 * scaleFactor))
    163         slotHeight = int(round(44.0 * scaleFactor))
    164         label = EveLabelMedium(parent=self, text=GetByLabel('UI/Fitting/StructureServices'), align=uiconst.TOBOTTOM)
    165         top = label.textheight + 2
    166         width = 0
    167         for i, flagID in enumerate(invConst.serviceSlotFlags):
    168             left = i * (slotWidth + 4)
    169             slot = self.SLOT_CLASS(name='%s' % flagID, parent=self, pos=(left,
    170              top,
    171              slotWidth,
    172              slotHeight), controller=self.controller.GetSlotController(flagID))
    173             self.slotsByFlagID[flagID] = slot
    174             width += slotWidth + 4
    175 
    176         self.width = width
    177         self.height = slotHeight + label.textheight + 100
    178         self.ChangeSignalConnection(connect=True)
    179 
    180     def ChangeSignalConnection(self, connect = True):
    181         signalAndCallback = [(self.controller.on_slots_with_menu_changed, self.OnSlotsWithMenuChanged)]
    182         ChangeSignalConnect(signalAndCallback, connect)
    183 
    184     def OnSlotsWithMenuChanged(self, oldFlagID, newFlagID):
    185         slot = self.slotsByFlagID.get(oldFlagID, None)
    186         if slot is not None:
    187             slot.HideUtilButtons()
    188 
    189     def GetSlotsByFlagID(self):
    190         return self.slotsByFlagID
    191 
    192     def Close(self):
    193         with EatSignalChangingErrors(errorMsg='FittingServiceCont'):
    194             self.ChangeSignalConnection(connect=False)
    195         self.controller = None
    196         Container.Close(self)