pickOffer.py (3583B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\vgs\views\pickOffer.py 2 from carbonui import const as uiconst 3 from carbonui.control.scrollContainer import ScrollContainer 4 from carbonui.primitives.container import Container 5 from carbonui.primitives.containerAutoSize import ContainerAutoSize 6 from carbonui.primitives.fill import Fill 7 from carbonui.uianimations import animations 8 from vgs.client.currency import OFFER_CURRENCY_PLEX 9 from eve.client.script.ui.shared.vgs.label import VgsHeaderLarge, VgsHeaderMedium, VgsLabelSmall 10 from eve.client.script.ui.shared.vgs.offer import Offer, OfferProductList 11 import localization 12 13 class PickOfferView(Container): 14 PADDING = 10 15 16 def ApplyAttributes(self, attributes): 17 super(PickOfferView, self).ApplyAttributes(attributes) 18 self.offers = attributes.offers 19 self.onPick = attributes.get('onPick', None) 20 self.Layout() 21 22 def Layout(self): 23 scroll = ScrollContainer(parent=self, align=uiconst.TOALL, pushContent=False) 24 VgsHeaderLarge(parent=scroll, align=uiconst.TOTOP, padding=(self.PADDING, 25 self.PADDING, 26 self.PADDING, 27 0), text=localization.GetByLabel('UI/VirtualGoodsStore/Purchase/ChooseOffer')) 28 VgsLabelSmall(parent=scroll, align=uiconst.TOTOP, padding=(self.PADDING, 29 0, 30 self.PADDING, 31 self.PADDING), text=localization.GetByLabel('UI/VirtualGoodsStore/Purchase/ChooseOfferSubtext')) 32 sortedOffers = self._SortOffers(self.offers) 33 for offer in sortedOffers: 34 OfferEntry(parent=scroll, align=uiconst.TOTOP, padding=(self.PADDING, 35 0, 36 self.PADDING, 37 self.PADDING), offer=offer, onClick=lambda offer = offer: self.PickOffer(offer)) 38 39 def _SortOffers(self, offers): 40 41 def sortKey(offer): 42 plexPrice = 0 43 for pricing in offer.offerPricings: 44 if pricing.currency == OFFER_CURRENCY_PLEX: 45 plexPrice = pricing.price 46 47 return (offer.label is not None, plexPrice, offer.name) 48 49 return sorted(offers, key=sortKey, reverse=True) 50 51 def PickOffer(self, offer): 52 if callable(self.onPick): 53 self.onPick(offer) 54 55 56 class OfferEntryImage(Offer): 57 default_showDescription = False 58 default_showPrice = True 59 default_showImage = True 60 TITLE_FONT_CLASS = VgsHeaderMedium 61 RIBBON_ALIGN = uiconst.TOPRIGHT 62 63 64 class OfferEntry(ContainerAutoSize): 65 default_state = uiconst.UI_NORMAL 66 BACKGROUND_COLOR = (0.1, 0.1, 0.1, 1.0) 67 PADDING = 8 68 69 def ApplyAttributes(self, attributes): 70 super(OfferEntry, self).ApplyAttributes(attributes) 71 self.offer = attributes.offer 72 self.onClick = attributes.onClick 73 Fill(bgParent=self, color=self.BACKGROUND_COLOR) 74 self.bannerOffer = OfferEntryImage(parent=self, align=uiconst.TOTOP, height=160, padBottom=self.PADDING, offer=self.offer) 75 OfferProductList(parent=self, align=uiconst.TOTOP, padding=(self.PADDING, 76 0, 77 self.PADDING, 78 self.PADDING), iconSize=32, products=self.offer.productQuantities.values()) 79 80 def OnMouseEnter(self, *args): 81 animations.Tr2DScaleTo(self.bannerOffer.imageLayer, startScale=self.bannerOffer.imageLayer.scale, endScale=(1.04, 1.04), duration=0.05) 82 83 def OnMouseExit(self, *args): 84 animations.Tr2DScaleTo(self.bannerOffer.imageLayer, self.bannerOffer.imageLayer.scale, endScale=(1.0, 1.0), duration=0.2) 85 86 def OnClick(self, *args): 87 self.onClick()