Example #1
0
    def awardTrophies(self):
        """Award the trophies. Also update self.newTrophies."""
        stillPlaying = self.getStillPlayingAvIds()
        for avId in stillPlaying:
            av = simbase.air.doId2do.get(avId)
            if av:
                oldHistory = self.startingHistory[avId]
                endingHistory = self.endingHistory[avId]
                oldTrophies = GolfGlobals.calcTrophyListFromHistory(oldHistory)
                endingTrophies = GolfGlobals.calcTrophyListFromHistory(
                    endingHistory)
                av.b_setGolfHistory(endingHistory)

                # now figure out which trophies he just got
                newTrophies = []
                for index in xrange(len(oldTrophies)):
                    if not oldTrophies[index] and endingTrophies[index]:
                        self.notify.debug('New Trophy %d' % index)
                        self.air.writeServerEvent("golf_trophy", avId,
                                                  "%s" % (index))
                        newTrophies.append(True)
                        self.trophyListLen = self.trophyListLen + 1
                    else:
                        newTrophies.append(False)
                self.newTrophies[avId] = newTrophies
Example #2
0
    def awardCups(self):
        """Award the cups and laff boost. Also update self.newCups."""
        stillPlaying = self.getStillPlayingAvIds()
        for avId in stillPlaying:
            av = simbase.air.doId2do.get(avId)
            if av:
                oldHistory = self.startingHistory[avId]
                endingHistory = self.endingHistory[avId]
                oldCups = GolfGlobals.calcCupListFromHistory(oldHistory)
                endingCups = GolfGlobals.calcCupListFromHistory(endingHistory)

                # now figure out which trophies he just got
                newCups = []
                for index in xrange(len(oldCups)):
                    if not oldCups[index] and endingCups[index]:
                        self.notify.debug('New Trophy %d' % index)
                        newCups.append(True)
                        self.air.writeServerEvent("golf_cup", avId,
                                                  "%s" % (index))
                        newMaxHp = av.getMaxHp() + 1
                        av.b_setMaxHp(newMaxHp)
                        # Also, give them a full heal
                        av.toonUp(newMaxHp)
                    else:
                        newCups.append(False)

                self.newCups[avId] = newCups
Example #3
0
 def load(self):
     self.gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui')
     self.listXorigin = -0.5
     self.listFrameSizeX = 1.5
     self.listZorigin = -0.90000000000000002
     self.listFrameSizeZ = 1.04
     self.arrowButtonScale = 1.3
     self.itemFrameXorigin = -0.23699999999999999
     self.itemFrameZorigin = 0.36499999999999999
     self.labelXstart = self.itemFrameXorigin + 0.29299999999999998
     self.scrollList = DirectScrolledList(parent = self, relief = None, pos = (0, 0, 0), incButton_image = (self.gui.find('**/FndsLst_ScrollUp'), self.gui.find('**/FndsLst_ScrollDN'), self.gui.find('**/FndsLst_ScrollUp_Rllvr'), self.gui.find('**/FndsLst_ScrollUp')), incButton_relief = None, incButton_scale = (self.arrowButtonScale, self.arrowButtonScale, -(self.arrowButtonScale)), incButton_pos = (self.labelXstart, 0, self.itemFrameZorigin - 0.999), incButton_image3_color = Vec4(1, 1, 1, 0.20000000000000001), decButton_image = (self.gui.find('**/FndsLst_ScrollUp'), self.gui.find('**/FndsLst_ScrollDN'), self.gui.find('**/FndsLst_ScrollUp_Rllvr'), self.gui.find('**/FndsLst_ScrollUp')), decButton_relief = None, decButton_scale = (self.arrowButtonScale, self.arrowButtonScale, self.arrowButtonScale), decButton_pos = (self.labelXstart, 0, self.itemFrameZorigin + 0.22700000000000001), decButton_image3_color = Vec4(1, 1, 1, 0.20000000000000001), itemFrame_pos = (self.itemFrameXorigin, 0, self.itemFrameZorigin), itemFrame_scale = 1.0, itemFrame_relief = DGG.SUNKEN, itemFrame_frameSize = (self.listXorigin, self.listXorigin + self.listFrameSizeX, self.listZorigin, self.listZorigin + self.listFrameSizeZ), itemFrame_frameColor = (0.84999999999999998, 0.94999999999999996, 1, 1), itemFrame_borderWidth = (0.01, 0.01), numItemsVisible = 12, forceHeight = 0.083000000000000004, items = [])
     for courseId in GolfGlobals.CourseInfo:
         courseName = GolfGlobals.getCourseName(courseId)
         frame = DirectFrame(parent = self.scrollList, relief = None)
         courseNameDisplay = DirectLabel(parent = frame, relief = None, pos = (-0.47499999999999998, 0, 0.050000000000000003), text = courseName, text_align = TextNode.ALeft, text_scale = 0.074999999999999997, text_fg = (0.84999999999999998, 0.64000000000000001, 0.13, 1.0), text_shadow = (0, 0, 0, 1), text_font = ToontownGlobals.getSignFont())
         bestScoreDisplay = DirectLabel(parent = frame, relief = None, pos = (0.90000000000000002, 0, 0.050000000000000003), text = TTLocalizer.KartRace_Unraced, text_scale = 0.059999999999999998, text_fg = (0.0, 0.0, 0.0, 1.0), text_font = ToontownGlobals.getToonFont())
         self.bestDisplayList.append(bestScoreDisplay)
         self.scrollList.addItem(frame)
     
     for holeId in GolfGlobals.HoleInfo:
         holeName = GolfGlobals.getHoleName(holeId)
         frame = DirectFrame(parent = self.scrollList, relief = None)
         holeNameDisplay = DirectLabel(parent = frame, relief = None, pos = (-0.47499999999999998, 0, 0.050000000000000003), text = holeName, text_align = TextNode.ALeft, text_scale = 0.074999999999999997, text_fg = (0.94999999999999996, 0.94999999999999996, 0.0, 1.0), text_shadow = (0, 0, 0, 1), text_font = ToontownGlobals.getSignFont())
         bestScoreDisplay = DirectLabel(parent = frame, relief = None, pos = (0.90000000000000002, 0, 0.050000000000000003), text = TTLocalizer.KartRace_Unraced, text_scale = 0.059999999999999998, text_fg = (0.0, 0.0, 0.0, 1.0), text_font = ToontownGlobals.getToonFont())
         self.bestDisplayList.append(bestScoreDisplay)
         self.scrollList.addItem(frame)
Example #4
0
 def doGolf(self, word):
     args = word.split()
     response = None
     if len(args) == 1:
         pass
     1
     if args[1] == 'debugBarrier':
         golfHole = base.cr.doFind('DistributedGolfHole')
         if golfHole:
             if hasattr(golfHole, 'golfBarrier') and not golfHole.golfBarrier.isEmpty():
                 if golfHole.golfBarrier.isHidden():
                     golfHole.golfBarrier.show()
                     response = 'showing golf barrier'
                 else:
                     golfHole.golfBarrier.hide()
                     response = 'hiding golf barrier'
             
         else:
             response = 'no golf hole'
     elif args[1] == 'contact':
         messenger.send('ode toggle contacts')
     elif args[1] == 'power':
         if len(args) > 2:
             base.golfPower = args[2]
             response = 'setting power to %s' % args[2]
         else:
             base.golfPower = None
             response = 'unsetting power'
     elif args[1] == 'heading':
         if len(args) > 2:
             golfHole = base.cr.doFind('DistributedGolfHole')
             if golfHole:
                 golfHole.doMagicWordHeading(args[2])
                 response = 'setting heading to %s' % args[2]
             
         else:
             response = 'need heading parameter'
     elif args[1] == 'list':
         response = ''
         for holeId in GolfGlobals.HoleInfo:
             if holeId < 18:
                 response += '%d: %s\n' % (holeId, GolfGlobals.getHoleName(holeId))
                 continue
         
     elif args[1] == 'list2':
         response = ''
         for holeId in GolfGlobals.HoleInfo:
             if holeId >= 18:
                 response += '%d: %s\n' % (holeId, GolfGlobals.getHoleName(holeId))
                 continue
         
     
     if response:
         self.setMagicWordResponse(response)
 def doGolf(self, word):
     args = word.split()
     response = None
     if len(args) == 1:
         pass
     1
     if args[1] == 'debugBarrier':
         golfHole = base.cr.doFind('DistributedGolfHole')
         if golfHole:
             if hasattr(golfHole, 'golfBarrier') and not golfHole.golfBarrier.isEmpty():
                 if golfHole.golfBarrier.isHidden():
                     golfHole.golfBarrier.show()
                     response = 'showing golf barrier'
                 else:
                     golfHole.golfBarrier.hide()
                     response = 'hiding golf barrier'
             
         else:
             response = 'no golf hole'
     elif args[1] == 'contact':
         messenger.send('ode toggle contacts')
     elif args[1] == 'power':
         if len(args) > 2:
             base.golfPower = args[2]
             response = 'setting power to %s' % args[2]
         else:
             base.golfPower = None
             response = 'unsetting power'
     elif args[1] == 'heading':
         if len(args) > 2:
             golfHole = base.cr.doFind('DistributedGolfHole')
             if golfHole:
                 golfHole.doMagicWordHeading(args[2])
                 response = 'setting heading to %s' % args[2]
             
         else:
             response = 'need heading parameter'
     elif args[1] == 'list':
         response = ''
         for holeId in GolfGlobals.HoleInfo:
             if holeId < 18:
                 response += '%d: %s\n' % (holeId, GolfGlobals.getHoleName(holeId))
                 continue
         
     elif args[1] == 'list2':
         response = ''
         for holeId in GolfGlobals.HoleInfo:
             if holeId >= 18:
                 response += '%d: %s\n' % (holeId, GolfGlobals.getHoleName(holeId))
                 continue
         
     
     if response:
         self.setMagicWordResponse(response)
Example #6
0
    def doGolf(self, word):
        """Handle the ~golf magic word for valid client side stuff."""
        args = word.split()
        response = None
        if len(args) == 1:
            # No parameter: ignore (handled by AI).
            pass
        elif args[1] == "debugBarrier":
            golfHole = base.cr.doFind('DistributedGolfHole')
            if golfHole:
                if hasattr(
                        golfHole,
                        'golfBarrier') and not golfHole.golfBarrier.isEmpty():
                    if golfHole.golfBarrier.isHidden():
                        golfHole.golfBarrier.show()
                        response = 'showing golf barrier'
                    else:
                        golfHole.golfBarrier.hide()
                        response = 'hiding golf barrier'
            else:
                response = 'no golf hole'
        elif args[1] == "contact":
            messenger.send("ode toggle contacts")
        elif args[1] == "power":
            if len(args) > 2:
                base.golfPower = args[2]
                response = ('setting power to %s' % (args[2]))
            else:
                base.golfPower = None
                response = 'unsetting power'
        elif args[1] == "heading":
            if len(args) > 2:
                golfHole = base.cr.doFind('DistributedGolfHole')
                if golfHole:
                    golfHole.doMagicWordHeading(args[2])
                    response = ('setting heading to %s' % (args[2]))
            else:
                response = 'need heading parameter'
        elif args[1] == "list":
            response = ""
            for holeId in GolfGlobals.HoleInfo:
                if holeId < 18:
                    response += '%d: %s\n' % (holeId,
                                              GolfGlobals.getHoleName(holeId))
        elif args[1] == "list2":
            response = ""
            for holeId in GolfGlobals.HoleInfo:
                if holeId >= 18:
                    response += '%d: %s\n' % (holeId,
                                              GolfGlobals.getHoleName(holeId))

        if response:
            self.setMagicWordResponse(response)
    def doGolf(self, word):
        args = word.split()
        response = None
        if len(args) == 1:
            pass
        elif args[1] == "debugBarrier":
            golfHole = base.cr.doFind("DistributedGolfHole")
            if golfHole:
                if hasattr(golfHole, "golfBarrier") and not golfHole.golfBarrier.isEmpty():
                    if golfHole.golfBarrier.isHidden():
                        golfHole.golfBarrier.show()
                        response = "showing golf barrier"
                    else:
                        golfHole.golfBarrier.hide()
                        response = "hiding golf barrier"
            else:
                response = "no golf hole"
        elif args[1] == "contact":
            messenger.send("ode toggle contacts")
        elif args[1] == "power":
            if len(args) > 2:
                base.golfPower = args[2]
                response = "setting power to %s" % args[2]
            else:
                base.golfPower = None
                response = "unsetting power"
        elif args[1] == "heading":
            if len(args) > 2:
                golfHole = base.cr.doFind("DistributedGolfHole")
                if golfHole:
                    golfHole.doMagicWordHeading(args[2])
                    response = "setting heading to %s" % args[2]
            else:
                response = "need heading parameter"
        elif args[1] == "list":
            response = ""
            for holeId in GolfGlobals.HoleInfo:
                if holeId < 18:
                    response += "%d: %s\n" % (holeId, GolfGlobals.getHoleName(holeId))

        elif args[1] == "list2":
            response = ""
            for holeId in GolfGlobals.HoleInfo:
                if holeId >= 18:
                    response += "%d: %s\n" % (holeId, GolfGlobals.getHoleName(holeId))

        if response:
            self.setMagicWordResponse(response)
        return
    def showBoard(self, task = None):
        scoreDict = self.golfCourse.scores
        x = 0
        currentGolfer = self.golfCourse.getCurGolfer()
        for playaIndex in range(self.numPlayas):
            if self.golfCourse.isGameDone():
                self.playaTags[playaIndex].setColor(0, 0, 0, 1)
            elif currentGolfer == self.golfCourse.avIdList[playaIndex]:
                self.highlightCur.setColor(*GolfGlobals.PlayerColors[playaIndex])
                self.highlightCur.setAlphaScale(0.4)
                self.highlightCur.setPos(-0.003, 0, 0.038 - playaIndex * (self.lineVertOffset + 0.005))
                self.highlightCur.show()
            else:
                self.playaTags[playaIndex].setColor(0, 0, 0, 1)

        for avId in self.avIdList:
            holeIndex = 0
            totScore = 0
            playerExited = False
            for y in range(len(self.golfCourse.exitedAvIdList)):
                if self.golfCourse.exitedAvIdList[y] == avId:
                    self.playaTags[x].setColor(0.7, 0.7, 0.7, 1)
                    holeIndex = 0
                    for holeIndex in range(self.golfCourse.numHoles):
                        self.getScoreLabel(self.avIdList[x], holeIndex).setColor(0.7, 0.7, 0.7, 1)

                    self.totalTags[x].setColor(0.7, 0.7, 0.7, 1)
                    playerExited = True

            if playerExited == False:
                for holeIndex in range(self.golfCourse.numHoles):
                    if holeIndex <= self.golfCourse.curHoleIndex:
                        self.getScoreLabel(avId, holeIndex)['text'] = '%s' % scoreDict[avId][holeIndex]
                        totScore = totScore + scoreDict[avId][holeIndex]
                        if self.golfCourse.isGameDone() == False:
                            if holeIndex == self.golfCourse.curHoleIndex:
                                self.getScoreLabel(avId, holeIndex).setColor(1, 0, 0, 1)
                                self.holeLabels[holeIndex].setColor(1, 0, 0, 1)
                                self.parLabels[holeIndex].setColor(1, 0, 0, 1)
                                title = GolfGlobals.getCourseName(self.golfCourse.courseId) + ' - ' + GolfGlobals.getHoleName(self.golfCourse.holeIds[self.golfCourse.curHoleIndex])
                                self.titleLabel['text'] = title
                            else:
                                self.getScoreLabel(avId, holeIndex).setColor(0, 0, 0, 1)
                                self.holeLabels[holeIndex].setColor(0, 0, 0, 1)
                                self.parLabels[holeIndex].setColor(0, 0, 0, 1)

                self.totalTags[x]['text'] = '%s' % totScore
            if self.golfCourse.isGameDone():
                self.getScoreLabel(avId, self.golfCourse.numHoles - 1).setColor(0, 0, 0, 1)
                self.totalTags[x].setColor(1, 0, 0, 1)
            x = x + 1

        y = 0
        if self.golfCourse.isGameDone():
            self.parLabels[self.golfCourse.numHoles - 1].setColor(0, 0, 0, 1)
            self.holeLabels[self.golfCourse.numHoles - 1].setColor(0, 0, 0, 1)
            self.parLabels[self.golfCourse.numHoles].setColor(1, 0, 0, 1)
            self.totalLabel.setColor(1, 0, 0, 1)
        self.scoreboard.show()
        self.maximizeB.hide()
    def showBoard(self, task = None):
        scoreDict = self.golfCourse.scores
        x = 0
        currentGolfer = self.golfCourse.getCurGolfer()
        for playaIndex in xrange(self.numPlayas):
            if self.golfCourse.isGameDone():
                self.playaTags[playaIndex].setColor(0, 0, 0, 1)
            elif currentGolfer == self.golfCourse.avIdList[playaIndex]:
                self.highlightCur.setColor(*GolfGlobals.PlayerColors[playaIndex])
                self.highlightCur.setAlphaScale(0.4)
                self.highlightCur.setPos(-0.003, 0, 0.038 - playaIndex * (self.lineVertOffset + 0.005))
                self.highlightCur.show()
            else:
                self.playaTags[playaIndex].setColor(0, 0, 0, 1)

        for avId in self.avIdList:
            holeIndex = 0
            totScore = 0
            playerExited = False
            for y in xrange(len(self.golfCourse.exitedAvIdList)):
                if self.golfCourse.exitedAvIdList[y] == avId:
                    self.playaTags[x].setColor(0.7, 0.7, 0.7, 1)
                    holeIndex = 0
                    for holeIndex in xrange(self.golfCourse.numHoles):
                        self.getScoreLabel(self.avIdList[x], holeIndex).setColor(0.7, 0.7, 0.7, 1)

                    self.totalTags[x].setColor(0.7, 0.7, 0.7, 1)
                    playerExited = True

            if playerExited == False:
                for holeIndex in xrange(self.golfCourse.numHoles):
                    if holeIndex <= self.golfCourse.curHoleIndex:
                        self.getScoreLabel(avId, holeIndex)['text'] = '%s' % scoreDict[avId][holeIndex]
                        totScore = totScore + scoreDict[avId][holeIndex]
                        if self.golfCourse.isGameDone() == False:
                            if holeIndex == self.golfCourse.curHoleIndex:
                                self.getScoreLabel(avId, holeIndex).setColor(1, 0, 0, 1)
                                self.holeLabels[holeIndex].setColor(1, 0, 0, 1)
                                self.parLabels[holeIndex].setColor(1, 0, 0, 1)
                                title = GolfGlobals.getCourseName(self.golfCourse.courseId) + ' - ' + GolfGlobals.getHoleName(self.golfCourse.holeIds[self.golfCourse.curHoleIndex])
                                self.titleLabel['text'] = title
                            else:
                                self.getScoreLabel(avId, holeIndex).setColor(0, 0, 0, 1)
                                self.holeLabels[holeIndex].setColor(0, 0, 0, 1)
                                self.parLabels[holeIndex].setColor(0, 0, 0, 1)

                self.totalTags[x]['text'] = '%s' % totScore
            if self.golfCourse.isGameDone():
                self.getScoreLabel(avId, self.golfCourse.numHoles - 1).setColor(0, 0, 0, 1)
                self.totalTags[x].setColor(1, 0, 0, 1)
            x = x + 1

        y = 0
        if self.golfCourse.isGameDone():
            self.parLabels[self.golfCourse.numHoles - 1].setColor(0, 0, 0, 1)
            self.holeLabels[self.golfCourse.numHoles - 1].setColor(0, 0, 0, 1)
            self.parLabels[self.golfCourse.numHoles].setColor(1, 0, 0, 1)
            self.totalLabel.setColor(1, 0, 0, 1)
        self.scoreboard.show()
        self.maximizeB.hide()
Example #10
0
 def grow(self, index, pos):
     self.trophyPanels[index]['image_color'] = Vec4(1.0, 1.0, 0.8, 1.0)
     if index < GolfGlobals.NumTrophies:
         self.trophyTextDisplay['text'] = TTLocalizer.GolfTrophyTextDisplay % {'number': index + 1,
          'desc': TTLocalizer.GolfTrophyDescriptions[index]}
         historyIndex = GolfGlobals.getHistoryIndexForTrophy(index)
         if historyIndex >= 0:
             self.currentHistory['text'] = TTLocalizer.GolfCurrentHistory % {'historyDesc': TTLocalizer.GolfHistoryDescriptions[historyIndex],
              'num': self.avatar.getGolfHistory()[historyIndex]}
Example #11
0
 def grow(self, index, pos):
     self.trophyPanels[index]['image_color'] = Vec4(1.0, 1.0, 0.8, 1.0)
     if index < GolfGlobals.NumTrophies:
         self.trophyTextDisplay['text'] = TTLocalizer.GolfTrophyTextDisplay % {'number': index + 1,
          'desc': TTLocalizer.GolfTrophyDescriptions[index]}
         historyIndex = GolfGlobals.getHistoryIndexForTrophy(index)
         if historyIndex >= 0:
             self.currentHistory['text'] = TTLocalizer.GolfCurrentHistory % {'historyDesc': TTLocalizer.GolfHistoryDescriptions[historyIndex],
              'num': self.avatar.getGolfHistory()[historyIndex]}
 def awardTrophies(self):
     stillPlaying = self.getStillPlayingAvIds()
     for avId in stillPlaying:
         av = simbase.air.doId2do.get(avId)
         if av:
             oldHistory = self.startingHistory[avId]
             endingHistory = self.endingHistory[avId]
             oldTrophies = GolfGlobals.calcTrophyListFromHistory(oldHistory)
             endingTrophies = GolfGlobals.calcTrophyListFromHistory(endingHistory)
             av.b_setGolfHistory(endingHistory)
             newTrophies = []
             for index in xrange(len(oldTrophies)):
                 if not oldTrophies[index] and endingTrophies[index]:
                     self.notify.debug('New Trophy %d' % index)
                     self.air.writeServerEvent('golf_trophy', avId, '%s' % index)
                     newTrophies.append(True)
                     self.trophyListLen = self.trophyListLen + 1
                     continue
                 newTrophies.append(False)
             self.newTrophies[avId] = newTrophies
 def awardCups(self):
     stillPlaying = self.getStillPlayingAvIds()
     for avId in stillPlaying:
         av = simbase.air.doId2do.get(avId)
         if av:
             oldHistory = self.startingHistory[avId]
             endingHistory = self.endingHistory[avId]
             oldCups = GolfGlobals.calcCupListFromHistory(oldHistory)
             endingCups = GolfGlobals.calcCupListFromHistory(endingHistory)
             newCups = []
             for index in xrange(len(oldCups)):
                 if not oldCups[index] and endingCups[index]:
                     self.notify.debug('New Trophy %d' % index)
                     newCups.append(True)
                     self.air.writeServerEvent('golf_cup', avId, '%s' % index)
                     newMaxHp = av.getMaxHp() + 1
                     av.b_setMaxHp(newMaxHp)
                     av.toonUp(newMaxHp)
                     continue
                 newCups.append(False)
             self.newCups[avId] = newCups
    def awardTrophies(self):
        stillPlaying = self.getStillPlayingAvIds()
        for avId in stillPlaying:
            av = simbase.air.doId2do.get(avId)
            if av:
                oldHistory = self.startingHistory[avId]
                endingHistory = self.endingHistory[avId]
                oldTrophies = GolfGlobals.calcTrophyListFromHistory(oldHistory)
                endingTrophies = GolfGlobals.calcTrophyListFromHistory(endingHistory)
                av.b_setGolfHistory(endingHistory)
                newTrophies = []
                for index in xrange(len(oldTrophies)):
                    if not oldTrophies[index] and endingTrophies[index]:
                        self.notify.debug('New Trophy %d' % index)
                        self.air.writeServerEvent('golf_trophy', avId, '%s' % index)
                        newTrophies.append(True)
                        self.trophyListLen = self.trophyListLen + 1
                    else:
                        newTrophies.append(False)

                self.newTrophies[avId] = newTrophies
 def awardCups(self):
     stillPlaying = self.getStillPlayingAvIds()
     for avId in stillPlaying:
         av = simbase.air.doId2do.get(avId)
         if av:
             oldHistory = self.startingHistory[avId]
             endingHistory = self.endingHistory[avId]
             oldCups = GolfGlobals.calcCupListFromHistory(oldHistory)
             endingCups = GolfGlobals.calcCupListFromHistory(endingHistory)
             newCups = []
             for index in xrange(len(oldCups)):
                 if not oldCups[index] and endingCups[index]:
                     self.notify.debug('New Trophy %d' % index)
                     newCups.append(True)
                     self.air.writeServerEvent('golf_cup', avId,
                                               '%s' % index)
                     newMaxHp = av.getMaxHp() + 1
                     av.b_setMaxHp(newMaxHp)
                     av.toonUp(newMaxHp)
                     continue
                 newCups.append(False)
             self.newCups[avId] = newCups
    def awardTrophies(self):
        stillPlaying = self.getStillPlayingAvIds()
        for avId in stillPlaying:
            av = simbase.air.doId2do.get(avId)
            if av:
                oldHistory = self.startingHistory[avId]
                endingHistory = self.endingHistory[avId]
                oldTrophies = GolfGlobals.calcTrophyListFromHistory(oldHistory)
                endingTrophies = GolfGlobals.calcTrophyListFromHistory(endingHistory)
                av.b_setGolfHistory(endingHistory)
                av.addStat(ToontownGlobals.STAT_GOLF)
                newTrophies = []
                for index in xrange(len(oldTrophies)):
                    if not oldTrophies[index] and endingTrophies[index]:
                        self.notify.debug("New Trophy %d" % index)
                        self.air.writeServerEvent("golf_trophy", avId, "%s" % index)
                        newTrophies.append(True)
                        self.trophyListLen = self.trophyListLen + 1
                    else:
                        newTrophies.append(False)

                self.newTrophies[avId] = newTrophies
Example #17
0
    def load(self):
        self.gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui')
        self.listXorigin = -0.5
        self.listFrameSizeX = 1.5
        self.listZorigin = -0.9
        self.listFrameSizeZ = 1.04
        self.arrowButtonScale = 1.3
        self.itemFrameXorigin = -0.237
        self.itemFrameZorigin = 0.365
        self.labelXstart = self.itemFrameXorigin + 0.293
        self.scrollList = DirectScrolledList(parent=self, relief=None, pos=(0, 0, 0), incButton_image=(self.gui.find('**/FndsLst_ScrollUp'),
         self.gui.find('**/FndsLst_ScrollDN'),
         self.gui.find('**/FndsLst_ScrollUp_Rllvr'),
         self.gui.find('**/FndsLst_ScrollUp')), incButton_relief=None, incButton_scale=(self.arrowButtonScale, self.arrowButtonScale, -self.arrowButtonScale), incButton_pos=(self.labelXstart, 0, self.itemFrameZorigin - 0.999), incButton_image3_color=Vec4(1, 1, 1, 0.2), decButton_image=(self.gui.find('**/FndsLst_ScrollUp'),
         self.gui.find('**/FndsLst_ScrollDN'),
         self.gui.find('**/FndsLst_ScrollUp_Rllvr'),
         self.gui.find('**/FndsLst_ScrollUp')), decButton_relief=None, decButton_scale=(self.arrowButtonScale, self.arrowButtonScale, self.arrowButtonScale), decButton_pos=(self.labelXstart, 0, self.itemFrameZorigin + 0.227), decButton_image3_color=Vec4(1, 1, 1, 0.2), itemFrame_pos=(self.itemFrameXorigin, 0, self.itemFrameZorigin), itemFrame_scale=1.0, itemFrame_relief=DGG.SUNKEN, itemFrame_frameSize=(self.listXorigin,
         self.listXorigin + self.listFrameSizeX,
         self.listZorigin,
         self.listZorigin + self.listFrameSizeZ), itemFrame_frameColor=(0.85, 0.95, 1, 1), itemFrame_borderWidth=(0.01, 0.01), numItemsVisible=12, forceHeight=0.083, items=[])
        for courseId in GolfGlobals.CourseInfo:
            courseName = GolfGlobals.getCourseName(courseId)
            frame = DirectFrame(parent=self.scrollList, relief=None)
            courseNameDisplay = DirectLabel(parent=frame, relief=None, pos=(-0.475, 0, 0.05), text=courseName, text_align=TextNode.ALeft, text_scale=0.075, text_fg=(0.85, 0.64, 0.13, 1.0), text_shadow=(0, 0, 0, 1), text_font=ToontownGlobals.getSignFont())
            bestScoreDisplay = DirectLabel(parent=frame, relief=None, pos=(0.9, 0, 0.05), text=TTLocalizer.KartRace_Unraced, text_scale=0.06, text_fg=(0.0, 0.0, 0.0, 1.0), text_font=ToontownGlobals.getToonFont())
            self.bestDisplayList.append(bestScoreDisplay)
            self.scrollList.addItem(frame)

        for holeId in GolfGlobals.HoleInfo:
            holeName = GolfGlobals.getHoleName(holeId)
            frame = DirectFrame(parent=self.scrollList, relief=None)
            holeNameDisplay = DirectLabel(parent=frame, relief=None, pos=(-0.475, 0, 0.05), text=holeName, text_align=TextNode.ALeft, text_scale=0.075, text_fg=(0.95, 0.95, 0.0, 1.0), text_shadow=(0, 0, 0, 1), text_font=ToontownGlobals.getSignFont())
            bestScoreDisplay = DirectLabel(parent=frame, relief=None, pos=(0.9, 0, 0.05), text=TTLocalizer.KartRace_Unraced, text_scale=0.06, text_fg=(0.0, 0.0, 0.0, 1.0), text_font=ToontownGlobals.getToonFont())
            self.bestDisplayList.append(bestScoreDisplay)
            self.scrollList.addItem(frame)

        return
Example #18
0
    def load(self):
        """
        Purpose: The load Method handles the construction of the specific
        UI components that make up the RaceRecordsUI object.

        Params: None
        Return: None
        """
        self.gui = loader.loadModel("phase_3.5/models/gui/friendslist_gui")

        self.listXorigin = -0.5
        self.listFrameSizeX = 1.5
        self.listZorigin = -0.9
        self.listFrameSizeZ = 1.04
        self.arrowButtonScale = 1.3
        self.itemFrameXorigin = -0.237
        self.itemFrameZorigin = 0.365
        self.labelXstart = self.itemFrameXorigin + 0.293

        self.scrollList = DirectScrolledList(
            parent=self,
            relief=None,
            pos=(0, 0, 0),
            # inc and dec are DirectButtons
            # incButton is on the bottom of page, decButton is on the top!
            incButton_image=(
                self.gui.find("**/FndsLst_ScrollUp"),
                self.gui.find("**/FndsLst_ScrollDN"),
                self.gui.find("**/FndsLst_ScrollUp_Rllvr"),
                self.gui.find("**/FndsLst_ScrollUp"),
            ),
            incButton_relief=None,
            incButton_scale=(self.arrowButtonScale, self.arrowButtonScale,
                             -self.arrowButtonScale),
            incButton_pos=(self.labelXstart, 0, self.itemFrameZorigin - 0.999),
            # Make the disabled button fade out
            incButton_image3_color=Vec4(1, 1, 1, 0.2),
            decButton_image=(
                self.gui.find("**/FndsLst_ScrollUp"),
                self.gui.find("**/FndsLst_ScrollDN"),
                self.gui.find("**/FndsLst_ScrollUp_Rllvr"),
                self.gui.find("**/FndsLst_ScrollUp"),
            ),
            decButton_relief=None,
            decButton_scale=(self.arrowButtonScale, self.arrowButtonScale,
                             self.arrowButtonScale),
            decButton_pos=(self.labelXstart, 0, self.itemFrameZorigin + 0.227),
            # Make the disabled button fade out
            decButton_image3_color=Vec4(1, 1, 1, 0.2),

            # itemFrame is a DirectFrame
            itemFrame_pos=(self.itemFrameXorigin, 0, self.itemFrameZorigin),
            itemFrame_scale=1.0,
            itemFrame_relief=DGG.SUNKEN,
            # frameSize is (minX,maxX,minZ,maxZ);  where x goes left->right neg->pos,
            # and z goes bottom->top neg->pos
            itemFrame_frameSize=(self.listXorigin,
                                 self.listXorigin + self.listFrameSizeX,
                                 self.listZorigin,
                                 self.listZorigin + self.listFrameSizeZ),
            itemFrame_frameColor=(0.85, 0.95, 1, 1),
            itemFrame_borderWidth=(0.01, 0.01),
            # each item is a button with text on it
            numItemsVisible=12,
            # need to set height of each entry to avoid list text running off end of listbox
            forceHeight=0.083,
            items=[],
        )

        # course bests
        for courseId in GolfGlobals.CourseInfo:
            courseName = GolfGlobals.getCourseName(courseId)
            frame = DirectFrame(parent=self.scrollList, relief=None)
            courseNameDisplay = DirectLabel(
                parent=frame,
                relief=None,
                pos=(-0.475, 0, 0.05),
                text=courseName,
                text_align=TextNode.ALeft,
                text_scale=0.075,
                text_fg=(0.85, 0.64, 0.13, 1.0),
                text_shadow=(0, 0, 0, 1),
                text_font=ToontownGlobals.getSignFont())
            bestScoreDisplay = DirectLabel(
                parent=frame,
                relief=None,
                pos=(0.9, 0, 0.05),
                text=TTLocalizer.KartRace_Unraced,
                text_scale=0.06,
                text_fg=(0.0, 0.0, 0.0, 1.0),
                text_font=ToontownGlobals.getToonFont())
            # save this one for updating
            self.bestDisplayList.append(bestScoreDisplay)
            # add to scrolled list
            self.scrollList.addItem(frame)

        # hole bests
        for holeId in GolfGlobals.HoleInfo:
            holeName = GolfGlobals.getHoleName(holeId)
            frame = DirectFrame(parent=self.scrollList, relief=None)
            holeNameDisplay = DirectLabel(
                parent=frame,
                relief=None,
                pos=(-0.475, 0, 0.05),
                text=holeName,
                text_align=TextNode.ALeft,
                text_scale=0.075,
                text_fg=(0.95, 0.95, 0.0, 1.0),
                text_shadow=(0, 0, 0, 1),
                text_font=ToontownGlobals.getSignFont())
            bestScoreDisplay = DirectLabel(
                parent=frame,
                relief=None,
                pos=(0.9, 0, 0.05),
                text=TTLocalizer.KartRace_Unraced,
                text_scale=0.06,
                text_fg=(0.0, 0.0, 0.0, 1.0),
                text_font=ToontownGlobals.getToonFont())
            # save this one for updating
            self.bestDisplayList.append(bestScoreDisplay)
            # add to scrolled list
            self.scrollList.addItem(frame)
Example #19
0
 def getTitle(self):
     return GolfGlobals.getCourseName(self.courseId)
Example #20
0
 def getTitle(self):
     return GolfGlobals.getCourseName(self.courseId)
Example #21
0
    def showBoard(self, task=None):

        scoreDict = self.golfCourse.scores
        x = 0

        currentGolfer = self.golfCourse.getCurGolfer()
        for playaIndex in range(self.numPlayas):
            if self.golfCourse.isGameDone():
                self.playaTags[playaIndex].setColor(0, 0, 0, 1)
            else:
                if (currentGolfer == self.golfCourse.avIdList[playaIndex]):
                    # self.playaTags[playaIndex].setColor(1,0,0,1)
                    self.highlightCur.setColor(
                        *GolfGlobals.PlayerColors[playaIndex])
                    self.highlightCur.setAlphaScale(0.4)
                    self.highlightCur.setPos(
                        -0.003, 0,
                        0.038 - (playaIndex * (self.lineVertOffset + 0.005)))
                    self.highlightCur.show()

                else:
                    self.playaTags[playaIndex].setColor(0, 0, 0, 1)

        for avId in self.avIdList:
            holeIndex = 0
            totScore = 0
            playerExited = False

            for y in range(len(self.golfCourse.exitedAvIdList)):
                if (self.golfCourse.exitedAvIdList[y] == avId):
                    self.playaTags[x].setColor(0.7, 0.7, 0.7, 1)
                    holeIndex = 0
                    for holeIndex in range(self.golfCourse.numHoles):
                        self.getScoreLabel(self.avIdList[x],
                                           holeIndex).setColor(
                                               0.7, 0.7, 0.7, 1)
                    self.totalTags[x].setColor(0.7, 0.7, 0.7, 1)
                    playerExited = True

            if playerExited == False:
                for holeIndex in range(self.golfCourse.numHoles):
                    if (holeIndex <= self.golfCourse.curHoleIndex):
                        self.getScoreLabel(
                            avId,
                            holeIndex)['text'] = ("%s" %
                                                  (scoreDict[avId][holeIndex]))
                        totScore = totScore + scoreDict[avId][holeIndex]
                        if self.golfCourse.isGameDone() == False:
                            if (holeIndex == self.golfCourse.curHoleIndex):
                                self.getScoreLabel(avId, holeIndex).setColor(
                                    1, 0, 0, 1)
                                self.holeLabels[holeIndex].setColor(1, 0, 0, 1)
                                self.parLabels[holeIndex].setColor(1, 0, 0, 1)
                                title = GolfGlobals.getCourseName(
                                    self.golfCourse.courseId
                                ) + ' - ' + GolfGlobals.getHoleName(
                                    self.golfCourse.holeIds[
                                        self.golfCourse.curHoleIndex])
                                # title = TTLocalizer.GolfCourseName[self.golfCourse.courseId] + ' - ' + TTLocalizer.GolfHoleNames[holeIndex]
                                self.titleLabel['text'] = title
                            else:
                                self.getScoreLabel(avId, holeIndex).setColor(
                                    0, 0, 0, 1)
                                self.holeLabels[holeIndex].setColor(0, 0, 0, 1)
                                self.parLabels[holeIndex].setColor(0, 0, 0, 1)

                self.totalTags[x]['text'] = ("%s" % totScore)

            if (self.golfCourse.isGameDone()):
                self.getScoreLabel(avId,
                                   self.golfCourse.numHoles - 1).setColor(
                                       0, 0, 0, 1)
                self.totalTags[x].setColor(1, 0, 0, 1)

            x = x + 1

        y = 0

        # Check if any players have dropped out
        #for y in range(len(self.golfCourse.exitedAvIdList)):
        #    z = 0
        #    for z in range(len(self.avIdList)):
        #        if( self.golfCourse.exitedAvIdList[y] == self.avIdList[z]):
        #            self.playaTags[z].setColor(0.7, 0.7, 0.7, 1)
        #            holeIndex = 0
        #            for holeIndex in range(self.golfCourse.numHoles):
        #                self.getScoreLabel(self.avIdList[z], holeIndex).setColor(0.7, 0.7, 0.7 ,1)
        #            self.totalTags[z].setColor(0.7, 0.7, 0.7, 1)

        if (self.golfCourse.isGameDone()):
            self.parLabels[self.golfCourse.numHoles - 1].setColor(0, 0, 0, 1)
            self.holeLabels[self.golfCourse.numHoles - 1].setColor(0, 0, 0, 1)
            self.parLabels[self.golfCourse.numHoles].setColor(1, 0, 0, 1)
            self.totalLabel.setColor(1, 0, 0, 1)

        self.scoreboard.show()
        self.maximizeB.hide()
    def setup(self):
        self.scoreboard = DirectFrame(parent=aspect2d, relief=None, geom=DGG.getDefaultDialogGeom(), geom_color=ToontownGlobals.GlobalDialogColor, geom_scale=(1.9, 1, 1.05), pos=(0, 0, 0.375))
        self.lines = LineSegs()
        self.lines.setColor(0, 0, 0, 1)
        self.lines.setThickness(2)
        guiModel = loader.loadModel('phase_6/models/golf/golf_gui')
        highlight = loader.loadModel('phase_6/models/golf/headPanel')
        self.maximizeB = DirectButton(parent=base.a2dBottomRight, pos=(-0.15, 0, 0.15), relief=None, state=DGG.NORMAL, image=(guiModel.find('**/score_card_icon'), guiModel.find('**/score_card_icon_rollover'), guiModel.find('**/score_card_icon_rollover')), image_scale=(0.2, 1, 0.2), command=self.showBoard)
        self.vertOffset = 0.13
        self.playaTop = 0.12
        horzOffset = 0.12
        holeTop = 0.3
        self.vCenter = 0.025
        totScore = 0
        totPar = 0
        self.lineVStart = -0.465
        self.lineHStart = 0.17
        self.lineHorOffset = 0.13
        self.lineVertOffset = 0.125
        self.lineVCenter = 0.025
        buttons = loader.loadModel('phase_3/models/gui/dialog_box_buttons_gui')
        self.minimizeB = DirectButton(parent=self.scoreboard, pos=(0, 0, self.lineHStart - 0.59), relief=None, state=DGG.NORMAL, image=(buttons.find('**/CloseBtn_UP'), buttons.find('**/CloseBtn_DN'), buttons.find('**/CloseBtn_Rllvr')), image_scale=(1, 1, 1), command=self.hideBoard, extraArgs=[None])
        self.exitCourseB = DirectButton(parent=self.scoreboard, pos=(0, 0, self.lineHStart - 0.59), relief=None, state=DGG.NORMAL, image=(buttons.find('**/CloseBtn_UP'), buttons.find('**/CloseBtn_DN'), buttons.find('**/CloseBtn_Rllvr')), image_scale=(1, 1, 1), text=TTLocalizer.GolfExitCourse, text_scale=0.04, text_pos=TTLocalizer.GSBexitCourseBPos, command=self.exitCourse)
        self.exitCourseB.hide()
        self.highlightCur = DirectLabel(parent=self.scoreboard, relief=None, pos=(-0.003, 0, 0.038), image=highlight, image_scale=(1.82, 1, 0.135))
        self.titleBar = DirectLabel(parent=self.scoreboard, relief=None, pos=(-0.003, 0, 0.166), color=(0.7, 0.7, 0.7, 0.3), image=highlight, image_scale=(1.82, 1, 0.195))
        self.titleBar.show()
        self.highlightCur.show()
        buttons.removeNode()
        guiModel.removeNode()
        title = GolfGlobals.getCourseName(self.golfCourse.courseId) + ' - ' + GolfGlobals.getHoleName(self.golfCourse.holeIds[self.golfCourse.curHoleIndex])
        self.titleLabel = DirectLabel(parent=self.scoreboard, relief=None, pos=(0, 0, holeTop + 0.1), text_align=TextNode.ACenter, text=title, text_scale=TTLocalizer.GSBtitleLabel, text_font=ToontownGlobals.getSignFont(), text_fg=(0, 0.5, 0.125, 1))
        self.playaLabel = DirectLabel(parent=self.scoreboard, relief=None, pos=(self.lineVStart - 0.23, 0, holeTop), text_align=TextNode.ACenter, text=TTLocalizer.GolfHole, text_font=ToontownGlobals.getMinnieFont(), text_scale=0.05)
        for holeLIndex in xrange(self.golfCourse.numHoles):
            holeLabel = DirectLabel(parent=self.scoreboard, relief=None, pos=(self.lineVStart + 0.055 + horzOffset * holeLIndex, 0, holeTop), text_align=TextNode.ACenter, text='%s' % (holeLIndex + 1), text_scale=0.05)
            self.holeLabels.append(holeLabel)

        self.totalLabel = DirectLabel(parent=self.scoreboard, relief=None, pos=(self.lineVStart + 0.1 + horzOffset * 9.5, 0, holeTop), text_align=TextNode.ACenter, text=TTLocalizer.GolfTotal, text_font=ToontownGlobals.getMinnieFont(), text_scale=0.05)
        self.parTitleLabel = DirectLabel(parent=self.scoreboard, relief=None, pos=(self.lineVStart - 0.23, 0, holeTop - 0.1), text_align=TextNode.ACenter, text=TTLocalizer.GolfPar, text_font=ToontownGlobals.getMinnieFont(), text_scale=0.05)
        for parHoleIndex in xrange(self.golfCourse.numHoles):
            parLabel = DirectLabel(parent=self.scoreboard, relief=None, pos=(self.lineVStart + 0.055 + horzOffset * parHoleIndex, 0, holeTop - 0.1), text_align=TextNode.ACenter, text='%s' % GolfGlobals.HoleInfo[self.golfCourse.holeIds[parHoleIndex]]['par'], text_scale=0.05, text_wordwrap=10)
            totPar = totPar + GolfGlobals.HoleInfo[self.golfCourse.holeIds[parHoleIndex]]['par']
            self.parLabels.append(parLabel)

        parLabel = DirectLabel(parent=self.scoreboard, relief=None, pos=(self.lineVStart + 0.1 + horzOffset * 9.5, 0, holeTop - 0.1), text_align=TextNode.ACenter, text='%s' % totPar, text_scale=0.05, text_wordwrap=10)
        self.parLabels.append(parLabel)
        vert = 0.0
        self.numPlayas = len(self.golfCourse.avIdList)
        for playaIndex in xrange(self.numPlayas):
            name = TTLocalizer.GolfUnknownPlayer
            av = base.cr.doId2do.get(self.golfCourse.avIdList[playaIndex])
            if av:
                name = av.getName()
            playaLabel = DirectLabel(parent=self.scoreboard, relief=None, text_align=TextNode.ACenter, text=name, text_scale=0.05, text_wordwrap=9)
            self.playaTags.append(playaLabel)
            textN = playaLabel.component(playaLabel.components()[0])
            if type(textN) == OnscreenText:
                try:
                    if textN.textNode.getWordwrappedWtext() != name:
                        vert = self.playaTop - self.vertOffset * playaIndex
                    else:
                        vert = self.playaTop - self.vertOffset * playaIndex - self.vCenter
                except:
                    vert = self.playaTop - self.vertOffset * playaIndex

            self.playaTags[playaIndex].setPos(self.lineVStart - 0.23, 0, vert)
            self.notify.debug('self.text height = %f' % self.playaTags[playaIndex].getHeight())
            holeIndex = 0
            for holeIndex in xrange(self.golfCourse.numHoles):
                holeLabel = DirectLabel(parent=self.scoreboard, relief=None, pos=(self.lineVStart + 0.055 + horzOffset * holeIndex, 0, self.playaTop - self.vertOffset * playaIndex - self.vCenter), text_align=TextNode.ACenter, text='-', text_scale=0.05, text_wordwrap=10)
                self.scoreTags.append(holeLabel)

            holeLabel = DirectLabel(parent=self.scoreboard, relief=None, pos=(self.lineVStart + 0.1 + horzOffset * 9.5, 0, self.playaTop - self.vertOffset * playaIndex - self.vCenter), text_align=TextNode.ACenter, text='-', text_scale=0.05, text_wordwrap=10)
            self.totalTags.append(holeLabel)

        self.lines.moveTo(self.lineVStart - 0.45, 0, self.lineHStart + 0.19)
        self.lines.drawTo(self.lineVStart + 11 * self.lineVertOffset, 0, self.lineHStart + 0.19)
        self.lines.moveTo(self.lineVStart - 0.45, 0, self.lineHStart + 0.09)
        self.lines.drawTo(self.lineVStart + 11 * self.lineVertOffset, 0, self.lineHStart + 0.09)
        self.lines.moveTo(self.lineVStart - 0.45, 0, self.lineHStart)
        self.lines.drawTo(self.lineVStart + 11 * self.lineVertOffset, 0, self.lineHStart)
        self.lines.moveTo(self.lineVStart - 0.45, 0, self.lineHStart + 0.19)
        self.lines.drawTo(self.lineVStart - 0.45, 0, self.lineHStart - 4 * 0.13)
        self.lines.moveTo(self.lineVStart, 0, self.lineHStart + 0.19)
        self.lines.drawTo(self.lineVStart, 0, self.lineHStart - 4 * 0.13)
        for x in xrange(4):
            self.lines.moveTo(self.lineVStart - 0.45, 0, self.lineHStart - (x + 1) * self.lineHorOffset)
            self.lines.drawTo(self.lineVStart + 11 * self.lineVertOffset + 0.005, 0, self.lineHStart - (x + 1) * self.lineHorOffset)

        for y in xrange(10):
            self.lines.moveTo(self.lineVStart + y * self.lineVertOffset, 0, self.lineHStart + 0.19)
            self.lines.drawTo(self.lineVStart + y * self.lineVertOffset, 0, self.lineHStart - 4 * 0.13)

        self.lines.moveTo(self.lineVStart + 11 * self.lineVertOffset, 0, self.lineHStart + 0.19)
        self.lines.drawTo(self.lineVStart + 11 * self.lineVertOffset, 0, self.lineHStart - 4 * 0.13)
        self.scoreboard.attachNewNode(self.lines.create())
        self.hide()
        return
    def setup(self):
        self.scoreboard = DirectFrame(
            parent=aspect2d,
            relief=None,
            geom=DGG.getDefaultDialogGeom(),
            geom_color=ToontownGlobals.GlobalDialogColor,
            geom_scale=(1.9, 1, 1.05),
            pos=(0, 0, 0.375))
        self.lines = LineSegs()
        self.lines.setColor(0, 0, 0, 1)
        self.lines.setThickness(2)
        guiModel = loader.loadModel('phase_6/models/golf/golf_gui')
        highlight = loader.loadModel('phase_6/models/golf/headPanel')
        self.maximizeB = DirectButton(
            parent=base.a2dBottomRight,
            pos=(-0.15, 0, 0.15),
            relief=None,
            state=DGG.NORMAL,
            image=(guiModel.find('**/score_card_icon'),
                   guiModel.find('**/score_card_icon_rollover'),
                   guiModel.find('**/score_card_icon_rollover')),
            image_scale=(0.2, 1, 0.2),
            command=self.showBoard)
        self.vertOffset = 0.13
        self.playaTop = 0.12
        horzOffset = 0.12
        holeTop = 0.3
        self.vCenter = 0.025
        totScore = 0
        totPar = 0
        self.lineVStart = -0.465
        self.lineHStart = 0.17
        self.lineHorOffset = 0.13
        self.lineVertOffset = 0.125
        self.lineVCenter = 0.025
        buttons = loader.loadModel('phase_3/models/gui/dialog_box_buttons_gui')
        self.minimizeB = DirectButton(
            parent=self.scoreboard,
            pos=(0, 0, self.lineHStart - 0.59),
            relief=None,
            state=DGG.NORMAL,
            image=(buttons.find('**/CloseBtn_UP'),
                   buttons.find('**/CloseBtn_DN'),
                   buttons.find('**/CloseBtn_Rllvr')),
            image_scale=(1, 1, 1),
            command=self.hideBoard,
            extraArgs=[None])
        self.exitCourseB = DirectButton(
            parent=self.scoreboard,
            pos=(0, 0, self.lineHStart - 0.59),
            relief=None,
            state=DGG.NORMAL,
            image=(buttons.find('**/CloseBtn_UP'),
                   buttons.find('**/CloseBtn_DN'),
                   buttons.find('**/CloseBtn_Rllvr')),
            image_scale=(1, 1, 1),
            text=TTLocalizer.GolfExitCourse,
            text_scale=0.04,
            text_pos=TTLocalizer.GSBexitCourseBPos,
            command=self.exitCourse)
        self.exitCourseB.hide()
        self.highlightCur = DirectLabel(parent=self.scoreboard,
                                        relief=None,
                                        pos=(-0.003, 0, 0.038),
                                        image=highlight,
                                        image_scale=(1.82, 1, 0.135))
        self.titleBar = DirectLabel(parent=self.scoreboard,
                                    relief=None,
                                    pos=(-0.003, 0, 0.166),
                                    color=(0.7, 0.7, 0.7, 0.3),
                                    image=highlight,
                                    image_scale=(1.82, 1, 0.195))
        self.titleBar.show()
        self.highlightCur.show()
        buttons.removeNode()
        guiModel.removeNode()
        title = GolfGlobals.getCourseName(
            self.golfCourse.courseId) + ' - ' + GolfGlobals.getHoleName(
                self.golfCourse.holeIds[self.golfCourse.curHoleIndex])
        self.titleLabel = DirectLabel(parent=self.scoreboard,
                                      relief=None,
                                      pos=(0, 0, holeTop + 0.1),
                                      text_align=TextNode.ACenter,
                                      text=title,
                                      text_scale=TTLocalizer.GSBtitleLabel,
                                      text_font=ToontownGlobals.getSignFont(),
                                      text_fg=(0, 0.5, 0.125, 1))
        self.playaLabel = DirectLabel(
            parent=self.scoreboard,
            relief=None,
            pos=(self.lineVStart - 0.23, 0, holeTop),
            text_align=TextNode.ACenter,
            text=TTLocalizer.GolfHole,
            text_font=ToontownGlobals.getMinnieFont(),
            text_scale=0.05)
        for holeLIndex in xrange(self.golfCourse.numHoles):
            holeLabel = DirectLabel(parent=self.scoreboard,
                                    relief=None,
                                    pos=(self.lineVStart + 0.055 +
                                         horzOffset * holeLIndex, 0, holeTop),
                                    text_align=TextNode.ACenter,
                                    text='%s' % (holeLIndex + 1),
                                    text_scale=0.05)
            self.holeLabels.append(holeLabel)

        self.totalLabel = DirectLabel(
            parent=self.scoreboard,
            relief=None,
            pos=(self.lineVStart + 0.1 + horzOffset * 9.5, 0, holeTop),
            text_align=TextNode.ACenter,
            text=TTLocalizer.GolfTotal,
            text_font=ToontownGlobals.getMinnieFont(),
            text_scale=0.05)
        self.parTitleLabel = DirectLabel(
            parent=self.scoreboard,
            relief=None,
            pos=(self.lineVStart - 0.23, 0, holeTop - 0.1),
            text_align=TextNode.ACenter,
            text=TTLocalizer.GolfPar,
            text_font=ToontownGlobals.getMinnieFont(),
            text_scale=0.05)
        for parHoleIndex in xrange(self.golfCourse.numHoles):
            parLabel = DirectLabel(
                parent=self.scoreboard,
                relief=None,
                pos=(self.lineVStart + 0.055 + horzOffset * parHoleIndex, 0,
                     holeTop - 0.1),
                text_align=TextNode.ACenter,
                text='%s' % GolfGlobals.HoleInfo[
                    self.golfCourse.holeIds[parHoleIndex]]['par'],
                text_scale=0.05,
                text_wordwrap=10)
            totPar = totPar + GolfGlobals.HoleInfo[
                self.golfCourse.holeIds[parHoleIndex]]['par']
            self.parLabels.append(parLabel)

        parLabel = DirectLabel(parent=self.scoreboard,
                               relief=None,
                               pos=(self.lineVStart + 0.1 + horzOffset * 9.5,
                                    0, holeTop - 0.1),
                               text_align=TextNode.ACenter,
                               text='%s' % totPar,
                               text_scale=0.05,
                               text_wordwrap=10)
        self.parLabels.append(parLabel)
        vert = 0.0
        self.numPlayas = len(self.golfCourse.avIdList)
        for playaIndex in xrange(self.numPlayas):
            name = TTLocalizer.GolfUnknownPlayer
            av = base.cr.doId2do.get(self.golfCourse.avIdList[playaIndex])
            if av:
                name = av.getName()
            playaLabel = DirectLabel(parent=self.scoreboard,
                                     relief=None,
                                     text_align=TextNode.ACenter,
                                     text=name,
                                     text_scale=0.05,
                                     text_wordwrap=9)
            self.playaTags.append(playaLabel)
            textN = playaLabel.component(playaLabel.components()[0])
            if type(textN) == OnscreenText:
                try:
                    if textN.textNode.getWordwrappedWtext() != name:
                        vert = self.playaTop - self.vertOffset * playaIndex
                    else:
                        vert = self.playaTop - self.vertOffset * playaIndex - self.vCenter
                except:
                    vert = self.playaTop - self.vertOffset * playaIndex

            self.playaTags[playaIndex].setPos(self.lineVStart - 0.23, 0, vert)
            self.notify.debug('self.text height = %f' %
                              self.playaTags[playaIndex].getHeight())
            holeIndex = 0
            for holeIndex in xrange(self.golfCourse.numHoles):
                holeLabel = DirectLabel(
                    parent=self.scoreboard,
                    relief=None,
                    pos=(self.lineVStart + 0.055 + horzOffset * holeIndex, 0,
                         self.playaTop - self.vertOffset * playaIndex -
                         self.vCenter),
                    text_align=TextNode.ACenter,
                    text='-',
                    text_scale=0.05,
                    text_wordwrap=10)
                self.scoreTags.append(holeLabel)

            holeLabel = DirectLabel(
                parent=self.scoreboard,
                relief=None,
                pos=(self.lineVStart + 0.1 + horzOffset * 9.5, 0,
                     self.playaTop - self.vertOffset * playaIndex -
                     self.vCenter),
                text_align=TextNode.ACenter,
                text='-',
                text_scale=0.05,
                text_wordwrap=10)
            self.totalTags.append(holeLabel)

        self.lines.moveTo(self.lineVStart - 0.45, 0, self.lineHStart + 0.19)
        self.lines.drawTo(self.lineVStart + 11 * self.lineVertOffset, 0,
                          self.lineHStart + 0.19)
        self.lines.moveTo(self.lineVStart - 0.45, 0, self.lineHStart + 0.09)
        self.lines.drawTo(self.lineVStart + 11 * self.lineVertOffset, 0,
                          self.lineHStart + 0.09)
        self.lines.moveTo(self.lineVStart - 0.45, 0, self.lineHStart)
        self.lines.drawTo(self.lineVStart + 11 * self.lineVertOffset, 0,
                          self.lineHStart)
        self.lines.moveTo(self.lineVStart - 0.45, 0, self.lineHStart + 0.19)
        self.lines.drawTo(self.lineVStart - 0.45, 0,
                          self.lineHStart - 4 * 0.13)
        self.lines.moveTo(self.lineVStart, 0, self.lineHStart + 0.19)
        self.lines.drawTo(self.lineVStart, 0, self.lineHStart - 4 * 0.13)
        for x in xrange(4):
            self.lines.moveTo(self.lineVStart - 0.45, 0,
                              self.lineHStart - (x + 1) * self.lineHorOffset)
            self.lines.drawTo(
                self.lineVStart + 11 * self.lineVertOffset + 0.005, 0,
                self.lineHStart - (x + 1) * self.lineHorOffset)

        for y in xrange(10):
            self.lines.moveTo(self.lineVStart + y * self.lineVertOffset, 0,
                              self.lineHStart + 0.19)
            self.lines.drawTo(self.lineVStart + y * self.lineVertOffset, 0,
                              self.lineHStart - 4 * 0.13)

        self.lines.moveTo(self.lineVStart + 11 * self.lineVertOffset, 0,
                          self.lineHStart + 0.19)
        self.lines.drawTo(self.lineVStart + 11 * self.lineVertOffset, 0,
                          self.lineHStart - 4 * 0.13)
        self.scoreboard.attachNewNode(self.lines.create())
        self.hide()
        return
Example #24
0
 def getTitle(self):
     """
     Return the title of the minigame.
     Subclasses should redefine.
     """
     return GolfGlobals.getCourseName(self.courseId)