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

Function display_pickinv

src/invent.c:3056–3114  ·  view source on GitHub ↗

* Internal function used by display_inventory and getobj that can display * inventory and return a count as well as a letter. */

Source from the content-addressed store, hash-verified

3054 * inventory and return a count as well as a letter.
3055 */
3056staticfn char
3057display_pickinv(
3058 const char *lets, /* non-compacted list of invlet values */
3059 const char *xtra_choice, /* non-object "bare hands" or "fingers" */
3060 const char *query, /* optional; prompt string for menu */
3061 boolean allowxtra, /* hands are allowed (maybe alternate) choice */
3062 boolean want_reply, /* True: select an item, False: just display */
3063 long *out_cnt) /* optional; count player entered when selecting an item */
3064{
3065 static const char /* potential entries for perm_invent window */
3066 not_carrying_anything[] = "Not carrying anything",
3067 not_using_anything[] = "Not using any items",
3068 only_carrying_gold[] = "Only carrying gold";
3069 struct obj *otmp, wizid_fakeobj, inuse_fakeobj;
3070 char ilet, ret, *formattedobj;
3071 const char *invlet = flags.inv_order;
3072 int n, classcount, inusecount = 0;
3073 winid win; /* windows being used */
3074 anything any;
3075 menu_item *selected;
3076 unsigned sortflags;
3077 Loot *sortedinvent, *srtinv;
3078 int8_t prevorderclass;
3079 boolean (*filter)(struct obj *) = (boolean (*)(OBJ_P)) 0;
3080 boolean wizid = (wizard && iflags.override_ID), gotsomething = FALSE;
3081 int clr = NO_COLOR, menu_behavior = MENU_BEHAVE_STANDARD;
3082 boolean show_gold = TRUE, inuse_only = FALSE, skipped_gold = FALSE,
3083 doing_perm_invent = FALSE, save_flags_sortpack,
3084 usextra = (xtra_choice && allowxtra);
3085
3086 if (lets && !*lets)
3087 lets = 0; /* simplify tests: (lets) instead of (lets && *lets) */
3088
3089#ifdef DUMPLOG
3090 if (iflags.in_dumplog) {
3091 win = 0; /* passed to dump_putstr() which ignores it... */
3092 } else
3093#endif
3094 if (lets || usextra || wizid || want_reply
3095#ifdef TTY_PERM_INVENT
3096 /*|| !gi.in_sync_perminvent*/
3097#endif
3098 || WIN_INVEN == WIN_ERR) {
3099 /* partial inventory in perm_invent setting; don't operate on
3100 full inventory window, use an alternate one instead; create
3101 the first time needed and keep it for re-use as needed later */
3102 if (gc.cached_pickinv_win == WIN_ERR)
3103 gc.cached_pickinv_win = create_nhwindow(NHW_MENU);
3104 win = gc.cached_pickinv_win;
3105 if (flags.sortloot == 'i')
3106 inuse_only = TRUE;
3107 } else {
3108 win = WIN_INVEN;
3109 menu_behavior = MENU_BEHAVE_PERMINV;
3110 prepare_perminvent(win);
3111 show_gold = ((wri_info.fromcore.invmode & (enum inv_modes) InvShowGold) != 0);
3112 inuse_only = ((wri_info.fromcore.invmode & (enum inv_modes) InvInUse) != 0);
3113 doing_perm_invent = TRUE;

Callers 3

getobjFunction · 0.85
display_inventoryFunction · 0.85
repopulate_perminventFunction · 0.85

Calls 1

prepare_perminventFunction · 0.85

Tested by

no test coverage detected