Changeset 206
- Timestamp:
- 06/22/07 03:47:48 (1 year ago)
- Files:
-
- trunk/src/birth.c (modified) (20 diffs)
- trunk/src/externs.h (modified) (1 diff)
- trunk/src/util.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/birth.c
r199 r206 436 436 * Clear all the global "character" data 437 437 */ 438 static void player_wipe( void)438 static void player_wipe(bool really_wipe) 439 439 { 440 440 int i; 441 441 442 /* Backup the player choices */ 443 byte psex = p_ptr->psex; 444 byte prace = p_ptr->prace; 445 byte pclass = p_ptr->pclass; 446 442 byte psex, prace, pclass; 443 444 if (really_wipe) 445 { 446 psex = 0; 447 prace = 0; 448 pclass = 0; 449 } 450 else 451 { 452 /* Backup the player choices */ 453 psex = p_ptr->psex; 454 prace = p_ptr->prace; 455 pclass = p_ptr->pclass; 456 } 447 457 448 458 /* Wipe the player */ … … 597 607 598 608 599 /* "Failure" codes */600 #define BIRTH_SUCCESS 0601 #define BIRTH_RESTART -1602 #define BIRTH_BACK -2603 604 605 609 /* Locations of the tables on the screen */ 606 610 #define HEADER_ROW 1 … … 687 691 static region race_region = {RACE_COL, TABLE_ROW, 15, -2}; 688 692 static region class_region = {CLASS_COL, TABLE_ROW, 19, -2}; 689 static region roller_region = {44, TABLE_ROW, 2 0, -2};693 static region roller_region = {44, TABLE_ROW, 21, -2}; 690 694 691 695 … … 772 776 773 777 if (oid == 0) 774 str = "Point-based";778 str = "Point-based"; 775 779 else if (oid == 1) 776 str = "Autoroller";780 str = "Autoroller"; 777 781 else 778 str = "Standard roller";782 str = "Standard roller"; 779 783 780 784 c_prt(attr, str, row, col); … … 792 796 roller_type = oid; 793 797 else if (cmd == '*') 794 roller_type = 3;798 roller_type = 2; 795 799 else if(cmd == '=') 796 800 do_cmd_options(); … … 870 874 cx = menu_select(&menu, &cursor, 0); 871 875 872 if (cx.key == ESCAPE) 873 { 874 /* Restart */ 875 return FALSE; 876 } 877 else if (cx.type == EVT_BACK) 878 { 879 /* Move back one menu */ 880 *values[i] = cursor; 881 region_erase(regions[i]); 882 i--; 876 if (cx.key == ESCAPE || cx.type == EVT_BACK) 877 { 878 if (i > 0) 879 { 880 /* Move back one menu */ 881 *values[i] = cursor; 882 region_erase(regions[i]); 883 i--; 884 } 883 885 } 884 886 else if (cx.key == '*') … … 931 933 text_out("' for a random menu item, '"); 932 934 text_out_c(TERM_L_GREEN, "ESC"); 933 text_out("' to restart the character selection, '");935 text_out("' to step back through the birth process, '"); 934 936 text_out_c(TERM_L_GREEN, "="); 935 937 text_out("' for the birth options, '"); … … 961 963 squelch_level[i] = 0; 962 964 963 964 /* Clear */965 Term_clear();966 965 967 966 /* Done */ … … 988 987 * Each unused point is converted into 100 gold pieces. 989 988 */ 990 static boolplayer_birth_aux_2(void)989 static int player_birth_aux_2(void) 991 990 { 992 991 int i; … … 1005 1004 char buf[80]; 1006 1005 1006 bool first_time = TRUE; 1007 1008 /* Clear */ 1009 Term_clear(); 1007 1010 1008 1011 /* Initialize stats */ … … 1109 1112 ch = inkey(); 1110 1113 1111 /* Quit */ 1112 if (ch == 'Q') quit(NULL); 1113 1114 /* Start over */ 1115 if (ch == 'S') return (FALSE); 1114 /* Go back a step, or back to the start of this step */ 1115 if (ch == ESCAPE) 1116 { 1117 if (first_time) 1118 return -1; 1119 else 1120 return 0; 1121 } 1122 1123 first_time = FALSE; 1116 1124 1117 1125 /* Done */ … … 1146 1154 1147 1155 1148 /* Done */1149 return (TRUE);1156 /* Done - advance a step*/ 1157 return +1; 1150 1158 } 1151 1159 … … 1156 1164 * This function handles "auto-rolling" and "random-rolling". 1157 1165 */ 1158 static boolplayer_birth_aux_3(bool autoroll)1166 static int player_birth_aux_3(bool autoroll) 1159 1167 { 1160 1168 int i, j, m, v; … … 1179 1187 s32b last_round; 1180 1188 1189 1190 /* Clear */ 1191 Term_clear(); 1181 1192 1182 1193 /*** Autoroll ***/ … … 1255 1266 1256 1267 /* Get a response (or escape) */ 1257 if (!askfor_aux(inp, 9, NULL)) inp[0] = '\0'; 1268 if (!askfor_aux(inp, 9, NULL)) 1269 { 1270 if (i == 0) 1271 /* Back a step */ 1272 return -1; 1273 else 1274 /* Repeat this step */ 1275 return 0; 1276 } 1258 1277 1259 1278 /* Hack -- add a fake slash */ … … 1280 1299 /* Clean up */ 1281 1300 clear_from(10); 1282 1283 1301 1284 1302 /*** Generate ***/ … … 1454 1472 ch = inkey(); 1455 1473 1456 /* Quit */ 1457 if (ch == 'Q') quit(NULL); 1458 1459 /* Start over */ 1460 if (ch == 'S') return (FALSE); 1474 /* Go back to the start of the step, or the previous step */ 1475 /* if we're not autorolling. */ 1476 if (ch == ESCAPE) 1477 { 1478 if (autoroll) 1479 return 0; 1480 else 1481 return -1; 1482 } 1461 1483 1462 1484 /* 'Enter' accepts the roll */ … … 1497 1519 clear_from(23); 1498 1520 1499 /* Done */ 1500 return (TRUE); 1501 } 1521 /* Done - move on a stage */ 1522 return +1; 1523 } 1524 1525 typedef enum 1526 { 1527 BIRTH_RESTART = 0, 1528 BIRTH_QUESTIONS, 1529 BIRTH_STATS, 1530 BIRTH_NAME, 1531 BIRTH_FINAL_APPROVAL, 1532 BIRTH_ACCEPTED 1533 } birth_stages; 1502 1534 1503 1535 … … 1507 1539 * See "display_player" for screen layout code. 1508 1540 */ 1509 static boolplayer_birth_aux(void)1541 static void player_birth_aux(void) 1510 1542 { 1511 1543 char ch; 1512 cptr prompt = "['Q' to suicide, 'S' to start over, or any other key to continue]"; 1513 1514 /* Ask questions */ 1515 if (!player_birth_aux_1()) return (FALSE); 1516 1517 /* Point-based */ 1518 if (roller_type == ROLLER_POINT) 1519 { 1520 /* Point based */ 1521 if (!player_birth_aux_2()) return (FALSE); 1522 } 1523 1524 /* Random */ 1525 else 1526 { 1527 /* Auto-roll */ 1528 if (!player_birth_aux_3(roller_type == ROLLER_AUTO)) return (FALSE); 1529 } 1530 1531 /* Get a name, prepare savefile */ 1532 get_name(FALSE); 1533 1534 /* Display the player */ 1535 display_player(0); 1536 1537 /* Prompt for it */ 1538 prt(prompt, Term->hgt - 1, Term->wid / 2 - strlen(prompt) / 2); 1539 1540 /* Get a key */ 1541 ch = inkey(); 1542 1543 /* Quit */ 1544 if (ch == 'Q') quit(NULL); 1545 1546 /* Start over */ 1547 if (ch == 'S') return (FALSE); 1548 1549 /* Accept */ 1550 return (TRUE); 1544 cptr prompt = "['ESC' to step back, 'S' to start over, or any other key to continue]"; 1545 birth_stages state = BIRTH_QUESTIONS; 1546 1547 while (1) 1548 { 1549 switch (state) 1550 { 1551 case BIRTH_RESTART: 1552 { 1553 player_wipe(FALSE); 1554 state++; 1555 break; 1556 } 1557 1558 case BIRTH_QUESTIONS: 1559 { 1560 /* Race, class, etc. choices */ 1561 if (player_birth_aux_1()) state++; 1562 break; 1563 } 1564 1565 case BIRTH_STATS: 1566 { 1567 if (roller_type == ROLLER_POINT) 1568 { 1569 /* Fill stats using point-based methods */ 1570 state += player_birth_aux_2(); 1571 } 1572 else 1573 { 1574 /* Fills stats using the standard- or auto-roller */ 1575 state += player_birth_aux_3(roller_type == ROLLER_AUTO); 1576 } 1577 break; 1578 } 1579 1580 case BIRTH_NAME: 1581 { 1582 /* Get a name, prepare savefile */ 1583 if (get_name(FALSE)) 1584 state++; 1585 else 1586 state--; 1587 1588 break; 1589 } 1590 1591 case BIRTH_FINAL_APPROVAL: 1592 { 1593 /* Display the player */ 1594 display_player(0); 1595 1596 /* Prompt for it */ 1597 prt(prompt, Term->hgt - 1, Term->wid / 2 - strlen(prompt) / 2); 1598 1599 /* Get a key */ 1600 ch = inkey(); 1601 1602 /* Start over */ 1603 if (ch == 'S') 1604 state = BIRTH_RESTART; 1605 1606 if (ch == ESCAPE) 1607 state--; 1608 else 1609 state++; 1610 1611 /* Clear prompt */ 1612 clear_from(23); 1613 1614 break; 1615 } 1616 1617 case BIRTH_ACCEPTED: 1618 { 1619 return; 1620 } 1621 1622 } 1623 } 1551 1624 } 1552 1625 … … 1560 1633 void player_birth(void) 1561 1634 { 1635 /* Wipe the player properly */ 1636 player_wipe(TRUE); 1637 1562 1638 /* Create a new character */ 1563 while (1) 1564 { 1565 /* Wipe the player */ 1566 player_wipe(); 1567 1568 /* Roll up a new character */ 1569 if (player_birth_aux()) break; 1570 } 1571 1639 player_birth_aux(); 1572 1640 1573 1641 /* Note player birth in the message recall */ trunk/src/externs.h
r200 r206 329 329 extern void do_cmd_help(void); 330 330 extern void process_player_name(bool sf); 331 extern voidget_name(bool sf);331 extern bool get_name(bool sf); 332 332 extern void do_cmd_suicide(void); 333 333 extern void do_cmd_save_game(void); trunk/src/util.c
r199 r206 2856 2856 * What a horrible name for a global function. XXX XXX XXX 2857 2857 */ 2858 voidget_name(bool sf)2858 bool get_name(bool sf) 2859 2859 { 2860 2860 bool res; … … 2884 2884 process_player_name(sf); 2885 2885 } 2886 2887 return res; 2886 2888 } 2887 2889
