Пример #1
0
 def InitMovie(self):
     self.sr.movieCont = uiprimitives.Container(parent=self, name='movieCont', idx=0, align=uiconst.TOALL, state=uiconst.UI_DISABLED)
     x, y, contWidth, contHeight = self.sr.movieCont.GetAbsolute()
     dimWidth, dimHeight = self.GetVideoDimensions(contWidth, contHeight, 1280, 720)
     audioTracks = {'EN': 0,
      'DE': 1,
      'FR': 2,
      'RU': 3}
     audioTrack = audioTracks.get(str(prefs.languageID), 0)
     self.movie = StreamingVideoSprite(parent=self.sr.movieCont, pos=(0,
      0,
      dimWidth,
      dimHeight), align=uiconst.CENTER, videoPath=self.moviePath, audioTrack=audioTrack)
Пример #2
0
    def PlayIntro(self, videoPath):
        if not videoPath:
            return
        video = StreamingVideoSprite(parent=self,
                                     videoPath=videoPath,
                                     align=uiconst.TOALL,
                                     padding=(-128, -132, -128, -132),
                                     positionComponent=getattr(
                                         self.uiDesktop, 'positionComponent',
                                         None))
        while not video.isFinished:
            blue.synchro.Yield()

        video.Close()
        uicore.animations.FadeIn(self, duration=0.3)
Пример #3
0
 def Populate(self, path = None):
     self.sr.movieCont.Flush()
     uicontrols.Frame(parent=self.sr.movieCont, color=(1.0, 1.0, 1.0, 0.2), idx=0)
     dimWidth, dimHeight = self.GetSize(self.movieWidth, self.movieHeight)
     if path is not None:
         moviePath = path
     else:
         moviePath = str(self.node.resPath)
     self.path = moviePath
     self.movie = StreamingVideoSprite(parent=self.sr.movieCont, width=dimWidth, height=dimHeight, align=uiconst.CENTER, state=uiconst.UI_DISABLED, videoPath=moviePath)
Пример #4
0
 def Play(self, data):
     if data is None:
         return
     self.PlayIntro(data.get('introVideoPath', None))
     self.leftCont = uiprimitives.Container(parent=self,
                                            align=uiconst.TOLEFT,
                                            width=640,
                                            padRight=10)
     self.rightCont = uicls.ScreenFrame5(parent=self, align=uiconst.TOALL)
     headingCont = uiprimitives.Container(parent=self.leftCont,
                                          align=uiconst.TOTOP,
                                          height=100,
                                          bgColor=(0.35, 0.35, 0.35, 1.0))
     uicontrols.Label(parent=headingCont,
                      text=data.headingText,
                      fontsize=80,
                      align=uiconst.CENTER,
                      color=util.Color.WHITE,
                      uppercase=True,
                      bold=True)
     blue.pyos.synchro.SleepWallclock(300)
     uicls.ScreenHeading2(parent=self.leftCont,
                          appear=True,
                          align=uiconst.TOTOP,
                          text=data.subHeadingText)
     frame = uicls.ScreenFrame4(parent=self.leftCont,
                                align=uiconst.TOALL,
                                appear=True,
                                padTop=10)
     frame.mainCont.padLeft = 30
     frame.mainCont.padTop = 20
     uicontrols.Label(name='charNameLabel',
                      parent=frame.mainCont,
                      text=cfg.eveowners.Get(data.charID).name,
                      fontsize=35,
                      left=290)
     pictureCont = uiprimitives.Container(align=uiconst.TOPLEFT,
                                          parent=frame.mainCont,
                                          pos=(0, 8, 256, 256))
     uicontrols.Frame(parent=pictureCont, color=util.Color.WHITE)
     uiutil.GetOwnerLogo(pictureCont, data.charID, size=256)
     uicontrols.EveLabelMedium(name='mainTextLabel',
                               parent=frame.mainCont,
                               pos=(290, 45, 300, 0),
                               text=data.mainText)
     video = StreamingVideoSprite(parent=self.rightCont.mainCont,
                                  videoPath=data.careerVideoPath,
                                  align=uiconst.TOALL,
                                  repeat=True,
                                  positionComponent=getattr(
                                      self.uiDesktop, 'positionComponent',
                                      None))
     while not video.isFinished:
         blue.synchro.Yield()
Пример #5
0
    def _PlayVideo(self, introPath, outroPath, color):
        self.videoCont.Flush()
        videoSprite = StreamingVideoSprite(parent=self.videoCont,
                                           align=uiconst.TOALL,
                                           spriteEffect=trinity.TR2_SFX_COPY,
                                           videoPath=introPath,
                                           color=color)
        while not videoSprite.isFinished:
            blue.synchro.Yield()

        blue.synchro.SleepWallclock(3000)
        videoSprite.Close()
        videoSprite = StreamingVideoSprite(parent=self.videoCont,
                                           align=uiconst.TOALL,
                                           spriteEffect=trinity.TR2_SFX_COPY,
                                           videoPath=outroPath,
                                           color=color)
        while not videoSprite.isFinished:
            blue.synchro.Yield()

        uicore.animations.FadeOut(videoSprite, callback=videoSprite.Close)
Пример #6
0
 def _animate_icon_glow(self):
     animation_video_container = Container(
         parent=self.reward_item_icon_glow_container,
         name='animation_video_container',
         align=uiconst.CENTER,
         width=ICON_GLOW_ANIMATION_SIZE,
         height=ICON_GLOW_ANIMATION_SIZE)
     StreamingVideoSprite(bgParent=animation_video_container,
                          name='animation_video',
                          videoPath=ICON_GLOW_ANIMATION_VIDEO_PATH,
                          videoLoop=True,
                          spriteEffect=trinity.TR2_SFX_COPY)
Пример #7
0
 def Play(self, data):
     if data is None:
         return
     self.PlayIntro(data.get('introVideoPath', None))
     frame = uicls.ScreenFrame4(parent=self, align=uiconst.TOALL)
     blue.pyos.synchro.SleepWallclock(300)
     video = StreamingVideoSprite(parent=frame.mainCont,
                                  videoPath=data.videoPath,
                                  align=uiconst.TOALL,
                                  positionComponent=getattr(
                                      self.uiDesktop, 'positionComponent',
                                      None))
     uicore.animations.BlinkIn(frame.mainCont, loops=4)
     while not video.isFinished:
         blue.synchro.Yield()
Пример #8
0
 def ApplyAttributes(self, attributes):
     uicontrols.Window.ApplyAttributes(self, attributes)
     sm.RegisterNotify(self)
     self.tilesByTileCoord = {}
     self.linesByTileCoords = {}
     self.utilityElements = []
     self.accessibleTiles = []
     self.hasGameEnded = False
     self.bottomCont = uiprimitives.Container(name='bottomCont',
                                              parent=self.sr.main,
                                              align=uiconst.TOBOTTOM,
                                              height=110)
     self.tileHintLabel = uicontrols.Label(name='tileHintLabel',
                                           parent=self.bottomCont,
                                           align=uiconst.BOTTOMRIGHT,
                                           pos=(15, 15, 220, 0),
                                           fontsize=10)
     self.utilityElementContainer = uicontrols.ContainerAutoSize(
         name='utilityElementContainer',
         parent=self.bottomCont,
         align=uiconst.CENTERBOTTOM,
         state=uiconst.UI_PICKCHILDREN,
         opacity=1.0,
         height=50,
         top=10)
     self.virusInfo = hackingUI.VirusInfo(parent=self.bottomCont,
                                          left=15,
                                          top=10,
                                          opacity=0.0)
     self.boardTransform = uiprimitives.Transform(name='boardTransform',
                                                  parent=self.sr.main,
                                                  align=uiconst.TOALL,
                                                  state=uiconst.UI_NORMAL,
                                                  scalingCenter=(0.5, 0.5))
     self.boardContainer = uiprimitives.Container(
         name='boardContainer',
         parent=self.boardTransform,
         align=uiconst.TOPLEFT,
         opacity=0.0)
     self.backgroundVideo = StreamingVideoSprite(
         bgParent=self.sr.maincontainer,
         videoPath='res:/video/hacking/bgLoop_alpha.webm',
         videoLoop=True,
         spriteEffect=trinity.TR2_SFX_COPY,
         color=hackingUIConst.COLOR_WINDOW_BG,
         opacity=0.0)
     sm.GetService('audio').SendUIEvent('minigame_start')
Пример #9
0
class Intro(uicls.LayerCore):
    __guid__ = 'form.Intro'
    __notifyevents__ = ['OnSetDevice']

    def OnCloseView(self):
        sm.GetService('viewState').LogInfo('intro.OnCloseView')
        if self.movie:
            self.movie.Pause()
        self.movie = None
        sm.GetService('audio').SendUIEvent('music_login_resume')
        sm.GetService('ui').ForceCursorUpdate()
        self.Flush()

    def OnOpenView(self):
        if not sm.GetService('connection').IsConnected():
            return
        self.opened = 0
        self.movie = None
        self.sr.movieCont = None
        self.sr.subtitleCont = None
        self.subtitles = None
        self.fadeTime = 125
        self.moviePath = 'res:/video/origins_intro.webm'
        if blue.paths.FileExistsLocally(self.moviePath):
            self.InitMovie()
            self.InitSubtitles()
            sm.StartService('audio').SendUIEvent('music_login_pause')
            self.PlayMovie()
        else:
            self.StopIntro()
        self.opened = 1

    def OnSetDevice(self):
        dimWidth, dimHeight = self.GetVideoDimensions(uicore.desktop.width, uicore.desktop.height, 1280, 720)
        self.movie.width = dimWidth
        self.movie.height = dimHeight

    def InitMovie(self):
        self.sr.movieCont = uiprimitives.Container(parent=self, name='movieCont', idx=0, align=uiconst.TOALL, state=uiconst.UI_DISABLED)
        x, y, contWidth, contHeight = self.sr.movieCont.GetAbsolute()
        dimWidth, dimHeight = self.GetVideoDimensions(contWidth, contHeight, 1280, 720)
        audioTracks = {'EN': 0,
         'DE': 1,
         'FR': 2,
         'RU': 3}
        audioTrack = audioTracks.get(str(prefs.languageID), 0)
        self.movie = StreamingVideoSprite(parent=self.sr.movieCont, pos=(0,
         0,
         dimWidth,
         dimHeight), align=uiconst.CENTER, videoPath=self.moviePath, audioTrack=audioTrack)

    def PlayMovie(self):
        self.movie.Play()
        uthread.new(self.WatchMovie)

    def InitSubtitles(self):
        x, y, contWidth, contHeight = self.sr.movieCont.GetAbsolute()
        subsHeight = int(float(contHeight) * 0.1)
        self.sr.subtitleCont = uiprimitives.Container(parent=self.sr.movieCont, name='subtitleCont', idx=0, align=uiconst.TOBOTTOM, state=uiconst.UI_DISABLED, height=subsHeight)
        self.sr.subtitleCont.Flush()
        self.subtitles = []
        endPadding = 3 * self.fadeTime
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part1'), 2510, 4350 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part2'), 4955, 7090 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part3'), 15490, 19125 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part4'), 21925, 23425 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part5'), 24925, 27815 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part6'), 30320, 32120 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part7'), 33425, 37720 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part8'), 39775, 43745 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part9'), 44990, 47290 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part10'), 59755, 64690 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part11'), 66560, 69825 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part12'), 71490, 77490 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part13'), 79460, 81990 + self.fadeTime))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part14'), 82225, 86360 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part15'), 90160, 94590 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part16'), 97290, 100060 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part17'), 102760, 107690 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part18'), 118825, 124560 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part19'), 127160, 129590 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part20'), 132790, 137725 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part21'), 140660, 145060 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part22'), 146460, 149160 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part23'), 150325, 153525 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part24'), 155000, 157990 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part25'), 159660, 163725 + endPadding))
        self.subtitles.append((localization.GetByLabel('UI/Login/IntroMovie/OriginsMovieSubtitles/Part26'), 169360, 177360 + endPadding))

    def UpdateSubtitles(self):
        x, y, contWidth, contHeight = self.sr.movieCont.GetAbsolute()
        subsWidth = int(float(contWidth) * 0.6)
        currentTime = self.GetCurrentMovieTime()
        self.sr.subtitleCont.Flush()
        for subtitle in self.subtitles:
            if currentTime >= subtitle[1] and currentTime <= subtitle[2]:
                framesFromEnd = min(currentTime - subtitle[1], subtitle[2] - currentTime)
                alpha = min(1.0, float(framesFromEnd) / self.fadeTime)
                uicontrols.EveCaptionLarge(text='<center>%s' % subtitle[0], parent=self.sr.subtitleCont, color=(0.75,
                 0.75,
                 0.75,
                 alpha), align=uiconst.TOALL, bold=False, state=uiconst.UI_DISABLED)

    def GetCurrentMovieTime(self):
        return (self.movie.mediaTime or 0) / 1000000

    def WatchMovie(self):
        while not self.destroyed:
            if getattr(self, 'movie', None):
                if self.movie.isFinished:
                    self.StopIntro()
                    return
                self.UpdateSubtitles()
            else:
                return
            blue.pyos.synchro.SleepWallclock(20)

    def GetVideoDimensions(self, contWidth, contHeight, vidResWidth, vidResHeight):
        dimWidth = vidResWidth
        dimHeight = vidResHeight
        contFactor = float(contWidth) / float(contHeight)
        vidResFactor = float(vidResWidth) / float(vidResHeight)
        if vidResFactor > contFactor:
            widthFactor = float(contWidth) / float(vidResWidth)
            dimWidth *= widthFactor
            dimHeight *= widthFactor
        elif vidResFactor < contFactor:
            heightFactor = float(contHeight) / float(vidResHeight)
            dimWidth *= heightFactor
            dimHeight *= heightFactor
        else:
            dimWidth = contWidth
            dimHeight = contHeight
        return (int(dimWidth), int(dimHeight))

    def LoadNextView(self):
        while sm.GetService('viewState').HasActiveTransition():
            blue.pyos.synchro.SleepWallclock(500)

        if sm.GetService('cc').GetCharactersToSelect():
            uthread.pool('viewState::ActivateView::charsel', sm.GetService('viewState').ActivateView, 'charsel')
        else:
            uthread.pool('viewState::ActivateView::charsel', sm.GetService('viewState').ActivateView, 'charactercreation')

    def StopIntro(self):
        settings.public.generic.Set('showintro2', 0)
        uthread.new(self.LoadNextView)

    def OnEsc(self):
        sm.GetService('viewState').LogInfo('OnEsc called')
        self.StopIntro()
Пример #10
0
 def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     self.SetTopparentHeight(0)
     self.SetWndIcon('res:/ui/texture/icons/bigplay_64.png')
     self._stopUpdate = False
     self._onFinish = None
     self._subtitles = None
     self._finished = False
     self.bottomContainer = Container(name='bottomContainer',
                                      parent=self.sr.main,
                                      align=uiconst.TOBOTTOM,
                                      height=16,
                                      padding=const.defaultPadding)
     self.layoutAreaParent = Container(parent=self.sr.main,
                                       padding=const.defaultPadding)
     self.layoutAreaParent._OnSizeChange_NoBlock = self.RecalcLayout
     self.layoutArea = Container(parent=self.layoutAreaParent,
                                 align=uiconst.CENTER,
                                 width=100,
                                 height=100)
     self.video = StreamingVideoSprite(parent=self.layoutArea,
                                       align=uiconst.TOALL)
     self.video.OnVideoSizeAvailable = self.RecalcLayout
     self.video.OnVideoFinished = self._OnVideoFinished
     self.playPauseBtn = ButtonIcon(parent=self.bottomContainer,
                                    func=self.Play,
                                    align=uiconst.TOLEFT)
     self.muteBtn = ButtonIcon(parent=self.bottomContainer,
                               func=self.Mute,
                               align=uiconst.TOLEFT)
     self.volumeSlider = Slider(parent=self.bottomContainer,
                                width=48,
                                minValue=0,
                                maxValue=100,
                                startValue=100,
                                showLabel=False,
                                onsetvaluefunc=self.SetVolume,
                                align=uiconst.TOLEFT)
     self.volume = settings.user.ui.Get('videoPlayerVolume', 100)
     self.volumeSlider.SetValue(self.volume,
                                updateHandle=True,
                                triggerCallback=False)
     self.subtitlesBtn = ButtonIcon(parent=self.bottomContainer,
                                    func=self.SwitchSubtitles,
                                    align=uiconst.TORIGHT)
     self.showSubtitles = True
     positionContainer = Container(parent=self.bottomContainer,
                                   align=uiconst.TOALL,
                                   padding=6)
     self.positionFill = Fill(parent=Container(parent=positionContainer,
                                               state=uiconst.UI_DISABLED),
                              name='progressFill',
                              align=uiconst.TOLEFT_PROP,
                              color=(0.1804, 0.5412, 0.6392, 1))
     self.downloadedFill = Fill(parent=Container(parent=positionContainer,
                                                 state=uiconst.UI_DISABLED),
                                name='downloadFill',
                                align=uiconst.TOLEFT_PROP,
                                color=(0.4667, 0.7529, 0.8392, 1))
     Fill(parent=positionContainer,
          align=uiconst.TOALL,
          color=(1.0, 1.0, 1.0, 0.3))
     self.followUpContainer = Container(parent=self.layoutAreaParent,
                                        align=uiconst.TOALL,
                                        state=uiconst.UI_HIDDEN)
     self.sr.subtitleCont = Container(parent=self.layoutArea,
                                      name='subtitleCont',
                                      idx=0,
                                      align=uiconst.TOBOTTOM_NOPUSH,
                                      state=uiconst.UI_DISABLED,
                                      height=100)
     self.sr.subtitleCont.Flush()
     self.UpdateLayoutArea()
     uthread2.StartTasklet(self._UpdatePosition)
Пример #11
0
class VideoPlayerWindow(Window):
    default_caption = 'Video'
    default_minSize = (500, 400)
    default_windowID = 'VideoPlayer'

    def ApplyAttributes(self, attributes):
        Window.ApplyAttributes(self, attributes)
        self.SetTopparentHeight(0)
        self.SetWndIcon('res:/ui/texture/icons/bigplay_64.png')
        self._stopUpdate = False
        self._onFinish = None
        self._subtitles = None
        self._finished = False
        self.bottomContainer = Container(name='bottomContainer',
                                         parent=self.sr.main,
                                         align=uiconst.TOBOTTOM,
                                         height=16,
                                         padding=const.defaultPadding)
        self.layoutAreaParent = Container(parent=self.sr.main,
                                          padding=const.defaultPadding)
        self.layoutAreaParent._OnSizeChange_NoBlock = self.RecalcLayout
        self.layoutArea = Container(parent=self.layoutAreaParent,
                                    align=uiconst.CENTER,
                                    width=100,
                                    height=100)
        self.video = StreamingVideoSprite(parent=self.layoutArea,
                                          align=uiconst.TOALL)
        self.video.OnVideoSizeAvailable = self.RecalcLayout
        self.video.OnVideoFinished = self._OnVideoFinished
        self.playPauseBtn = ButtonIcon(parent=self.bottomContainer,
                                       func=self.Play,
                                       align=uiconst.TOLEFT)
        self.muteBtn = ButtonIcon(parent=self.bottomContainer,
                                  func=self.Mute,
                                  align=uiconst.TOLEFT)
        self.volumeSlider = Slider(parent=self.bottomContainer,
                                   width=48,
                                   minValue=0,
                                   maxValue=100,
                                   startValue=100,
                                   showLabel=False,
                                   onsetvaluefunc=self.SetVolume,
                                   align=uiconst.TOLEFT)
        self.volume = settings.user.ui.Get('videoPlayerVolume', 100)
        self.volumeSlider.SetValue(self.volume,
                                   updateHandle=True,
                                   triggerCallback=False)
        self.subtitlesBtn = ButtonIcon(parent=self.bottomContainer,
                                       func=self.SwitchSubtitles,
                                       align=uiconst.TORIGHT)
        self.showSubtitles = True
        positionContainer = Container(parent=self.bottomContainer,
                                      align=uiconst.TOALL,
                                      padding=6)
        self.positionFill = Fill(parent=Container(parent=positionContainer,
                                                  state=uiconst.UI_DISABLED),
                                 name='progressFill',
                                 align=uiconst.TOLEFT_PROP,
                                 color=(0.1804, 0.5412, 0.6392, 1))
        self.downloadedFill = Fill(parent=Container(parent=positionContainer,
                                                    state=uiconst.UI_DISABLED),
                                   name='downloadFill',
                                   align=uiconst.TOLEFT_PROP,
                                   color=(0.4667, 0.7529, 0.8392, 1))
        Fill(parent=positionContainer,
             align=uiconst.TOALL,
             color=(1.0, 1.0, 1.0, 0.3))
        self.followUpContainer = Container(parent=self.layoutAreaParent,
                                           align=uiconst.TOALL,
                                           state=uiconst.UI_HIDDEN)
        self.sr.subtitleCont = Container(parent=self.layoutArea,
                                         name='subtitleCont',
                                         idx=0,
                                         align=uiconst.TOBOTTOM_NOPUSH,
                                         state=uiconst.UI_DISABLED,
                                         height=100)
        self.sr.subtitleCont.Flush()
        self.UpdateLayoutArea()
        uthread2.StartTasklet(self._UpdatePosition)

    def _OnVideoFinished(self):
        for each in self.followUpContainer.children[:]:
            each.Close()

        self._finished = True
        self.playPauseBtn.SetTexturePath('res:/ui/texture/icons/replay.png')
        if self._onFinish:
            self.followUpContainer.SetState(uiconst.UI_NORMAL)
            self.layoutArea.SetState(uiconst.UI_HIDDEN)
            self._onFinish(self.followUpContainer)

    def PlayVideo(self, path, title=None, subtitles=None, onFinish=None):
        self.playPauseBtn.SetTexturePath('res:/ui/texture/icons/pause.png')
        self.muteBtn.SetTexturePath('res:/ui/texture/icons/73_16_35.png')
        self.subtitlesBtn.SetTexturePath('res:/ui/texture/icons/73_16_10.png')
        self.layoutArea.SetState(uiconst.UI_NORMAL)
        self.followUpContainer.SetState(uiconst.UI_HIDDEN)
        self.video.SetVideoPath(path)
        self.video.SetVolume(float(self.volume) / 100.0)
        self.volumeSlider.SetValue(self.volume,
                                   updateHandle=True,
                                   triggerCallback=False)
        self.SetCaption(
            title if title is not None else VideoPlayerWindow.default_caption)
        self._onFinish = onFinish
        self._finished = False
        self._replayArgs = (path, title, subtitles, onFinish)
        if subtitles is None:
            self._subtitles = None
        else:
            self._subtitles = Subtitles(subtitles)

    def Close(self, *args, **kwds):
        self._stopUpdate = True
        self.video = None
        Window.Close(self, *args, **kwds)

    def _UpdatePosition(self):
        while not self._stopUpdate:
            if self.video:
                duration = float((self.video.duration or 1) / 1000000)
                if duration == 0:
                    duration = 1
                mediaTime = min(
                    float((self.video.mediaTime or 0) / 1000000) / duration, 1)
                downloadedTime = min(
                    float(
                        (self.video.downloadedTime or 0) / 1000000) / duration,
                    1)
                if mediaTime == 0:
                    self.positionFill.Hide()
                else:
                    self.positionFill.Show()
                    self.positionFill.width = mediaTime
                if downloadedTime == 0:
                    self.downloadedFill.Hide()
                else:
                    self.downloadedFill.Show()
                    self.downloadedFill.width = downloadedTime
                self._UpdateSubtitles()
            uthread2.Sleep(0.1)

    def _UpdateSubtitles(self):
        if self._subtitles is None or not self.showSubtitles:
            return
        currentTime = self.video.mediaTime or 0
        currentTime /= 1000000
        self.sr.subtitleCont.Flush()
        text = self._subtitles.GetSubtitle(currentTime)
        if text is not None:
            EveCaptionLarge(text=u'<center>%s' % text,
                            parent=self.sr.subtitleCont,
                            color=(0.75, 0.75, 0.75, 1),
                            align=uiconst.TOBOTTOM_NOPUSH,
                            bold=False,
                            state=uiconst.UI_DISABLED)
            l = EveCaptionLarge(text=u'<center>%s' % text,
                                parent=self.sr.subtitleCont,
                                color=(0, 0, 0, 1),
                                align=uiconst.TOBOTTOM,
                                bold=False,
                                state=uiconst.UI_DISABLED)
            l.renderObject.spriteEffect = trinity.TR2_SFX_GLOW

    def UpdateLayoutArea(self):
        size = self.video.GetVideoSize()
        if not size:
            return
        areaWidth, areaHeight = self.layoutAreaParent.GetAbsoluteSize()
        xFitScale = areaWidth / float(size[0])
        yFitScale = areaHeight / float(size[1])
        scaling = min(xFitScale, yFitScale)
        self.layoutArea.width = int(size[0] * scaling)
        self.layoutArea.height = int(size[1] * scaling)

    def RecalcLayout(self, *args):
        self.UpdateLayoutArea()

    def Play(self, *args):
        if self._finished:
            self._finished = False
            self.PlayVideo(*self._replayArgs)
        elif self.video.isPaused:
            self.video.Play()
            self.playPauseBtn.SetTexturePath('res:/ui/texture/icons/pause.png')
        else:
            self.video.Pause()
            self.playPauseBtn.SetTexturePath('res:/ui/texture/icons/play.png')

    def Mute(self, *args):
        if self.video.isMuted:
            self.video.UnmuteAudio()
            self.volumeSlider.SetValue(self.volume,
                                       updateHandle=True,
                                       triggerCallback=False)
            self.muteBtn.SetTexturePath('res:/ui/texture/icons/73_16_35.png')
        else:
            self.video.MuteAudio()
            self.volumeSlider.SetValue(0,
                                       updateHandle=True,
                                       triggerCallback=False)
            self.muteBtn.SetTexturePath('res:/ui/texture/icons/73_16_37.png')

    def SetVolume(self, slider):
        self.video.SetVolume(float(slider.value) / 100.0)
        self.volume = slider.value
        settings.user.ui.Set('videoPlayerVolume', self.volume)
        if self.volume:
            self.muteBtn.SetTexturePath('res:/ui/texture/icons/73_16_35.png')

    def SwitchSubtitles(self):
        self.showSubtitles = not self.showSubtitles
        if self.showSubtitles:
            self.subtitlesBtn.opacity = 1.0
        else:
            self.subtitlesBtn.opacity = 0.2
            self.sr.subtitleCont.Flush()
Пример #12
0
    def ApplyAttributes(self, attributes):
        self.raceInfo = {}
        self.bloodlineInfo = {}
        self.movieStateCheckRunning = 0
        self.padValue = 6
        self.raceID = None
        self.hoveredRaceID = None
        BaseCharacterCreationStep.ApplyAttributes(self, attributes)
        info = self.GetInfo()
        if uicore.desktop.width <= 1360:
            fontsize = 12
        else:
            fontsize = 14
        self.sr.raceInfoCont = uiprimitives.Container(
            name='raceInfoCont',
            parent=self.sr.uiContainer,
            align=uiconst.CENTERTOP,
            width=600,
            height=uicore.desktop.height,
            state=uiconst.UI_PICKCHILDREN)
        self.sr.textCont = uiprimitives.Container(name='raceCont',
                                                  parent=self.sr.raceInfoCont,
                                                  align=uiconst.TOTOP,
                                                  pos=(0, 38, 0, 20),
                                                  state=uiconst.UI_NORMAL)
        header = uicls.CCLabel(
            text=localization.GetByLabel('UI/CharacterCreation/RaceSelection'),
            name='header',
            parent=self.sr.textCont,
            align=uiconst.CENTERTOP,
            uppercase=1,
            letterspace=2,
            color=(0.9, 0.9, 0.9, 0.8),
            fontsize=22,
            bold=False)
        self.sr.raceCont = uiprimitives.Container(name='raceCont',
                                                  parent=self.sr.raceInfoCont,
                                                  align=uiconst.TOTOP,
                                                  pos=(0, 40, 0, 80),
                                                  state=uiconst.UI_HIDDEN)
        self.raceSprite = uiprimitives.Sprite(name='raceSprite',
                                              parent=self.sr.raceCont,
                                              align=uiconst.CENTER,
                                              state=uiconst.UI_DISABLED,
                                              texturePath=self.raceHeaderPath,
                                              pos=(0, 0, 512, 128))
        uiprimitives.Container(name='push',
                               parent=self.sr.raceInfoCont,
                               align=uiconst.TOTOP,
                               pos=(0, 0, 0, 15),
                               state=uiconst.UI_DISABLED)
        self.sr.movieCont = uiprimitives.Container(name='movieCont',
                                                   parent=self.sr.raceInfoCont,
                                                   align=uiconst.TOTOP,
                                                   pos=(0, 0, 0, 338),
                                                   state=uiconst.UI_HIDDEN)
        self.sr.raceTextCont = uiprimitives.Container(
            name='raceTextCont',
            parent=self.sr.raceInfoCont,
            align=uiconst.TOTOP,
            padding=(0, 15, 0, self.padValue),
            state=uiconst.UI_HIDDEN)
        self.sr.raceText = uicls.CCLabel(parent=self.sr.raceTextCont,
                                         fontsize=fontsize,
                                         align=uiconst.TOPLEFT,
                                         text='',
                                         letterspace=0,
                                         top=0,
                                         pos=(0, 0, 600, 0),
                                         bold=0,
                                         color=ccConst.COLOR75)
        self.sr.buttonCont = uiprimitives.Container(parent=self.sr.uiContainer,
                                                    align=uiconst.CENTERBOTTOM,
                                                    pos=(0, 60, 512, 128))
        self.raceBtns = []
        for race in sm.GetService('cc').GetRaceData(shuffleFirstTime=True):
            raceBtn = RaceButton(name='raceBtn',
                                 parent=self.sr.buttonCont,
                                 align=uiconst.TOLEFT,
                                 pos=(0, 0, 128, 128),
                                 raceID=race.raceID,
                                 mouseExitCallback=self.ResetHoverRaceID)
            btnName = 'raceBtn_%s' % race.raceID
            self.raceBtns.append(raceBtn)
            setattr(self.sr, btnName, raceBtn)
            if info.raceID and info.raceID == race.raceID:
                raceBtn.Select()

        if info.raceID:
            self.raceID = info.raceID
            self.UpdateRaceHeader(info.raceID)
            self.GetRaceText()
        uicontrols.Frame(parent=self.sr.movieCont, color=(1.0, 1.0, 1.0, 0.2))
        self.sr.racialImage = uiprimitives.Sprite(name='racialImage',
                                                  parent=self.sr.movieCont,
                                                  align=uiconst.TOALL,
                                                  state=uiconst.UI_DISABLED)
        self.sr.movieCont.OnMouseEnter = self.OnMovieEnter
        self.movie = StreamingVideoSprite(parent=self.sr.movieCont,
                                          pos=(0, 0, 600, 338),
                                          videoPath=self.racialMovies.get(
                                              info.raceID, ''),
                                          videoAutoPlay=False)
        self.movie.display = False
        self.sr.movieControlCont = uiprimitives.Container(
            name='controlCont',
            parent=self.sr.movieCont,
            align=uiconst.CENTERBOTTOM,
            pos=(0, 0, 60, 22),
            idx=0,
            state=uiconst.UI_HIDDEN)
        uiprimitives.Fill(parent=self.sr.movieControlCont,
                          padding=(0, 0, 0, 1),
                          color=(0, 0, 0, 0.3))
        self.UpdateLayout()
        buttons = [('playpPauseBtn', 4, 'ui_73_16_225', self.ClickPlayPause),
                   ('soundBtn', 40, 'ui_73_16_230', self.ClickSound),
                   ('noSoundBtn', 40, 'ui_38_16_111', self.ClickSound)]
        for name, left, iconPath, function in buttons:
            icon = uicontrols.Icon(parent=self.sr.movieControlCont,
                                   align=uiconst.TOPLEFT,
                                   state=uiconst.UI_NORMAL,
                                   pos=(left, 2, 16, 16),
                                   icon=iconPath,
                                   idx=0)
            icon.OnClick = function
            icon.OnMouseEnter = (self.MouseOverButton, icon)
            icon.OnMouseExit = (self.MouseExitButton, icon)
            icon.SetAlpha(0.5)
            self.sr.Set(name, icon)

        self.sr.noSoundBtn.state = uiconst.UI_HIDDEN
        self.setupDone = 1
        self.TryPlayMovie()
Пример #13
0
class RaceStep(BaseCharacterCreationStep):
    __guid__ = 'uicls.RaceStep'
    stepID = ccConst.RACESTEP
    racialMovies = {
        const.raceCaldari: 'res:/video/charactercreation/caldari.webm',
        const.raceMinmatar: 'res:/video/charactercreation/minmatar.webm',
        const.raceAmarr: 'res:/video/charactercreation/amarr.webm',
        const.raceGallente: 'res:/video/charactercreation/gallente.webm'
    }
    racialMusic = {
        const.raceCaldari: 'wise:/music_switch_race_caldari',
        const.raceMinmatar: 'wise:/music_switch_race_minmatar',
        const.raceAmarr: 'wise:/music_switch_race_amarr',
        const.raceGallente: 'wise:/music_switch_race_gallente',
        None: 'music_switch_race_norace'
    }
    raceColorCodes = {
        (0, 0, 1, 1): const.raceCaldari,
        (1, 0, 0, 1): const.raceMinmatar,
        (1, 1, 0, 1): const.raceAmarr,
        (0, 1, 0, 1): const.raceGallente
    }

    def ApplyAttributes(self, attributes):
        self.raceInfo = {}
        self.bloodlineInfo = {}
        self.movieStateCheckRunning = 0
        self.padValue = 6
        self.raceID = None
        self.hoveredRaceID = None
        BaseCharacterCreationStep.ApplyAttributes(self, attributes)
        info = self.GetInfo()
        if uicore.desktop.width <= 1360:
            fontsize = 12
        else:
            fontsize = 14
        self.sr.raceInfoCont = uiprimitives.Container(
            name='raceInfoCont',
            parent=self.sr.uiContainer,
            align=uiconst.CENTERTOP,
            width=600,
            height=uicore.desktop.height,
            state=uiconst.UI_PICKCHILDREN)
        self.sr.textCont = uiprimitives.Container(name='raceCont',
                                                  parent=self.sr.raceInfoCont,
                                                  align=uiconst.TOTOP,
                                                  pos=(0, 38, 0, 20),
                                                  state=uiconst.UI_NORMAL)
        header = uicls.CCLabel(
            text=localization.GetByLabel('UI/CharacterCreation/RaceSelection'),
            name='header',
            parent=self.sr.textCont,
            align=uiconst.CENTERTOP,
            uppercase=1,
            letterspace=2,
            color=(0.9, 0.9, 0.9, 0.8),
            fontsize=22,
            bold=False)
        self.sr.raceCont = uiprimitives.Container(name='raceCont',
                                                  parent=self.sr.raceInfoCont,
                                                  align=uiconst.TOTOP,
                                                  pos=(0, 40, 0, 80),
                                                  state=uiconst.UI_HIDDEN)
        self.raceSprite = uiprimitives.Sprite(name='raceSprite',
                                              parent=self.sr.raceCont,
                                              align=uiconst.CENTER,
                                              state=uiconst.UI_DISABLED,
                                              texturePath=self.raceHeaderPath,
                                              pos=(0, 0, 512, 128))
        uiprimitives.Container(name='push',
                               parent=self.sr.raceInfoCont,
                               align=uiconst.TOTOP,
                               pos=(0, 0, 0, 15),
                               state=uiconst.UI_DISABLED)
        self.sr.movieCont = uiprimitives.Container(name='movieCont',
                                                   parent=self.sr.raceInfoCont,
                                                   align=uiconst.TOTOP,
                                                   pos=(0, 0, 0, 338),
                                                   state=uiconst.UI_HIDDEN)
        self.sr.raceTextCont = uiprimitives.Container(
            name='raceTextCont',
            parent=self.sr.raceInfoCont,
            align=uiconst.TOTOP,
            padding=(0, 15, 0, self.padValue),
            state=uiconst.UI_HIDDEN)
        self.sr.raceText = uicls.CCLabel(parent=self.sr.raceTextCont,
                                         fontsize=fontsize,
                                         align=uiconst.TOPLEFT,
                                         text='',
                                         letterspace=0,
                                         top=0,
                                         pos=(0, 0, 600, 0),
                                         bold=0,
                                         color=ccConst.COLOR75)
        self.sr.buttonCont = uiprimitives.Container(parent=self.sr.uiContainer,
                                                    align=uiconst.CENTERBOTTOM,
                                                    pos=(0, 60, 512, 128))
        self.raceBtns = []
        for race in sm.GetService('cc').GetRaceData(shuffleFirstTime=True):
            raceBtn = RaceButton(name='raceBtn',
                                 parent=self.sr.buttonCont,
                                 align=uiconst.TOLEFT,
                                 pos=(0, 0, 128, 128),
                                 raceID=race.raceID,
                                 mouseExitCallback=self.ResetHoverRaceID)
            btnName = 'raceBtn_%s' % race.raceID
            self.raceBtns.append(raceBtn)
            setattr(self.sr, btnName, raceBtn)
            if info.raceID and info.raceID == race.raceID:
                raceBtn.Select()

        if info.raceID:
            self.raceID = info.raceID
            self.UpdateRaceHeader(info.raceID)
            self.GetRaceText()
        uicontrols.Frame(parent=self.sr.movieCont, color=(1.0, 1.0, 1.0, 0.2))
        self.sr.racialImage = uiprimitives.Sprite(name='racialImage',
                                                  parent=self.sr.movieCont,
                                                  align=uiconst.TOALL,
                                                  state=uiconst.UI_DISABLED)
        self.sr.movieCont.OnMouseEnter = self.OnMovieEnter
        self.movie = StreamingVideoSprite(parent=self.sr.movieCont,
                                          pos=(0, 0, 600, 338),
                                          videoPath=self.racialMovies.get(
                                              info.raceID, ''),
                                          videoAutoPlay=False)
        self.movie.display = False
        self.sr.movieControlCont = uiprimitives.Container(
            name='controlCont',
            parent=self.sr.movieCont,
            align=uiconst.CENTERBOTTOM,
            pos=(0, 0, 60, 22),
            idx=0,
            state=uiconst.UI_HIDDEN)
        uiprimitives.Fill(parent=self.sr.movieControlCont,
                          padding=(0, 0, 0, 1),
                          color=(0, 0, 0, 0.3))
        self.UpdateLayout()
        buttons = [('playpPauseBtn', 4, 'ui_73_16_225', self.ClickPlayPause),
                   ('soundBtn', 40, 'ui_73_16_230', self.ClickSound),
                   ('noSoundBtn', 40, 'ui_38_16_111', self.ClickSound)]
        for name, left, iconPath, function in buttons:
            icon = uicontrols.Icon(parent=self.sr.movieControlCont,
                                   align=uiconst.TOPLEFT,
                                   state=uiconst.UI_NORMAL,
                                   pos=(left, 2, 16, 16),
                                   icon=iconPath,
                                   idx=0)
            icon.OnClick = function
            icon.OnMouseEnter = (self.MouseOverButton, icon)
            icon.OnMouseExit = (self.MouseExitButton, icon)
            icon.SetAlpha(0.5)
            self.sr.Set(name, icon)

        self.sr.noSoundBtn.state = uiconst.UI_HIDDEN
        self.setupDone = 1
        self.TryPlayMovie()

    def UpdateLayout(self):
        if not self.sr.raceInfoCont:
            return
        if uicore.desktop.height <= 900:
            self.sr.raceInfoCont.width = 400
            self.sr.movieCont.height = 225
            self.sr.raceText.width = self.sr.raceInfoCont.width - self.padValue * 2
            self.sr.raceText.fontsize = 12
            self.sr.buttonCont.top = 60
            self.sr.raceCont.top = 40
        else:
            self.sr.raceInfoCont.width = 600
            self.sr.raceText.width = self.sr.raceInfoCont.width - self.padValue * 2
            self.sr.movieCont.height = 338
            self.sr.raceText.fontsize = 14
            self.sr.buttonCont.top = 80
            self.sr.raceCont.top = 80
        uthread.new(self.UpdateTextHeight)
        self.movie.width = self.sr.raceInfoCont.width
        self.movie.height = self.sr.movieCont.height

    def UpdateTextHeight(self):
        blue.pyos.synchro.Yield()
        self.sr.raceTextCont.height = self.sr.raceText.textheight

    def OnRaceSelected(self, raceID, *args):
        for i in [
                const.raceAmarr, const.raceMinmatar, const.raceGallente,
                const.raceCaldari
        ]:
            raceBtn = self.sr.Get('raceBtn_%d' % i)
            raceBtn.Deselect()

        btn = self.sr.Get('raceBtn_%d' % raceID)
        btn.Select()
        uicore.layer.charactercreation.UpdateBackdropLite(raceID)
        self.UpdateRaceHeader(raceID)
        self.UpdateRaceInfo(raceID)

    def UpdateRaceHeader(self, raceID):
        self.sr.raceCont.state = uiconst.UI_DISABLED
        height = 128
        top = self.racialHeader.get(raceID, None)
        self.raceSprite.rectTop, self.raceSprite.rectHeight = top, height

    def UpdateRaceInfo(self, raceID):
        oldRaceID = self.raceID
        self.raceID = raceID
        uicore.layer.charactercreation.UpdateRaceMusic(raceID)
        self.TryPlayMovie(oldRaceID)
        self.GetRaceText()

    def GetRaceText(self):
        info = self.GetInfo()
        if info.raceID is None:
            return
        if not len(self.raceInfo):
            self.raceInfo = sm.GetService('cc').GetRaceDataByID()
        self.sr.raceTextCont.state = uiconst.UI_NORMAL
        raceInfo = self.raceInfo[info.raceID]
        raceText = localization.GetByMessageID(raceInfo.descriptionID)
        color = self.raceFontColor.get(info.raceID, (1.0, 1.0, 1.0, 0.75))
        self.sr.raceText.text = raceText
        self.sr.raceText.color.SetRGB(*color)
        uthread.new(self.UpdateTextHeight)

    def TryPlayMovie(self, oldRaceID=None, *args):
        info = self.GetInfo()
        if info.raceID is None:
            return
        self.sr.movieCont.state = uiconst.UI_NORMAL
        if not getattr(self, 'setupDone', 0):
            return
        if info.raceID != oldRaceID:
            self.Pause()
        if settings.user.ui.Get('cc_racialMoviePlayed_%s' % info.raceID, 0):
            self.ShowMovieRacialImage()
        else:
            uthread.new(self.MovieState)
            self.PlayMovie()

    def OnMovieEnter(self, *args):
        self.sr.movieControlCont.state = uiconst.UI_NORMAL

    def OnMouseEnter(self, *args):
        if self.sr.movieControlCont:
            self.sr.movieControlCont.state = uiconst.UI_HIDDEN

    def PlayMovie(self):
        info = self.GetInfo()
        if info.raceID is None:
            return
        videoPath = self.racialMovies.get(info.raceID, None)
        self.movie.SetVideoPath(videoPath)
        sm.StartService('dynamicMusic').StopLocationMusic(
            'music_character_creation')
        uicore.layer.charactercreation.raceMusicStarted = False
        uthread.new(self.MovieState)
        self.movie.display = True
        self.movie.Play()
        settings.user.ui.Set('cc_racialMoviePlayed_%s' % info.raceID, 1)
        self.sr.racialImage.state = uiconst.UI_HIDDEN
        self.movie.state = uiconst.UI_DISABLED
        self.sr.playpPauseBtn.LoadIcon('ui_73_16_226')

    def ClickPlayPause(self, *args):
        if getattr(self, 'movie', None) is not None:
            if getattr(self.movie, 'path', '') and not getattr(
                    self.movie, 'isPaused', None) and not getattr(
                        self.movie, 'isFinished', None):
                self.Pause()
            else:
                self.PlayMovie()

    def Pause(self, *args):
        if not uicore.layer.charactercreation.raceMusicStarted:
            sm.StartService('dynamicMusic').PlayLocationMusic(
                'music_character_creation')
        self.movie.Pause()
        self.sr.playpPauseBtn.LoadIcon('ui_73_16_225')

    def ClickSound(self, *args):
        if self.movie.isMuted:
            self.movie.UnmuteAudio()
            self.sr.noSoundBtn.state = uiconst.UI_HIDDEN
        else:
            self.movie.MuteAudio()
            self.sr.noSoundBtn.state = uiconst.UI_NORMAL

    def MouseOverButton(self, btn, *args):
        btn.SetAlpha(1.0)

    def MouseExitButton(self, btn, *args):
        btn.SetAlpha(0.5)

    def MovieState(self):
        if self.movieStateCheckRunning:
            return
        self.movieStateCheckRunning = 1
        while self and not self.destroyed and self.movieStateCheckRunning:
            if getattr(self, 'movie', None) and self.sr:
                if getattr(self.movie, 'isPaused', None):
                    self.sr.playpPauseBtn.LoadIcon('ui_73_16_225')
                else:
                    self.sr.playpPauseBtn.LoadIcon('ui_73_16_226')
                if self.movie.isFinished:
                    self.ShowMovieRacialImage()
                    self.sr.playpPauseBtn.LoadIcon('ui_73_16_225')
            blue.pyos.synchro.SleepWallclock(1000)

        if self and not self.destroyed:
            self.movieStateCheckRunning = 0

    def ShowMovieRacialImage(self, *args):
        info = self.GetInfo()
        if info.raceID not in [
                const.raceCaldari, const.raceMinmatar, const.raceAmarr,
                const.raceGallente
        ]:
            return
        self.movieStateCheckRunning = 0
        self.movie.display = False
        self.sr.racialImage.state = uiconst.UI_DISABLED
        self.sr.racialImage.LoadTexture(
            'res:/UI/Texture/Charsel/movieImage_%s.dds' % info.raceID)
        if not uicore.layer.charactercreation.raceMusicStarted:
            sm.StartService('dynamicMusic').PlayLocationMusic(
                'music_character_creation')

    def OnMouseMove(self, *args):
        uicls.BaseCharacterCreationStep.OnMouseMove(self, *args)
        info = self.GetInfo()
        if info.raceID:
            return
        raceID = self.FindRaceFromColorMap()
        if raceID != self.hoveredRaceID:
            self.hoveredRaceID = raceID
            for eachBtn in self.raceBtns:
                eachBtn.normalSprite.SetAlpha(0.3)

            if self.hoveredRaceID is not None:
                btn = getattr(self.sr, 'raceBtn_%s' % raceID, None)
                btn.OnMouseEnter()
            uicore.layer.charactercreation.UpdateBackdropLite(raceID=raceID,
                                                              mouseEnter=True)
            if raceID is None:
                self.cursor = uiconst.UICURSOR_DEFAULT
            else:
                self.cursor = uiconst.UICURSOR_SELECT

    def OnMouseUp(self, btn, *args):
        uicls.BaseCharacterCreationStep.OnMouseUp(self, btn, *args)
        raceID = self.FindRaceFromColorMap()
        if raceID is not None:
            sm.StartService('audio').SendUIEvent(
                unicode('wise:/ui_icc_button_select_play'))
            uicore.layer.charactercreation.SelectRace(raceID)

    def ResetHoverRaceID(self, *args):
        self.hoveredRaceID = None

    def FindRaceFromColorMap(self, *args):
        pos = (int(uicore.uilib.x * uicore.desktop.dpiScaling),
               int(uicore.uilib.y * uicore.desktop.dpiScaling))
        bdScene = sm.GetService('sceneManager').Get2DBackdropScene()
        raceID = None
        for each in bdScene.children:
            if each.name != 'backdropSprite':
                continue
            colorCodedBackDrop = uicore.layer.charactercreation.colorCodedBackDrop
            if colorCodedBackDrop is None:
                continue
            xPosInBackDrop = pos[0] - each.displayX
            yPosInBackDrop = pos[1] - each.displayY
            xRatioPos = xPosInBackDrop / float(each.displayWidth)
            yRatioPos = yPosInBackDrop / float(each.displayHeight)
            xPosInMask = int(xRatioPos * colorCodedBackDrop.width)
            yPosInMask = int(yRatioPos * colorCodedBackDrop.height)
            colorCode = colorCodedBackDrop.GetPixelColor(
                xPosInMask, yPosInMask)
            raceID = self.raceColorCodes.get(colorCode, None)

        return raceID
Пример #14
0
 def Play(self, data):
     if data is None:
         return
     self.PlayIntro(data.get('introVideoPath', None))
     uicls.TextBanner(parent=self,
                      align=uiconst.TOBOTTOM,
                      height=100,
                      text=data.bottomText)
     rightCont = uicls.ScreenFrame5(parent=self,
                                    align=uiconst.TORIGHT,
                                    width=700,
                                    padLeft=10,
                                    padBottom=10)
     blue.pyos.synchro.SleepWallclock(300)
     topLeftCont = uicls.ScreenFrame2(parent=self,
                                      align=uiconst.TOTOP,
                                      height=300)
     bottomLeftCont = uicls.ScreenHeading1(parent=self,
                                           align=uiconst.TOALL,
                                           pos=(0, 0, 0, 0),
                                           padTop=10,
                                           padBottom=10,
                                           leftContWidth=150,
                                           appear=False)
     blue.pyos.synchro.SleepWallclock(300)
     uicls.ScreenHeading2(
         parent=topLeftCont.mainCont,
         text=localization.GetByLabel(
             'UI/Station/Holoscreen/RacialEpicArc/EpicArcAgent'),
         align=uiconst.TOBOTTOM,
         hasBargraph=False,
         padBottom=10,
         padRight=10)
     topLeftCont.mainCont.padLeft = 30
     topLeftCont.mainCont.padTop = 15
     pictureCont = uiprimitives.Container(align=uiconst.TOPLEFT,
                                          parent=topLeftCont.mainCont,
                                          pos=(0, 20, 180, 180))
     uicontrols.Frame(parent=pictureCont, color=util.Color.WHITE)
     uiutil.GetOwnerLogo(pictureCont, data.charID, size=256)
     logo = pictureCont.children[1]
     logo.align = uiconst.TOALL
     logo.width = logo.height = 0
     uicontrols.Label(name='charNameLabel',
                      parent=topLeftCont.mainCont,
                      text=cfg.eveowners.Get(data.charID).name,
                      fontsize=50,
                      left=200,
                      top=20,
                      color=util.Color.WHITE)
     uicontrols.EveLabelMedium(name='charLocationLabel',
                               parent=topLeftCont.mainCont,
                               pos=(200, 75, 300, 0),
                               text=data.mainText)
     uicore.animations.BlinkIn(topLeftCont.mainCont)
     uiutil.GetOwnerLogo(bottomLeftCont.leftCont, data.factionID, size=150)
     uicontrols.Label(parent=bottomLeftCont.mainCont,
                      text=data.factionNameText,
                      fontsize=42,
                      top=30,
                      left=15)
     uicontrols.Label(
         parent=bottomLeftCont.mainCont,
         text=localization.GetByLabel('UI/Agents/MissionTypes/EpicArc'),
         fontsize=30,
         top=80,
         left=15)
     bottomLeftCont.AnimAppear()
     video = StreamingVideoSprite(parent=rightCont.mainCont,
                                  videoPath=data.videoPath,
                                  align=uiconst.TOALL,
                                  positionComponent=getattr(
                                      self.uiDesktop, 'positionComponent',
                                      None))
     while not video.isFinished:
         blue.synchro.Yield()
Пример #15
0
 def Play(self, data):
     if data is None:
         return
     self.PlayIntro(data.get('introVideoPath', None))
     leftCont = uiprimitives.Container(parent=self,
                                       align=uiconst.TOLEFT,
                                       width=845,
                                       padRight=10)
     rightCont = uicls.ScreenFrame5(parent=self, align=uiconst.TOALL)
     headingCont = uiprimitives.Container(parent=leftCont,
                                          align=uiconst.TOTOP,
                                          height=100,
                                          fontsize=50)
     fill = uiprimitives.Fill(bgParent=headingCont,
                              color=(1.0, 0.0, 0.0, 0.5))
     uicore.animations.FadeTo(fill,
                              startVal=0.5,
                              endVal=0.2,
                              duration=1.0,
                              loops=uiconst.ANIM_REPEAT)
     label = uicontrols.Label(parent=headingCont,
                              text=data.headingText,
                              fontsize=80,
                              align=uiconst.CENTER,
                              color=util.Color.WHITE,
                              uppercase=True,
                              bold=True)
     frame = uicls.ScreenFrame1(parent=leftCont,
                                align=uiconst.TOALL,
                                appear=True,
                                padTop=10)
     frame.mainCont.padTop = 70
     banner = uicls.TextBanner(parent=frame.mainCont,
                               align=uiconst.TOBOTTOM,
                               padTop=10,
                               scrollText=False,
                               text=data.bottomText,
                               fontSize=30,
                               leftContWidth=310)
     uiprimitives.Sprite(
         parent=banner.leftCont,
         pos=(10, -20, 300, 100),
         texturePath='res:/UI/Texture/Classes/CQMainScreen/concordLogo.png')
     uicontrols.Label(
         parent=frame.mainCont,
         left=20,
         top=0,
         text=localization.GetByLabel('UI/Common/Constellation'),
         fontsize=30)
     uicontrols.Label(parent=frame.mainCont,
                      left=20,
                      top=30,
                      text=data.constellationText,
                      fontsize=45)
     uicontrols.Label(
         parent=frame.mainCont,
         left=280,
         top=0,
         text=localization.GetByLabel('UI/Incursion/Journal/StagingSystem'),
         fontsize=30)
     uicontrols.Label(parent=frame.mainCont,
                      left=280,
                      top=30,
                      text=data.systemInfoText,
                      fontsize=45)
     uicontrols.Label(parent=frame.mainCont,
                      left=20,
                      top=140,
                      text=localization.GetByLabel(
                          'UI/Incursion/Common/HUDInfluenceTitle'),
                      fontsize=30)
     influenceBar = uicls.SystemInfluenceBar(parent=frame.mainCont,
                                             align=uiconst.TOPLEFT,
                                             pos=(20, 180, 700, 60))
     influenceBar.SetInfluence(data.influence, True)
     uicore.animations.BlinkIn(frame.mainCont, sleep=True)
     video = StreamingVideoSprite(parent=rightCont.mainCont,
                                  videoPath=data.videoPath,
                                  align=uiconst.TOALL,
                                  repeat=True,
                                  positionComponent=getattr(
                                      self.uiDesktop, 'positionComponent',
                                      None))
     while not video.isFinished:
         blue.synchro.Yield()