Example #1
0
def render_messages():
    tcod.console_print_rect(panel,
                            22,
                            1,
                            SCREEN_WIDTH - 22,
                            SCREEN_HEIGHT - MAP_HEIGHT,
                            fmt="\n".join(messages))
def test_console_printing(console, fg, bg):
    libtcodpy.console_set_background_flag(console,
                                          libtcodpy.BKGND_SET)
    assert (libtcodpy.console_get_background_flag(console) ==
                     libtcodpy.BKGND_SET)

    libtcodpy.console_set_alignment(console, libtcodpy.LEFT)
    assert (libtcodpy.console_get_alignment(console) ==
                     libtcodpy.LEFT)

    libtcodpy.console_print(console, 0, 0, 'print')
    libtcodpy.console_print_ex(console, 0, 0, libtcodpy.BKGND_SET,
                               libtcodpy.LEFT, 'print ex')

    assert (libtcodpy.console_print_rect(
        console, 0, 0, 8, 8, 'print rect') > 0
        )
    assert (libtcodpy.console_print_rect_ex(
        console, 0, 0, 8, 8, libtcodpy.BKGND_SET, libtcodpy.LEFT,
        'print rect ex') > 0
        )
    assert (libtcodpy.console_get_height_rect(
        console, 0, 0, 8, 8, 'get height') > 0
        )

    libtcodpy.console_set_color_control(libtcodpy.COLCTRL_1, fg, bg)
Example #3
0
def test_console_printing(console, fg, bg):
    libtcodpy.console_set_background_flag(console,
                                          libtcodpy.BKGND_SET)
    assert (libtcodpy.console_get_background_flag(console) ==
                     libtcodpy.BKGND_SET)

    libtcodpy.console_set_alignment(console, libtcodpy.LEFT)
    assert (libtcodpy.console_get_alignment(console) ==
                     libtcodpy.LEFT)

    libtcodpy.console_print(console, 0, 0, 'print')
    libtcodpy.console_print_ex(console, 0, 0, libtcodpy.BKGND_SET,
                               libtcodpy.LEFT, 'print ex')

    assert (libtcodpy.console_print_rect(
        console, 0, 0, 8, 8, 'print rect') > 0
        )
    assert (libtcodpy.console_print_rect_ex(
        console, 0, 0, 8, 8, libtcodpy.BKGND_SET, libtcodpy.LEFT,
        'print rect ex') > 0
        )
    assert (libtcodpy.console_get_height_rect(
        console, 0, 0, 8, 8, 'get height') > 0
        )

    libtcodpy.console_set_color_control(libtcodpy.COLCTRL_1, fg, bg)
    def _render_details_box(self, species, status):
        """
            If a pokemon has been selected then this is called to display a 
            box with the specific details as an overlay on top of the pokedex.
        """
        libtcod.console_set_default_foreground(self.console, settings.POKEDEX_LINE_COLOR)
        libtcod.console_print_frame(self.console, 19, 15, 43, 16)  # TODO: Generalise to widths
        
        libtcod.console_print(self.console, 23, 16, u"No. {0.pokedex_number:0=3d}  {0.name}".format(species))

        if status == 2:
            libtcod.console_print(self.console, 23, 17, u"  {0.genus} Pokemon".format(species))
            libtcod.console_print(self.console, 23, 18, u"Type(s): {0}".format(', '.join(str(t) for t in species.types)))
            libtcod.console_print(self.console, 23, 19, "Height: {0}".format(species.imperial_height_str()))
            libtcod.console_print(self.console, 23, 20, "Weight: {0}".format(species.imperial_weight_str()))
            
            libtcod.console_print_rect(self.console, 20, 22, 41, 14, species.flavor_text)
        elif status == 1:
            libtcod.console_print(self.console, 23, 17, "  ????? Pokemon".format(species))
            libtcod.console_print(self.console, 23, 18, "Type(s): ?????")
            libtcod.console_print(self.console, 23, 19, "Height: ??'??\"")
            libtcod.console_print(self.console, 23, 20, "Weight: ????.? lbs.")
Example #5
0
def menu(header, options, width):
    if len(options) > 26:
        raise ValueError("Can't have more than 26 options in popup menu")
    fmt = "\n".join([header.center(width)+"\n"] +
                    options +
                    ["\n" + "--- press space to continue ---".center(width)])
    height = len(fmt.splitlines()) + 3
    popup = tcod.console_new(width, height)
    tcod.console_set_default_background(popup, (0, 0, 20))
    tcod.console_clear(popup)
    tcod.console_print_rect(popup, 1, 1, width+2, height+2, fmt=fmt)
    tcod.console_blit(src=popup, x=0, y=0,
                      w=width+2, h=height,
                      dst=root,
                      xdst=SCREEN_WIDTH//2-width//2,
                      ydst= 0, # SCREEN_HEIGHT//2-height//2,
                      ffade=1.0, bfade=0.8)
    tcod.console_flush()
    key = tcod.console_wait_for_keypress(flush=True)
    while key.c != 32:  # Space
        key = tcod.console_wait_for_keypress(flush=True)
    tcod.console_clear(popup)
Example #6
0
 def write_rect(self, x, y, w, h, fmt):
     xstr = make_colored_string(fmt)
     tcod.console_print_rect(self._c, x, y, w, h, xstr)
Example #7
0
 def write_rect(self, x, y, w, h, fmt):
     xstr = make_colored_string(fmt)
     tcod.console_print_rect(self._c, x, y, w, h, xstr)