def setMovie(self, mode, avId):
     isLocalToon = avId == base.localAvatar.doId
     if isLocalToon:
         DistributedMailbox.notify.debug('setMovie( mode=%d, avId=%d ) called on a local toon' % (mode, avId))
     else:
         DistributedMailbox.notify.debug('setMovie( mode=%d, avId=%d ) called on a non-local toon' % (mode, avId))
     if mode == MailboxGlobals.MAILBOX_MOVIE_CLEAR:
         DistributedMailbox.notify.debug('setMovie: clear')
         return
     elif mode == MailboxGlobals.MAILBOX_MOVIE_EXIT:
         if random.random() < 0.5:
             sfx = base.loader.loadSfx('phase_5.5/audio/sfx/mailbox_close_1.mp3')
         else:
             sfx = base.loader.loadSfx('phase_5.5/audio/sfx/mailbox_close_2.mp3')
         sfxTrack = SoundInterval(sfx, node=self.model)
         sfxTrack.start()
         DistributedMailbox.notify.debug('setMovie: exit')
         return
     elif mode == MailboxGlobals.MAILBOX_MOVIE_EMPTY:
         DistributedMailbox.notify.debug('setMovie: empty')
         if isLocalToon:
             self.mailboxDialog = TTDialog.TTDialog(dialogName='MailboxEmpty', style=TTDialog.Acknowledge, text=TTLocalizer.DistributedMailboxEmpty, text_wordwrap=15, fadeScreen=1, command=self.__clearDialog)
         return
     elif mode == MailboxGlobals.MAILBOX_MOVIE_WAITING:
         DistributedMailbox.notify.debug('setMovie: waiting')
         if isLocalToon:
             self.mailboxDialog = TTDialog.TTDialog(dialogName='MailboxWaiting', style=TTDialog.Acknowledge, text=TTLocalizer.DistributedMailboxWaiting, text_wordwrap=15, fadeScreen=1, command=self.__clearDialog)
         return
     elif mode == MailboxGlobals.MAILBOX_MOVIE_READY:
         DistributedMailbox.notify.debug('setMovie: ready')
         if random.random() < 0.5:
             sfx = base.loader.loadSfx('phase_5.5/audio/sfx/mailbox_open_1.mp3')
         else:
             sfx = base.loader.loadSfx('phase_5.5/audio/sfx/mailbox_open_2.mp3')
         sfxTrack = SoundInterval(sfx, node=self.model)
         sfxTrack.start()
         if isLocalToon:
             self.mailboxGui = MailboxScreen.MailboxScreen(self, base.localAvatar, self.mailboxGuiDoneEvent)
             self.mailboxGui.show()
             self.accept(self.mailboxGuiDoneEvent, self.__handleMailboxDone)
         return
     elif mode == MailboxGlobals.MAILBOX_MOVIE_NOT_OWNER:
         DistributedMailbox.notify.debug('setMovie: not owner')
         if isLocalToon:
             self.mailboxDialog = TTDialog.TTDialog(dialogName='MailboxNotOwner', style=TTDialog.Acknowledge, text=TTLocalizer.DistributedMailboxNotOwner, text_wordwrap=15, fadeScreen=1, command=self.__clearDialog)
         return
     else:
         DistributedMailbox.notify.warning('unknown mode in setMovie: %s' % mode)
Beispiel #2
0
    def setMovie(self, mode, avId):
        """
        This is a message from the AI describing a movie between this mailbox
        and a Toon that has approached us.
        """

        # See if this is the local toon
        isLocalToon = (avId == base.localAvatar.doId)

        if isLocalToon:
            DistributedMailbox.notify.debug(
                "setMovie( mode=%d, avId=%d ) called on a local toon" %
                (mode, avId))
        else:
            DistributedMailbox.notify.debug(
                "setMovie( mode=%d, avId=%d ) called on a non-local toon" %
                (mode, avId))

        # This is an old movie in the server ram that has been cleared.
        # Just return and do nothing
        if (mode == MailboxGlobals.MAILBOX_MOVIE_CLEAR):
            DistributedMailbox.notify.debug("setMovie: clear")
            return

        elif (mode == MailboxGlobals.MAILBOX_MOVIE_EXIT):
            # Play one of the two mailbox closing sounds
            if random.random() < 0.5:
                sfx = base.loader.loadSfx(
                    "phase_5.5/audio/sfx/mailbox_close_1.mp3")
            else:
                sfx = base.loader.loadSfx(
                    "phase_5.5/audio/sfx/mailbox_close_2.mp3")
            sfxTrack = SoundInterval(sfx, node=self.model)
            sfxTrack.start()
            DistributedMailbox.notify.debug("setMovie: exit")
            return

        elif (mode == MailboxGlobals.MAILBOX_MOVIE_EMPTY):
            DistributedMailbox.notify.debug("setMovie: empty")
            if isLocalToon:
                self.mailboxDialog = TTDialog.TTDialog(
                    dialogName='MailboxEmpty',
                    style=TTDialog.Acknowledge,
                    text=TTLocalizer.DistributedMailboxEmpty,
                    text_wordwrap=15,
                    fadeScreen=1,
                    command=self.__clearDialog,
                )
            return

        elif (mode == MailboxGlobals.MAILBOX_MOVIE_WAITING):
            DistributedMailbox.notify.debug("setMovie: waiting")
            if isLocalToon:
                self.mailboxDialog = TTDialog.TTDialog(
                    dialogName='MailboxWaiting',
                    style=TTDialog.Acknowledge,
                    text=TTLocalizer.DistributedMailboxWaiting,
                    text_wordwrap=15,
                    fadeScreen=1,
                    command=self.__clearDialog,
                )
            return

        elif (mode == MailboxGlobals.MAILBOX_MOVIE_READY):
            DistributedMailbox.notify.debug("setMovie: ready")
            # Play one of the two mailbox opening sounds
            if random.random() < 0.5:
                sfx = base.loader.loadSfx(
                    "phase_5.5/audio/sfx/mailbox_open_1.mp3")
            else:
                sfx = base.loader.loadSfx(
                    "phase_5.5/audio/sfx/mailbox_open_2.mp3")
            sfxTrack = SoundInterval(sfx, node=self.model)
            sfxTrack.start()
            # If you are local toon, show the mailbox gui
            if isLocalToon:
                self.mailboxGui = MailboxScreen.MailboxScreen(
                    self, base.localAvatar, self.mailboxGuiDoneEvent)
                self.mailboxGui.show()
                self.accept(self.mailboxGuiDoneEvent, self.__handleMailboxDone)
            return

        elif (mode == MailboxGlobals.MAILBOX_MOVIE_NOT_OWNER):
            DistributedMailbox.notify.debug("setMovie: not owner")
            if isLocalToon:
                self.mailboxDialog = TTDialog.TTDialog(
                    dialogName='MailboxNotOwner',
                    style=TTDialog.Acknowledge,
                    text=TTLocalizer.DistributedMailboxNotOwner,
                    text_wordwrap=15,
                    fadeScreen=1,
                    command=self.__clearDialog,
                )
            return

        else:
            DistributedMailbox.notify.warning("unknown mode in setMovie: %s" %
                                              (mode))