예제 #1
0
 def render_dialog(self, title):
     libtcod.console_set_keyboard_repeat(1000, 500)
     libtcod.console_print_frame(self.con, 10, 10, 30, 3, True, libtcod.BKGND_NONE, title)
     line = ''
     while True:
         libtcod.console_print(self.con, 11, 11, ' '.rjust(len(line) + 2, ' '))
         libtcod.console_print(self.con, 11, 11, line + '_')
         libtcod.console_blit(self.con, 10, 10, 30, 3, 0, 10, 10)
         libtcod.console_flush()
         libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS, self.key, self.mouse)
         key = self.key
         if key.c == 27:
             game_input.default_rate()
             return None
         if key.c == 13:
             game_input.default_rate()
             return line
         if key.c == 8:
             line = line[0:len(line) - 1]
         elif key.c != 0:
             line += chr(key.c)
예제 #2
0
 def render_yn_dialog(self, title, warn=False):
     if warn:
         libtcod.console_set_default_foreground(self.con, libtcod.red)
     else:
         libtcod.console_set_default_foreground(self.con, libtcod.white)
     libtcod.console_set_keyboard_repeat(1000, 500)
     libtcod.console_print_frame(self.con, 10, 10, 30, 3, True, libtcod.BKGND_NONE, title)
     line = ''
     #todo - adjust the size of window to match line's size
     while True:
         libtcod.console_print_ex(self.con, 11, 11, libtcod.BKGND_NONE, libtcod.LEFT, ' '.rjust(len(line) + 2, ' '))
         libtcod.console_print_ex(self.con, 11, 11, libtcod.BKGND_NONE, libtcod.LEFT, line + '_')
         libtcod.console_blit(self.con, 10, 10, 30, 3, 0, 10, 10)
         libtcod.console_flush()
         libtcod.sys_check_for_event(libtcod.KEY_PRESSED, self.key, self.mouse)
         key = self.key
         if chr(key.c) == 'y' or chr(key.c) == 'Y' or key.c == 13:
             game_input.default_rate()
             return True
         if chr(key.c) == 'n' or chr(key.c) == 'N' or key.c == 27:
             game_input.default_rate()
             return False