# ship_gui.cpp

Go to the documentation of this file.

    00001 /* $Id: ship_gui.cpp 15480 2009-02-14 18:42:03Z michi_cc $ */
    00002
    00005 #include "stdafx.h"
    00006 #include "vehicle_base.h"
    00007 #include "window_gui.h"
    00008 #include "gfx_func.h"
    00009 #include "vehicle_gui.h"
    00010 #include "strings_func.h"
    00011 #include "vehicle_func.h"
    00012
    00013 #include "table/strings.h"
    00014
    00015 void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection)
    00016 {
    00017   DrawSprite(v->GetImage(DIR_W), GetVehiclePalette(v), x + 32, y + 10);
    00018
    00019   if (v->index == selection) {
    00020     DrawFrameRect(x - 5, y - 1, x + 67, y + 21, COLOUR_WHITE, FR_BORDERONLY);
    00021   }
    00022 }
    00023
    00024 void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2)
    00025 {
    00026   const Vehicle *v;
    00027   if (!success) return;
    00028
    00029   v = GetVehicle(_new_vehicle_id);
    00030   if (v->tile == _backup_orders_tile) {
    00031     _backup_orders_tile = 0;
    00032     RestoreVehicleOrders(v);
    00033   }
    00034   ShowVehicleViewWindow(v);
    00035 }
    00036
    00044 void DrawShipDetails(const Vehicle *v, int x, int y)
    00045 {
    00046   SetDParam(0, v->engine_type);
    00047   SetDParam(1, v->build_year);
    00048   SetDParam(2, v->value);
    00049   DrawString(x, y, STR_9816_BUILT_VALUE, TC_FROMSTRING);
    00050
    00051   SetDParam(0, v->cargo_type);
    00052   SetDParam(1, v->cargo_cap);
    00053   SetDParam(2, GetCargoSubtypeText(v));
    00054   DrawString(x, y + 10, STR_9817_CAPACITY, TC_FROMSTRING);
    00055
    00056   StringID str = STR_8812_EMPTY;
    00057   if (!v->cargo.Empty()) {
    00058     SetDParam(0, v->cargo_type);
    00059     SetDParam(1, v->cargo.Count());
    00060     SetDParam(2, v->cargo.Source());
    00061     str = STR_8813_FROM;
    00062   }
    00063   DrawString(x, y + 21, str, TC_FROMSTRING);
    00064
    00065   /* Draw Transfer credits text */
    00066   SetDParam(0, v->cargo.FeederShare());
    00067   DrawString(x, y + 33, STR_FEEDER_CARGO_VALUE, TC_FROMSTRING);
    00068 }