Ejemplo n.º 1
0
/** Dumps an object as list item. */
void
dump_list_item_object(struct obj *obj)
{
#ifdef DUMP_LOG
    if (dump_fp)
        fprintf(dump_fp, "  %s\n", doname(obj));
    if (html_dump_fp) {
        const char* str = doname(obj);
        char *link = html_link(dump_typename(obj->otyp), str);
#ifdef MENU_COLOR
# ifdef TTY_GRAPHICS
        int color;
        int attr;
        if (iflags.use_menu_color &&
                get_menu_coloring(str, &color, &attr)) {
            fprintf(html_dump_fp, "<li class=\"nh_color_%d\">%s</li>\n", color, link);
        } else
# endif
#endif
            fprintf(html_dump_fp, "<li>%s</li>\n", link);
    }
#endif
}
Ejemplo n.º 2
0
/** Dumps an object from the inventory. */
void
dump_object(const const char c, const struct obj *obj, const char *str)
{
#ifdef DUMP_LOG
    char *starting_inventory = obj->was_in_starting_inventory ? "*" : "";
    if (dump_fp)
        fprintf(dump_fp, "  %c - %s%s\n", c, str, starting_inventory);
    if (html_dump_fp) {
        char *link = html_link(dump_typename(obj->otyp), str);
#ifdef MENU_COLOR
# ifdef TTY_GRAPHICS
        int color;
        int attr;
        if (iflags.use_menu_color &&
                get_menu_coloring(str, &color, &attr)) {
            fprintf(html_dump_fp, "<span class=\"nh_color_%d\"><span class=\"nh_item_letter\">%c</span> - %s</span>%s<br />\n", color, c, link, starting_inventory);
        } else
# endif
#endif
            fprintf(html_dump_fp, "<span class=\"nh_item_letter\">%c</span> - %s%s<br />\n", c, link, starting_inventory);
    }
#endif
}
Ejemplo n.º 3
0
static void menu_display_page(nhmenu *menu, WINDOW *win, int page_num)
{
    nhmenu_item *menu_item_ptr;
    int count, curletter, entry_cols, start_col, num_lines, footer_x;
    boolean first_accel = TRUE;
#ifdef MENU_COLOR
    int color = NO_COLOR;
    int attr = A_NORMAL;
    boolean menu_color = FALSE;
#endif /* MENU_COLOR */
    
    /* Cycle through entries until we are on the correct page */

    menu_item_ptr = menu->entries;
    
    while (menu_item_ptr != NULL)
    {
        if (menu_item_ptr->page_num == page_num)
        {
            break;
        }
        menu_item_ptr = menu_item_ptr->next_item;
    }
    
    if (menu_item_ptr == NULL)  /* Page not found */
    {
        panic("menu_display_page: attempt to display nonexistant page");
    }

    werase(win);

    if (strlen(menu->prompt) > 0)
    {
        num_lines = curses_num_lines(menu->prompt, menu->width);
        
        for (count = 0; count < num_lines; count++)
        {
            mvwprintw(win, count + 1, 1, "%s",
             curses_break_str(menu->prompt, menu->width, count + 1));
        }
    }

    /* Display items for current page */
    
    while (menu_item_ptr != NULL)
    {
        if (menu_item_ptr->page_num != page_num)
        {
            break;
        }
        if (menu_item_ptr->identifier.a_void != NULL)
        {
            if (menu_item_ptr->accelerator != 0)
            {
                curletter = menu_item_ptr->accelerator;
            }
            else
            {
                if (first_accel)
                {
                    curletter = menu_get_accel(TRUE);
                    first_accel = FALSE;
                    if (!menu->reuse_accels && (menu->num_pages > 1))
                    {
                        menu->reuse_accels = TRUE;
                    }
                }
                else
                {
                    curletter = menu_get_accel(FALSE);
                }
                menu_item_ptr->accelerator = curletter;
            }

            if (menu_item_ptr->selected)
            {
                curses_toggle_color_attr(win, HIGHLIGHT_COLOR, A_REVERSE, ON);
                mvwaddch(win, menu_item_ptr->line_num + 1, 1, '<');
                mvwaddch(win, menu_item_ptr->line_num + 1, 2, curletter);
                mvwaddch(win, menu_item_ptr->line_num + 1, 3, '>');
                curses_toggle_color_attr(win, HIGHLIGHT_COLOR, A_REVERSE, OFF);
            }
            else
            {
                curses_toggle_color_attr(win, HIGHLIGHT_COLOR, NONE, ON);
                mvwaddch(win, menu_item_ptr->line_num + 1, 2, curletter);
                curses_toggle_color_attr(win, HIGHLIGHT_COLOR, NONE, OFF);
                mvwprintw(win, menu_item_ptr->line_num + 1, 3, ") ");
            }
        }
#ifdef MENU_COLOR
		if (iflags.use_menu_color && iflags.use_color &&
		    (menu_color = get_menu_coloring
		 ((char *)menu_item_ptr->str, &color, &attr)))
		{
		    if (color != NO_COLOR)
		    {
                curses_toggle_color_attr(win, color, NONE, ON);
		    }
    		if (attr != A_NORMAL)
    		{
    		    menu_item_ptr->attr = menu_item_ptr->attr|attr;
    		}
		}
#endif /* MENU_COLOR */
        curses_toggle_color_attr(win, NONE, menu_item_ptr->attr, ON);
        entry_cols = menu->width;
        start_col = 1;

        if (menu_item_ptr->identifier.a_void != NULL)
        {
            entry_cols -= 4;
            start_col += 4;
        }        
        
        num_lines = curses_num_lines(menu_item_ptr->str, entry_cols);
        
        for (count = 0; count < num_lines; count++)
        {
            if (strlen(menu_item_ptr->str) > 0)
            {
                mvwprintw(win, menu_item_ptr->line_num + count + 1,
                 start_col, "%s", curses_break_str(menu_item_ptr->str,
                 entry_cols, count + 1));
             }
        }
#ifdef MENU_COLOR
	if (menu_color && (color != NO_COLOR))
    {
        curses_toggle_color_attr(win, color, NONE, OFF);
    }
#endif /* MENU_COLOR */
        curses_toggle_color_attr(win, NONE, menu_item_ptr->attr, OFF);
        menu_item_ptr = menu_item_ptr->next_item;
    }

    if (menu->num_pages > 1)
    {
        footer_x = menu->width - strlen("<- (Page X of Y) ->");
        if (menu->num_pages > 9)    /* Unlikely */
        {
            footer_x -= 2;
        }
        mvwprintw(win, menu->height, footer_x + 3, "(Page %d of %d)",
         page_num, menu->num_pages);
        if (page_num != 1)
        {
            curses_toggle_color_attr(win, HIGHLIGHT_COLOR, NONE, ON);
            mvwaddstr(win, menu->height, footer_x, "<=");
            curses_toggle_color_attr(win, HIGHLIGHT_COLOR, NONE, OFF);
        }
        if (page_num != menu->num_pages)
        {
            curses_toggle_color_attr(win, HIGHLIGHT_COLOR, NONE, ON);
            mvwaddstr(win, menu->height, menu->width - 2, "=>");        
            curses_toggle_color_attr(win, HIGHLIGHT_COLOR, NONE, OFF);
        }
    }
    curses_toggle_color_attr(win, DIALOG_BORDER_COLOR, NONE, ON);
    box(win, 0, 0);
    curses_toggle_color_attr(win, DIALOG_BORDER_COLOR, NONE, OFF);
    wrefresh(win);
}