コード例 #1
0
 def render_stats_two_column(self, x, y, text1, value, x2, text2, value2, lbl_color, value_color):
     libtcod.console_set_default_foreground(self.panel, self.create_color(lbl_color))
     libtcod.console_print(self.panel, x, y, text1 + ':')
     libtcod.console_print(self.panel, x2, y, text2 + ':')
     libtcod.console_set_default_foreground(self.panel, self.create_color(value_color))
     libtcod.console_print(self.panel, x + len(text1) + 1, y, str(value))
     libtcod.console_print(self.panel, x2 + len(text2) + 1, y,str(value2))
コード例 #2
0
 def render_messages(self, map, player):
     if gl.__lookmode__:
         self.render_tile_description(map, player)
         libtcod.console_blit(self.panel_msg, 0, 0, SCREEN_WIDTH, MSG_PANEL_HEIGHT, 0, 0, MSG_PANEL_Y)
         return
     #print the game messages, one line at a time
     y = 0
     for (line, level) in gl.__msgs__:
         if level < 1 and not gl.__wizard_mode__:
             continue
         libtcod.console_set_default_foreground(self.panel_msg, self.message_colours.get(level, libtcod.white))
         libtcod.console_print(self.panel_msg, 0, y, line.ljust(SCREEN_WIDTH, ' '))
         y += 1
     libtcod.console_blit(self.panel_msg, 0, 0, SCREEN_WIDTH, MSG_PANEL_HEIGHT, 0, 0, MSG_PANEL_Y)
コード例 #3
0
    def render(self):
        libtcod.console_clear(self.console)
        pages = len(self.content) / (self.height - 2)
        pages += 1 if len(self.content) % (self.height - 2) != 0 else 0
        x = 0
        y = 1
        if self.offset:
            libtcod.console_set_default_foreground(self.console, libtcod.dark_crimson)
            libtcod.console_print(self.console, 0, 0, "---  [-][PgDwn] Scroll up ---" .center(self.width))
        for line, rgb, newline in self.content[self.offset:]:
            libtcod.console_set_default_foreground(self.console, rgb)
            libtcod.console_print(self.console, x, y, line)
            if newline:
                x = 0
                y+= 1
            else:
                x += len(line)
        y = self.height - 1
        if pages > 1:
            libtcod.console_set_default_foreground(self.console, libtcod.dark_crimson)
            footer = "---  [+][PgDwn] Scroll down \t Line [%d]/[%d] ---" % (self.offset, len(self.content))
            libtcod.console_print(self.console, 0, y, footer.center(self.width))

        libtcod.console_blit(self.console, 0, 0, self.width, self.height, 0, 0, 0)
        libtcod.console_flush()
コード例 #4
0
    def render_examine(self, player, map):
        libtcod.console_clear(self.con_full)
        _x, _y = self.viewport.look_x, self.viewport.look_y
        if (_x, _y) == self.viewport.playerxy:
            #starting point of view
            libtcod.console_set_default_foreground(self.panel_msg, libtcod.white)
            libtcod.console_print(self.con_full, 1, 0, 'This is you'.ljust(SCREEN_WIDTH, ' '))
            libtcod.console_print(self.con_full, 1, 1, 'Press e to go back to look-around mode'.ljust(SCREEN_WIDTH, ' '))
        else:
            visible = rlfl.has_flag(map.current.fov_map0, (_x, _y), rlfl.CELL_MEMO)
            if not visible:
                libtcod.console_set_default_foreground(self.panel_msg, libtcod.white)
                libtcod.console_print(self.con_full, 1, 0, 'You can\'t see this far'.ljust(SCREEN_WIDTH, ' '))
                libtcod.console_print(self.con_full, 1, 1, 'Press e to go back to look-around mode'.ljust(SCREEN_WIDTH, ' '))
                return

            result = ''
            crit = map.critter_at(_x, _y)
            if crit:
                result +=  getattr(crit, 'description_' + player.time)
            tile_at = map.tile_at(_x, _y)
            result += tile_at.get_full_description(player.time)
            result += '\n\nPress e to go back to look-around mode.'
            libtcod.console_set_default_foreground(self.panel_msg, libtcod.white)
            libtcod.console_print(self.con_full, 0, 0, result.ljust(SCREEN_WIDTH, ' '))
            libtcod.console_blit(self.con_full, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)
            libtcod.console_flush()
コード例 #5
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
コード例 #6
0
    def render_tile_description(self, map, player):
        libtcod.console_clear(self.panel_msg)
        _x, _y = self.viewport.look_x, self.viewport.look_y
        if (_x, _y) == self.viewport.playerxy:
            #starting point of view
            libtcod.console_set_default_foreground(self.panel_msg, libtcod.white)
            libtcod.console_print(self.panel_msg, 0, 0, 'Look-around mode. Use keys to move cursor'.ljust(SCREEN_WIDTH, ' '))
        else:
            visible = rlfl.has_flag(map.current.fov_map0, (_x, _y), rlfl.CELL_MEMO)
            if not visible:
                libtcod.console_set_default_foreground(self.panel_msg, libtcod.white)
                libtcod.console_print(self.panel_msg, 0, 0, 'You can\'t see this far'.ljust(SCREEN_WIDTH, ' '))
                return

            result = ''
            crit = map.critter_at(_x, _y)
            if crit:
                result += 'You see ' + crit.name + '.\n'
            tile_at = map.tile_at(_x, _y)
            result += tile_at.get_view_description()
            result += 'Press e to examine'
            libtcod.console_set_default_foreground(self.panel_msg, libtcod.white)
            libtcod.console_print(self.panel_msg, 0, 0, result.ljust(SCREEN_WIDTH, ' '))
コード例 #7
0
    def render_bar(self, x, y, x2, total_width, value, maximum, bar_color, dim_color, text_color, color_lvls):
        TEXT_PAD = 8
        #this is totaly incorrect! should be total_width/maximum instead
        tick_price = 0.0
        tick_price = float(total_width) / float(maximum)

        libtcod.console_set_default_background(self.panel, dim_color)
        formated_str = "HP: %i/%i" % (value, maximum)
        #if displayed value == 0 - skip rendering bar
        if not maximum:
            return
        libtcod.console_set_default_foreground(self.panel, text_color)
        libtcod.console_print(self.panel, x, y, formated_str)
        libtcod.console_set_default_foreground(self.panel, self.create_color(bar_color[0]))
        libtcod.console_print(self.panel, x2, y, '[' + ''.ljust(total_width, '_') + ']')
        active_ticks = min(int(value * tick_price), total_width)
        severity = 0
        #now choose apropriate color depending on how much value left (compared to maximum)
        for color_lvl in color_lvls:
            if active_ticks <= maximum * color_lvl:
                severity += 1
        #now render the bar on top
        libtcod.console_set_default_foreground(self.panel, self.create_color(bar_color[severity]))
        libtcod.console_print(self.panel, x2 + 1 ,y, '#'.center(active_ticks, '#'))