コード例 #1
0
 def _initModel(self):
     baseName = '**/tt_t_gui_cmg_miniMap_'
     cardModel = CogdoUtil.loadMazeModel('miniMap_cards', group='gui')
     cm = CardMaker('bg')
     cm.setFrame(-1.1, 1.1, -1.1, 1.1)
     bg = self.attachNewNode(cm.generate())
     bg.setColor(*self._bgColor)
     bg.setBin('fixed', 0)
     frame = cardModel.find(baseName + 'frame')
     frame.reparentTo(self)
     frame.setScale(2.5)
     frame.setPos(0.01, 0, -0.01)
     self._entrance = cardModel.find(baseName + 'entrance')
     self._entrance.reparentTo(self)
     self._entrance.setScale(0.35)
     self._entrance.hide()
     self._exit = NodePath('exit')
     self._exit.setScale(0.35)
     self._exit.reparentTo(self)
     self._exitOpen = cardModel.find(baseName + 'exitOpen')
     self._exitOpen.reparentTo(self._exit)
     self._exitClosed = cardModel.find(baseName + 'exitClosed')
     self._exitClosed.reparentTo(self._exit)
     self._suitMarkerTemplate = cardModel.find(baseName + 'cogIcon')
     self._suitMarkerTemplate.detachNode()
     self._suitMarkerTemplate.setScale(0.225)
     self._waterCoolerTemplate = cardModel.find(baseName + 'waterDrop')
     self._waterCoolerTemplate.detachNode()
     self._waterCoolerTemplate.setScale(0.225)
     self._exit.hide()
     cardModel.removeNode()
コード例 #2
0
    def _createMaskTextureCard(self):
        """
        This will return a NodePath with a card textured with the map mask.  It
        also creates several other members that re needed to change the mask.
        """
        # create and fill empty mask image
        self._maskImage = PNMImage(self._maskResolution, self._maskResolution,
                                   4)
        for x in range(self._maskResolution):
            for y in range(self._maskResolution):
                #maskImage.setXel(x,y,mapImage.getRed(x/13,y/10),mapImage.getGreen(x/13,y/10),mapImage.getBlue(x/13,y/10))
                self._maskImage.setXelA(x, y, 0, 0, 0, 1)

        # create the texture for the mask
        self.maskTexture = Texture("maskTexture")
        self.maskTexture.setupTexture(Texture.TT2dTexture,
                                      self._maskResolution,
                                      self._maskResolution, 1,
                                      Texture.TUnsignedByte, Texture.FRgba)
        self.maskTexture.setMinfilter(Texture.FTLinear)
        self.maskTexture.setWrapU(Texture.WMClamp)
        self.maskTexture.setWrapV(Texture.WMClamp)

        self.maskTexture.load(self._maskImage)
        base.graphicsEngine.renderFrame()

        # put the mask texture on a card and return it
        cm = CardMaker("mask_cardMaker")
        cm.setFrame(-1.0, 1.0, -1.0, 1.0)
        mask = self.attachNewNode(cm.generate())
        mask.setTexture(self.maskTexture, 1)
        mask.setTransparency(1)
        return mask
コード例 #3
0
    def setupRightTexture(self):
        cm = CardMaker('quadMaker')
        cm.setColor(1.0, 1.0, 1.0, 1.0)

        aspect = base.camLens.getAspectRatio()
        htmlWidth = 2.0 * aspect * WEB_WIDTH / float(WIN_WIDTH)
        htmlHeight = 2.0 * float(WEB_HEIGHT) / float(WIN_HEIGHT)

        # the html area will be center aligned and vertically top aligned
        #cm.setFrame(-htmlWidth/2.0, htmlWidth/2.0, 1.0 - htmlHeight, 1.0)
        cm.setFrame(0, htmlWidth / 2.0, -htmlHeight / 2.0, htmlHeight / 2.0)
        card = cm.generate()
        self.rightQuad = NodePath(card)
        self.rightQuad.reparentTo(self.parent)

        self.rightGuiTex = Texture("guiTex")
        self.rightGuiTex.setupTexture(Texture.TT2dTexture, WEB_HALF_WIDTH,
                                      WEB_HEIGHT, 1, Texture.TUnsignedByte,
                                      Texture.FRgba)
        self.rightGuiTex.setKeepRamImage(True)
        self.rightGuiTex.makeRamImage()
        self.rightGuiTex.setWrapU(Texture.WMClamp)
        self.rightGuiTex.setWrapV(Texture.WMClamp)

        ts = TextureStage('rightWebTS')
        self.rightQuad.setTexture(ts, self.rightGuiTex)
        self.rightQuad.setTexScale(ts, 1.0, -1.0)

        self.rightQuad.setTransparency(0)
        self.rightQuad.setTwoSided(True)
        self.rightQuad.setColor(1.0, 1.0, 1.0, 1.0)
コード例 #4
0
 def announceGenerate(self):
     assert (self.notify.debug("announceGenerate()"))
     DistributedObject.DistributedObject.announceGenerate(self)
     self.sendUpdate("avIdEnteredParty", [base.localAvatar.doId])
     # we probably just spent a lot of time loading, so
     # tell globalClock to update the frame timestamp
     globalClock.syncFrameTime()
     self.startPartyClock()
     base.localAvatar.chatMgr.chatInputSpeedChat.addInsidePartiesMenu()
     self.spawnTitleText()
     messenger.send(self.generatedEvent)
     if ConfigVariableBool('show-debug-party-grid', 0).getValue():
         # Debug grid
         self.testGrid = NodePath("test_grid")
         self.testGrid.reparentTo(base.cr.playGame.hood.loader.geom)
         for i in range(len(self.grid)):
             for j in range(len(self.grid[i])):
                 cm = CardMaker("gridsquare")
                 np = NodePath(cm.generate())
                 np.setScale(12)
                 np.setP(-90.0)
                 np.setPos(
                     PartyUtils.convertDistanceFromPartyGrid(j, 0) - 6.0,
                     PartyUtils.convertDistanceFromPartyGrid(i, 1) - 6.0,
                     0.1)
                 np.reparentTo(self.testGrid)
                 if self.grid[i][j]:
                     np.setColorScale(0.0, 1.0, 0.0, 1.0)
                 else:
                     np.setColorScale(1.0, 0.0, 0.0, 1.0)
コード例 #5
0
    def __init__(self, player):

        self.player = player

        self.root = NodePath("CogdoFlyingGui")
        self.root.reparentTo(aspect2d)

        self.fuelMeter = NodePath("scrubMeter")
        self.fuelMeter.reparentTo(self.root)
        self.fuelMeter.setPos(1.1, 0.0, -0.7)
        self.fuelMeter.setSz(2.0)

        cm = CardMaker('card')
        cm.setFrame(-0.07, 0.07, 0.0, 0.75)
        self.fuelMeterBar = self.fuelMeter.attachNewNode(cm.generate())
        self.fuelMeterBar.setColor(0.95, 0.95, 0.0, 1.0)

        self.fuelLabel = DirectLabel(
            parent=self.root,
            relief=None,
            pos=(1.1, 0, -0.8),
            scale=0.075,
            text="Fuel",
            text_fg=(0.95, 0.95, 0, 1),
            text_shadow=(0, 0, 0, 1),
            text_font=ToontownGlobals.getInterfaceFont(),
        )

        self.messageLabel = DirectLabel(
            parent=self.root,
            relief=None,
            pos=(0.0, 0.0, -0.9),
            scale=0.1,
            text="                ",
            text_align=TextNode.ACenter,
            text_fg=(0.95, 0.95, 0, 1),
            text_shadow=(0, 0, 0, 1),
            text_font=ToontownGlobals.getInterfaceFont(),
            textMayChange=1,
        )
        self.messageLabel.stash()

        self.winLabel = DirectLabel(
            parent=self.root,
            relief=None,
            pos=(0.0, 0.0, 0.0),
            scale=0.25,
            text="You win!",
            text_align=TextNode.ACenter,
            text_fg=(0.95, 0.95, 0, 1),
            text_shadow=(0, 0, 0, 1),
            text_font=ToontownGlobals.getInterfaceFont(),
        )
        self.winLabel.stash()

        self.refuelLerp = LerpFunctionInterval(self.fuelMeterBar.setSz,
                                               fromData=0.0,
                                               toData=1.0,
                                               duration=2.0)
コード例 #6
0
    def loadFlatQuad(self, fullFilename):
        """Load the flat jpg into a quad."""
        assert self.notify.debugStateCall(self)
        #Texture.setTexturesPower2(AutoTextureScale.ATSUp)
        #Texture.setTexturesPower2(2)

        cm = CardMaker('cm-%s' % fullFilename)
        cm.setColor(1.0, 1.0, 1.0, 1.0)
        aspect = base.camLens.getAspectRatio()
        htmlWidth = 2.0 * aspect * WEB_WIDTH_PIXELS / float(WIN_WIDTH)
        htmlHeight = 2.0 * float(WEB_HEIGHT_PIXELS) / float(WIN_HEIGHT)

        # the html area will be center aligned and vertically top aligned
        #cm.setFrame(-htmlWidth/2.0, htmlWidth/2.0, 1.0 - htmlHeight, 1.0)
        cm.setFrame(-htmlWidth / 2.0, htmlWidth / 2.0, -htmlHeight / 2.0,
                    htmlHeight / 2.0)

        bottomRightX = (WEB_WIDTH_PIXELS) / float(WEB_WIDTH + 1)
        bottomRightY = WEB_HEIGHT_PIXELS / float(WEB_HEIGHT + 1)

        #cm.setUvRange(Point2(0,0), Point2(bottomRightX, bottomRightY))
        cm.setUvRange(Point2(0, 1 - bottomRightY), Point2(bottomRightX, 1))

        card = cm.generate()
        quad = NodePath(card)
        #quad.reparentTo(self.parent)

        jpgFile = PNMImage(WEB_WIDTH, WEB_HEIGHT)
        smallerJpgFile = PNMImage()
        readFile = smallerJpgFile.read(Filename(fullFilename))
        if readFile:
            jpgFile.copySubImage(smallerJpgFile, 0, 0)

            guiTex = Texture("guiTex")
            guiTex.setupTexture(Texture.TT2dTexture, WEB_WIDTH, WEB_HEIGHT, 1,
                                Texture.TUnsignedByte, Texture.FRgba)
            guiTex.setMinfilter(Texture.FTLinear)
            guiTex.load(jpgFile)
            #guiTex.setKeepRamImage(True)
            #guiTex.makeRamImage()
            guiTex.setWrapU(Texture.WMClamp)
            guiTex.setWrapV(Texture.WMClamp)

            ts = TextureStage('webTS')
            quad.setTexture(ts, guiTex)
            #quad.setTexScale(ts, 1.0, -1.0)

            quad.setTransparency(0)
            quad.setTwoSided(True)
            quad.setColor(1.0, 1.0, 1.0, 1.0)
            result = quad
        else:
            # if we have an error loading the file, return None to signify an error
            result = None

        #Texture.setTexturesPower2(AutoTextureScale.ATSDown)
        Texture.setTexturesPower2(1)
        return result
コード例 #7
0
    def _createMapTextureCard(self):
        """
        This will return a NodePath with a card textured with the minimap.  The
        minimap texture is dynamically created from the map data.
        """
        # create and fill empty map image
        mapImage = PNMImage(MAP_RESOLUTION, MAP_RESOLUTION)
        blockFiles = []
        for i in range(5):
            blockFiles.append(PNMImage())
            #blockFiles[i].read(Filename("mapBlock%i.png"%(i+1)))
            # TODO:maze either reference a set of textures for each piece or fill with color
            blockFiles[i].read(Filename('phase_4/maps/male_sleeve4New.png'))
        mapImage.fill(0.8, 0.8, 0.8)

        # iterate through the map data and place a block in the map image where appropriate
        for x in range(len(self._mazeLayout[0])):
            for y in range(len(self._mazeLayout)):
                if self._mazeLayout[y][x]:
                    ax = float(x) / len(self._mazeLayout[0]) * MAP_RESOLUTION
                    ay = float(y) / len(self._mazeLayout) * MAP_RESOLUTION

                    #TODO:maze use different blocks for different wall types or items
                    #mapImage.copySubImage(random.choice(blockFiles), int(ax), int(ay), 20, 20, 32, 32)

                    #TODO:maze find the ideal block texture size for the map so we dont
                    #          have to do this strange offset
                    #mapImage.copySubImage(blockFiles[0], int(ax), int(ay), 0, 0, 32, 32)
                    self._drawSquare(mapImage, int(ax), int(ay), 10,
                                     VBase4D(0.5, 0.5, 0.5, 1.0))

        # create a texture from the map image
        mapTexture = Texture("mapTexture")
        mapTexture.setupTexture(Texture.TT2dTexture, self._maskResolution,
                                self._maskResolution, 1, Texture.TUnsignedByte,
                                Texture.FRgba)
        mapTexture.setMinfilter(Texture.FTLinear)
        mapTexture.load(mapImage)
        mapTexture.setWrapU(Texture.WMClamp)
        mapTexture.setWrapV(Texture.WMClamp)

        mapImage.clear()
        del mapImage

        # put the texture on a card and return it
        cm = CardMaker("map_cardMaker")
        cm.setFrame(-1.0, 1.0, -1.0, 1.0)
        map = self.attachNewNode(cm.generate())
        map.setTexture(mapTexture, 1)
        return map
コード例 #8
0
    def setupTexture(self):
        cm = CardMaker('quadMaker')
        cm.setColor(1.0, 1.0, 1.0, 1.0)

        aspect = base.camLens.getAspectRatio()
        htmlWidth = 2.0 * aspect * WEB_WIDTH_PIXELS / float(WIN_WIDTH)
        htmlHeight = 2.0 * float(WEB_HEIGHT_PIXELS) / float(WIN_HEIGHT)

        # the html area will be center aligned and vertically top aligned
        #cm.setFrame(-htmlWidth/2.0, htmlWidth/2.0, 1.0 - htmlHeight, 1.0)
        cm.setFrame(-htmlWidth / 2.0, htmlWidth / 2.0, -htmlHeight / 2.0,
                    htmlHeight / 2.0)

        bottomRightX = (WEB_WIDTH_PIXELS) / float(WEB_WIDTH + 1)
        bottomRightY = WEB_HEIGHT_PIXELS / float(WEB_HEIGHT + 1)

        #cm.setUvRange(Point2(0,0), Point2(bottomRightX, bottomRightY))
        cm.setUvRange(Point2(0, 1 - bottomRightY), Point2(bottomRightX, 1))

        card = cm.generate()
        self.quad = NodePath(card)
        self.quad.reparentTo(self.parent)

        self.guiTex = Texture("guiTex")
        self.guiTex.setupTexture(Texture.TT2dTexture, WEB_WIDTH, WEB_HEIGHT, 1,
                                 Texture.TUnsignedByte, Texture.FRgba)
        self.guiTex.setMinfilter(Texture.FTLinear)
        self.guiTex.setKeepRamImage(True)
        self.guiTex.makeRamImage()
        self.guiTex.setWrapU(Texture.WMRepeat)
        self.guiTex.setWrapV(Texture.WMRepeat)

        ts = TextureStage('webTS')
        self.quad.setTexture(ts, self.guiTex)
        self.quad.setTexScale(ts, 1.0, -1.0)

        self.quad.setTransparency(0)
        self.quad.setTwoSided(True)
        self.quad.setColor(1.0, 1.0, 1.0, 1.0)
        #self.quad.setZ(0.1) # shtickerbook is moved up by 0.1

        self.calcMouseLimits()
コード例 #9
0
    def addLock(self, x, y, color):
        """
        Adds a lock to the minimap.  This will add a colored dot to the map
        that represents a lock.
        --- This is subject to change pending a new player-lock data system. ---
        """
        assert self.notify.debugCall()

        x, y = self._tileToActualPosition(x, y)

        # TODO:maze: replace with lock model / texture
        cm = CardMaker("lock_cardMaker")
        cm.setFrame(-0.04, 0.04, -0.04, 0.04)
        lock = self.maskedLayer.attachNewNode(cm.generate())

        lock.setColor(color)
        lock.setPos(x / self._maskResolution * 2.0 - 0.97, 0,
                    y / self._maskResolution * -2.0 + 1.02)

        self._locks.append(lock)
コード例 #10
0
    def addPlayer(self, x, y, color):
        """
        Adds a player to the minimap.  This will add a colored dot to the map
        that represents the player.  The dot location can then be updated
        using the revealCell call.
        --- This is subject to change pending a new player-lock data system. ---
        """
        assert self.notify.debugCall()

        x, y = self._tileToActualPosition(x, y)

        # TODO:maze: replace with player model / texture
        cm = CardMaker("player_cardMaker")
        cm.setFrame(-0.04, 0.04, -0.04, 0.04)
        player = self.visibleLayer.attachNewNode(cm.generate())

        player.setColor(color)
        player.setPos(x / self._maskResolution * 2.0 - 0.97, 0,
                      y / self._maskResolution * -2.0 + 1.02)

        self._players.append(player)
コード例 #11
0
 def __init__(self, av, **kw):
     DirectFrame.__init__(self, relief=None, sortOrder=50)
     self.initialiseoptions(QuestMap)
     self.container = DirectFrame(parent=self, relief=None)
     self.marker = DirectFrame(parent=self.container, relief=None)
     self.cogInfoFrame = DirectFrame(parent=self.container, relief=None)
     cm = CardMaker('bg')
     cm.setFrame(-0.5, 0.5, -0.5, 0.5)
     bg = self.cogInfoFrame.attachNewNode(cm.generate())
     bg.setTransparency(1)
     bg.setColor(0.5, 0.5, 0.5, 0.5)
     bg.setBin('fixed', 0)
     self.cogInfoFrame['geom'] = bg
     self.cogInfoFrame['geom_pos'] = (0, 0, 0)
     self.cogInfoFrame['geom_scale'] = (6, 1, 2)
     self.cogInfoFrame.setScale(0.05)
     self.cogInfoFrame.setPos(0, 0, 0.6)
     self.buildingMarkers = []
     self.av = av
     self.wantToggle = False
     if ConfigVariableBool('want-toggle-quest-map', True).getValue():
         self.wantToggle = True
     self.updateMarker = True
     self.cornerPosInfo = None
     self.hqPosInfo = None
     self.fishingSpotInfo = None
     self.load()
     self.setScale(1.5)
     bg.removeNode()
     self.hoodId = None
     self.zoneId = None
     self.suitPercentage = {}
     for currHoodInfo in SuitPlannerBase.SuitPlannerBase.SuitHoodInfo:
         tracks = currHoodInfo[
             SuitPlannerBase.SuitPlannerBase.SUIT_HOOD_INFO_TRACK]
         self.suitPercentage[currHoodInfo[
             SuitPlannerBase.SuitPlannerBase.SUIT_HOOD_INFO_ZONE]] = tracks
コード例 #12
0
    def load(self):
        assert self.notify.debugStateCall(self)

        # Create top node for the world. Reparent all the assets to this.
        self.world = NodePath('ToonBlitzWorld')

        # Loading the models
        self.background = loader.loadModel(
            "phase_4/models/minigames/toonblitz_game")
        self.background.reparentTo(self.world)

        self.startingWall = loader.loadModel(
            "phase_4/models/minigames/toonblitz_game_wall")
        self.startingPipe = loader.loadModel(
            "phase_4/models/minigames/toonblitz_game_start")
        self.exitElevator = loader.loadModel(
            "phase_4/models/minigames/toonblitz_game_elevator")
        self.arrow = loader.loadModel(
            "phase_4/models/minigames/toonblitz_game_arrow")
        self.sprayProp = loader.loadModel(
            "phase_4/models/minigames/prop_waterspray")

        self.treasureModelList = []
        salesIcon = loader.loadModel("phase_4/models/minigames/salesIcon")
        self.treasureModelList.append(salesIcon)
        moneyIcon = loader.loadModel("phase_4/models/minigames/moneyIcon")
        self.treasureModelList.append(moneyIcon)
        legalIcon = loader.loadModel("phase_4/models/minigames/legalIcon")
        self.treasureModelList.append(legalIcon)
        corpIcon = loader.loadModel("phase_4/models/minigames/corpIcon")
        self.treasureModelList.append(corpIcon)

        self.particleGlow = loader.loadModel(
            "phase_4/models/minigames/particleGlow")

        self.blockTypes = []
        for i in range(4):
            blockType = loader.loadModel(
                "phase_4/models/minigames/toonblitz_game_block0" + str(i))
            self.blockTypes.append(blockType)

        self.stomper = loader.loadModel(
            "phase_4/models/minigames/toonblitz_game_stomper")

        # Creating bottom floor
        plane = CollisionPlane(Plane(Vec3(0, 0, 1), Point3(0, 0, -50)))
        dropPlane = CollisionNode('dropPlane')
        dropPlane.addSolid(plane)
        dropPlane.setCollideMask(ToontownGlobals.FloorBitmask)
        self.world.attachNewNode(dropPlane)

        # Loading the music
        self.gameMusic = base.loadMusic("phase_4/audio/bgm/MG_TwoDGame.mid")
        self.treasureGrabSound = loader.loadSfx(
            "phase_4/audio/sfx/SZ_DD_treasure.mp3")
        self.sndOof = base.loader.loadSfx(
            'phase_4/audio/sfx/MG_cannon_hit_dirt.mp3')
        self.soundJump = base.loader.loadSfx(
            'phase_4/audio/sfx/MG_sfx_vine_game_jump.mp3')
        self.fallSound = base.loader.loadSfx(
            "phase_4/audio/sfx/MG_sfx_vine_game_fall.mp3")
        self.watergunSound = base.loader.loadSfx(
            "phase_4/audio/sfx/AA_squirt_seltzer_miss.mp3")
        self.splashSound = base.loader.loadSfx(
            "phase_4/audio/sfx/Seltzer_squirt_2dgame_hit.mp3")
        self.threeSparkles = loader.loadSfx(
            "phase_4/audio/sfx/threeSparkles.mp3")
        self.sparkleSound = loader.loadSfx("phase_4/audio/sfx/sparkly.mp3")
        self.headCollideSound = loader.loadSfx(
            "phase_3.5/audio/sfx/AV_collision.mp3")

        # Card for the progress line
        self.faceStartPos = Vec3(-0.80, 0, -0.87)
        self.faceEndPos = Vec3(0.80, 0, -0.87)
        self.aspect2dRoot = aspect2d.attachNewNode('TwoDGuiAspect2dRoot')
        self.aspect2dRoot.setDepthWrite(1)
        self.cardMaker = CardMaker('card')
        self.cardMaker.reset()
        self.cardMaker.setName('ProgressLine')
        self.cardMaker.setFrame(-0.5, 0.5, -0.5, 0.5)
        self.progressLine = self.aspect2dRoot.attachNewNode(
            self.cardMaker.generate())
        self.progressLine.setScale(self.faceEndPos[0] - self.faceStartPos[0],
                                   1, 0.01)
        self.progressLine.setPos(0, 0, self.faceStartPos[2])

        self.cardMaker.setName('RaceProgressLineHash')
        for n in range(
                ToonBlitzGlobals.NumSections[self.game.getSafezoneId()] + 1):
            hash = self.aspect2dRoot.attachNewNode(self.cardMaker.generate())
            hash.setScale(self.progressLine.getScale()[2], 1,
                          self.progressLine.getScale()[2] * 5)
            t = float(n) / ToonBlitzGlobals.NumSections[
                self.game.getSafezoneId()]
            hash.setPos(
                self.faceStartPos[0] * (1 - t) + self.faceEndPos[0] * t,
                self.faceStartPos[1], self.faceStartPos[2])
コード例 #13
0
    def __init__(self, distRace):
        self.race = distRace
        self.timerEnabled = False
        self.maxLapHit = 0
        self.photoFinish = False

        toonInteriorTextures = loader.loadModel(
            'phase_3.5/models/modules/toon_interior_textures')
        invTextures = loader.loadModel('phase_3.5/models/gui/inventory_icons')
        racingTextures = loader.loadModel(
            'phase_6/models/karting/racing_textures')
        self.gagTextures = [
            toonInteriorTextures.find('**/couch'),
            invTextures.find('**/inventory_bannana_peel'),
            racingTextures.find('**/boost_arrow'),
            invTextures.find('**/inventory_anvil'),
            invTextures.find('**/inventory_creampie'),
        ]
        self.gagTextures[1].setScale(7.5)
        self.gagTextures[3].setScale(7.5)
        self.gagTextures[4].setScale(7.5)

        self.cardMaker = CardMaker('card')

        #racer info
        self.racerDict = {}

        #setup render2d
        self.render2dRoot = render2d.attachNewNode('RaceGuiRender2dRoot')
        self.render2dRoot.setDepthWrite(1)

        #setup a list of directobjects
        self.directObjList = []

        #setup aspect2d
        self.aspect2dRoot = aspect2d.attachNewNode('RaceGuiAspect2dRoot')
        self.aspect2dRoot.setDepthWrite(1)

        #setup raceModeRoot
        self.raceModeRoot = self.aspect2dRoot.attachNewNode('RaceModeRoot')

        #setup the 'leave race' button
        gui = loader.loadModel("phase_3.5/models/gui/avatar_panel_gui")
        self.closeButton = DirectButton(
            image=(
                gui.find("**/CloseBtn_UP"),
                gui.find("**/CloseBtn_DN"),
                gui.find("**/CloseBtn_Rllvr"),
                gui.find("**/CloseBtn_UP"),
            ),
            relief=None,
            scale=1.05,
            text=TTLocalizer.KartRace_Leave,
            text_scale=0.04,
            text_pos=(0, -0.07),
            text_fg=VBase4(1, 1, 1, 1),
            pos=(-0.99, 0, 0.925),
            command=self.race.leaveRace,
        )
        self.closeButton.reparentTo(self.aspect2dRoot)
        self.directObjList.append(self.closeButton)

        #setup the race gui
        self.raceTimeDelta = 0
        self.raceModeReady = False
        #        self.initRaceMode()

        #setup the end result mode gui
        self.resultModeReady = False
        #        self.initResultMode()

        # Load the sounds for cycling through and picking a gag.
        # Since the methods for gag cycling are all here, it makes sense
        # for the sounds to be here as well.
        self.gagCycleSound = base.loadSfx(
            "phase_3.5/audio/sfx/tick_counter.mp3")
        if hasattr(self.gagCycleSound, "setPlayRate"):
            self.gagCycleSound.setPlayRate(0.2)
        self.gagCycleSound.setLoop(1)
        self.gagAcquireSound = base.loadSfx(
            "phase_6/audio/sfx/SZ_MM_gliss.mp3")

        self.disable()