summaryrefslogtreecommitdiff
path: root/src/train_gui.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-05-31 14:04:19 +0000
committerfrosch <frosch@openttd.org>2009-05-31 14:04:19 +0000
commitea229c32bc6f681742627125b26791bebeaf2d1a (patch)
treeb4bbb546ea77079599e1b99a522af7541d4f00a1 /src/train_gui.cpp
parent9853c0dc224e01cf3394336ab074cbb18592bd5b (diff)
downloadopenttd-ea229c32bc6f681742627125b26791bebeaf2d1a.tar.xz
(svn r16483) -Codechange: Enumerate tabs in train details window.
Diffstat (limited to 'src/train_gui.cpp')
-rw-r--r--src/train_gui.cpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/train_gui.cpp b/src/train_gui.cpp
index b0a2ca30a..8dc526c56 100644
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -174,13 +174,19 @@ static void TrainDetailsCapacityTab(const Vehicle *v, int left, int right, int y
}
}
-int GetTrainDetailsWndVScroll(VehicleID veh_id, byte det_tab)
+/**
+ * Determines the number of lines in the train details window
+ * @param veh_id Train
+ * @param det_tab Selected details tab
+ * @return Number of line
+ */
+int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab)
{
AcceptedCargo act_cargo;
AcceptedCargo max_cargo;
int num = 0;
- if (det_tab == 3) { // Total cargo tab
+ if (det_tab == TDW_TAB_TOTALS) { // Total cargo tab
memset(max_cargo, 0, sizeof(max_cargo));
memset(act_cargo, 0, sizeof(act_cargo));
@@ -212,11 +218,14 @@ int GetTrainDetailsWndVScroll(VehicleID veh_id, byte det_tab)
* @param left The left most coordinate to draw
* @param right The right most coordinate to draw
* @param y The y coordinate
+ * @param vscroll_pos Position of scrollbar
+ * @param vscroll_cap Number of lines currently displayed
+ * @param det_tab Selected details tab
*/
-void DrawTrainDetails(const Vehicle *v, int left, int right, int y, int vscroll_pos, uint16 vscroll_cap, byte det_tab)
+void DrawTrainDetails(const Vehicle *v, int left, int right, int y, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab)
{
/* draw the first 3 details tabs */
- if (det_tab != 3) {
+ if (det_tab != TDW_TAB_TOTALS) {
const Vehicle *u = v;
int x = 1;
for (;;) {
@@ -235,14 +244,21 @@ void DrawTrainDetails(const Vehicle *v, int left, int right, int y, int vscroll_
int py = y + 2;
switch (det_tab) {
default: NOT_REACHED();
- case 0: TrainDetailsCargoTab( v, px, right, py); break;
- case 1:
+
+ case TDW_TAB_CARGO:
+ TrainDetailsCargoTab(v, px, right, py);
+ break;
+
+ case TDW_TAB_INFO:
/* Only show name and value for the 'real' part */
if (!IsArticulatedPart(v)) {
TrainDetailsInfoTab(v, px, right, py);
}
break;
- case 2: TrainDetailsCapacityTab(v, px, right, py); break;
+
+ case TDW_TAB_CAPACITY:
+ TrainDetailsCapacityTab(v, px, right, py);
+ break;
}
y += 14;