rewardEntry.py (14454B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\loginRewards\rewardEntry.py 2 import evetypes 3 from carbon.common.script.sys.serviceConst import ROLE_GML, ROLE_WORLDMOD, ROLE_LEGIONEER 4 from carbonui import uiconst 5 from carbonui.primitives.container import Container 6 from carbonui.primitives.containerAutoSize import ContainerAutoSize 7 from carbonui.primitives.frame import Frame 8 from carbonui.primitives.sprite import Sprite 9 from carbonui.uianimations import animations 10 from clonegrade import COLOR_OMEGA_GOLD 11 from crates import CratesStaticData 12 from eve.client.script.ui.control.eveLabel import EveLabelMedium, EveLabelSmall 13 from eve.client.script.ui.eveColor import WHITE 14 from eve.client.script.ui.shared.loginRewards.rewardItem import RewardItem, OmegaRewardItem, TwoTrackRewardItem 15 from eve.client.script.ui.shared.loginRewards.rewardTooltip import LoadTooltipPanelForReward 16 from eve.client.script.ui.shared.loginRewards.rewardUiConst import BLUE_TEXT_COLOR, TODAYS_HEADER_FILL_COLOR 17 from eveservices.menu import GetMenuService 18 from inventorycommon.const import categoryBlueprint 19 from localization import GetByLabel 20 from loginrewards.client.tooltips import OmegaIconToolTip 21 from loginrewards.common.const import CLAIM_STATE_CLAIMED 22 from utillib import KeyVal 23 import mathext 24 COLOR_ITEM_TODAY_BG = (1.0, 1.0, 1.0, 0.1) 25 SEC_PER_PIXEL = 0.07 26 27 class RewardEntry(Container): 28 default_name = 'rewardEntry' 29 default_state = uiconst.UI_NORMAL 30 default_align = uiconst.TOPLEFT 31 rewardItemClass = RewardItem 32 33 def ApplyAttributes(self, attributes): 34 self.panelController = attributes.panelController 35 pConst = self.panelController.GetPanelConstants() 36 self.default_height = pConst.ENTRY_HEIGHT 37 self.default_width = pConst.ENTRY_WIDTH 38 self.isSelected = False 39 Container.ApplyAttributes(self, attributes) 40 self.rewardInfo = attributes.rewardInfo 41 self.entryCont = ContainerAutoSize(parent=self, align=uiconst.TOTOP) 42 self.rewardItemCont = self.rewardItemClass(parent=self, align=uiconst.TOTOP, rewardInfo=self.rewardInfo, panelController=self.panelController) 43 if session.charid: 44 self.GetMenu = self.GetMenuFunc 45 self.labelScrollingCont = AddLabel(self, self.panelController, self.rewardInfo) 46 47 def OnMouseEnter(self, *args): 48 self.labelScrollingCont.TriggerOnMouseEnterParent() 49 50 def OnMouseExit(self, *args): 51 self.labelScrollingCont.TriggerOnMouseExitParent() 52 53 def SetSelectedState(self, isOn, animateTime = 0): 54 self.isSelected = isOn 55 self.rewardItemCont.SetSelectedState(isOn, animateTime) 56 57 def UpdateEntryState(self, entryIdx, selectedIdx, updateKeyVal): 58 self.rewardItemCont.UpdateEntryState(entryIdx, selectedIdx, updateKeyVal) 59 60 def GetMenuFunc(self, *args): 61 typeID = self.rewardInfo.typeID 62 pConst = self.panelController.GetPanelConstants() 63 if not pConst.CRATES_HAVE_INFO and CratesStaticData().is_crate(typeID): 64 if session.role & (ROLE_GML | ROLE_WORLDMOD | ROLE_LEGIONEER): 65 return [('GM / WM Extras', ('isDynamic', GetMenuService().GetGMMenu, (None, 66 None, 67 None, 68 None, 69 None, 70 typeID)))] 71 return [] 72 if evetypes.GetCategoryID(typeID) == categoryBlueprint: 73 bpData = sm.GetService('blueprintSvc').GetBlueprintTypeCopy(typeID=typeID, runsRemaining=self.rewardInfo.qty, original=False) 74 abstractInfo = KeyVal(fullBlueprintData=bpData) 75 else: 76 abstractInfo = None 77 return GetMenuService().GetMenuFromItemIDTypeID(None, typeID, includeMarketDetails=True, abstractInfo=abstractInfo) 78 79 def LoadTooltipPanel(self, tooltipPanel, *args): 80 LoadTooltipPanelForReward(tooltipPanel, self.rewardInfo) 81 82 83 class RewardEntryWithTodayAndNextText(RewardEntry): 84 default_padRight = 8 85 86 def ApplyAttributes(self, attributes): 87 self._currentTextColor = None 88 RewardEntry.ApplyAttributes(self, attributes) 89 pConst = self.panelController.GetPanelConstants() 90 dayTextCont = Container(name='dayTextCont', parent=self.entryCont, align=uiconst.TOTOP, height=pConst.DAY_TEXT_BANNER_HEIGHT) 91 self.todayLabel = EveLabelMedium(parent=dayTextCont, align=uiconst.CENTER, text=GetByLabel('UI/LoginRewards/TodaysGift'), color=BLUE_TEXT_COLOR, padBottom=20) 92 self.todayLabel.fullOpacity = 1.0 93 self.nextLabel = EveLabelMedium(parent=dayTextCont, align=uiconst.CENTER, text=GetByLabel('UI/LoginRewards/NextGift'), color=BLUE_TEXT_COLOR, padBottom=20) 94 self.nextLabel.fullOpacity = 1.0 95 96 def SetSelectedState(self, isOn, animateTime = 0): 97 wasSelected = self.isSelected 98 if isOn and wasSelected: 99 return 100 RewardEntry.SetSelectedState(self, isOn, animateTime) 101 todayLabelOpacity, nextLabelOpacity = self.GetTodayAndNextLabelOpacity(isOn) 102 if animateTime and (isOn or wasSelected): 103 animations.FadeTo(self.todayLabel, self.todayLabel.opacity, todayLabelOpacity, duration=animateTime) 104 animations.FadeTo(self.nextLabel, self.nextLabel.opacity, nextLabelOpacity, duration=animateTime) 105 else: 106 self.todayLabel.opacity = todayLabelOpacity 107 self.nextLabel.opacity = nextLabelOpacity 108 109 def GetTodayAndNextLabelOpacity(self, isOn): 110 if not isOn: 111 return (0.0, 0.0) 112 elif self.panelController.CanSomethingBeClaimedNow(): 113 return (self.todayLabel.fullOpacity, 0.0) 114 else: 115 return (0.0, self.nextLabel.fullOpacity) 116 117 118 class RewardEntryWithDay(RewardEntry): 119 default_padRight = 6 120 121 def ApplyAttributes(self, attributes): 122 self._currentTextColor = None 123 RewardEntry.ApplyAttributes(self, attributes) 124 pConst = self.panelController.GetPanelConstants() 125 dayTextCont = Container(name='dayTextCont', parent=self.entryCont, align=uiconst.TOTOP, height=pConst.DAY_TEXT_BANNER_HEIGHT, padBottom=4) 126 text = self.GetTextForEntry() 127 self.dayLabel = EveLabelMedium(parent=dayTextCont, align=uiconst.CENTER, text=text, padBottom=20) 128 self.dayLabel.fullOpacity = 1.0 129 130 def GetTextForEntry(self, isOn = False): 131 pConst = self.panelController.GetPanelConstants() 132 if pConst.SHOW_DAY_NUM: 133 return GetByLabel('UI/LoginRewards/DayText', day=self.rewardInfo.day) 134 else: 135 return GetByLabel('UI/LoginRewards/TodaysGift') 136 137 def GetTextColor(self, isOn): 138 opacity = self.dayLabel.fullOpacity 139 if isOn: 140 textColor = BLUE_TEXT_COLOR 141 else: 142 textColor = (1, 1, 1) 143 if not self.panelController.GetPanelConstants().SHOW_DAY_NUM: 144 opacity = 0 145 else: 146 textColor = (1, 1, 1) 147 return textColor[:3] + (opacity,) 148 149 def SetSelectedState(self, isOn, animateTime = 0): 150 wasSelected = self.isSelected 151 if isOn and wasSelected: 152 return 153 RewardEntry.SetSelectedState(self, isOn, animateTime) 154 textColor = self.GetTextColor(isOn) 155 if animateTime and (isOn or wasSelected): 156 self.SetTextColor(textColor) 157 else: 158 self.dayLabel.SetTextColor(textColor) 159 160 def UpdateEntryState(self, entryIdx, selectedIdx, updateKeyVal): 161 RewardEntry.UpdateEntryState(self, entryIdx, selectedIdx, updateKeyVal) 162 claimedDays = updateKeyVal.claimedDays 163 isClaimed = entryIdx in claimedDays 164 availableRewardsDays = getattr(updateKeyVal, 'availableRewardsDays', None) 165 if isClaimed: 166 self.dayLabel.fullOpacity = 0.5 167 elif availableRewardsDays is not None: 168 itemCanStillBeClaimed = self.rewardInfo.day - 1 in availableRewardsDays 169 if not itemCanStillBeClaimed: 170 self.dayLabel.SetRGBA(0.5, 0.5, 0.5, 0.5) 171 172 def SetTextColor(self, newColor): 173 startValue = self.dayLabel.GetRGB()[:3] 174 opacity = newColor[3] 175 newColor = newColor[:3] 176 animations.MorphVector3(self, 'currentTextColor', startVal=startValue, endVal=newColor, curveType=uiconst.ANIM_SMOOTH, duration=0.5, callback=lambda : self.SetCurrentTextColor(newColor)) 177 animations.FadeTo(self.dayLabel, self.dayLabel.opacity, opacity, duration=0.5) 178 179 def SetCurrentTextColor(self, newColor): 180 self._currentBalance = newColor 181 if not self.destroyed: 182 newLabelColor = newColor + (self.dayLabel.fullOpacity,) 183 self.dayLabel.SetTextColor(newLabelColor) 184 185 def GetCurrentTextColor(self): 186 return self._currentTextColor 187 188 currentTextColor = property(GetCurrentTextColor, SetCurrentTextColor) 189 190 191 class AlphaRewardEntry(RewardEntry): 192 default_padRight = 4 193 rewardItemClass = TwoTrackRewardItem 194 195 196 class OmegaRewardEntry(RewardEntry): 197 default_padRight = 4 198 default_name = 'omgaRewardEntry' 199 rewardItemClass = OmegaRewardItem 200 201 def ApplyAttributes(self, attributes): 202 RewardEntry.ApplyAttributes(self, attributes) 203 pConst = self.panelController.GetPanelConstants() 204 self.omegaLockSprite = Sprite(name='omegaLockSprite', parent=self, texturePath='res:/UI/Texture/classes/LoginCampaign/chapter_Locked.png', pos=(0, 205 -pConst.DAY_HEIGHT + 24, 206 14, 207 18), align=uiconst.CENTERRIGHT, state=uiconst.UI_NORMAL, idx=0, opacity=0.75, color=COLOR_OMEGA_GOLD) 208 self.omegaLockSprite.display = False 209 self.omegaLockSprite.tooltipPanelClassInfo = OmegaIconToolTip(sm.GetService('loginCampaignService').open_vgs_to_buy_omega_time_from_DLI) 210 211 def UpdateEntryState(self, entryIdx, selectedIdx, updateKeyVal): 212 self.rewardItemCont.UpdateEntryState(entryIdx, selectedIdx, updateKeyVal) 213 availableRewardsDays = updateKeyVal.availableRewardsDays 214 itemCanStillBeClaimed = entryIdx in availableRewardsDays 215 pastReward = entryIdx < selectedIdx 216 self.SetOmegaState(itemCanStillBeClaimed, pastReward) 217 218 def SetOmegaState(self, itemCanStillBeClaimed, pastReward): 219 isClaimed = self.rewardInfo.claimState == CLAIM_STATE_CLAIMED 220 if self.panelController.IsOmega() or isClaimed: 221 self.omegaLockSprite.display = False 222 return 223 if not itemCanStillBeClaimed and not pastReward: 224 self.omegaLockSprite.display = False 225 else: 226 self.omegaLockSprite.display = True 227 228 229 class DayEntry(Container): 230 default_height = 30 231 default_width = 98 232 default_padRight = 4 233 default_align = uiconst.TOPLEFT 234 235 def ApplyAttributes(self, attributes): 236 self._currentTextColor = None 237 self.isSelected = False 238 Container.ApplyAttributes(self, attributes) 239 self.rewardInfo = attributes.rewardInfo 240 text = self.GetTextForEntry() 241 self.dayLabel = EveLabelMedium(parent=self, align=uiconst.CENTER, text=text) 242 self.dayLabel.fullOpacity = 1.0 243 244 def GetTextForEntry(self, isOn = False): 245 return GetByLabel('UI/LoginRewards/DayText', day=self.rewardInfo.day) 246 247 def GetTextColor(self, isOn): 248 opacity = self.dayLabel.fullOpacity 249 if isOn: 250 textColor = BLUE_TEXT_COLOR 251 else: 252 textColor = (1, 1, 1) 253 return textColor[:3] + (opacity,) 254 255 def SetDaySelectedState(self, isOn, animateTime = 0): 256 wasSelected = self.isSelected 257 if isOn and wasSelected: 258 return 259 textColor = self.GetTextColor(isOn) 260 if animateTime and (isOn or wasSelected): 261 self.SetTextColor(textColor) 262 else: 263 self.dayLabel.SetTextColor(textColor) 264 265 def SetTextColor(self, newColor): 266 startValue = self.dayLabel.GetRGB()[:3] 267 opacity = newColor[3] 268 newColor = newColor[:3] 269 animations.MorphVector3(self, 'currentTextColor', startVal=startValue, endVal=newColor, curveType=uiconst.ANIM_SMOOTH, duration=0.5, callback=lambda : self.SetCurrentTextColor(newColor)) 270 animations.FadeTo(self.dayLabel, self.dayLabel.opacity, opacity, duration=0.5) 271 272 def SetCurrentTextColor(self, newColor): 273 self._currentBalance = newColor 274 if not self.destroyed: 275 newLabelColor = newColor + (self.dayLabel.fullOpacity,) 276 self.dayLabel.SetTextColor(newLabelColor) 277 278 def GetCurrentTextColor(self): 279 return self._currentTextColor 280 281 currentTextColor = property(GetCurrentTextColor, SetCurrentTextColor) 282 283 def UpdateEntryState(self, entryIdx, selectedIdx, updateKeyVal): 284 claimedDays = updateKeyVal.claimedDays 285 isClaimed = entryIdx in claimedDays 286 if isClaimed: 287 self.dayLabel.fullOpacity = 0.5 288 289 290 def AddLabel(parent, panelController, rewardInfo): 291 labelCont = Container(name='labelCont', parent=parent, align=uiconst.TOALL, clipChildren=True, padding=(2, 4, 2, 4)) 292 return LabelScrollingCont(parent=labelCont, rewardInfo=rewardInfo, panelController=panelController, align=uiconst.TOTOP_NOPUSH, height=45) 293 294 295 class LabelScrollingCont(Container): 296 default_state = uiconst.UI_DISABLED 297 fadeHeight = 10 298 299 def ApplyAttributes(self, attributes): 300 self._currentFade = None 301 Container.ApplyAttributes(self, attributes) 302 rewardInfo = attributes.rewardInfo 303 panelController = attributes.panelController 304 pConst = panelController.GetPanelConstants() 305 text = '<center>%s</center>' % rewardInfo.GetRewardName() 306 w, h = EveLabelSmall.MeasureTextSize(text, width=pConst.ENTRY_WIDTH) 307 self.label = EveLabelSmall(parent=self, align=uiconst.TOTOP_NOPUSH, text=text, width=pConst.ENTRY_WIDTH, color=WHITE) 308 self.label.SetBottomAlphaFade(self.height, maxFadeHeight=self.fadeHeight) 309 310 def TriggerOnMouseEnterParent(self, *args): 311 diff = self.label.textheight - self.height 312 if diff <= 2: 313 return 314 duration = mathext.clamp(SEC_PER_PIXEL * diff, 0, 2.0) 315 animations.MorphScalar(self.label, 'padTop', self.label.padTop, -diff, duration=duration) 316 fadeEndValue = (self.label.textheight, self.fadeHeight) 317 self.label.SetBottomAlphaFade(*fadeEndValue) 318 319 def TriggerOnMouseExitParent(self, *args): 320 self.label.StopAnimations() 321 self.label.padTop = 0 322 self.label.SetBottomAlphaFade(self.height, self.fadeHeight)