Changeset - r2570:9c32c3acd198
[Not reviewed]
master
0 2 0
peter1138 - 18 years ago 2005-10-30 21:47:42
peter1138@openttd.org
(svn r3107) -NewGRF: Move train y-position offset adjustment to remove code duplication, and make it apply only to vehicles with a custom image.
2 files changed with 10 insertions and 5 deletions:
0 comments (0 inline, 0 general)
train_cmd.c
Show inline comments
 
@@ -361,22 +361,28 @@ int GetTrainImage(const Vehicle *v, byte
 

	
 
	if (v->cargo_count >= (v->cargo_cap >> 1))
 
		base += _wagon_full_adder[img];
 
	return base;
 
}
 

	
 
extern int _traininfo_vehicle_pitch;
 

	
 
void DrawTrainEngine(int x, int y, EngineID engine, uint32 image_ormod)
 
{
 
	const RailVehicleInfo *rvi = RailVehInfo(engine);
 

	
 
	int img = rvi->image_index;
 
	uint32 image = 0;
 

	
 
	if (is_custom_sprite(img)) {
 
		image = GetCustomVehicleIcon(engine, 6);
 
		if (image == 0) img = orig_rail_vehicle_info[engine].image_index;
 
		if (image == 0) {
 
			img = orig_rail_vehicle_info[engine].image_index;
 
		} else {
 
			y += _traininfo_vehicle_pitch;
 
		}
 
	}
 
	if (image == 0) {
 
		image = (6 & _engine_sprite_and[img]) + _engine_sprite_base[img];
 
	}
 

	
 
	if (rvi->flags & RVI_MULTIHEAD) {
train_gui.c
Show inline comments
 
@@ -185,13 +185,13 @@ static void engine_drawing_loop(int *x, 
 

	
 
		if (*sel == 0)
 
			*selected_id = i;
 

	
 
		if (IS_INT_INSIDE(--*pos, -show_max, 0)) {
 
			DrawString(*x + 59, *y + 2, GetCustomEngineName(i), *sel == 0 ? 0xC : 0x10);
 
			DrawTrainEngine(*x + 29, *y + 6 + _traininfo_vehicle_pitch, i,
 
			DrawTrainEngine(*x + 29, *y + 6, i,
 
				SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)));
 
			*y += 14;
 
		}
 
		--*sel;
 
	}
 
}
 
@@ -355,13 +355,13 @@ static void DrawTrainImage(const Vehicle
 
			uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner));
 
			int width = v->u.rail.cached_veh_length * 3;
 

	
 
			if (x + width + 4 <= max_x) {
 
				if (v->vehstatus & VS_CRASHED)
 
					ormod = PALETTE_CRASH;
 
				DrawSprite(image | ormod, x + 14, y + 6 + _traininfo_vehicle_pitch);
 
				DrawSprite(image | ormod, x + 14, y + 6 + (is_custom_sprite(RailVehInfo(v->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0));
 
				if (v->index == selection)
 
					DrawFrameRect(x - 1, y - 1, x + width + 4, y + 12, 15, FR_BORDERONLY);
 
			}
 
			x += width + 5;
 
		}
 

	
 
@@ -1406,14 +1406,13 @@ static void PlayerTrainsWndProc(Window *
 
		for (i = w->vscroll.pos; i < max; ++i) {
 
			Vehicle *v = GetVehicle(vl->sort_list[i].index);
 
			StringID str;
 

	
 
			assert(v->type == VEH_Train && v->owner == owner);
 

	
 
			DrawTrainImage(
 
				v, x + 21, y + 6 + _traininfo_vehicle_pitch, w->hscroll.cap, 0, INVALID_VEHICLE);
 
			DrawTrainImage(v, x + 21, y + 6, w->hscroll.cap, 0, INVALID_VEHICLE);
 
			DrawVehicleProfitButton(v, x, y + 13);
 

	
 
			SetDParam(0, v->unitnumber);
 
			if (IsTileDepotType(v->tile, TRANSPORT_RAIL) && (v->vehstatus & VS_HIDDEN))
 
				str = STR_021F;
 
			else
0 comments (0 inline, 0 general)