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

Function query_arrayvalue

src/botl.c:2746–2781  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2744}
2745
2746staticfn int
2747query_arrayvalue(
2748 const char *querystr,
2749 const char *const *arr,
2750 int arrmin, int arrmax)
2751{
2752 int i, res, ret = arrmin - 1;
2753 winid tmpwin;
2754 anything any;
2755 menu_item *picks = (menu_item *) 0;
2756 int adj = (arrmin > 0) ? 1 : arrmax;
2757 int clr = NO_COLOR;
2758
2759 tmpwin = create_nhwindow(NHW_MENU);
2760 start_menu(tmpwin, MENU_BEHAVE_STANDARD);
2761
2762 for (i = arrmin; i < arrmax; i++) {
2763 if (!arr[i]) /* the array of hunger status values has a gap ...*/
2764 continue; /*... set to Null between Satiated and Hungry */
2765 any = cg.zeroany;
2766 any.a_int = i + adj;
2767 add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE,
2768 clr, arr[i], MENU_ITEMFLAGS_NONE);
2769 }
2770
2771 end_menu(tmpwin, querystr);
2772
2773 res = select_menu(tmpwin, PICK_ONE, &picks);
2774 destroy_nhwindow(tmpwin);
2775 if (res > 0) {
2776 ret = picks->item.a_int - adj;
2777 free((genericptr_t) picks);
2778 }
2779
2780 return ret;
2781}
2782
2783staticfn void
2784status_hilite_add_threshold(int fld, struct hilite_s *hilite)

Callers 1

status_hilite_menu_addFunction · 0.85

Calls 2

add_menuFunction · 0.85
select_menuFunction · 0.85

Tested by

no test coverage detected