# ship_gui.cpp

Go to the documentation of this file.

    00001 /* $Id: ship_gui.cpp 18779 2010-01-11 18:34:02Z rubidium $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    00008  */
    00009
    00012 #include "stdafx.h"
    00013 #include "vehicle_base.h"
    00014 #include "window_gui.h"
    00015 #include "gfx_func.h"
    00016 #include "vehicle_gui.h"
    00017 #include "strings_func.h"
    00018 #include "vehicle_func.h"
    00019 #include "spritecache.h"
    00020
    00021 #include "table/strings.h"
    00022
    00031 void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection)
    00032 {
    00033   bool rtl = _dynlang.text_dir == TD_RTL;
    00034
    00035   SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W);
    00036   const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
    00037
    00038   int x = rtl ? right - real_sprite->width - real_sprite->x_offs : left - real_sprite->x_offs;
    00039
    00040   DrawSprite(sprite, GetVehiclePalette(v), x, y + 10);
    00041
    00042   if (v->index == selection) {
    00043     x += real_sprite->x_offs;
    00044     y += real_sprite->y_offs + 10;
    00045     DrawFrameRect(x - 1, y - 1, x + real_sprite->width + 1, y + real_sprite->height + 1, COLOUR_WHITE, FR_BORDERONLY);
    00046   }
    00047 }
    00048
    00057 void DrawShipDetails(const Vehicle *v, int left, int right, int y)
    00058 {
    00059   SetDParam(0, v->engine_type);
    00060   SetDParam(1, v->build_year);
    00061   SetDParam(2, v->value);
    00062   DrawString(left, right, y, STR_VEHICLE_INFO_BUILT_VALUE, TC_FROMSTRING, SA_LEFT | SA_STRIP);
    00063
    00064   SetDParam(0, v->cargo_type);
    00065   SetDParam(1, v->cargo_cap);
    00066   SetDParam(4, GetCargoSubtypeText(v));
    00067   DrawString(left, right, y + FONT_HEIGHT_NORMAL, STR_VEHICLE_INFO_CAPACITY);
    00068
    00069   StringID str = STR_VEHICLE_DETAILS_CARGO_EMPTY;
    00070   if (!v->cargo.Empty()) {
    00071     SetDParam(0, v->cargo_type);
    00072     SetDParam(1, v->cargo.Count());
    00073     SetDParam(2, v->cargo.Source());
    00074     str = STR_VEHICLE_DETAILS_CARGO_FROM;
    00075   }
    00076   DrawString(left, right, y + 2 * FONT_HEIGHT_NORMAL + 1, str);
    00077
    00078   /* Draw Transfer credits text */
    00079   SetDParam(0, v->cargo.FeederShare());
    00080   DrawString(left, right, y + 3 * FONT_HEIGHT_NORMAL + 3, STR_VEHICLE_INFO_FEEDER_CARGO_VALUE);
    00081 }