Changeset 206

Show
Ignore:
Timestamp:
06/22/07 03:47:48 (1 year ago)
Author:
ajps
Message:

Birth 'improvements'. A few minor bugfixes, and the adoption of ESC as a consistent key to step back through the stages of the birth process.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/birth.c

    r199 r206  
    436436 * Clear all the global "character" data 
    437437 */ 
    438 static void player_wipe(void
     438static void player_wipe(bool really_wipe
    439439{ 
    440440        int i; 
    441441 
    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        } 
    447457 
    448458        /* Wipe the player */ 
     
    597607 
    598608 
    599 /* "Failure" codes */ 
    600 #define BIRTH_SUCCESS             0 
    601 #define BIRTH_RESTART            -1 
    602 #define BIRTH_BACK               -2 
    603  
    604  
    605609/* Locations of the tables on the screen */ 
    606610#define HEADER_ROW       1 
     
    687691static region race_region = {RACE_COL, TABLE_ROW, 15, -2}; 
    688692static region class_region = {CLASS_COL, TABLE_ROW, 19, -2}; 
    689 static region roller_region = {44, TABLE_ROW, 20, -2}; 
     693static region roller_region = {44, TABLE_ROW, 21, -2}; 
    690694 
    691695 
     
    772776 
    773777        if (oid == 0) 
    774             str = "Point-based"; 
     778               str = "Point-based"; 
    775779        else if (oid == 1) 
    776             str = "Autoroller"; 
     780               str = "Autoroller"; 
    777781        else 
    778             str = "Standard roller"; 
     782               str = "Standard roller"; 
    779783 
    780784        c_prt(attr, str, row, col); 
     
    792796                roller_type = oid; 
    793797        else if (cmd == '*') 
    794                 roller_type = 3
     798                roller_type = 2
    795799        else if(cmd == '=') 
    796800                do_cmd_options(); 
     
    870874                cx = menu_select(&menu, &cursor, 0); 
    871875 
    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                        } 
    883885                } 
    884886                else if (cx.key == '*') 
     
    931933        text_out("' for a random menu item, '"); 
    932934        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, '"); 
    934936        text_out_c(TERM_L_GREEN, "="); 
    935937        text_out("' for the birth options, '"); 
     
    961963                squelch_level[i] = 0; 
    962964 
    963  
    964         /* Clear */ 
    965         Term_clear(); 
    966965 
    967966        /* Done */ 
     
    988987 * Each unused point is converted into 100 gold pieces. 
    989988 */ 
    990 static bool player_birth_aux_2(void) 
     989static int player_birth_aux_2(void) 
    991990{ 
    992991        int i; 
     
    10051004        char buf[80]; 
    10061005 
     1006        bool first_time = TRUE; 
     1007 
     1008        /* Clear */ 
     1009        Term_clear(); 
    10071010 
    10081011        /* Initialize stats */ 
     
    11091112                ch = inkey(); 
    11101113 
    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; 
    11161124 
    11171125                /* Done */ 
     
    11461154 
    11471155 
    1148         /* Done */ 
    1149         return (TRUE)
     1156        /* Done - advance a step*/ 
     1157        return +1
    11501158} 
    11511159 
     
    11561164 * This function handles "auto-rolling" and "random-rolling". 
    11571165 */ 
    1158 static bool player_birth_aux_3(bool autoroll) 
     1166static int player_birth_aux_3(bool autoroll) 
    11591167{ 
    11601168        int i, j, m, v; 
     
    11791187        s32b last_round; 
    11801188 
     1189 
     1190        /* Clear */ 
     1191        Term_clear(); 
    11811192 
    11821193        /*** Autoroll ***/ 
     
    12551266 
    12561267                                /* 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                                } 
    12581277 
    12591278                                /* Hack -- add a fake slash */ 
     
    12801299        /* Clean up */ 
    12811300        clear_from(10); 
    1282  
    12831301 
    12841302        /*** Generate ***/ 
     
    14541472                        ch = inkey(); 
    14551473 
    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                        } 
    14611483 
    14621484                        /* 'Enter' accepts the roll */ 
     
    14971519        clear_from(23); 
    14981520 
    1499         /* Done */ 
    1500         return (TRUE); 
    1501 
     1521        /* Done - move on a stage */ 
     1522        return +1; 
     1523
     1524 
     1525typedef 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; 
    15021534 
    15031535 
     
    15071539 * See "display_player" for screen layout code. 
    15081540 */ 
    1509 static bool player_birth_aux(void) 
     1541static void player_birth_aux(void) 
    15101542{ 
    15111543        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        } 
    15511624} 
    15521625 
     
    15601633void player_birth(void) 
    15611634{ 
     1635        /* Wipe the player properly */ 
     1636        player_wipe(TRUE); 
     1637                 
    15621638        /* 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(); 
    15721640 
    15731641        /* Note player birth in the message recall */ 
  • trunk/src/externs.h

    r200 r206  
    329329extern void do_cmd_help(void); 
    330330extern void process_player_name(bool sf); 
    331 extern void get_name(bool sf); 
     331extern bool get_name(bool sf); 
    332332extern void do_cmd_suicide(void); 
    333333extern void do_cmd_save_game(void); 
  • trunk/src/util.c

    r199 r206  
    28562856 * What a horrible name for a global function.  XXX XXX XXX 
    28572857 */ 
    2858 void get_name(bool sf) 
     2858bool get_name(bool sf) 
    28592859{ 
    28602860        bool res; 
     
    28842884                process_player_name(sf); 
    28852885        } 
     2886 
     2887        return res; 
    28862888} 
    28872889