Changeset 217
- Timestamp:
- 06/24/07 01:54:38 (2 years ago)
- Files:
-
- trunk/src/cmd4.c (modified) (24 diffs)
- trunk/src/externs.h (modified) (1 diff)
- trunk/src/squelch.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/cmd4.c
r193 r217 210 210 byte c, byte attr_top, byte char_left); 211 211 212 static void dump_pref_file(void (*dump)(FILE*), const char *title );212 static void dump_pref_file(void (*dump)(FILE*), const char *title, int row); 213 213 214 214 /* … … 2158 2158 case 'T': 2159 2159 case '5': 2160 case '\n': 2161 case '\r': 2160 2162 case '\xff': 2161 2163 { … … 2174 2176 } 2175 2177 2176 static const menu_iter options_ iter =2178 static const menu_iter options_toggle_iter = 2177 2179 { 2178 2180 0, … … 2221 2223 cx = menu_select(menu, &cursor_pos, EVT_MOVE); 2222 2224 2223 if (cx. type == EVT_BACK || cx.key == ESCAPE)2225 if (cx.key == ESCAPE) 2224 2226 break; 2225 2227 else if (cx.type == EVT_MOVE) … … 2352 2354 2353 2355 /* Toggle */ 2354 if ((ke.key == '5') || (ke.key == 't') || ( (ke.key == '\xff') && (ke.index)))2356 if ((ke.key == '5') || (ke.key == 't') || (ke.key == '\n') || (ke.key == '\r') || ((ke.key == '\xff') && (ke.index))) 2355 2357 { 2356 2358 /* Hack -- ignore the main window */ … … 2575 2577 * Comments are generated automatically 2576 2578 */ 2577 static void dump_pref_file(void (*dump)(FILE*), const char *title )2579 static void dump_pref_file(void (*dump)(FILE*), const char *title, int row) 2578 2580 { 2579 2581 char ftmp[80]; 2580 2582 char buf[1025]; 2581 2583 FILE *fff; 2582 2583 int row = 15;2584 2584 2585 2585 /* Prompt */ … … 3022 3022 3023 3023 if (ESCAPE == c.key) break; 3024 if (c.key == ARROW_LEFT || c.key == ARROW_RIGHT) continue; 3024 3025 evt = macro_actions[cursor].id; 3025 3026 … … 3036 3037 { 3037 3038 /* Dump the macros */ 3038 (void)dump_pref_file(macro_dump, "Dump Macros" );3039 (void)dump_pref_file(macro_dump, "Dump Macros", 15); 3039 3040 3040 3041 break; … … 3138 3139 { 3139 3140 /* Dump the keymaps */ 3140 (void)dump_pref_file(keymap_dump, "Dump Keymaps" );3141 (void)dump_pref_file(keymap_dump, "Dump Keymaps", 15); 3141 3142 break; 3142 3143 } … … 3514 3515 break; 3515 3516 3517 if (key.key == ARROW_LEFT || key.key == ARROW_RIGHT) 3518 continue; 3519 3516 3520 assert(cursor >= 0 && cursor < visual_menu.count); 3517 3521 … … 3528 3532 else if (evt == DUMP_MON) 3529 3533 { 3530 dump_pref_file(dump_monsters, "Dump Monster attr/chars" );3534 dump_pref_file(dump_monsters, "Dump Monster attr/chars", 15); 3531 3535 } 3532 3536 3533 3537 else if (evt == DUMP_OBJ) 3534 3538 { 3535 dump_pref_file(dump_objects, "Dump Object attr/chars" );3539 dump_pref_file(dump_objects, "Dump Object attr/chars", 15); 3536 3540 } 3537 3541 3538 3542 else if (evt == DUMP_FEAT) 3539 3543 { 3540 dump_pref_file(dump_features, "Dump Feature attr/chars" );3544 dump_pref_file(dump_features, "Dump Feature attr/chars", 15); 3541 3545 } 3542 3546 … … 3544 3548 else if (evt == DUMP_FLAV) 3545 3549 { 3546 dump_pref_file(dump_flavors, "Dump Flavor attr/chars" );3550 dump_pref_file(dump_flavors, "Dump Flavor attr/chars", 15); 3547 3551 } 3548 3552 … … 3686 3690 /* Done */ 3687 3691 if (key.key == ESCAPE) break; 3692 3693 if (key.key == ARROW_RIGHT || key.key == ARROW_LEFT) continue; 3694 3688 3695 evt = color_events[cursor].id; 3689 3696 … … 3708 3715 else if (evt == DUMP_COL) 3709 3716 { 3710 dump_pref_file(dump_colors, "Dump Colors" );3717 dump_pref_file(dump_colors, "Dump Colors", 15); 3711 3718 } 3712 3719 … … 3903 3910 static void do_dump_options(void *unused, const char *title) 3904 3911 { 3905 dump_pref_file(option_dump, title );3912 dump_pref_file(option_dump, title, 20); 3906 3913 } 3907 3914 … … 3915 3922 * XXX Too many entries. 3916 3923 */ 3917 static menu_item option_actions [] = 3918 { 3919 {{0, "Interface options", do_cmd_options_aux, (void*)0}, '1'}, 3920 {{0, "Display options", do_cmd_options_aux, (void*)1}, '2'}, 3921 {{0, "Warning options", do_cmd_options_aux, (void*)2}, '3'}, 3922 {{0, "Birth (Difficulty) options", do_cmd_options_aux, (void*)3}, '4'}, 3923 {{0, "Cheat options", do_cmd_options_aux, (void*)4}, '5'}, 3924 {{0, 0, 0, 0}}, /* Load and append */ 3925 {{0, "Subwindow display settings", (action_f) do_cmd_options_win, 0}, 'W'}, 3926 {{0, "Item squelch and Autoinscribe settings", (action_f) do_cmd_options_item, 0}, 'S'}, 3927 {{0, "Set base delay factor", (action_f) do_cmd_delay, 0}, 'D'}, 3928 {{0, "Set hitpoint warning", (action_f) do_cmd_hp_warn, 0}, 'H'}, 3929 {{0, 0, 0,}, 0}, /* Special choices */ 3930 {{0, "Load a user pref file", (action_f) do_cmd_pref_file_hack, (void*)20}, 'L'}, 3931 {{0, "Dump options", do_dump_options, 0}, 'A'}, 3932 {{0, 0, 0,}, 0}, /* Interact with */ 3933 {{0, "Interact with macros (advanced)", (action_f) do_cmd_macros, 0}, 'M'}, 3934 {{0, "Interact with visuals (advanced)", (action_f) do_cmd_visuals, 0}, 'V'}, 3935 {{0, "Interact with colours (advanced)", (action_f) do_cmd_colors, 0}, 'C'}, 3924 3925 static event_action option_actions [] = 3926 { 3927 {'1', "Interface options", do_cmd_options_aux, (void*)0}, 3928 {'2', "Display options", do_cmd_options_aux, (void*)1}, 3929 {'3', "Warning options", do_cmd_options_aux, (void*)2}, 3930 {'4', "Birth (Difficulty) options", do_cmd_options_aux, (void*)3}, 3931 {'5', "Cheat options", do_cmd_options_aux, (void*)4}, 3932 {0, 0, 0, 0}, /* Load and append */ 3933 {'W', "Subwindow display settings", (action_f) do_cmd_options_win, 0}, 3934 {'S', "Item squelch and Autoinscribe settings", (action_f) do_cmd_options_item, 0}, 3935 {'D', "Set base delay factor", (action_f) do_cmd_delay, 0}, 3936 {'H', "Set hitpoint warning", (action_f) do_cmd_hp_warn, 0}, 3937 {0, 0, 0,}, /* Special choices */ 3938 {'L', "Load a user pref file", (action_f) do_cmd_pref_file_hack, (void*)20}, 3939 {'A', "Dump options", do_dump_options, 0}, 3940 {0, 0, 0,}, /* Interact with */ 3941 {'M', "Interact with macros (advanced)", (action_f) do_cmd_macros, 0}, 3942 {'V', "Interact with visuals (advanced)", (action_f) do_cmd_visuals, 0}, 3943 {'C', "Interact with colours (advanced)", (action_f) do_cmd_colors, 0}, 3936 3944 }; 3937 3945 3938 3946 static menu_type option_menu; 3947 3948 static char tag_opt_main(menu_type *menu, int oid) 3949 { 3950 if (option_actions[oid].id) 3951 return option_actions[oid].id; 3952 3953 return 0; 3954 } 3955 3956 static int valid_opt_main(menu_type *menu, int oid) 3957 { 3958 if (option_actions[oid].name) 3959 return 1; 3960 3961 return 0; 3962 } 3963 3964 static void display_opt_main(menu_type *menu, int oid, bool cursor, int row, int col, int width) 3965 { 3966 byte attr = curs_attrs[CURS_KNOWN][(int)cursor]; 3967 3968 if (option_actions[oid].name) 3969 c_prt(attr, option_actions[oid].name, row, col); 3970 } 3971 3972 3973 static const menu_iter options_iter = 3974 { 3975 0, 3976 tag_opt_main, 3977 valid_opt_main, 3978 display_opt_main, 3979 NULL 3980 }; 3939 3981 3940 3982 … … 3954 3996 clear_from(0); 3955 3997 c = menu_select(&option_menu, &cursor, 0); 3998 if (c.type == EVT_SELECT && option_actions[cursor].action) 3999 { 4000 option_actions[cursor].action(option_actions[cursor].data, 4001 option_actions[cursor].name); 4002 } 3956 4003 } 3957 4004 … … 4011 4058 void init_cmd4_c(void) 4012 4059 { 4060 /* some useful standard command keys */ 4061 static const char cmd_keys[] = { ARROW_LEFT, ARROW_RIGHT, '\0' }; 4062 4013 4063 /* Initialize the menus */ 4014 menu_type *menu; 4064 menu_type *menu; 4015 4065 4016 4066 /* options screen selection menu */ … … 4020 4070 menu->title = "Options Menu"; 4021 4071 menu->menu_data = option_actions; 4072 menu->cmd_keys = cmd_keys; 4022 4073 menu->count = N_ELEMENTS(option_actions); 4023 menu_init (menu, MN_SCROLL, MN_ACT, &SCREEN_REGION);4074 menu_init2(menu, find_menu_skin(MN_SCROLL), &options_iter, &SCREEN_REGION); 4024 4075 4025 4076 /* Initialize the options toggle menu */ … … 4027 4078 WIPE(menu, menu_type); 4028 4079 menu->prompt = "Set option (y/n/t), '?' for information"; 4029 menu->cmd_keys = "?Yy NnTt";4080 menu->cmd_keys = "?Yy\n\rNnTt\x8C"; /* \x8c = ARROW_RIGHT */ 4030 4081 menu->selections = "abcdefghijklmopqrsuvwxz"; 4031 4082 menu->count = OPT_PAGE_PER; 4032 4083 menu->flags = MN_DBL_TAP; 4033 menu_init2(menu, find_menu_skin(MN_SCROLL), &options_ iter, &SCREEN_REGION);4084 menu_init2(menu, find_menu_skin(MN_SCROLL), &options_toggle_iter, &SCREEN_REGION); 4034 4085 4035 4086 /* macro menu */ … … 4038 4089 menu_set_id(menu, MACRO_MENU); 4039 4090 menu->title = "Interact with macros"; 4091 menu->cmd_keys = cmd_keys; 4040 4092 menu->selections = default_choice; 4041 4093 menu->menu_data = macro_actions; … … 4048 4100 menu_set_id(menu, VISUAL_MENU); 4049 4101 menu->title = "Interact with visuals"; 4102 menu->cmd_keys = cmd_keys; 4050 4103 menu->selections = default_choice; 4051 4104 menu->menu_data = visual_menu_items; … … 4058 4111 menu_set_id(menu, COLOR_MENU); 4059 4112 menu->title = "Interact with colors"; 4113 menu->cmd_keys = cmd_keys; 4060 4114 menu->selections = default_choice; 4061 4115 menu->menu_data = color_events; … … 4130 4184 /* Silly message */ 4131 4185 msg_format("You are playing %s %s. Type '?' for more info.", 4132 VERSION_NAME, VERSION_STRING);4186 VERSION_NAME, VERSION_STRING); 4133 4187 } 4134 4188 trunk/src/externs.h
r216 r217 597 597 void squelch_set(object_type *o_ptr); 598 598 void squelch_items(void); 599 void do_cmd_options_item(void );599 void do_cmd_options_item(void *, cptr); 600 600 601 601 /* store.c */ trunk/src/squelch.c
r191 r217 363 363 } 364 364 365 break;365 break; 366 366 } 367 367 … … 375 375 } 376 376 377 break;377 break; 378 378 } 379 379 … … 381 381 { 382 382 if ((feel == INSCRIP_BROKEN) || (feel == INSCRIP_TERRIBLE) || 383 (feel == INSCRIP_WORTHLESS) || (feel == INSCRIP_CURSED) ||383 (feel == INSCRIP_WORTHLESS) || (feel == INSCRIP_CURSED) || 384 384 (feel == INSCRIP_AVERAGE) || (feel == INSCRIP_GOOD)) 385 385 { … … 407 407 { 408 408 return TRUE; 409 break;409 break; 410 410 } 411 411 } … … 645 645 646 646 /* Select an entry */ 647 while (evt.key != ESCAPE && evt.type != EVT_BACK)647 while (evt.key != ESCAPE) 648 648 evt = menu_select(&menu, &cursor, 0); 649 649 … … 686 686 687 687 /* Toggle */ 688 if (cmd == ' ')688 if (cmd == '\n' || cmd == '\r') 689 689 { 690 690 int idx = choice[oid]; … … 696 696 return FALSE; 697 697 } 698 698 699 699 700 /* … … 759 760 text_out_c(TERM_L_GREEN, "ESC"); 760 761 text_out(" to return to the previous menu. "); 761 text_out_c(TERM_L_BLUE, " Space");762 text_out_c(TERM_L_BLUE, "Enter"); 762 763 text_out(" toggles the current setting."); 763 764 … … 770 771 771 772 /* Select an entry */ 772 while (evt.key != ESCAPE && evt.type != EVT_BACK)773 while (evt.key != ESCAPE) 773 774 evt = menu_select(&menu, &cursor, 0); 774 775 … … 782 783 783 784 785 /* Returns TRUE if there's anything to display a menu of */ 786 static bool seen_tval(int tval) 787 { 788 int i; 789 790 for (i = 1; i < z_info->k_max; i++) 791 { 792 object_kind *k_ptr = &k_info[i]; 793 794 /* Skip empty objects, unseen objects, and incorrect tvals */ 795 if (!k_ptr->name) continue; 796 if (!k_ptr->everseen) continue; 797 if (k_ptr->tval != tval) continue; 798 799 return TRUE; 800 } 801 802 803 return FALSE; 804 } 805 806 807 /* Extra options on the "item options" menu */ 808 struct { 809 char tag; 810 char *name; 811 void (*action)(void); 812 } extra_item_options[] = { {'Q', "Quality squelching options", quality_menu } }; 813 814 static char tag_options_item(menu_type *menu, int oid) 815 { 816 if (oid < N_ELEMENTS(sval_dependent)) 817 return I2A(oid); 818 819 /* Separator - blank line. */ 820 if (oid == N_ELEMENTS(sval_dependent)) 821 return 0; 822 823 oid = oid - N_ELEMENTS(sval_dependent); 824 825 if (oid - 1 < N_ELEMENTS(extra_item_options)) 826 return extra_item_options[oid - 1].tag; 827 828 return 0; 829 } 830 831 static int valid_options_item(menu_type *menu, int oid) 832 { 833 if (oid < N_ELEMENTS(sval_dependent)) 834 return 1; 835 836 /* Separator - blank line. */ 837 if (oid == N_ELEMENTS(sval_dependent)) 838 return 0; 839 840 oid = oid - N_ELEMENTS(sval_dependent); 841 842 if (oid - 1 < N_ELEMENTS(extra_item_options)) 843 return 1; 844 845 return 0; 846 } 847 848 static void display_options_item(menu_type *menu, int oid, bool cursor, int row, int col, int width) 849 { 850 if (oid < N_ELEMENTS(sval_dependent)) 851 { 852 bool known = seen_tval(sval_dependent[oid].tval); 853 byte attr = curs_attrs[known ? CURS_KNOWN: CURS_UNKNOWN][(int)cursor]; 854 855 c_prt(attr, sval_dependent[oid].desc, row, col); 856 } 857 else 858 { 859 byte attr = curs_attrs[CURS_KNOWN][(int)cursor]; 860 861 oid = oid - N_ELEMENTS(sval_dependent); 862 863 if (oid - 1 < N_ELEMENTS(extra_item_options)) 864 c_prt(attr, extra_item_options[oid - 1].name, row, col); 865 } 866 } 867 868 869 static const menu_iter options_item_iter = 870 { 871 0, 872 tag_options_item, 873 valid_options_item, 874 display_options_item, 875 NULL 876 }; 877 784 878 785 879 /* 786 880 * Display and handle the main squelching menu. 787 881 */ 788 void do_cmd_options_item(void) 789 { 790 bool done = FALSE; 791 bool no_known = FALSE; 792 size_t i; 882 void do_cmd_options_item(void *unused, cptr title) 883 { 884 int cursor = 0; 885 event_type c = EVENT_EMPTY; 886 const char cmd_keys[] = { ARROW_LEFT, ARROW_RIGHT, '\0' }; 887 888 menu_type menu; 889 890 WIPE(&menu, menu_type); 891 menu.title = title; 892 menu.cmd_keys = cmd_keys; 893 menu.count = N_ELEMENTS(sval_dependent) + N_ELEMENTS(extra_item_options) + 1; 894 menu_init2(&menu, find_menu_skin(MN_SCROLL), &options_item_iter, &SCREEN_REGION); 895 896 menu_layout(&menu, &SCREEN_REGION); 793 897 794 898 /* Save and clear screen */ … … 796 900 clear_from(0); 797 901 798 799 /* Header */ 800 prt("Item handling menu", 0, 0); 801 802 /* Print all typevals and their descriptions */ 803 for (i = 0; i < N_ELEMENTS(sval_dependent); i++) 804 prt(format("%c) %s", I2A(i), sval_dependent[i].desc), i + 3, 1); 805 806 prt("Q) Quality squelching options", i + 4, 1); 807 prt("ESC) Back to options menu.", i + 6, 1); 808 809 while (!done) 810 { 811 char ch; 812 813 if (no_known) 902 while (c.key != ESCAPE) 903 { 904 clear_from(0); 905 c = menu_select(&menu, &cursor, 0); 906 907 if (c.type == EVT_SELECT) 814 908 { 815 prt("You've not seen any object of that type yet.", 1, 0); 816 no_known = FALSE; 817 } 818 else 819 { 820 prt("", 1, 0); 821 } 822 823 /* Prompt */ 824 ch = inkey(); 825 826 /* Choose! */ 827 if (ch == 'Q') quality_menu(); /* Switch to secondary squelching menu */ 828 else if (ch == ESCAPE) done = TRUE; /* Finished */ 829 830 else 831 { 832 /* Analyze choice */ 833 int choice = A2I(ch); 834 835 /* Ignore illegal choice */ 836 if (choice < 0 || choice >= (int)N_ELEMENTS(sval_dependent)) continue; 837 838 if (!sval_menu(sval_dependent[choice].tval, sval_dependent[choice].desc)) 839 no_known = TRUE; 909 if (cursor < N_ELEMENTS(sval_dependent)) 910 { 911 sval_menu(sval_dependent[cursor].tval, sval_dependent[cursor].desc); 912 } 913 else 914 { 915 cursor = cursor - N_ELEMENTS(sval_dependent) - 1; 916 if (cursor< N_ELEMENTS(extra_item_options)) 917 extra_item_options[cursor].action(); 918 } 840 919 } 841 920 }
