Changeset 22
- Timestamp:
- 03/29/07 03:20:15 (2 years ago)
- Files:
-
- trunk/src/birth.c (modified) (15 diffs)
- trunk/src/cmd4.c (modified) (3 diffs)
- trunk/src/externs.h (modified) (1 diff)
- trunk/src/squelch.c (modified) (1 diff)
- trunk/src/ui.c (modified) (13 diffs)
- trunk/src/ui.h (modified) (3 diffs)
- trunk/src/wizard2.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/birth.c
r21 r22 685 685 static region gender_region = {SEX_COL, TABLE_ROW, 15, -2}; 686 686 static region race_region = {RACE_COL, TABLE_ROW, 15, -2}; 687 static region class_region = {CLASS_COL, TABLE_ROW, 1 5, -2};687 static region class_region = {CLASS_COL, TABLE_ROW, 19, -2}; 688 688 689 689 static void show_help(cptr helpfile, cptr topic) { … … 705 705 706 706 /* Not worth writing a general purpose handler */ 707 static bool gender_handler(char cmd, void *db, int oid)708 { 709 if(cmd == '\xff' ) {707 static bool gender_handler(char cmd, const void *db, int oid) 708 { 709 if(cmd == '\xff' || cmd == '\r') { 710 710 p_ptr->psex = oid; 711 711 sp_ptr = &sex_info[p_ptr->psex]; 712 712 } 713 713 else if(cmd == '*') { 714 p_ptr->psex = rand_int(SEX_MALE );714 p_ptr->psex = rand_int(SEX_MALE+1); 715 715 sp_ptr = &sex_info[p_ptr->psex]; 716 716 } 717 else if(cmd == '=') do_cmd_options(); 717 718 else if(cmd == KTRL('X')) quit(NULL); 718 719 else if(cmd == '?') show_help("birth.txt", sex_info[oid].title); … … 729 730 } 730 731 731 static bool race_handler(char cmd, void *db, int oid)732 { 733 if(cmd == '\xff' ) {732 static bool race_handler(char cmd, const void *db, int oid) 733 { 734 if(cmd == '\xff' || cmd == '\r') { 734 735 p_ptr->prace = oid; 735 736 rp_ptr = &p_info[p_ptr->prace]; … … 739 740 rp_ptr = &p_info[p_ptr->prace]; 740 741 } 742 else if(cmd == '=') do_cmd_options(); 741 743 else if(cmd == KTRL('X')) quit(NULL); 742 744 else if(cmd == '?') show_help("birth.txt", p_name+p_info[oid].name); … … 754 756 } 755 757 756 static bool class_handler(char cmd, void *db, int oid)757 { 758 if(cmd == '\xff' ) {758 static bool class_handler(char cmd, const void *db, int oid) 759 { 760 if(cmd == '\xff' || cmd == '\r') { 759 761 p_ptr->pclass = oid; 760 762 cp_ptr = &c_info[p_ptr->pclass]; … … 763 765 else if(cmd == '*') { 764 766 for(;;) { 765 p_ptr->pclass = rand_int(z_info->c_max); 767 oid = rand_int(z_info->c_max); 768 p_ptr->pclass = oid; 766 769 cp_ptr = &c_info[p_ptr->pclass]; 767 770 mp_ptr = &cp_ptr->spells; … … 770 773 } 771 774 } 775 else if(cmd == '=') do_cmd_options(); 772 776 else if(cmd == KTRL('X')) quit(NULL); 773 777 else if(cmd == '?') show_help("birth.txt", c_name+c_info[oid].name); … … 785 789 /* Menu display and selector */ 786 790 787 static voidchoose_character()791 static bool choose_character() 788 792 { 789 793 int i; … … 801 805 menu_type menu; 802 806 WIPE(&menu, menu); 803 menu.cmd_keys = "?*"; 804 805 for(i = 0; i < N_ELEMENTS(menu_defs); i++) 806 { 807 menu.cmd_keys = "?*\r\x18"; /* ?, *, \n, <ctl-X> */ 808 809 i = 0; 810 while(i < N_ELEMENTS(menu_defs)) 811 { 812 menu.flags = MN_NO_TAGS | MN_DBL_TAP; 813 menu_init(&menu); 807 814 key_event cx; 808 815 int cursor = *values[i]; 809 816 clear_question(); 810 Term_putstr(QUESTION_COL, QUESTION_ROW, -1, TERM_YELLOW, hints[i]);817 Term_putstr(QUESTION_COL, QUESTION_ROW, -1, TERM_YELLOW, hints[i]); 811 818 menu.count = limits[i]; 812 menu.flags = MN_NO_TAGS | MN_DBL_TAP;813 menu_init(&menu);814 819 menu_set_class(&menu, &menu_defs[i]); 815 820 menu.browse_hook = browse[i]; … … 817 822 cx = menu_select(&menu, 0, menu.count, &cursor, *regions[i]); 818 823 if(cx.key == ESCAPE) { 819 i = 0; /* restart */824 return FALSE; /* restart */ 820 825 } 821 826 else if(cx.type == EVT_BACK) { 827 region_erase(regions[i]); 822 828 i--; 823 829 } 824 } 830 else if(cx.key == '*') { 831 /* Force refresh */ 832 Term_key_push('6'); 833 continue; 834 } 835 else i++; 836 } 837 return TRUE; 825 838 826 839 } … … 871 884 text_out_indent = 0; 872 885 873 choose_character();886 if(!choose_character()) return FALSE; 874 887 875 888 … … 1055 1068 if ((ch == '\r') || (ch == '\n')) break; 1056 1069 1070 ch = target_dir(ch); 1071 1057 1072 /* Prev stat */ 1058 if (ch == '8')1073 if (ch == 8) 1059 1074 { 1060 1075 stat = (stat + A_MAX - 1) % A_MAX; … … 1062 1077 1063 1078 /* Next stat */ 1064 if (ch == '2')1079 if (ch == 2) 1065 1080 { 1066 1081 stat = (stat + 1) % A_MAX; … … 1068 1083 1069 1084 /* Decrease stat */ 1070 if ((ch == '4') && (stats[stat] > 10))1085 if ((ch == 4) && (stats[stat] > 10)) 1071 1086 { 1072 1087 stats[stat]--; … … 1074 1089 1075 1090 /* Increase stat */ 1076 if ((ch == '6') && (stats[stat] < 18))1091 if ((ch == 6) && (stats[stat] < 18)) 1077 1092 { 1078 1093 stats[stat]++; trunk/src/cmd4.c
r18 r22 1346 1346 1347 1347 /* Tidy name */ 1348 strip_name(o_name, k_idx);1348 strip_name(o_name, k_idx, FALSE); 1349 1349 1350 1350 /* Display the name */ … … 2032 2032 } 2033 2033 2034 static bool update_option(char key, void *pgdb, int oid)2034 static bool update_option(char key, const void *pgdb, int oid) 2035 2035 { 2036 2036 switch(toupper(key)) … … 4148 4148 {{0, 0, 0, 0}}, /* Load and append */ 4149 4149 {{0, "Window Flags", (action_f) do_cmd_options_win, 0}, 'W'}, 4150 {{0, "Item Squelch and Autoinscribe Menus", (action_f) do_cmd_squelch_autoinsc, 0}, 'S'}, 4150 4151 {{0, "Load a user pref file", (action_f) do_cmd_pref_file_hack, (void*)20}, 'L'}, 4151 4152 {{0, "Dump Options", (action_f) dump_pref_file, option_dump}, 'A'}, trunk/src/externs.h
r16 r22 852 852 853 853 bool make_fake_artifact(object_type *o_ptr, byte name1); 854 extern void strip_name(char *buf, int k_idx );854 extern void strip_name(char *buf, int k_idx, bool easy_know); trunk/src/squelch.c
r18 r22 1519 1519 1520 1520 /* Acquire the "name" of object "i" */ 1521 strip_name(buf, choice[i] );1521 strip_name(buf, choice[i], TRUE); 1522 1522 1523 1523 /* Deal with the active selection */ trunk/src/ui.c
r20 r22 21 21 int menu_width = 23; 22 22 23 void region_erase(const region *loc) 24 { 25 int i = 0; 26 int w = loc->width; 27 int h = loc->page_rows; 28 if(loc->width <= 0 || loc->page_rows <= 0) { 29 Term_get_size(&w, &h); 30 if(loc->width <= 0) w -= loc->width; 31 if(loc->page_rows <= 0) h -= loc->page_rows; 32 } 33 for(i = 0; i < h; i++) { 34 Term_erase(loc->col, loc->row+i, w); 35 } 36 } 37 23 38 static void display_menu_row(menu_type *menu, const int object_list[], int pos, 24 39 int top, bool cursor, int row, int col, int width); … … 36 51 } 37 52 38 static bool inside( region *loc, key_event *key) {39 if(loc->col < key->mousex) return FALSE; 40 if( loc->col + loc->width <= key->mousex) return FALSE;41 if(loc->row < key->mousey)return FALSE;42 if( loc->row + loc->page_rows <= key->mousey) return FALSE;43 53 static bool inside(const region *loc, const key_event *key) 54 { 55 if((loc->col > key->mousex) || (loc->col + loc->width <= key->mousex)) 56 return FALSE; 57 if((loc->row > key->mousey) || (loc->row + loc->page_rows <= key->mousey)) 58 return FALSE; 44 59 return TRUE; 45 60 } … … 57 72 /* act on selection only */ 58 73 /* Return: true if handled. */ 59 static bool handle_menu_item_event(char cmd, void *db, int oid)74 static bool handle_menu_item_event(char cmd, const void *db, int oid) 60 75 { 61 76 event_action *evt = &((event_action*)db)[oid]; 62 77 if(cmd == '\xff' && evt->action) { 63 78 evt->action(evt->data, evt->name); 79 return TRUE; 64 80 } 65 81 else if(cmd == '\xff') 66 82 return TRUE; 83 return FALSE; 67 84 } 68 85 … … 101 118 102 119 /* act on selection only */ 103 static bool handle_menu_item(char cmd, void *db, int oid)120 static bool handle_menu_item(char cmd, const void *db, int oid) 104 121 { 105 122 if(cmd == '\xff') … … 141 158 int top, region *loc) 142 159 { 143 int cursor = col - loc->col+ top;160 int cursor = row - loc->row + top; 144 161 if(cursor < top) cursor = top-1; 145 162 else if(cursor > loc->page_rows) cursor = loc->page_rows; … … 170 187 bool is_curs = (cursor == i - *top); 171 188 display_menu_row(menu, object_list, i, *top, is_curs, row+i, col, loc->width); 189 } 190 if(cursor >= 0) { 191 Term_gotoxy(col, row + cursor-*top); 172 192 } 173 193 } … … 212 232 int pos = c*rows_per_page + r; 213 233 bool is_cursor = (pos == cursor); 214 display_menu_row(menu, object_list, pos, 0, is_cursor, row+r, col+c, colw); 234 display_menu_row(menu, object_list, pos, 0, is_cursor, 235 row+r, col+c*colw, colw); 215 236 } 216 237 } … … 328 349 329 350 330 key_event get_menu_choice(menu_type *menu, const int object_list[], int n, int *cursor,331 int top, region *loc)351 key_event get_menu_choice(menu_type *menu, const int object_list[], int n, 352 int *cursor, int top, region *loc) 332 353 { 333 354 key_event ke; … … 348 369 if(ke.mousex < loc->col) { 349 370 ke.type = EVT_BACK; 350 return ke;371 break; 351 372 } 352 373 … … 355 376 goto retry; 356 377 378 ke.index = m_curs; 379 *cursor = m_curs; 357 380 if(*cursor == m_curs || !(menu->flags & MN_DBL_TAP)) 358 381 { 359 382 /* menu selection event*/ 360 383 ke.type = EVT_SELECT; 361 return ke; 362 } 363 *cursor = m_curs; 384 break; 385 } 364 386 /* menu movement event */ 365 387 ke.type = EVT_MOVE; … … 372 394 int dir; 373 395 if(menu->cmd_keys && strchr(menu->cmd_keys, ke.key)) 374 return ke;396 break; 375 397 if(!(menu->flags & MN_NO_TAGS)) { 376 398 int c = get_cursor_key(menu, object_list, n, top, ke.key); … … 380 402 *cursor = c; 381 403 ke.type = EVT_SELECT; 404 ke.index = c; 382 405 ke.key = '\xff'; 383 406 break; … … 488 511 } 489 512 490 ke = get_menu_choice(menu, object_list, menu->count, cursor, top, &loc); 513 ke = get_menu_choice(menu, object_list, menu->count, cursor, top, &active); 514 if(*cursor != oid && ke.type == EVT_SELECT || menu->flags == MN_ONCE) 515 { 516 /* refresh prior to return */ 517 menu->skin->display_list(menu, object_list, n, *cursor, &top, &active); 518 } 491 519 if(ke.key == ESCAPE) return ke; 492 520 if(menu->flags & MN_ONCE) return ke; trunk/src/ui.h
r20 r22 135 135 bool (*valid_row)(menu_type *menu, int oid); 136 136 display_row_f display_row; 137 bool (*handler)(char cmd, void *db, int oid);137 bool (*handler)(char cmd, const void *db, int oid); 138 138 }; 139 139 … … 198 198 199 199 200 void *menu_data; /* the data used to access rows. */200 const void *menu_data; /* the data used to access rows. */ 201 201 202 202 203 203 /* command action. Should handle 0xff for selection */ 204 bool (*handler)(char cmd, void *db, int oid);204 bool (*handler)(char cmd, const void *db, int oid); 205 205 206 206 void (*browse_hook)(int oid, const region *loc); /* auxiliary browser help function */ … … 268 268 static const region SCREEN_REGION = {0, 0, 0, 0}; 269 269 270 /* Move to Term_ ? */ 271 void region_erase(const region *loc); 272 270 273 271 274 #endif /* UI_H */ trunk/src/wizard2.c
r16 r22 416 416 * Strip an "object name" into a buffer 417 417 */ 418 void strip_name(char *buf, int k_idx )418 void strip_name(char *buf, int k_idx, bool easy_know) 419 419 { 420 420 char *t; … … 532 532 533 533 /* Get the "name" of object "i" */ 534 strip_name(buf, i );534 strip_name(buf, i, TRUE); 535 535 536 536 /* Print it */
