Changeset 132

Show
Ignore:
Timestamp:
05/12/07 10:36:48 (2 years ago)
Author:
takkaria
Message:

Integrate roller menu better. (closes #117)

Files:

Legend:

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

    r120 r132  
    687687static region race_region = {RACE_COL, TABLE_ROW, 15, -2}; 
    688688static region class_region = {CLASS_COL, TABLE_ROW, 19, -2}; 
     689static region roller_region = {44, TABLE_ROW, 20, -2}; 
    689690 
    690691 
     
    763764} 
    764765 
     766/* ROLLER */ 
     767static void display_roller(menu_type *menu, int oid, bool cursor, 
     768                                                        int row, int col, int width) 
     769{ 
     770        byte attr = curs_attrs[CURS_KNOWN][0 != cursor]; 
     771        const char *str; 
     772 
     773        if (oid == 0) 
     774            str = "Point-based"; 
     775        else if (oid == 1) 
     776            str = "Autoroller"; 
     777        else if (oid == 2) 
     778            str = "Standard roller"; 
     779 
     780        c_prt(attr, str, row, col); 
     781} 
     782 
     783 
     784static byte roller_type = 0; 
     785#define ROLLER_POINT    0 
     786#define ROLLER_AUTO     1 
     787#define ROLLER_STD      2 
     788 
     789static bool roller_handler(char cmd, void *db, int oid) 
     790{ 
     791        if (cmd == '\xff' || cmd == '\r') 
     792                roller_type = oid; 
     793        else if (cmd == '*') 
     794                roller_type = 3; 
     795        else if(cmd == '=') 
     796                do_cmd_options(); 
     797        else if(cmd == KTRL('X')) 
     798                quit(NULL); 
     799        else 
     800                return FALSE; 
     801 
     802        return TRUE; 
     803} 
     804 
    765805 
    766806static const menu_iter menu_defs[] = { 
     
    768808        { 0, 0, 0, display_race, race_handler }, 
    769809        { 0, 0, 0, display_class, class_handler }, 
     810        { 0, 0, 0, display_roller, roller_handler }, 
    770811}; 
    771812 
     
    775816#define ARACE 1 
    776817#define ACLASS 2 
     818#define AROLL 3 
     819 
    777820 
    778821 
     
    781824        int i = 0; 
    782825 
    783         const region *regions[] = { &gender_region, &race_region, &class_region }; 
    784         byte *values[3]; /* { &p_ptr->psex, &p_ptr->prace, &p_ptr->pclass }; */ 
    785         int limits[3]; /* { SEX_MALE +1, z_info->p_max, z_info->c_max }; */ 
     826        const region *regions[] = { &gender_region, &race_region, &class_region, &roller_region }; 
     827        byte *values[4]; /* { &p_ptr->psex, &p_ptr->prace, &p_ptr->pclass }; */ 
     828        int limits[4]; /* { SEX_MALE +1, z_info->p_max, z_info->c_max }; */ 
    786829 
    787830        menu_type menu; 
     
    791834                "Your 'sex' does not have any significant gameplay effects.", 
    792835                "Your 'race' determines various intrinsic factors and bonuses.", 
    793                 "Your 'class' determines various intrinsic abilities and bonuses" 
     836                "Your 'class' determines various intrinsic abilities and bonuses", 
     837                "Your choice of character generation.  Point-based is recommended." 
    794838        }; 
    795839         
    796840        typedef void (*browse_f) (int oid, void *, const region *loc); 
    797         browse_f browse[] = {NULL, race_aux_hook, class_aux_hook }; 
     841        browse_f browse[] = {NULL, race_aux_hook, class_aux_hook, NULL }; 
    798842 
    799843        /* Stupid ISO C array initialization. */ 
     
    801845        values[ARACE] = &p_ptr->prace; 
    802846        values[ACLASS] = &p_ptr->pclass; 
     847        values[AROLL] = &roller_type; 
    803848        limits[ASEX] = SEX_MALE + 1; 
    804849        limits[ARACE] = z_info->p_max; 
    805850        limits[ACLASS] = z_info->c_max; 
     851        limits[AROLL] = 3; 
    806852 
    807853        WIPE(&menu, menu); 
     
    896942        text_out_indent = 0; 
    897943 
    898         if(!choose_character()) return FALSE; 
     944        if (!choose_character()) return FALSE; 
    899945 
    900946 
     
    14831529        cptr prompt = "['Q' to suicide, 'S' to start over, or any other key to continue]"; 
    14841530 
    1485         bool point_based = FALSE, autoroll = FALSE; 
    14861531        bool done = FALSE; 
    14871532 
     
    14891534        if (!player_birth_aux_1()) return (FALSE); 
    14901535 
    1491         /* XXX Ask for autoroll preference */ 
    1492         /* Turn into a real menu later */ 
    1493         Term_clear(); 
    1494         while (!done) 
    1495         { 
    1496                 prt("To create a character, would you like to:", 1, 1); 
    1497                 prt(" a) Use the point-based system", 2, 1); 
    1498                 prt(" b) Use the autoroller", 3, 1); 
    1499                 prt(" c/*) Use the basic roller", 4, 1); 
    1500  
    1501                 prt("", 6, 1); 
    1502                 ch = inkey(); 
    1503  
    1504                 switch (ch) 
    1505                 { 
    1506                         case 'a': 
    1507                         case 'A': 
    1508                                 done = point_based = TRUE; 
    1509                                 break; 
    1510  
    1511                         case 'b': 
    1512                         case 'B': 
    1513                                 done = autoroll = TRUE; 
    1514                                 break; 
    1515  
    1516                         case 'c': 
    1517                         case 'C': 
    1518                         case '*': 
    1519                                 done = TRUE; 
    1520                                 break; 
    1521                 } 
    1522         } 
    1523  
    15241536        /* Point-based */ 
    1525         if (point_based
     1537        if (roller_type == ROLLER_POINT
    15261538        { 
    15271539                /* Point based */ 
     
    15331545        { 
    15341546                /* Auto-roll */ 
    1535                 if (!player_birth_aux_3(autoroll)) return (FALSE); 
     1547                if (!player_birth_aux_3(roller_type == ROLLER_AUTO)) return (FALSE); 
    15361548        } 
    15371549