omegaPurchaseContainer.py (10161B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\contextualOffers\client\UI\omegaOffer\omegaPurchaseContainer.py 2 from carbonui import uiconst, fontconst 3 from carbonui.primitives.gradientSprite import GradientSprite 4 from contextualOffers.client.UI.offerContentContainer import OfferContentContainer 5 from contextualOffers.client.UI.timeRemaining import TimeRemaining 6 from contextualOffers.client.UI.offerInfoTooltip import OfferInfoTooltip 7 from carbonui.primitives.container import Container 8 from carbonui.primitives.containerAutoSize import ContainerAutoSize 9 from carbonui.primitives.sprite import Sprite 10 from carbonui.primitives.frame import Frame 11 from eve.client.script.ui.control.eveLabel import Label 12 from eve.client.script.ui.control.infoIcon import MoreInfoIcon 13 from newFeatures.newFeatureNotifyButton import NewFeatureButton 14 from clonegrade.const import COLOR_OMEGA_GOLD 15 from carbonui.primitives.base import ReverseScaleDpi 16 from carbonui.primitives.base import ScaleDpi 17 from carbonui.uianimations import animations 18 from carbonui.uicore import uicore 19 import math 20 BLINK_DURATION = 8 21 BLINK_ROTATION = math.pi * 1.08 22 BLINK_END_POS = (20.0, 0.0) 23 BLINK_OPACITY = 0.8 24 END_OPACITY = 1.0 25 MOVE_AMOUNT = 20 26 MOVE_DURATION = 0.45 27 FADE_IN_DURATION = 0.6 28 FADE_OFFSET_DIFF = 0.15 29 OFFSET_INCREMENT = 0.14 30 INITIAL_OFFSET = 0 31 TOOLTIP_ICON_SIZE = 20 32 OFFERS_IDS_WITHOUT_GRADIENT = [1, 2] 33 OFFER_ID_HIDDEN_TIMER_THRESHOLD = 100000 34 35 class OmegaPurchaseContainer(OfferContentContainer): 36 default_name = 'omegaPurchaseContainer' 37 38 def ApplyAttributes(self, attributes): 39 OfferContentContainer.ApplyAttributes(self, attributes) 40 self.ConstructLayout() 41 self.ConstructText() 42 self.ConstructButtons() 43 self.ConstructGradient() 44 45 def ConstructLayout(self): 46 textLayer = Container(name='textLayer', parent=self, align=uiconst.TOALL) 47 self.topCont = Container(name='topRightCont', parent=textLayer, align=uiconst.CENTERTOP, height=25, width=self.width, padding=(20, 20, 20, 0), clipChildren=False, idx=0) 48 self.timerCont = Container(name='timerContainer', parent=textLayer, align=uiconst.TOPRIGHT, height=80, width=300, top=20, left=30, opacity=0) 49 self.timeRemaining = TimeRemaining(parent=self.timerCont) 50 self.priceContainer = Container(name='priceCont', parent=textLayer, padding=(30, 0, 30, 20), height=50, align=uiconst.TOBOTTOM) 51 self.descriptionCont = ContainerAutoSize(name='descriptionCont', parent=textLayer, padding=(30, 0, 20, 10), height=int(35 * fontconst.fontSizeFactor), opacity=0, align=uiconst.TOBOTTOM) 52 self.titleCont = Container(name='titleCont', parent=textLayer, padding=(30, 0, 20, 0), height=int(40 * fontconst.fontSizeFactor), opacity=0, align=uiconst.TOBOTTOM) 53 self.newPriceCont = ContainerAutoSize(name='newPriceCont', parent=self.priceContainer, opacity=0, align=uiconst.TOLEFT) 54 self.oldPriceCont = ContainerAutoSize(name='oldPriceCont', parent=self.priceContainer, padding=(10, 0, 0, 0), top=11, opacity=0, align=uiconst.TOLEFT) 55 self.discountCont = Container(name='discountCont', parent=self.topCont, align=uiconst.TOPLEFT, left=10, top=10, opacity=0, height=55, width=110) 56 57 def ConstructGradient(self): 58 gradientLayer = Container(name='gradientLayer', parent=self, align=uiconst.TOALL) 59 gradientContainer = Container(name='gradientContainer', parent=gradientLayer, align=uiconst.TOBOTTOM, height=200) 60 self.gradient = GradientSprite(name='gradient', bgParent=gradientContainer, state=uiconst.UI_HIDDEN, rgbData=((0, (0.0, 0.0, 0.0)),), alphaData=((0.0, 0.7), (0.8, 0.4), (1.0, 0.0)), rotation=math.pi / 2) 61 62 def ConstructText(self): 63 basic_text_color = (1, 1, 1, 1) 64 self.discountBackground = Frame(name='discountBackground', parent=self.discountCont, aling=uiconst.TOALL, texturePath='res:/UI/Texture/Shared/BracketBorderWindow/mask_Window770.png', cornerSize=12, color=(0.74, 0.008, 0.008, 1)) 65 self.discountFrame = Frame(name='discountFrame', parent=self.discountCont, align=uiconst.TOALL, texturePath='res:/UI/Texture/Shared/BracketBorderWindow/frame_Window.png', cornerSize=12, color=(0, 0, 0, 0.5), idx=0) 66 self.discountText = Label(name='discountText', parent=self.discountCont, align=uiconst.CENTER, fontsize=32, bold=True, color=basic_text_color, idx=0) 67 self.newPriceText = Label(name='newPriceText', parent=self.newPriceCont, fontsize=32, bold=True, color=COLOR_OMEGA_GOLD) 68 self.oldPriceText = Label(name='oldPriceText', parent=self.oldPriceCont, fontsize=20, bold=True, color=(0.5, 0.5, 0.5, 1)) 69 self.strikeThrough = Sprite(name='strikeThrough', parent=self.oldPriceCont, texturePath='res:/UI/Texture/Vgs/strikethrough.png', height=18, top=int(35 * fontconst.fontSizeFactor - 33), color=(0.5, 0.5, 0.5, 0.85)) 70 self.descriptionText = Label(name='descriptionText', parent=self.descriptionCont, fontsize=20, align=uiconst.TOTOP, color=basic_text_color) 71 self.titleText = Label(name='titleText', parent=self.titleCont, fontsize=32, bold=True, align=uiconst.TOLEFT, color=basic_text_color, maxLines=1) 72 self.infoIconCont = Container(name='infoIconCont', parent=self.titleCont, align=uiconst.TOLEFT, state=uiconst.UI_DISABLED, width=TOOLTIP_ICON_SIZE, opacity=0, top=8) 73 self.offerInfoIcon = MoreInfoIcon(name='offerInfoButton', parent=self.infoIconCont, align=uiconst.TOPRIGHT) 74 75 def ConstructButtons(self): 76 self.buyButtonCont = Container(name='buyButtonCont', parent=self.priceContainer, align=uiconst.BOTTOMRIGHT, left=10, top=10, height=42, width=150, opacity=0) 77 self.buyButton = NewFeatureButton(name='buyButton', parent=self.buyButtonCont, align=uiconst.TOALL, stretchTexturePath='res:/UI/Texture/Shared/BracketBorderWindow/button180yellow.png', hiliteTexturePath='res:/UI/Texture/Shared/BracketBorderWindow/button180.png', state=uiconst.UI_DISABLED, buttonColor=(1, 1, 1, 1), mouseLeaveColor=(1, 1, 1, 0), hoverColor=(1, 1, 1, 0.15), fillColor=(1, 1, 1, 0.5), onClick=self.OnButtonClick) 78 self.blinkSprite = Sprite(parent=self.buyButtonCont, name='blinkSprite', texturePath='res:/UI/Texture/Shared/BracketBorderWindow/button180blink.png', align=uiconst.TOALL, state=uiconst.UI_DISABLED, opacity=0, idx=0) 79 self.buyButtonText = Label(parent=self.buyButtonCont, align=uiconst.CENTER, state=uiconst.UI_DISABLED, fontsize=20, bold=True, color=(0, 0, 0, 1), idx=0) 80 81 def SetTitleText(self, title): 82 self.titleText.SetText(title) 83 availableWidth = ReverseScaleDpi(self.titleCont.displayWidth) 84 fullTextWidth = self.titleText.width 85 self.titleText.width = min(availableWidth - TOOLTIP_ICON_SIZE, fullTextWidth) 86 87 def LoadOffer(self, offerID, title, description, offerPrice, originalPrice, discount, buttonText, remainingText, tooltipHeader, tooltipDescription): 88 if discount: 89 self.discountCont.Show() 90 self.discountText.SetText(discount) 91 self.discountCont.SetSize(ReverseScaleDpi(self.discountText.actualTextWidth) + 32, ReverseScaleDpi(self.discountText.actualTextHeight) + 8) 92 else: 93 self.discountText.SetText('') 94 self.discountCont.Hide() 95 if offerID > OFFER_ID_HIDDEN_TIMER_THRESHOLD: 96 self.timerCont.Hide() 97 else: 98 self.timerCont.Show() 99 self.timeRemaining.SetRemainingText(remainingText) 100 self.SetTitleText(title) 101 self.descriptionText.SetText(description) 102 if tooltipHeader or tooltipDescription: 103 self.offerInfoIcon.Show() 104 self.offerInfoIcon.tooltipPanelClassInfo = OfferInfoTooltip(header=tooltipHeader, description=tooltipDescription, wrapWidth=400) 105 else: 106 self.offerInfoIcon.Hide() 107 self.newPriceText.SetText(offerPrice) 108 self.oldPriceText.SetText(originalPrice) 109 self.strikeThrough.width = self.oldPriceText.width 110 if buttonText: 111 self.buyButtonCont.Show() 112 self.buyButtonText.SetText(buttonText) 113 else: 114 self.buyButtonText.SetText('') 115 self.buyButtonCont.Hide() 116 if offerID not in OFFERS_IDS_WITHOUT_GRADIENT: 117 self.gradient.Show() 118 119 def OnTimerUpdated(self, time): 120 self.timeRemaining.UpdateTimeRemaining(time) 121 122 def AnimateIn(self): 123 self.FadeFromLeft() 124 self.FadeFromRight() 125 self.FadeIn() 126 127 def FadeFromLeft(self): 128 fadeFromLeft = [self.titleCont, 129 self.descriptionCont, 130 self.oldPriceCont, 131 self.newPriceCont] 132 offset = INITIAL_OFFSET 133 for obj in fadeFromLeft: 134 animations.FadeIn(obj=obj, endVal=END_OPACITY, duration=FADE_IN_DURATION, timeOffset=offset + FADE_OFFSET_DIFF) 135 animations.MoveInFromLeft(obj=obj, amount=MOVE_AMOUNT, duration=MOVE_DURATION, timeOffset=offset) 136 offset += OFFSET_INCREMENT 137 138 animations.FadeIn(obj=self.infoIconCont, endVal=END_OPACITY, duration=FADE_IN_DURATION, timeOffset=len(fadeFromLeft) * OFFSET_INCREMENT + INITIAL_OFFSET, callback=self.EnableInfoIcon) 139 140 def FadeFromRight(self): 141 animations.FadeIn(obj=self.timerCont, endVal=END_OPACITY, duration=FADE_IN_DURATION, timeOffset=INITIAL_OFFSET + FADE_OFFSET_DIFF) 142 animations.MoveInFromLeft(obj=self.timerCont, amount=MOVE_AMOUNT, duration=MOVE_DURATION, timeOffset=INITIAL_OFFSET) 143 144 def FadeIn(self): 145 animations.FadeIn(obj=self.buyButtonCont, endVal=END_OPACITY, duration=FADE_IN_DURATION, timeOffset=INITIAL_OFFSET + 0.5 + FADE_OFFSET_DIFF, callback=self.EnableBuyButton) 146 animations.FadeIn(obj=self.discountCont, endVal=END_OPACITY, duration=FADE_IN_DURATION, timeOffset=INITIAL_OFFSET + FADE_OFFSET_DIFF) 147 148 def EnableInfoIcon(self): 149 self.infoIconCont.SetState(uiconst.UI_NORMAL) 150 151 def EnableBuyButton(self): 152 self.buyButton.SetState(uiconst.UI_NORMAL) 153 uicore.animations.SpSwoopBlink(obj=self.blinkSprite, loops=uiconst.ANIM_REPEAT, endVal=BLINK_END_POS, rotation=BLINK_ROTATION, duration=BLINK_DURATION) 154 self.blinkSprite.opacity = BLINK_OPACITY