aircraft_gui.cpp
Go to the documentation of this file.00001
00002
00005 #include "stdafx.h"
00006 #include "openttd.h"
00007 #include "aircraft.h"
00008 #include "debug.h"
00009 #include "gui.h"
00010 #include "engine.h"
00011 #include "depot.h"
00012 #include "vehicle_gui.h"
00013 #include "newgrf_engine.h"
00014 #include "strings_func.h"
00015 #include "vehicle_func.h"
00016 #include "gfx_func.h"
00017
00018 #include "table/sprites.h"
00019 #include "table/strings.h"
00020
00028 void DrawAircraftDetails(const Vehicle *v, int x, int y)
00029 {
00030 int y_offset = (v->Next()->cargo_cap != 0) ? -11 : 0;
00031 Money feeder_share = 0;
00032
00033 for (const Vehicle *u = v ; u != NULL ; u = u->Next()) {
00034 if (IsNormalAircraft(u)) {
00035 SetDParam(0, u->engine_type);
00036 SetDParam(1, u->build_year);
00037 SetDParam(2, u->value);
00038 DrawString(x, y, STR_A011_BUILT_VALUE, TC_FROMSTRING);
00039
00040 SetDParam(0, u->cargo_type);
00041 SetDParam(1, u->cargo_cap);
00042 SetDParam(2, u->Next()->cargo_type);
00043 SetDParam(3, u->Next()->cargo_cap);
00044 DrawString(x, y + 10, (u->Next()->cargo_cap != 0) ? STR_A019_CAPACITY : STR_A01A_CAPACITY, TC_FROMSTRING);
00045 }
00046
00047 if (u->cargo_cap != 0) {
00048 uint cargo_count = u->cargo.Count();
00049
00050 y_offset += 11;
00051 if (cargo_count != 0) {
00052
00053 SetDParam(0, u->cargo_type);
00054 SetDParam(1, cargo_count);
00055 SetDParam(2, u->cargo.Source());
00056 DrawString(x, y + 21 + y_offset, STR_8813_FROM, TC_FROMSTRING);
00057 feeder_share += u->cargo.FeederShare();
00058 }
00059 }
00060 }
00061
00062 SetDParam(0, feeder_share);
00063 DrawString(x, y + 33 + y_offset, STR_FEEDER_CARGO_VALUE, TC_FROMSTRING);
00064 }
00065
00066
00067 void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection)
00068 {
00069 SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
00070 DrawSprite(v->GetImage(DIR_W), pal, x + 25, y + 10);
00071 if (v->subtype == AIR_HELICOPTER) {
00072 SpriteID rotor_sprite = GetCustomRotorSprite(v, true);
00073 if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED;
00074 DrawSprite(rotor_sprite, PAL_NONE, x + 25, y + 5);
00075 }
00076 if (v->index == selection) {
00077 DrawFrameRect(x - 1, y - 1, x + 58, y + 21, 0xF, FR_BORDERONLY);
00078 }
00079 }
00080
00088 void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2)
00089 {
00090 if (success) {
00091 const Vehicle *v = GetVehicle(_new_vehicle_id);
00092
00093 if (v->tile == _backup_orders_tile) {
00094 _backup_orders_tile = 0;
00095 RestoreVehicleOrders(v);
00096 }
00097 ShowVehicleViewWindow(v);
00098 }
00099 }