Changeset 338

Show
Ignore:
Timestamp:
07/14/07 08:43:03 (1 year ago)
Author:
ajps
Message:

Tidying up of the knowledge screens some more, so that recalled text is always at the top of the screen and (hopefully) no more artifact spoilers as the artifact_known check has been improved. Closes #255.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/angband-3.0.8/src/cmd4.c

    r293 r338  
    343343} 
    344344 
     345static const char *recall_prompt(int oid) 
     346{ 
     347        return ", 'r' to recall"; 
     348} 
    345349 
    346350#define swap(a, b) (swapspace = (void*)(a)), ((a) = (b)), ((b) = swapspace) 
     
    548552                        else if (o_funcs.xattr) pvs = ", 'v' for visuals"; 
    549553 
    550                         prt(format("<dir>, 'r' to recall%s%s%s, ESC", pvs, pedit, xtra), hgt - 1, 0); 
     554 
     555 
     556                        prt(format("<dir>%s%s%s, ESC", pvs, pedit, xtra), hgt - 1, 0); 
    551557                } 
    552558 
     
    10351041static byte *m_xattr(int oid) { return &r_info[default_join[oid].oid].x_attr; } 
    10361042static const char *race_name(int gid) { return monster_group[gid].name; } 
    1037 static void mon_lore(int oid) { screen_roff(default_join[oid].oid); inkey_ex(); } 
     1043 
     1044static void mon_lore(int oid)  
     1045{  
     1046        /* Save the screen */ 
     1047        screen_save(); 
     1048 
     1049        /* Describe */ 
     1050        text_out_hook = text_out_to_screen; 
     1051 
     1052        /* Recall monster */ 
     1053        roff_top(default_join[oid].oid); 
     1054        Term_gotoxy(0,2); 
     1055        describe_monster(oid, FALSE); 
     1056 
     1057        text_out_c(TERM_L_BLUE, "\n[Press any key to continue]\n"); 
     1058        (void)anykey(); 
     1059 
     1060        /* Load the screen */ 
     1061        screen_load(); 
     1062
    10381063 
    10391064static void mon_summary(int gid, const int *object_list, int n, int top, int row, int col) 
     
    10991124                                                        m_cmp_race, default_group, mon_summary}; 
    11001125 
    1101         member_funcs m_funcs = {display_monster, mon_lore, m_xchar, m_xattr, 0, 0, 0}; 
     1126        member_funcs m_funcs = {display_monster, mon_lore, m_xchar, m_xattr, recall_prompt, 0, 0}; 
    11021127 
    11031128         
     
    11551180/* Many-to-one grouping */ 
    11561181 
    1157 /* 
    1158  * Display an artifact label 
    1159  */ 
    1160 static void display_artifact(int col, int row, bool cursor, int oid) 
    1161 
    1162         char o_name[80]; 
     1182static void get_artifact_display_name(char *o_name, size_t namelen, int a_idx) 
     1183
    11631184        object_type object_type_body; 
    11641185        object_type *o_ptr = &object_type_body; 
    11651186 
     1187        /* Make fake artifact */ 
     1188        o_ptr = &object_type_body; 
     1189        object_wipe(o_ptr); 
     1190        make_fake_artifact(o_ptr, a_idx); 
     1191 
     1192        /* Get its name */ 
     1193        object_desc_spoil(o_name, namelen, o_ptr, TRUE, 0); 
     1194} 
     1195 
     1196/* 
     1197 * Display an artifact label 
     1198 */ 
     1199static void display_artifact(int col, int row, bool cursor, int oid) 
     1200{ 
     1201        char o_name[80]; 
     1202 
    11661203        /* Choose a color */ 
    11671204        byte attr = curs_attrs[CURS_KNOWN][(int)cursor]; 
    11681205 
    1169         /* Get local object */ 
    1170         o_ptr = &object_type_body; 
    1171  
    1172         /* Wipe the object */ 
    1173         object_wipe(o_ptr); 
    1174  
    1175         /* Make fake artifact */ 
    1176         make_fake_artifact(o_ptr, oid); 
    1177  
    1178         /* Get its name */ 
    1179         object_desc_spoil(o_name, sizeof(o_name), o_ptr, TRUE, 0); 
     1206        get_artifact_display_name(o_name, sizeof o_name, oid); 
    11801207 
    11811208        /* Display the name */ 
     
    12081235        screen_save(); 
    12091236 
     1237        Term_gotoxy(0, 0); 
    12101238        object_info_screen(o_ptr); 
    12111239 
     
    12331261static int art2gid(int oid) { return obj_group_order[a_info[oid].tval]; } 
    12341262 
     1263/* Check if the given artifact idx is something we should "Know" about */ 
     1264static bool artifact_is_known(int a_idx) 
     1265{ 
     1266        int i; 
     1267 
     1268        /* Artifact doesn't exist at all, or not created yet */ 
     1269        if (!a_info[a_idx].name || a_info[a_idx].cur_num == 0) return FALSE; 
     1270 
     1271        /* Check all objects to see if it exists but hasn't been IDed */ 
     1272        for (i = 0; i < z_info->o_max; i++) 
     1273        { 
     1274                int a = o_list[i].name1; 
     1275 
     1276                /* If we haven't actually identified the artifact yet */ 
     1277                if (a && a == a_idx && !object_known_p(&o_list[i])) 
     1278                { 
     1279                        return FALSE; 
     1280                } 
     1281        } 
     1282 
     1283        /* Check inventory for the same */ 
     1284        for (i = 0; i < INVEN_TOTAL; i++) 
     1285        { 
     1286                object_type *o_ptr = &inventory[i]; 
     1287 
     1288                /* Ignore non-objects */ 
     1289                if (!o_ptr->k_idx) continue; 
     1290 
     1291 
     1292                if (o_ptr->name1 && o_ptr->name1 == a_idx &&  
     1293                    !object_known_p(o_ptr)) 
     1294                { 
     1295                        return FALSE; 
     1296                } 
     1297        } 
     1298 
     1299        return TRUE; 
     1300} 
     1301  
    12351302 
    12361303/* If 'artifacts' is NULL, it counts the number of known artifacts, otherwise 
     
    12391306{ 
    12401307        int a_count = 0; 
    1241         int i, j; 
     1308        int j; 
    12421309 
    12431310        if (artifacts) 
     
    12461313        for (j = 0; j < z_info->a_max; j++) 
    12471314        { 
    1248                 /* If the artifact has been created (or we're cheating) */ 
    1249                 if ((cheat_xtra || a_info[j].cur_num) && a_info[j].name) 
    1250                 { 
    1251                         bool valid = TRUE; 
    1252  
    1253                         for (i = 0; !cheat_xtra && i < z_info->o_max; i++) 
    1254                         { 
    1255                                 int a = o_list[i].name1; 
    1256  
    1257                                 /* If we haven't actually identified the artifact yet */ 
    1258                                 if (a && a == j && !object_known_p(&o_list[i])) 
    1259                                 { 
    1260                                         valid = FALSE; 
    1261                                 } 
    1262                         } 
    1263  
    1264                         if (valid) 
    1265                         { 
    1266                                 if (artifacts) 
    1267                                         artifacts[a_count++] = j; 
    1268                                 else 
    1269                                         a_count++; 
    1270                         } 
     1315                /* Artifact doesn't exist */ 
     1316                if (!a_info[j].name) continue; 
     1317 
     1318                if (cheat_xtra || artifact_is_known(j)) 
     1319                { 
     1320                        if (artifacts) 
     1321                                artifacts[a_count++] = j; 
     1322                        else 
     1323                                a_count++; 
    12711324                } 
    12721325        } 
     
    12821335        /* HACK -- should be TV_MAX */ 
    12831336        group_funcs obj_f = {TV_GOLD, FALSE, kind_name, a_cmp_tval, art2gid, 0}; 
    1284         member_funcs art_f = {display_artifact, desc_art_fake, 0, 0, 0, 0, 0}; 
     1337        member_funcs art_f = {display_artifact, desc_art_fake, 0, 0, recall_prompt, 0, 0}; 
    12851338 
    12861339        int *artifacts; 
     
    13421395        /* Begin recall */ 
    13431396        Term_gotoxy(0, 1); 
     1397        text_out("\n"); 
     1398 
    13441399        if (e_ptr->text) 
    13451400        { 
     
    13691424        Term_flush(); 
    13701425 
    1371         (void)inkey_ex(); 
     1426        text_out_c(TERM_L_BLUE, "\n\n[Press any key to continue]\n"); 
     1427        (void)anykey(); 
    13721428 
    13731429        screen_load(); 
     
    13961452                {TV_GOLD, FALSE, ego_grp_name, e_cmp_tval, default_group, 0}; 
    13971453 
    1398         member_funcs ego_f = {display_ego_item, desc_ego_fake, 0, 0, 0, 0, 0}; 
     1454        member_funcs ego_f = {display_ego_item, desc_ego_fake, 0, 0, recall_prompt, 0, 0}; 
    13991455 
    14001456        int *egoitems; 
     
    14321488/* =================== ORDINARY OBJECTS  ==================================== */ 
    14331489/* Many-to-one grouping */ 
     1490 
     1491/* 
     1492 * Looks up an artifact idx given an object_kind *that's already known 
     1493 * to be an artifact*.  Behaviour is distinctly unfriendly if passed 
     1494 * flavours which don't correspond to an artifact. 
     1495 */ 
     1496static int get_artifact_from_kind(object_kind *k_ptr) 
     1497{ 
     1498        int i; 
     1499 
     1500        assert(k_ptr->flags3 & TR3_INSTA_ART); 
     1501 
     1502        /* Look for the corresponding artifact */ 
     1503        for (i = 0; i < z_info->a_max; i++) 
     1504        { 
     1505                if (k_ptr->tval == a_info[i].tval && 
     1506                    k_ptr->sval == a_info[i].sval) 
     1507                { 
     1508                        break; 
     1509                } 
     1510        } 
     1511 
     1512        assert(i < z_info->a_max); 
     1513        return i; 
     1514} 
    14341515 
    14351516/* 
     
    14601541        } 
    14611542 
    1462         /* Tidy name */ 
    1463         object_kind_name(o_name, sizeof o_name, k_idx, cheat_know); 
     1543        /* Display known artifacts differently */ 
     1544        if ((k_ptr->flags3 & TR3_INSTA_ART) && artifact_is_known(get_artifact_from_kind(k_ptr))) 
     1545        { 
     1546                get_artifact_display_name(o_name, sizeof(o_name), get_artifact_from_kind(k_ptr)); 
     1547        } 
     1548        else 
     1549        { 
     1550                /* Tidy name */ 
     1551                object_kind_name(o_name, sizeof o_name, k_idx, cheat_know); 
     1552        } 
    14641553 
    14651554        /* Display the name */ 
     
    14851574static void desc_obj_fake(int k_idx) 
    14861575{ 
     1576        object_kind *k_ptr = &k_info[k_idx]; 
    14871577        object_type object_type_body; 
    14881578        object_type *o_ptr = &object_type_body; 
     1579 
     1580        /* Check for known artifacts, display them as artifacts */ 
     1581        if ((k_ptr->flags3 & TR3_INSTA_ART) && artifact_is_known(get_artifact_from_kind(k_ptr))) 
     1582        { 
     1583                desc_art_fake(get_artifact_from_kind(k_ptr)); 
     1584                return; 
     1585        } 
    14891586 
    14901587        /* Wipe the object */ 
     
    15681665        object_kind *k_ptr = &k_info[oid]; 
    15691666        s16b idx = get_autoinscription_index(oid); 
    1570  
    1571         const char *no_insc = ", '{'"; 
    1572         const char *with_insc = ", '{', '}'"; 
     1667                         
     1668        const char *no_insc = ", 'r' to recall, '{'"; 
     1669        const char *with_insc = ", 'r' to recall, '{', '}'"; 
    15731670 
    15741671