Esempio n. 1
0
static void _display(rect_t r, int options)
{
    doc_ptr doc = doc_alloc(r.cx);
    _list_spells(doc, options);
    doc_sync_term(doc, doc_range_all(doc), doc_pos_create(r.x, r.y));
    doc_free(doc);
}
Esempio n. 2
0
static int _choose_spell(spell_info* spells, int ct, cptr desc, int max_cost)
{
    int choice = -1;
    char prompt1[140];
    char prompt2[140];
    variant name;
    bool describe = FALSE;

    var_init(&name);

    for (;;)
    {
        char ch = '\0';

        strnfmt(prompt1, 78, "Use which %s? (Type '?' to Browse) ", desc);
        strnfmt(prompt2, 78, "Browse which %s? (Type '?' to Use)", desc);
        _list_spells(spells, ct, max_cost);

        /* Prompt User */
        choice = -1;

        if (!get_com(describe ? prompt2 : prompt1, &ch, FALSE)) break;

        if (ch == '?')
        {
            describe = !describe;
            if (!get_com(describe ? prompt2 : prompt1, &ch, FALSE)) break;
        }

        if (isupper(ch))
            choice = ch - 'A' + 26;
        else if (islower(ch))
            choice = ch - 'a';
        else if (ch >= '0' && ch <= '9')
            choice = ch - '0' + 52;

        /* Valid Choice? */
        if (choice < 0 || choice >= ct)
        {
            bell();
            continue;
        }

        if (describe)
        {
            _describe_spell(&spells[choice], _col_height(ct));
            continue;
        }

        /* Good to go! */
        break;
    }
    
    var_clear(&name);
    return choice;
}
Esempio n. 3
0
/**********************************************************************
 * Private Helpers
 **********************************************************************/
static void _character_dump(doc_ptr doc)
{
    doc_printf(doc, "<topic:Spells>==================================== <color:keypress>S</color>pells ===================================\n\n");
    _list_spells(doc, _SHOW_INFO | _SHOW_STATS);
    doc_newline(doc);
}