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

Function handler_sortloot

src/options.c:6166–6203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6164}
6165
6166staticfn int
6167handler_sortloot(void)
6168{
6169 winid tmpwin;
6170 anything any;
6171 int i, n;
6172 const char *sortl_name;
6173 menu_item *sortl_pick = (menu_item *) 0;
6174 int clr = NO_COLOR;
6175
6176 tmpwin = create_nhwindow(NHW_MENU);
6177 start_menu(tmpwin, MENU_BEHAVE_STANDARD);
6178 any = cg.zeroany;
6179 for (i = 0; i < SIZE(sortltype); i++) {
6180 sortl_name = sortltype[i];
6181 any.a_char = *sortl_name;
6182 add_menu(tmpwin, &nul_glyphinfo, &any, *sortl_name,
6183 0, ATR_NONE, clr,
6184 sortl_name, (flags.sortloot == *sortl_name)
6185 ? MENU_ITEMFLAGS_SELECTED
6186 : MENU_ITEMFLAGS_NONE);
6187 }
6188 end_menu(tmpwin, "Select loot sorting type:");
6189 n = select_menu(tmpwin, PICK_ONE, &sortl_pick);
6190 if (n > 0) {
6191 char c = sortl_pick[0].item.a_char;
6192
6193 if (n > 1 && c == flags.sortloot)
6194 c = sortl_pick[1].item.a_char;
6195 flags.sortloot = c;
6196 /* changing to or from 'f' affects persistent inventory display */
6197 if (iflags.perm_invent)
6198 update_inventory();
6199 free((genericptr_t) sortl_pick);
6200 }
6201 destroy_nhwindow(tmpwin);
6202 return optn_ok;
6203}
6204
6205staticfn int
6206handler_whatis_coord(void)

Callers 1

optfn_sortlootFunction · 0.85

Calls 3

add_menuFunction · 0.85
select_menuFunction · 0.85
update_inventoryFunction · 0.85

Tested by

no test coverage detected