Esempio n. 1
0
 def mostrar_camaras(self):
     #
     if self.reflection_buffer:
         lbl_refl=DirectLabel(text="reflejo", pos=LVector3f(-1.05, -0.4), scale=0.05)
         lbl_refl.reparentTo(self.base.aspect2d)
         frame_refl=DirectFrame(image=self.reflection_buffer.getTexture(0), scale=0.25, pos=LVector3f(-1.05, -0.7))
         frame_refl.reparentTo(self.base.aspect2d)
     #
     if self.refraction_buffer:
         lbl_refr=DirectLabel(text="refraccion", pos=LVector3f(-0.5, -0.4), scale=0.05)
         lbl_refr.reparentTo(self.base.aspect2d)
         frame_refr=DirectFrame(image=self.refraction_buffer.getTexture(0), scale=0.25, pos=LVector3f(-0.5, -0.7))
         frame_refr.reparentTo(self.base.aspect2d)
Esempio n. 2
0
    def __init__(self, image, carPos, trackDir):
        ShowBase.__init__(self)
        self.image = image
        # add show image function
        #OnscreenImage(image=image, pos=(0, 0, 0))
        bg = DirectFrame(image=image, sortOrder=(-1))
        bg.setPos(0, 20, 0)
        bg.reparentTo(render2d)

        nrDisplayRegions = self.camera.getNumDisplayRegions()
        print(nrDisplayRegions)
        self.carPos = carPos
        self.carModel = None
        self.loadModels(carPos)
        self.trackDir = trackDir
class PiratesDownloadWatcher(DownloadWatcher.DownloadWatcher):
    positions = [
        (Point3(1, 0, 0.90000000000000002), Point3(1, 0, 0.90000000000000002)),
        (Point3(1, 0, 0.90000000000000002), Point3(1, 0, 0.90000000000000002)),
        (Point3(1, 0, 0.90000000000000002), Point3(1, 0, 0.90000000000000002))]
    
    def __init__(self, phaseNames):
        self.phaseNames = phaseNames
        self.model = loader.loadModel('models/gui/pir_m_gui_gen_loadingBar')
        bar = self.model.findTexture('pir_t_gui_gen_loadingBar')
        self.model.find('**/loading_bar').hide()
        self.topFrame = DirectFrame(parent = base.a2dTopRight, pos = (-0.80000000000000004, 0, -0.10000000000000001), sortOrder = NO_FADE_SORT_INDEX + 1)
        self.text = DirectLabel(relief = None, parent = self.topFrame, guiId = 'DownloadWatcherText', pos = (0, 0, 0), text = '                     ', text_fg = (1, 1, 1, 1), text_shadow = (0, 0, 0, 1), text_scale = 0.040000000000000001, textMayChange = 1, text_align = TextNode.ARight, text_pos = (0.17000000000000001, 0), sortOrder = 2)
        self.bar = DirectWaitBar(relief = None, parent = self.topFrame, guiId = 'DownloadWatcherBar', pos = (0, 0, 0), frameSize = (-0.40000000000000002, 0.38, -0.044999999999999998, 0.065000000000000002), borderWidth = (0.02, 0.02), range = 100, frameColor = (1, 1, 1, 1), barColor = (0, 0.29999999999999999, 0, 1), barTexture = bar, geom = self.model, geom_scale = 0.089999999999999997, geom_pos = (-0.014, 0, 0.01), text = '0%', text_scale = 0.040000000000000001, text_fg = (1, 1, 1, 1), text_align = TextNode.ALeft, text_pos = (0.19, 0), sortOrder = 1)
        self.bgFrame = DirectFrame(relief = DGG.FLAT, parent = self.topFrame, pos = (0, 0, 0), frameColor = (0.5, 0.27000000000000002, 0.35999999999999999, 0.20000000000000001), frameSize = (-0.44, 0.39000000000000001, -0.035999999999999997, 0.056000000000000001), borderWidth = (0.02, 0.02), scale = 0.90000000000000002, sortOrder = 0)
        self.accept('launcherPercentPhaseComplete', self.update)

    
    def update(self, phase, percent, reqByteRate, actualByteRate):
        phaseName = self.phaseNames[phase]
        self.text['text'] = OTPLocalizer.DownloadWatcherUpdate % phaseName + '  -'
        self.bar['text'] = '%s %%' % percent
        self.bar['value'] = percent

    
    def foreground(self):
        self.topFrame.reparentTo(base.a2dpTopRight)
        self.topFrame.setBin('gui-fixed', 55)
        self.topFrame['sortOrder'] = NO_FADE_SORT_INDEX + 1

    
    def background(self):
        self.topFrame.reparentTo(base.a2dTopRight)
        self.topFrame.setBin('unsorted', 49)
        self.topFrame['sortOrder'] = -1

    
    def cleanup(self):
        self.text.destroy()
        self.bar.destroy()
        self.bgFrame.destroy()
        self.topFrame.destroy()
        self.ignoreAll()
class PiratesDownloadWatcher(DownloadWatcher.DownloadWatcher):
    positions = [
        (Point3(1, 0, 0.90000000000000002), Point3(1, 0, 0.90000000000000002)),
        (Point3(1, 0, 0.90000000000000002), Point3(1, 0, 0.90000000000000002)),
        (Point3(1, 0, 0.90000000000000002), Point3(1, 0, 0.90000000000000002))]
    
    def __init__(self, phaseNames):
        self.phaseNames = phaseNames
        self.model = loader.loadModel('models/gui/pir_m_gui_gen_loadingBar')
        bar = self.model.findTexture('pir_t_gui_gen_loadingBar')
        self.model.find('**/loading_bar').hide()
        self.topFrame = DirectFrame(parent = base.a2dTopRight, pos = (-0.80000000000000004, 0, -0.10000000000000001), sortOrder = NO_FADE_SORT_INDEX + 1)
        self.text = DirectLabel(relief = None, parent = self.topFrame, guiId = 'DownloadWatcherText', pos = (0, 0, 0), text = '                     ', text_fg = (1, 1, 1, 1), text_shadow = (0, 0, 0, 1), text_scale = 0.040000000000000001, textMayChange = 1, text_align = TextNode.ARight, text_pos = (0.17000000000000001, 0), sortOrder = 2)
        self.bar = DirectWaitBar(relief = None, parent = self.topFrame, guiId = 'DownloadWatcherBar', pos = (0, 0, 0), frameSize = (-0.40000000000000002, 0.38, -0.044999999999999998, 0.065000000000000002), borderWidth = (0.02, 0.02), range = 100, frameColor = (1, 1, 1, 1), barColor = (0, 0.29999999999999999, 0, 1), barTexture = bar, geom = self.model, geom_scale = 0.089999999999999997, geom_pos = (-0.014, 0, 0.01), text = '0%', text_scale = 0.040000000000000001, text_fg = (1, 1, 1, 1), text_align = TextNode.ALeft, text_pos = (0.19, 0), sortOrder = 1)
        self.bgFrame = DirectFrame(relief = DGG.FLAT, parent = self.topFrame, pos = (0, 0, 0), frameColor = (0.5, 0.27000000000000002, 0.35999999999999999, 0.20000000000000001), frameSize = (-0.44, 0.39000000000000001, -0.035999999999999997, 0.056000000000000001), borderWidth = (0.02, 0.02), scale = 0.90000000000000002, sortOrder = 0)
        self.accept('launcherPercentPhaseComplete', self.update)

    
    def update(self, phase, percent, reqByteRate, actualByteRate):
        phaseName = self.phaseNames[phase]
        self.text['text'] = OTPLocalizer.DownloadWatcherUpdate % phaseName + '  -'
        self.bar['text'] = '%s %%' % percent
        self.bar['value'] = percent

    
    def foreground(self):
        self.topFrame.reparentTo(base.a2dpTopRight)
        self.topFrame.setBin('gui-fixed', 55)
        self.topFrame['sortOrder'] = NO_FADE_SORT_INDEX + 1

    
    def background(self):
        self.topFrame.reparentTo(base.a2dTopRight)
        self.topFrame.setBin('unsorted', 49)
        self.topFrame['sortOrder'] = -1

    
    def cleanup(self):
        self.text.destroy()
        self.bar.destroy()
        self.bgFrame.destroy()
        self.topFrame.destroy()
        self.ignoreAll()
Esempio n. 5
0
def load(args):
    """Sets up the GUI for the main menu.
    Arguments:
        This takes no arguments.
    """

    global backFrame
    global menuFrame
    global pauseText
    global backButton

    font_digital = loader.loadFont('digital.egg')

    backFrame = DirectFrame()
    backFrame['frameColor'] = (0, 0, 0, .5)
    backFrame['frameSize'] = (2, -2, 2, -2)
    backFrame.setPos(0, 0, 0)

    menuFrame = DirectFrame()
    menuFrame.reparentTo(backFrame)
    menuFrame['frameColor'] = (1, 1, 1, .5)
    menuFrame['frameSize'] = (.5, -.5, .5, -.5)
    menuFrame.setPos(0, 0, 0)

    pauseText = OnscreenText()
    pauseText['text'] = ('PAUSED')
    pauseText['scale'] = (.1)
    pauseText['font'] = (font_digital)
    pauseText['fg'] = (1, 1, 1, 1)
    pauseText.setPos(0, .9)

    backButton = DirectButton()
    backButton.reparentTo(menuFrame)
    backButton['text'] = ('Back')
    backButton['text_scale'] = (.1)
    backButton['text_pos'] = (0, -0.03)
    backButton['frameVisibleScale'] = (2, 0.5, 0)
    backButton['frameColor'] = (1, 1, 1, 0)
    backButton['command'] = (messenger.send)
    backButton['extraArgs'] = ("switch_gui", [gui.menu.pause_options, gui.menu.pause])
    backButton.setPos(0, 0, 0)
class RadialMenu(DirectObject):
    def __init__(self, items):
        ''' 
            Initialize using the set of items specified
            Set of items should be passed as RadialItems
        '''
        DirectObject.__init__(self)
        # Initialize variables
        self.isActive = 0
        self.selected = 0

        self.items = items

        # Load the palletized gui model
        gui = loader.loadModel("resources/camera_gui.bam")

        # Create the frame
        self.frame = DirectFrame(geom=gui.find("**/radial_menu_bg"),
                                 parent=hidden,
                                 scale=1.3,
                                 relief=None)

        # Create the selection indicator
        self.selector = OnscreenImage(
            image=gui.find("**/radial_menu_bg_quarter"), parent=self.frame)

        # Create the selected item description box
        self.descriptionBox = OnscreenText(parent=self.frame,
                                           pos=(0, -.6),
                                           style=3,
                                           font=ToontownGlobals.getSignFont(),
                                           scale=0.05,
                                           bg=(0, 0, 0, .4))

        # Load all the and calculate their positions
        self.itemAngle = 360 / len(items)
        self.itemImages = []
        for i in range(len(items)):
            x = .38 * math.cos(i * deg2Rad(self.itemAngle))
            z = .38 * math.sin(i * deg2Rad(self.itemAngle))
            img = OnscreenImage(image=self.items[i].nodepath,
                                scale=0.2,
                                parent=self.frame,
                                pos=(x, 0, z))
            self.itemImages.append(img)

    def activate(self):
        ''' Shows the menu and spawns the mouse reader task '''
        self.frame.reparentTo(aspect2d)
        taskMgr.add(self.radialTask, 'cam-radialTask')
        self.isActive = 1

    def deactivate(self):
        ''' Hides the menu and kills the mouse reader task '''
        taskMgr.remove('cam-radialTask')
        self.frame.reparentTo(hidden)
        self.isActive = 0

    def destroy(self):
        ''' Destroy everything '''
        self.frame.destroy()
        self.selector.destroy()
        for item in self.itemImages:
            item.destroy()
            del item

        for item in self.items:
            del item
        del self.frame
        del self.selector

    def getChoice(self):
        ''' Convenience Function Get the selected item '''
        return self.selected

    def radialTask(self, task):
        ''' Reads the mouse position and calculates which object it is looking at '''
        # Initialize these as 0 incase we can't read the mouses position
        mouseX = 0
        mouseY = 0
        # Read the mouse position
        if base.mouseWatcherNode.hasMouse():
            mouseX = base.mouseWatcherNode.getMouseX()
            mouseY = base.mouseWatcherNode.getMouseY()
        # Calculate the angle that the mouse is at from the cursor
        menuAngle = rad2Deg(math.atan2(mouseY, mouseX)) + 45

        # Get the index of the item at the mouse angle
        self.selected = int(math.floor((menuAngle % 360) / self.itemAngle))

        # Set the rotation of the selector
        # The selector image is from 12 o'clock to 3 o'clock, so we need to
        # rotate it counter clockwise 45 degrees
        self.selector.setR(-self.itemAngle * self.selected + 45)

        # Highlight the selected item
        for i in self.itemImages:
            i.setColorScale(1.0, 1.0, 1.0, 1.0)
            i.setScale(0.2)
        self.itemImages[self.selected].setScale(0.25)
        self.itemImages[self.selected].setColorScale(0.3, 1.0, 1.0, 1.0)

        self.descriptionBox['text'] = self.items[self.selected].description

        return Task.cont
Esempio n. 7
0
class Menu(object):
    def __init__(self, main):
        self.main = main

        wx = base.win.get_x_size()
        wy = base.win.get_y_size()
        kx = 1920
        ky = 1080
        self.myFrame = DirectFrame(frameColor=(1, 1, 1, 1),
                                   frameSize=(0, kx, 0, ky))

        menu_tex = loader.loadTexture("res/menu.png")
        menu_tex.set_minfilter(SamplerState.FT_nearest)
        menu_tex.set_magfilter(SamplerState.FT_linear)
        self.myFrame["frameTexture"] = menu_tex
        self.myFrame.reparentTo(base.pixel2d)
        self.myFrame.set_pos((wx - kx) / 2, 0, -(wy + ky) / 2)
        self.myFrame.set_transparency(True)

        self.startButton = DirectButton(text="",
                                        text_scale=1.0,
                                        text_fg=(0.2, 0.2, 0.2, 1),
                                        frameTexture="res/start_game.png",
                                        frameColor=(1, 1, 1, 1),
                                        frameSize=(-64, 64, -20, 20),
                                        command=self.main.startGame,
                                        relief=DGG.FLAT,
                                        rolloverSound=None,
                                        clickSound=None,
                                        parent=self.myFrame,
                                        scale=2.0,
                                        pos=(wx / 2 + 160, 0, wy / 2 + 50))
        self.startButton.setTransparency(1)

        self.exitButton = DirectButton(
            text=("Exit Game"),
            pos=(0, 0, -.8),
            text_scale=.1,
            frameColor=(0, 0, 0, 0),
            relief=1,
            frameVisibleScale=(2, 3),
            command=exit,
            rolloverSound=None,
            clickSound=None,
            parent=self.myFrame,
        )
        self.exitButton.setTransparency(1)

        self.resumeButton = DirectButton(
            text=("Resume"),
            pos=(.0, 0, .3),
            text_scale=.1,
            frameColor=(0, 0, 0, 0),
            relief=1,
            frameVisibleScale=(2, 3),
            command=self.main.resumeGame,
            rolloverSound=None,
            clickSound=None,
            parent=self.myFrame,
        )

        self.resumeButton.setTransparency(1)
        self.resumeButton.hide()

        self.selectFrame = DirectFrame(frameColor=(1, 1, 1, 1),
                                       frameSize=(-64, 64, -20, 20),
                                       frameTexture="res/select.png")
        self.selectFrame.setTransparency(1)
        self.selectFrame.reparentTo(self.startButton)
        self.entries = [self.exitButton, self.startButton, self.resumeButton]
        self.activeEntry = 1

    def clearKeys(self):
        base.ignore("arrow_up")
        base.ignore("arrow_down")
        base.ignore("arrow_left")
        base.ignore("arrow_right")
        base.ignore("escape")
        base.ignore("enter")

    def execSelection(self):
        self.entries[self.activeEntry]["command"]()

    def selectDown(self):
        if self.activeEntry == 0:
            self.activeEntry = len(self.entries) - 1
        else:
            self.activeEntry -= 1

        if self.entries[self.activeEntry].isHidden():
            self.selectDown()
            return
        self.selectFrame.reparentTo(self.entries[self.activeEntry])

    def selectUp(self):

        if self.activeEntry == len(self.entries) - 1:
            self.activeEntry = 0
        else:
            self.activeEntry += 1
        if self.entries[self.activeEntry].isHidden():
            self.selectUp()
            return
        self.selectFrame.reparentTo(self.entries[self.activeEntry])

    def hideMenu(self):
        self.clearKeys()
        self.main.gui.show()
        seq = Sequence(LerpColorScaleInterval(self.myFrame, 0.4, (1, 1, 1, 0)),
                       Func(self.myFrame.hide))
        seq.start()

    def hideResume(self):
        seq = Sequence(
            LerpColorScaleInterval(self.resumeButton, .5, (1, 1, 1, 0)),
            Func(self.resumeButton.hide))
        seq.start()

    def showResume(self):
        self.resumeButton.show()
        #seq= Sequence(  LerpColorScaleInterval(self.resumeButton, 1 ,(1,1,1,1)) )
        #seq.start()

    def showMenu(self):
        self.clearKeys()
        base.accept("arrow_up", self.selectUp)
        base.accept("arrow_down", self.selectDown)
        base.accept("escape", exit)
        base.accept("enter", self.execSelection)
        self.myFrame.show()
        self.main.gui.hide()
        seq = Sequence(LerpColorScaleInterval(self.myFrame, .5, (1, 1, 1, 1)))
        seq.start()
Esempio n. 8
0
def load(args):
    """Sets up the GUI for the in game pause menu.
    Arguments:
        args[0] -- The function for the 'resume' button.
        args[1] -- The function for the 'settings' button.
        args[2] -- The function for the 'exit' button.
    """
    # GUI should do what they are told, they should get data sent to them, not request it.

    global pauseText
    global backFrame
    global menuFrame
    global resumeButton

    font_digital = loader.loadFont("digital.egg")

    backFrame = DirectFrame()
    backFrame["frameSize"] = (2, -2, 2, -2)
    backFrame.setPos(0, 0, 0)

    backFrame["frameColor"] = (0, 0, 0, 0.5)
    menuFrame = DirectFrame()
    menuFrame.reparentTo(backFrame)
    menuFrame["frameColor"] = (1, 1, 1, 0.5)
    menuFrame["frameSize"] = (0.5, -0.5, 0.5, -0.5)
    menuFrame.setPos(0, 0, 0)

    buttonClickSound = loader.loadSfx("sound/buttonClick.wav")
    buttonRollSound = loader.loadSfx("sound/buttonRoll.wav")

    resumeButton = DirectButton()
    resumeButton.reparentTo(menuFrame)
    resumeButton["text"] = "Resume"
    resumeButton["text_scale"] = 0.1
    resumeButton["text_pos"] = (0, -0.03)
    resumeButton["frameVisibleScale"] = (2, 0.5, 0)
    resumeButton["frameColor"] = (1, 1, 1, 0)
    resumeButton["command"] = resume
    resumeButton["rolloverSound"] = buttonRollSound
    resumeButton["clickSound"] = buttonClickSound
    resumeButton.setPos(0, 0, 0.4)

    settingsButton = DirectButton()
    settingsButton.reparentTo(menuFrame)
    settingsButton["text"] = "Settings"
    settingsButton["text_scale"] = 0.1
    settingsButton["text_pos"] = (0, -0.03)
    settingsButton["frameVisibleScale"] = (2, 0.5, 0)
    settingsButton["frameColor"] = (1, 1, 1, 0)
    settingsButton["rolloverSound"] = buttonRollSound
    settingsButton["clickSound"] = buttonClickSound
    settingsButton["command"] = messenger.send  # Command to run
    settingsButton["extraArgs"] = ("switch_gui", [gui.menu.pause, gui.menu.pause_options])  # Args to send
    settingsButton.setPos(0, 0, 0.2)

    exitButton = DirectButton()
    exitButton.reparentTo(menuFrame)
    exitButton["text"] = "Exit"
    exitButton["text_scale"] = 0.1
    exitButton["text_pos"] = (0, -0.03)
    exitButton["frameVisibleScale"] = (2, 0.5, 0)
    exitButton["frameColor"] = (1, 1, 1, 0)
    exitButton["rolloverSound"] = buttonRollSound
    exitButton["clickSound"] = buttonClickSound
    exitButton["command"] = exit
    exitButton.setPos(0, 0, 0)

    pauseText = OnscreenText()
    pauseText["text"] = "PAUSED"
    pauseText["scale"] = 0.1
    pauseText["font"] = font_digital
    pauseText["fg"] = (1, 1, 1, 1)
    pauseText.setPos(0, 0.9)
Esempio n. 9
0
class Menu(object):
    def __init__(self, main):
        self.main = main
        wx = base.win.get_x_size()
        wy = base.win.get_y_size()
        kx = 1600
        ky = 900
        self.myFrame = DirectFrame(frameColor=(1, 1, 1, 1),
                                   frameSize=(0, kx, 0, ky))

        menu_tex = loader.loadTexture("res/menu.png")
        menu_tex.set_minfilter(SamplerState.FT_nearest)
        menu_tex.set_magfilter(SamplerState.FT_linear)
        self.myFrame["frameTexture"] = menu_tex
        self.myFrame.reparentTo(base.pixel2d)
        self.myFrame.set_pos((wx - kx) / 2, 0, -(wy + ky) / 2)
        self.myFrame.set_transparency(True)

        self.startButton = DirectButton(text="",
                                        text_scale=1.0,
                                        text_fg=(0.2, 0.2, 0.2, 1),
                                        frameTexture="res/start.png",
                                        frameColor=(1, 1, 1, 1),
                                        frameSize=(-64, 64, -20, 20),
                                        command=self.main.startGame,
                                        relief=DGG.FLAT,
                                        rolloverSound=None,
                                        clickSound=None,
                                        parent=self.myFrame,
                                        scale=2.0,
                                        pos=(wx / 2, 0, wy / 2 + 50))
        self.startButton.setTransparency(1)

        self.exitButton = DirectButton(text="",
                                       text_scale=1.0,
                                       text_fg=(0.2, 0.2, 0.2, 1),
                                       frameTexture="res/exit.png",
                                       frameColor=(1, 1, 1, 1),
                                       frameSize=(-64, 64, -20, 20),
                                       relief=DGG.FLAT,
                                       command=exit,
                                       rolloverSound=None,
                                       clickSound=None,
                                       parent=self.myFrame,
                                       scale=2.0,
                                       pos=(wx / 2, 0, wy / 2 - 50))
        self.exitButton.setTransparency(1)

        self.resumeButton = DirectButton(text="",
                                         text_scale=1.0,
                                         text_fg=(0.2, 0.2, 0.2, 1),
                                         frameTexture="res/resume.png",
                                         frameColor=(1, 1, 1, 1),
                                         frameSize=(-64, 64, -20, 20),
                                         relief=DGG.FLAT,
                                         command=self.main.resumeGame,
                                         rolloverSound=None,
                                         clickSound=None,
                                         parent=self.myFrame,
                                         scale=2.0,
                                         pos=(wx / 2, 0, wy / 2 + 150))

        self.resumeButton.setTransparency(1)
        self.resumeButton.hide()

    def hideMenu(self):
        self.main.gui.show()
        seq = Sequence(LerpColorScaleInterval(self.myFrame, 0.4, (1, 1, 1, 0)),
                       Func(self.myFrame.hide))
        seq.start()

    def hideResume(self):
        seq = Sequence(
            LerpColorScaleInterval(self.resumeButton, .5, (1, 1, 1, 0)),
            Func(self.resumeButton.hide))
        seq.start()

    def showResume(self):
        self.resumeButton.show()
        seq = Sequence(
            LerpColorScaleInterval(self.resumeButton, .5, (1, 1, 1, 1)))
        seq.start()

    def showMenu(self):
        self.myFrame.show()
        self.main.gui.hide()
        seq = Sequence(LerpColorScaleInterval(self.myFrame, .5, (1, 1, 1, 1)))
        seq.start()
Esempio n. 10
0
class Menu(object):
    def __init__(self,main): 
        self.main=main

        wx = base.win.get_x_size()
        wy = base.win.get_y_size()
        kx = 1920
        ky = 1080
        self.myFrame = DirectFrame(frameColor=(1,1,1,1),
            frameSize=(0, kx,0, ky))

        menu_tex = loader.loadTexture("res/menu.png")
        menu_tex.set_minfilter(SamplerState.FT_nearest)
        menu_tex.set_magfilter(SamplerState.FT_linear)
        self.myFrame["frameTexture"] = menu_tex
        self.myFrame.reparentTo(base.pixel2d)
        self.myFrame.set_pos( (wx-kx) / 2, 0, -(wy+ky) / 2)
        self.myFrame.set_transparency(True)

        self.startButton = DirectButton(
                    text = "",  
                    text_scale=1.0,
                    text_fg=(0.2,0.2,0.2,1),
                    frameTexture="res/start_game.png",
                    frameColor=(1,1,1,1),
                    frameSize=(-64, 64, -20, 20),
                    command=self.main.startGame,
                    relief=DGG.FLAT,
                    rolloverSound=None,
                    clickSound=None,
                    parent=self.myFrame,
                    scale=2.0,
                    pos=(wx/2 + 160, 0, wy/2 + 50)
                    )
        self.startButton.setTransparency(1)

        self.exitButton = DirectButton(
                    text = ("Exit Game"),  
                    pos=(0,0,-.8),
                    text_scale=.1,
                    frameColor=(0,0,0,0),
                    relief=1,
                    frameVisibleScale=(2,3),
                    command=exit,
                    rolloverSound=None,
                    clickSound=None,
                    parent=self.myFrame,
                    )
        self.exitButton.setTransparency(1)
        
        self.resumeButton = DirectButton(
                    text = ("Resume"),  
                    pos=(.0,0,.3),
                    text_scale=.1,
                    frameColor=(0,0,0,0),
                    relief=1,
                    frameVisibleScale=(2,3),
                    command=self.main.resumeGame,
                    rolloverSound=None,
                    clickSound=None,
                    parent=self.myFrame,
                    )
        
        self.resumeButton.setTransparency(1)
        self.resumeButton.hide()
        
        self.selectFrame= DirectFrame( frameColor=(1,1,1,1) , frameSize=(-64, 64, -20, 20) , frameTexture="res/select.png")
        self.selectFrame.setTransparency(1)
        self.selectFrame.reparentTo(self.startButton)
        self.entries = [self.exitButton,self.startButton,self.resumeButton]
        self.activeEntry = 1


    
    
    def clearKeys(self):
        base.ignore("arrow_up")
        base.ignore("arrow_down")
        base.ignore("arrow_left")
        base.ignore("arrow_right")
        base.ignore("escape")
        base.ignore("enter")
    
    def execSelection(self):
        self.entries[self.activeEntry]["command"]()
      
        
    def selectDown(self):
        if self.activeEntry == 0:
            self.activeEntry = len(self.entries)-1
        else:
            self.activeEntry -=1
        
        if self.entries[self.activeEntry].isHidden():
            self.selectDown()
            return   
        self.selectFrame.reparentTo(self.entries[self.activeEntry])
        
    def selectUp(self):

        if self.activeEntry == len(self.entries)-1:
            self.activeEntry=0
        else:
            self.activeEntry +=1
        if self.entries[self.activeEntry].isHidden() :
            self.selectUp()
            return
        self.selectFrame.reparentTo(self.entries[self.activeEntry])

    def hideMenu(self):
        self.clearKeys()
        self.main.gui.show()
        seq= Sequence( LerpColorScaleInterval(self.myFrame, 0.4 ,(1,1,1,0)) , Func(self.myFrame.hide) )
        seq.start()
    
    def hideResume(self):
        seq= Sequence( LerpColorScaleInterval(self.resumeButton, .5 ,(1,1,1,0)) , Func(self.resumeButton.hide))
        seq.start()
     
    def showResume(self):
        self.resumeButton.show()
        #seq= Sequence(  LerpColorScaleInterval(self.resumeButton, 1 ,(1,1,1,1)) )
        #seq.start()
        
    def showMenu(self): 
        self.clearKeys()
        base.accept("arrow_up" , self.selectUp )
        base.accept("arrow_down" , self.selectDown )
        base.accept("escape", exit)
        base.accept("enter",self.execSelection)  
        self.myFrame.show()
        self.main.gui.hide()
        seq= Sequence( LerpColorScaleInterval(self.myFrame, .5 ,(1,1,1,1)) )
        seq.start()