returns -1 if cancelled via ESC */
| 2715 | |
| 2716 | /* returns -1 if cancelled via ESC */ |
| 2717 | int |
| 2718 | set_vanq_order(boolean for_vanq) |
| 2719 | { |
| 2720 | winid tmpwin; |
| 2721 | menu_item *selected; |
| 2722 | anything any; |
| 2723 | char buf[BUFSZ]; |
| 2724 | const char *desc; |
| 2725 | int i, n, choice, |
| 2726 | clr = NO_COLOR; |
| 2727 | |
| 2728 | tmpwin = create_nhwindow(NHW_MENU); |
| 2729 | start_menu(tmpwin, MENU_BEHAVE_STANDARD); |
| 2730 | any = cg.zeroany; /* zero out all bits */ |
| 2731 | for (i = 0; i < SIZE(vanqorders); i++) { |
| 2732 | if (i == VANQ_ALPHA_MIX || i == VANQ_MCLS_HTOL) /* skip these */ |
| 2733 | continue; |
| 2734 | /* suppress some orderings if this menu if for 'm #genocided' */ |
| 2735 | if (!for_vanq && (i == VANQ_COUNT_H_L || i == VANQ_COUNT_L_H)) |
| 2736 | continue; |
| 2737 | desc = vanqorders[i][2]; |
| 2738 | /* unique monsters can't be genocided so "alpha, unique separate" |
| 2739 | and "alpha, unique intermixed" are confusing descriptions when |
| 2740 | this menu is for #genocided rather than for #vanquished */ |
| 2741 | if (!for_vanq && i == VANQ_ALPHA_SEP) |
| 2742 | desc = "alphabetically"; |
| 2743 | any.a_int = i + 1; |
| 2744 | add_menu(tmpwin, &nul_glyphinfo, &any, *vanqorders[i][0], 0, |
| 2745 | ATR_NONE, clr, desc, |
| 2746 | (i == flags.vanq_sortmode) ? MENU_ITEMFLAGS_SELECTED |
| 2747 | : MENU_ITEMFLAGS_NONE); |
| 2748 | } |
| 2749 | Sprintf(buf, "Sort order for %s", |
| 2750 | for_vanq ? "vanquished monster counts (also genocided types)" |
| 2751 | : "genocided monster types (also vanquished counts)"); |
| 2752 | end_menu(tmpwin, buf); |
| 2753 | |
| 2754 | n = select_menu(tmpwin, PICK_ONE, &selected); |
| 2755 | destroy_nhwindow(tmpwin); |
| 2756 | if (n > 0) { |
| 2757 | choice = selected[0].item.a_int - 1; |
| 2758 | /* skip preselected entry if we have more than one item chosen */ |
| 2759 | if (n > 1 && choice == flags.vanq_sortmode) |
| 2760 | choice = selected[1].item.a_int - 1; |
| 2761 | free((genericptr_t) selected); |
| 2762 | flags.vanq_sortmode = choice; |
| 2763 | } |
| 2764 | return (n < 0) ? -1 : flags.vanq_sortmode; |
| 2765 | } |
| 2766 | |
| 2767 | /* #vanquished command */ |
| 2768 | int |
no test coverage detected