/** * Display a row of the spell menu */ static void spell_menu_display(struct menu *m, int oid, bool cursor, int row, int col, int wid) { struct spell_menu_data *d = menu_priv(m); int spell_index = d->spells[oid]; const struct class_spell *spell = spell_by_index(spell_index); char help[30]; char out[80]; int attr; const char *illegible = NULL; const char *comment = NULL; if (spell->slevel >= 99) { illegible = "(illegible)"; attr = COLOUR_L_DARK; } else if (player->spell_flags[spell_index] & PY_SPELL_FORGOTTEN) { comment = " forgotten"; attr = COLOUR_YELLOW; } else if (player->spell_flags[spell_index] & PY_SPELL_LEARNED) { if (player->spell_flags[spell_index] & PY_SPELL_WORKED) { /* Get extra info */ get_spell_info(spell_index, help, sizeof(help)); comment = help; attr = COLOUR_WHITE; } else { comment = " untried"; attr = COLOUR_L_GREEN; } } else if (spell->slevel <= player->lev) { comment = " unknown"; attr = COLOUR_L_BLUE; } else { comment = " difficult"; attr = COLOUR_RED; } /* Dump the spell --(-- */ strnfmt(out, sizeof(out), "%-30s%2d %4d %3d%%%s", spell->name, spell->slevel, spell->smana, spell_chance(spell_index), comment); c_prt(attr, illegible ? illegible : out, row, col); }
/** * Display a row of the spell menu */ static void spell_menu_display(menu_type * m, int oid, bool cursor, int row, int col, int wid) { struct spell_menu_data *d = menu_priv(m); int spell = d->spells[oid]; const magic_type *s_ptr = &mp_ptr->info[spell]; char help[30]; int attr_name, attr_extra, attr_book; int tval = mp_ptr->spell_book; const char *comment = NULL; /* Choose appropriate spellbook color. */ if (tval == TV_MAGIC_BOOK) { if (d->book_sval < SV_BOOK_MIN_GOOD) attr_book = TERM_L_RED; else attr_book = TERM_RED; } else if (tval == TV_PRAYER_BOOK) { if (d->book_sval < SV_BOOK_MIN_GOOD) attr_book = TERM_L_BLUE; else attr_book = TERM_BLUE; } else if (tval == TV_DRUID_BOOK) { if (d->book_sval < SV_BOOK_MIN_GOOD) attr_book = TERM_L_GREEN; else attr_book = TERM_GREEN; } else if (tval == TV_NECRO_BOOK) { if (d->book_sval < SV_BOOK_MIN_GOOD) attr_book = TERM_L_PURPLE; else attr_book = TERM_PURPLE; } else attr_book = TERM_WHITE; if (p_ptr->spell_flags[spell] & PY_SPELL_FORGOTTEN) { comment = " forgotten"; attr_name = TERM_L_WHITE; attr_extra = TERM_L_WHITE; } else if (p_ptr->spell_flags[spell] & PY_SPELL_LEARNED) { if (p_ptr->spell_flags[spell] & PY_SPELL_WORKED) { /* Get extra info */ get_spell_info(mp_ptr->spell_book, s_ptr->index, help, sizeof(help)); comment = help; attr_name = attr_book; attr_extra = TERM_DEEP_L_BLUE; } else { comment = " untried"; attr_name = TERM_WHITE; attr_extra = TERM_WHITE; } } else if (s_ptr->slevel <= p_ptr->lev) { comment = " unknown"; attr_extra = TERM_L_WHITE; attr_name = TERM_WHITE; } else { comment = " difficult"; attr_extra = TERM_MUD; attr_name = TERM_MUD; } /* Dump the spell --(-- */ c_put_str(attr_name, format("%-30s", get_spell_name(s_ptr->index)), row, col); put_str(format ("%2d %4d %3d%%", s_ptr->slevel, s_ptr->smana, spell_chance(spell)), row, col + 30); c_put_str(attr_extra, format("%s", comment), row, col + 42); }