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

empireSelectionButton.py (4365B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\login\charcreation_new\steps\empireSelection\empireSelectionButton.py
      2 from carbon.client.script.environment.AudioUtil import PlaySound
      3 from carbonui import uiconst
      4 from carbonui.loggers.buttonLogger import log_button_clicked
      5 from carbonui.primitives.container import Container
      6 from carbonui.uianimations import animations
      7 from characterdata.races import get_race_name
      8 from eve.client.script.ui.const.eveIconConst import RACE_ICONS
      9 from eve.client.script.ui.control.eveLabel import EveCaptionLarge, EveLabelLarge
     10 from eve.client.script.ui.login.charcreation_new import soundConst
     11 from eve.client.script.ui.login.charcreation_new.steps.empireSelection.empireSelectionConst import COLOR_BY_FACTIONID, BLURB_BY_FACTIONID, MINIMIZE_ANIMATION_DURATION
     12 from eve.client.script.ui.login.charcreation_new.charCreationSignals import onEmpireFactionSelected, onEmpireFactionButtonClicked
     13 from eve.common.lib import appConst
     14 from eveui import Sprite
     15 from localization import GetByLabel
     16 ICONSIZE_SMALL = 70
     17 ICONSIZE_LARGE = 100
     18 OPACITY_IDLE = 0.7
     19 OPACITY_HOVER = 1.0
     20 BLURB_CONT_OFFSET = -180
     21 BLURB_CONT_OFFSET_HOVER = -140
     22 
     23 class EmpireSelectionButton(Container):
     24     default_name = 'EmpireIcon'
     25     default_state = uiconst.UI_NORMAL
     26     default_opacity = OPACITY_IDLE
     27     default_analyticID = ''
     28 
     29     def ApplyAttributes(self, attributes):
     30         super(EmpireSelectionButton, self).ApplyAttributes(attributes)
     31         self.factionID = attributes.factionID
     32         self.analyticID = attributes.get('analyticID', self.default_analyticID)
     33         self.isLarge = True
     34         raceID = appConst.raceByFaction[self.factionID]
     35         self.icon = Sprite(name='icon', parent=self, texturePath=RACE_ICONS[raceID], align=uiconst.CENTER, pos=(0,
     36          -10,
     37          ICONSIZE_LARGE,
     38          ICONSIZE_LARGE))
     39         self.nameLabel = EveCaptionLarge(name='NameLabel', parent=self, align=uiconst.CENTER, top=55, text=get_race_name(raceID))
     40         self.ConstructBlurbCont()
     41 
     42     def ConstructBlurbCont(self):
     43         self.blurbCont = Container(name='blurbCont', parent=self, align=uiconst.CENTERBOTTOM, pos=(0.0,
     44          BLURB_CONT_OFFSET,
     45          208,
     46          208), opacity=0.0)
     47         Sprite(name='topLine', parent=self.blurbCont, align=uiconst.CENTERBOTTOM, height=33, width=290, color=COLOR_BY_FACTIONID[self.factionID], texturePath='res:/UI/Texture/Classes/CharacterSelection/EmpireSelection/empireBottomGlow.png')
     48         EveLabelLarge(name='blurbLabel', parent=self.blurbCont, align=uiconst.CENTERBOTTOM, color=COLOR_BY_FACTIONID[self.factionID], top=30, width=198, text='<center>' + GetByLabel(BLURB_BY_FACTIONID[self.factionID]))
     49 
     50     def OnMouseEnter(self, *args):
     51         super(EmpireSelectionButton, self).OnMouseEnter(*args)
     52         PlaySound(soundConst.RACE_HOVER)
     53         animations.FadeTo(self, self.opacity, OPACITY_HOVER, duration=0.1)
     54         if self.isLarge:
     55             animations.FadeTo(self.blurbCont, self.blurbCont.opacity, 1.0, duration=0.6)
     56             animations.MorphScalar(self.blurbCont, 'top', self.blurbCont.top, BLURB_CONT_OFFSET_HOVER, duration=0.6)
     57 
     58     def OnMouseExit(self, *args):
     59         super(EmpireSelectionButton, self).OnMouseExit(*args)
     60         animations.FadeTo(self, self.opacity, OPACITY_IDLE, duration=0.1)
     61         if self.isLarge:
     62             self.FadeOutBlurbCont()
     63 
     64     def FadeOutBlurbCont(self, duration = 0.6):
     65         animations.FadeTo(self.blurbCont, self.blurbCont.opacity, 0.0, duration=duration)
     66         animations.MorphScalar(self.blurbCont, 'top', self.blurbCont.top, BLURB_CONT_OFFSET, duration=duration)
     67 
     68     def OnClick(self, *args):
     69         PlaySound(soundConst.RACE_SELECTION)
     70         log_button_clicked(self)
     71         onEmpireFactionButtonClicked(self.factionID)
     72 
     73     def ReduceSize(self):
     74         self.isLarge = False
     75         animations.FadeOut(self.nameLabel, duration=MINIMIZE_ANIMATION_DURATION)
     76         self.FadeOutBlurbCont(duration=MINIMIZE_ANIMATION_DURATION)
     77         animations.MorphScalar(self.icon, 'top', self.icon.top, 0, duration=MINIMIZE_ANIMATION_DURATION)
     78         animations.MorphScalar(self.icon, 'width', self.icon.width, ICONSIZE_SMALL, duration=MINIMIZE_ANIMATION_DURATION)
     79         animations.MorphScalar(self.icon, 'height', self.icon.height, ICONSIZE_SMALL, duration=MINIMIZE_ANIMATION_DURATION)