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

characterPortrait.py (9013B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\login\charcreation\steps\characterPortrait.py
      2 from carbon.common.script.util import timerstuff
      3 from carbonui import uiconst
      4 from carbonui.primitives.container import Container
      5 from carbonui.primitives.fill import Fill
      6 from carbonui.primitives.frame import Frame
      7 from carbonui.util.various_unsorted import MapIcon
      8 from charactercreator import const as ccConst
      9 from eve.client.script.ui.control import eveIcon, eveLabel
     10 from carbonui.control.button import Button
     11 from eve.client.script.ui.login.charcreation.assetMenu import CCColorPalette, CharCreationAssetMenu
     12 from eve.client.script.ui.login.charcreation.charCreation import BaseCharacterCreationStep, MAXMENUSIZE
     13 from evegraphics import settings as gfxsettings
     14 import localization
     15 from carbonui.uicore import uicore
     16 
     17 class CharacterPortrait(BaseCharacterCreationStep):
     18     __notifyevents__ = BaseCharacterCreationStep.__notifyevents__
     19     __notifyevents__ += ['OnGraphicSettingsChanged']
     20     stepID = ccConst.PORTRAITSTEP
     21 
     22     def ApplyAttributes(self, attributes):
     23         BaseCharacterCreationStep.ApplyAttributes(self, attributes)
     24         self.colorPaletteWidth = CCColorPalette.COLORPALETTEWIDTH
     25         self.portraitSize = 128
     26         self.selectedPortrait = 0
     27         self.portraitAssetMenu = None
     28         self.portraitCont = None
     29         self.assetMenuPar = Container(parent=self.rightSide, pos=(20,
     30          115,
     31          MAXMENUSIZE,
     32          uicore.desktop.height), state=uiconst.UI_PICKCHILDREN, align=uiconst.TORIGHT)
     33         self.hintBox = Container(parent=self.assetMenuPar, pos=(MAXMENUSIZE,
     34          40,
     35          200,
     36          150), align=uiconst.TOPRIGHT, state=uiconst.UI_DISABLED)
     37         self.hintText = eveLabel.EveLabelMedium(text='', parent=self.hintBox, align=uiconst.TOTOP)
     38         self.UpdateLayout()
     39 
     40     def UpdateLayout(self):
     41         self.ReloadPortraitAssetMenu()
     42         self.ReloadPortraits()
     43         self.hintBox.left = self.assetMenuMainWidth + 20
     44 
     45     def ReloadPortraitAssetMenu(self):
     46         sm.GetService('cc').LogInfo('CharacterPortrait::ReloadPortraitAssetMenu')
     47         if self.portraitAssetMenu:
     48             self.portraitAssetMenu.Close()
     49         groups = [(ccConst.BACKGROUNDGROUP, ()), (ccConst.POSESGROUP, ()), (ccConst.LIGHTSGROUP, ())]
     50         rightSideWidth = self.rightSide.GetAbsoluteSize()[1]
     51         assetMenuWidth = max(min(MAXMENUSIZE + CCColorPalette.COLORPALETTEWIDTH, rightSideWidth - 32), 0)
     52         self.assetMenuMainWidth = assetMenuWidth - CCColorPalette.COLORPALETTEWIDTH
     53         self.portraitAssetMenu = CharCreationAssetMenu(parent=self.assetMenuPar, groups=groups, align=uiconst.CENTERTOP, width=assetMenuWidth, height=uicore.desktop.height)
     54         self.assetMenuPar.width = assetMenuWidth
     55 
     56     def SetHintText(self, modifier, hintText = ''):
     57         text = hintText
     58         if modifier in ccConst.HELPTEXTS:
     59             labelPath = ccConst.HELPTEXTS[modifier]
     60             text = localization.GetByLabel(labelPath)
     61         if text != self.hintText.text:
     62             self.hintText.text = text
     63 
     64     def ReloadPortraits(self):
     65         if self.portraitCont:
     66             self.portraitCont.Close()
     67         self.portraitCont = Container(name='portraitCont', parent=self.leftSide, align=uiconst.TOPLEFT, pos=(25,
     68          128,
     69          128,
     70          134 * ccConst.NUM_PORTRAITS - 6 + 44))
     71         self.facePortraits = [None] * ccConst.NUM_PORTRAITS
     72         for i in xrange(ccConst.NUM_PORTRAITS):
     73             if i == 0:
     74                 frameAlpha = 0.8
     75             else:
     76                 frameAlpha = 0.2
     77             portraitCont = Container(name='portraitCont1', parent=self.portraitCont, align=uiconst.TOTOP, pos=(0,
     78              0,
     79              0,
     80              self.portraitSize), padBottom=6, state=uiconst.UI_NORMAL)
     81             portraitCont.OnClick = (self.PickPortrait, i)
     82             portraitCont.OnDblClick = self.OnPortraitDblClick
     83             portraitCont.OnMouseEnter = (self.OnPortraitEnter, portraitCont)
     84             button = eveIcon.Icon(parent=portraitCont, icon=ccConst.ICON_CAM_IDLE, state=uiconst.UI_NORMAL, align=uiconst.TOPRIGHT, color=ccConst.COLOR75, left=6, top=6)
     85             button._idleIcon = ccConst.ICON_CAM_IDLE
     86             button._pressedIcon = ccConst.ICON_CAM_PRESSED
     87             button._imageIndex = i
     88             button.OnClick = (self.CameraButtonClick, button)
     89             button.OnMouseEnter = (self.GenericButtonEnter, button)
     90             button.OnMouseExit = (self.GenericButtonExit, button)
     91             button.OnMouseDown = (self.GenericButtonDown, button)
     92             button.OnMouseUp = (self.GenericButtonUp, button)
     93             frame = Frame(parent=portraitCont, color=ccConst.COLOR + (frameAlpha,))
     94             facePortrait = eveIcon.Icon(parent=portraitCont, align=uiconst.TOALL, state=uiconst.UI_DISABLED)
     95             Fill(parent=portraitCont, color=(0.0, 0.0, 0.0, 0.35))
     96             portraitCont.button = button
     97             portraitCont.frame = frame
     98             portraitCont.facePortrait = facePortrait
     99             portraitCont.hasPhoto = False
    100             self.facePortraits[i] = portraitCont
    101 
    102         for i in xrange(ccConst.NUM_PORTRAITS):
    103             if uicore.layer.charactercreation.controller.facePortraits[i] is not None:
    104                 photo = uicore.layer.charactercreation.controller.facePortraits[i]
    105                 cont = self.facePortraits[i]
    106                 cont.facePortrait.texture.atlasTexture = photo
    107                 cont.facePortrait.texture.atlasTexture.Reload()
    108                 cont.hasPhoto = True
    109                 cont.button.state = uiconst.UI_HIDDEN
    110                 if photo == uicore.layer.charactercreation.controller.activePortrait:
    111                     self.SetPortraitFocus(i)
    112 
    113         Button(parent=self.portraitCont, label=localization.GetByLabel('UI/CharacterCreation/ResetExpression'), align=uiconst.CENTERBOTTOM, func=self.ResetFacePose)
    114 
    115     def ResetFacePose(self, *args):
    116         info = self.GetInfo()
    117         self.charSvc.ResetFacePose(info.charID)
    118 
    119     def OnPortraitDblClick(self, *args):
    120         uicore.layer.charactercreation.controller.Approve()
    121 
    122     def PickPortrait(self, selectedNo):
    123         uicore.layer.charactercreation.controller.AnimateToStoredPortrait(selectedNo)
    124         self.SetPortraitFocus(selectedNo)
    125 
    126     def SetPortraitFocus(self, selectedNo, *args):
    127         self.selectedPortrait = selectedNo
    128         for portraitContainer in self.facePortraits:
    129             portraitContainer.frame.SetAlpha(0.2)
    130             portraitContainer.facePortrait.SetAlpha(0.3)
    131 
    132         frame = self.facePortraits[selectedNo].frame
    133         frame.SetAlpha(0.8)
    134         portrait = self.facePortraits[selectedNo].facePortrait
    135         portrait.SetAlpha(1.0)
    136         uicore.layer.charactercreation.controller.SetActivePortrait(selectedNo)
    137 
    138     def ValidateStepComplete(self):
    139         if not self.IsDollReady:
    140             return False
    141         if uicore.layer.charactercreation.controller.GetPortraitInfo(self.selectedPortrait) is None:
    142             self.CapturePortrait(self.selectedPortrait)
    143         return True
    144 
    145     def CapturePortrait(self, idx, *args):
    146         photo = uicore.layer.charactercreation.controller.CapturePortrait(idx)
    147         if photo:
    148             self.SetPortrait(photo)
    149             uicore.layer.charactercreation.controller.SetFacePortrait(photo, idx)
    150 
    151     def SetPortrait(self, photo, *args):
    152         if self.destroyed:
    153             return
    154         facePortraitCont = self.facePortraits[self.selectedPortrait]
    155         facePortraitCont.facePortrait.texture.atlasTexture = photo
    156         facePortraitCont.facePortrait.texture.atlasTexture.Reload()
    157         facePortraitCont.hasPhoto = True
    158 
    159     def OnPortraitEnter(self, portrait, *args):
    160         portrait.button.state = uiconst.UI_NORMAL
    161         portrait.mouseOverTimer = timerstuff.AutoTimer(33.0, self.CheckPortraitMouseOver, portrait)
    162 
    163     def CheckPortraitMouseOver(self, portrait, *args):
    164         if uicore.uilib.mouseOver is portrait or uicore.uilib.mouseOver.IsUnder(portrait):
    165             return
    166         portrait.mouseOverTimer = None
    167         if portrait.hasPhoto:
    168             portrait.button.state = uiconst.UI_HIDDEN
    169 
    170     def CameraButtonClick(self, button, *args):
    171         sm.StartService('audio').SendUIEvent(unicode('ui_icc_portrait_snapshot_play'))
    172         self.SetPortraitFocus(button._imageIndex)
    173         self.CapturePortrait(button._imageIndex)
    174 
    175     def GenericButtonDown(self, button, mouseBtn, *args):
    176         if mouseBtn == uiconst.MOUSELEFT:
    177             MapIcon(button, button._pressedIcon)
    178 
    179     def GenericButtonUp(self, button, *args):
    180         MapIcon(button, button._idleIcon)
    181 
    182     def GenericButtonEnter(self, button, *args):
    183         MapIcon(button, button._idleIcon)
    184 
    185     def GenericButtonExit(self, button, *args):
    186         MapIcon(button, button._idleIcon)
    187 
    188     def OnGraphicSettingsChanged(self, changes):
    189         if gfxsettings.UI_NCC_GREEN_SCREEN in changes:
    190             self.UpdateLayout()
    191         self.ReloadPortraitAssetMenu()