static rect_t _menu_rect(void)
{
    rect_t r = ui_menu_rect();
    if (r.cx > 80)
        r.cx = 80;
    return r;
}
Exemple #2
0
static int _col_height(int ct)
{
    int    result = ct;
    rect_t display = ui_menu_rect();

    display.cy -= 5; /* Room for browsing */
    if (result > display.cy)
    {
        result = (ct + 1)/2;
    }

    return result;
}
Exemple #3
0
static bool _describe_spell(spell_info *spell, int col_height)
{
    bool result = TRUE;
    variant info;

    var_init(&info);

    (spell->fn)(SPELL_ON_BROWSE, &info);
    if (!var_get_bool(&info))
    {
        char tmp[62*5];
        int i, line;
        rect_t display = ui_menu_rect();

        /* 2 lines below list of spells, 5 lines for description */
        for (i = 0; i < 7; i++)
            Term_erase(display.x, display.y + col_height + i + 2, display.cx);

        /* Get the description, and line break it (max 5 lines) */
        (spell->fn)(SPELL_DESC, &info);
        roff_to_buf(var_get_string(&info), 62, tmp, sizeof(tmp));

        line = display.y + col_height + 3;
        for(i = 0; tmp[i]; i += 1+strlen(&tmp[i]))
        {
            put_str(&tmp[i], line, display.x + 2);
            line++;
        }

        (spell->fn)(SPELL_INFO, &info);
        put_str(format("%^s", var_get_string(&info)), line, display.x + 2);
        result = FALSE;
    }
    var_clear(&info);
    return result;
}
Exemple #4
0
static bool choose_kamae(void)
{
    char choice;
    int new_kamae = 0;
    int i;
    rect_t display = ui_menu_rect();
    char buf[80];

    if (display.cx > 40)
        display.cx = 40;

    if (p_ptr->confused)
    {
        msg_print("You are too confused.");
        return FALSE;
    }

    screen_save();

    Term_erase(display.x, display.y, display.cx);
    put_str("Choose Form: ", display.y, display.x + 1);

    Term_erase(display.x, display.y + 1, display.cx);
    put_str(" a) No form", display.y + 1, display.x + 1);

    for (i = 0; i < MAX_KAMAE; i++)
    {
        if (p_ptr->lev >= kamae_shurui[i].min_level)
        {
            sprintf(buf," %c) %-12s  %s",I2A(i+1), kamae_shurui[i].desc, kamae_shurui[i].info);
            Term_erase(display.x, display.y + 2 + i, display.cx);
            put_str(buf, display.y + 2 + i, display.x + 1);
        }
    }

    while(1)
    {
        choice = inkey();
        if (choice == ESCAPE)
        {
            screen_load();
            return FALSE;
        }
        else if ((choice == 'a') || (choice == 'A'))
        {
            if (p_ptr->action == ACTION_KAMAE)
                set_action(ACTION_NONE);
            else
                msg_print("You are not assuming a posture.");
            screen_load();
            return TRUE;
        }
        else if ((choice == 'b') || (choice == 'B'))
        {
            new_kamae = 0;
            break;
        }
        else if (((choice == 'c') || (choice == 'C')) && (p_ptr->lev > 29))
        {
            new_kamae = 1;
            break;
        }
        else if (((choice == 'd') || (choice == 'D')) && (p_ptr->lev > 34))
        {
            new_kamae = 2;
            break;
        }
        else if (((choice == 'e') || (choice == 'E')) && (p_ptr->lev > 39))
        {
            new_kamae = 3;
            break;
        }
    }
    set_action(ACTION_KAMAE);

    if (p_ptr->special_defense & (KAMAE_GENBU << new_kamae))
        msg_print("You reassume a posture.");
    else
    {
        p_ptr->special_defense &= ~(KAMAE_MASK);
        p_ptr->update |= (PU_BONUS);
        p_ptr->redraw |= (PR_STATE);
        msg_format("You assume a posture of %s form.",kamae_shurui[new_kamae].desc);
        p_ptr->special_defense |= (KAMAE_GENBU << new_kamae);
    }
    p_ptr->redraw |= PR_STATE;
    screen_load();
    return TRUE;
}
Exemple #5
0
static void _list_spells(spell_info* spells, int ct, int max_cost)
{
    char temp[140];
    int  i;
    rect_t display = ui_menu_rect();
    int  col_height = _col_height(ct);
    int  col_width;
    variant name, info, color;

    var_init(&name);
    var_init(&info);
    var_init(&color);

    Term_erase(display.x, display.y, display.cx);
    if (col_height == ct)
    {
        put_str("Lvl Cost Fail Desc", display.y, display.x + 29);
    }
    else
    {
        col_width = 42;
        put_str("Lvl Cost Fail", display.y, display.x + 29);
        put_str("Lvl Cost Fail", display.y, display.x + col_width + 29);
    }

    for (i = 0; i < ct; i++)
    {
        char letter = '\0';
        byte attr = TERM_WHITE;
        spell_info* spell = &spells[i];

        var_set_int(&color, TERM_WHITE);

        (spell->fn)(SPELL_NAME, &name);
        (spell->fn)(SPELL_INFO, &info);
        (spell->fn)(SPELL_COLOR, &color);

        attr = var_get_int(&color);

        if (i < 26)
            letter = I2A(i);
        else if (i < 52)
            letter = 'A' + i - 26;
        else
            letter = '0' + i - 52;

        sprintf(temp, "  %c) ", letter);

        strcat(temp, format("%-23.23s %3d %4d %3d%%", 
                            var_get_string(&name),
                            spell->level,
                            spell->cost,
                            spell->fail));

        if (col_height == ct)
            strcat(temp, format(" %s", var_get_string(&info)));

        if (spell->fail == 100)
            attr = TERM_L_DARK;

        if (spell->cost > max_cost)
            attr = TERM_L_DARK;

        if (spell->level > p_ptr->lev)
            attr = TERM_L_DARK;

        if (i < col_height)
        {
            Term_erase(display.x, display.y + i + 1, display.cx);
            c_put_str(attr, temp, display.y + i + 1, display.x);
        }
        else
        {
            c_put_str(attr, temp, display.y + (i - col_height) + 1, display.x + col_width);
        }
    }
    Term_erase(display.x, display.y + col_height + 1, display.cx);
    var_clear(&name);
    var_clear(&info);
    var_clear(&color);
}