purchaseView.py (5606B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\vgs\views\purchaseView.py 2 import logging 3 from carbonui import const as uiconst 4 from carbonui.primitives.container import Container 5 from carbonui.primitives.containerAutoSize import ContainerAutoSize 6 from carbonui.primitives.sprite import Sprite 7 from carbonui.primitives.transform import Transform 8 from carbonui.uianimations import animations 9 from eve.client.script.ui.control.eveLabel import Label 10 from gametime import SEC 11 from localization import GetByLabel 12 log = logging.getLogger(__name__) 13 MINIMUM_PROGRESS_DISPLAY_TIME = 1.2 * SEC 14 15 class BasePanel(Container): 16 default_align = uiconst.TOLEFT 17 default_opacity = 0.0 18 TRANSITION_TIME = 0.5 19 20 def AnimEntry(self): 21 animations.FadeIn(self, duration=self.TRANSITION_TIME, timeOffset=self.TRANSITION_TIME) 22 23 def AnimExit(self): 24 animations.FadeOut(self, duration=self.TRANSITION_TIME) 25 26 27 class PurchaseSuccessPanel(BasePanel): 28 ICON_FOREGROUND = 'res:/UI/Texture/vgs/purchase_success_fg.png' 29 ICON_BACKGROUND = 'res:/UI/Texture/vgs/purchase_success_bg.png' 30 AUDIO_EVENT = 'store_purchase_success' 31 ICON_WIDTH = 72 32 ICON_HEIGHT = 64 33 ICON_HEIGHT_TRANSFORM = 78 34 PADDING_ICON_LEFT = 10 35 PADDING_ICON_TO_TEXT = 20 36 PADDING_TOP_TO_TEXT = 12 37 PADDING_TEXT_TO_SUBTEXT = 12 38 FONTSIZE_TEXT = 14 39 FONTSIZE_SUBTEXT = 12 40 default_name = 'PurchaseSuccessPanel' 41 default_text = 'UI/VirtualGoodsStore/Purchase/Completed' 42 default_subtext = 'UI/VirtualGoodsStore/Purchase/NewPurchaseInstruction' 43 44 def ApplyAttributes(self, attributes): 45 super(PurchaseSuccessPanel, self).ApplyAttributes(attributes) 46 default_text = GetByLabel(self.default_text) 47 default_subtext = GetByLabel(self.default_subtext) if self.default_subtext is not None else None 48 self.text = attributes.pop('text', default_text) 49 self.subtext = attributes.pop('subText', default_subtext) 50 self.subtext_time_offset = attributes.get('subTextTimeOffset', 2) 51 self._add_icon() 52 self._add_text() 53 54 def _add_icon(self): 55 icon_container = Container(name='icon_container', parent=self, align=uiconst.TOLEFT, width=self.ICON_WIDTH, padLeft=self.PADDING_ICON_LEFT) 56 self.icon_foreground_transform = Transform(name='icon_foreground_transform', parent=icon_container, align=uiconst.CENTERTOP, width=self.ICON_WIDTH, height=self.ICON_HEIGHT_TRANSFORM, scalingCenter=(0.5, 0.5)) 57 self.icon_foreground = Sprite(name='icon_foreground_sprite', parent=self.icon_foreground_transform, align=uiconst.CENTER, state=uiconst.UI_DISABLED, texturePath=self.ICON_FOREGROUND, width=self.ICON_WIDTH, height=self.ICON_HEIGHT, opacity=0) 58 self.icon_background_transform = Transform(name='icon_background_transform', parent=icon_container, align=uiconst.CENTERTOP, width=self.ICON_WIDTH, height=self.ICON_HEIGHT_TRANSFORM, scalingCenter=(0.5, 0.5)) 59 self.icon_background = Sprite(name='icon_background', parent=self.icon_background_transform, align=uiconst.CENTER, state=uiconst.UI_DISABLED, texturePath=self.ICON_BACKGROUND, width=self.ICON_WIDTH, height=self.ICON_HEIGHT, opacity=0) 60 61 def _add_text(self): 62 text_container = Container(name='text_container', parent=self, align=uiconst.TOALL, padLeft=self.PADDING_ICON_TO_TEXT, padTop=self.PADDING_TOP_TO_TEXT) 63 text_width = self.width - self.PADDING_ICON_LEFT - self.ICON_WIDTH - self.PADDING_ICON_TO_TEXT 64 label_container = ContainerAutoSize(name='label_container', parent=text_container, align=uiconst.TOTOP) 65 Label(name='label', parent=label_container, align=uiconst.CENTER, text=self.text, bold=True, fontsize=self.FONTSIZE_TEXT, width=text_width) 66 if self.subtext: 67 self.subtext_container = ContainerAutoSize(name='subtext_container', parent=text_container, align=uiconst.TOTOP, top=self.PADDING_TEXT_TO_SUBTEXT, opacity=0) 68 Label(name='subtext_label', parent=self.subtext_container, align=uiconst.CENTER, text=self.subtext, fontsize=self.FONTSIZE_SUBTEXT, width=text_width) 69 70 def AnimEntry(self): 71 super(PurchaseSuccessPanel, self).AnimEntry() 72 sm.GetService('audio').SendUIEvent(self.AUDIO_EVENT) 73 animations.FadeIn(self.icon_background, duration=0.5, timeOffset=self.TRANSITION_TIME) 74 animations.FadeIn(self.icon_foreground, duration=0.5, timeOffset=self.TRANSITION_TIME + 0.5) 75 animations.Tr2DScaleTo(self.icon_background_transform, startScale=(2.0, 2.0), endScale=(1.0, 1.0), duration=0.25, timeOffset=self.TRANSITION_TIME) 76 animations.Tr2DScaleTo(self.icon_foreground_transform, startScale=(2.0, 2.0), endScale=(1.0, 1.0), duration=0.25, timeOffset=self.TRANSITION_TIME + 0.5) 77 if hasattr(self, 'subtext_container'): 78 animations.FadeTo(self.subtext_container, timeOffset=self.subtext_time_offset) 79 80 81 class PurchaseFailedPanel(PurchaseSuccessPanel): 82 ICON_FOREGROUND = 'res:/UI/Texture/vgs/purchase_fail_fg.png' 83 ICON_BACKGROUND = 'res:/UI/Texture/vgs/purchase_fail_bg.png' 84 AUDIO_EVENT = 'store_purchase_failure' 85 default_text = 'UI/VirtualGoodsStore/Purchase/Failed' 86 default_subtext = None 87 88 89 class ConfirmPurchasePanel(PurchaseSuccessPanel): 90 ICON_FOREGROUND = 'res:/UI/Texture/WindowIcons/attention.png' 91 ICON_BACKGROUND = 'res:/UI/Texture/Vgs/loading-track.png' 92 AUDIO_EVENT = 'store_purchase_failure' 93 default_text = 'UI/VirtualGoodsStore/Purchase/ConfirmationRequired' 94 default_subtext = 'UI/VirtualGoodsStore/Purchase/ConfirmationInstructions'