Exemple #1
0
def input_string(msg=[], pattern="^[a-zA-Z0-9]$", default="", spell=True):
    voice.menu(msg)
    s = default
    while True:
        e = pygame.event.poll()
        if e.type == QUIT:
            sys.exit()
        elif e.type == KEYDOWN:
            pygame.event.clear()
            if e.key in [K_LSHIFT, K_RSHIFT]:
                continue
            if e.key in (K_RETURN, K_KP_ENTER):
                voice.item([s])
                return s
            elif e.key == K_ESCAPE:
                return None
            elif e.key == K_BACKSPACE:
                s = s[:-1]
                voice.item(string_to_msg(s, spell))
            elif re.match(pattern, e.unicode) != None:
                try:
                    c = e.unicode.encode("ascii") # telnetlib doesn't like unicode
                    s += c
                    voice.item(string_to_msg(c) + [9999] + string_to_msg(s, spell))
                except:
                    warning("error reading character from keyboard")
                    voice.item([1003, 9999] + string_to_msg(s, spell))
            else:
                voice.item([1003, 9999] + string_to_msg(s, spell))
        elif e.type == USEREVENT:
            voice.update()
        voice.update() # XXX useful for SAPI
Exemple #2
0
 def _say_choice(self):
     psounds.play_stereo(sounds.get_sound(SELECT_SOUND))
     choice = self.choices[self.choice_index]
     msg = list(choice[0])
     if len(choice) > 2:
         msg +=  mp.COMMA + choice[2]
     voice.item(msg)
Exemple #3
0
def input_string(msg=[], pattern="^[a-zA-Z0-9]$", default="", spell=True):
    voice.menu(msg)
    s = default
    while True:
        e = pygame.event.poll()
        if e.type == QUIT:
            sys.exit()
        elif e.type == KEYDOWN:
            pygame.event.clear()
            if e.key in [K_LSHIFT, K_RSHIFT]:
                continue
            if e.key in (K_RETURN, K_KP_ENTER):
                voice.item([s])
                return s
            elif e.key == K_ESCAPE:
                return None
            elif e.key == K_BACKSPACE:
                s = s[:-1]
                voice.item(string_to_msg(s, spell))
            elif re.match(pattern, e.unicode) != None:
                try:
                    c = e.unicode.encode("ascii") # telnetlib doesn't like unicode
                    s += c
                    voice.item(string_to_msg(c) + [9999] + string_to_msg(s, spell))
                except:
                    warning("error reading character from keyboard")
                    voice.item([1003, 9999] + string_to_msg(s, spell))
            else:
                voice.item([1003, 9999] + string_to_msg(s, spell))
        elif e.type == USEREVENT:
            voice.update()
        voice.update() # XXX useful for SAPI
Exemple #4
0
 def _say_choice(self):
     psounds.play_stereo(sounds.get_sound(SELECT_SOUND))
     choice = self.choices[self.choice_index]
     msg = list(choice[0])
     if len(choice) > 2:
         msg += mp.COMMA + choice[2]
     voice.item(msg)
Exemple #5
0
 def _process_keydown(self, e):
     if e.key == K_TAB and e.mod & KMOD_ALT:
         return
     if e.key in [K_ESCAPE, K_LEFT]:
         self.choice_index = len(self.choices) - 1
         return self._confirm_choice()
     elif e.key == K_TAB and e.mod & KMOD_SHIFT or e.key == K_UP:
         self._clear_choice_characters()
         self._select_next_choice(inc=-1)
     elif e.key in [K_TAB, K_DOWN]:
         self._clear_choice_characters()
         self._select_next_choice()
     elif e.key in (K_RETURN, K_KP_ENTER, K_RIGHT):
         return self._confirm_choice()
     elif e.key == K_F2 and e.mod & KMOD_CTRL:
         toggle_fullscreen()
     elif e.key == K_F1 and e.mod & KMOD_SHIFT or e.key == K_F2:
         voice.item(help_msg("menu", -1))
     elif e.key == K_F1:
         voice.item(help_msg("menu"))
     elif e.key == K_F5:
         voice.previous()
     elif e.key in [K_LALT,K_RALT]:
         voice.next()
     elif e.key == K_F6:
         voice.next(history_only=True)
     elif e.key in [K_HOME, K_KP_PLUS]:
         modify_volume(1)
     elif e.key in [K_END, K_KP_MINUS]:
         modify_volume(-1)
     elif e.key == K_F7:
         if self.server is None:
             voice.item([1029]) # hostile sound
         else:
             msg = input_string(msg=[4288], pattern="^[a-zA-Z0-9 .,'@#$%^&*()_+=?!]$", spell=False)
             if msg:
                 self.server.write_line("say %s" % msg)
     elif e.key == K_BACKSPACE:
         self.choice_characters = self.choice_characters[:-1]
         self._select_next_choice(self.choice_characters)
     elif e.unicode and e.mod & KMOD_SHIFT:
         self.choice_characters = e.unicode.lower()
         self._select_next_choice(self.choice_characters, -1)
     elif e.unicode:
         self.choice_characters += e.unicode
         self._select_next_choice(self.choice_characters)
     elif e.key not in [K_LSHIFT,K_RSHIFT]:
         voice.item([4052])
Exemple #6
0
 def _process_keydown(self, e):
     if e.key in [K_ESCAPE, K_LEFT]:
         self.choice_index = len(self.choices) - 1
         return self._confirm_choice()
     elif e.key == K_TAB and e.mod & KMOD_SHIFT or e.key == K_UP:
         self._select_next_choice(inc=-1)
     elif e.key in [K_TAB, K_DOWN]:
         self._select_next_choice()
     elif e.key in (K_RETURN, K_KP_ENTER, K_RIGHT):
         return self._confirm_choice()
     elif e.key == K_F2 and e.mod & KMOD_CTRL:
         toggle_fullscreen()
     elif e.key == K_F1 and e.mod & KMOD_SHIFT or e.key == K_F2:
         voice.item(help_msg("menu", -1))
     elif e.key == K_F1:
         voice.item(help_msg("menu"))
     elif e.key == K_F5:
         voice.previous()
     elif e.key in [K_LALT, K_RALT]:
         voice.next()
     elif e.key == K_F6:
         voice.next(history_only=True)
     elif e.key in [K_HOME, K_KP_PLUS]:
         modify_volume(1)
     elif e.key in [K_END, K_KP_MINUS]:
         modify_volume(-1)
     elif e.key == K_F7:
         if self.server is None:
             voice.item(mp.BEEP)
         else:
             msg = input_string(msg=mp.ENTER_MESSAGE,
                                pattern="^[a-zA-Z0-9 .,'@#$%^&*()_+=?!]$",
                                spell=False)
             if msg:
                 self.server.write_line("say %s" % msg)
     elif e.unicode and e.mod & KMOD_SHIFT:
         self._select_next_choice(e.unicode, -1)
     elif e.unicode:
         self._select_next_choice(e.unicode)
     elif e.key not in [K_LSHIFT, K_RSHIFT]:
         voice.item(mp.SELECT_AND_CONFIRM_EXPLANATION)
Exemple #7
0
 def _process_keydown(self, e):
     if e.key == K_TAB and e.mod & KMOD_ALT:
         return
     if e.key in [K_ESCAPE, K_LEFT]:
         self.choice_index = len(self.choices) - 1
         return self._confirm_choice()
     elif e.key == K_TAB and e.mod & KMOD_SHIFT or e.key == K_UP:
         self._select_next_choice(inc=-1)
     elif e.key in [K_TAB, K_DOWN]:
         self._select_next_choice()
     elif e.key in (K_RETURN, K_KP_ENTER, K_RIGHT):
         return self._confirm_choice()
     elif e.key == K_F2 and e.mod & KMOD_CTRL:
         toggle_fullscreen()
     elif e.key == K_F1 and e.mod & KMOD_SHIFT or e.key == K_F2:
         voice.item(help_msg("menu", -1))
     elif e.key == K_F1:
         voice.item(help_msg("menu"))
     elif e.key == K_F5:
         voice.previous()
     elif e.key in [K_LALT,K_RALT]:
         voice.next()
     elif e.key == K_F6:
         voice.next(history_only=True)
     elif e.key in [K_HOME, K_KP_PLUS]:
         modify_volume(1)
     elif e.key in [K_END, K_KP_MINUS]:
         modify_volume(-1)
     elif e.key == K_F7:
         if self.server is None:
             voice.item([1029]) # hostile sound
         else:
             msg = input_string(msg=[4288], pattern="^[a-zA-Z0-9 .,'@#$%^&*()_+=?!]$", spell=False)
             if msg:
                 self.server.write_line("say %s" % msg)
     elif e.unicode and e.mod & KMOD_SHIFT:
         self._select_next_choice(e.unicode, -1)
     elif e.unicode:
         self._select_next_choice(e.unicode)
     elif e.key not in [K_LSHIFT,K_RSHIFT]:
         voice.item([4052])
Exemple #8
0
 def _say_choice(self):
     voice.item(self.choices[self.choice_index][0])
Exemple #9
0
 def _say_choice(self):
     psounds.play_stereo(sounds.get_sound(6115))
     voice.item(self.choices[self.choice_index][0])
Exemple #10
0
 def _countdown(self):
     voice.important(mp.THE_GAME_WILL_START)
     for n in [5, 4, 3, 2, 1, 0]:
         voice.item(nb2msg(n))
         time.sleep(1)
     pygame.event.clear(KEYDOWN)
Exemple #11
0
 def _countdown(self):
     voice.important(mp.THE_GAME_WILL_START)
     for n in [5, 4, 3, 2, 1, 0]:
         voice.item(nb2msg(n))
         time.sleep(1)
     pygame.event.clear(KEYDOWN)
Exemple #12
0
 def _countdown(self):
     voice.important([4062]) # "the game starts in 5 seconds"
     for n in [5, 4, 3, 2, 1, 0]:
         voice.item(nb2msg(n))
         time.sleep(1)
     pygame.event.clear(KEYDOWN)
Exemple #13
0
 def _countdown(self):
     voice.important([4062])  # "the game starts in 5 seconds"
     for n in [5, 4, 3, 2, 1, 0]:
         voice.item(nb2msg(n))
         time.sleep(1)
     pygame.event.clear(KEYDOWN)
Exemple #14
0
 def _say_choice(self):
     psounds.play_stereo(sounds.get_sound(6115))
     voice.item(self.choices[self.choice_index][0])
Exemple #15
0
 def _say_choice(self):
     voice.item(self.choices[self.choice_index][0])