| 70 | | int maxnum; /* Maximum possible item count for this class */ |
|---|
| 71 | | bool easy_know; /* Items don't need to be IDed to recognize membership */ |
|---|
| 72 | | |
|---|
| 73 | | const char *(*name)(int gid); /* name of this group */ |
|---|
| 74 | | |
|---|
| 75 | | /* Compare, in group and display order */ |
|---|
| 76 | | /* Optional, if already sorted */ |
|---|
| 77 | | int (*gcomp)(const void *, const void *); /* Compare GroupIDs of two oids */ |
|---|
| 78 | | int (*group)(int oid); /* Group ID for of an oid */ |
|---|
| 79 | | bool (*aware)(object_type *obj); /* Object is known sufficiently for group */ |
|---|
| 80 | | |
|---|
| 81 | | /* summary function for the "object" information. */ |
|---|
| 82 | | void (*summary)(int gid, const int *object_list, int n, int top, int row, int col); |
|---|
| | 72 | int maxnum; /* Maximum possible item count for this class */ |
|---|
| | 73 | bool easy_know; /* Items don't need to be IDed to recognize membership */ |
|---|
| | 74 | |
|---|
| | 75 | const char *(*name)(int gid); /* name of this group */ |
|---|
| | 76 | |
|---|
| | 77 | /* Compare, in group and display order */ |
|---|
| | 78 | /* Optional, if already sorted */ |
|---|
| | 79 | int (*gcomp)(const void *, const void *); /* Compare GroupIDs of two oids */ |
|---|
| | 80 | int (*group)(int oid); /* Group ID for of an oid */ |
|---|
| | 81 | |
|---|
| | 82 | /* summary function for the "object" information. */ |
|---|
| | 83 | void (*summary)(int gid, const int *object_list, int n, int top, int row, int col); |
|---|
| | 84 | |
|---|
| 87 | | |
|---|
| 88 | | /* Print a tabular-formatted description for an oid */ |
|---|
| 89 | | /* This includes things like kill-count, the current graphic, */ |
|---|
| 90 | | /* any tile illumination info. Item id for Wizard mode and */ |
|---|
| 91 | | /* autoinscription are handled by the caller */ |
|---|
| 92 | | void (*display_member)(int col, int row, bool cursor, int oid); |
|---|
| 93 | | |
|---|
| 94 | | void (*lore)(int oid); /* Dump known lore to screen*/ |
|---|
| 95 | | |
|---|
| 96 | | |
|---|
| 97 | | /* Required only for objects with modifiable display attributes */ |
|---|
| 98 | | /* Unknown 'flavors' return flavor attributes */ |
|---|
| 99 | | char *(*xchar)(int oid); /* get character attr for OID (by address) */ |
|---|
| 100 | | byte *(*xattr)(int oid); /* get color attr for OID (by address) */ |
|---|
| 101 | | |
|---|
| 102 | | /* Required only for manipulable (ordinary) objects */ |
|---|
| 103 | | /* Address of inscription. Unknown 'flavors' return null */ |
|---|
| 104 | | u16b *(*note)(int oid); |
|---|
| 105 | | |
|---|
| 106 | | /* extra context for display of members */ |
|---|
| 107 | | bool is_visual; |
|---|
| | 89 | /* Print a tabular-formatted description for an oid */ |
|---|
| | 90 | /* This includes things like kill-count, the current graphic, */ |
|---|
| | 91 | /* any tile illumination info. Item id for Wizard mode and */ |
|---|
| | 92 | /* autoinscription are handled by the caller */ |
|---|
| | 93 | void (*display_member)(int col, int row, bool cursor, int oid); |
|---|
| | 94 | |
|---|
| | 95 | void (*lore)(int oid); /* Dump known lore to screen*/ |
|---|
| | 96 | |
|---|
| | 97 | |
|---|
| | 98 | /* Required only for objects with modifiable display attributes */ |
|---|
| | 99 | /* Unknown 'flavors' return flavor attributes */ |
|---|
| | 100 | char *(*xchar)(int oid); /* get character attr for OID (by address) */ |
|---|
| | 101 | byte *(*xattr)(int oid); /* get color attr for OID (by address) */ |
|---|
| | 102 | |
|---|
| | 103 | |
|---|
| | 104 | const char *(*xtra_prompt)(int oid); /* For kinds that need extra prompts */ |
|---|
| | 105 | void (*xtra_act)(char ch, int oid); /* For kinds that need extra actions */ |
|---|
| | 106 | |
|---|
| | 107 | |
|---|
| | 108 | /* extra context for display of members */ |
|---|
| | 109 | bool is_visual; |
|---|
| 303 | | /* |
|---|
| 304 | | * Interact with inscriptions. |
|---|
| 305 | | * Create a copy of an existing quark, except if the quark has '=x' in it, |
|---|
| 306 | | * If an quark has '=x' in it remove it from the copied string, otherwise append it where 'x' is ch. |
|---|
| 307 | | * Return the new quark location. |
|---|
| 308 | | */ |
|---|
| 309 | | static int auto_note_modify(int note, char ch) |
|---|
| 310 | | { |
|---|
| 311 | | char tmp[80]; |
|---|
| 312 | | |
|---|
| 313 | | cptr s; |
|---|
| 314 | | |
|---|
| 315 | | /* Paranoia */ |
|---|
| 316 | | if (!ch) return(note); |
|---|
| 317 | | |
|---|
| 318 | | /* Null length string to start */ |
|---|
| 319 | | tmp[0] = '\0'; |
|---|
| 320 | | |
|---|
| 321 | | /* Inscription */ |
|---|
| 322 | | if (note) |
|---|
| 323 | | { |
|---|
| 324 | | |
|---|
| 325 | | /* Get the inscription */ |
|---|
| 326 | | s = quark_str(note); |
|---|
| 327 | | |
|---|
| 328 | | /* Temporary copy */ |
|---|
| 329 | | my_strcpy(tmp,s,80); |
|---|
| 330 | | |
|---|
| 331 | | /* Process inscription */ |
|---|
| 332 | | while (s) |
|---|
| 333 | | { |
|---|
| 334 | | |
|---|
| 335 | | /* Auto-pickup on "=g" */ |
|---|
| 336 | | if (s[1] == ch) |
|---|
| 337 | | { |
|---|
| 338 | | |
|---|
| 339 | | /* Truncate string */ |
|---|
| 340 | | tmp[strlen(tmp)-strlen(s)] = '\0'; |
|---|
| 341 | | |
|---|
| 342 | | /* Overwrite shorter string */ |
|---|
| 343 | | my_strcat(tmp,s+2,80); |
|---|
| 344 | | |
|---|
| 345 | | /* Create quark */ |
|---|
| 346 | | return(quark_add(tmp)); |
|---|
| 347 | | } |
|---|
| 348 | | |
|---|
| 349 | | /* Find another '=' */ |
|---|
| 350 | | s = strchr(s + 1, '='); |
|---|
| 351 | | } |
|---|
| 352 | | } |
|---|
| 353 | | |
|---|
| 354 | | /* Append note */ |
|---|
| 355 | | my_strcat(tmp,format("=%c",ch),80); |
|---|
| 356 | | |
|---|
| 357 | | /* Create quark */ |
|---|
| 358 | | return(quark_add(tmp)); |
|---|
| 359 | | } |
|---|
| 360 | | |
|---|
| 567 | | const char *pnote = (!o_funcs.note || !o_funcs.note(oid)) ? |
|---|
| 568 | | "" : ((note_idx) ? ", '\\' to re-inscribe" : ""); |
|---|
| 569 | | |
|---|
| 570 | | const char *pnote1 = (!o_funcs.note || !o_funcs.note(oid)) ? |
|---|
| 571 | | "" : ", '{', '}', 'k', 'g', ..."; |
|---|
| 572 | | |
|---|
| 573 | | const char *pvs = (!o_funcs.xattr) ? "" : ", 'v' for visuals"; |
|---|
| | 509 | const char *pvs = o_funcs.xattr ? ", 'v' for visuals" : ""; |
|---|
| | 510 | const char *xtra = o_funcs.xtra_prompt ? o_funcs.xtra_prompt(oid) : ""; |
|---|
| 578 | | prt(format("<dir>, 'r' to recall%s ESC%s%s%s", |
|---|
| 579 | | pvs, pedit, pnote, pnote1), hgt-1, 0); |
|---|
| 580 | | } |
|---|
| | 515 | prt(format("<dir>, 'r' to recall%s%s%s, ESC", pvs, pedit, xtra), hgt-1, 0); |
|---|
| | 516 | } |
|---|
| | 517 | |
|---|
| 681 | | /* HACK: make this a function. Replace g_funcs.aware() */ |
|---|
| 682 | | case '{': |
|---|
| 683 | | case '}': |
|---|
| 684 | | case '\\': |
|---|
| 685 | | /* precondition -- valid object */ |
|---|
| 686 | | if (o_funcs.note == NULL || o_funcs.note(oid) == 0) |
|---|
| 687 | | break; |
|---|
| 688 | | { |
|---|
| 689 | | char note_text[80] = ""; |
|---|
| 690 | | u16b *note = o_funcs.note(oid); |
|---|
| 691 | | u16b old_note = *note; |
|---|
| 692 | | |
|---|
| 693 | | if (ke.key == '{') |
|---|
| 694 | | { |
|---|
| 695 | | /* Prompt */ |
|---|
| 696 | | prt("Inscribe with: ", hgt, 0); |
|---|
| 697 | | |
|---|
| 698 | | /* Default note */ |
|---|
| 699 | | if (old_note) |
|---|
| 700 | | strnfmt(note_text, sizeof note_text, "%s", quark_str(old_note)); |
|---|
| 701 | | |
|---|
| 702 | | /* Get a filename */ |
|---|
| 703 | | if (!askfor_aux(note_text, sizeof note_text, NULL)) continue; |
|---|
| 704 | | |
|---|
| 705 | | /* Set the inscription */ |
|---|
| 706 | | *note = quark_add(note_text); |
|---|
| 707 | | |
|---|
| 708 | | /* Set the current default note */ |
|---|
| 709 | | note_idx = *note; |
|---|
| 710 | | } |
|---|
| 711 | | else if (ke.key == '}') |
|---|
| 712 | | { |
|---|
| 713 | | *note = 0; |
|---|
| 714 | | } |
|---|
| 715 | | else |
|---|
| 716 | | { |
|---|
| 717 | | /* '\\' */ |
|---|
| 718 | | *note = note_idx; |
|---|
| 719 | | } |
|---|
| 720 | | |
|---|
| 721 | | /* Process existing objects */ |
|---|
| 722 | | for (i = 1; i < o_max; i++) |
|---|
| 723 | | { |
|---|
| 724 | | /* Get the object */ |
|---|
| 725 | | object_type *i_ptr = &o_list[i]; |
|---|
| 726 | | |
|---|
| 727 | | /* Skip dead or differently sourced items */ |
|---|
| 728 | | if (!i_ptr->k_idx || i_ptr->note != old_note) continue; |
|---|
| 729 | | |
|---|
| 730 | | /* Not matching item */ |
|---|
| 731 | | if (!g_funcs.group(oid) != i_ptr->tval) continue; |
|---|
| 732 | | |
|---|
| 733 | | /* Auto-inscribe */ |
|---|
| 734 | | if (g_funcs.aware(i_ptr) || cheat_peek) |
|---|
| 735 | | i_ptr->note = note_idx; |
|---|
| 736 | | } |
|---|
| 737 | | |
|---|
| 738 | | break; |
|---|
| 739 | | } |
|---|
| 740 | | |
|---|
| 1114 | | m_cmp_race, default_group, 0, mon_summary}; |
|---|
| 1115 | | |
|---|
| 1116 | | member_funcs m_funcs = {display_monster, mon_lore, m_xchar, m_xattr, 0, 0}; |
|---|
| | 993 | m_cmp_race, default_group, mon_summary}; |
|---|
| | 994 | |
|---|
| | 995 | member_funcs m_funcs = {display_monster, mon_lore, m_xchar, m_xattr, 0, 0, 0}; |
|---|
| 1257 | | group_funcs obj_f = {TV_GOLD, FALSE, kind_name, a_cmp_tval, art2tval, 0, 0}; |
|---|
| 1258 | | member_funcs art_f = {display_artifact, desc_art_fake, 0, 0, 0, 0}; |
|---|
| | 1136 | group_funcs obj_f = {TV_GOLD, FALSE, kind_name, a_cmp_tval, art2tval, 0}; |
|---|
| | 1137 | member_funcs art_f = {display_artifact, desc_art_fake, 0, 0, 0, 0, 0}; |
|---|
| 1387 | | {TV_GOLD, FALSE, ego_grp_name, e_cmp_tval, default_group, 0, 0}; |
|---|
| 1388 | | |
|---|
| 1389 | | member_funcs ego_f = {display_ego_item, desc_ego_fake, 0, 0, 0, 0/*e_note */ }; |
|---|
| | 1266 | {TV_GOLD, FALSE, ego_grp_name, e_cmp_tval, default_group, 0}; |
|---|
| | 1267 | |
|---|
| | 1268 | member_funcs ego_f = {display_ego_item, desc_ego_fake, 0, 0, 0, 0, 0}; |
|---|
| 1535 | | int ind = get_autoinscription_index(oid); |
|---|
| 1536 | | if (!k_ptr->flavor || k_ptr->aware) return (u16b*) &inscriptions[ind].inscription_idx; |
|---|
| 1537 | | else return 0; |
|---|
| 1538 | | } |
|---|
| | 1424 | s16b idx = get_autoinscription_index(oid); |
|---|
| | 1425 | |
|---|
| | 1426 | const char *no_insc = ", '{'"; |
|---|
| | 1427 | const char *with_insc = ", '{', '}'"; |
|---|
| | 1428 | |
|---|
| | 1429 | |
|---|
| | 1430 | /* Forget it if we've never seen the thing */ |
|---|
| | 1431 | if (!k_ptr->everseen) |
|---|
| | 1432 | return ""; |
|---|
| | 1433 | |
|---|
| | 1434 | /* If it's already inscribed */ |
|---|
| | 1435 | if (idx != -1) |
|---|
| | 1436 | return with_insc; |
|---|
| | 1437 | |
|---|
| | 1438 | return no_insc; |
|---|
| | 1439 | } |
|---|
| | 1440 | |
|---|
| | 1441 | /* |
|---|
| | 1442 | * Special key actions for object inscription. |
|---|
| | 1443 | */ |
|---|
| | 1444 | static void o_xtra_act(char ch, int oid) |
|---|
| | 1445 | { |
|---|
| | 1446 | object_kind *k_ptr = &k_info[oid]; |
|---|
| | 1447 | s16b idx = get_autoinscription_index(oid); |
|---|
| | 1448 | |
|---|
| | 1449 | /* Forget it if we've never seen the thing */ |
|---|
| | 1450 | if (!k_ptr->everseen) |
|---|
| | 1451 | return; |
|---|
| | 1452 | |
|---|
| | 1453 | /* Uninscribe */ |
|---|
| | 1454 | if (ch == '}') |
|---|
| | 1455 | { |
|---|
| | 1456 | if (idx) remove_autoinscription(oid); |
|---|
| | 1457 | return; |
|---|
| | 1458 | } |
|---|
| | 1459 | |
|---|
| | 1460 | /* Inscribe */ |
|---|
| | 1461 | else if (ch == '{') |
|---|
| | 1462 | { |
|---|
| | 1463 | char note_text[80] = ""; |
|---|
| | 1464 | |
|---|
| | 1465 | /* Avoid the prompt getting in the way */ |
|---|
| | 1466 | screen_save(); |
|---|
| | 1467 | |
|---|
| | 1468 | /* Prompt */ |
|---|
| | 1469 | prt("Inscribe with: ", 0, 0); |
|---|
| | 1470 | |
|---|
| | 1471 | /* Default note */ |
|---|
| | 1472 | if (idx != -1) |
|---|
| | 1473 | strnfmt(note_text, sizeof(note_text), "%s", get_autoinscription(oid)); |
|---|
| | 1474 | |
|---|
| | 1475 | /* Get an inscription */ |
|---|
| | 1476 | if (askfor_aux(note_text, sizeof(note_text), NULL)) |
|---|
| | 1477 | { |
|---|
| | 1478 | /* Remove old inscription if existent */ |
|---|
| | 1479 | if (idx != -1) |
|---|
| | 1480 | remove_autoinscription(oid); |
|---|
| | 1481 | |
|---|
| | 1482 | /* Add the autoinscription */ |
|---|
| | 1483 | add_autoinscription(oid, note_text); |
|---|
| | 1484 | |
|---|
| | 1485 | /* Notice stuff (later) */ |
|---|
| | 1486 | p_ptr->notice |= (PN_AUTOINSCRIBE); |
|---|
| | 1487 | p_ptr->window |= (PW_INVEN | PW_EQUIP); |
|---|
| | 1488 | } |
|---|
| | 1489 | |
|---|
| | 1490 | /* Reload the screen */ |
|---|
| | 1491 | screen_load(); |
|---|
| | 1492 | } |
|---|
| | 1493 | } |
|---|
| | 1494 | |
|---|
| | 1495 | |
|---|
| 1545 | | group_funcs kind_f = {TV_GOLD, FALSE, kind_name, o_cmp_tval, obj2gid, 0, 0}; |
|---|
| 1546 | | member_funcs obj_f = {display_object, desc_obj_fake, o_xchar, o_xattr,0 /* o_note*/}; |
|---|
| | 1502 | group_funcs kind_f = {TV_GOLD, FALSE, kind_name, o_cmp_tval, obj2gid, 0}; |
|---|
| | 1503 | member_funcs obj_f = {display_object, desc_obj_fake, o_xchar, o_xattr, o_xtra_prompt, o_xtra_act, 0}; |
|---|
| 1618 | | fkind_name, f_cmp_fkind, feat_order, 0, 0}; |
|---|
| 1619 | | |
|---|
| 1620 | | member_funcs feat_f = {display_feature, feat_lore, f_xchar, f_xattr, 0}; |
|---|
| | 1577 | fkind_name, f_cmp_fkind, feat_order, 0}; |
|---|
| | 1578 | |
|---|
| | 1579 | member_funcs feat_f = {display_feature, feat_lore, f_xchar, f_xattr, 0, 0, 0}; |
|---|