# aircraft_gui.cpp

Go to the documentation of this file.

    00001 /* $Id: aircraft_gui.cpp 15711 2009-03-14 18:16:29Z rubidium $ */
    00002
    00005 #include "stdafx.h"
    00006 #include "aircraft.h"
    00007 #include "vehicle_gui.h"
    00008 #include "newgrf_engine.h"
    00009 #include "strings_func.h"
    00010 #include "vehicle_func.h"
    00011 #include "gfx_func.h"
    00012 #include "window_gui.h"
    00013
    00014 #include "table/sprites.h"
    00015 #include "table/strings.h"
    00016
    00024 void DrawAircraftDetails(const Vehicle *v, int x, int y)
    00025 {
    00026   int y_offset = (v->Next()->cargo_cap != 0) ? -11 : 0;
    00027   Money feeder_share = 0;
    00028
    00029   for (const Vehicle *u = v ; u != NULL ; u = u->Next()) {
    00030     if (IsNormalAircraft(u)) {
    00031       SetDParam(0, u->engine_type);
    00032       SetDParam(1, u->build_year);
    00033       SetDParam(2, u->value);
    00034       DrawString(x, y, STR_A011_BUILT_VALUE, TC_FROMSTRING);
    00035
    00036       SetDParam(0, u->cargo_type);
    00037       SetDParam(1, u->cargo_cap);
    00038       SetDParam(2, u->Next()->cargo_type);
    00039       SetDParam(3, u->Next()->cargo_cap);
    00040       SetDParam(4, GetCargoSubtypeText(u));
    00041       DrawString(x, y + 10, (u->Next()->cargo_cap != 0) ? STR_A019_CAPACITY : STR_A01A_CAPACITY, TC_FROMSTRING);
    00042     }
    00043
    00044     if (u->cargo_cap != 0) {
    00045       uint cargo_count = u->cargo.Count();
    00046
    00047       y_offset += 11;
    00048       if (cargo_count != 0) {
    00049         /* Cargo names (fix pluralness) */
    00050         SetDParam(0, u->cargo_type);
    00051         SetDParam(1, cargo_count);
    00052         SetDParam(2, u->cargo.Source());
    00053         DrawString(x, y + 21 + y_offset, STR_8813_FROM, TC_FROMSTRING);
    00054         feeder_share += u->cargo.FeederShare();
    00055       }
    00056     }
    00057   }
    00058
    00059   SetDParam(0, feeder_share);
    00060   DrawString(x, y + 33 + y_offset, STR_FEEDER_CARGO_VALUE, TC_FROMSTRING);
    00061 }
    00062
    00063
    00064 void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection)
    00065 {
    00066   SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
    00067   DrawSprite(v->GetImage(DIR_W), pal, x + 25, y + 10);
    00068   if (v->subtype == AIR_HELICOPTER) {
    00069     SpriteID rotor_sprite = GetCustomRotorSprite(v, true);
    00070     if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED;
    00071     DrawSprite(rotor_sprite, PAL_NONE, x + 25, y + 5);
    00072   }
    00073   if (v->index == selection) {
    00074     DrawFrameRect(x - 1, y - 1, x + 58, y + 21, COLOUR_WHITE, FR_BORDERONLY);
    00075   }
    00076 }
    00077
    00085 void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2)
    00086 {
    00087   if (success) {
    00088     const Vehicle *v = GetVehicle(_new_vehicle_id);
    00089
    00090     if (v->tile == _backup_orders_tile) {
    00091       _backup_orders_tile = 0;
    00092       RestoreVehicleOrders(v);
    00093     }
    00094     ShowVehicleViewWindow(v);
    00095   }
    00096 }