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

charCreationButtons.py (12951B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\login\charcreation_new\charCreationButtons.py
      2 import trinity
      3 import carbonui.const as uiconst
      4 from carbonui.primitives.container import Container
      5 from carbonui.primitives.frame import Frame
      6 from carbonui.primitives.gradientSprite import GradientSprite
      7 from carbonui.primitives.sprite import Sprite
      8 from carbonui.uianimations import animations
      9 from carbonui.util.color import Color
     10 from charactercreator.client.empireSelectionData import GetEmpireColor, GetEmpireLogo, GetEmpireButtonLogo
     11 import charactercreator.client.scalingUtils as ccScalingUtils
     12 from eve.client.script.ui import eveColor
     13 from eve.common.lib.appConst import raceAmarr, raceCaldari, raceGallente, raceMinmatar
     14 from localization import GetByLabel
     15 FILL_SELECTION = 0.2
     16 TEXT_NORMAL = 0.8
     17 EXIT_BUTTON_SIZE = 16
     18 TEMP_RACE_BUTTON_NORMAL = 'res:/UI/Texture/CharacterCreation/raceButtons/RaceButtonNormal_%s.dds'
     19 TEMP_RACE_BUTTON_DOWN = 'res:/UI/Texture/CharacterCreation/raceButtons/RaceButtonDown_%s.dds'
     20 BLOODLINE_HEADERS = {raceAmarr: GetByLabel('UI/Login/CharacterCreation/BloodlineSelection/AmarrBloodlines'),
     21  raceCaldari: GetByLabel('UI/Login/CharacterCreation/BloodlineSelection/CaldariBloodlines'),
     22  raceGallente: GetByLabel('UI/Login/CharacterCreation/BloodlineSelection/GallenteBloodlines'),
     23  raceMinmatar: GetByLabel('UI/Login/CharacterCreation/BloodlineSelection/MinmatarBloodlines')}
     24 EMPIRE_TAB_BUTTON_OPACITY = 0.3
     25 EMPIRE_TAB_BUTTON_TEXTURE_ACTIVE = 'res:/UI/Texture/classes/EmpireSelection/empireTabActive.png'
     26 EMPIRE_TAB_BUTTON_TEXTURE_ACTIVE_GLOW = 'res:/UI/Texture/classes/EmpireSelection/empireTabActiveGlow.png'
     27 EMPIRE_TAB_BUTTON_TEXTURE_INACTIVE = 'res:/UI/Texture/classes/EmpireSelection/empireTabInactive.png'
     28 HEADER_SPOTLIGHT_HEIGHT_FACTOR = 1.6
     29 EMPIRE_TAB_ICON_SIZE = 160
     30 EMPIRE_ICON_SIZE_ACTIVE = 84
     31 EMPIRE_ICON_PAD = 3
     32 EMPIRE_ICON_GLOW_WIDTH = 64
     33 EMPIRE_ICON_GLOW_HEIGHT = 17
     34 EMPIRE_ICON_GRADIENT_HEIGHT = 1
     35 EMPIRE_ICON_FRAME_ACTIVE_OPACITY = 1.0
     36 EMPIRE_ICON_FRAME_INACTIVE_OPACITY = 0.6
     37 EMPIRE_ICON_FRAME_HOVER_OPACITY = 1.5
     38 EMPIRE_ICON_FRAME_DOWN_OPACITY = 3.0
     39 EMPIRE_ICON_FRAME_GLOW_OPACITY = 1.0
     40 EMPIRE_ICON_FRAME_GRADIENT_OPACITY = 1.0
     41 
     42 def GetEmpireTabSizeLarge():
     43     return EMPIRE_ICON_SIZE_ACTIVE * ccScalingUtils.GetScaleFactor()
     44 
     45 
     46 class BaseCCButton(Container):
     47     __guid__ = 'uicls.BaseCCButton'
     48     default_state = uiconst.UI_NORMAL
     49     default_left = 0
     50     default_top = 0
     51     default_width = 128
     52     default_height = 128
     53     default_align = uiconst.CENTER
     54     mouseoverSound = 'ui_icc_button_mouse_over_play'
     55     selectSound = 'ui_icc_button_select_play'
     56 
     57     def ApplyAttributes(self, attributes):
     58         Container.ApplyAttributes(self, attributes)
     59         spriteWidth = attributes.Get('spriteWidth', self.default_width)
     60         spriteHeight = attributes.Get('spriteHeight', self.default_height)
     61         self.normalSprite = Sprite(name='normalSprite', parent=self, align=uiconst.CENTER, state=uiconst.UI_DISABLED, texturePath='', width=spriteWidth, height=spriteHeight)
     62         self.hiliteSprite = Sprite(name='hiliteSprite', parent=self, align=uiconst.CENTER, state=uiconst.UI_HIDDEN, texturePath='', width=spriteWidth, height=spriteHeight)
     63         self.normalSprite.SetAlpha(0.3)
     64 
     65     def OnMouseEnter(self, *args):
     66         if self.mouseoverSound:
     67             sm.StartService('audio').SendUIEvent(unicode(self.mouseoverSound))
     68         self.normalSprite.SetAlpha(0.6)
     69 
     70     def OnMouseExit(self, *args):
     71         self.normalSprite.SetAlpha(0.3)
     72 
     73     def Deselect(self):
     74         self.hiliteSprite.state = uiconst.UI_HIDDEN
     75         self.normalSprite.state = uiconst.UI_DISABLED
     76         self.normalSprite.SetAlpha(0.3)
     77 
     78     def Select(self):
     79         if self.selectSound:
     80             sm.StartService('audio').SendUIEvent(unicode(self.selectSound))
     81         self.hiliteSprite.state = uiconst.UI_DISABLED
     82         self.normalSprite.state = uiconst.UI_HIDDEN
     83 
     84     def OnClick(self, *args):
     85         pass
     86 
     87 
     88 class EmpireTabAnimationType:
     89     ACTIVATE = 1
     90     DEACTIVATE = 2
     91     HOVER = 3
     92     DEHOVER = 4
     93 
     94 
     95 class EmpireTabButton(BaseCCButton):
     96     selectSound = None
     97     mouseoverSound = None
     98 
     99     def ApplyAttributes(self, attributes):
    100         self.isActive = attributes.isActive
    101         self.isHovered = False
    102         tabSize = GetEmpireTabSizeLarge()
    103         attributes.spriteWidth = tabSize
    104         attributes.spriteHeight = tabSize
    105         super(EmpireTabButton, self).ApplyAttributes(attributes)
    106         self.raceSetter = attributes.raceSetter
    107         self.raceHoverer = attributes.raceHoverer
    108         self.raceID = attributes.raceID
    109         self.isDisabled = attributes.get('isDisabled', False)
    110         r, g, b, _ = GetEmpireColor(self.raceID)
    111         self.buttonLogo = Sprite(name='buttonLogo', texturePath=GetEmpireButtonLogo(self.raceID), parent=self, width=tabSize, height=tabSize, state=uiconst.UI_DISABLED, align=uiconst.CENTER, opacity=float(not self.isActive))
    112         self.empireLogo = Sprite(name='empireLogo', texturePath=GetEmpireLogo(self.raceID), parent=self, width=tabSize, height=tabSize, state=uiconst.UI_DISABLED, align=uiconst.CENTER, opacity=float(self.isActive))
    113         self.BuildFrames()
    114 
    115     def BuildFrames(self):
    116         scaleFactor = ccScalingUtils.GetScaleFactor()
    117         r, g, b, _ = GetEmpireColor(self.raceID)
    118         tabSize = GetEmpireTabSizeLarge()
    119         self.frameGradientContainer = Container(parent=self, name='frameGradientContainer', align=uiconst.TOTOP_NOPUSH, width=tabSize, height=tabSize)
    120         self.frameGradient = GradientSprite(parent=self.frameGradientContainer, name='frameGradient', align=uiconst.CENTERBOTTOM, width=tabSize, height=EMPIRE_ICON_GRADIENT_HEIGHT, rgbData=[(0, (1.0, 1.0, 1.0))], alphaData=[(0, 0.0),
    121          (0.4, 0.5),
    122          (0.6, 0.5),
    123          (1.0, 0.0)], opacity=EMPIRE_ICON_FRAME_GRADIENT_OPACITY * self.isActive)
    124         self.frameGlowContainer = Container(parent=self, name='frameGlowContainer', align=uiconst.TOTOP_NOPUSH, width=tabSize, height=tabSize)
    125         self.frameGlow = Frame(parent=self.frameGlowContainer, name='frameGlow', align=uiconst.CENTERBOTTOM, width=EMPIRE_ICON_GLOW_WIDTH * scaleFactor, height=EMPIRE_ICON_GLOW_HEIGHT * scaleFactor, texturePath=EMPIRE_TAB_BUTTON_TEXTURE_ACTIVE_GLOW, color=(r,
    126          g,
    127          b,
    128          EMPIRE_ICON_FRAME_GLOW_OPACITY * self.isActive))
    129         self.frameActiveContainer = Container(parent=self, name='frameActiveContainer', align=uiconst.TOTOP_NOPUSH, width=tabSize, height=tabSize)
    130         self.frameActive = Frame(parent=self.frameActiveContainer, name='frameActive', align=uiconst.TOALL, texturePath=EMPIRE_TAB_BUTTON_TEXTURE_ACTIVE, color=(r,
    131          g,
    132          b,
    133          EMPIRE_ICON_FRAME_ACTIVE_OPACITY * self.isActive))
    134         self.frameInactiveContainer = Container(parent=self, name='frameInactiveContainer', align=uiconst.TOTOP_NOPUSH, width=tabSize, height=tabSize)
    135         self.frameInactive = Frame(parent=self.frameInactiveContainer, name='frameInactive', align=uiconst.TOALL, texturePath=EMPIRE_TAB_BUTTON_TEXTURE_INACTIVE, color=(r,
    136          g,
    137          b,
    138          EMPIRE_ICON_FRAME_INACTIVE_OPACITY))
    139 
    140     def DesaturateRaceIcon(self):
    141         self.buttonLogo.spriteEffect = trinity.TR2_SFX_SOFTLIGHT
    142         self.buttonLogo.saturation = 0
    143 
    144     def GetMaximumAllowedLogoOpacity(self):
    145         if self.isDisabled:
    146             return 0.5
    147         return 1.0
    148 
    149     def Activate(self):
    150         self.isActive = True
    151         self.ActivateFrame()
    152         self.buttonLogo.opacity = 0.0
    153         self.empireLogo.opacity = 1.0
    154 
    155     def ActivateFrame(self):
    156         self.frameActive.opacity = EMPIRE_ICON_FRAME_ACTIVE_OPACITY
    157         self.frameGlow.opacity = EMPIRE_ICON_FRAME_GLOW_OPACITY
    158         self.frameGradient.opacity = EMPIRE_ICON_FRAME_GRADIENT_OPACITY
    159 
    160     def Deactivate(self):
    161         self.isActive = False
    162         self.DeactivateFrame()
    163         self.buttonLogo.opacity = self.GetMaximumAllowedLogoOpacity()
    164         self.empireLogo.opacity = 0.0
    165 
    166     def DeactivateFrame(self):
    167         self.frameActive.opacity = 0.0
    168         self.frameGlow.opacity = 0.0
    169         self.frameGradient.opacity = 0.0
    170 
    171     def Hover(self):
    172         self.isHovered = True
    173         self.HoverFrame()
    174         self.buttonLogo.opacity = self.GetMaximumAllowedLogoOpacity()
    175         self.empireLogo.opacity = 0.0
    176 
    177     def HoverFrame(self):
    178         self.frameActive.opacity = EMPIRE_ICON_FRAME_HOVER_OPACITY
    179         self.frameGlow.opacity = 0.0
    180         self.frameGradient.opacity = 0.0
    181 
    182     def Dehover(self):
    183         self.isHovered = False
    184         self.DeactivateFrame()
    185         self.buttonLogo.opacity = self.GetMaximumAllowedLogoOpacity()
    186         self.empireLogo.opacity = 0.0
    187 
    188     def OnClick(self):
    189         self.raceSetter(self.raceID)
    190 
    191     def OnMouseDown(self, *args):
    192         animations.MorphScalar(self.frameActive, 'opacity', self.frameActive.opacity, EMPIRE_ICON_FRAME_DOWN_OPACITY, 0.05)
    193         super(EmpireTabButton, self).OnMouseDown(self, *args)
    194 
    195     def OnMouseUp(self, *args):
    196         animations.MorphScalar(self.frameActive, 'opacity', self.frameActive.opacity, EMPIRE_ICON_FRAME_ACTIVE_OPACITY, 0.25)
    197         super(EmpireTabButton, self).OnMouseUp(self, *args)
    198 
    199     def OnMouseEnter(self):
    200         if not self.isActive and not self.isHovered:
    201             self.raceHoverer(self.raceID)
    202         super(EmpireTabButton, self).OnMouseEnter()
    203 
    204     def OnMouseExit(self):
    205         if not self.isActive and self.isHovered:
    206             self.raceHoverer(None)
    207         super(EmpireTabButton, self).OnMouseExit()
    208 
    209 
    210 class EmpireTab(Container):
    211     default_mouseUpBGTexture = None
    212     default_mouseEnterBGTexture = None
    213     default_mouseDownBGTexture = None
    214     default_isBGFrameUsed = None
    215     default_frameOffset = 0
    216     default_frameCornerSize = 0
    217 
    218     def ApplyAttributes(self, attributes):
    219         self.isActive = attributes.Get('isActive', False)
    220         self.isHovered = attributes.Get('isActive', False)
    221         self.raceID = attributes.Get('raceID', None)
    222         self.raceSetter = attributes.Get('raceSetter', None)
    223         self.raceHoverer = attributes.Get('raceHoverer', None)
    224         self.empireLogoPath = attributes.Get('empireLogoPath', None)
    225         self.isDisabled = attributes.Get('isDisabled', False)
    226         super(EmpireTab, self).ApplyAttributes(attributes)
    227         self.iconSize = self.width / 2.0
    228         tabSize = GetEmpireTabSizeLarge()
    229         self.buttonContainer = Container(parent=self, align=uiconst.BOTTOMLEFT, width=self.width, height=self.height)
    230         self.button = EmpireTabButton(parent=self.buttonContainer, width=tabSize, height=tabSize, raceID=self.raceID, align=uiconst.BOTTOMLEFT, raceSetter=self.raceSetter, raceHoverer=self.raceHoverer, isActive=self.isActive, isDisabled=self.isDisabled)
    231         self.gradientFill = None
    232         self.gradientBgFill = None
    233         self.width = tabSize
    234         self.height = tabSize
    235         if self.isDisabled:
    236             Sprite(name='warningIcon', parent=self.buttonContainer, align=uiconst.BOTTOMLEFT, width=26, height=26, left=5, texturePath='res:/UI/Texture/classes/agency/iconExclamation.png', color=eveColor.WARNING_ORANGE, state=uiconst.UI_NORMAL, hint=GetByLabel('UI/CharacterCreation/FactionDisabled'))
    237             self.button.Disable()
    238             self.button.DesaturateRaceIcon()
    239 
    240     def Activate(self):
    241         self.isActive = True
    242         self.button.Activate()
    243 
    244     def Deactivate(self):
    245         self.isActive = False
    246         self.button.Deactivate()
    247 
    248     def Hover(self):
    249         self.isHovered = True
    250         self.button.Hover()
    251 
    252     def Dehover(self):
    253         self.isHovered = False
    254         self.button.Dehover()
    255 
    256 
    257 class StaticBloodlineButton(Container):
    258     __guid__ = 'uicls.SmallerBloodlineButton'
    259     default_width = 125
    260     default_height = 100
    261 
    262     def ApplyAttributes(self, attributes):
    263         iconTexturePath = attributes.iconTexturePath
    264         super(StaticBloodlineButton, self).ApplyAttributes(attributes)
    265         self.bloodlineID = attributes.bloodlineID
    266         self.sprite = Sprite(parent=self, align=uiconst.CENTER, texturePath=iconTexturePath, width=self.width, height=self.height)
    267 
    268     def Resize(self, width, height):
    269         self.width = width
    270         self.height = height
    271         self.sprite.width = width
    272         self.sprite.height = height
    273 
    274 
    275 class ExitButton(Container):
    276     default_name = 'exitButton'
    277     default_width = EXIT_BUTTON_SIZE
    278     default_height = EXIT_BUTTON_SIZE
    279     default_state = uiconst.UI_NORMAL
    280 
    281     def ApplyAttributes(self, attributes):
    282         Container.ApplyAttributes(self, attributes)
    283         self.onClick = attributes.onClick
    284         width = attributes.Get('width', self.default_width)
    285         height = attributes.Get('height', self.default_height)
    286         Sprite(parent=self, texturePath='res:/UI/Texture/Icons/73_16_45.png', width=width, height=height, align=uiconst.CENTER, state=uiconst.UI_DISABLED, color=Color.GRAY7)
    287 
    288     def OnClick(self):
    289         self.onClick()