예제 #1
0
void veh_interact::do_rename(int reason)
{
std::string name = string_input_popup("Enter new vehicle name", 20);
(veh->name = name);
    werase(w_stats);
    werase(w_grid);
    display_stats ();
    display_veh   ();
}
예제 #2
0
/**
 * Handles renaming a vehicle.
 * @param reason Unused.
 */
void veh_interact::do_rename(int reason)
{
    std::string name = string_input_popup(_("Enter new vehicle name:"), 20);
    if(name.length() > 0) {
        (veh->name = name);
    }
    werase(w_stats);
    werase(w_grid);
    display_stats ();
    display_veh   ();
}
예제 #3
0
/**
 * Handles renaming a vehicle.
 * @param reason Unused.
 */
void veh_interact::do_rename(task_reason reason)
{
    std::string name = string_input_popup(_("Enter new vehicle name:"), 20);
    if(name.length() > 0) {
        (veh->name = name);
        if (veh->tracking_on) {
            g->cur_om->vehicles[veh->om_id].name = name;
        }
    }
    werase(w_stats);
    werase(w_grid);
    display_stats ();
    display_veh   ();
}
예제 #4
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();
}
예제 #5
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();
}
예제 #6
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();
}
예제 #7
0
/**
 * Moves the cursor on the vehicle editing window.
 * @param dx How far to move the cursor on the x-axis.
 * @param dy How far to move the cursor on the y-axis.
 */
void veh_interact::move_cursor (int dx, int dy)
{
    mvwputch (w_disp, 6, 6, cpart >= 0 ? veh->part_color (cpart) : c_black,
              special_symbol(cpart >= 0 ? veh->part_sym (cpart) : ' '));
    ddx += dy;
    ddy -= dx;
    display_veh();
    cpart = part_at (0, 0);
    int vdx = -ddx;
    int vdy = -ddy;
    int vx, vy;
    veh->coord_translate (vdx, vdy, vx, vy);
    int vehx = veh->global_x() + vx;
    int vehy = veh->global_y() + vy;
    bool obstruct = g->m.move_cost_ter_furn (vehx, vehy) == 0;
    vehicle *oveh = g->m.veh_at (vehx, vehy);
    if (oveh && oveh != veh) {
        obstruct = true;
    }
    nc_color col = cpart >= 0 ? veh->part_color (cpart) : c_black;
    mvwputch (w_disp, 6, 6, obstruct ? red_background(col) : hilite(col),
              special_symbol(cpart >= 0 ? veh->part_sym (cpart) : ' '));
    wrefresh (w_disp);
    werase (w_parts);
    veh->print_part_desc (w_parts, 0, parts_w, cpart, -1);
    wrefresh (w_parts);

    can_mount.clear();
    if (!obstruct) {
        for (std::map<std::string, vpart_info>::iterator
             part_type_iterator = vehicle_part_types.begin();
             part_type_iterator != vehicle_part_types.end();
             ++part_type_iterator) {
            if (veh->can_mount (vdx, vdy, part_type_iterator->first)) {
                can_mount.push_back (part_type_iterator->second);
            }
        }
    }

    //Only build the wheel list once
    if(wheel_types.empty()) {
        for (std::map<std::string, vpart_info>::iterator
             part_type_iterator = vehicle_part_types.begin();
             part_type_iterator != vehicle_part_types.end();
             ++part_type_iterator) {
            if (part_type_iterator->second.has_flag("WHEEL")) {
                wheel_types.push_back (part_type_iterator->second);
            }
        }
    }

    need_repair.clear();
    parts_here.clear();
    ptank = NULL;
    wheel = NULL;
    if (cpart >= 0) {
        parts_here = veh->parts_at_relative(veh->parts[cpart].mount_dx, veh->parts[cpart].mount_dy);
        for (int i = 0; i < parts_here.size(); i++) {
            int p = parts_here[i];
            if (veh->parts[p].hp < veh->part_info(p).durability) {
                need_repair.push_back (i);
            }
            if (veh->part_flag(p, "FUEL_TANK") && veh->parts[p].amount < veh->part_info(p).size) {
                ptank = &veh->parts[p];
            }
            if (veh->part_flag(p, "WHEEL")) {
                wheel = &veh->parts[p];
            }
        }
    }
    has_fuel = ptank != NULL ? g->refill_vehicle_part(*veh, ptank, true) : false;
    werase (w_msg);
    wrefresh (w_msg);
    display_mode (' ');
}