OpenTTD: src/ship_gui.cpp Source File

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

ship_gui.cpp
Go to the documentation of this file.
1 /* $Id: ship_gui.cpp 27134 2015-02-01 20:54:24Z frosch $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
9
12 #include "stdafx.h"
13 #include "vehicle_base.h"
14 #include "window_gui.h"
15 #include "gfx_func.h"
16 #include "vehicle_gui.h"
17 #include "strings_func.h"
18 #include "vehicle_func.h"
19 #include "spritecache.h"
20 #include "zoom_func.h"
21
22 #include "table/strings.h"
23
24 #include "safeguards.h"
25
34 void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
35 {
36 bool rtl = _current_text_dir == TD_RTL;
37
38 SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W, image_type);
39 const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
40
41 int width = UnScaleGUI(real_sprite->width);
42 int x_offs = UnScaleGUI(real_sprite->x_offs);
43 int x = rtl ? right - width - x_offs : left - x_offs;
44
45 y += ScaleGUITrad(10);
46 DrawSprite(sprite, GetVehiclePalette(v), x, y);
47
48 if (v->index == selection) {
49 x += x_offs;
50 y += UnScaleGUI(real_sprite->y_offs);
51 DrawFrameRect(x - 1, y - 1, x + width + 1, y + UnScaleGUI(real_sprite->height) + 1, COLOUR_WHITE, FR_BORDERONLY);
52 }
53 }
54
63 void DrawShipDetails(const Vehicle *v, int left, int right, int y)
64 {
65 SetDParam(0, v->engine_type);
66 SetDParam(1, v->build_year);
67 SetDParam(2, v->value);
68 DrawString(left, right, y, STR_VEHICLE_INFO_BUILT_VALUE);
69
70 SetDParam(0, v->cargo_type);
71 SetDParam(1, v->cargo_cap);
72 SetDParam(4, GetCargoSubtypeText(v));
73 DrawString(left, right, y + FONT_HEIGHT_NORMAL, STR_VEHICLE_INFO_CAPACITY);
74
75 StringID str = STR_VEHICLE_DETAILS_CARGO_EMPTY;
76 if (v->cargo.StoredCount() > 0) {
77 SetDParam(0, v->cargo_type);
78 SetDParam(1, v->cargo.StoredCount());
79 SetDParam(2, v->cargo.Source());
80 str = STR_VEHICLE_DETAILS_CARGO_FROM;
81 }
82 DrawString(left, right, y + 2 * FONT_HEIGHT_NORMAL + 1, str);
83
84 /* Draw Transfer credits text */
85 SetDParam(0, v->cargo.FeederShare());
86 DrawString(left, right, y + 3 * FONT_HEIGHT_NORMAL + 3, STR_VEHICLE_INFO_FEEDER_CARGO_VALUE);
87 }