characterOverviewPanel.py (15235B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\neocom\charsheet\characterOverviewPanel\characterOverviewPanel.py 2 import eveformat.client 3 import expertSystems.client 4 import localization 5 from achievement_system.client.ui.chip.achievement_info import AchievementInfoChips 6 from carbon.common.script.util.format import FmtAmt 7 from carbon.common.script.util.timerstuff import AutoTimer 8 from carbonui import TextColor, uiconst 9 from carbonui.control.button import Button 10 from carbonui.primitives.container import Container 11 from carbonui.primitives.containerAutoSize import ContainerAutoSize 12 from carbonui.primitives.flowcontainer import FlowContainer 13 from carbonui.primitives.sprite import Sprite 14 from carbonui.primitives.fill import Fill 15 from carbonui.uianimations import animations 16 from carbonui.uicore import uicore 17 from characterdata.ancestries import get_ancestry_name 18 from characterdata.bloodlines import get_bloodline_name 19 from characterdata.races import get_race_name 20 from characterdata.schools import get_school_name 21 from eve.client.script.ui import eveColor 22 from eve.client.script.ui.control.eveIcon import LogoIcon, GetLogoIcon 23 from eve.client.script.ui.control.eveLabel import EveCaptionLarge, EveCaptionSmall 24 from eve.client.script.ui.shared.cloneGrade import ORIGIN_CHARACTERSHEET 25 from eve.client.script.ui.shared.cloneGrade.cloneStateIcon import CloneStateIcon 26 from eve.client.script.ui.shared.neocom.avatarHeaderPreview import AvatarHeaderPreview 27 from eve.common.lib import appConst 28 from eve.common.lib import appConst as const 29 import eve.client.script.ui.shared.pointerTool.pointerToolConst as pConst 30 from localization import GetByLabel 31 from playerprogression.ui.totalnetworthcontainer import TotalNetWorthProgressionContainer 32 from eve.client.script.ui.shared.neocom.charsheet.characterOverviewPanel.characterOverviewElements import AtWarIconAndLabel, CHAR_INFO_ELEMENT_HEIGHT, CharacterInfoElement, CharacterInfoHomeStation, CharacterInfoSecurityStatus, EmpireIcon, IconButtonCont 33 RIGHT_SIDE_PADDING = 22 34 LEFT_SIDE_PADDING = 32 35 BOTTOM_ICONS_PADDING = 22 36 BOTTOM_CONT_HEIGHT = 282 37 38 class CharacterSheetCharacterOverviewPanel(Container): 39 default_clipChildren = True 40 41 def ApplyAttributes(self, attributes): 42 Container.ApplyAttributes(self, attributes) 43 self.charMgr = sm.RemoteSvc('charMgr') 44 self.charsvc = sm.GetService('cc') 45 charinfo = self.charMgr.GetPublicInfo(session.charid) 46 self.uiCont = Container(parent=self, name='uiCont', align=uiconst.TOALL) 47 self.topCont = Container(parent=self.uiCont, name='topCont', align=uiconst.TOTOP_NOPUSH, height=200) 48 self.titleCont = None 49 self.titleLabelWrapper = None 50 self.titleLabel = None 51 self.ConstructTopCont(charinfo) 52 self.bottomCont = ContainerAutoSize(parent=self.uiCont, name='bottomCont', align=uiconst.TOBOTTOM, alignMode=uiconst.TOTOP) 53 self.ConstructBottomCont(charinfo) 54 self.centralCont = ContainerAutoSize(parent=self.uiCont, name='centralCont', align=uiconst.TOBOTTOM, alignMode=uiconst.TOTOP, padBottom=4) 55 self.ConstructCentralCont(attributes['toggleFunc']) 56 self.ConstructAvatarPreview() 57 self.UpdateToggleButton(attributes['isCharsheetExpanded'], animate=False) 58 59 def ConstructTopCont(self, charinfo): 60 self.windowNameCont = ContainerAutoSize(name='windowNameCont', parent=self.topCont, align=uiconst.TOPLEFT, minHeight=25, left=16, top=16) 61 EveCaptionSmall(parent=self.windowNameCont, text=GetByLabel('UI/CharacterSheet/CharacterSheetWindow/CharacterSheetCaption'), align=uiconst.CENTERLEFT, padding=(12, 0, 40, 0), color=TextColor.HIGHLIGHT) 62 iconsCont = ContainerAutoSize(parent=self.topCont, name='iconsCont', align=uiconst.TOPRIGHT, width=64, top=50, left=18) 63 EmpireIcon(parent=iconsCont, name='empireIcon', align=uiconst.TOTOP, empireID=session.raceID, width=64, height=64) 64 if sm.GetService('war').IsPlayerCurrentlyAtWarOrInFW(): 65 AtWarIconAndLabel(parent=iconsCont, align=uiconst.TOTOP, height=AtWarIconAndLabel.iconSize) 66 67 def SetExpanded(self, animate = False): 68 self.UpdateToggleButton(expanded=True, animate=animate) 69 if animate: 70 animations.FadeTo(self.windowNameCont, self.windowNameCont.opacity, 0.0, duration=0.4) 71 else: 72 self.windowNameCont.opacity = 0.0 73 74 def SetNotExpanded(self, animate = False): 75 self.UpdateToggleButton(expanded=False, animate=animate) 76 if animate: 77 animations.FadeTo(self.windowNameCont, self.windowNameCont.opacity, 1.0, duration=0.4) 78 else: 79 self.windowNameCont.opacity = 1.0 80 81 def GetRaceIconHint(self, charinfo): 82 if charinfo.ancestryID == appConst.ancestryUndefined: 83 charBackgroundInfo = GetByLabel('UI/CharacterSheet/CharacterSheetWindow/CharacterBackgroundInformationNoAncestry', raceName=get_race_name(charinfo.raceID), bloodlineName=get_bloodline_name(charinfo.bloodlineID), schoolName=get_school_name(charinfo.schoolID)) 84 else: 85 charBackgroundInfo = GetByLabel('UI/CharacterSheet/CharacterSheetWindow/CharacterBackgroundInformation', raceName=get_race_name(charinfo.raceID), bloodlineName=get_bloodline_name(charinfo.bloodlineID), ancestryName=get_ancestry_name(charinfo.ancestryID), schoolName=get_school_name(charinfo.schoolID)) 86 return charBackgroundInfo 87 88 def ConstructToggleBtn(self, container, toggleFunc): 89 self.toggleBtn = Button(parent=container, name='toggleBtn', align=uiconst.CENTERLEFT, iconSize=16, texturePath='res:/UI/Texture/Shared/DarkStyle/forward.png', func=toggleFunc, uniqueUiName=pConst.UNIQUE_NAME_EXPAND_CHARSHEET) 90 91 def UpdateToggleButton(self, expanded, animate = True): 92 if expanded: 93 self.toggleBtn.texturePath = 'res:/UI/Texture/Shared/DarkStyle/backward.png' 94 else: 95 self.toggleBtn.texturePath = 'res:/UI/Texture/Shared/DarkStyle/forward.png' 96 97 def ConstructCharacterInfo(self, charinfo): 98 self.ConstructCharacterInfoName(self.charInfoCont) 99 self.construct_achievement_info_chips() 100 self.construct_divider() 101 self.ConstructCharacterInfoBirthDate(charinfo, self.charInfoCont) 102 self.ConstructCharacterInfoTotalNetWorth(self.charInfoCont) 103 self.ConstructCharacterInfoSecurityStatus(self.charInfoCont) 104 self.ConstructCharacterInfoHomeStation(self.charInfoCont) 105 self.ConstructCharacterTotalSkillPoints(self.charInfoCont) 106 107 @staticmethod 108 def ConstructCharacterInfoName(container): 109 characterName = cfg.eveowners.Get(session.charid).name 110 characterLink = GetByLabel('UI/Contracts/ContractsWindow/ShowInfoLink', showInfoName=characterName, info=('showinfo', const.typeCharacter, session.charid)) 111 EveCaptionLarge(text=characterLink, parent=container, align=uiconst.TOTOP, state=uiconst.UI_NORMAL, padBottom=2) 112 113 def construct_achievement_info_chips(self): 114 self.achievement_info_chips = AchievementInfoChips(name='achievement_info_chips', parent=self.charInfoCont, align=uiconst.TOTOP, character_id=session.charid, padding=(0, 2, 0, 2)) 115 116 def construct_divider(self): 117 Fill(name='divider', parent=self.charInfoCont, align=uiconst.TOTOP, color=eveColor.WHITE, opacity=0.2, height=1, padding=(0, 4, 32, 4)) 118 119 @staticmethod 120 def ConstructCharacterInfoBirthDate(charinfo, container): 121 birthDate = localization.formatters.FormatDateTime(value=charinfo.createDateTime, dateFormat='short', timeFormat='short') 122 CharacterInfoElement(parent=container, name='birthdateCont', align=uiconst.TOTOP, height=CHAR_INFO_ELEMENT_HEIGHT, titleText=GetByLabel('UI/CharacterSheet/CharacterSheetWindow/BornTitle'), valueText=birthDate) 123 124 @staticmethod 125 def ConstructCharacterInfoTotalNetWorth(container): 126 TotalNetWorthProgressionContainer(parent=container, name='totalNetWorthCont', align=uiconst.TOTOP, height=CHAR_INFO_ELEMENT_HEIGHT) 127 128 @staticmethod 129 def ConstructCharacterInfoSecurityStatus(container): 130 securityStatus = sm.GetService('crimewatchSvc').GetMySecurityStatus() 131 roundedSecurityStatus = localization.formatters.FormatNumeric(securityStatus, decimalPlaces=1) 132 roundedSecurityStatus = roundedSecurityStatus.replace(',', '.') 133 whereAttacked = sm.GetService('crimewatchSvc').GetSecurityWhereAttacked() 134 secStatusTextList = [GetByLabel('UI/AgentFinder/SecurityStatus')] 135 if whereAttacked: 136 securityStatusText = eveformat.security_status(whereAttacked) 137 if whereAttacked == 1.0: 138 secStatusTextList += [GetByLabel('UI/CharacterSheet/CharacterSheetWindow/AttackedByEmpireFactionPolice2', securityStatus=securityStatusText)] 139 else: 140 secStatusTextList += [GetByLabel('UI/CharacterSheet/CharacterSheetWindow/AttackedByEmpireFactionPolice', securityStatus=securityStatusText)] 141 secStatusTooltip = '<br>'.join(secStatusTextList) 142 CharacterInfoSecurityStatus(parent=container, name='securityStatusCont', align=uiconst.TOTOP, height=CHAR_INFO_ELEMENT_HEIGHT, titleText=GetByLabel('UI/CharacterSheet/CharacterSheetWindow/SecurityStatusTitle'), valueText='%s' % roundedSecurityStatus, tooltip=secStatusTooltip) 143 144 @staticmethod 145 def ConstructCharacterInfoHomeStation(container): 146 CharacterInfoHomeStation(parent=container, name='homeStationCont', align=uiconst.TOTOP, height=CHAR_INFO_ELEMENT_HEIGHT, titleText=GetByLabel('UI/CharacterSheet/CharacterSheetWindow/HomeStationTitle'), valueText='', tooltip='') 147 148 def ConstructCharacterTotalSkillPoints(self, container): 149 element = CharacterInfoElement(parent=container, name='birthdateCont', align=uiconst.TOTOP, height=CHAR_INFO_ELEMENT_HEIGHT, titleText=GetByLabel('UI/CharacterSheet/TotalSkillPoints'), valueText='') 150 self._UpdateNumberOfSkillPoints(element.valueLabel) 151 self.updateSkillPointsThread = AutoTimer(2000, self._UpdateNumberOfSkillPointsThread, element.valueLabel) 152 153 def ConstructCentralCont(self, toggleFunc): 154 toggleBtnCont = ContainerAutoSize(name='toggleBtnCont', parent=self.centralCont, align=uiconst.TORIGHT, pos=(RIGHT_SIDE_PADDING, 155 0, 156 0, 157 50)) 158 self.ConstructToggleBtn(toggleBtnCont, toggleFunc) 159 serviceCont = FlowContainer(parent=self.centralCont, align=uiconst.TOTOP, contentSpacing=(0, 0), padLeft=LEFT_SIDE_PADDING - 5) 160 CloneStateIcon(parent=serviceCont, align=uiconst.NOALIGN, width=50, height=50, origin=ORIGIN_CHARACTERSHEET, left=5) 161 expertSystems.StateIcon(parent=serviceCont, align=uiconst.NOALIGN, width=50, height=50) 162 163 def ConstructBottomCont(self, charinfo): 164 self._charinfo = charinfo 165 Fill(bgParent=self.bottomCont, color=(0, 0, 0, 0.6)) 166 self.charInfoCont = ContainerAutoSize(parent=self.bottomCont, name='charInfoCont', align=uiconst.TOTOP, padding=(LEFT_SIDE_PADDING, 167 8, 168 0, 169 12)) 170 self.ConstructCharacterInfo(charinfo) 171 iconsButtonCont = Container(parent=self.bottomCont, align=uiconst.TOTOP, height=71) 172 bottomRightCont = Container(parent=iconsButtonCont, name='bottomRightCont', align=uiconst.BOTTOMRIGHT, width=202, height=71) 173 Button(parent=bottomRightCont, name='skillsBtn', align=uiconst.CENTERRIGHT, label=GetByLabel('UI/CharacterSheet/CharacterSheetWindow/SkillTabs/Skills'), left=RIGHT_SIDE_PADDING, func=self.OnSkillsBtnClicked) 174 bottomLeftCont = ContainerAutoSize(parent=iconsButtonCont, name='bottomLeftCont', align=uiconst.BOTTOMLEFT, pos=(BOTTOM_ICONS_PADDING, 175 BOTTOM_ICONS_PADDING, 176 0, 177 IconButtonCont.default_width)) 178 self.ConstructCorpIcon(bottomLeftCont) 179 if session.allianceid: 180 self.ConstructAllianceIcon(bottomLeftCont) 181 if session.warfactionid: 182 self.ConstructFactionalWarfareIcon(bottomLeftCont) 183 184 def ConstructFactionalWarfareIcon(self, container): 185 factionName = cfg.eveowners.Get(session.warfactionid).name 186 pirateIds = [500010, 500011] 187 if session.warfactionid in pirateIds: 188 func = uicore.cmd.OpenInsurgencyDashboard 189 else: 190 func = uicore.cmd.OpenMilitia 191 buttonCont = IconButtonCont(parent=container, func=func, padLeft=2, hint=GetByLabel('UI/CharacterSheet/CharacterSheetWindow/FactionalWarfare', factionName=factionName)) 192 LogoIcon(parent=buttonCont, state=uiconst.UI_DISABLED, align=uiconst.TOALL, itemID=session.warfactionid, ignoreSize=True) 193 194 def ConstructAllianceIcon(self, container): 195 buttonCont = IconButtonCont(parent=container, func=self.OnAllianceLogoClick, padLeft=2, hint=GetByLabel('UI/CharacterSheet/CharacterSheetWindow/Alliance', allianceName=cfg.eveowners.Get(session.allianceid).name)) 196 allianceIcon = Sprite(parent=buttonCont, state=uiconst.UI_DISABLED, align=uiconst.TOALL, ownerID=session.allianceid) 197 sm.GetService('photo').GetAllianceLogo(session.allianceid, 128, allianceIcon, orderIfMissing=True) 198 199 def ConstructCorpIcon(self, container): 200 corpName = cfg.eveowners.Get(session.corpid).name 201 buttonCont = IconButtonCont(parent=container, func=self.OnCorpIconClick, padLeft=2, hint=GetByLabel('UI/CharacterSheet/CharacterSheetWindow/Corporation', corpName=corpName)) 202 GetLogoIcon(parent=buttonCont, state=uiconst.UI_DISABLED, align=uiconst.TOALL, itemID=session.corpid, ignoreSize=True) 203 204 def OnCorpIconClick(self): 205 sm.GetService('info').ShowInfo(typeID=const.typeCorporation, itemID=session.corpid) 206 207 def OnAllianceLogoClick(self): 208 sm.GetService('info').ShowInfo(const.typeAlliance, itemID=session.allianceid) 209 210 def OnSkillsBtnClicked(self, *args): 211 from eve.client.script.ui.skillPlan.skillPlanDockablePanel import SkillPlanDockablePanel 212 SkillPlanDockablePanel.Open() 213 214 def ConstructAvatarPreview(self): 215 self.avatarHeaderPreview = AvatarHeaderPreview(parent=self, align=uiconst.TOALL, state=uiconst.UI_DISABLED) 216 bgCont = Container(name='bgCont', parent=self, state=uiconst.UI_DISABLED) 217 Sprite(parent=bgCont, align=uiconst.TOPLEFT, texturePath=self.GetBackground(), width=400, height=1180) 218 219 @staticmethod 220 def GetBackground(): 221 raceID = session.raceID 222 if raceID == appConst.raceMinmatar: 223 return 'res:/UI/Texture/classes/CharacterSheet/minmatar_bg.png' 224 if raceID == appConst.raceAmarr: 225 return 'res:/UI/Texture/classes/CharacterSheet/amarr_bg.png' 226 if raceID == appConst.raceGallente: 227 return 'res:/UI/Texture/classes/CharacterSheet/gallente_bg.png' 228 if raceID == appConst.raceCaldari: 229 return 'res:/UI/Texture/classes/CharacterSheet/caldari_bg.png' 230 231 def _UpdateNumberOfSkillPointsThread(self, label): 232 if self.destroyed: 233 self.updateSkillPointsThread = None 234 return 235 self._UpdateNumberOfSkillPoints(label) 236 237 def _UpdateNumberOfSkillPoints(self, label): 238 totalSkillPoints = sm.GetService('skillqueue').GetEstimatedTotalSkillPoints() 239 label.text = FmtAmt(totalSkillPoints) if totalSkillPoints else '-'