src/train_gui.cpp
branchNewGRF_ports
changeset 6720 35756db7e577
parent 6719 4cc327ad39d5
child 6725 23339968083f
--- a/src/train_gui.cpp	Sat Jun 02 19:59:29 2007 +0000
+++ b/src/train_gui.cpp	Sat Jul 14 19:42:58 2007 +0000
@@ -93,7 +93,7 @@
 		if (dx + width > 0) {
 			if (dx <= count) {
 				SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
-				DrawSprite(GetTrainImage(v, DIR_W), pal, 16 + WagonLengthToPixels(dx), 7 + (is_custom_sprite(RailVehInfo(v->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0));
+				DrawSprite(v->GetImage(DIR_W), pal, 16 + WagonLengthToPixels(dx), 7 + (is_custom_sprite(RailVehInfo(v->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0));
 				if (v->index == selection) {
 					/* Set the highlight position */
 					highlight_l = WagonLengthToPixels(dx) + 1;
@@ -169,8 +169,7 @@
 		}
 
 		/* draw widgets & caption */
-		SetDParam(0, v->string_id);
-		SetDParam(1, v->unitnumber);
+		SetDParam(0, v->index);
 		DrawWindowWidgets(w);
 
 		if (v->u.rail.crash_anim_pos != 0) {
@@ -283,6 +282,7 @@
 		DeleteWindowById(WC_VEHICLE_REFIT, w->window_number);
 		DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number);
 		DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number);
+		DeleteWindowById(WC_VEHICLE_TIMETABLE, w->window_number);
 		break;
 
 	case WE_MOUSELOOP: {
@@ -327,13 +327,12 @@
 static void TrainDetailsCargoTab(const Vehicle *v, int x, int y)
 {
 	if (v->cargo_cap != 0) {
-		uint num = v->cargo_count;
 		StringID str = STR_8812_EMPTY;
 
-		if (num != 0) {
+		if (!v->cargo.Empty()) {
 			SetDParam(0, v->cargo_type);
-			SetDParam(1, num);
-			SetDParam(2, v->cargo_source);
+			SetDParam(1, v->cargo.Count());
+			SetDParam(2, v->cargo.Source());
 			SetDParam(3, _patches.freight_trains);
 			str = FreightWagonMult(v->cargo_type) > 1 ? STR_FROM_MULT : STR_8813_FROM;
 		}
@@ -344,11 +343,11 @@
 static void TrainDetailsInfoTab(const Vehicle *v, int x, int y)
 {
 	if (RailVehInfo(v->engine_type)->railveh_type == RAILVEH_WAGON) {
-		SetDParam(0, GetCustomEngineName(v->engine_type));
+		SetDParam(0, v->engine_type);
 		SetDParam(1, v->value);
 		DrawString(x, y, STR_882D_VALUE, 0x10);
 	} else {
-		SetDParam(0, GetCustomEngineName(v->engine_type));
+		SetDParam(0, v->engine_type);
 		SetDParam(1, v->build_year);
 		SetDParam(2, v->value);
 		DrawString(x, y, STR_882C_BUILT_VALUE, 0x10);
@@ -387,7 +386,7 @@
 		}
 
 		do {
-			act_cargo[u->cargo_type] += u->cargo_count;
+			act_cargo[u->cargo_type] += u->cargo.Count();
 			max_cargo[u->cargo_type] += u->cargo_cap;
 		} while ((u = u->next) != NULL);
 
@@ -413,8 +412,7 @@
 	SetWindowWidgetDisabledState(w, 6, !_patches.servint_trains);
 	SetWindowWidgetDisabledState(w, 7, !_patches.servint_trains);
 
-	SetDParam(0, v->string_id);
-	SetDParam(1, v->unitnumber);
+	SetDParam(0, v->index);
 	DrawWindowWidgets(w);
 
 	SetDParam(1, v->age / 366);
@@ -461,7 +459,7 @@
 				u = v;
 				do {
 					SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
-					DrawSprite(GetTrainImage(u, DIR_W), pal, x + WagonLengthToPixels(4 + dx), y + 6 + (is_custom_sprite(RailVehInfo(u->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0));
+					DrawSprite(u->GetImage(DIR_W), pal, x + WagonLengthToPixels(4 + dx), y + 6 + (is_custom_sprite(RailVehInfo(u->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0));
 					dx += u->u.rail.cached_veh_length;
 					u = u->next;
 				} while (u != NULL && IsArticulatedPart(u) && u->cargo_cap == 0);
@@ -504,7 +502,7 @@
 				DrawString(x, y + 2, FreightWagonMult(i) > 1 ? STR_TOTAL_CAPACITY_MULT : STR_013F_TOTAL_CAPACITY, 0);
 			}
 		}
-		SetDParam(0, v->cargo_feeder_share);
+		SetDParam(0, v->cargo.FeederShare());
 		DrawString(x, y + 15, STR_FEEDER_CARGO_VALUE, 0);
 	}
 }
@@ -521,8 +519,8 @@
 		switch (e->we.click.widget) {
 		case 2: /* name train */
 			v = GetVehicle(w->window_number);
-			SetDParam(0, v->unitnumber);
-			ShowQueryString(v->string_id, STR_8865_NAME_TRAIN, 31, 150, w, CS_ALPHANUMERAL);
+			SetDParam(0, v->index);
+			ShowQueryString(STR_VEHICLE_NAME, STR_8865_NAME_TRAIN, 31, 150, w, CS_ALPHANUMERAL);
 			break;
 		case 6: /* inc serv interval */
 			mod = _ctrl_pressed? 5 : 10;