author | belugas |
Sun, 15 Jun 2008 02:48:25 +0000 | |
changeset 10965 | a2b5f6f9be0c |
parent 10429 | 1b99254f9607 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10429
1b99254f9607
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
10222
diff
changeset
|
3 |
/** @file ship_gui.cpp GUI for ships. */ |
6916
e87d54a598ea
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6524
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1820
diff
changeset
|
6 |
#include "openttd.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1294
diff
changeset
|
7 |
#include "debug.h" |
3961
e2783f244ac6
(svn r5120) Add IsShipInDepot{Stopped,}() and remove some redundant checks
tron
parents:
3948
diff
changeset
|
8 |
#include "ship.h" |
0 | 9 |
#include "gui.h" |
8603
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8320
diff
changeset
|
10 |
#include "window_gui.h" |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
11 |
#include "viewport_func.h" |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
12 |
#include "gfx_func.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2113
diff
changeset
|
13 |
#include "vehicle_gui.h" |
2962
dbd168a4703a
(svn r3524) - Split newgrf features from engine.[ch] into newgrf_engine.[ch], and add the new files to project files.
peter1138
parents:
2958
diff
changeset
|
14 |
#include "newgrf_engine.h" |
8610
17cc343a23dd
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8603
diff
changeset
|
15 |
#include "strings_func.h" |
8640
1e93b81e96d2
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8627
diff
changeset
|
16 |
#include "vehicle_func.h" |
9280
9c03416d26b1
(svn r12488) -Codechange: split order.h into order_base.h and order_func.h.
rubidium
parents:
8760
diff
changeset
|
17 |
#include "order_func.h" |
0 | 18 |
|
8760
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8720
diff
changeset
|
19 |
#include "table/strings.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8720
diff
changeset
|
20 |
#include "table/sprites.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8720
diff
changeset
|
21 |
|
4442
8d8d0c2df7cb
(svn r6215) -Codechange: [vehicle list windows] unified Player(vehicle)WndProc into PlayerVehWndProc
bjarni
parents:
4436
diff
changeset
|
22 |
void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection) |
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1751
diff
changeset
|
23 |
{ |
7630
2cd754d7dfa4
(svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents:
7559
diff
changeset
|
24 |
DrawSprite(v->GetImage(DIR_W), GetVehiclePalette(v), x + 32, y + 10); |
0 | 25 |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1751
diff
changeset
|
26 |
if (v->index == selection) { |
2639 | 27 |
DrawFrameRect(x - 5, y - 1, x + 67, y + 21, 15, FR_BORDERONLY); |
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1751
diff
changeset
|
28 |
} |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1751
diff
changeset
|
29 |
} |
0 | 30 |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
31 |
void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 32 |
{ |
4171 | 33 |
const Vehicle *v; |
0 | 34 |
if (!success) return; |
35 |
||
3948
95f9fa0ac551
(svn r5094) Remove _new_{aircraft,roadveh,ship,train,wagon}_id. _new_vehicle_id is enough.
tron
parents:
3887
diff
changeset
|
36 |
v = GetVehicle(_new_vehicle_id); |
0 | 37 |
if (v->tile == _backup_orders_tile) { |
38 |
_backup_orders_tile = 0; |
|
8149
eb78fb69096f
(svn r11184) -Codechange: cleanup the code related to backup orders.
rubidium
parents:
8026
diff
changeset
|
39 |
RestoreVehicleOrders(v); |
0 | 40 |
} |
7982
539e32cc37ce
(svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium
parents:
7980
diff
changeset
|
41 |
ShowVehicleViewWindow(v); |
0 | 42 |
} |
8026
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
43 |
|
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
44 |
/** |
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
45 |
* Draw the details for the given vehicle at the position (x,y) |
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
46 |
* |
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
47 |
* @param v current vehicle |
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
48 |
* @param x The x coordinate |
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
49 |
* @param y The y coordinate |
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
50 |
*/ |
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
51 |
void DrawShipDetails(const Vehicle *v, int x, int y) |
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
52 |
{ |
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
53 |
SetDParam(0, v->engine_type); |
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
54 |
SetDParam(1, v->build_year); |
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
55 |
SetDParam(2, v->value); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8149
diff
changeset
|
56 |
DrawString(x, y, STR_9816_BUILT_VALUE, TC_FROMSTRING); |
8026
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
57 |
|
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
58 |
SetDParam(0, v->cargo_type); |
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
59 |
SetDParam(1, v->cargo_cap); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8149
diff
changeset
|
60 |
DrawString(x, y + 10, STR_9817_CAPACITY, TC_FROMSTRING); |
8026
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
61 |
|
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
62 |
StringID str = STR_8812_EMPTY; |
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
63 |
if (!v->cargo.Empty()) { |
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
64 |
SetDParam(0, v->cargo_type); |
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
65 |
SetDParam(1, v->cargo.Count()); |
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
66 |
SetDParam(2, v->cargo.Source()); |
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
67 |
str = STR_8813_FROM; |
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
68 |
} |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8149
diff
changeset
|
69 |
DrawString(x, y + 21, str, TC_FROMSTRING); |
8026
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
70 |
|
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
71 |
/* Draw Transfer credits text */ |
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
72 |
SetDParam(0, v->cargo.FeederShare()); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8149
diff
changeset
|
73 |
DrawString(x, y + 33, STR_FEEDER_CARGO_VALUE, TC_FROMSTRING); |
8026
269979f5319d
(svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents:
7984
diff
changeset
|
74 |
} |