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

empireSelectionTechnology.py (6107B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\charactercreator\client\empireSelectionTechnology.py
      2 from carbonui.fontconst import EVE_MEDIUM_FONTSIZE, EVE_SMALL_FONTSIZE
      3 from eve.common.lib.appConst import raceAmarr, raceMinmatar, raceGallente, raceCaldari
      4 from eve.client.script.ui.util.uix import GetTextWidth
      5 from localization import GetByMessageID
      6 
      7 class TechnologyExample(object):
      8 
      9     def __init__(self, icons, titles, subtitles):
     10         self.icons = icons
     11         self.titles = titles
     12         self.subtitles = subtitles
     13 
     14     def GetTitle(self, raceID):
     15         return GetByMessageID(self.titles[raceID]).upper()
     16 
     17     def GetSubtitle(self, raceID):
     18         return GetByMessageID(self.subtitles[raceID])
     19 
     20     def GetIcon(self, raceID):
     21         return self.icons[raceID]
     22 
     23     def GetTextWidth(self, raceID):
     24         titleWidth = self._GetTitleWidth(raceID)
     25         subtitleWidth = self._GetSubtitleWidth(raceID)
     26         return max(titleWidth, subtitleWidth)
     27 
     28     def _GetTitleWidth(self, raceID):
     29         title = self.GetTitle(raceID)
     30         return GetTextWidth(title, EVE_MEDIUM_FONTSIZE)
     31 
     32     def _GetSubtitleWidth(self, raceID):
     33         subtitle = self.GetSubtitle(raceID)
     34         return GetTextWidth(subtitle, EVE_SMALL_FONTSIZE)
     35 
     36 
     37 class Technology(object):
     38 
     39     def __init__(self, title, iconTexture, mainTexts, mainViews, techExamples, techStepOrder):
     40         self.title = title
     41         self.iconTexture = iconTexture
     42         self.mainTexts = mainTexts
     43         self.mainViews = mainViews
     44         self.techExamples = techExamples
     45         self.techStepOrder = techStepOrder
     46 
     47     def GetTechTitle(self):
     48         return GetByMessageID(self.title).upper()
     49 
     50     def GetIconTexture(self):
     51         return self.iconTexture
     52 
     53     def GetTechStepOrder(self):
     54         return self.techStepOrder
     55 
     56     def GetMainText(self, raceID):
     57         return GetByMessageID(self.mainTexts[raceID])
     58 
     59     def GetMainView(self, raceID):
     60         return self.mainViews[raceID]
     61 
     62     def GetTechExample(self, order):
     63         return self.techExamples[order]
     64 
     65     def GetNumberOfExamples(self):
     66         return len(self.techExamples)
     67 
     68     def GetTechExamples(self):
     69         return self.techExamples.iteritems()
     70 
     71     def GetTitleWidth(self):
     72         title = self.GetTechTitle()
     73         return GetTextWidth(title, fontsize=EVE_MEDIUM_FONTSIZE, uppercase=1, hspace=1)
     74 
     75     def GetMaxTechExampleTitleWidth(self, raceID):
     76         maxWidth = 0
     77         for techExample in self.techExamples.values():
     78             textWidth = techExample.GetTextWidth(raceID)
     79             if textWidth > maxWidth:
     80                 maxWidth = textWidth
     81 
     82         return maxWidth
     83 
     84 
     85 class TechnologyData(object):
     86 
     87     def __init__(self, technologyStaticData):
     88         self.data = {}
     89         self._ReadTechnologies(technologyStaticData)
     90 
     91     def _ReadTechnologies(self, technologyStaticData):
     92         techsToDisplay = {}
     93         for techID, techData in technologyStaticData.iteritems():
     94             if techData.isDisplayed:
     95                 techsToDisplay[techData.order] = techID
     96 
     97         for techOrder, techStepOrder in enumerate(sorted(techsToDisplay.keys())):
     98             techID = techsToDisplay[techStepOrder]
     99             techData = technologyStaticData[techID]
    100             mainTexts = self._ReadMainTexts(techData)
    101             mainViews = self._ReadMainViews(techData)
    102             techExamples = self._ReadTechExamples(techData.examples)
    103             if techData.isDisplayed:
    104                 self.data[techOrder + 1] = Technology(title=techData.title, iconTexture=techData.icon, mainTexts=mainTexts, mainViews=mainViews, techExamples=techExamples, techStepOrder=techStepOrder)
    105 
    106     def _ReadMainTexts(self, techData):
    107         return {raceAmarr: getattr(techData, 'mainTextAmarr', None),
    108          raceCaldari: getattr(techData, 'mainTextCaldari', None),
    109          raceGallente: getattr(techData, 'mainTextGallente', None),
    110          raceMinmatar: getattr(techData, 'mainTextMinmatar', None)}
    111 
    112     def _ReadMainViews(self, techData):
    113         return {raceAmarr: getattr(techData, 'mainViewAmarr', None),
    114          raceCaldari: getattr(techData, 'mainViewCaldari', None),
    115          raceGallente: getattr(techData, 'mainViewGallente', None),
    116          raceMinmatar: getattr(techData, 'mainViewMinmatar', None)}
    117 
    118     def _ReadTechExamples(self, techExamplesData):
    119         techExamples = {}
    120         for techExampleID, techExampleData in techExamplesData.iteritems():
    121             titles = self._ReadTechExampleTitles(techExampleData)
    122             subtitles = self._ReadTechExampleSubtitles(techExampleData)
    123             icons = self._ReadTechExampleIcons(techExampleData)
    124             techExamples[techExampleID] = TechnologyExample(titles=titles, subtitles=subtitles, icons=icons)
    125 
    126         return techExamples
    127 
    128     def _ReadTechExampleTitles(self, techExampleData):
    129         return {raceAmarr: techExampleData.titleAmarr,
    130          raceCaldari: techExampleData.titleCaldari,
    131          raceGallente: techExampleData.titleGallente,
    132          raceMinmatar: techExampleData.titleMinmatar}
    133 
    134     def _ReadTechExampleSubtitles(self, techExampleData):
    135         return {raceAmarr: techExampleData.subtitleAmarr,
    136          raceCaldari: techExampleData.subtitleCaldari,
    137          raceGallente: techExampleData.subtitleGallente,
    138          raceMinmatar: techExampleData.subtitleMinmatar}
    139 
    140     def _ReadTechExampleIcons(self, techExampleData):
    141         return {raceAmarr: techExampleData.iconAmarr,
    142          raceCaldari: techExampleData.iconCaldari,
    143          raceGallente: techExampleData.iconGallente,
    144          raceMinmatar: techExampleData.iconMinmatar}
    145 
    146     def GetNumberOfTechs(self):
    147         return len(self.data)
    148 
    149     def GetFirstOrder(self):
    150         return min(self.data.keys())
    151 
    152     def GetTechnologies(self):
    153         return self.data.iteritems()
    154 
    155     def GetTech(self, order):
    156         return self.data[order]
    157 
    158     def GetMaxTechTitleWidth(self):
    159         maxWidth = 0
    160         for tech in self.data.values():
    161             textWidth = tech.GetTitleWidth()
    162             if textWidth > maxWidth:
    163                 maxWidth = textWidth
    164 
    165         return maxWidth