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

planetWindow.py (5205B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\planet\planetWindow.py
      2 import blue
      3 from carbon.common.script.util.format import FmtDate
      4 from carbon.common.script.util.timerstuff import AutoTimer
      5 from carbonui.primitives.container import Container
      6 from eve.client.script.ui.control.entries.util import GetFromClass
      7 from eve.client.script.ui.control.eveScroll import Scroll
      8 from carbonui.control.window import Window
      9 from carbonui.control.tabGroup import TabGroup
     10 from eve.client.script.ui.shared.neocom.journal import PlanetaryInteractionLaunchEntry
     11 from eve.client.script.ui.shared.planet.planetsWindow.coloniesPanel import ColoniesPanel
     12 from eve.common.lib import appConst as const
     13 from localization import GetByLabel
     14 from localization.formatters.timeIntervalFormatters import FormatTimeIntervalShortWritten
     15 
     16 class PlanetWindow(Window):
     17     __guid__ = 'form.PlanetWindow'
     18     __notifyevents__ = ['OnPILaunchesChange']
     19     default_width = 500
     20     default_height = 500
     21     default_minSize = (300, 400)
     22     default_windowID = 'planetWindow'
     23     default_analyticID = 'pi_planet_window'
     24     default_captionLabelPath = 'UI/InfoWindow/TabNames/PlanetaryProduction'
     25     default_descriptionLabelPath = 'UI/ScienceAndIndustry/PlanetaryColoniesDesc'
     26     default_caption = GetByLabel('UI/InfoWindow/TabNames/PlanetaryProduction')
     27     default_iconNum = 'res:/UI/Texture/WindowIcons/planets.png'
     28     default_isCompactable = True
     29 
     30     def ApplyAttributes(self, attributes):
     31         Window.ApplyAttributes(self, attributes)
     32         self.ReconstructWindow()
     33 
     34     def ReconstructWindow(self):
     35         self.sr.main.Flush()
     36         coloniesPanel = ColoniesPanel(parent=self.sr.main, isCompact=self.IsCompact())
     37         launches = self.GetLaunches()
     38         if launches:
     39             launchesPanel = LaunchesPanel(parent=self.sr.main)
     40             TabGroup(name='myTabGroup', parent=self.sr.main, groupID='MyTabGroupID', idx=0, tabs=((GetByLabel('UI/ScienceAndIndustry/ScienceAndIndustryWindow/Colonies'),
     41               coloniesPanel,
     42               self,
     43               'colonies'), (GetByLabel('UI/ScienceAndIndustry/ScienceAndIndustryWindow/Launches'),
     44               launchesPanel,
     45               self,
     46               'launchesPanel')))
     47         else:
     48             coloniesPanel.LoadPlanetScroll()
     49 
     50     def GetLaunches(self, reload = False):
     51         return sm.GetService('planetUI').GetLaunches(force=reload)
     52 
     53     def OnPILaunchesChange(self):
     54         self.GetLaunches(reload=True)
     55         self.ReconstructWindow()
     56 
     57     def OnCompactModeEnabled(self):
     58         super(PlanetWindow, self).OnCompactModeEnabled()
     59         self.ReconstructWindow()
     60 
     61     def OnCompactModeDisabled(self):
     62         super(PlanetWindow, self).OnCompactModeDisabled()
     63         self.ReconstructWindow()
     64 
     65 
     66 class LaunchesPanel(Container):
     67     default_name = 'LaunchesPanel'
     68 
     69     def ApplyAttributes(self, attributes):
     70         Container.ApplyAttributes(self, attributes)
     71         self.scroll = Scroll(parent=self)
     72         self.scroll.sr.id = 'launchesScroll'
     73 
     74     def OnTabSelect(self):
     75         self.UpdateScroll()
     76 
     77     def UpdateScroll(self, reload = 0):
     78         launchsRowSet = sm.GetService('planetUI').GetLaunches(force=reload)
     79         scrolllist = []
     80         for launch in launchsRowSet:
     81             label = '<t>'.join(['    ',
     82              cfg.evelocations.Get(launch.solarSystemID).name,
     83              cfg.evelocations.Get(launch.planetID).name,
     84              FmtDate(launch.launchTime)])
     85             expired = not blue.os.GetWallclockTime() - launch.launchTime < const.piLaunchOrbitDecayTime
     86             scrolllist.append(GetFromClass(PlanetaryInteractionLaunchEntry, {'id': launch.launchID,
     87              'label': label,
     88              'callback': None,
     89              'selected': 0,
     90              'expired': expired,
     91              'rec': launch}))
     92 
     93         self.scroll.Load(contentList=scrolllist, headers=[GetByLabel('UI/Journal/JournalWindow/PI/HeaderReentry'),
     94          GetByLabel('UI/Journal/JournalWindow/PI/HeaderSolarSystem'),
     95          GetByLabel('UI/Journal/JournalWindow/PI/HeaderPlanet'),
     96          GetByLabel('UI/Journal/JournalWindow/PI/HeaderLaunchTime')], noContentHint=GetByLabel('UI/Journal/JournalWindow/PI/NoActiveLaunches'))
     97         self.AutoUpdateLaunchDecayTimes()
     98         self.sr.launchtimer = AutoTimer(1000, self.AutoUpdateLaunchDecayTimes)
     99 
    100     def AutoUpdateLaunchDecayTimes(self):
    101         if self.destroyed:
    102             self.sr.launchtimer = None
    103             return
    104         for entry in self.scroll.GetNodes():
    105             text = entry.label
    106             if not entry.rec:
    107                 continue
    108             expiryNumeric = blue.os.GetWallclockTime() - entry.rec.launchTime
    109             if expiryNumeric < const.piLaunchOrbitDecayTime:
    110                 expiryLabel = '<color=0xFFFFFF00>' + FormatTimeIntervalShortWritten(const.piLaunchOrbitDecayTime - expiryNumeric) + '</color>'
    111             else:
    112                 expiryLabel = '<color=0xffeb3700>' + GetByLabel('UI/Journal/JournalWindow/PI/BurnedUp') + '</color>'
    113                 entry.expired = True
    114             entry.label = expiryLabel + text[text.find('<t>'):]
    115             if entry.panel:
    116                 entry.panel.Load(entry)