Пример #1
0
void draw_sidebar(void)
{
    int flheight = 0, invheight = 0, invwh, flwh;
    int sbwidth = getmaxx(sidebar);
    
    if (!ui_flags.draw_sidebar)
	return;
    
    /* re-create the subwindows every time; they only exist for use by draw_objlist */
    if (objwin)
	delwin(objwin);
    if (invwin)
	delwin(invwin);
    objwin = invwin = NULL;
    
    werase(sidebar);
    if (flooritems && inventory) {
	split_sidebar(&invheight, &flheight);
	draw_sidebar_divider();
    } else if (flooritems)
	flheight = ui_flags.viewheight;
    else
	invheight = ui_flags.viewheight;
    
    if (invheight) {
	wattron(sidebar, A_UNDERLINE);
	mvwprintw(sidebar, 0, 0, "物品:%d/%d负重 (%d/52空间)",
		  player.wt, player.wtcap, player.invslots);
	wattroff(sidebar, A_UNDERLINE);
	
	invwh = invheight-1;
	if (invwh < inv_icount) {
	    invwh--;
	    mvwprintw(sidebar, invheight - 1, 0, "(%d more omitted)",
		      count_omitted_items(inventory, inv_icount, invwh));
	}
	invwin = derwin(sidebar, invwh, sbwidth, 1, 0);
	draw_objlist(invwin, inv_icount, inventory, NULL, PICK_NONE);
    }
    
    if (flheight) {
	wattron(sidebar, A_UNDERLINE);
	mvwaddstr(sidebar, invheight ? invheight + 1 : 0, 0, "这里有东西:");
	wattroff(sidebar, A_UNDERLINE);
	
	flwh = flheight - 1;
	if (flwh < floor_icount) {
	    flwh--;
	    mvwprintw(sidebar, ui_flags.viewheight - 1, 0, "(%d more omitted)",
		      count_omitted_items(flooritems, floor_icount, flwh));
	}
	
	objwin = derwin(sidebar, flwh, sbwidth, invheight ? invheight + 2 : 1, 0);
	draw_objlist(objwin, floor_icount, flooritems, NULL, PICK_NONE);
    }
    
    wnoutrefresh(sidebar);
}
Пример #2
0
void
draw_sidebar(void)
{
    int flheight = 0, invheight = 0, invwh, flwh;
    int viewheight = LINES - (ui_flags.draw_outer_frame_lines ? 2 : 0);

    if (!ui_flags.sidebarwidth)
        return;

    int sbwidth = getmaxx(sidebar);

    /* re-create the subwindows every time; they only exist for use by
       draw_objlist */
    if (objwin)
        delwin(objwin);
    if (invwin)
        delwin(invwin);
    objwin = invwin = NULL;

    werase(sidebar);
    /* Inventory and floor item list sizing: Each list "owns" half the sidebar,
       but will expand into unused space in the other half. If unused space
       remains, the inventory list is expanded to push the floor item list to
       the bottom of the screen. */
    if (flooritems.icount && inventory.icount) {
        invheight = min(inventory.icount + 1, viewheight / 2);
        flheight = min(flooritems.icount + 1, (viewheight - 1) / 2);
        /* if there is need and available space, expand the floor item list up
           */
        if (flooritems.icount + 1 > flheight &&
            invheight < (viewheight + 1) / 2)
            flheight =
                min(flooritems.icount + 1, viewheight - invheight - 1);
        /* assign all unused space to the inventory list whether it is needed
           or not */
        invheight = viewheight - flheight - 1;
        nh_mvwhline(sidebar, invheight, 0, sbwidth);
    } else if (flooritems.icount)
        flheight = viewheight;
    else
        invheight = viewheight;

    if (invheight) {
        wattron(sidebar, A_UNDERLINE);
        mvwaddstr(sidebar, 0, 0, "Inventory:");
        wattroff(sidebar, A_UNDERLINE);

        invwh = invheight - 1;
        if (invwh < inventory.icount) {
            invwh--;
            mvwprintw(sidebar, invheight - 1, 0, "(%d more omitted)",
                      count_omitted_items(&inventory, invwh));
        }
        invwin = derwin(sidebar, invwh, sbwidth, 1, 0);
        draw_objlist(invwin, &inventory, NULL, PICK_NONE);
    }

    if (flheight) {
        wattron(sidebar, A_UNDERLINE);
        mvwaddstr(sidebar, invheight ? invheight + 1 : 0, 0,
                  "Things that are here:");
        wattroff(sidebar, A_UNDERLINE);

        flwh = flheight - 1;
        if (flwh < flooritems.icount) {
            flwh--;
            mvwprintw(sidebar, viewheight - 1, 0, "(%d more omitted)",
                      count_omitted_items(&flooritems, flwh));
        }

        objwin =
            derwin(sidebar, flwh, sbwidth, invheight ? invheight + 2 : 1, 0);
        draw_objlist(objwin, &flooritems, NULL, PICK_NONE);
    }

    wnoutrefresh(sidebar);
}