Example #1
0
class GroupTrackerPage(ShtikerPage.ShtikerPage):
    notify = directNotify.newCategory('GroupTrackerPage')

    def __init__(self):
        ShtikerPage.ShtikerPage.__init__(self)
        self.groupWidgets = []
        self.playerWidgets = []
        self.images = []  # image nodes: Possible images to apply on groups
        self.scrollList = None  # DirectScrolledList: Holds the GroupTrackerGroup widgets
        self.scrollTitle = None  # DirectLabel: Title of the list that holds the groups
        self.playerList = None  # DirectScrolledList: Holds players when showing a specific group details
        self.playerListTitle = None  # DirectLabel: Title of the playerList
        self.groupInfoTitle = None  # DirectLabel: holds the group detail title to show on the right
        self.groupInfoDistrict = None  # DirectLabel: shows group detail district on the right
        self.statusMessage = None  # DirectLabel: Shows important messages like Loading... or "No boarding groups available"
        self.groupIcon = None  # DirectButton: Icon to associate with the group ex. sellbot icon or cashbot icon depending on group info
        self.wantGroupToggle = None  # DirectButton: Allows the toon to toggle his listing

    def load(self):
        self.listXorigin = -0.02
        self.listFrameSizeX = 0.67
        self.listZorigin = -0.96
        self.listFrameSizeZ = 1.04
        self.arrowButtonScale = 1.3
        self.itemFrameXorigin = -0.237
        self.itemFrameZorigin = 0.365
        self.buttonXstart = self.itemFrameXorigin + 0.293
        self.gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui')
        guiButton = loader.loadModel('phase_3/models/gui/quit_button')
        self.scrollList = DirectScrolledList(
            parent=self,
            relief=None,
            pos=(-0.5, 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.buttonXstart, 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.buttonXstart, 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=15,
            forceHeight=0.065,
            items=self.groupWidgets)

        self.scrollTitle = DirectFrame(parent=self.scrollList,
                                       text=TTLocalizer.GroupTrackerListTitle,
                                       text_scale=0.06,
                                       text_align=TextNode.ACenter,
                                       relief=None,
                                       pos=(self.buttonXstart, 0,
                                            self.itemFrameZorigin + 0.127))

        self.playerList = DirectScrolledList(
            parent=self,
            relief=None,
            pos=(0.45, 0, 0.1),
            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=(1.0, 1.0, -1.0),
            incButton_pos=(0, 0, -0.28),
            incButton_image3_color=Vec4(1, 1, 1, 0.05),
            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=(1.0, 1.0, 1.0),
            decButton_pos=(0.0, 0, 0.04),
            decButton_image3_color=Vec4(1, 1, 1, 0.25),
            itemFrame_pos=(0, 0, -0.05),
            itemFrame_scale=1.0,
            itemFrame_relief=DGG.SUNKEN,
            itemFrame_frameSize=(
                -0.3,
                0.3,  #x
                -0.2,
                0.06),  #z
            itemFrame_frameColor=(0.85, 0.95, 1, 1),
            itemFrame_borderWidth=(0.01, 0.01),
            numItemsVisible=4,
            forceHeight=0.05,
            items=self.playerWidgets)

        self.playerListTitle = DirectFrame(parent=self.playerList,
                                           text='',
                                           text_scale=0.05,
                                           text_align=TextNode.ACenter,
                                           relief=None,
                                           pos=(0, 0, 0.08))
        self.groupInfoTitle = DirectLabel(parent=self,
                                          text='',
                                          text_scale=0.080,
                                          text_align=TextNode.ACenter,
                                          text_wordwrap=15,
                                          relief=None,
                                          pos=(0.45, 0, 0.5))
        self.groupInfoDistrict = DirectLabel(parent=self,
                                             text='',
                                             text_scale=0.050,
                                             text_align=TextNode.ACenter,
                                             text_wordwrap=15,
                                             relief=None,
                                             pos=(0.45, 0, 0.4))

        self.statusMessage = DirectLabel(parent=self,
                                         text='',
                                         text_scale=0.060,
                                         text_align=TextNode.ACenter,
                                         text_wordwrap=5,
                                         relief=None,
                                         pos=(0.45, 0, 0.1))

        # Group Image:
        self.groupIcon = DirectButton(parent=self,
                                      relief=None,
                                      state=DGG.DISABLED,
                                      image=None,
                                      image_scale=(0.35, 1, 0.35),
                                      image_color=Vec4(1.0, 1.0, 1.0, 0.75),
                                      pos=(0.45, 10, -0.45),
                                      command=self.doNothing)

        # Group Toggle:
        self.wantGroupToggle = DirectButton(
            parent=self,
            relief=None,
            image=(guiButton.find('**/QuitBtn_UP'),
                   guiButton.find('**/QuitBtn_DN'),
                   guiButton.find('**/QuitBtn_RLVR')),
            image_scale=(0.7, 1, 1),
            text='',
            text_scale=0.052,
            text_pos=(0, -0.02),
            pos=(0.2, 0, -0.65),
            command=self.toggleWantGroup)
        self.updateWantGroupButton()

        # Loading possible group icons
        suitIcons = loader.loadModel('phase_3/models/gui/cog_icons')
        bossbotIcon = suitIcons.find('**/CorpIcon')
        bossbotIcon.setColor(SUIT_ICON_COLORS[0])
        self.images.append(bossbotIcon)

        lawbotIcon = suitIcons.find('**/LegalIcon')
        lawbotIcon.setColor(SUIT_ICON_COLORS[1])
        self.images.append(lawbotIcon)

        cashbotIcon = suitIcons.find('**/MoneyIcon')
        cashbotIcon.setColor(SUIT_ICON_COLORS[2])
        self.images.append(cashbotIcon)

        sellbotIcon = suitIcons.find('**/SalesIcon')
        sellbotIcon.setColor(SUIT_ICON_COLORS[3])
        self.images.append(sellbotIcon)

        # Clean up
        self.clearGroupInfo()
        self.statusMessage.hide()

        suitIcons.removeNode()
        self.gui.removeNode()
        guiButton.removeNode()

        self.accept('GroupTrackerResponse', self.updatePage)

    def unload(self):
        self.scrollList.destroy()
        self.groupInfoDistrict.destroy()
        self.playerList.destroy()
        self.groupInfoTitle.destroy()
        self.groupIcon.destroy()
        self.wantGroupToggle.destroy()
        for widget in self.playerWidgets:
            widget.destroy()
        for widget in self.groupWidgets:
            widget.destroy()
        self.playerWidgets = []

        del self.scrollList
        del self.groupInfoDistrict
        del self.playerList
        del self.groupInfoTitle
        del self.groupIcon
        del self.wantGroupToggle
        ShtikerPage.ShtikerPage.unload(self)

    def enter(self):
        ShtikerPage.ShtikerPage.enter(self)
        self.setGroups([])  # CLEAR IT ALL
        self.setPlayers()  # CLEAR IT ALL
        if (self.scrollList['items'] == []):
            self.statusMessage['text'] = TTLocalizer.GroupTrackerLoading
            self.statusMessage.show()
        base.cr.globalGroupTracker.requestGroups()
        taskMgr.doMethodLater(3, self.displayNoGroupsTaskHandler,
                              self.uniqueName('timeout'))

    def displayNoGroups(self):
        self.statusMessage['text'] = TTLocalizer.GroupTrackerEmpty
        self.statusMessage.show()
        self.clearGroupInfo()

    def displayNoGroupsTaskHandler(self, task):
        self.displayNoGroups()
        return task.done

    def updatePage(self):
        taskMgr.remove(self.uniqueName('timeout'))
        groups = base.cr.globalGroupTracker.getGroupInfo()
        self.setGroups(groups)

    def exit(self):
        self.clearGroupInfo()
        ShtikerPage.ShtikerPage.exit(self)
        base.cr.globalGroupTracker.doneRequesting()

    def updateGroupInfoEventHandle(self, groupWidget, mouseEvent):
        self.updateGroupInfo(groupWidget)

    def updateGroupInfo(self, groupWidget):
        ''' Updates the Right Page of the Group Tracker Page with new Info '''
        self.statusMessage.hide()

        # Update the Player List
        self.setPlayers(groupWidget)
        self.playerList.show()

        # Update the Player List Title
        self.playerListTitle['text'] = ('Players ' +
                                        str(groupWidget.getCurrentPlayers()) +
                                        '/' +
                                        str(groupWidget.getMaxPlayers()) + ':')
        self.playerListTitle.show()

        # Update the District
        self.groupInfoDistrict[
            'text'] = TTLocalizer.BoardingGroupDistrictInformation % {
                'district': groupWidget.getDistrict()
            }
        self.groupInfoDistrict.show()

        # Update the Title
        self.groupInfoTitle['text'] = groupWidget.getTitle()
        self.groupInfoTitle.show()

        # Update the Image
        self.groupIcon['image'] = self.images[
            GroupTrackerGlobals.CATEGORY_TO_IMAGE_ID[
                groupWidget.getCategory()]]
        self.groupIcon['image_scale'] = (0.35, 1, 0.35)
        self.groupIcon.show()

    def clearGroupInfo(self):
        self.playerList.hide()
        self.playerListTitle.hide()
        self.groupInfoDistrict.hide()
        self.groupInfoTitle.hide()
        self.groupIcon.hide()

    def setPlayers(self, groupWidget=None):
        ''' Calls updatePlayerList '''

        # Clear the Widgets that were held in the listings
        for playerWidget in self.playerWidgets:
            playerWidget.destroy()
        self.playerWidgets = []

        # Make a player widget for each player
        # TODO: Edit this stuff when avIds come from players
        if groupWidget:
            leaderId = groupWidget.getLeaderId()
            playerNames = groupWidget.getMemberNames()
            playerIds = groupWidget.getMemberIds()
            for playerName in playerNames:
                playerId = playerIds[playerNames.index(playerName)]
                isLeader = playerId == leaderId
                self.playerWidgets.append(
                    GroupTrackerPlayer(parent=self,
                                       avId=playerId,
                                       name=playerName,
                                       isLeader=isLeader))

        self.updatePlayerList()

    def reconsiderGroupInfo(self, groupWidget):
        ''' If someone is viewing this info and it was updated, we also want to update the info being viewed '''
        if self.playerWidgets is None or self.playerList['items'] == []:
            return  # No Info is being viewed at the moment since you cant have an empty group

        # We have to update if this group's leader is the leader in the playerlist being viewed right now
        leaderId = groupWidget.getLeaderId()

        # Check all the players in the playerList being viewed for the same leader
        for playerWidget in self.playerWidgets:
            if playerWidget.getLeader():
                if leaderId == playerWidget.getId():
                    self.updateGroupInfo(groupWidget)
                    return False

        return True

    def setGroups(self, groups):
        ''' Calls updateGroupList '''

        # Clear our Group Widgets
        for group in self.groupWidgets:
            group.destroy()
        self.groupWidgets = []

        wantReconsiderInfo = True

        # Create a new group widget for each group
        for group in groups:
            if not group[GroupTrackerGlobals.SHOW] or len(
                    group[GroupTrackerGlobals.MEMBER_IDS]) == 0:
                continue  # We are using this to see if this group is dead or if someone doesnt want it up
            leaderId = 0
            for i, g in base.cr.globalGroupTracker.leader2Group.items():
                if g == group:
                    leaderId = i
            if not leaderId:
                continue

            leaderName = group[GroupTrackerGlobals.LEADER_NAME]
            shardName = group[GroupTrackerGlobals.SHARD_NAME]
            category = group[GroupTrackerGlobals.CATEGORY]
            memberIds = group[GroupTrackerGlobals.MEMBER_IDS]
            memberNames = group[GroupTrackerGlobals.MEMBER_NAMES]

            groupWidget = GroupTrackerGroup(parent=self,
                                            leaderId=leaderId,
                                            leaderName=leaderName,
                                            shardName=shardName,
                                            category=category,
                                            memberIds=memberIds,
                                            memberNames=memberNames)
            groupWidget.bind(DGG.WITHIN,
                             self.updateGroupInfoEventHandle,
                             extraArgs=[groupWidget])
            self.groupWidgets.append(groupWidget)
            if wantReconsiderInfo:
                wantReconsiderInfo = self.reconsiderGroupInfo(groupWidget)

        # Edge case where a group that was removed, info might remain on the screen if it didn't exist any more
        if wantReconsiderInfo:
            self.clearGroupInfo()

        # There are no groups, hide the information
        if len(self.groupWidgets) == 0:
            self.displayNoGroups()
        self.updateGroupList()

    def updateGroupList(self):
        self.statusMessage.hide()
        if self.scrollList is None:
            return

        # Clear the Group Listing
        for item in self.scrollList['items']:
            if item:
                self.scrollList.removeItem(item, refresh=True)
        self.scrollList['items'] = []

        # Re-populate the Group Listing
        for groupWidget in self.groupWidgets:
            self.scrollList.addItem(groupWidget, refresh=True)

        if len(self.groupWidgets) == 0:
            self.displayNoGroups()

    def updatePlayerList(self):
        if self.playerList is None:
            return

        # Clear the Player Listing
        for item in self.playerList['items']:
            if item:
                self.playerList.removeItem(item)
        self.playerList['items'] = []

        # Re-Populate the List
        for playerWidget in self.playerWidgets:
            self.playerList.addItem(playerWidget)

    def toggleWantGroup(self):
        if settings.get('grouptracker', False):
            settings['grouptracker'] = False
            base.cr.globalGroupTracker.showMe(False)
        else:
            settings['grouptracker'] = True
            base.cr.globalGroupTracker.showMe(True)

        base.localAvatar.wantGroupTracker()

        base.localAvatar.wantGroupTracker(
        )  # Updates the ai toon so the boarding group AI could know what he wants
        self.updateWantGroupButton()

    def updateWantGroupButton(self):
        if settings.get('grouptracker', False):
            self.wantGroupToggle['text'] = 'Hide Me'
        else:
            self.wantGroupToggle['text'] = 'Show Me'

    def doNothing(self):
        pass
Example #2
0
class lobbyGUI():
    def __init__(self, _client):

        self.client = _client
        self.playerList = []

        # Visuals
        self.lstLobby = DirectScrolledList(
            decButton_pos= (1.1, 0, -0.45),
            decButton_text = "up",
            decButton_text_scale = 0.06,
            decButton_borderWidth = (0.005, 0.005),

            incButton_pos= (1.1, 0, -0.55),
            incButton_text = "down",
            incButton_text_scale = 0.06,
            incButton_borderWidth = (0.005, 0.005),

            frameSize = (-1.05, 1.20, -1.16, 0.16),
            frameColor = (1,0,0,0.5),
            pos = (-0.075, 0, 0.5),
            numItemsVisible = 10,
            forceHeight = 0.11,
            itemFrame_frameSize = (-1, 1, -1.11, 0.11),
            itemFrame_pos = (0, 0, 0),
            )

        # create a start button
        self.btnStart = DirectButton(
            # Scale and position
            scale = 0.15,
            pos = (1,0,-0.90),
            # Text
            text = "Start",
            # Frame
            # Functionality
            command = self.start)

        # create a back button
        self.btnBack = DirectButton(
            # Scale and position
            scale = 0.15,
            pos = (-1,0,-0.90),
            # Text
            text = "back",
            # Frame
            # Functionality
            command = self.back)
        self.hide()

    def show(self):
        self.lstLobby.show()
        self.btnStart.show()
        self.btnBack.show()

    def hide(self):
        self.lstLobby.hide()
        self.btnStart.hide()
        self.btnBack.hide()

    def start(self):
        #TODO: Send event or whatever to let the other parts know we can
        #      start the game
        pass

    def back(self):
        #TODO: Send event or whatever to let the other parts know we
        #      want to move to the previous menu
        pass

    def updateList(self, newList):
        for item in newList:
            l = DirectLabel(text = item, text_scale=0.1)
            self.lstLobby.addItem(l)
Example #3
0
class Highscore():
    def __init__(self):

        home = os.path.expanduser("~")
        quickJNRDir = os.path.join(home, ".quickShooter")
        if not os.path.exists(quickJNRDir): os.makedirs(quickJNRDir)
        self.highscorefile = os.path.join(quickJNRDir, "highscore.txt")

        self.highscore = []

        if not os.path.exists(self.highscorefile):
            with open(self.highscorefile, "w") as f:
                f.write("""Foxy;4000
Wolf;3500
Coon;3000
Kitty;2020
Ferret;2000
Lynx;1700
Lion;1280
Tiger;800
Birdy;450
Fishy;250""")


        with open(self.highscorefile, "r+") as f:
            data = f.readlines()
            for line in data:
                name = line.split(";")[0]
                pts = line.split(";")[1]
                self.highscore.append([name, pts])


        self.lstHighscore = DirectScrolledList(
            frameSize = (-1, 1, -0.6, 0.6),
            frameColor = (0,0,0,0.5),
            pos = (0, 0, 0),
            numItemsVisible = 10,
            itemMakeFunction = self.__makeListItem,
            itemFrame_frameSize = (-0.9, 0.9, 0.0, -1),
            itemFrame_color = (1, 1, 1, 0),
            itemFrame_pos = (0, 0, 0.5))

        self.btnBack = DirectButton(
            # size of the button
            scale = (0.15, 0.15, 0.15),
            text = "Back",
            # set no relief
            relief = None,
            frameColor = (0,0,0,0),
            # No sink in when press
            pressEffect = False,
            # position on the window
            pos = (0.2, 0, 0.1),
            # the event which is thrown on clickSound
            command = self.btnBack_Click,
            # sounds that should be played
            rolloverSound = None,
            clickSound = None)
        self.btnBack.setTransparency(1)
        self.btnBack.reparentTo(base.a2dBottomLeft)

        self.refreshList()
        self.hide()

    def show(self):
        self.lstHighscore.show()
        self.btnBack.show()

    def hide(self):
        self.lstHighscore.hide()
        self.btnBack.hide()

    def writeHighscore(self):
        self.__sortHigscore()
        with open(self.highscorefile, "w") as f:
            for entry in self.highscore:
                f.write("{0};{1}".format(entry[0], entry[1]))

    def refreshList(self):
        self.__sortHigscore()
        self.lstHighscore.removeAllItems()
        for entry in self.highscore:
            self.lstHighscore.addItem("{0};{1}".format(entry[0], entry[1]))

    def __makeListItem(self, highscoreItem, stuff, morestuff):
        name = highscoreItem.split(";")[0]
        pts = highscoreItem.split(";")[1]
        # left
        l = -0.9
        # right
        r = 0.9
        itemFrame = DirectFrame(
            frameColor=(1, 1, 1, 0.5),
            frameSize=(l, r, -0.1, 0),
            relief=DGG.SUNKEN,
            borderWidth=(0.01, 0.01),
            pos=(0, 0, 0))
        lblName = DirectLabel(
            pos=(l + 0.01, 0, -0.07),
            text=name,
            text_align=TextNode.ALeft,
            scale=0.07,
            frameColor=(0, 0, 0, 0))
        lblPts = DirectLabel(
            pos=(r - 0.01, 0, -0.07),
            text=pts,
            text_align=TextNode.ARight,
            scale=0.07,
            frameColor=(0, 0, 0, 0))
        lblName.reparentTo(itemFrame)
        lblPts.reparentTo(itemFrame)
        return itemFrame


    def __sortHigscore(self):
        self.highscore = sorted(
            self.highscore,
            key=lambda score: int(score[1]),
            reverse=True)[:10]

    def setPoints(self, name, points):
        self.highscore.append([name, str(points) + "\n"])
        self.refreshList()
        self.writeHighscore()

    def btnBack_Click(self):
        self.hide()
        base.messenger.send("Highscore_back")
Example #4
0
class MainMenu():
	def __init__(self, showbase):
		self.showbase = showbase
		
		self.status = OnscreenText(text = "", pos = Vec3(0, -0.35, 0), scale = 0.05, fg = (1, 0, 0, 1), align = TextNode.ACenter, mayChange = True)
		
		self.background = DirectFrame(
			frameSize = (-1, 1, -1, 1),
			frameTexture  = 'media/gui/mainmenu/menu.png',
			parent = self.showbase.render2d,
		)

		self.title = OnscreenText(
			text   = 'Main Menu',
			fg     = (1, 1, 1, 1),
			parent = self.background,
			pos    = (-0.6, 0.1),
			scale  = 0.06
		)

		self.ip = '127.0.0.1' # Should make this write to file... so that the user can save ip's...
		# yep thats a good idea, there will be a few things i guess that need to be done like this
		# like settings and keys and whatnot
		
		# Buttons
		self.buttons = []
		serverButtons = Vec3(-0.60, 0, -0.79)
		# Host
		self.params = ['3', '8']
		p = serverButtons + Vec3(-0.25, 0, 0)
		self.hostButton = DirectButton(text = 'Host', pos = p,  scale = 0.048, relief = DGG.GROOVE, command = self.showbase.hostGame, extraArgs = [self.params])
		self.buttons.append(self.hostButton)
		# Join
		p = serverButtons + Vec3(0.0, 0.0, 0.0)
		self.joinButton = DirectButton(text = 'Join', pos = p, scale = 0.048, relief = DGG.GROOVE, command = self.joinServer)
		self.buttons.append(self.joinButton)
		# Refresh
		if self.showbase.online:
			p = serverButtons + Vec3(0.25, 0, 0)
			self.refreshButton = DirectButton(text = "Refresh", pos = p, scale = 0.048, relief = DGG.GROOVE, command = self.refreshStart)
			self.buttons.append(self.refreshButton)
			self.refreshStart()
			
			chatFrameCenter = (0.0, 0.325)
			chatFrameSize = (2.5, 1.2)
			self.chat = DirectFrame(
							frameColor = (0, 0, 0, 1),
							frameSize = (chatFrameSize[0] / 2, -chatFrameSize[0] / 2,  chatFrameSize[1] / 2, -chatFrameSize[1] / 2),
							pos = (chatFrameCenter[0], 0, chatFrameCenter[1])
						)
			
			channelFrameSize = (chatFrameSize[0] / 4, chatFrameSize[1])
			channelFrameCenter = (- chatFrameSize[0] / 2 + channelFrameSize[0] / 2, 0)
			numItemsVisible = 8
			itemHeight = channelFrameSize[1] / (numItemsVisible + 1)
			self.channels = DirectScrolledList(
								parent = self.chat,
								pos = (channelFrameCenter[0], 0, channelFrameCenter[1]),
								frameSize = (-channelFrameSize[0] / 2, channelFrameSize[0] / 2, channelFrameSize[1] / 2, -channelFrameSize[1] / 2),
								frameColor = (1, 0, 0, 0.5),
								numItemsVisible = numItemsVisible,
								forceHeight = itemHeight,

								#itemFrame_frameSize = (-channelFrameSize[0] / 2.1, channelFrameSize[0] / 2.1, itemHeight, -channelFrameSize[1] + itemHeight),
								itemFrame_pos = (0, 0, channelFrameSize[1] / 2 - itemHeight),

								decButton_pos = (-0.2, 0, channelFrameCenter[1] - channelFrameSize[1] / 2 + itemHeight / 4),
								decButton_text = 'Prev',
								decButton_text_scale = 0.05,
								decButton_borderWidth = (0.005, 0.005),

								incButton_pos = (0.2, 0, channelFrameCenter[1] - channelFrameSize[1] / 2 + itemHeight / 4),
								incButton_text = 'Next',
								incButton_text_scale = 0.05,
								incButton_borderWidth = (0.005, 0.005),
							)

			b1 = DirectButton(text = ("Button1", "click!", "roll", "disabled"),
								text_scale = 0.1, borderWidth = (0.01, 0.01),
								relief = 2)
			
			b2 = DirectButton(text = ("Button2", "click!", "roll", "disabled"),
								text_scale = 0.1, borderWidth = (0.01, 0.01),
								relief = 2)
			
			l1 = DirectLabel(text = "Test1", text_scale = 0.1)
			l2 = DirectLabel(text = "Test2", text_scale = 0.1)
			l3 = DirectLabel(text = "Test3", text_scale = 0.1)

			self.channels.addItem(b1)
			self.channels.addItem(b2)
			self.channels.addItem(l1)
			self.channels.addItem(l2)
			self.channels.addItem(l3)

			for fruit in ['apple', 'pear', 'banana', 'orange', 'cake', 'chocolate']:
				l = DirectLabel(text = fruit, text_scale = 0.1)
				self.channels.addItem(l) 
			# need to add the chat stuff
			# i guess have like a chat manager which will hold an array of 'chat_instances'
			# and the chat manager can sort out which is displayed and which channel the text is sent from/received to
			# a bit more thinking needs to be done i guess
			# can discuss sometime (not really that important now :P)
			
			# also i guess the layout and shit will need to be sorted (for whoever is doing the designing)
			
			# current games list (need to implement this)
			# it should send a query to the master server to get the current list (just ip's atmo i guess)
			
			# options shit aswell needs to be sorted
			# maybe just an overlay or something
			
			# functionality for the host button (popup an overlay that will be able to set options and then 'start_game' button
			# then should auto connect and go to lobby (will be same as for all clients, except have a couple of different buttons i guess)
			# close game instead of disconnect, start game instead of ready (greyed until all others are ready), kick button i suppose
			
			# once the options are set the 'server_inst' should be started on the local computer (which will broadcast to master server, once host can successfully connect)
			# then game client will move to pregame state (connect to the server, and wait for others and ready)
		else:
			self.entry = DirectEntry(
							focusInCommand = self.clearText,
							frameSize   = (-3, 3, -.5, 1),
							initialText = self.ip,
							parent      = self.buttons[0],
							pos         = (0, -0.6, -1.5),
							text_align  = TextNode.ACenter,
						)
		self.hide()

	def refreshStart(self):
		self.refreshButton["state"] = DGG.DISABLED
		if self.showbase.authCon.getConnected():
			self.servers = []
			self.showbase.authCon.sendData('serverQuery')
			self.showbase.taskMgr.doMethodLater(0.25, self.queryServers, 'Server Query')

	def queryServers(self, task):
		finished = False
		temp = self.showbase.authCon.getData()
		for package in temp:
			if len(package) == 2:
				# Handle Server Query
				if package[0] == 'server':
					self.servers.append(package[1])
					print package[1]
				elif package[0] == 'final':
					self.refreshButton["state"] = DGG.NORMAL
					finished = True
				else:
					self.showbase.authCon.passData(package)
		if finished:
			return task.done
		return task.cont

	def joinChat(self):
		pass
		# Let the client mini auth with the lobby server(lobby_loop) by "Logging into the chat"
		# Since everything will be in the main menu? like a main chat window.. something similar to HoN i guess?
		# When the player opens the Join game by button, a list will be send from the lobby server telling it what games are active.
		# Then the player picks one and it connects via the host name/ip or whatever.
		# While this is busy happening the client stays connected to the lobby server.
		
	def joinServer(self):
		if self.showbase.online:
			self.ip = '127.0.0.1'
		else:
			self.ip = self.entry.get()
		self.status.setText('Attempting to join server @ ' + self.ip + '...')
		# attempt to connect to the game server
		self.showbase.client = Client(self.showbase, self.ip, 9099, compress = True)
		if self.showbase.client.getConnected():
			print 'Connected to server, Awaiting authentication...'
			self.showbase.client.sendData(('username', self.showbase.username))
			self.showbase.taskMgr.add(self.authorizationListener, 'Authorization Listener')
		else:
			self.status.setText('Could not Connect...')

	def authorizationListener(self, task):
		temp = self.showbase.client.getData()
		auth = False
		if temp != []:
			for package in temp:
				if len(package) == 2:
					if package[0] == 'auth':
						print 'Authentication Successful'
						auth = True
					elif package[0] == 'fail':
						self.status.setText('Authentication failed on server...')
						return task.done
					else:
						self.showbase.client.passData(package)
		if auth:
			self.showbase.startPregame()
			return task.done
		return task.again

	def clearText(self):
		self.entry.enterText('')

	def hide(self):
		self.showbase.taskMgr.remove('Server Query Timeout')
		self.background.hide()
		for b in self.buttons:
			b.hide()
		self.status.hide()
		if self.showbase.online:
			self.chat.hide()
			self.channels.hide()
		else:
			self.entry.hide()

	def show(self):
		self.background.show()
		for b in self.buttons:
			b.show()
		self.status.show()
		if self.showbase.online:
			self.chat.show()
			self.channels.show()
		else:
			self.entry.show()
Example #5
0
class MainMenu():
    def __init__(self, showbase):
        self.showbase = showbase

        self.status = OnscreenText(text="",
                                   pos=Vec3(0, -0.35, 0),
                                   scale=0.05,
                                   fg=(1, 0, 0, 1),
                                   align=TextNode.ACenter,
                                   mayChange=True)

        self.background = DirectFrame(
            frameSize=(-1, 1, -1, 1),
            frameTexture='media/gui/mainmenu/menu.png',
            parent=self.showbase.render2d,
        )

        self.title = OnscreenText(text='Main Menu',
                                  fg=(1, 1, 1, 1),
                                  parent=self.background,
                                  pos=(-0.6, 0.1),
                                  scale=0.06)

        self.ip = '127.0.0.1'  # Should make this write to file... so that the user can save ip's...
        # yep thats a good idea, there will be a few things i guess that need to be done like this
        # like settings and keys and whatnot

        # Buttons
        self.buttons = []
        serverButtons = Vec3(-0.60, 0, -0.79)
        # Host
        self.params = ['3', '8']
        p = serverButtons + Vec3(-0.25, 0, 0)
        self.hostButton = DirectButton(text='Host',
                                       pos=p,
                                       scale=0.048,
                                       relief=DGG.GROOVE,
                                       command=self.showbase.hostGame,
                                       extraArgs=[self.params])
        self.buttons.append(self.hostButton)
        # Join
        p = serverButtons + Vec3(0.0, 0.0, 0.0)
        self.joinButton = DirectButton(text='Join',
                                       pos=p,
                                       scale=0.048,
                                       relief=DGG.GROOVE,
                                       command=self.joinServer)
        self.buttons.append(self.joinButton)
        # Refresh
        if self.showbase.online:
            p = serverButtons + Vec3(0.25, 0, 0)
            self.refreshButton = DirectButton(text="Refresh",
                                              pos=p,
                                              scale=0.048,
                                              relief=DGG.GROOVE,
                                              command=self.refreshStart)
            self.buttons.append(self.refreshButton)
            self.refreshStart()

            chatFrameCenter = (0.0, 0.325)
            chatFrameSize = (2.5, 1.2)
            self.chat = DirectFrame(
                frameColor=(0, 0, 0, 1),
                frameSize=(chatFrameSize[0] / 2, -chatFrameSize[0] / 2,
                           chatFrameSize[1] / 2, -chatFrameSize[1] / 2),
                pos=(chatFrameCenter[0], 0, chatFrameCenter[1]))

            channelFrameSize = (chatFrameSize[0] / 4, chatFrameSize[1])
            channelFrameCenter = (-chatFrameSize[0] / 2 +
                                  channelFrameSize[0] / 2, 0)
            numItemsVisible = 8
            itemHeight = channelFrameSize[1] / (numItemsVisible + 1)
            self.channels = DirectScrolledList(
                parent=self.chat,
                pos=(channelFrameCenter[0], 0, channelFrameCenter[1]),
                frameSize=(-channelFrameSize[0] / 2, channelFrameSize[0] / 2,
                           channelFrameSize[1] / 2, -channelFrameSize[1] / 2),
                frameColor=(1, 0, 0, 0.5),
                numItemsVisible=numItemsVisible,
                forceHeight=itemHeight,

                #itemFrame_frameSize = (-channelFrameSize[0] / 2.1, channelFrameSize[0] / 2.1, itemHeight, -channelFrameSize[1] + itemHeight),
                itemFrame_pos=(0, 0, channelFrameSize[1] / 2 - itemHeight),
                decButton_pos=(-0.2, 0, channelFrameCenter[1] -
                               channelFrameSize[1] / 2 + itemHeight / 4),
                decButton_text='Prev',
                decButton_text_scale=0.05,
                decButton_borderWidth=(0.005, 0.005),
                incButton_pos=(0.2, 0, channelFrameCenter[1] -
                               channelFrameSize[1] / 2 + itemHeight / 4),
                incButton_text='Next',
                incButton_text_scale=0.05,
                incButton_borderWidth=(0.005, 0.005),
            )

            b1 = DirectButton(text=("Button1", "click!", "roll", "disabled"),
                              text_scale=0.1,
                              borderWidth=(0.01, 0.01),
                              relief=2)

            b2 = DirectButton(text=("Button2", "click!", "roll", "disabled"),
                              text_scale=0.1,
                              borderWidth=(0.01, 0.01),
                              relief=2)

            l1 = DirectLabel(text="Test1", text_scale=0.1)
            l2 = DirectLabel(text="Test2", text_scale=0.1)
            l3 = DirectLabel(text="Test3", text_scale=0.1)

            self.channels.addItem(b1)
            self.channels.addItem(b2)
            self.channels.addItem(l1)
            self.channels.addItem(l2)
            self.channels.addItem(l3)

            for fruit in [
                    'apple', 'pear', 'banana', 'orange', 'cake', 'chocolate'
            ]:
                l = DirectLabel(text=fruit, text_scale=0.1)
                self.channels.addItem(l)
            # need to add the chat stuff
            # i guess have like a chat manager which will hold an array of 'chat_instances'
            # and the chat manager can sort out which is displayed and which channel the text is sent from/received to
            # a bit more thinking needs to be done i guess
            # can discuss sometime (not really that important now :P)

            # also i guess the layout and shit will need to be sorted (for whoever is doing the designing)

            # current games list (need to implement this)
            # it should send a query to the master server to get the current list (just ip's atmo i guess)

            # options shit aswell needs to be sorted
            # maybe just an overlay or something

            # functionality for the host button (popup an overlay that will be able to set options and then 'start_game' button
            # then should auto connect and go to lobby (will be same as for all clients, except have a couple of different buttons i guess)
            # close game instead of disconnect, start game instead of ready (greyed until all others are ready), kick button i suppose

            # once the options are set the 'server_inst' should be started on the local computer (which will broadcast to master server, once host can successfully connect)
            # then game client will move to pregame state (connect to the server, and wait for others and ready)
        else:
            self.entry = DirectEntry(
                focusInCommand=self.clearText,
                frameSize=(-3, 3, -.5, 1),
                initialText=self.ip,
                parent=self.buttons[0],
                pos=(0, -0.6, -1.5),
                text_align=TextNode.ACenter,
            )
        self.hide()

    def refreshStart(self):
        self.refreshButton["state"] = DGG.DISABLED
        if self.showbase.authCon.getConnected():
            self.servers = []
            self.showbase.authCon.sendData('serverQuery')
            self.showbase.taskMgr.doMethodLater(0.25, self.queryServers,
                                                'Server Query')

    def queryServers(self, task):
        finished = False
        temp = self.showbase.authCon.getData()
        for package in temp:
            if len(package) == 2:
                # Handle Server Query
                if package[0] == 'server':
                    self.servers.append(package[1])
                    print package[1]
                elif package[0] == 'final':
                    self.refreshButton["state"] = DGG.NORMAL
                    finished = True
                else:
                    self.showbase.authCon.passData(package)
        if finished:
            return task.done
        return task.cont

    def joinChat(self):
        pass
        # Let the client mini auth with the lobby server(lobby_loop) by "Logging into the chat"
        # Since everything will be in the main menu? like a main chat window.. something similar to HoN i guess?
        # When the player opens the Join game by button, a list will be send from the lobby server telling it what games are active.
        # Then the player picks one and it connects via the host name/ip or whatever.
        # While this is busy happening the client stays connected to the lobby server.

    def joinServer(self):
        if self.showbase.online:
            self.ip = '127.0.0.1'
        else:
            self.ip = self.entry.get()
        self.status.setText('Attempting to join server @ ' + self.ip + '...')
        # attempt to connect to the game server
        self.showbase.client = Client(self.showbase,
                                      self.ip,
                                      9099,
                                      compress=True)
        if self.showbase.client.getConnected():
            print 'Connected to server, Awaiting authentication...'
            self.showbase.client.sendData(('username', self.showbase.username))
            self.showbase.taskMgr.add(self.authorizationListener,
                                      'Authorization Listener')
        else:
            self.status.setText('Could not Connect...')

    def authorizationListener(self, task):
        temp = self.showbase.client.getData()
        auth = False
        if temp != []:
            for package in temp:
                if len(package) == 2:
                    if package[0] == 'auth':
                        print 'Authentication Successful'
                        auth = True
                    elif package[0] == 'fail':
                        self.status.setText(
                            'Authentication failed on server...')
                        return task.done
                    else:
                        self.showbase.client.passData(package)
        if auth:
            self.showbase.startPregame()
            return task.done
        return task.again

    def clearText(self):
        self.entry.enterText('')

    def hide(self):
        self.showbase.taskMgr.remove('Server Query Timeout')
        self.background.hide()
        for b in self.buttons:
            b.hide()
        self.status.hide()
        if self.showbase.online:
            self.chat.hide()
            self.channels.hide()
        else:
            self.entry.hide()

    def show(self):
        self.background.show()
        for b in self.buttons:
            b.show()
        self.status.show()
        if self.showbase.online:
            self.chat.show()
            self.channels.show()
        else:
            self.entry.show()
class GroupTrackerPage(ShtikerPage.ShtikerPage):
    notify = directNotify.newCategory('GroupTrackerPage')

    def __init__(self):
        ShtikerPage.ShtikerPage.__init__(self)
        self.groupWidgets = []
        self.playerWidgets = []
        self.images = []                # image nodes: Possible images to apply on groups
        self.scrollList = None          # DirectScrolledList: Holds the GroupTrackerGroup widgets
        self.scrollTitle = None         # DirectLabel: Title of the list that holds the groups
        self.playerList = None          # DirectScrolledList: Holds players when showing a specific group details
        self.playerListTitle = None     # DirectLabel: Title of the playerList
        self.groupInfoTitle = None      # DirectLabel: holds the group detail title to show on the right
        self.groupInfoDistrict = None   # DirectLabel: shows group detail district on the right
        self.statusMessage = None       # DirectLabel: Shows important messages like Loading... or "No boarding groups available"
        self.groupIcon = None           # DirectButton: Icon to associate with the group ex. sellbot icon or cashbot icon depending on group info
        self.wantGroupToggle = None     # DirectButton: Allows the toon to toggle his listing

    def load(self):
        self.listXorigin = -0.02
        self.listFrameSizeX = 0.67
        self.listZorigin = -0.96
        self.listFrameSizeZ = 1.04
        self.arrowButtonScale = 1.3
        self.itemFrameXorigin = -0.237
        self.itemFrameZorigin = 0.365
        self.buttonXstart = self.itemFrameXorigin + 0.293
        self.gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui')
        guiButton = loader.loadModel('phase_3/models/gui/quit_button')
        self.scrollList = DirectScrolledList(parent=self, 
                                            relief=None, 
                                            pos=(-0.5, 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.buttonXstart, 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.buttonXstart, 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=15, 
                                            forceHeight=0.065, 
                                            items=self.groupWidgets
                                            )
                                            
        self.scrollTitle = DirectFrame(parent=self.scrollList, 
                                       text=TTLocalizer.GroupTrackerListTitle, 
                                       text_scale=0.06, 
                                       text_align=TextNode.ACenter, 
                                       relief=None,
                                       pos=(self.buttonXstart, 0, self.itemFrameZorigin + 0.127)
                                       )
        
        self.playerList = DirectScrolledList(parent=self, 
                                            relief=None, 
                                            pos=(0.45, 0, 0.1), 
                                            
                                            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=(1.0, 1.0, -1.0), 
                                            incButton_pos=(0, 0, -0.28), 
                                            incButton_image3_color=Vec4(1, 1, 1, 0.05),
                                            
                                            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=(1.0, 1.0, 1.0),
                                            decButton_pos=(0.0, 0, 0.04), 
                                            decButton_image3_color=Vec4(1, 1, 1, 0.25), 
                                            
                                            itemFrame_pos=(0, 0, -0.05), 
                                            itemFrame_scale=1.0,
                                            itemFrame_relief=DGG.SUNKEN, 
                                            itemFrame_frameSize=(-0.3, 0.3,  #x
                                                                 -0.2, 0.06),  #z
                                            itemFrame_frameColor=(0.85, 0.95, 1, 1), 
                                            itemFrame_borderWidth=(0.01, 0.01), 
                                            numItemsVisible=4,
                                            forceHeight=0.05, 
                                            items=self.playerWidgets
                                            )
                                            
        self.playerListTitle = DirectFrame(parent=self.playerList, 
                                       text='', 
                                       text_scale=0.05, 
                                       text_align=TextNode.ACenter, 
                                       relief=None,
                                       pos=(0, 0, 0.08)
                                       )
        self.groupInfoTitle = DirectLabel(parent=self, text='', 
                                          text_scale=0.080, text_align=TextNode.ACenter,
                                          text_wordwrap=15, relief=None, pos=(0.45, 0, 0.5))
        self.groupInfoDistrict = DirectLabel(parent=self,
                                     text='',
                                     text_scale=0.050,
                                     text_align=TextNode.ACenter, 
                                     text_wordwrap=15, 
                                     relief=None, 
                                     pos=(0.45, 0, 0.4)
                                     )
        
        self.statusMessage = DirectLabel(parent=self, text='', text_scale=0.060, text_align=TextNode.ACenter, text_wordwrap=5, relief=None, pos=(0.45,0,0.1))
                                     
        # Group Image:
        self.groupIcon = DirectButton(parent=self, relief=None, state=DGG.DISABLED, image=None, image_scale=(0.35, 1, 0.35), image_color=Vec4(1.0, 1.0, 1.0, 0.75), pos=(0.45, 10, -0.45), command=self.doNothing)
        
        # Group Toggle:
        self.wantGroupToggle = DirectButton(parent=self, relief=None, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), image_scale=(0.7, 1, 1), text='', text_scale=0.052, text_pos=(0, -0.02), pos=(0.2, 0, -0.65), command=self.toggleWantGroup)
        self.updateWantGroupButton()
        
        
        # Loading possible group icons
        suitIcons = loader.loadModel('phase_3/models/gui/cog_icons')     
        bossbotIcon = suitIcons.find('**/CorpIcon')
        bossbotIcon.setColor(SUIT_ICON_COLORS[0])
        self.images.append(bossbotIcon)
        
        lawbotIcon = suitIcons.find('**/LegalIcon')
        lawbotIcon.setColor(SUIT_ICON_COLORS[1])
        self.images.append(lawbotIcon)
        
        cashbotIcon = suitIcons.find('**/MoneyIcon')
        cashbotIcon.setColor(SUIT_ICON_COLORS[2])
        self.images.append(cashbotIcon)
        
        sellbotIcon = suitIcons.find('**/SalesIcon')
        sellbotIcon.setColor(SUIT_ICON_COLORS[3])
        self.images.append(sellbotIcon)
        
        # Clean up
        self.clearGroupInfo()
        self.statusMessage.hide()
        
        suitIcons.removeNode()
        self.gui.removeNode()
        guiButton.removeNode()

        self.accept('GroupTrackerResponse', self.updatePage)

    def unload(self):
        self.scrollList.destroy()
        self.groupInfoDistrict.destroy()
        self.playerList.destroy()
        self.groupInfoTitle.destroy()
        self.groupIcon.destroy()
        self.wantGroupToggle.destroy()
        for widget in self.playerWidgets:
            widget.destroy()
        for widget in self.groupWidgets:
            widget.destroy()
        self.playerWidgets = []
        
        del self.scrollList
        del self.groupInfoDistrict
        del self.playerList
        del self.groupInfoTitle
        del self.groupIcon
        del self.wantGroupToggle
        ShtikerPage.ShtikerPage.unload(self)

    def enter(self):
        ShtikerPage.ShtikerPage.enter(self)
        self.setGroups([]) # CLEAR IT ALL
        self.setPlayers()  # CLEAR IT ALL
        if(self.scrollList['items'] == []):
            self.statusMessage['text'] = TTLocalizer.GroupTrackerLoading
            self.statusMessage.show()
        base.cr.globalGroupTracker.requestGroups()
        taskMgr.doMethodLater(3, self.displayNoGroupsTaskHandler, self.uniqueName('timeout'))

    def displayNoGroups(self):
        self.statusMessage['text'] = TTLocalizer.GroupTrackerEmpty
        self.statusMessage.show()
        self.clearGroupInfo()
    
    def displayNoGroupsTaskHandler(self, task):
        self.displayNoGroups()
        return task.done

    def updatePage(self):
        taskMgr.remove(self.uniqueName('timeout'))
        groups = base.cr.globalGroupTracker.getGroupInfo()
        self.setGroups(groups)
        
    def exit(self):
        self.clearGroupInfo()
        ShtikerPage.ShtikerPage.exit(self)
        base.cr.globalGroupTracker.doneRequesting()
    
    def updateGroupInfoEventHandle(self, groupWidget, mouseEvent):
        self.updateGroupInfo(groupWidget)
        
    def updateGroupInfo(self, groupWidget):
        ''' Updates the Right Page of the Group Tracker Page with new Info '''
        self.statusMessage.hide()

        # Update the Player List
        self.setPlayers(groupWidget)
        self.playerList.show()

        # Update the Player List Title
        self.playerListTitle['text'] = ('Players ' + str(groupWidget.getCurrentPlayers()) + '/' + str(groupWidget.getMaxPlayers()) + ':')
        self.playerListTitle.show()

        # Update the District
        self.groupInfoDistrict['text'] = TTLocalizer.BoardingGroupDistrictInformation % { 'district' : groupWidget.getDistrict() }
        self.groupInfoDistrict.show()

        # Update the Title
        self.groupInfoTitle['text'] = groupWidget.getTitle()
        self.groupInfoTitle.show()

        # Update the Image
        self.groupIcon['image'] = self.images[GroupTrackerGlobals.CATEGORY_TO_IMAGE_ID[groupWidget.getCategory()]]
        self.groupIcon['image_scale'] = (0.35, 1, 0.35)
        self.groupIcon.show()

    def clearGroupInfo(self):
        self.playerList.hide()
        self.playerListTitle.hide()
        self.groupInfoDistrict.hide()
        self.groupInfoTitle.hide()
        self.groupIcon.hide()

    def setPlayers(self, groupWidget=None):
        ''' Calls updatePlayerList '''

        # Clear the Widgets that were held in the listings
        for playerWidget in self.playerWidgets:
            playerWidget.destroy()
        self.playerWidgets = []

        # Make a player widget for each player
        # TODO: Edit this stuff when avIds come from players
        if groupWidget:
            leaderId = groupWidget.getLeaderId()
            playerNames = groupWidget.getMemberNames()
            playerIds = groupWidget.getMemberIds()
            for playerName in playerNames:
                playerId = playerIds[playerNames.index(playerName)]
                isLeader = playerId == leaderId
                self.playerWidgets.append(GroupTrackerPlayer(parent=self, avId=playerId, name=playerName, isLeader=isLeader))

        self.updatePlayerList()

    def reconsiderGroupInfo(self, groupWidget):
        ''' If someone is viewing this info and it was updated, we also want to update the info being viewed '''
        if self.playerWidgets is None or self.playerList['items'] == []:
            return # No Info is being viewed at the moment since you cant have an empty group
        
        # We have to update if this group's leader is the leader in the playerlist being viewed right now
        leaderId = groupWidget.getLeaderId()
        
        # Check all the players in the playerList being viewed for the same leader
        for playerWidget in self.playerWidgets:
            if playerWidget.getLeader():
                if leaderId == playerWidget.getId():
                    self.updateGroupInfo(groupWidget)
                    return False
        
        return True
                
    def setGroups(self, groups):
        ''' Calls updateGroupList '''
        
        # Clear our Group Widgets
        for group in self.groupWidgets:
            group.destroy()
        self.groupWidgets = []
        
        wantReconsiderInfo = True
    
        # Create a new group widget for each group
        for group in groups:
            if not group[GroupTrackerGlobals.SHOW] or len(group[GroupTrackerGlobals.MEMBER_IDS]) == 0:
                continue # We are using this to see if this group is dead or if someone doesnt want it up
            leaderId = 0
            for i, g in base.cr.globalGroupTracker.leader2Group.items():
                if g == group:
                    leaderId = i
            if not leaderId:
                continue
                
            leaderName = group[GroupTrackerGlobals.LEADER_NAME]
            shardName = group[GroupTrackerGlobals.SHARD_NAME]
            category = group[GroupTrackerGlobals.CATEGORY]
            memberIds = group[GroupTrackerGlobals.MEMBER_IDS]
            memberNames = group[GroupTrackerGlobals.MEMBER_NAMES]
            
            groupWidget = GroupTrackerGroup(parent=self, leaderId=leaderId, leaderName=leaderName, shardName=shardName, category=category, memberIds=memberIds, memberNames=memberNames)
            groupWidget.bind(DGG.WITHIN, self.updateGroupInfoEventHandle, extraArgs=[groupWidget])
            self.groupWidgets.append(groupWidget)
            if wantReconsiderInfo:
                wantReconsiderInfo = self.reconsiderGroupInfo(groupWidget)
        
        # Edge case where a group that was removed, info might remain on the screen if it didn't exist any more
        if wantReconsiderInfo:
            self.clearGroupInfo()
        
        # There are no groups, hide the information
        if len(self.groupWidgets) == 0:
            self.displayNoGroups()
        self.updateGroupList()

    def updateGroupList(self): 
        self.statusMessage.hide()
        if self.scrollList is None:
            return
            
        # Clear the Group Listing
        for item in self.scrollList['items']:
            if item:
                self.scrollList.removeItem(item, refresh=True)
        self.scrollList['items'] = []
        
        # Re-populate the Group Listing
        for groupWidget in self.groupWidgets:
            self.scrollList.addItem(groupWidget, refresh=True)
        
        if len(self.groupWidgets) == 0:
            self.displayNoGroups()

    def updatePlayerList(self):
        if self.playerList is None:
            return

        # Clear the Player Listing
        for item in self.playerList['items']:
            if item:
                self.playerList.removeItem(item)
        self.playerList['items'] = []

        # Re-Populate the List
        for playerWidget in self.playerWidgets:
            self.playerList.addItem(playerWidget)

    def toggleWantGroup(self):
        if settings.get('grouptracker', False):
            settings['grouptracker'] = False
            base.cr.globalGroupTracker.showMe(False)
        else:
            settings['grouptracker'] = True
            base.cr.globalGroupTracker.showMe(True)
            
        base.localAvatar.wantGroupTracker()
        
        base.localAvatar.wantGroupTracker() # Updates the ai toon so the boarding group AI could know what he wants
        self.updateWantGroupButton()
    
    def updateWantGroupButton(self):
        if settings.get('grouptracker', False):
            self.wantGroupToggle['text'] = 'Hide Me'
        else:
            self.wantGroupToggle['text'] = 'Show Me'
            
    def doNothing(self):
        pass