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

Function choose_disco_sort

src/o_init.c:610–657  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

608#ifndef SFCTOOL
609
610int
611choose_disco_sort(
612 int mode) /* 0 => 'O' cmd, 1 => full discoveries; 2 => class disco */
613{
614 winid tmpwin;
615 menu_item *selected;
616 anything any;
617 int i, n, choice;
618 int clr = NO_COLOR;
619
620 tmpwin = create_nhwindow(NHW_MENU);
621 start_menu(tmpwin, MENU_BEHAVE_STANDARD);
622 any = cg.zeroany; /* zero out all bits */
623 for (i = 0; disco_orders_descr[i]; ++i) {
624 any.a_int = disco_order_let[i];
625 add_menu(tmpwin, &nul_glyphinfo, &any, (char) any.a_int,
626 0, ATR_NONE, clr,
627 disco_orders_descr[i],
628 (disco_order_let[i] == flags.discosort)
629 ? MENU_ITEMFLAGS_SELECTED
630 : MENU_ITEMFLAGS_NONE);
631 }
632 if (mode == 2) {
633 /* called via 'm `' where full alphabetize doesn't make sense
634 (only showing one class so can't span all classes) but the
635 chosen sort will stick and also apply to '\' usage */
636 add_menu_str(tmpwin, "");
637 add_menu_str(tmpwin,
638 "Note: full alphabetical and alphabetical within class");
639 add_menu_str(tmpwin,
640 " are equivalent for single class discovery, but");
641 add_menu_str(tmpwin,
642 " will matter for future use of total discoveries.");
643 }
644 end_menu(tmpwin, "Ordering of discoveries");
645
646 n = select_menu(tmpwin, PICK_ONE, &selected);
647 destroy_nhwindow(tmpwin);
648 if (n > 0) {
649 choice = selected[0].item.a_int;
650 /* skip preselected entry if we have more than one item chosen */
651 if (n > 1 && choice == (int) flags.discosort)
652 choice = selected[1].item.a_int;
653 free((genericptr_t) selected);
654 flags.discosort = choice;
655 }
656 return n;
657}
658
659/* augment obj_typename() with explanation of Japanese item names */
660staticfn char *

Callers 3

optfn_sortdiscoveriesFunction · 0.85
dodiscoveredFunction · 0.85
doclassdiscoFunction · 0.85

Calls 3

add_menuFunction · 0.85
add_menu_strFunction · 0.85
select_menuFunction · 0.85

Tested by

no test coverage detected