Ejemplo n.º 1
0
void veh_interact::display_mode (char mode)
{
    werase (w_mode);
    if (mode == ' ')
    {
        bool mi = !cant_do('i');
        bool mr = !cant_do('r');
        bool mf = !cant_do('f');
        bool mo = !cant_do('o');
        bool ms = !cant_do('s');
        mvwprintz(w_mode, 0, 1, mi? c_ltgray : c_dkgray, "install");
        mvwputch (w_mode, 0, 1, mi? c_ltgreen : c_green, 'i');
        mvwprintz(w_mode, 0, 9, mr? c_ltgray : c_dkgray, "repair");
        mvwputch (w_mode, 0, 9, mr? c_ltgreen : c_green, 'r');
        mvwprintz(w_mode, 0, 16, mf? c_ltgray : c_dkgray, "refill");
        mvwputch (w_mode, 0, 18, mf? c_ltgreen : c_green, 'f');
        mvwprintz(w_mode, 0, 23, mo? c_ltgray : c_dkgray, "remove");
        mvwputch (w_mode, 0, 26, mo? c_ltgreen : c_green, 'o');
        mvwprintz(w_mode, 0, 30, ms? c_ltgray : c_dkgray, "siphon");
        mvwputch (w_mode, 0, 30, ms? c_ltgreen : c_green, 's');
    }
    mvwprintz(w_mode, 0, 37, c_ltgray, "rename");
    mvwputch (w_mode, 0, 38, c_ltgreen, 'e');
    mvwprintz(w_mode, 0, 71, c_ltgreen, "ESC");
    mvwprintz(w_mode, 0, 74, c_ltgray, "-back");
    wrefresh (w_mode);
}
Ejemplo n.º 2
0
/**
 * Prints the list of usable commands at the top of the window, and highlights
 * the hotkeys used to activate them.
 * @param mode What command we are currently using. ' ' for no command.
 */
void veh_interact::display_mode (char mode)
{
    werase (w_mode);
    int x = 1;
    if (mode == ' ')
    {
        bool mi = !cant_do('i');
        bool mr = !cant_do('r');
        bool mf = !cant_do('f');
        bool mo = !cant_do('o');
        bool ms = !cant_do('s');
        bool mc = !cant_do('c');
        x += shortcut_print(w_mode, 0, x, mi? c_ltgray : c_dkgray, mi? c_ltgreen : c_green, _("<i>nstall"))+1;
        x += shortcut_print(w_mode, 0, x, mr? c_ltgray : c_dkgray, mr? c_ltgreen : c_green, _("<r>epair"))+1;
        x += shortcut_print(w_mode, 0, x, mf? c_ltgray : c_dkgray, mf? c_ltgreen : c_green, _("re<f>ill"))+1;
        x += shortcut_print(w_mode, 0, x, mo? c_ltgray : c_dkgray, mo? c_ltgreen : c_green, _("rem<o>ve"))+1;
        x += shortcut_print(w_mode, 0, x, ms? c_ltgray : c_dkgray, ms? c_ltgreen : c_green, _("<s>iphon"))+1;
        x += shortcut_print(w_mode, 0, x, ms? c_ltgray : c_dkgray, ms? c_ltgreen : c_green, _("<d>rain water"))+1;
        x += shortcut_print(w_mode, 0, x, mc? c_ltgray : c_dkgray, mc? c_ltgreen : c_green, _("<c>hange tire"))+1;
    }
    x += shortcut_print(w_mode, 0, x, c_ltgray, c_ltgreen, _("r<e>name"))+1;
    std::string backstr = _("<ESC>-back");
    int w = utf8_width(backstr.c_str())-2;
    x = 78-w; // right text align
    shortcut_print(w_mode, 0, x, c_ltgray, c_ltgreen, _("<ESC>-back"));
    wrefresh (w_mode);
}
Ejemplo n.º 3
0
/**
 * Creates a veh_interact window based on the given parameters.
 * @param v The vehicle the player is interacting with.
 * @param x The x-coordinate of the square the player is 'e'xamining.
 * @param y The y-coordinate of the square the player is 'e'xamining.
 */
void veh_interact::exec (game *gm, vehicle *v, int x, int y)
{
    g = gm;
    veh = v;
    //        x1      x2
    // y1 ----+------+--
    //        |      |
    // y2 ----+------+
    //               |
    //               |
    winw1 = 12;
    winw2 = 35;
    winh1 = 3;
    winh2 = 12;
    winw12 = winw1 + winw2 + 1;
    winw3 = FULL_SCREEN_WIDTH - winw1 - winw2 - 2;
    winh3 = FULL_SCREEN_HEIGHT - winh1 - winh2 - 2;
    winh23 = winh2 + winh3 + 1;
    winx1 = winw1;
    winx2 = winw1 + winw2 + 1;
    winy1 = winh1;
    winy2 = winh1 + winh2 + 1;

    // changed FALSE value to 1, to keep w_border from starting at a negative x,y
    const int iOffsetX = (TERMX > FULL_SCREEN_WIDTH) ? (TERMX-FULL_SCREEN_WIDTH)/2 : 1;
    const int iOffsetY = (TERMY > FULL_SCREEN_HEIGHT) ? (TERMY-FULL_SCREEN_HEIGHT)/2 : 1;

    page_size = winh23;

    //               h   w    y     x
    WINDOW *w_border= newwin(FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH,  -1 + iOffsetY,    -1 + iOffsetX);
    w_grid  = newwin(FULL_SCREEN_HEIGHT -2, FULL_SCREEN_WIDTH-2,  iOffsetY,    iOffsetX);
    w_mode  = newwin(1,  FULL_SCREEN_WIDTH-2, iOffsetY,    iOffsetX);
    w_msg   = newwin(winh1 - 1, FULL_SCREEN_WIDTH-2, 1 + iOffsetY,    iOffsetX);
    w_disp  = newwin(winh2-1, winw1,  winy1 + 1 + iOffsetY, iOffsetX);
    w_parts = newwin(winh2-1, winw2,  winy1 + 1 + iOffsetY, winx1 + 1 + iOffsetX);
    w_stats = newwin(winh3-1, winw12, winy2 + iOffsetY, iOffsetX);
    w_list  = newwin(winh23, winw3, winy1 + 1 + iOffsetY, winx2 + 1 + iOffsetX);

    wborder(w_border, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX,
                      LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX );

    mvwputch(w_border, 16, 0, c_ltgray, LINE_XXXO); // |-
    mvwputch(w_border, 4, 0, c_ltgray, LINE_XXXO); // |-
    mvwputch(w_border, 4, FULL_SCREEN_WIDTH-1, c_ltgray, LINE_XOXX); // -|
    mvwputch(w_border, 24, 49, c_ltgray, LINE_XXOX);

    wrefresh(w_border);

    for (int i = 0; i < FULL_SCREEN_HEIGHT; i++)
    {
        mvwputch(w_grid, i, winx2, c_ltgray, i == winy1 || i == winy2-1? LINE_XOXX : LINE_XOXO);
        if (i >= winy1 && i < winy2) {
            mvwputch(w_grid, i, winx1, c_ltgray, LINE_XOXO);
        }
    }
    for (int i = 0; i < FULL_SCREEN_WIDTH; i++)
    {
        mvwputch(w_grid, winy1, i, c_ltgray,
                 i == winx1? LINE_OXXX : (i == winx2? LINE_OXXX : LINE_OXOX));
        if (i < winx2) {
            mvwputch(w_grid, winy2-1, i, c_ltgray, i == winx1? LINE_XXOX : LINE_OXOX);
        }
    }
    wrefresh(w_grid);

    crafting_inv = gm->crafting_inventory(&gm->u);

    int charges = static_cast<it_tool *>(g->itypes["welder"])->charges_per_use;
    int charges_crude = static_cast<it_tool *>(g->itypes["welder_crude"])->charges_per_use;
    has_wrench = crafting_inv.has_amount("wrench", 1) ||
        crafting_inv.has_amount("toolset", 1);
    has_hacksaw = crafting_inv.has_amount("hacksaw", 1) ||
        crafting_inv.has_amount("toolset", 1);
    has_welder = (crafting_inv.has_amount("welder", 1) &&
                  crafting_inv.has_charges("welder", charges)) ||
                  (crafting_inv.has_amount("welder_crude", 1) &&
                  crafting_inv.has_charges("welder_crude", charges_crude)) ||
                (crafting_inv.has_amount("toolset", 1) &&
                 crafting_inv.has_charges("toolset", charges/20));
    has_jack = crafting_inv.has_amount("jack", 1);
    has_siphon = crafting_inv.has_amount("hose", 1);

    has_wheel = crafting_inv.has_amount( "wheel", 1 ) ||
                crafting_inv.has_amount( "wheel_wide", 1 ) ||
                crafting_inv.has_amount( "wheel_bicycle", 1 ) ||
                crafting_inv.has_amount( "wheel_motorbike", 1 ) ||
                crafting_inv.has_amount( "wheel_small", 1 );

    display_stats ();
    display_veh   ();
    move_cursor (0, 0);
    bool finish = false;
    while (!finish)
    {
        char ch = input(); // See keypress.h
        int dx, dy;
        get_direction (dx, dy, ch);
        if (ch == KEY_ESCAPE || ch == 'q' )
        {
            finish = true;
        } 
        else
        {
            if (dx != -2 && (dx || dy) &&
                cursor_x + dx >= -6 && cursor_x + dx < 6 &&
                cursor_y + dy >= -6 && cursor_y + dy < 6)
            {
                move_cursor(dx, dy);
            }
            else
            {
                int mval = cant_do(ch);
                display_mode (ch);
                switch (ch)
                {
                    case 'i': do_install(mval); break;
                    case 'r': do_repair(mval);  break;
                    case 'f': do_refill(mval);  break;
                    case 'o': do_remove(mval);  break;
                    case 'e': do_rename(mval);  break;
                    case 's': do_siphon(mval);  break;
                    case 'c': do_tirechange(mval); break;
                    case 'd': do_drain(mval);  break;
                }
                if (sel_cmd != ' ')
                {
                    finish = true;
                }
                display_mode (' ');
            }
        }
    }
    werase(w_grid);
    werase(w_mode);
    werase(w_msg);
    werase(w_disp);
    werase(w_parts);
    werase(w_stats);
    werase(w_list);
    delwin(w_grid);
    delwin(w_mode);
    delwin(w_msg);
    delwin(w_disp);
    delwin(w_parts);
    delwin(w_stats);
    delwin(w_list);
    erase();
}
Ejemplo n.º 4
0
void veh_interact::exec (game *gm, vehicle *v, int x, int y)
{
    g = gm;
    veh = v;
    ex = x;
    ey = y;
    //        x1      x2
    // y1 ----+------+--
    //        |      |
    // y2 ----+------+
    //               |
    //               |
    winw1 = 12;
    winw2 = 35;
    winh1 = 3;
    winh2 = 12;
    winw12 = winw1 + winw2 + 1;
    winw3 = 80 - winw1 - winw2 - 2;
    winh3 = 25 - winh1 - winh2 - 2;
    winh23 = winh2 + winh3 + 1;
    winx1 = winw1;
    winx2 = winw1 + winw2 + 1;
    winy1 = winh1;
    winy2 = winh1 + winh2 + 1;

    page_size = winh23;
    //               h   w    y     x
    w_grid  = newwin(25, 80,  0,    0);
    w_mode  = newwin(1,  80, 0,    0);
    w_msg   = newwin(winh1 - 1, 80, 1,    0);
    w_disp  = newwin(winh2, winw1,  winy1 + 1, 0);
    w_parts = newwin(winh2, winw2,  winy1 + 1, winx1 + 1);
    w_stats = newwin(winh3, winw12, winy2 + 1, 0);
    w_list  = newwin(winh23, winw3, winy1 + 1, winx2 + 1);

    for (int i = 0; i < 25; i++)
    {
        mvwputch(w_grid, i, winx2, c_ltgray, i == winy1 || i == winy2? LINE_XOXX : LINE_XOXO);
        if (i >= winy1 && i < winy2)
            mvwputch(w_grid, i, winx1, c_ltgray, LINE_XOXO);
    }
    for (int i = 0; i < 80; i++)
    {
        mvwputch(w_grid, winy1, i, c_ltgray, i == winx1? LINE_OXXX : (i == winx2? LINE_OXXX : LINE_OXOX));
        if (i < winx2)
            mvwputch(w_grid, winy2, i, c_ltgray, i == winx1? LINE_XXOX : LINE_OXOX);
    }
    wrefresh(w_grid);

    crafting_inv = gm->crafting_inventory();

    int charges = ((it_tool *) g->itypes["welder"])->charges_per_use;
    has_wrench = crafting_inv.has_amount("wrench", 1) ||
                 crafting_inv.has_amount("toolset", 1);
    has_hacksaw = crafting_inv.has_amount("hacksaw", 1) ||
                  crafting_inv.has_amount("toolset", 1);
    has_welder = (crafting_inv.has_amount("welder", 1) &&
                  crafting_inv.has_charges("welder", charges)) ||
                 (crafting_inv.has_amount("toolset", 1) &&
                 crafting_inv.has_charges("toolset", charges/5));

    display_stats ();
    display_veh   ();
    move_cursor (0, 0);
    bool finish = false;
    while (!finish)
    {
        char ch = input(); // See keypress.h
        int dx, dy;
        get_direction (gm, dx, dy, ch);
        if (ch == KEY_ESCAPE)
            finish = true;
        else
        if (dx != -2 && (dx || dy) &&
            cx + dx >= -6 && cx + dx < 6 &&
            cy + dy >= -6 && cy + dy < 6)
            move_cursor(dx, dy);
        else
        {
            int mval = cant_do(ch);
            display_mode (ch);
            switch (ch)
            {
            case 'i': do_install(mval); break;
            case 'r': do_repair(mval);  break;
            case 'f': do_refill(mval);  break;
            case 'o': do_remove(mval);  break;
            case 'e': do_rename(mval);  break;
            default:;
            }
            if (sel_cmd != ' ')
                finish = true;
            display_mode (' ');
        }
    }
    werase(w_grid);
    werase(w_mode);
    werase(w_msg);
    werase(w_disp);
    werase(w_parts);
    werase(w_stats);
    werase(w_list);
    delwin(w_grid);
    delwin(w_mode);
    delwin(w_msg);
    delwin(w_disp);
    delwin(w_parts);
    delwin(w_stats);
    delwin(w_list);
    erase();
}
Ejemplo n.º 5
0
/**
 * Creates a veh_interact window based on the given parameters.
 * @param v The vehicle the player is interacting with.
 * @param x The x-coordinate of the square the player is 'e'xamining.
 * @param y The y-coordinate of the square the player is 'e'xamining.
 */
void veh_interact::exec (game *gm, vehicle *v, int x, int y)
{
    veh = v;
    //        winw1   winw2   winw3
    //  winh1       |       |
    //        ------+-------+------
    //  winh2       |       |
    //        ------+-------+------
    //  winh3       |       |
    //
    // +-------------------------+
    // |         w_mode          |
    // |         w_msg           |
    // +-------+---------+-------+
    // |w_disp | w_parts | w_list|
    // +-------+---------+-------+
    // |         w_stats         |
    // +-------------------------+
    int winw1 = 12;
    int winw2 = 35;
    int winh1 = 3;
    int winh2 = 13;
    int winw3 = FULL_SCREEN_WIDTH - winw1 - winw2 - 4;
    int winh3 = FULL_SCREEN_HEIGHT - winh1 - winh2 - 2;
    int winx1 = winw1;
    int winx2 = winw1 + winw2 + 1;
    int winy1 = winh1;
    int winy2 = winh1 + winh2 + 1;

    mode_h = 1;
    mode_w = FULL_SCREEN_WIDTH - 2;
    msg_h = winh1 - 1;
    msg_w = FULL_SCREEN_WIDTH - 2;
    disp_h = winh2 - 1;
    disp_w = winw1;
    parts_h = winh2 - 1;
    parts_w = winw2;
    stats_h = winh3 - 1;
    stats_w = FULL_SCREEN_WIDTH - 2;
    list_h = winh2 - 1;
    list_w = winw3;

    const int iOffsetX = 1 + ((TERMX > FULL_SCREEN_WIDTH) ? (TERMX-FULL_SCREEN_WIDTH)/2 : 0);
    const int iOffsetY = 1 + ((TERMY > FULL_SCREEN_HEIGHT) ? (TERMY-FULL_SCREEN_HEIGHT)/2 : 0);

    page_size = list_h;

    //               h   w    y     x
    WINDOW *w_border = newwin( FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH, -1 + iOffsetY, -1 + iOffsetX );
    w_grid  = newwin( FULL_SCREEN_HEIGHT - 2, FULL_SCREEN_WIDTH - 2, iOffsetY, iOffsetX );
    w_mode  = newwin( mode_h,  mode_w,   iOffsetY,                           iOffsetX );
    w_msg   = newwin( msg_h,   msg_w,    mode_h + iOffsetY,                  iOffsetX );
    w_disp  = newwin( disp_h,  disp_w,   mode_h + msg_h + 1 + iOffsetY,  iOffsetX );
    w_parts = newwin( parts_h, parts_w,  mode_h + msg_h + 1 + iOffsetY,  disp_w + 1 + iOffsetX );
    w_list  = newwin( list_h,  list_w,   mode_h + msg_h + 1 + iOffsetY,
                      disp_w + 1 + parts_w + 1 + iOffsetX );
    w_stats = newwin( stats_h, stats_w,  mode_h + msg_h + 1 + disp_h + 1 + iOffsetY, iOffsetX );


    wborder(w_border, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX,
                      LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX );

    mvwputch(w_border, mode_h + msg_h + 1 + disp_h + 1, 0, c_ltgray, LINE_XXXO); // |-
    mvwputch(w_border, mode_h + msg_h + 1, 0, c_ltgray, LINE_XXXO); // |-
    mvwputch(w_border, mode_h + msg_h + 1 + disp_h + 1, FULL_SCREEN_WIDTH - 1, c_ltgray, LINE_XOXX);
    mvwputch(w_border, mode_h + msg_h + 1, FULL_SCREEN_WIDTH - 1, c_ltgray, LINE_XOXX);

    wrefresh(w_border);

    // Two lines dividing the three middle sections.
    for (int i = winy1; i < winy2; i++) {
        mvwputch(w_grid, i, winx2, c_ltgray, LINE_XOXO);
        mvwputch(w_grid, i, winx1, c_ltgray, LINE_XOXO);
    }
    // Two lines dividing the vertical menu sections.
    for (int i = 0; i < FULL_SCREEN_WIDTH; i++) {
        mvwputch( w_grid, winy1, i, c_ltgray, LINE_OXOX );
        mvwputch( w_grid, winy2-1, i, c_ltgray, LINE_OXOX );
    }
    // Fix up the line intersections.
    mvwputch( w_grid, winy1, winx1, c_ltgray, LINE_OXXX );
    mvwputch( w_grid, winy1, winx2, c_ltgray, LINE_OXXX );
    mvwputch( w_grid, winy2 - 1, winx1, c_ltgray, LINE_XXOX );
    mvwputch( w_grid, winy2 - 1, winx2, c_ltgray, LINE_XXOX );

    wrefresh(w_grid);

    crafting_inv = g->crafting_inventory(&g->u);

    int charges = static_cast<it_tool *>(g->itypes["welder"])->charges_per_use;
    int charges_crude = static_cast<it_tool *>(g->itypes["welder_crude"])->charges_per_use;
    has_wrench = crafting_inv.has_amount("wrench", 1) ||
        crafting_inv.has_amount("toolset", 1);
    has_hacksaw = crafting_inv.has_amount("hacksaw", 1) ||
        crafting_inv.has_amount("toolset", 1);
    has_welder = (crafting_inv.has_amount("welder", 1) &&
                  crafting_inv.has_charges("welder", charges)) ||
                  (crafting_inv.has_amount("welder_crude", 1) &&
                  crafting_inv.has_charges("welder_crude", charges_crude)) ||
                (crafting_inv.has_amount("toolset", 1) &&
                 crafting_inv.has_charges("toolset", charges/20));
    has_jack = crafting_inv.has_amount("jack", 1);
    has_siphon = crafting_inv.has_amount("hose", 1);

    has_wheel = crafting_inv.has_amount( "wheel", 1 ) ||
                crafting_inv.has_amount( "wheel_wide", 1 ) ||
                crafting_inv.has_amount( "wheel_bicycle", 1 ) ||
                crafting_inv.has_amount( "wheel_motorbike", 1 ) ||
                crafting_inv.has_amount( "wheel_small", 1 );

    display_stats ();
    display_veh   ();
    move_cursor (0, 0);
    bool finish = false;
    while (!finish)
    {
        char ch = input(); // See keypress.h
        int dx, dy;
        get_direction (dx, dy, ch);
        if (ch == KEY_ESCAPE || ch == 'q' ) {
            finish = true;
        } else {
            if (dx != -2 && (dx || dy) &&
                cursor_x + dx >= -6 && cursor_x + dx < 6 &&
                cursor_y + dy >= -6 && cursor_y + dy < 6)
            {
                move_cursor(dx, dy);
            }
            else
            {
                int mval = cant_do(ch);
                display_mode (ch);
                switch (ch)
                {
                    case 'i': do_install(mval); break;
                    case 'r': do_repair(mval);  break;
                    case 'f': do_refill(mval);  break;
                    case 'o': do_remove(mval);  break;
                    case 'e': do_rename(mval);  break;
                    case 's': do_siphon(mval);  break;
                    case 'c': do_tirechange(mval); break;
                    case 'd': do_drain(mval);  break;
                }
                if (sel_cmd != ' ')
                {
                    finish = true;
                }
                display_mode (' ');
            }
        }
    }
    werase(w_grid);
    werase(w_mode);
    werase(w_msg);
    werase(w_disp);
    werase(w_parts);
    werase(w_stats);
    werase(w_list);
    delwin(w_grid);
    delwin(w_mode);
    delwin(w_msg);
    delwin(w_disp);
    delwin(w_parts);
    delwin(w_stats);
    delwin(w_list);
    erase();
}