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

personal.py (6692B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\theatersOfWar\landingPage\personal.py
      2 import eveicon
      3 from carbonui import Align, TextColor
      4 from carbonui.primitives.container import Container
      5 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      6 from carbonui.primitives.layoutGrid import LayoutGrid
      7 from carbonui.text.styles import TextHeader, TextDetail, TextBody
      8 from eve.client.script.ui.control import eveIcon
      9 from eve.client.script.ui.shared.theatersOfWar.landingPage.landingPageWidgets import WidgetContWithContent
     10 import eve.common.lib.appConst as appConst
     11 from localization import GetByLabel
     12 
     13 class PersonalCont(WidgetContWithContent):
     14     default_iconsSize = 160
     15 
     16     def ApplyAttributes(self, attributes):
     17         self.iconSize = attributes.get('iconSize', self.default_iconsSize)
     18         self.personal_controller = PersonalController()
     19         super(PersonalCont, self).ApplyAttributes(attributes)
     20 
     21     def construct_ui(self):
     22         super(PersonalCont, self).construct_ui()
     23         self.set_header(GetByLabel('UI/TheatersOfWar/PersonalProgress'))
     24         self.construct_content()
     25         self.construct_portrait_container()
     26 
     27     def construct_content(self):
     28         self.current_rank_header_label = TextDetail(name='current_rank_header_label', parent=self.content_cont, align=Align.TOTOP, text=GetByLabel('UI/TheatersOfWar/PersonalCurrentFwRank'), color=TextColor.SECONDARY)
     29         self.current_rank_label = TextHeader(name='current_rank_label', parent=self.content_cont, align=Align.TOTOP, text=' ', color=TextColor.HIGHLIGHT)
     30         c = ContainerAutoSize(parent=self.content_cont, align=Align.TOTOP)
     31         self.stats_grid = LayoutGrid(parent=c, columns=2, cellSpacing=(16, 0), top=8)
     32         self.stats_grid.Hide()
     33         TextDetail(parent=self.stats_grid, align=Align.CENTERLEFT, text=GetByLabel('UI/TheatersOfWar/PersonalVictoryPoints'), color=TextColor.SECONDARY)
     34         TextDetail(parent=self.stats_grid, align=Align.CENTERLEFT, text=GetByLabel('UI/TheatersOfWar/PersonalFwKills'), color=TextColor.SECONDARY)
     35         self.vp_label = TextBody(parent=self.stats_grid, align=Align.CENTERLEFT, text=' ', color=TextColor.HIGHLIGHT)
     36         self.num_kills_label = TextBody(parent=self.stats_grid, align=Align.CENTERLEFT, text=' ', color=TextColor.HIGHLIGHT)
     37         self.explanation_label = TextBody(parent=self.content_cont, align=Align.TOTOP, text=' ', top=16)
     38         self.explanation_label.Hide()
     39 
     40     def construct_portrait_container(self):
     41         self.content_cont.minHeight = self.iconSize
     42         left_cont = Container(name='left_cont', parent=self.content_cont, align=Align.TOLEFT, width=self.iconSize / 2, idx=0, clipChildren=True, padRight=16)
     43         self.portrait_container = Container(name='portrait_container', parent=left_cont, pos=(0,
     44          0,
     45          self.iconSize,
     46          self.iconSize), align=Align.CENTER)
     47 
     48     def load(self):
     49         rank_text = self.personal_controller.get_current_rank_text()
     50         self.current_rank_label.SetText(rank_text)
     51         if self.personal_controller.is_in_factional_warfare():
     52             vp_text = self.personal_controller.get_num_victory_points_text()
     53             self.vp_label.SetText(vp_text)
     54             num_kills_text = self.personal_controller.get_num_kills_text()
     55             self.num_kills_label.SetText(num_kills_text)
     56             self.stats_grid.Show()
     57             self.explanation_label.Hide()
     58         else:
     59             self.stats_grid.Hide()
     60             self.explanation_label.Show()
     61             self.explanation_label.SetText(self.personal_controller.get_explanation_text())
     62         self.set_footer_left(self.personal_controller.get_footer_text())
     63         self.set_footer_left_icon(self.personal_controller.get_footer_texture_path())
     64         self.load_portrait()
     65 
     66     def load_portrait(self):
     67         eveIcon.GetOwnerLogo(parent=self.portrait_container, ownerID=session.charid, size=self.iconSize, noServerCall=True)
     68 
     69 
     70 class PersonalController(object):
     71 
     72     def __init__(self):
     73         self.fac_war_svc = sm.GetService('facwar')
     74         super(PersonalController, self).__init__()
     75 
     76     def get_footer_text(self):
     77         if self.is_enlisted_with_pirates() or self.is_in_factional_warfare():
     78             faction_name = cfg.eveowners.Get(session.warfactionid).name
     79             return GetByLabel('UI/TheatersOfWar/PersonalEnlistedWith', factionName=faction_name)
     80         return GetByLabel('UI/TheatersOfWar/PersonalUnenlisted')
     81 
     82     def get_footer_texture_path(self):
     83         if self.is_enlisted_with_pirates():
     84             return eveicon.pirate_insurgencies
     85         if self.is_in_factional_warfare():
     86             return eveicon.factional_warfare
     87 
     88     def is_enlisted_with_pirates(self):
     89         if session.warfactionid in appConst.factionsPirates:
     90             return True
     91         return False
     92 
     93     def is_in_factional_warfare(self):
     94         if session.warfactionid in appConst.factionsEmpires:
     95             return True
     96         return False
     97 
     98     def get_current_rank(self):
     99         if not self.is_in_factional_warfare():
    100             return None
    101         currentRankObject = self.fac_war_svc.GetCharacterRankInfo(session.charid)
    102         return currentRankObject.currentRank
    103 
    104     def get_current_rank_text(self):
    105         rank = self.get_current_rank()
    106         if rank is None:
    107             return GetByLabel('UI/TheatersOfWar/PersonalNoRankAvailable')
    108         rankName, _ = self.fac_war_svc.GetRankLabel(session.warfactionid, rank)
    109         return rankName
    110 
    111     def get_current_rank_description(self):
    112         rank = self.get_current_rank()
    113         if rank is None:
    114             return
    115         _, rankDescription = self.fac_war_svc.GetRankLabel(session.warfactionid, rank)
    116         return rankDescription
    117 
    118     def get_num_kills_text(self):
    119         num_kills = self._get_num_kills()
    120         if num_kills is None:
    121             return '-'
    122         return num_kills
    123 
    124     def _get_num_kills(self):
    125         if not self.is_in_factional_warfare():
    126             return None
    127         stats = self.fac_war_svc.GetStats_Character()
    128         kills_last_week = stats['killsLW']
    129         return kills_last_week
    130 
    131     def get_num_victory_points_text(self):
    132         vp = self._get_num_victory_points()
    133         if vp is None:
    134             return '-'
    135         return vp
    136 
    137     def _get_num_victory_points(self):
    138         if not self.is_in_factional_warfare():
    139             return None
    140         stats = self.fac_war_svc.GetStats_Character()
    141         vp_last_week = stats['vpLW']
    142         return vp_last_week
    143 
    144     def get_explanation_text(self):
    145         if self.is_in_factional_warfare():
    146             return
    147         return GetByLabel('UI/TheatersOfWar/PersonalStatsOnlyForFW')