MCPcopy Create free account
hub / github.com/NetHack/NetHack / display_used_invlets

Function display_used_invlets

src/invent.c:3466–3519  ·  view source on GitHub ↗

* Show what is current using inventory letters. * */

Source from the content-addressed store, hash-verified

3464 *
3465 */
3466staticfn char
3467display_used_invlets(char avoidlet)
3468{
3469 struct obj *otmp;
3470 char ilet, ret = 0;
3471 char *invlet = flags.inv_order;
3472 int n, classcount, invdone = 0, tmpglyph;
3473 glyph_info tmpglyphinfo = nul_glyphinfo;
3474 winid win;
3475 anything any;
3476 menu_item *selected;
3477 int clr = NO_COLOR;
3478
3479 if (gi.invent) {
3480 win = create_nhwindow(NHW_MENU);
3481 start_menu(win, MENU_BEHAVE_STANDARD);
3482 while (!invdone) {
3483 any = cg.zeroany; /* set all bits to zero */
3484 classcount = 0;
3485 for (otmp = gi.invent; otmp; otmp = otmp->nobj) {
3486 ilet = otmp->invlet;
3487 if (ilet == avoidlet)
3488 continue;
3489 if (!flags.sortpack || otmp->oclass == *invlet) {
3490 if (flags.sortpack && !classcount) {
3491 any = cg.zeroany; /* zero */
3492 add_menu_heading(win,
3493 let_to_name(*invlet, FALSE, FALSE));
3494 classcount++;
3495 }
3496 any.a_char = ilet;
3497 tmpglyph = obj_to_glyph(otmp, rn2_on_display_rng);
3498 map_glyphinfo(0, 0, tmpglyph, 0U, &tmpglyphinfo);
3499 add_menu(win, &tmpglyphinfo, &any, ilet, 0,
3500 ATR_NONE, clr, doname(otmp),
3501 MENU_ITEMFLAGS_NONE);
3502 }
3503 }
3504 if (flags.sortpack && *++invlet)
3505 continue;
3506 invdone = 1;
3507 }
3508 end_menu(win, "Inventory letters used:");
3509
3510 n = select_menu(win, PICK_ONE, &selected);
3511 if (n > 0) {
3512 ret = selected[0].item.a_char;
3513 free((genericptr_t) selected);
3514 } else
3515 ret = !n ? '\0' : '\033'; /* cancelled */
3516 destroy_nhwindow(win);
3517 }
3518 return ret;
3519}
3520
3521/*
3522 * Returns the number of unpaid items within the given list. This includes

Callers 1

doorganize_coreFunction · 0.85

Calls 6

add_menu_headingFunction · 0.85
let_to_nameFunction · 0.85
map_glyphinfoFunction · 0.85
add_menuFunction · 0.85
donameFunction · 0.85
select_menuFunction · 0.85

Tested by

no test coverage detected