Exemplo n.º 1
0
    def __init__(self, viewport):
        DocObject.__init__(self, viewport.doc)

        self.viewport = viewport

        self.enabled = False
        self.mouseSensitivity = 0.3
        self.cameraSpeed = 500 / 16.0
        self.timeToSpeed = 0.5  # seconds
        self.moveStart = 0.0
        self.cameraRotateSpeed = 75.0
        self.cameraSmooth = 0.7
        self.slideFactor = 0.75
        self.maxPitch = 90
        self.minPitch = -90
        self.diagonalFactor = math.sqrt(2.0) / 2.0
        self.lastSpeeds = Vec3(0)
        self.moving = False

        self.cursor = QtGui.QCursor()
        self.cursor.setShape(QtCore.Qt.BlankCursor)

        tex = base.loader.loadTexture('icons/editor-crosshair.png')
        tex.setMinfilter(SamplerState.FTLinear)
        tex.setMagfilter(SamplerState.FTLinear)
        crosshair = OnscreenImage(tex)
        crosshair.setTransparency(True)
        crosshair.setScale(0.04)
        crosshair.reparentTo(NodePath())
        self.crosshair = crosshair

        self.inputState = {}

        self.addInput("forward", KeyBind.Forward3DView)
        self.addInput("reverse", KeyBind.Back3DView)
        self.addInput("slideLeft", KeyBind.Left3DView)
        self.addInput("slideRight", KeyBind.Right3DView)
        self.addInput("floatDown", KeyBind.Down3DView)
        self.addInput("floatUp", KeyBind.Up3DView)
        self.addInput("lookUp", KeyBind.LookUp3DView)
        self.addInput("lookDown", KeyBind.LookDown3DView)
        self.addInput("lookRight", KeyBind.LookRight3DView)
        self.addInput("lookLeft", KeyBind.LookLeft3DView)

        self.accept(KeyBinds.getPandaShortcut(KeyBind.FlyCam), self.handleZ)

        self.doc.taskMgr.add(self.__flyCamTask, 'flyCam')
Exemplo n.º 2
0
def makeLoadingScreen(firstTime = False):
    global LoadingScreen
    if firstTime:
        base.transitions.fadeScreen(1.0)

    from direct.gui.DirectGui import OnscreenText, DGG, OnscreenImage

    if not firstTime:
        # Freeze the current frame
        ss = base.win.getScreenshot()
        img = OnscreenImage(image = ss)
        img.reparentTo(render2d, DGG.FADE_SORT_INDEX - 1)
        base.transitions.fadeScreen(0.5)
    else:
        img = None

    txt = OnscreenText(text = "Loading...", fg = (1, 1, 1, 1), mayChange = False)
    txt.reparentTo(aspect2d, DGG.NO_FADE_SORT_INDEX)

    base.renderFrames()

    LoadingScreen = (img, txt)
Exemplo n.º 3
0
ConfigVariableDouble('decompressor-step-time').setValue(0.01)
ConfigVariableDouble('extractor-step-time').setValue(0.01)

# loading screen
backgroundNodePath = aspect2d.attachNewNode(backgroundNode, 0)
backgroundNodePath.setPos(0.0, 0.0, 0.0)
backgroundNodePath.setScale(render2d, VBase3(1))
backgroundNodePath.find('**/bg').setBin('fixed', 10)

# change the logo
backgroundNodePath.find('**/fg').stash()

from direct.gui.DirectGui import OnscreenImage
logo = OnscreenImage('phase_3/maps/toontown-logo-new.png')
logo.reparentTo(backgroundNodePath)
logo.setBin('fixed', 20)
logo.setTransparency(TransparencyAttrib.MAlpha)
logo.setScale(.8, 1, .7)
logo.setZ(.3)

base.graphicsEngine.renderFrame()

# default DGG stuff
DirectGuiGlobals.setDefaultRolloverSound(
    base.loadSfx('phase_3/audio/sfx/GUI_rollover.ogg'))
DirectGuiGlobals.setDefaultClickSound(
    base.loadSfx('phase_3/audio/sfx/GUI_create_toon_fwd.ogg'))
DirectGuiGlobals.setDefaultDialogGeom(
    loader.loadModel('phase_3/models/gui/dialog_box_gui'))
class CIProgressScreen:

    Color = (118 / 255.0, 121 / 255.0, 127 / 255.0, 1.0)
    BarColor = (152 / 255.0, 129 / 255.0, 64 / 255.0, 1.0)

    def __init__(self):
        self.defaultLogoScale = 1
        self.defaultLogoZ = 0.65
        self.bgm = loader.loadModel(
            "phase_3/models/gui/progress-background.bam")
        self.bgm.find('**/logo').stash()
        self.barShadow = OnscreenImage(image=self.bgm.find("**/bar_shadow"),
                                       parent=hidden)
        self.bgm.find("**/bar_shadow").removeNode()
        self.bg = self.bgm.find('**/bg')
        self.defaultBgTexture = self.bg.findTexture('*')

        self.logoNode, self.logoImg = CIGlobals.getLogoImage(
            hidden, self.defaultLogoScale, (0, 0, self.defaultLogoZ))

        self.bg_img = OnscreenImage(image=self.bg, parent=hidden)
        self.bg_img.setSx(1.35)
        self.bg_img.hide()
        self.progress_bar = DirectWaitBar(value=0,
                                          pos=(0, 0, -0.85),
                                          parent=hidden,
                                          text_pos=(0, 0, 0.2))
        self.progress_bar.setSx(1.064)
        self.progress_bar.setSz(0.38)
        toontipgui = loader.loadModel(
            'phase_3.5/models/gui/stickerbook_gui.bam')
        poster = toontipgui.find('**/questCard')
        self.toontipFrame = DirectFrame(image=poster,
                                        image_scale=(1.4, 1, 1),
                                        parent=hidden,
                                        relief=None,
                                        pos=(0, 0, -0.1),
                                        scale=0.85)
        self.toontipLbl = OnscreenText(text="",
                                       parent=self.toontipFrame,
                                       fg=(89.0 / 255, 95.0 / 255, 98.0 / 255,
                                           1),
                                       font=CIGlobals.getToonFont(),
                                       wordwrap=13,
                                       pos=(-0.59, 0.25),
                                       align=TextNode.ALeft,
                                       scale=0.08)
        self.loading_lbl = DirectLabel(text="",
                                       relief=None,
                                       scale=0.08,
                                       pos=(-1.0725, 0, -0.79),
                                       text_align=TextNode.ALeft,
                                       sortOrder=100,
                                       text_fg=(1, 1, 1, 1),
                                       text_font=CIGlobals.getMinnieLogoFont(),
                                       parent=hidden,
                                       text_shadow=(0, 0, 0, 0))

        # This is useful when the user has chosen to hide aspect2d before the loading screen.
        # However, we want to show the loading screen all the time, so we need to restore the
        # previous state after the loading screen ends.
        self.mustRestoreHiddenAspect2d = False

    def begin(self, hood, range, wantGui):
        render.hide()
        NametagGlobals.setWant2dNametags(False)

        if base.aspect2d.isHidden():
            base.aspect2d.show()
            self.mustRestoreHiddenAspect2d = True

        self.renderFrames()
        base.setBackgroundColor(0, 0, 0)
        if hood == "localAvatarEnterGame":
            self.loading_lbl['text'] = "Entering..."
        elif hood == "init":
            self.loading_lbl['text'] = "Loading..."
        else:
            self.loading_lbl['text'] = "Heading to %s..." % hood
        self.progress_bar['barColor'] = self.BarColor
        self.progress_bar['range'] = range
        self.bgm.reparentTo(aspect2d)

        ZoneUtil.Hood2ZoneId.keys()

        # We only want to show special loading screens for actual in-game locations.
        if hood in ZoneUtil.Hood2ZoneId.keys():
            abbr = ZoneUtil.ZoneId2HoodAbbr.get(
                ZoneUtil.Hood2ZoneId.get(hood)).lower()
            bgTexture = loader.loadTexture(
                'phase_14/maps/{0}_loading.png'.format(abbr), okMissing=True)

            if bgTexture:
                self.bg.setTexture(bgTexture, 1)

        self.barShadow.reparentTo(aspect2d)
        self.bg.reparentTo(render2d)
        self.bg_img.reparentTo(hidden)
        self.loading_lbl.reparentTo(aspect2d)
        self.logoNode.reparentTo(aspect2d)
        self.progress_bar.reparentTo(aspect2d)
        tip = random.choice(CIGlobals.ToonTips)
        self.toontipLbl.setText("TOON TIP:\n" + tip)
        self.toontipFrame.reparentTo(aspect2d)
        self.__count = 0
        self.__expectedCount = range
        self.progress_bar.update(self.__count)

    def renderFramesTask(self, task):
        self.renderFrames()
        return task.cont

    def end(self):
        base.setBackgroundColor(CIGlobals.DefaultBackgroundColor)
        taskMgr.remove("renderFrames")
        render.show()

        if self.mustRestoreHiddenAspect2d:
            base.aspect2d.hide()
            self.mustRestoreHiddenAspect2d = False

        self.progress_bar.finish()
        self.bg_img.reparentTo(hidden)
        self.logoNode.reparentTo(hidden)
        self.barShadow.reparentTo(hidden)
        self.bg.reparentTo(hidden)

        # Let's get rid of the extra texture stage.
        self.bg.setTexture(self.defaultBgTexture, 1)

        self.bgm.reparentTo(hidden)
        self.loading_lbl.reparentTo(hidden)
        self.progress_bar.reparentTo(hidden)
        self.toontipFrame.reparentTo(hidden)
        base.transitions.fadeScreen(1.0)
        NametagGlobals.setWant2dNametags(True)
        self.renderFrames()

    def destroy(self):
        self.bg.removeNode()
        del self.bg
        self.bgm.removeNode()
        del self.bgm
        self.bg_img.destroy()
        self.barShadow.destroy()
        del self.barShadow
        self.loading_lbl.destroy()
        self.progress_bar.destroy()
        self.bgm.destroy()
        self.mustRestoreHiddenAspect2d = False
        del self.bg_img
        del self.loading_lbl
        del self.progress_bar
        del self.bgm
        del self.defaultBgTexture
        del self.mustRestoreHiddenAspect2d

    def renderFrames(self):
        base.graphicsEngine.renderFrame()
        base.graphicsEngine.renderFrame()

    def tick(self):
        self.__count += 1
        self.progress_bar.update(self.__count)
Exemplo n.º 5
0
ConfigVariableDouble('decompressor-step-time').setValue(0.01)
ConfigVariableDouble('extractor-step-time').setValue(0.01)

# loading screen
backgroundNodePath = aspect2d.attachNewNode(backgroundNode, 0)
backgroundNodePath.setPos(0.0, 0.0, 0.0)
backgroundNodePath.setScale(render2d, VBase3(1))
backgroundNodePath.find('**/bg').setBin('fixed', 10)

# change the logo
backgroundNodePath.find('**/fg').stash()

from direct.gui.DirectGui import OnscreenImage
logo = OnscreenImage('phase_3/maps/toontown-logo-new.png')
logo.reparentTo(backgroundNodePath)
logo.setBin('fixed', 20)
logo.setTransparency(TransparencyAttrib.MAlpha)

base.graphicsEngine.renderFrame()

# default DGG stuff
DirectGuiGlobals.setDefaultRolloverSound(base.loadSfx('phase_3/audio/sfx/GUI_rollover.ogg'))
DirectGuiGlobals.setDefaultClickSound(base.loadSfx('phase_3/audio/sfx/GUI_create_toon_fwd.ogg'))
DirectGuiGlobals.setDefaultDialogGeom(loader.loadModel('phase_3/models/gui/dialog_box_gui'))

# localizer
import TTLocalizer
from otp.otpbase import OTPGlobals
OTPGlobals.setDefaultProductPrefix(TTLocalizer.ProductPrefix)
Exemplo n.º 6
0
class CIProgressScreen:

    def __init__(self):
        self.bgm = loader.loadModel('phase_3/models/gui/progress-background.bam')
        self.bgm.find('**/logo').stash()
        self.bg = self.bgm.find('**/bg')
        self.logo = loader.loadTexture('phase_3/maps/CogInvasion_Logo.png')
        self.logoImg = OnscreenImage(image=self.logo, scale=(0.5, 0, 0.3), pos=(0, 0, 0), parent=hidden)
        self.logoImg.setTransparency(True)
        self.bg_img = OnscreenImage(image=self.bg, parent=hidden)
        self.bg_img.setSx(1.35)
        self.bg_img.hide()
        self.progress_bar = DirectWaitBar(value=0, pos=(0, 0, -0.85), parent=hidden, text_pos=(0, 0, 0.2))
        self.progress_bar.setSx(1.064)
        self.progress_bar.setSz(0.38)
        self.loading_lbl = DirectLabel(text='', relief=None, scale=0.08, pos=(-1.0725, 0, -0.79), text_align=TextNode.ALeft, sortOrder=100, text_fg=(0.343, 0.343, 0.343, 1.0), text_font=CIGlobals.getMinnieFont(), parent=hidden, text_shadow=(0, 0, 0, 1))
        return

    def begin(self, hood, range, wantGui):
        render.hide()
        self.renderFrames()
        base.setBackgroundColor(0, 0, 0)
        if hood == 'localAvatarEnterGame':
            self.loading_lbl['text'] = 'Entering...'
        elif hood == 'init':
            self.loading_lbl['text'] = 'Loading...'
        else:
            self.loading_lbl['text'] = 'Heading to %s...' % hood
        self.progress_bar['barColor'] = (0.343, 0.343, 0.343, 1.0)
        self.progress_bar['range'] = range
        self.bgm.reparentTo(aspect2d)
        self.bg.reparentTo(render2d)
        self.bg_img.reparentTo(hidden)
        self.loading_lbl.reparentTo(aspect2d)
        self.logoImg.reparentTo(aspect2d)
        self.progress_bar.reparentTo(aspect2d)
        self.__count = 0
        self.__expectedCount = range
        self.progress_bar.update(self.__count)

    def renderFramesTask(self, task):
        self.renderFrames()
        return task.cont

    def end(self):
        base.setBackgroundColor(CIGlobals.DefaultBackgroundColor)
        taskMgr.remove('renderFrames')
        render.show()
        self.progress_bar.finish()
        self.bg_img.reparentTo(hidden)
        self.logoImg.reparentTo(hidden)
        self.bg.reparentTo(hidden)
        self.bgm.reparentTo(hidden)
        self.loading_lbl.reparentTo(hidden)
        self.progress_bar.reparentTo(hidden)
        self.renderFrames()

    def destroy(self):
        self.bg.removeNode()
        del self.bg
        self.bgm.removeNode()
        del self.bgm
        self.bg_img.destroy()
        self.loading_lbl.destroy()
        self.progress_bar.destroy()
        self.bgm.destroy()
        del self.bg_img
        del self.loading_lbl
        del self.progress_bar
        del self.bgm

    def renderFrames(self):
        base.graphicsEngine.renderFrame()
        base.graphicsEngine.renderFrame()

    def tick(self):
        self.__count += 1
        self.progress_bar.update(self.__count)
Exemplo n.º 7
0
class CIProgressScreen:

    def __init__(self):
        self.defaultLogoScale = 0.85
        self.defaultLogoZ = 0.65
        self.bgm = loader.loadModel('phase_3/models/gui/progress-background.bam')
        self.bgm.find('**/logo').stash()
        self.bg = self.bgm.find('**/bg')
        self.logo = loader.loadTexture('phase_3/maps/CogInvasion_Logo.png')
        self.logoNode = hidden.attachNewNode('logoNode')
        self.logoNode.setScale(self.defaultLogoScale)
        self.logoNode.setPos(0, self.defaultLogoZ, 0)
        self.logoImg = OnscreenImage(image=self.logo, scale=(0.685, 0, 0.3), parent=self.logoNode)
        self.logoImg.setTransparency(True)
        self.bg_img = OnscreenImage(image=self.bg, parent=hidden)
        self.bg_img.setSx(1.35)
        self.bg_img.hide()
        self.progress_bar = DirectWaitBar(value=0, pos=(0, 0, -0.85), parent=hidden, text_pos=(0,
                                                                                               0,
                                                                                               0.2))
        self.progress_bar.setSx(1.064)
        self.progress_bar.setSz(0.38)
        toontipgui = loader.loadModel('phase_3.5/models/gui/stickerbook_gui.bam')
        poster = toontipgui.find('**/questCard')
        self.toontipFrame = DirectFrame(image=poster, image_scale=(1.4, 1, 1), parent=hidden, relief=None, pos=(0,
                                                                                                                0,
                                                                                                                -0.1), scale=0.85)
        self.toontipLbl = OnscreenText(text='', parent=self.toontipFrame, fg=(0.35,
                                                                              0.35,
                                                                              0.35,
                                                                              1), font=CIGlobals.getToonFont(), wordwrap=14.5, pos=(-0.59,
                                                                                                                                    0.25), align=TextNode.ALeft, scale=0.08)
        self.loading_lbl = DirectLabel(text='', relief=None, scale=0.08, pos=(-1.0725,
                                                                              0,
                                                                              -0.79), text_align=TextNode.ALeft, sortOrder=100, text_fg=(0.343,
                                                                                                                                         0.343,
                                                                                                                                         0.343,
                                                                                                                                         1.0), text_font=CIGlobals.getMinnieFont(), parent=hidden, text_shadow=(0,
                                                                                                                                                                                                                0,
                                                                                                                                                                                                                0,
                                                                                                                                                                                                                1))
        return

    def begin(self, hood, range, wantGui):
        render.hide()
        self.renderFrames()
        base.setBackgroundColor(0, 0, 0)
        if hood == 'localAvatarEnterGame':
            self.loading_lbl['text'] = 'Entering...'
        else:
            if hood == 'init':
                self.loading_lbl['text'] = 'Loading...'
            else:
                self.loading_lbl['text'] = 'Heading to %s...' % hood
        self.progress_bar['barColor'] = (0.343, 0.343, 0.343, 1.0)
        self.progress_bar['range'] = range
        self.bgm.reparentTo(aspect2d)
        self.bg.reparentTo(render2d)
        self.bg_img.reparentTo(hidden)
        self.loading_lbl.reparentTo(aspect2d)
        self.logoNode.reparentTo(aspect2d)
        self.progress_bar.reparentTo(aspect2d)
        tip = random.choice(CIGlobals.ToonTips)
        self.toontipLbl.setText('TOON TIP:\n' + tip)
        self.toontipFrame.reparentTo(aspect2d)
        self.__count = 0
        self.__expectedCount = range
        self.progress_bar.update(self.__count)

    def renderFramesTask(self, task):
        self.renderFrames()
        return task.cont

    def end(self):
        base.setBackgroundColor(CIGlobals.DefaultBackgroundColor)
        taskMgr.remove('renderFrames')
        render.show()
        self.progress_bar.finish()
        self.bg_img.reparentTo(hidden)
        self.logoNode.reparentTo(hidden)
        self.bg.reparentTo(hidden)
        self.bgm.reparentTo(hidden)
        self.loading_lbl.reparentTo(hidden)
        self.progress_bar.reparentTo(hidden)
        self.toontipFrame.reparentTo(hidden)
        self.renderFrames()

    def destroy(self):
        self.bg.removeNode()
        del self.bg
        self.bgm.removeNode()
        del self.bgm
        self.bg_img.destroy()
        self.loading_lbl.destroy()
        self.progress_bar.destroy()
        self.bgm.destroy()
        del self.bg_img
        del self.loading_lbl
        del self.progress_bar
        del self.bgm

    def renderFrames(self):
        base.graphicsEngine.renderFrame()
        base.graphicsEngine.renderFrame()

    def tick(self):
        self.__count += 1
        self.progress_bar.update(self.__count)
Exemplo n.º 8
0
class DMenuScreen(DirectObject):
    notify = directNotify.newCategory('DMenuScreen')

    def __init__(self):
        DirectObject.__init__(self)
        base.cr.DMENU_SCREEN = self
        self.seq = None
        self.isSeqPlaying = False  # .isPlaying() doesnt want to work
        if DMENU_GAME == 'Toontown':
            base.cr.avChoice = None
        fadeSequence = Sequence(
            Func(base.transitions.fadeOut, .001), Wait(.5),
            Func(base.transitions.fadeIn, .5),
            base.camera.posHprInterval(1,
                                       Point3(MAIN_POS),
                                       VBase3(MAIN_HPR),
                                       blendType='easeInOut')).start()
        if DMENU_GAME == 'Toontown':
            self.background = loader.loadModel(
                'phase_3.5/models/modules/tt_m_ara_int_toonhall')
            self.background.reparentTo(render)
            self.background.setPosHpr(-25, 0, 8.1, -95, 0, 0)
            ropes = loader.loadModel(
                'phase_4/models/modules/tt_m_ara_int_ropes')
            ropes.reparentTo(self.background)
            self.sillyMeter = Actor.Actor(
                'phase_4/models/props/tt_a_ara_ttc_sillyMeter_default', {
                    'arrowTube':
                    'phase_4/models/props/tt_a_ara_ttc_sillyMeter_arrowFluid',
                    'phaseOne':
                    'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseOne',
                    'phaseTwo':
                    'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseTwo',
                    'phaseThree':
                    'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseThree',
                    'phaseFour':
                    'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFour',
                    'phaseFourToFive':
                    'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFourToFive',
                    'phaseFive':
                    'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFive'
                })
            self.sillyMeter.reparentTo(self.background)
            self.sillyMeter.makeSubpart('arrow',
                                        ['uvj_progressBar*', 'def_springA'])
            self.sillyMeter.makeSubpart('meter', ['def_pivot'],
                                        ['uvj_progressBar*', 'def_springA'])
            self.audio3d = Audio3DManager.Audio3DManager(
                base.sfxManagerList[0], camera)

            self.phase3Sfx = self.audio3d.loadSfx(
                'phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseThree.ogg')
            self.phase3Sfx.setLoop(True)
            self.arrowSfx = self.audio3d.loadSfx(
                'phase_4/audio/sfx/tt_s_prp_sillyMeterArrow.ogg')
            self.arrowSfx.setLoop(False)
            self.phase3Sfx.setVolume(0.2)
            self.arrowSfx.setVolume(0.2)

            self.animSeq = Sequence(
                Sequence(
                    ActorInterval(self.sillyMeter,
                                  'arrowTube',
                                  partName='arrow',
                                  constrainedLoop=0,
                                  startFrame=236,
                                  endFrame=247), Func(self.arrowSfx.play)),
                Parallel(
                    ActorInterval(self.sillyMeter,
                                  'arrowTube',
                                  partName='arrow',
                                  duration=604800,
                                  constrainedLoop=1,
                                  startFrame=247,
                                  endFrame=276),
                    Sequence(
                        Func(self.phase3Sfx.play),
                        Func(self.audio3d.attachSoundToObject, self.phase3Sfx,
                             self.sillyMeter))))
            self.animSeq.start()
            self.smPhase2 = self.sillyMeter.find('**/stage2')
            self.smPhase2.show()
            self.sillyMeter.loop('phaseOne', partName='meter')
            self.sillyMeter.setBlend(frameBlend=True)

            self.surlee = Toon.Toon()
            self.surlee.setName('Doctor Surlee')
            self.surlee.setPickable(0)
            self.surlee.setPlayerType(CCNonPlayer)
            dna = ToonDNA.ToonDNA()
            dna.newToonFromProperties('pls', 'ls', 'l', 'm', 9, 0, 9, 9, 98,
                                      27, 86, 27, 38, 27)
            self.surlee.setDNA(dna)
            self.surlee.loop('scientistGame')
            self.surlee.reparentTo(self.background)
            self.surlee.setPosHpr(13, 24, 0.025, -180, 0, 0)

            self.dimm = Toon.Toon()
            self.dimm.setName('Doctor Dimm')
            self.dimm.setPickable(0)
            self.dimm.setPlayerType(CCNonPlayer)
            dna = ToonDNA.ToonDNA()
            dna.newToonFromProperties('fll', 'ss', 's', 'm', 15, 0, 15, 15, 99,
                                      27, 86, 27, 39, 27)
            self.dimm.setDNA(dna)
            self.dimm.loop('scientistGame')
            self.dimm.reparentTo(self.background)
            self.dimm.setPosHpr(16, 24, 0.025, -180, 0, 0)

            surleeHand = self.surlee.find('**/def_joint_right_hold')
            clipBoard = loader.loadModel(
                'phase_4/models/props/tt_m_prp_acs_clipboard')
            surleeHandNode = surleeHand.attachNewNode('ClipBoard')
            clipBoard.instanceTo(surleeHandNode)
            surleeHandNode.setH(180)
            surleeHandNode.setScale(render, 1.0)
            surleeHandNode.setPos(0, 0, 0.1)

            dimmHand = self.dimm.find('**/def_joint_right_hold')
            sillyReader = loader.loadModel(
                'phase_4/models/props/tt_m_prp_acs_sillyReader')
            dimHandNode = dimmHand.attachNewNode('SillyReader')
            sillyReader.instanceTo(dimHandNode)
            dimHandNode.setH(180)
            dimHandNode.setScale(render, 1.0)
            dimHandNode.setPos(0, 0, 0.1)

            self.banana = self.background.find('**/gagBanana')

            self.bananaClicker = CollisionTraverser()
            #self.bananaClicker.showCollisions(render)
            self.collHandlerQueue = CollisionHandlerQueue()

            self.bananaRayNode = CollisionNode('bananaMouseRay')
            self.bananaRayNP = base.camera.attachNewNode(self.bananaRayNode)
            self.bananaRayNode.setIntoCollideMask(BitMask32.bit(0))
            self.bananaRayNode.setFromCollideMask(BitMask32.bit(1))
            self.banana.setCollideMask(BitMask32.bit(1))
            self.ray = CollisionRay()
            self.bananaRayNode.addSolid(self.ray)
            self.bananaClicker.addCollider(self.bananaRayNP,
                                           self.collHandlerQueue)
            self.accept("mouse1", self.slipAndSlideOnThisBananaPeelHaHaHa)

            for frame in render.findAllMatches('*/doorFrame*'):
                frame.removeNode()
            self.sky = loader.loadModel('phase_3.5/models/props/TT_sky')
            SkyUtil.startCloudSky(self)
            base.camera.setPosHpr(MAIN_POS, MAIN_HPR)

        self.logo = OnscreenImage(image=GameLogo, scale=(.5, .5, .25))
        self.logo.reparentTo(aspect2d)
        self.logo.setTransparency(TransparencyAttrib.MAlpha)
        scale = self.logo.getScale()
        self.logo.setPos(0, 0, .5)
        self.logo.setColorScale(Vec4(0, 0, 0, 0))
        fadeInLogo = (LerpColorScaleInterval(self.logo, 1, Vec4(1, 1, 1, 1),
                                             Vec4(1, 1, 1, 0))).start()

        self.createButtons()

        self.fadeOut = None
        self.optionsMgr = PickAToonOptions.NewPickAToonOptions()
        #self.quitConfirmation = DMenuQuit()
        self.patNode = None

        if DMENU_GAME == 'Toontown':
            # TT: We need these to run the Pick A Toon screen
            self.patAvList = base.cr.PAT_AVLIST
            self.patFSM = base.cr.PAT_LOGINFSM
            self.patDoneEvent = base.cr.PAT_DONEEVENT

    def slipAndSlideOnThisBananaPeelHaHaHa(self):
        if base.mouseWatcherNode.hasMouse():
            mpos = base.mouseWatcherNode.getMouse()

            def setPlayingStatus(status):
                self.isSeqPlaying = status

            self.ray.setFromLens(base.camNode, mpos.getX(), mpos.getY())
            self.bananaClicker.traverse(render)

            if self.collHandlerQueue.getNumEntries() > 0:
                self.collHandlerQueue.sortEntries()
                pickedObj = self.collHandlerQueue.getEntry(0).getIntoNodePath()
                surleeAnim = random.choice(['slip-backward', 'slip-forward'])
                dimmAnim = random.choice(['slip-backward', 'slip-forward'])
                if pickedObj == self.banana:
                    self.seq = Sequence(
                        Func(setPlayingStatus, True),
                        Func(self.surlee.play, surleeAnim),
                        Func(self.dimm.play, dimmAnim), Wait(3),
                        Func(self.surlee.loop, 'scientistGame'),
                        Func(self.dimm.loop, 'scientistGame'),
                        Func(setPlayingStatus, False))
                    if not self.isSeqPlaying:
                        self.seq.start()

    def skyTrack(self, task):
        return SkyUtil.cloudSkyTrack(task)

    def createButtons(self):
        buttonImage = GuiModel.find('**/QuitBtn_RLVR')

        self.PlayButton = DirectButton(relief=None,
                                       text_style=3,
                                       text_fg=(1, 1, 1, 1),
                                       text=PlayGame,
                                       text_scale=.1,
                                       scale=0.95,
                                       command=self.playGame)
        self.PlayButton.reparentTo(aspect2d)
        self.PlayButton.setPos(PlayBtnHidePos)
        self.PlayButton.show()

        self.OptionsButton = DirectButton(relief=None,
                                          text_style=3,
                                          text_fg=(1, 1, 1, 1),
                                          text=Options,
                                          text_scale=.1,
                                          scale=0.95,
                                          command=self.openOptions)
        self.OptionsButton.reparentTo(aspect2d)
        self.OptionsButton.setPos(OptionsBtnHidePos)
        self.OptionsButton.show()

        self.QuitButton = DirectButton(relief=None,
                                       text_style=3,
                                       text_fg=(1, 1, 1, 1),
                                       text=Quit,
                                       text_scale=.1,
                                       scale=0.95,
                                       command=self.quitGame)
        self.QuitButton.reparentTo(aspect2d)
        self.QuitButton.setPos(QuitBtnHidePos)
        self.QuitButton.show()

        # self.BRButton = DirectButton(text = 'REPORT BUG', text_scale = .1, scale=0.95)
        # self.BRButton.reparentTo(aspect2d)
        # self.BRButton.setPos(-.9, 0, -.9)
        # self.BRButton.show()

        self.buttonInAnimation()

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

        if self.background is not None:
            self.background.hide()
            self.background.reparentTo(hidden)
            self.background.removeNode()
            self.background = None

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

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

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

        if self.phase3Sfx:
            self.phase3Sfx.stop()
            del self.phase3Sfx

        if self.surlee:
            self.surlee.delete()
        if self.dimm:
            self.dimm.delete()

        del self.bananaRayNode
        del self.bananaRayNP
        del self.bananaClicker
        del self.collHandlerQueue
        del self.ray

        self.ignoreAll()

        taskMgr.remove('skyTrack')
        self.sky.reparentTo(hidden)

    def openOptions(self):
        self.optionsMgr.showOptions()
        self.closeOptionsButton = DirectButton(
            relief=None,
            image=(btnUp, btnDn, btnRlvr),
            text="Back",
            text_fg=(0, 0, 0, 1),
            text_scale=TTLocalizer.AClogoutButton,
            text_pos=(0, -0.035),
            image_scale=1,
            image1_scale=1.05,
            image2_scale=1.05,
            scale=0.7,
            command=self.hideOptions)
        self.closeOptionsButton.reparentTo(base.a2dTopLeft)
        self.closeOptionsButton.setPos(0.5, 0, -0.07)
        Parallel(
            self.PlayButton.posInterval(.5,
                                        Point3(PlayBtnHidePos),
                                        blendType='easeInOut'),
            self.OptionsButton.posInterval(.5,
                                           Point3(OptionsBtnHidePos),
                                           blendType='easeInOut'),
            self.QuitButton.posInterval(.5,
                                        Point3(QuitBtnHidePos),
                                        blendType='easeInOut'),
            self.logo.posInterval(0.5,
                                  Point3(0, 0, 2.5),
                                  blendType='easeInOut')).start()

    def hideOptions(self):
        self.optionsMgr.hideOptions()
        self.closeOptionsButton.hide()
        self.buttonInAnimation()

    def playGame(self):
        if self.fadeOut is not None:
            self.fadeOut.finish()
            self.fadeOut = None
        self.fadeOut = base.transitions.getFadeOutIval(t=1)
        #base.camera.posHprInterval(1, Point3(TOON_HALL_POS), VBase3(TOON_HALL_HPR), blendType = 'easeInOut').start()
        Sequence(
            Func(self.doPlayButton),
            Wait(1),
            #Func(self.murder),
            Func(self.enterGame)).start()
        #Func(base.transitions.fadeIn, 1)).start()

    def enterOptions(self):
        pass

    def enterGame(self):
        base.cr.avChoice = PickAToon.PickAToon(self.patAvList, self.patFSM,
                                               self.patDoneEvent)
        base.cr.avChoice.load()
        base.cr.avChoice.enter()

    def doPlayButton(self):
        Parallel(
            self.PlayButton.posInterval(1,
                                        Point3(PlayBtnHidePos),
                                        blendType='easeInOut'),
            self.OptionsButton.posInterval(1,
                                           Point3(OptionsBtnHidePos),
                                           blendType='easeInOut'),
            self.QuitButton.posInterval(1,
                                        Point3(QuitBtnHidePos),
                                        blendType='easeInOut'),
            self.logo.posInterval(0.5,
                                  Point3(0, 0, 2.5),
                                  blendType='easeInOut')).start()

    def quitGame(self):
        self.showQuitConfirmation()

    def showQuitConfirmation(self):
        #self.quitConfirmation.showConfirmation()
        base.exitFunc()

    def buttonInAnimation(self):
        logo = self.logo.posInterval(.5,
                                     Point3(0, 0, .5),
                                     blendType='easeInOut')
        play = self.PlayButton.posInterval(.5,
                                           Point3(PlayBtnPos),
                                           blendType='easeInOut')
        opt = self.OptionsButton.posInterval(.5,
                                             Point3(OptionsBtnPos),
                                             blendType='easeInOut')
        quit = self.QuitButton.posInterval(.5,
                                           Point3(QuitBtnPos),
                                           blendType='easeInOut')

        Sequence(Func(logo.start), Wait(0.1), Func(play.start), Wait(0.2),
                 Func(opt.start), Wait(0.2), Func(quit.start)).start()

    def showHamburgerMenu(self):
        self.hbButton.hide()
        self.hbHideButton.show()

        self.patNode2d = aspect2d.find("**/patNode2d")
        self.patNode2d.posInterval(.5, Point3(.5, 0, 0),
                                   blendType='easeInOut').start()

        self.patNode = render.find("**/patNode")
        self.patNode.posInterval(.5, Point3(0, -3, 0),
                                 blendType='easeInOut').start()

    def hideHamburgerMenu(self):
        self.hbButton.show()
        self.hbHideButton.hide()

        self.patNode2d.posInterval(.5, Point3(0, 0, 0),
                                   blendType='easeInOut').start()

        self.patNode.posInterval(.5, Point3(0, 0, 0),
                                 blendType='easeInOut').start()

    def reportBug(self):
        BugReportGUI.BugReportGUI()

    def createTabs(self):
        self.PlayButton = DirectButton(relief=None,
                                       text_style=3,
                                       text_fg=(1, 1, 1, 1),
                                       text=PlayGame,
                                       text_scale=.1,
                                       scale=0.95,
                                       command=self.playGame)
        self.PlayButton.reparentTo(aspect2d)
        self.PlayButton.setPos(PlayBtnHidePos)
        self.PlayButton.show()

        self.OptionsButton = DirectButton(relief=None,
                                          text_style=3,
                                          text_fg=(1, 1, 1, 1),
                                          text=Options,
                                          text_scale=.1,
                                          scale=0.95,
                                          command=self.openOptions)
        self.OptionsButton.reparentTo(aspect2d)
        self.OptionsButton.setPos(OptionsBtnHidePos)
        self.OptionsButton.show()

        self.QuitButton = DirectButton(relief=None,
                                       text_style=3,
                                       text_fg=(1, 1, 1, 1),
                                       text=Quit,
                                       text_scale=.1,
                                       scale=0.95,
                                       command=self.quitGame)
        self.QuitButton.reparentTo(aspect2d)
        self.QuitButton.setPos(QuitBtnHidePos)
        self.QuitButton.show()
Exemplo n.º 9
0
class DMenuScreen(DirectObject):
    notify = directNotify.newCategory('DMenuScreen')

    def __init__(self):#, avatarList, parentFSM, doneEvent):
        DirectObject.__init__(self)
        base.disableMouse()
        #base.cr.avChoice = None
        fadeSequence = Sequence(
            Wait(.5),
            Func(base.transitions.fadeIn, .5),
            Wait(1)).start()#,
            #base.camera.posHprInterval(1, Point3(MAIN_POS), VBase3(MAIN_HPR), blendType = 'easeInOut')).start()
        #self.background = loader.loadModel('phase_4/models/neighborhoods/toontown_central_full')
        #self.background.reparentTo(render)
        #for frame in render.findAllMatches('*/doorFrame*'):
        #    frame.removeNode()
        #self.sky = loader.loadModel('phase_3.5/models/props/TT_sky')
        #SkyUtil.startCloudSky(self)

        #base.camera.setPosHpr(INIT_POS, INIT_HPR)
        self.background = OnscreenImage(image = DMenuResources.MenuBackground, parent = aspect2d)
        self.background.setBin('background', 1)
        self.background.reparentTo(aspect2d)
        self.background.setScale(2, 1, 1)
        
        self.logo = OnscreenImage(image = DMenuResources.GameLogo, scale = (1, 1, .5))
        self.logo.reparentTo(aspect2d)
        self.logo.setTransparency(TransparencyAttrib.MAlpha)
        scale = self.logo.getScale()
        self.logo.setPos(0, 0, .5)
        self.logo.setColorScale(Vec4(0, 0, 0, 0))

        #fadeInBackground = (LerpColorScaleInterval(self.background, 1, Vec4(1, 1, 1, 1), Vec4(1, 1, 1, 0))).start()
        fadeInLogo = (LerpColorScaleInterval(self.logo, 1, Vec4(1, 1, 1, 1), Vec4(1, 1, 1, 0))).start()

        self.createButtons()

        self.fadeOut = None
        self.optionsMgr = DMenuOptions.DMenuOptions()
        self.quitConfirmation = DMenuQuit.DMenuQuit()

        # TT: We need these to run the Pick A Toon screen
        #self.patAvList = avatarList
        #self.patFSM = parentFSM
        #self.patDoneEvent = doneEvent
        
        self.transcircle = Resources.transcircle
        self.transcircle.setTransparency(TransparencyAttrib.MAlpha)
        self.transcircle.setScale(VBase3(0.01, 0.01, 0.01))
        self.transcircle.setBin('background', 3)
        
        self.savemgr = LOTASaveMgr.LOTASaveMgr()
        
        # Get the save data
        self.savePos = self.savemgr.loadSaveData()
        
        self.titleMusic = Resources.titleMusic
        self.titleMusic.setLoop(1)
        self.setMusicNormal()

    def skyTrack(self, task):
    #    return SkyUtil.cloudSkyTrack(task)
        pass

    def createButtons(self):
        self.PlayButton = DirectButton(relief = None, text_style = 3, text_fg = (1, 1, 1, 1), text = DMenuLocalizer.PlayGame, text_scale = .1, scale = 0.95, command = self.playGame)
        self.PlayButton.reparentTo(aspect2d)
        self.PlayButton.setPos(PlayBtnHidePos)
        self.PlayButton.show()

        self.OptionsButton = DirectButton(relief = None, text_style = 3, text_fg = (1, 1, 1, 1), text = DMenuLocalizer.Options, text_scale = .1, scale = 0.95, command = self.openOptions)
        self.OptionsButton.reparentTo(aspect2d)
        self.OptionsButton.setPos(OptionsBtnHidePos)
        self.OptionsButton.show()

        self.QuitButton = DirectButton(relief = None, text_style = 3, text_fg = (1, 1, 1, 1), text = DMenuLocalizer.Quit, text_scale = .1, scale = 0.95, command = self.quitGame)
        self.QuitButton.reparentTo(aspect2d)
        self.QuitButton.setPos(QuitBtnHidePos)
        self.QuitButton.show()


        # self.BRButton = DirectButton(text = 'REPORT BUG', text_scale = .1, scale=0.95)
        # self.BRButton.reparentTo(aspect2d)
        # self.BRButton.setPos(-.9, 0, -.9)
        # self.BRButton.show()
        
        self.buttonInAnimation()
        
        # Slap on the saves menu from the old main menu until a proper implementation to DMENU is made
        self.SavesButton = DirectButton(relief = None, text = AmdLocalizerEnglish.LOTA_SAVES, image_scale = 2, text_scale = .1, scale = 0.95, command = self.openSavesMenu)
        self.SavesButton.reparentTo(aspect2d)
        self.SavesButton.setPos(0, 0, -.5)
        self.SavesButton.show()

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

        if self.background is not None:
            self.background.hide()
            self.background.reparentTo(hidden)
            self.background.removeNode()
            self.background = None

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

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

        if self.QuitButton is not None:
            self.QuitButton.destroy()
            self.QuitButton = None
            
        if self.SavesButton is not None:
            self.SavesButton.destroy()
            self.SavesButton = None
            
        if self.titleMusic is not None:
            self.titleMusic.stop()

        #taskMgr.remove('skyTrack')
        #self.sky.reparentTo(hidden)

    def openOptions(self):
        self.optionsMgr.showOptions()
        self.closeOptionsButton = DirectButton(relief = None, text = "< Back", text_fg = (0.977, 0.816, 0.133, 1), text_pos = (0, -0.035), scale = .1, command = self.hideOptions)
        self.closeOptionsButton.reparentTo(base.a2dTopLeft)
        self.closeOptionsButton.setPos(0.5, 0, -0.07)
        Parallel(
            self.PlayButton.posInterval(.5, Point3(PlayBtnHidePos), blendType = 'easeInOut'),
            self.OptionsButton.posInterval(.5, Point3(OptionsBtnHidePos), blendType = 'easeInOut'),
            self.QuitButton.posInterval(.5, Point3(QuitBtnHidePos), blendType = 'easeInOut'),
            self.logo.posInterval(0.5, Point3(0, 0, 2.5), blendType = 'easeInOut')).start()
        #base.camera.posHprInterval(0.5, Point3(HQ_POS), VBase3(HQ_HPR), blendType = 'easeInOut').start()
        #self.setMusicCalm()

    def hideOptions(self):
        self.optionsMgr.hideOptions()
        self.closeOptionsButton.hide()
        Parallel(
            self.PlayButton.posInterval(.5, Point3(PlayBtnPos), blendType = 'easeInOut'),
            self.OptionsButton.posInterval(.5, Point3(OptionsBtnPos), blendType = 'easeInOut'),
            self.QuitButton.posInterval(.5, Point3(QuitBtnPos), blendType = 'easeInOut'),
            self.logo.posInterval(.5, Point3(0, 0, .5), blendType = 'easeInOut')).start()
        base.camera.posHprInterval(0.5, Point3(MAIN_POS), VBase3(MAIN_HPR), blendType = 'easeInOut').start()
        #self.setMusicNormal()

    def playGame(self):
        if self.fadeOut is not None:
            self.fadeOut.finish()
            self.fadeOut = None
        self.fadeOut = base.transitions.getFadeOutIval(t = 1)
        #base.camera.posHprInterval(1, Point3(TOON_HALL_POS), VBase3(TOON_HALL_HPR), blendType = 'easeInOut').start()
        Sequence(
            Func(self.doPlayButton),
            #Func(self.fadeOut.start),
            Wait(1),
            Func(self.murder),
            Wait(1),
            Func(self.enterGame)).start()#,
            #Func(base.transitions.fadeIn, 1)).start()

    def enterOptions(self):
        pass

    def enterGame(self):
        #base.cr.avChoice = AvatarChooser.AvatarChooser(self.patAvList, self.patFSM, self.patDoneEvent)
        #base.cr.avChoice.load(1)
        #base.cr.avChoice.enter()
        from Game.NewGame.Scenes import SceneOne
        # Hamburger Menu Button
        #self.hbButton = DirectButton(image = "phase_3/maps/dmenu/dmhbmenu.png", relief = None, text = ' ', command=self.showHamburgerMenu)
        #self.hbButton.reparentTo(base.a2dTopLeft)
        #self.hbButton.setPos(0.05, 0, -0.05)
        #self.hbButton.setScale(0.04)

        # Hamburger Menu Hide Button
        #self.hbHideButton = DirectButton(image = "phase_3/maps/dmenu/close_window.png", relief = None, text = ' ', command=self.hideHamburgerMenu)
        #self.hbHideButton.reparentTo(base.a2dTopLeft)
        #self.hbHideButton.setPos(0.05, 0, -0.05)
        #self.hbHideButton.setScale(0.04)
        #self.hbHideButton.hide()

        # TODO: Add options and stuff to the hamburger menu

    def doPlayButton(self):
        Parallel(
            self.PlayButton.posInterval(1, Point3(PlayBtnHidePos), blendType = 'easeInOut'),
            self.OptionsButton.posInterval(1, Point3(OptionsBtnHidePos), blendType = 'easeInOut'),
            self.QuitButton.posInterval(1, Point3(QuitBtnHidePos), blendType = 'easeInOut'),
            self.logo.posInterval(0.5, Point3(0, 0, 2.5), blendType = 'easeInOut')).start()

    def quitGame(self):
        self.showQuitConfirmation()

    def showQuitConfirmation(self):
        self.quitConfirmation.showConfirmation()
        #base.exitFunc()

    def setMusicNormal(self):
        #LerpFunctionInterval(base.cr.music.setVolume, fromData = 0, toData = .9, duration = 1).start()
        #LerpFunctionInterval(base.cr.musicCalm.setVolume, fromData = .9, toData = 0, duration = 1).start()
        self.titleMusic.play()

    def setMusicCalm(self):
        LerpFunctionInterval(base.cr.music.setVolume, fromData = .9, toData = 0, duration = 1).start()
        LerpFunctionInterval(base.cr.musicCalm.setVolume, fromData = 0, toData = .9, duration = 1).start()

    def openSavesMenu(self):
        self.saveOne = DirectButton(relief=None, text = 'Save One: ' + '(Scene ' + str(self.savePos) + ')', scale=0.3, command=self.saveLoader, parent=aspect2d, pos=(0, 0, -.6), text_scale = .5)
        self.saveOne.hide()
        self.transcircle.show()
        self.exitLoadButton = DirectButton(relief=None, text = '< Back', scale=0.3, command=self.closeSavesMenu, parent=base.a2dBottomCenter, pos=(0, 0, -.4), text_scale = .5)
        self.exitLoadButton.show()

        
        self.openSavesMenuSequence = Parallel(
            self.transcircle.scaleInterval(0.5, VBase3(3, 3, 3), blendType = 'easeInOut'),
            self.exitLoadButton.posInterval(0.5, Point3(0, 0, .4), blendType = 'easeInOut'),
            Func(self.saveOne.show),
            self.saveOne.posInterval(0.5, Point3(0, 0, .2), blendType = 'easeInOut'))
        self.openSavesMenuSequence.start()
        
    def closeSavesMenu(self):
        self.hideThings = Sequence(
            Wait(0.5),
            Func(self.saveOne.hide),
            Func(self.transcircle.hide))
    
        self.closeSavesMenuSequence = Parallel(
            self.saveOne.posInterval(0.5, Point3(0, 0, -.6), blendType = 'easeInOut'),
            self.transcircle.scaleInterval(0.5, VBase3(0.01, 0.01, 0.01), blendType = 'easeInOut'),
            self.exitLoadButton.posInterval(0.5, Point3(0, 0, -.4), blendType = 'easeInOut'),
            Func(self.hideThings.start))
        self.closeSavesMenuSequence.start()
        self.exitLoadButton.removeNode()
        del self.exitLoadButton
        
    def saveLoader(self):
        # this was thrown together in like 10 seconds. how the f**k does this work
        # TODO: Make this save to a file thats not easily editable
        self.saveOne.hide()
        self.background.hide()
        self.transcircle.hide()
        if self.savePos == '1':
            from Game.NewGame.Scenes import SceneOne
        elif self.savePos == '2':
            from Game import SceneTwo
        elif self.savePos == '3':
            from Game import SceneThree
        elif self.savePos == '4':
            from Game import SceneFour
        elif self.savePos == '5':
            from Game import SceneFive
        else:
            print ("\n\n Save data is set to an unknown scene!!\n\n")
            
    def buttonInAnimation(self):
        logo = self.logo.posInterval(.5, Point3(0, 0, .5), blendType = 'easeInOut')
        play = self.PlayButton.posInterval(.5, Point3(PlayBtnPos), blendType = 'easeInOut')
        opt = self.OptionsButton.posInterval(.5, Point3(OptionsBtnPos), blendType = 'easeInOut')
        quit = self.QuitButton.posInterval(.5, Point3(QuitBtnPos), blendType = 'easeInOut')
        
        Sequence(
                 Func(logo.start),
                 Wait(0.1),
                 Func(play.start),
                 Wait(0.2),
                 Func(opt.start),
                 Wait(0.2),
                 Func(quit.start)).start()
                 
    def showHamburgerMenu(self):
        self.hbButton.hide()
        self.hbHideButton.show()
        
    def hideHamburgerMenu(self):
        self.hbButton.show()
        self.hbHideButton.hide()
Exemplo n.º 10
0
class MainMenu():
    def __init__(self):
        self.frameMain = DirectFrame(image="mainmenu.png",
                                     image_scale=(1.7778, 1, 1),
                                     frameSize=(base.a2dLeft, base.a2dRight,
                                                base.a2dBottom, base.a2dTop),
                                     frameColor=(0, 0, 0, 0))
        self.frameMain.setTransparency(True)

        self.btnStart = DirectButton(
            text="Enter",
            scale=0.15,
            text_pos=(0, 1.1),
            text_scale=0.5,
            text_fg=(240 / 255.0, 255 / 255.0, 240 / 255.0, 1),
            frameColor=(0, 0, 0, 0),
            image=("btnEnter.png", "btnEnter_hover.png", "btnEnter_hover.png",
                   "btnEnter_hover.png"),
            pos=(0, 0, -0.3),
            command=base.messenger.send,
            extraArgs=["menu_StartGame"])
        self.btnStart.setTransparency(True)
        self.btnStart.reparentTo(self.frameMain)

        self.btnOptions = DirectButton(text="Options",
                                       scale=0.1,
                                       text_fg=(240 / 255.0, 255 / 255.0,
                                                240 / 255.0, 1),
                                       frameColor=(0, 0, 0, 0),
                                       image=("settings.png"),
                                       image_scale=1.2,
                                       text_pos=(0, -0.2),
                                       pos=(base.a2dRight - 0.3, 0,
                                            base.a2dBottom + 0.25),
                                       command=base.messenger.send,
                                       extraArgs=["menu_Options"])
        self.btnOptions.setTransparency(True)
        self.btnOptions.reparentTo(self.frameMain)

        self.btnQuit = DirectButton(
            text="Exit",
            scale=0.15,
            text_pos=(-0.3, -0.25),
            text_scale=0.75,
            text_fg=(240 / 255.0, 255 / 255.0, 240 / 255.0, 1),
            frameColor=(0, 0, 0, 0),
            image=("btnExit.png", "btnExit_hover.png", "btnExit_hover.png",
                   "btnExit_hover.png"),
            image_scale=(1, 1, 0.5),
            pos=(base.a2dLeft + 0.3, 0, base.a2dBottom + 0.25),
            command=base.messenger.send,
            extraArgs=["menu_QuitGame"])
        self.btnQuit.setTransparency(True)
        self.btnQuit.reparentTo(self.frameMain)

        self.imgBouncer = OnscreenImage(image="bouncer.png",
                                        scale=(0.75 * 0.25, 1 * 0.25,
                                               1 * 0.25),
                                        pos=(-0.25, 0, -0.3))
        self.imgBouncer.setTransparency(True)
        self.imgBouncer.reparentTo(self.frameMain)

        self.imgBadDude1 = OnscreenImage(image="badDude1.png",
                                         scale=(0.25, 0.25, 0.25),
                                         pos=(-0.75, 0, -0.4))
        self.imgBadDude1.setTransparency(True)
        self.imgBadDude1.reparentTo(self.frameMain)

        img = self.imgBadDude1
        up = img.posInterval(3.0,
                             Point3(img.getX(), img.getY(),
                                    img.getZ() + 0.01),
                             bakeInStart=0)
        left = img.posInterval(3.0,
                               Point3(img.getX() - 0.01, img.getY(),
                                      img.getZ()),
                               bakeInStart=0)
        right = img.posInterval(3.0,
                                Point3(img.getX() + 0.01, img.getY(),
                                       img.getZ()),
                                bakeInStart=0)
        down = img.posInterval(3.0,
                               Point3(img.getX(), img.getY(),
                                      img.getZ() - 0.01),
                               bakeInStart=0)
        rotForward = img.hprInterval(3.0, Point3(0, 0, 2.5), bakeInStart=0)
        rotBackward = img.hprInterval(3.0, Point3(0, 0, -2.5), bakeInStart=0)
        rotCenter = img.hprInterval(3.0, Point3(0, 0, 0), bakeInStart=0)
        self.ivalBadDude1 = Sequence(Parallel(rotCenter, up),
                                     Parallel(rotBackward, left), down,
                                     Parallel(rotCenter, up),
                                     Parallel(rotForward, right), down)

        self.imgGoodGal1 = OnscreenImage(image="goodGal1.png",
                                         scale=(0.6 * 0.25, 0.25, 0.25),
                                         pos=(-0.95, 0, -0.43))
        self.imgGoodGal1.setTransparency(True)
        self.imgGoodGal1.reparentTo(self.frameMain)

        img = self.imgGoodGal1
        up = img.posInterval(3.0,
                             Point3(img.getX(), img.getY(),
                                    img.getZ() + 0.01),
                             bakeInStart=0)
        left = img.posInterval(3.0,
                               Point3(img.getX() - 0.01, img.getY(),
                                      img.getZ()),
                               bakeInStart=0)
        right = img.posInterval(3.0,
                                Point3(img.getX() + 0.01, img.getY(),
                                       img.getZ()),
                                bakeInStart=0)
        down = img.posInterval(3.0,
                               Point3(img.getX(), img.getY(),
                                      img.getZ() - 0.01),
                               bakeInStart=0)
        rotForward = img.hprInterval(3.0, Point3(0, 0, 2.5), bakeInStart=0)
        rotBackward = img.hprInterval(3.0, Point3(0, 0, -2.5), bakeInStart=0)
        rotCenter = img.hprInterval(3.0, Point3(0, 0, 0), bakeInStart=0)
        self.ivalGoodGal1 = Sequence(left, right, left, down, up)

        self.imgGoodDude1 = OnscreenImage(image="goodDude1.png",
                                          scale=(0.25, 0.25, 0.25),
                                          pos=(0.95, 0, 0))
        self.imgGoodDude1.setTransparency(True)
        self.imgGoodDude1.reparentTo(self.frameMain)

        img = self.imgGoodDude1
        up = img.posInterval(3.0,
                             Point3(img.getX(), img.getY(),
                                    img.getZ() + 0.02),
                             bakeInStart=0)
        left = img.posInterval(3.0,
                               Point3(img.getX() - 0.02, img.getY(),
                                      img.getZ()),
                               bakeInStart=0)
        right = img.posInterval(3.0,
                                Point3(img.getX() + 0.02, img.getY(),
                                       img.getZ()),
                                bakeInStart=0)
        down = img.posInterval(3.0,
                               Point3(img.getX(), img.getY(),
                                      img.getZ() - 0.02),
                               bakeInStart=0)
        rotForward = img.hprInterval(3.0, Point3(0, 0, 4), bakeInStart=0)
        rotBackward = img.hprInterval(3.0, Point3(0, 0, -4), bakeInStart=0)
        rotCenter = img.hprInterval(3.0, Point3(0, 0, 0), bakeInStart=0)
        self.ivalGoodDude1 = Sequence(Parallel(up, rotCenter),
                                      Parallel(right, rotForward),
                                      Parallel(down, rotCenter),
                                      Parallel(left, rotBackward))

        self.hide()

    def show(self):
        self.frameMain.show()
        self.ivalBadDude1.loop()
        self.ivalGoodGal1.loop()
        self.ivalGoodDude1.loop()

    def hide(self):
        self.frameMain.hide()
        self.ivalBadDude1.finish()
        self.ivalGoodGal1.finish()
        self.ivalGoodDude1.finish()