NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

skinLicenseCard.py (9776B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\cosmetics\ship\pages\cards\skinLicenseCard.py
      2 import evetypes
      3 from carbonui import Align, TextAlign
      4 from carbonui.text.styles import TextBody
      5 from carbonui.control.contextMenu.menuData import MenuData
      6 from carbonui.primitives.container import Container
      7 from carbonui.uianimations import animations
      8 from cosmetics.client.ships import ship_skin_signals
      9 from cosmetics.client.shipSkinLicensesSvc import get_ship_skin_license_svc
     10 from eve.client.script.ui import eveColor
     11 from eve.client.script.ui.cosmetics.ship import shipUtil
     12 from eve.client.script.ui.cosmetics.ship.pages.cards.baseSkinCard import SkinCard
     13 from eve.client.script.ui.cosmetics.ship.pages.cards.cardConst import CardOutline
     14 from eve.client.script.ui.cosmetics.ship.pages.collection import collectionSignals
     15 from eveservices.menu import GetMenuService
     16 from localization import GetByLabel
     17 
     18 class BaseSkinLicenseCard(SkinCard):
     19 
     20     def __init__(self, skin_license, *args, **kwargs):
     21         self.license_id = skin_license.skin_hex
     22         self.skin_license = skin_license
     23         super(BaseSkinLicenseCard, self).__init__(*args, **kwargs)
     24         self.connect_signals()
     25 
     26     def Close(self):
     27         try:
     28             self.disconnect_signals()
     29         finally:
     30             super(BaseSkinLicenseCard, self).Close()
     31 
     32     def connect_signals(self):
     33         ship_skin_signals.on_skin_license_activated.connect(self.on_skin_license_activated)
     34         ship_skin_signals.on_skin_state_set.connect(self.on_skin_state_set)
     35 
     36     def disconnect_signals(self):
     37         ship_skin_signals.on_skin_license_activated.disconnect(self.on_skin_license_activated)
     38         ship_skin_signals.on_skin_state_set.disconnect(self.on_skin_state_set)
     39 
     40     def get_live_rendered_icon_skin_design(self):
     41         return self.skin_license.skin_design
     42 
     43     def get_background_texture(self):
     44         pass
     45 
     46     def get_outline_texture(self):
     47         if self.is_stack:
     48             return CardOutline.DEFAULT_STACK
     49         return CardOutline.DEFAULT
     50 
     51     def get_skin_tier_level(self):
     52         return self.skin_license.tier_level
     53 
     54     def get_skin_name(self):
     55         return self.skin_license.name
     56 
     57     def get_top_line_color(self):
     58         if self.is_selected:
     59             return self.get_highlight_color()
     60         else:
     61             return eveColor.WHITE
     62 
     63     def get_top_line_corner_color(self):
     64         if self.is_selected:
     65             return self.get_highlight_color()
     66         else:
     67             return eveColor.WHITE
     68 
     69     def get_highlight_color(self):
     70         return eveColor.CRYO_BLUE
     71 
     72     def on_skin_license_activated(self, license_id):
     73         self.update()
     74 
     75     def on_skin_state_set(self, _ship_instance_id, skin_state):
     76         self.update()
     77 
     78     def OnClick(self, *args):
     79         if self.is_selected:
     80             return
     81         super(BaseSkinLicenseCard, self).OnClick(*args)
     82 
     83     def GetMenu(self):
     84         menu_data = MenuData()
     85         type_id = self.skin_license.skin_design.ship_type_id
     86         menu_data.AddEntry(text=evetypes.GetName(type_id), subMenuData=lambda : GetMenuService().GetMenuFromItemIDTypeID(itemID=None, typeID=type_id, includeMarketDetails=True))
     87         return menu_data
     88 
     89     @property
     90     def is_stack(self):
     91         return self.skin_license.nb_unactivated > 1
     92 
     93 
     94 class ActivatedSkinLicenseCard(BaseSkinLicenseCard):
     95     ship_glow = False
     96 
     97     def get_label_color(self):
     98         if shipUtil.is_currently_applied_skin(self.skin_license.skin_hex):
     99             return eveColor.CRYO_BLUE
    100         else:
    101             return super(ActivatedSkinLicenseCard, self).get_label_color()
    102 
    103     def get_outline_texture(self):
    104         return CardOutline.DEFAULT
    105 
    106     def get_background_texture(self):
    107         return 'res:/UI/Texture/classes/Cosmetics/Ship/cards/skin_design/activated_bg.png'
    108 
    109     def _on_selected(self):
    110         collectionSignals.on_activated_skin_license_selected(self.skin_license)
    111 
    112 
    113 class UnactivatedSkinLicenseCard(BaseSkinLicenseCard):
    114 
    115     def __init__(self, skin_license, *args, **kwargs):
    116         self.is_new = False
    117         self.is_animating = False
    118         super(UnactivatedSkinLicenseCard, self).__init__(skin_license, *args, **kwargs)
    119 
    120     def construct_layout(self):
    121         self.construct_unactivated_label()
    122         super(UnactivatedSkinLicenseCard, self).construct_layout()
    123 
    124     def construct_unactivated_label(self):
    125         self.unactivated_container = Container(name='unactivated_container', parent=self, align=Align.TOBOTTOM_NOPUSH, opacity=0.5, top=55, height=20)
    126         TextBody(name='unactivated_label', parent=self.unactivated_container, align=Align.TOTOP, textAlign=TextAlign.CENTER, text=GetByLabel('UI/Personalization/ShipSkins/SKINR/Collection/Unactivated'))
    127 
    128     def update_stack_lines(self):
    129         if not self.is_stack:
    130             return
    131         self.stack_lines_container.display = True
    132         target_opacity = 1.0 if self.is_hovered or self.is_selected else 0.5
    133         animations.FadeTo(self.stack_lines_container, self.stack_lines_container.opacity, target_opacity, self.ANIM_DURATION)
    134 
    135     def update_stack_numbers(self):
    136         if not self.is_stack:
    137             self.stack_numbers_container.display = False
    138         else:
    139             self.stack_numbers_container.display = True
    140             self.stack_numbers_label.text = self.skin_license.nb_unactivated
    141 
    142     def update(self):
    143         self.is_new = get_ship_skin_license_svc().is_license_new(self.license_id)
    144         super(UnactivatedSkinLicenseCard, self).update()
    145         self.update_unactivated_label()
    146         if self.is_new:
    147             if not self.is_animating:
    148                 self.start_new_highlight_animation()
    149         else:
    150             self.stop_new_highlight_animation()
    151 
    152     def update_unactivated_label(self):
    153         self.unactivated_container.display = True
    154         target_opacity = 1.0 if self.is_hovered or self.is_selected else 0.5
    155         animations.FadeTo(self.unactivated_container, self.unactivated_container.opacity, target_opacity, self.ANIM_DURATION)
    156 
    157     def start_new_highlight_animation(self):
    158         self.is_animating = True
    159         animations.MorphScalar(obj=self.top_line, attrName='glowBrightness', startVal=self.top_line.glowBrightness, endVal=1.5, duration=1.0, timeOffset=0.5, callback=self.on_new_highlight_animation_in_complete)
    160         animations.MorphScalar(obj=self.top_left_corner, attrName='glowBrightness', startVal=self.top_left_corner.glowBrightness, endVal=1.5, duration=1.0, timeOffset=0.5)
    161         animations.MorphScalar(obj=self.top_right_corner, attrName='glowBrightness', startVal=self.top_right_corner.glowBrightness, endVal=1.5, duration=1.0, timeOffset=0.5)
    162         animations.MorphScalar(obj=self.highlight_bottom, attrName='glowBrightness', startVal=self.highlight_bottom.glowBrightness, endVal=1.5, duration=1.0, timeOffset=0.5)
    163 
    164     def on_new_highlight_animation_in_complete(self, *args):
    165         animations.MorphScalar(obj=self.top_line, attrName='glowBrightness', startVal=self.top_line.glowBrightness, endVal=self.GLOW_AMOUNT, duration=1.0, timeOffset=1.0, callback=self.on_new_highlight_animation_out_complete)
    166         animations.MorphScalar(obj=self.top_left_corner, attrName='glowBrightness', startVal=self.top_left_corner.glowBrightness, endVal=self.GLOW_AMOUNT, duration=1.0, timeOffset=1.0)
    167         animations.MorphScalar(obj=self.top_right_corner, attrName='glowBrightness', startVal=self.top_right_corner.glowBrightness, endVal=self.GLOW_AMOUNT, duration=1.0, timeOffset=1.0)
    168         animations.MorphScalar(obj=self.highlight_bottom, attrName='glowBrightness', startVal=self.highlight_bottom.glowBrightness, endVal=self.GLOW_AMOUNT, duration=1.0, timeOffset=1.0)
    169 
    170     def on_new_highlight_animation_out_complete(self, *args):
    171         if self.is_new:
    172             self.start_new_highlight_animation()
    173 
    174     def stop_new_highlight_animation(self):
    175         animations.StopAnimation(self.top_line, 'glowBrightness')
    176         animations.StopAnimation(self.top_right_corner, 'glowBrightness')
    177         animations.StopAnimation(self.top_left_corner, 'glowBrightness')
    178         animations.StopAnimation(self.highlight_bottom, 'glowBrightness')
    179         self.top_line.glowBrightness = self.GLOW_AMOUNT
    180         self.top_left_corner.glowBrightness = self.GLOW_AMOUNT
    181         self.top_right_corner.glowBrightness = self.GLOW_AMOUNT
    182         self.highlight_bottom.glowBrightness = self.GLOW_AMOUNT
    183         self.is_animating = False
    184 
    185     def get_background_texture(self):
    186         return 'res:/UI/Texture/classes/Cosmetics/Ship/cards/skin_design/background.png'
    187 
    188     def get_top_line_color(self):
    189         if self.is_new:
    190             return eveColor.DUSKY_ORANGE
    191         return super(UnactivatedSkinLicenseCard, self).get_top_line_color()
    192 
    193     def get_top_line_opacity(self):
    194         if self.is_new:
    195             return 1.0
    196         return super(UnactivatedSkinLicenseCard, self).get_top_line_opacity()
    197 
    198     def get_top_line_corner_color(self):
    199         if self.is_new:
    200             return eveColor.DUSKY_ORANGE
    201         return super(UnactivatedSkinLicenseCard, self).get_top_line_corner_color()
    202 
    203     def get_highlight_color(self):
    204         if self.is_new:
    205             return eveColor.DUSKY_ORANGE
    206         return super(UnactivatedSkinLicenseCard, self).get_highlight_color()
    207 
    208     def get_highlight_opacity(self):
    209         if self.is_new:
    210             return 1.0
    211         return super(UnactivatedSkinLicenseCard, self).get_highlight_opacity()
    212 
    213     def _on_selected(self):
    214         collectionSignals.on_unactivated_skin_license_selected(self.skin_license)
    215 
    216     def OnClick(self, *args):
    217         if self.is_selected:
    218             return
    219         get_ship_skin_license_svc().set_license_is_new_flag(self.license_id, is_new=False)
    220         super(UnactivatedSkinLicenseCard, self).OnClick(*args)