ship_gui.cpp
Go to the documentation of this file.00001
00002
00005 #include "stdafx.h"
00006 #include "openttd.h"
00007 #include "debug.h"
00008 #include "ship.h"
00009 #include "gui.h"
00010 #include "window_gui.h"
00011 #include "viewport_func.h"
00012 #include "gfx_func.h"
00013 #include "depot.h"
00014 #include "vehicle_gui.h"
00015 #include "newgrf_engine.h"
00016 #include "strings_func.h"
00017 #include "vehicle_func.h"
00018
00019 #include "table/strings.h"
00020 #include "table/sprites.h"
00021
00022 void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection)
00023 {
00024 DrawSprite(v->GetImage(DIR_W), GetVehiclePalette(v), x + 32, y + 10);
00025
00026 if (v->index == selection) {
00027 DrawFrameRect(x - 5, y - 1, x + 67, y + 21, 15, FR_BORDERONLY);
00028 }
00029 }
00030
00031 void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2)
00032 {
00033 const Vehicle *v;
00034 if (!success) return;
00035
00036 v = GetVehicle(_new_vehicle_id);
00037 if (v->tile == _backup_orders_tile) {
00038 _backup_orders_tile = 0;
00039 RestoreVehicleOrders(v);
00040 }
00041 ShowVehicleViewWindow(v);
00042 }
00043
00051 void DrawShipDetails(const Vehicle *v, int x, int y)
00052 {
00053 SetDParam(0, v->engine_type);
00054 SetDParam(1, v->build_year);
00055 SetDParam(2, v->value);
00056 DrawString(x, y, STR_9816_BUILT_VALUE, TC_FROMSTRING);
00057
00058 SetDParam(0, v->cargo_type);
00059 SetDParam(1, v->cargo_cap);
00060 DrawString(x, y + 10, STR_9817_CAPACITY, TC_FROMSTRING);
00061
00062 StringID str = STR_8812_EMPTY;
00063 if (!v->cargo.Empty()) {
00064 SetDParam(0, v->cargo_type);
00065 SetDParam(1, v->cargo.Count());
00066 SetDParam(2, v->cargo.Source());
00067 str = STR_8813_FROM;
00068 }
00069 DrawString(x, y + 21, str, TC_FROMSTRING);
00070
00071
00072 SetDParam(0, v->cargo.FeederShare());
00073 DrawString(x, y + 33, STR_FEEDER_CARGO_VALUE, TC_FROMSTRING);
00074 }