示例#1
0
class ModCredits(DirectObject):
    def __init__(self, menu):
        base.transitions.fadeScreen(1.0)
        vfs = VirtualFileSystem.getGlobalPtr()
        creditsTextStr = str(vfs.readFile("scripts/credits.txt", True))
        self.creditsText = OnscreenText(text=creditsTextStr,
                                        fg=(1, 1, 1, 1),
                                        align=TextNode.ACenter,
                                        mayChange=False,
                                        scale=0.06)
        self.creditsText.reparentTo(aspect2d, DGG.FADE_SORT_INDEX + 1)
        self.creditsText.setZ(-1)
        self.ival = Sequence(
            LerpPosInterval(self.creditsText, 20.0, (0, 0, 2.6), (0, 0, -1.0)),
            Func(self.done))
        self.ival.start()
        self.acceptOnce('space', self.done)
        self.menu = menu

    def done(self):
        self.creditsText.destroy()
        self.creditsText = None
        self.ival.pause()
        self.ival = None
        base.transitions.irisIn(0.5)
        self.menu.enableButtons()
        self.menu = None
        self.ignore('space')
class ClickToStart(DirectObject):
    notify = directNotify.newCategory('ClickToStart')

    def __init__(self, version='n/a'):
        DirectObject.__init__(self)

        self.backgroundNodePath = render2d.attachNewNode('background', 0)
        self.backgroundModel = loader.loadModel(
            'phase_3/models/gui/loading-background.bam')
        self.backgroundModel.reparentTo(self.backgroundNodePath)
        self.backgroundNodePath.find('**/fg').removeNode()
        self.backgroundNodePath.setScale(1, 1, 1)

        self.logo = OnscreenImage(
            parent=base.a2dTopCenter, image='phase_3/maps/toontown-logo.png',
            scale=(1.0, 1, 0.5), pos=(0, 0, -0.85))
        self.logo.setTransparency(TransparencyAttrib.MAlpha)

        self.label = OnscreenText(
            TTLocalizer.ClickToStartLabel, parent=base.a2dBottomCenter,
            font=ToontownGlobals.getMinnieFont(), fg=Vec4(1, 1, 1, 1),
            scale=0.1, align=TextNode.ACenter)
        self.label.setZ(0.35)

        self.versionLabel = OnscreenText(
            '\x01white_shadow\x01%s\x02' % version, parent=base.a2dBottomRight,
            font=ToontownGlobals.getMinnieFont(), fg=Vec4(0, 0, 0, 1),
            scale=0.06, align=TextNode.ARight)
        self.versionLabel.setPos(-0.025, 0.025)

        self.setColorScale(Vec4(0, 0, 0, 0))

        self.fadeTrack = None
        self.logoPosTrack = None
        self.logoScaleTrack = None
        self.labelPosTrack = None
        self.labelColorScaleTrack = None

    def delete(self):
        if self.labelColorScaleTrack is not None:
            self.labelColorScaleTrack.finish()
            self.labelColorScaleTrack = None

        if self.labelPosTrack is not None:
            self.labelPosTrack.finish()
            self.labelPosTrack = None

        if self.logoScaleTrack is not None:
            self.logoScaleTrack.finish()
            self.logoScaleTrack = None

        if self.logoPosTrack is not None:
            self.logoPosTrack.finish()
            self.logoPosTrack = None

        if self.fadeTrack is not None:
            self.fadeTrack.finish()
            self.fadeTrack = None

        if self.versionLabel is not None:
            self.versionLabel.destroy()
            self.versionLabel = None

        if self.label is not None:
            self.label.destroy()
            self.label = None

        if self.logo is not None:
            self.logo.destroy()
            self.logo = None

        if self.backgroundNodePath is not None:
            self.backgroundNodePath.removeNode()
            self.backgroundNodePath = None

        if self.backgroundModel is not None:
            self.backgroundModel.removeNode()
            self.backgroundModel = None

    def start(self):
        base.transitions.fadeOut(t=0)

        self.setColorScale(Vec4(1, 1, 1, 1))

        if self.fadeTrack is not None:
            self.fadeTrack.finish()
            self.fadeTrack = None

        self.fadeTrack = base.transitions.getFadeInIval(t=2)
        self.fadeTrack.start()

        if self.logoScaleTrack is not None:
            self.logoScaleTrack.finish()
            self.logoScaleTrack = None

        self.logoScaleTrack = Sequence(
            LerpScaleInterval(self.logo, 2, Vec3(1.1, 1, 0.55), Vec3(1, 1, 0.5),
                              blendType='easeInOut'),
            LerpScaleInterval(self.logo, 2, Vec3(1, 1, 0.5), Vec3(1.1, 1, 0.55),
                              blendType='easeInOut')
        )

        if self.logoPosTrack is not None:
            self.logoPosTrack.finish()
            self.logoPosTrack = None

        self.logoPosTrack = Sequence(
            LerpPosInterval(self.logo, 2, Point3(0, 0, -0.85),
                            Point3(0, 0, -0.7), blendType='easeOut'),
            Func(self.logoScaleTrack.loop)
        )
        self.logoPosTrack.start()

        if self.labelColorScaleTrack is not None:
            self.labelColorScaleTrack.finish()
            self.labelColorScaleTrack = None

        self.labelColorScaleTrack = Sequence(
            LerpColorScaleInterval(self.label, 1, Vec4(1, 1, 1, 0.6),
                                   Vec4(1, 1, 1, 1)),
            LerpColorScaleInterval(self.label, 1, Vec4(1, 1, 1, 1),
                                   Vec4(1, 1, 1, 0.6))
        )

        if self.labelPosTrack is not None:
            self.labelPosTrack.finish()
            self.labelPosTrack = None

        self.labelPosTrack = Sequence(
            LerpPosInterval(self.label, 2, Point3(0, 0, 0.35),
                            Point3(0, 0, 0.15), blendType='easeOut'),
            Func(self.labelColorScaleTrack.loop)
        )
        self.labelPosTrack.start()

        self.acceptOnce('mouse1', self.begin)

    def stop(self):
        self.ignore('mouse1')

        if self.labelPosTrack is not None:
            self.labelPosTrack.finish()
            self.labelPosTrack = None

        if self.labelColorScaleTrack is not None:
            self.labelColorScaleTrack.finish()
            self.labelColorScaleTrack = None

        if self.logoPosTrack is not None:
            self.logoPosTrack.finish()
            self.logoPosTrack = None

        if self.logoScaleTrack is not None:
            self.logoScaleTrack.finish()
            self.logoScaleTrack = None

        if self.fadeTrack is not None:
            self.fadeTrack.finish()
            self.fadeTrack = None

        self.setColorScale(Vec4(0, 0, 0, 0))

    def begin(self):
        base.cr.introDone = True

        if self.fadeTrack is not None:
            self.fadeTrack.finish()
            self.fadeTrack = None

        self.fadeTrack = base.transitions.getFadeOutIval(t=2)

        Sequence(
            Func(self.fadeTrack.start),
            Wait(2),
            Func(self.delete),
            Func(base.cr.introduction.delete),
            Func(base.cr.loginFSM.request, 'chooseAvatar', [base.cr.avList]),
            Func(base.transitions.fadeIn, 2)
        ).start()

    def setColorScale(self, *args, **kwargs):
        self.backgroundNodePath.setColorScale(*args, **kwargs)
        self.logo.setColorScale(*args, **kwargs)
        self.label.setColorScale(*args, **kwargs)
        self.versionLabel.setColorScale(*args, **kwargs)
示例#3
0
class ClickToStart(DirectObject):
    notify = directNotify.newCategory('ClickToStart')

    def __init__(self, version='n/a'):
        DirectObject.__init__(self)

        self.backgroundNodePath = render2d.attachNewNode('background', 0)
        self.backgroundModel = loader.loadModel(
            'phase_3/models/gui/loading-background.bam')
        self.backgroundModel.reparentTo(self.backgroundNodePath)
        self.backgroundNodePath.find('**/fg').removeNode()
        self.backgroundNodePath.setScale(1, 1, 1)

        self.logo = OnscreenImage(parent=base.a2dTopCenter,
                                  image='phase_3/maps/toontown-logo.png',
                                  scale=(1.0, 1, 0.5),
                                  pos=(0, 0, -0.85))
        self.logo.setTransparency(TransparencyAttrib.MAlpha)

        self.label = OnscreenText(TTLocalizer.ClickToStartLabel,
                                  parent=base.a2dBottomCenter,
                                  font=ToontownGlobals.getMinnieFont(),
                                  fg=Vec4(1, 1, 1, 1),
                                  scale=0.1,
                                  align=TextNode.ACenter)
        self.label.setZ(0.35)

        self.versionLabel = OnscreenText('\x01white_shadow\x01%s\x02' %
                                         version,
                                         parent=base.a2dBottomRight,
                                         font=ToontownGlobals.getMinnieFont(),
                                         fg=Vec4(0, 0, 0, 1),
                                         scale=0.06,
                                         align=TextNode.ARight)
        self.versionLabel.setPos(-0.025, 0.025)

        self.setColorScale(Vec4(0, 0, 0, 0))

        self.fadeTrack = None
        self.logoPosTrack = None
        self.logoScaleTrack = None
        self.labelPosTrack = None
        self.labelColorScaleTrack = None

    def delete(self):
        if self.labelColorScaleTrack is not None:
            self.labelColorScaleTrack.finish()
            self.labelColorScaleTrack = None

        if self.labelPosTrack is not None:
            self.labelPosTrack.finish()
            self.labelPosTrack = None

        if self.logoScaleTrack is not None:
            self.logoScaleTrack.finish()
            self.logoScaleTrack = None

        if self.logoPosTrack is not None:
            self.logoPosTrack.finish()
            self.logoPosTrack = None

        if self.fadeTrack is not None:
            self.fadeTrack.finish()
            self.fadeTrack = None

        if self.versionLabel is not None:
            self.versionLabel.destroy()
            self.versionLabel = None

        if self.label is not None:
            self.label.destroy()
            self.label = None

        if self.logo is not None:
            self.logo.destroy()
            self.logo = None

        if self.backgroundNodePath is not None:
            self.backgroundNodePath.removeNode()
            self.backgroundNodePath = None

        if self.backgroundModel is not None:
            self.backgroundModel.removeNode()
            self.backgroundModel = None

    def start(self):
        base.transitions.fadeOut(t=0)

        self.setColorScale(Vec4(1, 1, 1, 1))

        if self.fadeTrack is not None:
            self.fadeTrack.finish()
            self.fadeTrack = None

        self.fadeTrack = base.transitions.getFadeInIval(t=2)
        self.fadeTrack.start()

        if self.logoScaleTrack is not None:
            self.logoScaleTrack.finish()
            self.logoScaleTrack = None

        self.logoScaleTrack = Sequence(
            LerpScaleInterval(self.logo,
                              2,
                              Vec3(1.1, 1, 0.55),
                              Vec3(1, 1, 0.5),
                              blendType='easeInOut'),
            LerpScaleInterval(self.logo,
                              2,
                              Vec3(1, 1, 0.5),
                              Vec3(1.1, 1, 0.55),
                              blendType='easeInOut'))

        if self.logoPosTrack is not None:
            self.logoPosTrack.finish()
            self.logoPosTrack = None

        self.logoPosTrack = Sequence(
            LerpPosInterval(self.logo,
                            2,
                            Point3(0, 0, -0.85),
                            Point3(0, 0, -0.7),
                            blendType='easeOut'),
            Func(self.logoScaleTrack.loop))
        self.logoPosTrack.start()

        if self.labelColorScaleTrack is not None:
            self.labelColorScaleTrack.finish()
            self.labelColorScaleTrack = None

        self.labelColorScaleTrack = Sequence(
            LerpColorScaleInterval(self.label, 1, Vec4(1, 1, 1, 0.6),
                                   Vec4(1, 1, 1, 1)),
            LerpColorScaleInterval(self.label, 1, Vec4(1, 1, 1, 1),
                                   Vec4(1, 1, 1, 0.6)))

        if self.labelPosTrack is not None:
            self.labelPosTrack.finish()
            self.labelPosTrack = None

        self.labelPosTrack = Sequence(
            LerpPosInterval(self.label,
                            2,
                            Point3(0, 0, 0.35),
                            Point3(0, 0, 0.15),
                            blendType='easeOut'),
            Func(self.labelColorScaleTrack.loop))
        self.labelPosTrack.start()

        self.acceptOnce('mouse1', self.begin)

    def stop(self):
        self.ignore('mouse1')

        if self.labelPosTrack is not None:
            self.labelPosTrack.finish()
            self.labelPosTrack = None

        if self.labelColorScaleTrack is not None:
            self.labelColorScaleTrack.finish()
            self.labelColorScaleTrack = None

        if self.logoPosTrack is not None:
            self.logoPosTrack.finish()
            self.logoPosTrack = None

        if self.logoScaleTrack is not None:
            self.logoScaleTrack.finish()
            self.logoScaleTrack = None

        if self.fadeTrack is not None:
            self.fadeTrack.finish()
            self.fadeTrack = None

        self.setColorScale(Vec4(0, 0, 0, 0))

    def begin(self):
        base.cr.introDone = True

        if self.fadeTrack is not None:
            self.fadeTrack.finish()
            self.fadeTrack = None

        self.fadeTrack = base.transitions.getFadeOutIval(t=2)

        Sequence(
            Func(self.fadeTrack.start), Wait(2), Func(self.delete),
            Func(base.cr.introduction.delete),
            Func(base.cr.loginFSM.request, 'chooseAvatar', [base.cr.avList]),
            Func(base.transitions.fadeIn, 2)).start()

    def setColorScale(self, *args, **kwargs):
        self.backgroundNodePath.setColorScale(*args, **kwargs)
        self.logo.setColorScale(*args, **kwargs)
        self.label.setColorScale(*args, **kwargs)
        self.versionLabel.setColorScale(*args, **kwargs)