paintCard.py (3697B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\cosmetics\structure\components\paintCard.py 2 import carbonui 3 import carbonui.text.styles 4 from carbon.client.script.environment.AudioUtil import PlaySound 5 from carbonui.primitives.frame import Frame 6 from carbonui.primitives.fill import Fill 7 from localization import GetByMessageID 8 from signals import Signal 9 from carbonui import const as uiconst 10 from carbonui.control.buttonIcon import ButtonIcon 11 from carbonui.primitives.container import Container 12 from eve.client.script.ui.control.eveLabel import EveLabelSmall 13 from eve.client.script.ui import eveColor 14 from paints.data import dataLoader as paintsDataLoader 15 from carbonui.uianimations import animations 16 from eve.client.script.ui.cosmetics.structure import const as paintToolConst 17 CARD_HEIGHT = 101 18 CARD_WIDTH = 80 19 CARD_PAINT_WIDTH = CARD_WIDTH 20 CARD_PAINT_HEIGHT = 64 21 CARD_PAINT_ICON_SIZE = 64 22 SELECTED_FRAME_OPACITY = 1.0 23 UNSELECTED_FRAME_OPACITY = 0.0 24 SELECTED_FRAME_BRIGHTNESS = 0.5 25 UNSELECTED_FRAME_BRIGHTNESS = 0.0 26 27 class PaintCard(Container): 28 on_paint_card_clicked = Signal() 29 30 def __init__(self, paint_id, index, **kw): 31 super(PaintCard, self).__init__(**kw) 32 self._selected = False 33 self._paint_id = paint_id 34 self._name_nabel = None 35 self.index = index 36 self._construct_layout() 37 38 def _construct_layout(self): 39 center_cont = Container(name='centerCont', parent=self, align=uiconst.TOTOP, height=64) 40 self._name_nabel = carbonui.text.styles.TextDetail(name='nameLabel', parent=self, align=uiconst.TOTOP, padTop=5, padBottom=6, text=GetByMessageID(paintsDataLoader.get_paint_brand_name_id(self._paint_id)), maxFontSize=13) 41 btn = ButtonIcon(name='iconBtn', parent=center_cont, align=uiconst.TORIGHT_NOPUSH, func=self._on_clicked, width=CARD_PAINT_ICON_SIZE, height=CARD_PAINT_ICON_SIZE, iconSize=CARD_PAINT_ICON_SIZE, texturePath=paintToolConst.get_paint_icon(self._paint_id)) 42 btn.SetIconColor(eveColor.WHITE) 43 Fill(name='bgFill', parent=center_cont, align=uiconst.CENTER, width=CARD_PAINT_WIDTH, height=CARD_PAINT_HEIGHT, color=eveColor.WHITE, opacity=0.1) 44 self._frame = Frame(parent=center_cont, name='frame', align=uiconst.TOALL, frameConst=uiconst.FRAME_BORDER2_CORNER0, color=eveColor.PRIMARY_BLUE, outputMode=uiconst.OUTPUT_COLOR_AND_GLOW, glowBrightness=UNSELECTED_FRAME_BRIGHTNESS, opacity=UNSELECTED_FRAME_OPACITY) 45 46 def OnMouseEnter(self, *args): 47 super(PaintCard, self).OnMouseEnter(*args) 48 if not self._selected: 49 self._show_frame(True) 50 51 def OnMouseExit(self, *args): 52 super(PaintCard, self).OnMouseExit(*args) 53 if not self._selected: 54 self._show_frame(False) 55 56 def set_selected(self, selected): 57 self._selected = selected 58 self._show_frame(selected) 59 60 def _show_frame(self, show): 61 target_opacity = SELECTED_FRAME_OPACITY if show else UNSELECTED_FRAME_OPACITY 62 target_glow_brightness = SELECTED_FRAME_BRIGHTNESS if show else UNSELECTED_FRAME_BRIGHTNESS 63 animations.MorphScalar(self._frame, 'glowBrightness', startVal=self._frame.glowBrightness, endVal=target_glow_brightness, duration=0.25) 64 animations.FadeTo(self._frame, startVal=self._frame.opacity, endVal=target_opacity, duration=0.25) 65 66 def _on_clicked(self, *args): 67 self.on_paint_card_clicked(self._paint_id) 68 PlaySound('nanocoating_button_select_color_play') 69 70 def is_label_visible(self, value): 71 self._name_nabel.state = uiconst.UI_PICKCHILDREN if value else uiconst.UI_HIDDEN 72 self.height = CARD_HEIGHT if value else CARD_PAINT_HEIGHT