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

groupAllIcon.py (4542B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\inflight\shipHud\groupAllIcon.py
      2 from carbon.client.script.environment.AudioUtil import PlaySound
      3 from carbonui.control.buttonIcon import ButtonIcon
      4 import carbonui.const as uiconst
      5 from carbonui.primitives.container import Container
      6 from localization import GetByLabel
      7 import uthread
      8 import blue
      9 import eve.client.script.ui.shared.pointerTool.pointerToolConst as pConst
     10 from carbonui.loggers.buttonLogger import log_button_clicked
     11 
     12 class GroupAllIcon(ButtonIcon):
     13     default_left = 0
     14     default_top = 0
     15     default_width = 16
     16     default_height = 16
     17     default_state = uiconst.UI_HIDDEN
     18     default_icon = 'ui_73_16_251'
     19     default_name = 'groupAllIcon'
     20 
     21     def ApplyAttributes(self, attributes):
     22         ButtonIcon.ApplyAttributes(self, attributes)
     23         self.orgPos = self.top
     24 
     25     def OnClick(self, *args):
     26         if settings.user.ui.Get('lockModules', 0):
     27             return
     28         self.analyticID = pConst.UNIQUE_NAME_GROUP_WEAPONS
     29         log_button_clicked(self)
     30         PlaySound(uiconst.SOUND_BUTTON_CLICK)
     31         dogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation()
     32         if dogmaLocation.CanGroupAll(session.shipid):
     33             dogmaLocation.LinkAllWeapons(session.shipid)
     34         else:
     35             dogmaLocation.UnlinkAllWeapons(session.shipid)
     36 
     37 
     38 class GroupAllButton(Container):
     39     __notifyevents__ = ['OnAttributes', 'OnRefreshModuleBanks']
     40     default_left = 0
     41     default_top = 9
     42     default_width = 16
     43     default_height = 16
     44     default_name = 'GroupAllButton'
     45     default_align = uiconst.TOPLEFT
     46     groupAllITexturePath = 'res:/UI/Texture/Icons/73_16_252.png'
     47     ungroupAllTexturePath = 'res:/UI/Texture/Icons/73_16_251.png'
     48     groupAllLabelPath = 'UI/Inflight/GroupAllWeapons'
     49     ungroupAllLabelPath = 'UI/Inflight/UngroupAllWeapons'
     50     lockeLabelPath = 'UI/Inflight/Locked'
     51     uniqueUiName = pConst.UNIQUE_NAME_GROUP_WEAPONS
     52 
     53     def ApplyAttributes(self, attributes):
     54         self.updateGroupAllButtonThread = None
     55         Container.ApplyAttributes(self, attributes)
     56         self.groupAllIcon = GroupAllIcon(parent=self, idx=0, width=self.width, height=self.height)
     57         sm.RegisterNotify(self)
     58         self.CheckGroupAllButton()
     59 
     60     def CheckGroupAllButton(self):
     61         if self.destroyed:
     62             return
     63         icon = self.groupAllIcon
     64         if icon is None or icon.destroyed:
     65             return
     66         dogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation()
     67         for typeID, qty in dogmaLocation.GetGroupableTypes(session.shipid).iteritems():
     68             if qty > 1:
     69                 break
     70         else:
     71             icon.state = uiconst.UI_HIDDEN
     72             return
     73 
     74         icon.state = uiconst.UI_NORMAL
     75         if dogmaLocation.CanGroupAll(session.shipid):
     76             texturePath = self.groupAllITexturePath
     77             hintPath = self.groupAllLabelPath
     78         else:
     79             texturePath = self.ungroupAllTexturePath
     80             hintPath = self.ungroupAllLabelPath
     81         icon.SetTexturePath(texturePath)
     82         hint = GetByLabel(hintPath)
     83         if settings.user.ui.Get('lockModules', False):
     84             hint = GetByLabel(self.lockeLabelPath, unit=hint)
     85         icon.hint = hint
     86         if getattr(self, 'updateGroupAllButtonThread', None):
     87             self.updateGroupAllButtonThread.kill()
     88         self.updateGroupAllButtonThread = uthread.new(self.UpdateGroupAllButton)
     89 
     90     def UpdateGroupAllButton(self):
     91         if self.destroyed:
     92             return
     93         GetOpacity = sm.GetService('clientDogmaIM').GetDogmaLocation().GetGroupAllOpacity
     94         if sm.GetService('clientDogmaIM').GetDogmaLocation().CanGroupAll(session.shipid):
     95             attributeName = 'lastGroupAllRequest'
     96         else:
     97             attributeName = 'lastUngroupAllRequest'
     98         icon = self.groupAllIcon
     99         if icon is None or icon.destroyed:
    100             return
    101         icon.state = uiconst.UI_DISABLED
    102         while True:
    103             opacity = GetOpacity(attributeName)
    104             if opacity > 0.999:
    105                 break
    106             self.opacity = 0.2 + opacity * 0.6
    107             blue.pyos.synchro.Yield()
    108             if self.destroyed:
    109                 return
    110 
    111         self.opacity = 1.0
    112         icon.state = uiconst.UI_NORMAL
    113 
    114     def OnAttributes(self, ch):
    115         for each in ch:
    116             if each[0] == 'isOnline':
    117                 self.CheckGroupAllButton()
    118                 break
    119 
    120     def OnRefreshModuleBanks(self):
    121         self.CheckGroupAllButton()