def registerMarkerCaptured(self, msg):
        "received a marker captured message from the game server, update our marker count"
        markerID = msg.markerId()
        mrkrDisplay = ptMarkerMgr()

        self.gameData.data['numCapturedMarkers'] += 1
        self.gameData.save()

        output = ""
        if self.gameData.data[
                'svrGameTypeID'] == PtMarkerGameTypes.kMarkerGameCGZ:
            gameNum = grtzMarkerGames.GetCurrentCGZGame()

            if gameNum >= 0 and gameNum < len(grtzMarkerGames.mgs):
                try:
                    if self.clientUpdatedMarker:
                        self.clientUpdatedMarker -= 1
                        markers = grtzMarkerGames.mgs[gameNum][0][4]
                        output = "Found marker: '%s'" % markers[markerID][0]
                        PtSendKIMessage(kKILocalChatStatusMsg, output)
                    #Hide the markers...
                    mrkrDisplay.captureQuestMarker(markerID, 1)
                    #End game check is in the Marker Scope GUI
                except:
                    PtDebugPrint(
                        "ERROR: xMarkerGameManager.captureMarker():\tCould not get data for CGZ marker captured message!"
                    )
        else:
            mrkrDisplay.captureQuestMarker(markerID, 1)
            for marker in self.gameData.data['markers']:
                marker = marker.data
                if marker['id'] == markerID:
                    marker['captured'] = 1
                    if self.clientUpdatedMarker:
                        self.clientUpdatedMarker -= 1
                        output = "Found marker: '%s'" % marker['name']
                        PtSendKIMessage(kKILocalChatStatusMsg, output)
                        #check for completion of game...
                        if self.gameData.data[
                                'numCapturedMarkers'] >= self.gameData.data[
                                    'numMarkers']:
                            PtSendKIMessage(
                                kKILocalChatStatusMsg,
                                PtGetLocalizedString(
                                    "KI.MarkerGame.FinishedGame",
                                    [self.gameData.data['svrGameName']]))
                    #TODO: eventually this will need to be different for Hold games as they change colors...
                    #Quest game: Hide the marker....
                    mrkrDisplay.captureQuestMarker(markerID, 1)
                    break

        #Setup the KI display
        self.UpdateKIMarkerDisplay()
    def OnGUINotify(self, id, control, event):
        "Events from all the dialogs in the MarkerGameGUI Age..."
        if id != MarkerGameDlg.id:
            return

        #~PtDebugPrint("grtzMarkerScopeGUI::OnGUINotify id=%d, event=%d control=" % (id,event),control)#,level=kDebugDumpLevel )
        if event == kDialogLoaded:
            PtDebugPrint(
                "DEBUG: grtzMarkerScopeGUI():\tMarker Scope GUU--->Dialog Loaded!"
            )
            # hide stuff until needed
            MGAnim.animation.skipToTime(1.5)

        elif event == kShowHide:
            if control.isEnabled():
                PtDebugPrint(
                    "DEBUG: grtzMarkerScopeGUI():\tMarker Scope-GUI--->Show Dialog"
                )
                # make sure the player has enough level to see the GUI
                gameType = grtzMarkerGames.GetCurrentGameType()
                if PtDetermineKIMarkerLevel() < kKIMarkerNormalLevel:
                    PtDebugPrint(
                        "DEBUG: grtzMarkerScopeGUI.OnGUINotify():\tKI Level not high enough, disabling GUI controls"
                    )
                    gameSelector = ptGUIControlRadioGroup(
                        MarkerGameDlg.dialog.getControlFromTag(
                            kRGMarkerGameSelect))
                    gameSelector.setValue(-1)
                    gameSelector.disable()
                    self.updateLevel = kNoRefresh
                elif gameType > -1 and gameType != PtMarkerGameTypes.kMarkerGameCGZ:
                    PtDebugPrint(
                        "DEBUG: grtzMarkerScopeGUI.OnGUINotify():\tUser Created Marker Game in Progress, disabling GUI controls"
                    )
                    gameSelector = ptGUIControlRadioGroup(
                        MarkerGameDlg.dialog.getControlFromTag(
                            kRGMarkerGameSelect))
                    gameSelector.setValue(-1)
                    gameSelector.disable()
                    self.updateLevel = kNoRefresh
                    msg = "Please quit existing User-Created Marker Game, to play a CGZ Game."
                    PtSendKIMessage(kKILocalChatStatusMsg, msg)
                    self.IRefreshGamesDisplay()
                    MGMachineOnResp.run(self.key, netPropagate=0)
                else:  #We're loading the GUI
                    # Get gameData (if Any)
                    gameNum, numCaptured, numMarkers = grtzMarkerGames.GetGameProgress(
                    )
                    PtDebugPrint(
                        "DEBUG: grtzMarkerScopeGUI.OnGUINotify():\tInitializing GUI, current gameNum = %s"
                        % gameNum)

                    #Set refresh level to not update, later we'll change it if necessary...
                    self.updateLevel = kNoRefresh
                    self.lastGame = -1
                    self.lastGameScore = -1

                    if gameNum > -1 and numCaptured > -1 and numMarkers > -1:
                        if numCaptured == numMarkers:
                            #We've got a completed game!!!
                            #Stop the game....
                            PtSendKIMessage(kMGStopCGZGame, 0)

                            #Save the game information
                            self.lastGame = gameNum
                            self.lastGameScore = grtzMarkerGames.GetGameScore(
                                gameNum)

                            #Now set the selector to unselected...
                            gameNum = -1

                            #Setup the timer to refresh the display
                            self.updateLevel = kPartialRefresh

                    # Set selector to the game being played (if Any)
                    gameSelector = ptGUIControlRadioGroup(
                        MarkerGameDlg.dialog.getControlFromTag(
                            kRGMarkerGameSelect))
                    gameSelector.enable()
                    oldGame = gameSelector.getValue()
                    if gameNum != oldGame:
                        gameSelector.setValue(gameNum)
                        self.init = 0
                    else:
                        #We've already initialized properly, no need to do it again!
                        self.init = 1

                    if gameNum > -1:
                        # start/continue the counting
                        self.updateLevel = kPartialRefresh

                    #Refresh Display
                    self.IRefreshGamesDisplay()
                    MGMachineOnResp.run(self.key, netPropagate=0)

                    if self.updateLevel > kNoRefresh:
                        PtAtTimeCallback(self.key, 1, kDisplayTimer)
            else:
                PtDebugPrint(
                    "DEBUG: grtzMarkerScopeGUI():\tMarker Scope-GUI--->Hide dialog"
                )
                #Hide scope...
                MGAnim.animation.skipToTime(1.5)
                self.lastGame = -1
                self.lastGameScore = -1

                #Stop the timer callbacks...
                self.updateLevel = kNoRefresh

                #Get the game selected
                gameSelector = ptGUIControlRadioGroup(
                    MarkerGameDlg.dialog.getControlFromTag(
                        kRGMarkerGameSelect))
                reqGameNum = gameSelector.getValue()
                curGameNum = grtzMarkerGames.GetCurrentCGZGame()

                #Start the game if necessary
                if self.selectorChanged:
                    #Exit if somehow we really don't have a valid game!
                    if reqGameNum < 0 or reqGameNum > len(grtzMarkerGames.mgs):
                        PtDebugPrint(
                            "ERROR: grtzMarkerScopeGUI.OnGUINotify:\tCannot start invalid game number: %d"
                            % reqGameNum)
                        return

                    #Finally, start the new game!
                    PtDebugPrint(
                        "DEBUG: grtzMarkerScopeGUI.OnGUINotify():\tReceived GUI notification to start game: %s"
                        % reqGameNum)
                    PtSendKIMessageInt(kMGStartCGZGame, reqGameNum)

                    #Reset selector sensor
                    self.selectorChanged = 0

        elif event == kValueChanged:
            rgid = control.getTagID()
            if rgid == kRGMarkerGameSelect:
                #The first time we update the selector, we don't want to register a new game selected!!!
                #All played games are initialized upon age load, not upon marker scope GUI load....
                if self.init == 0:
                    PtDebugPrint(
                        "DEBUG: grtzMarkerScopeGUI.OnGUINotify():\tFinished initialization.... (ignoring selector change)"
                    )
                    self.init = 1  #Make sure we don't try to re-init!
                    return

                self.selectorChanged = 1  #let us know if the selector changed for (so we can start/stop a game if necessary)

                gameNum = control.getValue()
                PtDebugPrint(
                    "DEBUG: grtzMarkerScopeGUI.OnGUINotify():\tReceived CGZ Game Selector change: %s"
                    % gameNum)

                #If we were playing an existing game, we need to quit it!!!
                curGame = grtzMarkerGames.GetCurrentCGZGame()
                if curGame != None and curGame > -1:
                    PtDebugPrint(
                        "DEBUG: grtzMarkerScopeGUI.OnGUINotify():\tSelector value changed, stopping current game!"
                    )
                    PtSendKIMessage(kMGStopCGZGame, 0)
                    self.updateLevel = kOneTimeFullRefresh

                #Reset the score if we've seleced a game
                prevRefresh = self.updateLevel
                if gameNum > -1 and gameNum < len(grtzMarkerGames.mgs):
                    grtzMarkerGames.UpdateScore(gameNum, PtGetDniTime(), 0.0)
                    self.updateLevel = kPartialRefresh
                else:
                    #just need to refresh the entire display to ensure we've stopped any timer displays
                    self.updateLevel = kOneTimeFullRefresh
                    pass

                #Force one update...
                self.IRefreshGamesDisplay()

                #Update display... only if we didn't have plans to update...
                if prevRefresh == kNoRefresh:
                    PtAtTimeCallback(self.key, 0, kDisplayTimer)