Ejemplo n.º 1
0
def makeDeltaTextEffect(delta, parent, pos):
    from direct.gui.DirectGui import OnscreenText
    text = OnscreenText(text = "", font = getMickeyFont())
    if delta > 0:
        text['fg'] = (0, 1, 0, 1)
        textstr = "+"
    else:
        text['fg'] = (1, 0, 0, 1)
        textstr = ""
    textstr += str(delta)
    text['text'] = textstr
    text.reparentTo(parent)
    text.setPos(pos[0], pos[2])
    text.setTransparency(True, 1)

    from panda3d.core import Point3
    from direct.interval.IntervalGlobal import Sequence, LerpPosInterval, LerpColorScaleInterval, Wait, Parallel
    seq = Parallel()
    seq.append(LerpPosInterval(text, 1.0, Point3(pos) + (0, 0, 0.1), pos))
    seq.append(Sequence(LerpColorScaleInterval(text, 0.25, (1, 1, 1, 1), (1, 1, 1, 0)),
                        Wait(0.5),
                        LerpColorScaleInterval(text, 0.25, (1, 1, 1, 0), (1, 1, 1, 1)),
                        Func(text.destroy)))
    seq.start()
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)
Ejemplo n.º 3
0
class PointCloudViewerApp(Navigator3D):
    def __init__(self, point_cloud_size=17776):
        Navigator3D.__init__(self)
        self._point_cloud = None
        self._point_cloud_coloring = None
        self._cuboids = []
        self.points_vb = PointCloudVertexBuffer(point_cloud_size)
        self._user_text = OnscreenText('', style=1, fg=(1, 1, 1, 1), scale=.04)
        self._user_text.setPos(-0.9, 0.9)

    def redraw_boxes(self):
        if self._boxes is not None:
            for c_index, box in enumerate(self._boxes):
                self._cuboids[c_index].show()

    def draw(self,
             point_cloud=None,
             point_cloud_coloring=None,
             on_screen_text=None,
             boxes=None):
        self._boxes = boxes
        if point_cloud is not None:
            pc_color = self.color_pc(point_cloud, point_cloud_coloring)
            self.draw_pc(point_cloud, pc_color)
        if on_screen_text is not None:
            self._user_text.setText(textwrap.fill(on_screen_text, 90))
        else:
            self._user_text.setText('')
        if boxes is not None:
            self.draw_cuboids(boxes)
            # self.redraw_boxes()

    def color_pc(self,
                 pc,
                 coloring='reflectivity_and_label',
                 colormap='pc_cmap'):
        """
        Generate coloring for point cloud based on multiple options
        :param pc: point cloud
        :param coloring: Coloring option. Supported: 'reflectivity', np.array of point cloud size x 4 with points colors
        :return:
        """
        if colormap is 'pc_cmap':
            colormap = pc_cmap

        points = pc[:, :3]
        color = np.zeros((len(pc), 4))
        color[:, -1] = 1.

        if isinstance(coloring, np.ndarray
                      ) and coloring.dtype == np.int and coloring.shape == (
                          points.shape[0], ):
            cmap = ListedColormap([
                'w',
                'magenta',
                'orange',
                'mediumspringgreen',
                'deepskyblue',
                'pink',
                'y',
                'g',
                'r',
                'purple',
            ])
            coloring = np.mod(coloring, len(cmap.colors))
            c = cm.ScalarMappable(cmap=cmap,
                                  norm=mcolors.Normalize(
                                      vmin=0, vmax=len(cmap.colors) - 1))
            color = c.to_rgba(coloring)
        elif isinstance(coloring, np.ndarray):
            if coloring.shape == (points.shape[0], 4):
                color = coloring
            if coloring.shape == (points.shape[0], ):
                c = cm.ScalarMappable(cmap=colormap)
                color = c.to_rgba(coloring, norm=False)
        elif isinstance(coloring, collections.Callable):
            colors = coloring(points)
            c = cm.ScalarMappable(cmap=colormap)
            color = c.to_rgba(colors)
        elif coloring == 'reflectivity':
            reflectivity = pc[:, 3]
            reflectivity[reflectivity > 1] = 1
            c = cm.ScalarMappable(cmap=colormap)
            color = c.to_rgba(reflectivity, norm=False)
            color[reflectivity < 0] = np.array([1.0, 1.0, 1.0, 1.0])
        elif coloring == 'reflectivity_and_label':
            # pc_colors
            reflectivity = pc[:, 3]
            reflectivity[reflectivity > 1] = 1
            c = cm.ScalarMappable(cmap=colormap)
            color = c.to_rgba(reflectivity, norm=False)
            if pc.shape[-1] == 5:
                labels = pc[:, 4]
                labels_valid = labels[labels > 0]
                c = cm.ScalarMappable(cmap=label_cmap)
                color_labels = c.to_rgba(labels_valid, norm=True)
                color[labels > 0] = color_labels
        else:
            color = np.ones((points.shape[0], 4))
            color[:, -1] = 1.
        return color

    def draw_pc(self, pc, color):
        points = pc[:, np.array([1, 0, 2])]
        self.points_vb.assign_points(points, color)

    def clear_point_cloud(self):
        self.points_vb.clear_pc()

    def draw_cuboids(self, boxes):
        for box_idx, box in enumerate(boxes):
            color = box['color'] if hasattr(box, 'color') else np.ones(4)
            size = box['size']
            translation = box['translation']
            rotation = box['rotation'] / np.pi * 180.
            try:
                text = box['text']
            except:
                text = ''

            if box_idx < len(self._cuboids):
                self._cuboids[box_idx].show()
                self._cuboids[box_idx].update_values(size, translation,
                                                     rotation, color, text)
            else:
                self._cuboids.append(
                    Cuboid(size, translation, rotation, color, text))
        for c in self._cuboids[len(boxes):]:
            c.hide()
class Introduction(DirectObject, FSM):
    notify = directNotify.newCategory('Introduction')

    def __init__(self):
        DirectObject.__init__(self)
        FSM.__init__(self, self.__class__.__name__)

        self.label = OnscreenText('',
                                  parent=hidden,
                                  font=ToontownGlobals.getMinnieFont(),
                                  fg=Vec4(1, 1, 1, 1),
                                  scale=0.06,
                                  align=TextNode.ACenter,
                                  wordwrap=35)
        self.label.setColorScale(Vec4(0, 0, 0, 0))

        gui = loader.loadModel('phase_3/models/gui/tt_m_gui_mat_mainGui.bam')
        shuffleUp = gui.find('**/tt_t_gui_mat_shuffleUp')
        shuffleDown = gui.find('**/tt_t_gui_mat_shuffleDown')
        okUp = gui.find('**/tt_t_gui_mat_okUp')
        okDown = gui.find('**/tt_t_gui_mat_okDown')
        closeUp = gui.find('**/tt_t_gui_mat_closeUp')
        closeDown = gui.find('**/tt_t_gui_mat_closeDown')
        gui.removeNode()
        del gui

        self.exitButton = DirectButton(
            parent=hidden,
            relief=None,
            image=(shuffleUp, shuffleDown, shuffleUp),
            image_scale=(0.6, 0.6, 0.6),
            image1_scale=(0.63, 0.6, 0.6),
            image2_scale=(0.63, 0.6, 0.6),
            text=(TTLocalizer.IntroExitButton, TTLocalizer.IntroExitButton,
                  TTLocalizer.IntroExitButton, ''),
            text_font=ToontownGlobals.getInterfaceFont(),
            text_scale=TTLocalizer.SBshuffleBtn,
            text_pos=(0, -0.02),
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1))

        self.yesButton = DirectButton(
            parent=hidden,
            relief=None,
            image=(okUp, okDown, okUp, okDown),
            image_scale=(0.6, 0.6, 0.6),
            image1_scale=(0.7, 0.7, 0.7),
            image2_scale=(0.7, 0.7, 0.7),
            text=('', TTLocalizer.IntroYesButton, TTLocalizer.IntroYesButton),
            text_font=ToontownGlobals.getInterfaceFont(),
            text_scale=0.08,
            text_align=TextNode.ACenter,
            text_pos=(0, -0.175),
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1))
        self.noButton = DirectButton(
            parent=hidden,
            relief=None,
            image=(closeUp, closeDown, closeUp, closeDown),
            image_scale=(0.6, 0.6, 0.6),
            image1_scale=(0.7, 0.7, 0.7),
            image2_scale=(0.7, 0.7, 0.7),
            text=('', TTLocalizer.IntroNoButton, TTLocalizer.IntroNoButton),
            text_font=ToontownGlobals.getInterfaceFont(),
            text_scale=0.08,
            text_align=TextNode.ACenter,
            text_pos=(0, -0.175),
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1))

        self.disclaimerTrack = None
        self.presentsTrack = None

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

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

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

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

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

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

    def calcLabelY(self):
        sy = self.label.getScale()[1]
        height = self.label.textNode.getHeight()
        return (height * sy) / 2.0

    def enterOff(self):
        pass

    def enterDisclaimer(self):
        self.label.setText(TTLocalizer.IntroDisclaimer)
        self.label.setPos(0, self.calcLabelY())
        self.label.reparentTo(aspect2d)

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

        self.disclaimerTrack = Sequence(
            LerpColorScaleInterval(self.label,
                                   2,
                                   Vec4(1, 1, 1, 1),
                                   Vec4(0, 0, 0, 0),
                                   blendType='easeIn'),
            Wait(3),
            LerpColorScaleInterval(self.label,
                                   2,
                                   Vec4(0, 0, 0, 0),
                                   Vec4(1, 1, 1, 1),
                                   blendType='easeOut'),
        )
        self.disclaimerTrack.start()

    def exitDisclaimer(self):
        if self.disclaimerTrack is not None:
            self.disclaimerTrack.finish()
            self.disclaimerTrack = None

        self.label.reparentTo(hidden)
        self.label.setPos(0, 0)
        self.label.setText('')

    def enterPresents(self):
        self.label.setText(TTLocalizer.IntroPresents)
        self.label.setPos(0, self.calcLabelY())
        self.label.reparentTo(aspect2d)

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

        self.presentsTrack = Sequence(
            LerpColorScaleInterval(self.label,
                                   2,
                                   Vec4(1, 1, 1, 1),
                                   Vec4(0, 0, 0, 0),
                                   blendType='easeIn'),
            Wait(3),
            LerpColorScaleInterval(self.label,
                                   2,
                                   Vec4(0, 0, 0, 0),
                                   Vec4(1, 1, 1, 1),
                                   blendType='easeOut'),
        )
        self.presentsTrack.start()

    def exitPresents(self):
        if self.presentsTrack is not None:
            self.presentsTrack.finish()
            self.presentsTrack = None

        self.label.reparentTo(hidden)
        self.label.setPos(0, 0)
        self.label.setText('')

    def enterLabel(self, text):
        self.label.setText(text)
        self.label.setPos(0, self.calcLabelY())
        self.label.reparentTo(aspect2d)
        self.label.setColorScale(Vec4(1, 1, 1, 1))

    def exitLabel(self):
        self.label.setColorScale(Vec4(0, 0, 0, 0))
        self.label.reparentTo(hidden)
        self.label.setPos(0, 0)
        self.label.setText('')

    def enterExitDialog(self,
                        text,
                        exitButtonCommand=None,
                        exitButtonExtraArgs=[]):
        self.label.setText(text)

        sy = self.label.getScale()[1]
        bottom = self.label.textNode.getBottom() * sy
        lineHeight = self.label.textNode.getLineHeight() * sy
        self.exitButton.setPos(0, 0, bottom - (lineHeight * 2))
        self.exitButton['command'] = exitButtonCommand
        self.exitButton['extraArgs'] = exitButtonExtraArgs

        labelY = self.calcLabelY()

        self.label.setPos(0, labelY)

        self.exitButton.setZ(self.exitButton, labelY)

        self.exitButton.reparentTo(aspect2d)
        self.label.reparentTo(aspect2d)

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

    def exitExitDialog(self):
        self.label.setColorScale(Vec4(0, 0, 0, 0))

        self.label.reparentTo(hidden)
        self.exitButton.reparentTo(hidden)

        self.label.setPos(0, 0)
        self.label.setText('')

        self.exitButton['command'] = None
        self.exitButton['extraArgs'] = []
        self.exitButton.setPos(0, 0, 0)

    def enterYesNoDialog(self,
                         text,
                         yesButtonCommand=None,
                         yesButtonExtraArgs=[],
                         noButtonCommand=None,
                         noButtonExtraArgs=[]):
        self.label.setText(text)

        sy = self.label.getScale()[1]
        bottom = self.label.textNode.getBottom() * sy
        lineHeight = self.label.textNode.getLineHeight() * sy
        self.yesButton.setPos(-0.1, 0, bottom - (lineHeight * 2))
        self.yesButton['command'] = yesButtonCommand
        self.yesButton['extraArgs'] = yesButtonExtraArgs
        self.noButton.setPos(0.1, 0, bottom - (lineHeight * 2))
        self.noButton['command'] = noButtonCommand
        self.noButton['extraArgs'] = noButtonExtraArgs

        labelY = self.calcLabelY()

        self.label.setPos(0, labelY)

        self.yesButton.setZ(self.yesButton, labelY)
        self.noButton.setZ(self.noButton, labelY)

        self.yesButton.reparentTo(aspect2d)
        self.noButton.reparentTo(aspect2d)
        self.label.reparentTo(aspect2d)

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

    def exitYesNoDialog(self):
        self.label.setColorScale(Vec4(0, 0, 0, 0))

        self.label.reparentTo(hidden)
        self.noButton.reparentTo(hidden)
        self.yesButton.reparentTo(hidden)

        self.label.setPos(0, 0)
        self.label.setText('')

        self.noButton['command'] = None
        self.noButton['extraArgs'] = []
        self.noButton.setPos(0, 0, 0)
        self.yesButton['command'] = None
        self.yesButton['extraArgs'] = []
        self.yesButton.setPos(0, 0, 0)

    def enterClickToStart(self):
        base.cr.clickToStart.start()

    def exitClickToStart(self):
        base.cr.clickToStart.stop()
Ejemplo n.º 5
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)
class Introduction(DirectObject, FSM):
    notify = directNotify.newCategory('Introduction')

    def __init__(self):
        DirectObject.__init__(self)
        FSM.__init__(self, self.__class__.__name__)

        self.label = OnscreenText(
            '', parent=hidden, font=ToontownGlobals.getMinnieFont(),
            fg=Vec4(1, 1, 1, 1), scale=0.06, align=TextNode.ACenter,
            wordwrap=35)
        self.label.setColorScale(Vec4(0, 0, 0, 0))

        gui = loader.loadModel('phase_3/models/gui/tt_m_gui_mat_mainGui.bam')
        shuffleUp = gui.find('**/tt_t_gui_mat_shuffleUp')
        shuffleDown = gui.find('**/tt_t_gui_mat_shuffleDown')
        okUp = gui.find('**/tt_t_gui_mat_okUp')
        okDown = gui.find('**/tt_t_gui_mat_okDown')
        closeUp = gui.find('**/tt_t_gui_mat_closeUp')
        closeDown = gui.find('**/tt_t_gui_mat_closeDown')
        gui.removeNode()
        del gui

        self.exitButton = DirectButton(
            parent=hidden, relief=None,
            image=(shuffleUp, shuffleDown, shuffleUp),
            image_scale=(0.6, 0.6, 0.6), image1_scale=(0.63, 0.6, 0.6),
            image2_scale=(0.63, 0.6, 0.6),
            text=(TTLocalizer.IntroExitButton, TTLocalizer.IntroExitButton,
                  TTLocalizer.IntroExitButton, ''),
            text_font=ToontownGlobals.getInterfaceFont(),
            text_scale=TTLocalizer.SBshuffleBtn, text_pos=(0, -0.02),
            text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1))

        self.yesButton = DirectButton(
            parent=hidden, relief=None, image=(okUp, okDown, okUp, okDown),
            image_scale=(0.6, 0.6, 0.6), image1_scale=(0.7, 0.7, 0.7),
            image2_scale=(0.7, 0.7, 0.7),
            text=('', TTLocalizer.IntroYesButton, TTLocalizer.IntroYesButton),
            text_font=ToontownGlobals.getInterfaceFont(), text_scale=0.08,
            text_align=TextNode.ACenter, text_pos=(0, -0.175),
            text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1))
        self.noButton = DirectButton(
            parent=hidden, relief=None,
            image=(closeUp, closeDown, closeUp, closeDown),
            image_scale=(0.6, 0.6, 0.6), image1_scale=(0.7, 0.7, 0.7),
            image2_scale=(0.7, 0.7, 0.7),
            text=('', TTLocalizer.IntroNoButton, TTLocalizer.IntroNoButton),
            text_font=ToontownGlobals.getInterfaceFont(), text_scale=0.08,
            text_align=TextNode.ACenter, text_pos=(0, -0.175),
            text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1))

        self.disclaimerTrack = None
        self.presentsTrack = None

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

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

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

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

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

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

    def calcLabelY(self):
        sy = self.label.getScale()[1]
        height = self.label.textNode.getHeight()
        return (height * sy) / 2.0

    def enterOff(self):
        pass

    def enterDisclaimer(self):
        self.label.setText(TTLocalizer.IntroDisclaimer)
        self.label.setPos(0, self.calcLabelY())
        self.label.reparentTo(aspect2d)

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

        self.disclaimerTrack = Sequence(
            LerpColorScaleInterval(
                self.label, 2, Vec4(1, 1, 1, 1), Vec4(0, 0, 0, 0),
                blendType='easeIn'),
            Wait(3),
            LerpColorScaleInterval(
                self.label, 2, Vec4(0, 0, 0, 0), Vec4(1, 1, 1, 1),
                blendType='easeOut'),
        )
        self.disclaimerTrack.start()

    def exitDisclaimer(self):
        if self.disclaimerTrack is not None:
            self.disclaimerTrack.finish()
            self.disclaimerTrack = None

        self.label.reparentTo(hidden)
        self.label.setPos(0, 0)
        self.label.setText('')

    def enterPresents(self):
        self.label.setText(TTLocalizer.IntroPresents)
        self.label.setPos(0, self.calcLabelY())
        self.label.reparentTo(aspect2d)

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

        self.presentsTrack = Sequence(
            LerpColorScaleInterval(
                self.label, 2, Vec4(1, 1, 1, 1), Vec4(0, 0, 0, 0),
                blendType='easeIn'),
            Wait(3),
            LerpColorScaleInterval(
                self.label, 2, Vec4(0, 0, 0, 0), Vec4(1, 1, 1, 1),
                blendType='easeOut'),
        )
        self.presentsTrack.start()

    def exitPresents(self):
        if self.presentsTrack is not None:
            self.presentsTrack.finish()
            self.presentsTrack = None

        self.label.reparentTo(hidden)
        self.label.setPos(0, 0)
        self.label.setText('')

    def enterLabel(self, text):
        self.label.setText(text)
        self.label.setPos(0, self.calcLabelY())
        self.label.reparentTo(aspect2d)
        self.label.setColorScale(Vec4(1, 1, 1, 1))

    def exitLabel(self):
        self.label.setColorScale(Vec4(0, 0, 0, 0))
        self.label.reparentTo(hidden)
        self.label.setPos(0, 0)
        self.label.setText('')

    def enterExitDialog(self, text, exitButtonCommand=None,
                        exitButtonExtraArgs=[]):
        self.label.setText(text)

        sy = self.label.getScale()[1]
        bottom = self.label.textNode.getBottom() * sy
        lineHeight = self.label.textNode.getLineHeight() * sy
        self.exitButton.setPos(0, 0, bottom - (lineHeight * 2))
        self.exitButton['command'] = exitButtonCommand
        self.exitButton['extraArgs'] = exitButtonExtraArgs

        labelY = self.calcLabelY()

        self.label.setPos(0, labelY)

        self.exitButton.setZ(self.exitButton, labelY)

        self.exitButton.reparentTo(aspect2d)
        self.label.reparentTo(aspect2d)

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

    def exitExitDialog(self):
        self.label.setColorScale(Vec4(0, 0, 0, 0))

        self.label.reparentTo(hidden)
        self.exitButton.reparentTo(hidden)

        self.label.setPos(0, 0)
        self.label.setText('')

        self.exitButton['command'] = None
        self.exitButton['extraArgs'] = []
        self.exitButton.setPos(0, 0, 0)

    def enterYesNoDialog(self, text, yesButtonCommand=None,
                         yesButtonExtraArgs=[], noButtonCommand=None,
                         noButtonExtraArgs=[]):
        self.label.setText(text)

        sy = self.label.getScale()[1]
        bottom = self.label.textNode.getBottom() * sy
        lineHeight = self.label.textNode.getLineHeight() * sy
        self.yesButton.setPos(-0.1, 0, bottom - (lineHeight * 2))
        self.yesButton['command'] = yesButtonCommand
        self.yesButton['extraArgs'] = yesButtonExtraArgs
        self.noButton.setPos(0.1, 0, bottom - (lineHeight * 2))
        self.noButton['command'] = noButtonCommand
        self.noButton['extraArgs'] = noButtonExtraArgs

        labelY = self.calcLabelY()

        self.label.setPos(0, labelY)

        self.yesButton.setZ(self.yesButton, labelY)
        self.noButton.setZ(self.noButton, labelY)

        self.yesButton.reparentTo(aspect2d)
        self.noButton.reparentTo(aspect2d)
        self.label.reparentTo(aspect2d)

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

    def exitYesNoDialog(self):
        self.label.setColorScale(Vec4(0, 0, 0, 0))

        self.label.reparentTo(hidden)
        self.noButton.reparentTo(hidden)
        self.yesButton.reparentTo(hidden)

        self.label.setPos(0, 0)
        self.label.setText('')

        self.noButton['command'] = None
        self.noButton['extraArgs'] = []
        self.noButton.setPos(0, 0, 0)
        self.yesButton['command'] = None
        self.yesButton['extraArgs'] = []
        self.yesButton.setPos(0, 0, 0)

    def enterClickToStart(self):
        base.cr.clickToStart.start()

    def exitClickToStart(self):
        base.cr.clickToStart.stop()