void veh_interact::move_cursor (int dx, int dy) { mvwputch (w_disp, cy+6, cx+6, cpart >= 0? veh->part_color (cpart) : c_black, special_symbol(cpart >= 0? veh->part_sym (cpart) : ' ')); cx += dx; cy += dy; cpart = part_at (cx, cy); int vdx = -ddx - cy; int vdy = cx - 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_only (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, cy+6, cx+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, winw2, cpart, -1); wrefresh (w_parts); can_mount.clear(); has_mats.clear(); if (!obstruct) for (int i = 1; i < num_vparts; i++) { if (veh->can_mount (vdx, vdy, (vpart_id) i)) can_mount.push_back (i); } need_repair.clear(); parts_here.clear(); ptank = -1; if (cpart >= 0) { parts_here = veh->internal_parts(cpart); parts_here.insert (parts_here.begin(), cpart); 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, vpf_fuel_tank) && veh->parts[p].amount < veh->part_info(p).size) ptank = p; } } has_fuel = ptank >= 0? g->pl_refill_vehicle(*veh, ptank, true) : false; werase (w_msg); wrefresh (w_msg); display_mode (' '); }
/** * 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, cursor_y + 6, cursor_x + 6, cpart >= 0 ? veh->part_color (cpart) : c_black, special_symbol(cpart >= 0 ? veh->part_sym (cpart) : ' ')); cursor_x += dx; cursor_y += dy; cpart = part_at (cursor_x, cursor_y); int vdx = -ddx - cursor_y; int vdy = cursor_x - 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, cursor_y + 6, cursor_x + 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, winw2, 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); } } } need_repair.clear(); parts_here.clear(); ptank = NULL; wheel = NULL; if (cpart >= 0) { //Misleading, internal_parts actually returns all parts at that square parts_here = veh->internal_parts(cpart); parts_here.insert (parts_here.begin(), cpart); 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") && veh->parts[p].amount < veh->part_info(p).size) { wheel = &veh->parts[p]; } } } has_fuel = ptank != NULL ? g->refill_vehicle_part(*veh, ptank, true) : false; werase (w_msg); wrefresh (w_msg); display_mode (' '); }
/** * 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 (' '); }