vgsDetailProduct.py (4384B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\view\aurumstore\vgsDetailProduct.py 2 from carbonui import const as uiconst 3 from carbonui.control.singlelineedits.singleLineEditInteger import SingleLineEditInteger 4 from carbonui.fontconst import STYLE_HEADER 5 from carbonui.primitives.container import Container 6 from carbonui.primitives.sprite import Sprite 7 from carbonui.util.color import Color 8 from eve.client.script.ui.control.eveLabel import Label 9 from eve.client.script.ui.util.uiComponents import Component, ButtonEffect 10 from eve.client.script.ui.view.aurumstore.shared.const import QUANTITY_MIN, QUANTITY_MAX 11 from eve.client.script.ui.view.aurumstore.vgsOffer import GetPreviewType 12 from eve.common.script.sys.eveCfg import IsPreviewable 13 from localization import GetByLabel 14 import trinity 15 PRICE_LABEL_COLOR = (1.0, 1.0, 1.0, 1.2) 16 17 @Component(ButtonEffect(bgElementFunc=lambda self, _: self.highlight, opacityHover=0.1, opacityMouseDown=0.4, audioOnEntry=uiconst.SOUND_ENTRY_HOVER, audioOnClick=uiconst.SOUND_ENTRY_SELECT)) 18 19 class VgsDetailProduct(Container): 20 default_height = 36 21 22 def ApplyAttributes(self, attributes): 23 super(VgsDetailProduct, self).ApplyAttributes(attributes) 24 self.name = attributes.name 25 self.quantity = attributes.quantity 26 self.price = attributes.price 27 self.typeID = attributes.typeID 28 self.onClick = attributes.onClick 29 self.isSinglePurchase = attributes.isSinglePurchase 30 self.showQuantity = attributes.get('showQuantity', True) 31 self.showPrice = attributes.get('showPrice', True) 32 self.onQuantityChangeCallback = attributes.get('onQuantityChangeCallback') 33 self.text = GetByLabel('UI/VirtualGoodsStore/ItemNameAndQuantity', itemName=self.name, quantity=self.quantity) 34 self.BuildHoverHighlight() 35 self.BuildPrice() 36 self.BuildQuantityEditor() 37 self.BuildProductName() 38 self.BuildCursor() 39 40 def BuildHoverHighlight(self): 41 self.highlight = Sprite(name='hoverGradient', bgParent=self, texturePath='res:/UI/Texture/Vgs/store-button-gradient2.png', color=(0.2, 0.7, 1.0)) 42 43 def BuildPrice(self): 44 if self.showPrice: 45 priceContainer = Container(name='priceContainer', parent=self, align=uiconst.TORIGHT, width=120, state=uiconst.UI_DISABLED) 46 Label(name='price', parent=priceContainer, align=uiconst.CENTERRIGHT, text=GetByLabel('UI/PlexVault/PlexBalance', amount=self.price), fontsize=16) 47 48 def BuildQuantityEditor(self): 49 if self.showQuantity: 50 quantityEditorContainer = Container(name='quantityEditorContainer', parent=self, align=uiconst.TORIGHT, width=64) 51 self.quantityEdit = SingleLineEditInteger(parent=quantityEditorContainer, minValue=QUANTITY_MIN, maxValue=QUANTITY_MAX, fontsize=16, fontStyle=STYLE_HEADER, bold=True, width=56, height=24, top=0, padLeft=8, align=uiconst.CENTERLEFT, bgColor=Color.GRAY7, arrowIconColor=(0.0, 0.0, 0.0, 1.0), arrowIconGlowColor=(0.2, 0.2, 0.2, 1.0), arrowIconClass=Sprite, arrowIconBlendMode=trinity.TR2_SBM_BLEND, arrowUseThemeColor=False, caretColor=(0.0, 0.0, 0.0, 0.75), selectColor=(0.0, 0.0, 0.0, 0.25), fontcolor=(0.0, 0.0, 0.0, 1.0), OnChange=self.onQuantityChangeCallback, maxLength=2, hint=GetByLabel('UI/Common/Quantity'), state=uiconst.UI_NORMAL) 52 if self.isSinglePurchase: 53 self.quantityEdit.Disable() 54 self.quantityEdit.underlay.Hide() 55 56 def BuildProductName(self): 57 productNameContainer = Container(name='productNameContainer', parent=self, align=uiconst.TOALL) 58 Label(name='productName', parent=productNameContainer, align=uiconst.CENTERLEFT, text=self.text, autoFadeSides=True, fontsize=14) 59 60 def BuildCursor(self): 61 if IsPreviewable(GetPreviewType(self.typeID)): 62 self.cursor = uiconst.UICURSOR_MAGNIFIER 63 else: 64 self.disabled = True 65 66 def OnClick(self): 67 self.onClick(self.typeID) 68 69 def GetQuantityEditValue(self): 70 if self.showQuantity: 71 return self.quantityEdit.GetValue() 72 73 def SetQuantityEditValue(self, quantity): 74 if self.showQuantity: 75 return self.quantityEdit.SetValue(quantity, docallback=False) 76 77 def DisableQuantityEdit(self): 78 if self.showQuantity: 79 self.quantityEdit.Disable()