Ejemplo n.º 1
0
def dummy_draw_console(con, x, y, blit_on=0):
    """
    Blits the widget to the console passed as parameter (defaults to
    the root console), with its top-left corner at the specified
    x:y position.
    This is the bare minimum any widget will have to do to draw
    itself.
    """
    # if self.framed:
    #     # draw an old school looking frame around the window \o/
    #     libtcod.console_set_foreground_color(con, self.frame_color)
    #     libtcod.console_print_frame(self.con, 0, 0, self.w, self.h,
    #                                 False, libtcod.BKGND_NONE, self.title)
    # blit any children on the widget's console
    # for child in con.children:
    #     child.display()
    # Blit self
    # !TEMPO!
    if id(con) not in tcod_consoles:
        new_console = libtcod.console_new(con.w, con.h)
        # libtcod.console_set_default_foreground(new_console, libtcod.white)
        # libtcod.console_set_default_background(new_console, libtcod.blue)
        libtcod.console_clear(new_console)
        tcod_consoles[id(con)] = new_console

    tcod_cons = tcod_consoles[id(con)]

    # if con.dirty:
    #     libtcod.console_clear(tcod_cons)
    #     con.dirty = False

    libtcod.console_print_frame(tcod_cons, 0, 0, con.w, con.h,
                                # False, # BACKGROUND_FLAG, title
                                )
    # /TEMPO!

    # for i, msg in enumerate(con.msgs[-(8+offset):-(offset)]):
    offset = 1 # TEMPO
    for i, msg in enumerate(con.last_msgs[-(con.h-2):]):
        libtcod.console_set_default_foreground(tcod_cons,
                                                getattr(colors, msg.col))
        libtcod.console_print_rect(
            tcod_cons, 1, offset, con.w-2, con.h-2, msg.txt
        )
        offset += libtcod.console_get_height_rect(
            tcod_cons, 1, offset, con.w-2, con.h-2, msg.txt
        )

    libtcod.console_blit(tcod_cons, 0, 0, con.w, con.h, blit_on, x, y,)
Ejemplo n.º 2
0
def clear(con=0):
    libtcod.console_clear(con)