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

characterPortrait.py (9284B)


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