Example #1
0
 def onTransitionIn(self):
     import bsInternal
     bs.Activity.onTransitionIn(self)
     bsInternal._addCleanFrameCallback(bs.WeakCall(self._startPreloads))
     self._background = bsUtils.Background(fadeTime=500, startFaded=True, showLogo=False)
     self._part = 1
     self._image = bsUtils.Image(self._tex, transition='fadeIn', modelTransparent=bs.getModel('image4x1'), scale=(800, 200), transitionDelay=500, transitionOutDelay=self._part1Duration-1300)
     bs.gameTimer(self._part1Duration, self.end)
Example #2
0
 def _startPart2(self):
     if self._part != 1: return
     self._part = 2
     self._image = bsUtils.Image(self._tex2, transition='fadeIn',
                                 scale=(400, 400), transitionDelay=0)
     t = bsUtils._translate('tips', 'If you are short on controllers, '
                            'install the \'${REMOTE_APP_NAME}\' app\n'
                            'on your mobile devices to use them '
                            'as controllers.')
     t = t.replace('${REMOTE_APP_NAME}',bsUtils._getRemoteAppName())
     self._text = bsUtils.Text(t, maxWidth=900, hAlign='center',
                               vAlign='center', position=(0,270),
                               color=(1,1,1,1), transition='fadeIn')
Example #3
0
    def showCompletionBanner(self, sound=True):

        global gLastAchievementDisplayTime
        gLastAchievementDisplayTime = bs.getRealTime()

        # just piggy-back onto any current activity...
        # (should we use the session instead?..)
        activity = bs.getActivity(exceptionOnNone=False)

        # if this gets called while this achievement is occupying a slot already, ignore it..
        # (probably should never happen in real life but whatevs..)
        if self._completionBannerSlot is not None:
            return

        if activity is None:
            print 'showCompletionBanner() called with no current activity!'
            return

        if sound: bs.playSound(bs.getSound('achievement'), hostOnly=True)
        else:
            bs.gameTimer(
                500, bs.Call(bs.playSound, bs.getSound('ding'), hostOnly=True))

        yOffs = 0
        inTime = 300
        outTime = 3500

        baseVRDepth = 200

        # find the first free slot
        i = 0
        while True:
            if not i in gCompletionBannerSlots:
                #print 'ADDING SLOT',i,'FOR',self
                gCompletionBannerSlots.add(i)
                self._completionBannerSlot = i
                # remove us from that slot when we close..
                # use a real-timer in the UI context so the removal runs even if our activity/session dies
                with bs.Context('UI'):
                    bs.realTimer(inTime + outTime, self._removeBannerSlot)
                break
            i += 1

        yOffs = 110 * self._completionBannerSlot

        objs = []
        obj = bsUtils.Image(bs.getTexture('shadow'),
                            position=(-30, 30 + yOffs),
                            front=True,
                            attach='bottomCenter',
                            transition='inBottom',
                            vrDepth=baseVRDepth - 100,
                            transitionDelay=inTime,
                            transitionOutDelay=outTime,
                            color=(0.0, 0.1, 0, 1),
                            scale=(1000, 300)).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True
        obj = bsUtils.Image(bs.getTexture('light'),
                            position=(-180, 60 + yOffs),
                            front=True,
                            attach='bottomCenter',
                            vrDepth=baseVRDepth,
                            transition='inBottom',
                            transitionDelay=inTime,
                            transitionOutDelay=outTime,
                            color=(1.8, 1.8, 1.0, 0.0),
                            scale=(40, 300)).autoRetain()
        objs.append(obj)

        obj.node.hostOnly = True
        obj.node.premultiplied = True
        c = bs.newNode('combine', owner=obj.node, attrs={'size': 2})
        bsUtils.animate(
            c, 'input0', {
                inTime: 0,
                inTime + 400: 30,
                inTime + 500: 40,
                inTime + 600: 30,
                inTime + 2000: 0
            })
        bsUtils.animate(
            c, 'input1', {
                inTime: 0,
                inTime + 400: 200,
                inTime + 500: 500,
                inTime + 600: 200,
                inTime + 2000: 0
            })
        c.connectAttr('output', obj.node, 'scale')
        bsUtils.animate(obj.node, 'rotate', {0: 0.0, 350: 360.0}, loop=True)
        obj = bsUtils.Image(self.getIconTexture(True),
                            position=(-180, 60 + yOffs),
                            attach='bottomCenter',
                            front=True,
                            vrDepth=baseVRDepth - 10,
                            transition='inBottom',
                            transitionDelay=inTime,
                            transitionOutDelay=outTime,
                            scale=(100, 100)).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True

        # flash
        color = self.getIconColor(True)
        c = bs.newNode('combine', owner=obj.node, attrs={'size': 3})
        keys = {
            inTime: 1.0 * color[0],
            inTime + 400: 1.5 * color[0],
            inTime + 500: 6.0 * color[0],
            inTime + 600: 1.5 * color[0],
            inTime + 2000: 1.0 * color[0]
        }
        bsUtils.animate(c, 'input0', keys)
        keys = {
            inTime: 1.0 * color[1],
            inTime + 400: 1.5 * color[1],
            inTime + 500: 6.0 * color[1],
            inTime + 600: 1.5 * color[1],
            inTime + 2000: 1.0 * color[1]
        }
        bsUtils.animate(c, 'input1', keys)
        keys = {
            inTime: 1.0 * color[2],
            inTime + 400: 1.5 * color[2],
            inTime + 500: 6.0 * color[2],
            inTime + 600: 1.5 * color[2],
            inTime + 2000: 1.0 * color[2]
        }
        bsUtils.animate(c, 'input2', keys)
        c.connectAttr('output', obj.node, 'color')

        obj = bsUtils.Image(bs.getTexture('achievementOutline'),
                            modelTransparent=bs.getModel('achievementOutline'),
                            position=(-180, 60 + yOffs),
                            front=True,
                            attach='bottomCenter',
                            vrDepth=baseVRDepth,
                            transition='inBottom',
                            transitionDelay=inTime,
                            transitionOutDelay=outTime,
                            scale=(100, 100)).autoRetain()
        obj.node.hostOnly = True

        # flash
        color = (2, 1.4, 0.4, 1)
        c = bs.newNode('combine', owner=obj.node, attrs={'size': 3})
        keys = {
            inTime: 1.0 * color[0],
            inTime + 400: 1.5 * color[0],
            inTime + 500: 6.0 * color[0],
            inTime + 600: 1.5 * color[0],
            inTime + 2000: 1.0 * color[0]
        }
        bsUtils.animate(c, 'input0', keys)
        keys = {
            inTime: 1.0 * color[1],
            inTime + 400: 1.5 * color[1],
            inTime + 500: 6.0 * color[1],
            inTime + 600: 1.5 * color[1],
            inTime + 2000: 1.0 * color[1]
        }
        bsUtils.animate(c, 'input1', keys)
        keys = {
            inTime: 1.0 * color[2],
            inTime + 400: 1.5 * color[2],
            inTime + 500: 6.0 * color[2],
            inTime + 600: 1.5 * color[2],
            inTime + 2000: 1.0 * color[2]
        }
        bsUtils.animate(c, 'input2', keys)
        c.connectAttr('output', obj.node, 'color')
        objs.append(obj)

        obj = bsUtils.Text(bs.Lstr(value='${A}:',
                                   subs=[('${A}',
                                          bs.Lstr(resource='achievementText'))
                                         ]),
                           position=(-120, 91 + yOffs),
                           front=True,
                           vAttach='bottom',
                           vrDepth=baseVRDepth - 10,
                           transition='inBottom',
                           flatness=0.5,
                           transitionDelay=inTime,
                           transitionOutDelay=outTime,
                           color=(1, 1, 1, 0.8),
                           scale=0.65).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True

        obj = bsUtils.Text(self.getDisplayString(),
                           position=(-120, 50 + yOffs),
                           front=True,
                           vAttach='bottom',
                           transition='inBottom',
                           vrDepth=baseVRDepth,
                           flatness=0.5,
                           transitionDelay=inTime,
                           transitionOutDelay=outTime,
                           flash=True,
                           color=(1, 0.8, 0, 1.0),
                           scale=1.5).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True

        obj = bsUtils.Text(bs.getSpecialChar('ticket'),
                           position=(-120 - 170 + 5, 75 + yOffs - 20),
                           front=True,
                           vAttach='bottom',
                           hAlign='center',
                           vAlign='center',
                           transition='inBottom',
                           vrDepth=baseVRDepth,
                           transitionDelay=inTime,
                           transitionOutDelay=outTime,
                           flash=True,
                           color=(0.5, 0.5, 0.5, 1),
                           scale=3.0).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True

        obj = bsUtils.Text('+' + str(self.getAwardTicketValue()),
                           position=(-120 - 180 + 5, 80 + yOffs - 20),
                           vAttach='bottom',
                           front=True,
                           hAlign='center',
                           vAlign='center',
                           transition='inBottom',
                           vrDepth=baseVRDepth,
                           flatness=0.5,
                           shadow=1.0,
                           transitionDelay=inTime,
                           transitionOutDelay=outTime,
                           flash=True,
                           color=(0, 1, 0, 1),
                           scale=1.5).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True

        # add the 'x 2' if we've got pro
        if bsUtils._havePro():
            obj = bsUtils.Text('x 2',
                               position=(-120 - 180 + 45, 80 + yOffs - 50),
                               vAttach='bottom',
                               front=True,
                               hAlign='center',
                               vAlign='center',
                               transition='inBottom',
                               vrDepth=baseVRDepth,
                               flatness=0.5,
                               shadow=1.0,
                               transitionDelay=inTime,
                               transitionOutDelay=outTime,
                               flash=True,
                               color=(0.4, 0, 1, 1),
                               scale=0.9).autoRetain()
            objs.append(obj)
            obj.node.hostOnly = True

        obj = bsUtils.Text(
            self.getDescriptionComplete(),
            # self.getDescriptionCompleteLocalized(),
            position=(-120, 30 + yOffs),
            front=True,
            vAttach='bottom',
            transition='inBottom',
            vrDepth=baseVRDepth - 10,
            flatness=0.5,
            transitionDelay=inTime,
            transitionOutDelay=outTime,
            color=(1.0, 0.7, 0.5, 1.0),
            scale=0.8).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True

        for obj in objs:
            bs.gameTimer(outTime + 1000,
                         bs.WeakCall(obj.handleMessage, bs.DieMessage()))
Example #4
0
    def createDisplay(self,
                      x,
                      y,
                      delay,
                      outDelay=None,
                      color=None,
                      style='postGame'):

        if style == 'postGame':
            inGameColors = False
            inMainMenu = False
            hAttach = vAttach = attach = 'center'
        elif style == 'inGame':
            inGameColors = True
            inMainMenu = False
            hAttach = 'left'
            vAttach = 'top'
            attach = 'topLeft'
        elif style == 'news':
            inGameColors = True
            inMainMenu = True
            hAttach = 'center'
            vAttach = 'top'
            attach = 'topCenter'
        else:
            raise Exception('invalid style "' + style + '"')

        # attempt to determine what campaign we're in
        # (so we know whether to show "hard mode only")
        if inMainMenu:
            hmo = False
        else:
            try:
                hmo = (self._hardModeOnly
                       and bs.getSession()._campaignInfo['campaign'] == 'Easy')
            except Exception:
                bs.printException("unable to determine campaign")
                hmo = False

        activity = bs.getActivity()
        if inGameColors:
            objs = []
            outDelayFin = (delay + outDelay) if outDelay is not None else None
            if color is not None:
                c1 = (2.0 * color[0], 2.0 * color[1], 2.0 * color[2], color[3])
                c2 = color
            else:
                c1 = (1.5, 1.5, 2, 1.0)
                c2 = (0.8, 0.8, 1.0, 1.0)

            if hmo:
                c1 = (c1[0], c1[1], c1[2], c1[3] * 0.6)
                c2 = (c2[0], c2[1], c2[2], c2[3] * 0.2)

            objs.append(
                bsUtils.Image(self.getIconTexture(False),
                              hostOnly=True,
                              color=c1,
                              position=(x - 25, y + 5),
                              attach=attach,
                              transition='fadeIn',
                              transitionDelay=delay,
                              vrDepth=4,
                              transitionOutDelay=outDelayFin,
                              scale=(40, 40)).autoRetain())
            txt = self.getDisplayString()
            txtS = 0.85
            txtMaxW = 300
            objs.append(
                bsUtils.Text(txt,
                             hostOnly=True,
                             maxWidth=txtMaxW,
                             position=(x, y + 2),
                             transition='fadeIn',
                             scale=txtS,
                             flatness=0.6,
                             shadow=0.5,
                             hAttach=hAttach,
                             vAttach=vAttach,
                             color=c2,
                             transitionDelay=delay + 50,
                             transitionOutDelay=outDelayFin).autoRetain())
            # txt2 = self.getDescriptionLocalized()
            txt2S = 0.62
            txt2MaxW = 400
            objs.append(
                bsUtils.Text(self.getDescriptionFull()
                             if inMainMenu else self.getDescription(),
                             hostOnly=True,
                             maxWidth=txt2MaxW,
                             position=(x, y - 14),
                             transition='fadeIn',
                             vrDepth=-5,
                             hAttach=hAttach,
                             vAttach=vAttach,
                             scale=txt2S,
                             flatness=1.0,
                             shadow=0.5,
                             color=c2,
                             transitionDelay=delay + 100,
                             transitionOutDelay=outDelayFin).autoRetain())

            if hmo:
                t = bsUtils.Text(bs.Lstr(resource='difficultyHardOnlyText'),
                                 hostOnly=True,
                                 maxWidth=txt2MaxW * 0.7,
                                 position=(x + 60, y + 5),
                                 transition='fadeIn',
                                 vrDepth=-5,
                                 hAttach=hAttach,
                                 vAttach=vAttach,
                                 hAlign='center',
                                 vAlign='center',
                                 scale=txtS * 0.8,
                                 flatness=1.0,
                                 shadow=0.5,
                                 color=(1, 1, 0.6, 1),
                                 transitionDelay=delay + 100,
                                 transitionOutDelay=outDelayFin).autoRetain()
                t.node.rotate = 10
                objs.append(t)

            # ticket-award
            awardX = -100
            objs.append(
                bsUtils.Text(bs.getSpecialChar('ticket'),
                             hostOnly=True,
                             position=(x + awardX + 33, y + 7),
                             transition='fadeIn',
                             scale=1.5,
                             hAttach=hAttach,
                             vAttach=vAttach,
                             hAlign='center',
                             vAlign='center',
                             color=(1, 1, 1, 0.2 if hmo else 0.4),
                             transitionDelay=delay + 50,
                             transitionOutDelay=outDelayFin).autoRetain())
            objs.append(
                bsUtils.Text('+' + str(self.getAwardTicketValue()),
                             hostOnly=True,
                             position=(x + awardX + 28, y + 16),
                             transition='fadeIn',
                             scale=0.7,
                             flatness=1,
                             hAttach=hAttach,
                             vAttach=vAttach,
                             hAlign='center',
                             vAlign='center',
                             color=(c2),
                             transitionDelay=delay + 50,
                             transitionOutDelay=outDelayFin).autoRetain())

        else:
            complete = self.isComplete()
            objs = []
            cIcon = self.getIconColor(complete)
            if hmo and not complete:
                cIcon = (cIcon[0], cIcon[1], cIcon[2], cIcon[3] * 0.3)
            objs.append(
                bsUtils.Image(self.getIconTexture(complete),
                              hostOnly=True,
                              color=cIcon,
                              position=(x - 25, y + 5),
                              attach=attach,
                              vrDepth=4,
                              transition='inRight',
                              transitionDelay=delay,
                              transitionOutDelay=None,
                              scale=(40, 40)).autoRetain())
            if complete:
                objs.append(
                    bsUtils.Image(
                        bs.getTexture('achievementOutline'),
                        hostOnly=True,
                        modelTransparent=bs.getModel('achievementOutline'),
                        color=(2, 1.4, 0.4, 1),
                        vrDepth=8,
                        position=(x - 25, y + 5),
                        attach=attach,
                        transition='inRight',
                        transitionDelay=delay,
                        transitionOutDelay=None,
                        scale=(40, 40)).autoRetain())
            else:

                if not complete:
                    awardX = -100
                    objs.append(
                        bsUtils.Text(bs.getSpecialChar('ticket'),
                                     hostOnly=True,
                                     position=(x + awardX + 33, y + 7),
                                     transition='inRight',
                                     scale=1.5,
                                     hAttach=hAttach,
                                     vAttach=vAttach,
                                     hAlign='center',
                                     vAlign='center',
                                     color=(1, 1, 1, 0.4) if complete else
                                     (1, 1, 1, (0.1 if hmo else 0.2)),
                                     transitionDelay=delay + 50,
                                     transitionOutDelay=None).autoRetain())
                    objs.append(
                        bsUtils.Text('+' + str(self.getAwardTicketValue()),
                                     hostOnly=True,
                                     position=(x + awardX + 28, y + 16),
                                     transition='inRight',
                                     scale=0.7,
                                     flatness=1,
                                     hAttach=hAttach,
                                     vAttach=vAttach,
                                     hAlign='center',
                                     vAlign='center',
                                     color=((0.8, 0.93, 0.8,
                                             1.0) if complete else
                                            (0.6, 0.6, 0.6,
                                             (0.2 if hmo else 0.4))),
                                     transitionDelay=delay + 50,
                                     transitionOutDelay=None).autoRetain())
                    # show 'hard-mode-only' only over incomplete achievements
                    # when that's the case..
                    if hmo:
                        t = bsUtils.Text(
                            bs.Lstr(resource='difficultyHardOnlyText'),
                            hostOnly=True,
                            maxWidth=300 * 0.7,
                            position=(x + 60, y + 5),
                            transition='fadeIn',
                            vrDepth=-5,
                            hAttach=hAttach,
                            vAttach=vAttach,
                            hAlign='center',
                            vAlign='center',
                            scale=0.85 * 0.8,
                            flatness=1.0,
                            shadow=0.5,
                            color=(1, 1, 0.6, 1),
                            transitionDelay=delay + 50,
                            transitionOutDelay=None).autoRetain()
                        t.node.rotate = 10
                        objs.append(t)

            objs.append(
                bsUtils.Text(self.getDisplayString(),
                             hostOnly=True,
                             maxWidth=300,
                             position=(x, y + 2),
                             transition='inRight',
                             scale=0.85,
                             flatness=0.6,
                             hAttach=hAttach,
                             vAttach=vAttach,
                             color=((0.8, 0.93, 0.8, 1.0) if complete else
                                    (0.6, 0.6, 0.6, (0.2 if hmo else 0.4))),
                             transitionDelay=delay + 50,
                             transitionOutDelay=None).autoRetain())
            objs.append(
                bsUtils.Text(self.getDescriptionComplete()
                             if complete else self.getDescription(),
                             hostOnly=True,
                             maxWidth=400,
                             position=(x, y - 14),
                             transition='inRight',
                             vrDepth=-5,
                             hAttach=hAttach,
                             vAttach=vAttach,
                             scale=0.62,
                             flatness=1.0,
                             color=((0.6, 0.6, 0.6, 1.0) if complete else
                                    (0.6, 0.6, 0.6, (0.2 if hmo else 0.4))),
                             transitionDelay=delay + 100,
                             transitionOutDelay=None).autoRetain())
        return objs