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

infoPanelResourceWars.py (4936B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\infoPanels\infoPanelResourceWars.py
      2 import carbonui.const as uiconst
      3 from carbonui.primitives.container import Container
      4 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      5 from eve.client.script.ui.shared.infoPanels.InfoPanelBase import InfoPanelBase
      6 from eve.client.script.ui.shared.infoPanels.const.infoPanelConst import PANEL_RESOURCE_WARS, MODE_NORMAL
      7 from localization import GetByLabel
      8 from resourcewars.client.const import RW_PANEL_ICON, RW_PANEL_TITLE_LABEL
      9 from resourcewars.client.rwinfopanelhaulertaskentry import RWInfoPanelHaulerTaskEntry
     10 from resourcewars.client.rwinfopanelorehauledtaskentry import RWInfoPanelOreHauledTaskEntry
     11 from resourcewars.client.rwinfopanelpiratetaskentry import RWInfoPanelPirateTaskEntry, PROGRESS_FRAME_CORNER_SIZE
     12 from resourcewars.client.rwinfopanelcountdowntimer import CountdownTimerLabel
     13 
     14 class InfoPanelResourceWars(InfoPanelBase):
     15     default_name = 'InfoPanelResourceWars'
     16     default_iconTexturePath = RW_PANEL_ICON
     17     default_state = uiconst.UI_PICKCHILDREN
     18     default_mode = MODE_NORMAL
     19     default_height = 120
     20     label = RW_PANEL_TITLE_LABEL
     21     hasSettings = False
     22     panelTypeID = PANEL_RESOURCE_WARS
     23     challengeContainer = None
     24     __notifyevents__ = ['OnHaulerEnteredInClient',
     25      'OnHaulerFullInClient',
     26      'OnRWPirateDestroyedInClient',
     27      'OnRWTimerStartedInClient']
     28 
     29     def ApplyAttributes(self, attributes):
     30         InfoPanelBase.ApplyAttributes(self, attributes)
     31         self.rwService = sm.GetService('rwService')
     32         self.michelle = sm.GetService('michelle')
     33         self.ballpark = self.michelle.GetBallpark()
     34         self.haulerTaskEntries = {}
     35         self.titleLabel = self.headerCls(name='title', text=GetByLabel(self.label), parent=self.headerCont, align=uiconst.CENTERLEFT, state=uiconst.UI_DISABLED)
     36         deadline = self.rwService.get_deadline()
     37         criticalTime = self.rwService.get_critical_time()
     38         self.timerPadContainer = Container(name='rwCountdownTimerPadContainer', parent=self.headerCont, padRight=PROGRESS_FRAME_CORNER_SIZE)
     39         self.countdownTimer = CountdownTimerLabel(name='rwCountdownTimer', parent=self.timerPadContainer, align=uiconst.BOTTOMRIGHT, deadline=deadline, criticalTime=criticalTime, rwService=self.rwService, state=uiconst.UI_NORMAL)
     40         self.countdownTimer.hint = GetByLabel('UI/ResourceWars/TimerHint')
     41         self.haulerContainer = None
     42         self._ConstructHaulerContainer()
     43         self._ConstructHaulerDetails()
     44         sm.RegisterNotify(self)
     45 
     46     def OnRWTimerStartedInClient(self, deadline, criticalTime):
     47         self.countdownTimer.InitiateCountdown(deadline, criticalTime)
     48 
     49     @staticmethod
     50     def IsAvailable():
     51         return sm.GetService('rwService').is_in_rw_dungeon()
     52 
     53     def _ConstructHaulerContainer(self):
     54         if not self.haulerContainer or self.haulerContainer.destroyed:
     55             self.mainCont.Flush()
     56             self.haulerContainer = ContainerAutoSize(parent=self.mainCont, name='haulerContainer', align=uiconst.TOTOP)
     57 
     58     def _ConstructHaulerDetails(self):
     59         haulersPresent = self.rwService.get_haulers_present()
     60         haulerProgress = self.rwService.get_hauler_progress()
     61         siteTarget = self.rwService.get_site_target()
     62         self.oreHauledTaskEntry = RWInfoPanelOreHauledTaskEntry(name='OreHauledTaskEntry', parent=self.haulerContainer, align=uiconst.TOTOP, progress=self.rwService.get_site_progress(), target=siteTarget)
     63         for haulerID, haulerProgress in haulerProgress.iteritems():
     64             if haulerID in haulersPresent:
     65                 self._ConstructHaulerEntry(haulerID, haulerProgress)
     66 
     67         self.pirateEntry = RWInfoPanelPirateTaskEntry(name='PirateTaskEntry', parent=self.haulerContainer, align=uiconst.TOTOP, progress=self.rwService.get_pirates_killed())
     68 
     69     def OnHaulerEnteredInClient(self, haulerID, haulerProgress):
     70         self._ConstructHaulerEntry(haulerID, haulerProgress)
     71 
     72     def _ConstructHaulerEntry(self, haulerID, haulerProgress):
     73         if haulerID in self.haulerTaskEntries:
     74             return
     75         haulerTaskEnty = RWInfoPanelHaulerTaskEntry(name='haulerTaskEntry', parent=self.haulerContainer, align=uiconst.TOTOP, haulerID=haulerID, haulerProgress=haulerProgress, ballpark=self.ballpark)
     76         self.haulerTaskEntries[haulerID] = haulerTaskEnty
     77         if hasattr(self, 'pirateEntry'):
     78             self.pirateEntry.SetOrder(-1)
     79 
     80     def OnRWPirateDestroyedInClient(self, pirateKillCount):
     81         if hasattr(self, 'pirateEntry'):
     82             self.pirateEntry.register_progress(pirateKillCount)
     83 
     84     def OnHaulerFullInClient(self, haulerID):
     85         haulerTaskEntry = self.haulerTaskEntries.pop(haulerID, None)
     86         if haulerTaskEntry is not None:
     87             oreSaved = haulerTaskEntry.get_capacity()
     88             self.oreHauledTaskEntry.register_progress(oreSaved)