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

componentLicenseCard.py (8217B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\cosmetics\ship\pages\cards\componentLicenseCard.py
      2 from carbonui import Align, SpriteEffect, uiconst
      3 from carbonui.primitives.sprite import Sprite
      4 from carbonui.uianimations import animations
      5 from cosmetics.client.shipSkinComponentSvc import get_ship_skin_component_svc
      6 from cosmetics.common.ships.skins.live_data.component_license_type import ComponentLicenseType
      7 from cosmetics.common.ships.skins.static_data.component_category import ComponentCategory
      8 from eve.client.script.ui import eveColor
      9 from eve.client.script.ui.cosmetics.ship.controls.numRunsIndicator import NumRunsIndicator
     10 from eve.client.script.ui.cosmetics.ship.pages.cards.baseComponentCard import ComponentCard, BlankComponentCard
     11 from eve.client.script.ui.cosmetics.ship.pages.collection import collectionSignals
     12 from eveservices.menu import GetMenuService
     13 
     14 class ComponentLicenceCard(ComponentCard):
     15 
     16     def __init__(self, component_license, *args, **kwargs):
     17         self.component_license = component_license
     18         self.is_new = False
     19         self.is_animating = False
     20         super(ComponentLicenceCard, self).__init__(*args, **kwargs)
     21 
     22     def get_background_texture(self):
     23         if self.component_license.get_component_data().category == ComponentCategory.PATTERN:
     24             return 'res:/UI/Texture/classes/Cosmetics/Ship/cards/components/pattern_background.png'
     25         else:
     26             return 'res:/UI/Texture/classes/Cosmetics/Ship/cards/components/material_background.png'
     27 
     28     def construct_icon(self):
     29         super(ComponentLicenceCard, self).construct_icon()
     30         if self.component_license.get_component_data().category == ComponentCategory.PATTERN:
     31             self.icon = Sprite(name='icon', parent=self.icon_container, align=Align.CENTER, state=uiconst.UI_DISABLED, texturePath=self.component_license.get_component_data().icon_file_path, textureSecondaryPath='res:/UI/Texture/classes/Cosmetics/Ship/cards/components/pattern_icon_mask.png', spriteEffect=SpriteEffect.MODULATE, glow=False, width=80, height=80)
     32         else:
     33             self.icon = Sprite(name='icon', parent=self.icon_container, align=Align.CENTER, state=uiconst.UI_DISABLED, texturePath=self.component_license.get_component_data().icon_file_path, textureSecondaryPath='res:/UI/Texture/classes/Cosmetics/Ship/pages/studio/nanocoating_mask.png', spriteEffect=SpriteEffect.MODULATE, glow=False, width=64, height=64)
     34             Sprite(name='icon_ring', parent=self, align=Align.CENTERTOP, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/Cosmetics/Ship/cards/components/material_ring.png', width=90, height=90, top=49)
     35 
     36     def construct_usage_indicator(self):
     37         self.usage_container = NumRunsIndicator(name='usage_container', parent=self, align=Align.TOPRIGHT, opacity=0.5, width=self.USAGE_ICON_SIZE, height=self.USAGE_ICON_SIZE, top=self.CORNER_ICON_OFFSET, left=self.CORNER_ICON_OFFSET, num_runs=self.get_uses_remaining(), licence_type=self.component_license.license_type)
     38 
     39     def update(self):
     40         self.is_new = get_ship_skin_component_svc().is_component_new(self.component_license.component_id)
     41         super(ComponentLicenceCard, self).update()
     42         self.update_usage_indicator()
     43         if self.is_new:
     44             if not self.is_animating:
     45                 self.start_new_highlight_animation()
     46         else:
     47             self.stop_new_highlight_animation()
     48 
     49     def update_usage_indicator(self):
     50         target_opacity = 1.0 if self.is_hovered or self.is_selected else 0.5
     51         animations.FadeTo(self.usage_container, self.usage_container.opacity, target_opacity, self.ANIM_DURATION)
     52 
     53     def start_new_highlight_animation(self):
     54         self.is_animating = True
     55         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)
     56         animations.MorphScalar(obj=self.top_left_corner, attrName='glowBrightness', startVal=self.top_left_corner.glowBrightness, endVal=1.5, duration=1.0, timeOffset=0.5)
     57         animations.MorphScalar(obj=self.top_right_corner, attrName='glowBrightness', startVal=self.top_right_corner.glowBrightness, endVal=1.5, duration=1.0, timeOffset=0.5)
     58         animations.MorphScalar(obj=self.highlight_bottom, attrName='glowBrightness', startVal=self.highlight_bottom.glowBrightness, endVal=1.5, duration=1.0, timeOffset=0.5)
     59 
     60     def on_new_highlight_animation_in_complete(self, *args):
     61         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)
     62         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)
     63         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)
     64         animations.MorphScalar(obj=self.highlight_bottom, attrName='glowBrightness', startVal=self.highlight_bottom.glowBrightness, endVal=self.GLOW_AMOUNT, duration=1.0, timeOffset=1.0)
     65 
     66     def on_new_highlight_animation_out_complete(self, *args):
     67         if self.is_new:
     68             self.start_new_highlight_animation()
     69 
     70     def stop_new_highlight_animation(self):
     71         animations.StopAnimation(self.top_line, 'glowBrightness')
     72         animations.StopAnimation(self.top_right_corner, 'glowBrightness')
     73         animations.StopAnimation(self.top_left_corner, 'glowBrightness')
     74         animations.StopAnimation(self.highlight_bottom, 'glowBrightness')
     75         self.top_line.glowBrightness = self.GLOW_AMOUNT
     76         self.top_left_corner.glowBrightness = self.GLOW_AMOUNT
     77         self.top_right_corner.glowBrightness = self.GLOW_AMOUNT
     78         self.highlight_bottom.glowBrightness = self.GLOW_AMOUNT
     79         self.is_animating = False
     80 
     81     def get_top_line_color(self):
     82         if self.is_new:
     83             return eveColor.DUSKY_ORANGE
     84         return super(ComponentLicenceCard, self).get_top_line_color()
     85 
     86     def get_top_line_opacity(self):
     87         if self.is_new:
     88             return 1.0
     89         return super(ComponentLicenceCard, self).get_top_line_opacity()
     90 
     91     def get_highlight_color(self):
     92         if self.is_new:
     93             return eveColor.DUSKY_ORANGE
     94         return super(ComponentLicenceCard, self).get_highlight_color()
     95 
     96     def get_highlight_opacity(self):
     97         if self.is_new:
     98             return 1.0
     99         return super(ComponentLicenceCard, self).get_highlight_opacity()
    100 
    101     def get_rarity(self):
    102         return self.component_license.get_component_data().rarity
    103 
    104     def has_unlimited_uses(self):
    105         return self.component_license.license_type is ComponentLicenseType.UNLIMITED
    106 
    107     def get_uses_remaining(self):
    108         return self.component_license.remaining_license_uses
    109 
    110     def get_component_name(self):
    111         return self.component_license.name
    112 
    113     def _on_selected(self):
    114         collectionSignals.on_component_license_selected(self.component_license)
    115 
    116     def OnClick(self, *args):
    117         if self.is_selected:
    118             return
    119         get_ship_skin_component_svc().set_component_is_new_flag(self.component_license.component_id, False)
    120         super(ComponentLicenceCard, self).OnClick(*args)
    121 
    122     def GetMenu(self):
    123         for type_id, component_item_data in self.component_license.get_component_data().component_item_data_by_type_id.items():
    124             if component_item_data.component_id == self.component_license.component_id:
    125                 return GetMenuService().GetMenuFromItemIDTypeID(itemID=None, typeID=type_id, includeMarketDetails=True)
    126 
    127 
    128 class BlankMaterialComponentCard(BlankComponentCard):
    129 
    130     def get_background_texture(self):
    131         return 'res:/UI/Texture/classes/Cosmetics/Ship/cards/components/material_blank.png'
    132 
    133 
    134 class BlankPatternComponentCard(BlankComponentCard):
    135 
    136     def get_background_texture(self):
    137         return 'res:/UI/Texture/classes/Cosmetics/Ship/cards/components/pattern_blank.png'