Changeset - r18234:0d83ef81cba4
[Not reviewed]
master
0 25 0
frosch - 13 years ago 2011-11-01 16:51:47
frosch@openttd.org
(svn r23080) -Feature: [NewGRF] Use variable 10 to enable vehicle GRFs to draw different sprites on the map and in various GUIs.
25 files changed with 124 insertions and 111 deletions:
0 comments (0 inline, 0 general)
src/aircraft.h
Show inline comments
 
@@ -27,7 +27,7 @@ enum AircraftSubType {
 

	
 

	
 
void HandleAircraftEnterHangar(Aircraft *v);
 
void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height);
 
void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height, EngineImageType image_type);
 
void UpdateAirplanesOnNewStation(const Station *st);
 
void UpdateAircraftCache(Aircraft *v);
 

	
 
@@ -58,7 +58,7 @@ struct Aircraft : public SpecializedVehi
 
	void UpdateDeltaXY(Direction direction);
 
	ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_AIRCRAFT_INC : EXPENSES_AIRCRAFT_RUN; }
 
	bool IsPrimaryVehicle() const                  { return this->IsNormalAircraft(); }
 
	SpriteID GetImage(Direction direction) const;
 
	SpriteID GetImage(Direction direction, EngineImageType image_type) const;
 
	int GetDisplaySpeed() const    { return this->cur_speed; }
 
	int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed; }
 
	int GetSpeedOldUnits() const   { return this->vcache.cached_max_speed * 10 / 128; }
 
@@ -90,7 +90,7 @@ struct Aircraft : public SpecializedVehi
 
 */
 
#define FOR_ALL_AIRCRAFT(var) FOR_ALL_VEHICLES_OF_TYPE(Aircraft, var)
 

	
 
SpriteID GetRotorImage(const Aircraft *v);
 
SpriteID GetRotorImage(const Aircraft *v, EngineImageType image_type);
 

	
 
Station *GetTargetAirportIfValid(const Aircraft *v);
 

	
src/aircraft_cmd.cpp
Show inline comments
 
@@ -143,12 +143,12 @@ static StationID FindNearestHangar(const
 
	return index;
 
}
 

	
 
SpriteID Aircraft::GetImage(Direction direction) const
 
SpriteID Aircraft::GetImage(Direction direction, EngineImageType image_type) const
 
{
 
	uint8 spritenum = this->spritenum;
 

	
 
	if (is_custom_sprite(spritenum)) {
 
		SpriteID sprite = GetCustomVehicleSprite(this, direction);
 
		SpriteID sprite = GetCustomVehicleSprite(this, direction, image_type);
 
		if (sprite != 0) return sprite;
 

	
 
		spritenum = this->GetEngine()->original_image_index;
 
@@ -157,13 +157,13 @@ SpriteID Aircraft::GetImage(Direction di
 
	return direction + _aircraft_sprite[spritenum];
 
}
 

	
 
SpriteID GetRotorImage(const Aircraft *v)
 
SpriteID GetRotorImage(const Aircraft *v, EngineImageType image_type)
 
{
 
	assert(v->subtype == AIR_HELICOPTER);
 

	
 
	const Aircraft *w = v->Next()->Next();
 
	if (is_custom_sprite(v->spritenum)) {
 
		SpriteID sprite = GetCustomRotorSprite(v, false);
 
		SpriteID sprite = GetCustomRotorSprite(v, false, image_type);
 
		if (sprite != 0) return sprite;
 
	}
 

	
 
@@ -171,13 +171,13 @@ SpriteID GetRotorImage(const Aircraft *v
 
	return SPR_ROTOR_STOPPED + w->state;
 
}
 

	
 
static SpriteID GetAircraftIcon(EngineID engine)
 
static SpriteID GetAircraftIcon(EngineID engine, EngineImageType image_type)
 
{
 
	const Engine *e = Engine::Get(engine);
 
	uint8 spritenum = e->u.air.image_index;
 

	
 
	if (is_custom_sprite(spritenum)) {
 
		SpriteID sprite = GetCustomVehicleIcon(engine, DIR_W);
 
		SpriteID sprite = GetCustomVehicleIcon(engine, DIR_W, image_type);
 
		if (sprite != 0) return sprite;
 

	
 
		spritenum = e->original_image_index;
 
@@ -186,15 +186,15 @@ static SpriteID GetAircraftIcon(EngineID
 
	return DIR_W + _aircraft_sprite[spritenum];
 
}
 

	
 
void DrawAircraftEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal)
 
void DrawAircraftEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
 
{
 
	SpriteID sprite = GetAircraftIcon(engine);
 
	SpriteID sprite = GetAircraftIcon(engine, image_type);
 
	const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
 
	preferred_x = Clamp(preferred_x, left - real_sprite->x_offs, right - real_sprite->width - real_sprite->x_offs);
 
	DrawSprite(sprite, pal, preferred_x, y);
 

	
 
	if (!(AircraftVehInfo(engine)->subtype & AIR_CTOL)) {
 
		SpriteID rotor_sprite = GetCustomRotorIcon(engine);
 
		SpriteID rotor_sprite = GetCustomRotorIcon(engine, image_type);
 
		if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED;
 
		DrawSprite(rotor_sprite, PAL_NONE, preferred_x, y - 5);
 
	}
 
@@ -206,9 +206,9 @@ void DrawAircraftEngine(int left, int ri
 
 * @param width The width of the sprite
 
 * @param height The height of the sprite
 
 */
 
void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height)
 
void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height, EngineImageType image_type)
 
{
 
	const Sprite *spr = GetSprite(GetAircraftIcon(engine), ST_NORMAL);
 
	const Sprite *spr = GetSprite(GetAircraftIcon(engine, image_type), ST_NORMAL);
 

	
 
	width  = spr->width;
 
	height = spr->height;
 
@@ -449,13 +449,13 @@ static void HelicopterTickHandler(Aircra
 
	SpriteID img;
 
	if (spd == 0) {
 
		u->state = HRS_ROTOR_STOPPED;
 
		img = GetRotorImage(v);
 
		img = GetRotorImage(v, EIT_ON_MAP);
 
		if (u->cur_image == img) return;
 
	} else if (tick >= spd) {
 
		u->tick_counter = 0;
 
		u->state++;
 
		if (u->state > HRS_ROTOR_MOVING_3) u->state = HRS_ROTOR_MOVING_1;
 
		img = GetRotorImage(v);
 
		img = GetRotorImage(v, EIT_ON_MAP);
 
	} else {
 
		return;
 
	}
 
@@ -479,7 +479,7 @@ void SetAircraftPosition(Aircraft *v, in
 
	v->z_pos = z;
 

	
 
	v->UpdateViewport(true, false);
 
	if (v->subtype == AIR_HELICOPTER) v->Next()->Next()->cur_image = GetRotorImage(v);
 
	if (v->subtype == AIR_HELICOPTER) v->Next()->Next()->cur_image = GetRotorImage(v, EIT_ON_MAP);
 

	
 
	Aircraft *u = v->Next();
 

	
 
@@ -1116,7 +1116,7 @@ TileIndex Aircraft::GetOrderStationLocat
 
void Aircraft::MarkDirty()
 
{
 
	this->UpdateViewport(false, false);
 
	if (this->subtype == AIR_HELICOPTER) this->Next()->Next()->cur_image = GetRotorImage(this);
 
	if (this->subtype == AIR_HELICOPTER) this->Next()->Next()->cur_image = GetRotorImage(this, EIT_ON_MAP);
 
}
 

	
 

	
src/aircraft_gui.cpp
Show inline comments
 
@@ -76,11 +76,11 @@ void DrawAircraftDetails(const Aircraft 
 
 * @param y         Vertical position to draw at
 
 * @param selection Selected vehicle to draw a frame around
 
 */
 
void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID selection)
 
void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
 
{
 
	bool rtl = _current_text_dir == TD_RTL;
 

	
 
	SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W);
 
	SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W, image_type);
 
	const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
 

	
 
	int x = rtl ? right - real_sprite->width - real_sprite->x_offs : left - real_sprite->x_offs;
 
@@ -90,7 +90,7 @@ void DrawAircraftImage(const Vehicle *v,
 
	DrawSprite(sprite, pal, x, y + 10);
 
	if (helicopter) {
 
		const Aircraft *a = Aircraft::From(v);
 
		SpriteID rotor_sprite = GetCustomRotorSprite(a, true);
 
		SpriteID rotor_sprite = GetCustomRotorSprite(a, true, image_type);
 
		if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED;
 
		DrawSprite(rotor_sprite, PAL_NONE, x, y + 5);
 
	}
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -878,7 +878,7 @@ void DrawEngineList(VehicleType type, in
 

	
 
		SetDParam(0, engine);
 
		DrawString(text_left, text_right, y + normal_text_y_offset, STR_ENGINE_NAME, engine == selected_id ? TC_WHITE : TC_BLACK);
 
		DrawVehicleEngine(l, r, sprite_x, y + sprite_y_offset, engine, (show_count && num_engines == 0) ? PALETTE_CRASH : GetEnginePalette(engine, _local_company));
 
		DrawVehicleEngine(l, r, sprite_x, y + sprite_y_offset, engine, (show_count && num_engines == 0) ? PALETTE_CRASH : GetEnginePalette(engine, _local_company), EIT_PURCHASE);
 
		if (show_count) {
 
			SetDParam(0, num_engines);
 
			DrawString(text_left, text_right, y + small_text_y_offset, STR_TINY_BLACK_COMA, TC_FROMSTRING, SA_RIGHT);
src/depot_gui.cpp
Show inline comments
 
@@ -180,8 +180,8 @@ static void InitBlocksizeForShipAircraft
 

	
 
		switch (type) {
 
			default: NOT_REACHED();
 
			case VEH_SHIP:     GetShipSpriteSize(    eid, x, y); break;
 
			case VEH_AIRCRAFT: GetAircraftSpriteSize(eid, x, y); break;
 
			case VEH_SHIP:     GetShipSpriteSize(    eid, x, y, EIT_IN_DEPOT); break;
 
			case VEH_AIRCRAFT: GetAircraftSpriteSize(eid, x, y, EIT_IN_DEPOT); break;
 
		}
 
		if (x > max_width)  max_width  = x;
 
		if (y > max_height) max_height = y;
 
@@ -283,7 +283,7 @@ struct DepotWindow : Window {
 

	
 
				uint x_space = free_wagon ? TRAININFO_DEFAULT_VEHICLE_WIDTH : 0;
 
				DrawTrainImage(u, image_left + (rtl ? 0 : x_space), image_right - (rtl ? x_space : 0), sprite_y - 1,
 
						this->sel, free_wagon ? 0 : this->hscroll->GetPosition(), this->vehicle_over);
 
						this->sel, EIT_IN_DEPOT, free_wagon ? 0 : this->hscroll->GetPosition(), this->vehicle_over);
 

	
 
				/* Length of consist in tiles with 1 fractional digit (rounded up) */
 
				SetDParam(0, CeilDiv(u->gcache.cached_total_length * 10, TILE_SIZE));
 
@@ -292,13 +292,13 @@ struct DepotWindow : Window {
 
				break;
 
			}
 

	
 
			case VEH_ROAD:     DrawRoadVehImage( v, image_left, image_right, sprite_y, this->sel); break;
 
			case VEH_SHIP:     DrawShipImage(    v, image_left, image_right, sprite_y, this->sel); break;
 
			case VEH_ROAD:     DrawRoadVehImage( v, image_left, image_right, sprite_y, this->sel, EIT_IN_DEPOT); break;
 
			case VEH_SHIP:     DrawShipImage(    v, image_left, image_right, sprite_y, this->sel, EIT_IN_DEPOT); break;
 
			case VEH_AIRCRAFT: {
 
				const Sprite *spr = GetSprite(v->GetImage(DIR_W), ST_NORMAL);
 
				const Sprite *spr = GetSprite(v->GetImage(DIR_W, EIT_IN_DEPOT), ST_NORMAL);
 
				DrawAircraftImage(v, image_left, image_right,
 
									y + max(spr->height + spr->y_offs - 14, 0), // tall sprites needs an y offset
 
									this->sel);
 
									this->sel, EIT_IN_DEPOT);
 
				break;
 
			}
 
			default: NOT_REACHED();
 
@@ -501,7 +501,7 @@ struct DepotWindow : Window {
 
					this->sel = INVALID_VEHICLE;
 
					TrainDepotMoveVehicle(v, sel, gdvp.head);
 
				} else if (v != NULL) {
 
					int image = v->GetImage(_current_text_dir == TD_RTL ? DIR_E : DIR_W);
 
					int image = v->GetImage(_current_text_dir == TD_RTL ? DIR_E : DIR_W, EIT_IN_DEPOT);
 
					SetObjectToPlaceWnd(image, GetVehiclePalette(v), HT_DRAG, this);
 

	
 
					this->sel = v->index;
src/engine_gui.cpp
Show inline comments
 
@@ -96,7 +96,7 @@ struct EnginePreviewWindow : Window {
 
		DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_ENGINE_NAME, TC_BLACK, SA_HOR_CENTER);
 
		y += FONT_HEIGHT_NORMAL;
 

	
 
		DrawVehicleEngine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, this->width >> 1, y + VEHICLE_SPACE / 2, engine, GetEnginePalette(engine, _local_company));
 
		DrawVehicleEngine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, this->width >> 1, y + VEHICLE_SPACE / 2, engine, GetEnginePalette(engine, _local_company), EIT_PREVIEW);
 

	
 
		y += VEHICLE_SPACE;
 
		DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, r.bottom, GetEngineInfoString(engine), TC_FROMSTRING, SA_CENTER);
 
@@ -268,25 +268,25 @@ StringID GetEngineInfoString(EngineID en
 
 * @param engine Engine to draw.
 
 * @param pal    Palette to use for drawing.
 
 */
 
void DrawVehicleEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal)
 
void DrawVehicleEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
 
{
 
	const Engine *e = Engine::Get(engine);
 

	
 
	switch (e->type) {
 
		case VEH_TRAIN:
 
			DrawTrainEngine(left, right, preferred_x, y, engine, pal);
 
			DrawTrainEngine(left, right, preferred_x, y, engine, pal, image_type);
 
			break;
 

	
 
		case VEH_ROAD:
 
			DrawRoadVehEngine(left, right, preferred_x, y, engine, pal);
 
			DrawRoadVehEngine(left, right, preferred_x, y, engine, pal, image_type);
 
			break;
 

	
 
		case VEH_SHIP:
 
			DrawShipEngine(left, right, preferred_x, y, engine, pal);
 
			DrawShipEngine(left, right, preferred_x, y, engine, pal, image_type);
 
			break;
 

	
 
		case VEH_AIRCRAFT:
 
			DrawAircraftEngine(left, right, preferred_x, y, engine, pal);
 
			DrawAircraftEngine(left, right, preferred_x, y, engine, pal, image_type);
 
			break;
 

	
 
		default: NOT_REACHED();
src/engine_gui.h
Show inline comments
 
@@ -25,10 +25,10 @@ void EngList_SortPartial(GUIEngineList *
 
StringID GetEngineCategoryName(EngineID engine);
 
StringID GetEngineInfoString(EngineID engine);
 

	
 
void DrawVehicleEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal);
 
void DrawTrainEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal);
 
void DrawRoadVehEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal);
 
void DrawShipEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal);
 
void DrawAircraftEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal);
 
void DrawVehicleEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type);
 
void DrawTrainEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type);
 
void DrawRoadVehEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type);
 
void DrawShipEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type);
 
void DrawAircraftEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type);
 

	
 
#endif /* ENGINE_GUI_H */
src/group_gui.cpp
Show inline comments
 
@@ -573,7 +573,7 @@ public:
 

	
 
				this->vehicle_sel = v->index;
 

	
 
				int image = v->GetImage(_current_text_dir == TD_RTL ? DIR_E : DIR_W);
 
				int image = v->GetImage(_current_text_dir == TD_RTL ? DIR_E : DIR_W, EIT_IN_LIST);
 
				SetObjectToPlaceWnd(image, GetVehiclePalette(v), HT_DRAG, this);
 
				_cursor.vehchain = true;
 

	
src/newgrf_engine.cpp
Show inline comments
 
@@ -964,13 +964,15 @@ static const SpriteGroup *GetVehicleSpri
 
}
 

	
 

	
 
SpriteID GetCustomEngineSprite(EngineID engine, const Vehicle *v, Direction direction)
 
SpriteID GetCustomEngineSprite(EngineID engine, const Vehicle *v, Direction direction, EngineImageType image_type)
 
{
 
	const SpriteGroup *group;
 
	ResolverObject object;
 

	
 
	NewVehicleResolver(&object, engine, v);
 

	
 
	object.callback_param1 = image_type;
 

	
 
	group = SpriteGroup::Resolve(GetVehicleSpriteGroup(engine, v), &object);
 
	if (group == NULL || group->GetNumResults() == 0) return 0;
 

	
 
@@ -978,7 +980,7 @@ SpriteID GetCustomEngineSprite(EngineID 
 
}
 

	
 

	
 
SpriteID GetRotorOverrideSprite(EngineID engine, const Aircraft *v, bool info_view)
 
SpriteID GetRotorOverrideSprite(EngineID engine, const Aircraft *v, bool info_view, EngineImageType image_type)
 
{
 
	const Engine *e = Engine::Get(engine);
 

	
 
@@ -990,6 +992,7 @@ SpriteID GetRotorOverrideSprite(EngineID
 

	
 
	NewVehicleResolver(&object, engine, v);
 

	
 
	object.callback_param1 = image_type;
 
	object.u.vehicle.info_view = info_view;
 

	
 
	const SpriteGroup *group = GetWagonOverrideSpriteSet(engine, CT_DEFAULT, engine);
src/newgrf_engine.h
Show inline comments
 
@@ -26,10 +26,10 @@ static const uint VEHICLEINFO_FULL_VEHIC
 
void SetWagonOverrideSprites(EngineID engine, CargoID cargo, const struct SpriteGroup *group, EngineID *train_id, uint trains);
 
const SpriteGroup *GetWagonOverrideSpriteSet(EngineID engine, CargoID cargo, EngineID overriding_engine);
 
void SetCustomEngineSprites(EngineID engine, byte cargo, const struct SpriteGroup *group);
 
SpriteID GetCustomEngineSprite(EngineID engine, const Vehicle *v, Direction direction);
 
SpriteID GetRotorOverrideSprite(EngineID engine, const struct Aircraft *v, bool info_view);
 
#define GetCustomRotorSprite(v, i) GetRotorOverrideSprite(v->engine_type, v, i)
 
#define GetCustomRotorIcon(et) GetRotorOverrideSprite(et, NULL, true)
 
SpriteID GetCustomEngineSprite(EngineID engine, const Vehicle *v, Direction direction, EngineImageType image_type);
 
SpriteID GetRotorOverrideSprite(EngineID engine, const struct Aircraft *v, bool info_view, EngineImageType image_type);
 
#define GetCustomRotorSprite(v, i, image_type) GetRotorOverrideSprite(v->engine_type, v, i, image_type)
 
#define GetCustomRotorIcon(et, image_type) GetRotorOverrideSprite(et, NULL, true, image_type)
 

	
 
/* Forward declaration of GRFFile, to avoid unnecessary inclusion of newgrf.h
 
 * elsewhere... */
 
@@ -40,8 +40,8 @@ void SetEngineGRF(EngineID engine, const
 
uint16 GetVehicleCallback(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v);
 
uint16 GetVehicleCallbackParent(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v, const Vehicle *parent);
 
bool UsesWagonOverride(const Vehicle *v);
 
#define GetCustomVehicleSprite(v, direction) GetCustomEngineSprite(v->engine_type, v, direction)
 
#define GetCustomVehicleIcon(et, direction) GetCustomEngineSprite(et, NULL, direction)
 
#define GetCustomVehicleSprite(v, direction, image_type) GetCustomEngineSprite(v->engine_type, v, direction, image_type)
 
#define GetCustomVehicleIcon(et, direction, image_type) GetCustomEngineSprite(et, NULL, direction, image_type)
 

	
 
/* Handler to Evaluate callback 36. If the callback fails (i.e. most of the
 
 * time) orig_value is returned */
src/news_gui.cpp
Show inline comments
 
@@ -436,7 +436,7 @@ struct NewsWindow : Window {
 
			case NTW_VEH_SPR: {
 
				assert(this->ni->reftype1 == NR_ENGINE);
 
				EngineID engine = this->ni->ref1;
 
				DrawVehicleEngine(r.left, r.right, (r.left + r.right) / 2, (r.top + r.bottom) / 2, engine, GetEnginePalette(engine, _local_company));
 
				DrawVehicleEngine(r.left, r.right, (r.left + r.right) / 2, (r.top + r.bottom) / 2, engine, GetEnginePalette(engine, _local_company), EIT_PREVIEW);
 
				GfxFillRect(r.left, r.top, r.right, r.bottom, PALETTE_NEWSPAPER, FILLRECT_RECOLOUR);
 
				break;
 
			}
src/roadveh.h
Show inline comments
 
@@ -107,7 +107,7 @@ struct RoadVehicle : public GroundVehicl
 
	void UpdateDeltaXY(Direction direction);
 
	ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_ROADVEH_INC : EXPENSES_ROADVEH_RUN; }
 
	bool IsPrimaryVehicle() const { return this->IsFrontEngine(); }
 
	SpriteID GetImage(Direction direction) const;
 
	SpriteID GetImage(Direction direction, EngineImageType image_type) const;
 
	int GetDisplaySpeed() const { return this->gcache.last_speed / 2; }
 
	int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed / 2; }
 
	Money GetRunningCost() const;
src/roadveh_cmd.cpp
Show inline comments
 
@@ -103,13 +103,13 @@ int RoadVehicle::GetDisplayImageWidth(Po
 
	return this->gcache.cached_veh_length * reference_width / VEHICLE_LENGTH;
 
}
 

	
 
static SpriteID GetRoadVehIcon(EngineID engine)
 
static SpriteID GetRoadVehIcon(EngineID engine, EngineImageType image_type)
 
{
 
	const Engine *e = Engine::Get(engine);
 
	uint8 spritenum = e->u.road.image_index;
 

	
 
	if (is_custom_sprite(spritenum)) {
 
		SpriteID sprite = GetCustomVehicleIcon(engine, DIR_W);
 
		SpriteID sprite = GetCustomVehicleIcon(engine, DIR_W, image_type);
 
		if (sprite != 0) return sprite;
 

	
 
		spritenum = e->original_image_index;
 
@@ -118,13 +118,13 @@ static SpriteID GetRoadVehIcon(EngineID 
 
	return DIR_W + _roadveh_images[spritenum];
 
}
 

	
 
SpriteID RoadVehicle::GetImage(Direction direction) const
 
SpriteID RoadVehicle::GetImage(Direction direction, EngineImageType image_type) const
 
{
 
	uint8 spritenum = this->spritenum;
 
	SpriteID sprite;
 

	
 
	if (is_custom_sprite(spritenum)) {
 
		sprite = GetCustomVehicleSprite(this, (Direction)(direction + 4 * IS_CUSTOM_SECONDHEAD_SPRITE(spritenum)));
 
		sprite = GetCustomVehicleSprite(this, (Direction)(direction + 4 * IS_CUSTOM_SECONDHEAD_SPRITE(spritenum)), image_type);
 
		if (sprite != 0) return sprite;
 

	
 
		spritenum = this->GetEngine()->original_image_index;
 
@@ -146,9 +146,9 @@ SpriteID RoadVehicle::GetImage(Direction
 
 * @param engine Engine to draw
 
 * @param pal Palette to use.
 
 */
 
void DrawRoadVehEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal)
 
void DrawRoadVehEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
 
{
 
	SpriteID sprite = GetRoadVehIcon(engine);
 
	SpriteID sprite = GetRoadVehIcon(engine, image_type);
 
	const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
 
	preferred_x = Clamp(preferred_x, left - real_sprite->x_offs, right - real_sprite->width - real_sprite->x_offs);
 
	DrawSprite(sprite, pal, preferred_x, y);
src/roadveh_gui.cpp
Show inline comments
 
@@ -128,7 +128,7 @@ void DrawRoadVehDetails(const Vehicle *v
 
 * @param selection Selected vehicle to draw a frame around
 
 * @param skip      Number of pixels to skip at the front (for scrolling)
 
 */
 
void DrawRoadVehImage(const Vehicle *v, int left, int right, int y, VehicleID selection, int skip)
 
void DrawRoadVehImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip)
 
{
 
	bool rtl = _current_text_dir == TD_RTL;
 
	Direction dir = rtl ? DIR_E : DIR_W;
 
@@ -149,7 +149,7 @@ void DrawRoadVehImage(const Vehicle *v, 
 

	
 
		if (rtl ? px + width > 0 : px - width < max_width) {
 
			PaletteID pal = (u->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(u);
 
			DrawSprite(u->GetImage(dir), pal, px + (rtl ? -offset.x : offset.x), 6 + offset.y);
 
			DrawSprite(u->GetImage(dir, image_type), pal, px + (rtl ? -offset.x : offset.x), 6 + offset.y);
 
		}
 

	
 
		px += rtl ? -width : width;
src/saveload/vehicle_sl.cpp
Show inline comments
 
@@ -419,12 +419,12 @@ void AfterLoadVehicles(bool part_of_load
 

	
 
			case VEH_TRAIN:
 
			case VEH_SHIP:
 
				v->cur_image = v->GetImage(v->direction);
 
				v->cur_image = v->GetImage(v->direction, EIT_ON_MAP);
 
				break;
 

	
 
			case VEH_AIRCRAFT:
 
				if (Aircraft::From(v)->IsNormalAircraft()) {
 
					v->cur_image = v->GetImage(v->direction);
 
					v->cur_image = v->GetImage(v->direction, EIT_ON_MAP);
 

	
 
					/* The plane's shadow will have the same image as the plane */
 
					Vehicle *shadow = v->Next();
 
@@ -433,7 +433,7 @@ void AfterLoadVehicles(bool part_of_load
 
					/* In the case of a helicopter we will update the rotor sprites */
 
					if (v->subtype == AIR_HELICOPTER) {
 
						Vehicle *rotor = shadow->Next();
 
						rotor->cur_image = GetRotorImage(Aircraft::From(v));
 
						rotor->cur_image = GetRotorImage(Aircraft::From(v), EIT_ON_MAP);
 
					}
 

	
 
					UpdateAircraftCache(Aircraft::From(v));
src/ship.h
Show inline comments
 
@@ -15,7 +15,7 @@
 
#include "vehicle_base.h"
 
#include "water_map.h"
 

	
 
void GetShipSpriteSize(EngineID engine, uint &width, uint &height);
 
void GetShipSpriteSize(EngineID engine, uint &width, uint &height, EngineImageType image_type);
 
WaterClass GetEffectiveWaterClass(TileIndex tile);
 

	
 
/**
 
@@ -34,7 +34,7 @@ struct Ship: public SpecializedVehicle<S
 
	ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; }
 
	void PlayLeaveStationSound() const;
 
	bool IsPrimaryVehicle() const { return true; }
 
	SpriteID GetImage(Direction direction) const;
 
	SpriteID GetImage(Direction direction, EngineImageType image_type) const;
 
	int GetDisplaySpeed() const { return this->cur_speed / 2; }
 
	int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed / 2; }
 
	Money GetRunningCost() const;
src/ship_cmd.cpp
Show inline comments
 
@@ -62,13 +62,13 @@ static inline TrackBits GetTileShipTrack
 
	return TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_WATER, 0));
 
}
 

	
 
static SpriteID GetShipIcon(EngineID engine)
 
static SpriteID GetShipIcon(EngineID engine, EngineImageType image_type)
 
{
 
	const Engine *e = Engine::Get(engine);
 
	uint8 spritenum = e->u.ship.image_index;
 

	
 
	if (is_custom_sprite(spritenum)) {
 
		SpriteID sprite = GetCustomVehicleIcon(engine, DIR_W);
 
		SpriteID sprite = GetCustomVehicleIcon(engine, DIR_W, image_type);
 
		if (sprite != 0) return sprite;
 

	
 
		spritenum = e->original_image_index;
 
@@ -77,9 +77,9 @@ static SpriteID GetShipIcon(EngineID eng
 
	return DIR_W + _ship_sprites[spritenum];
 
}
 

	
 
void DrawShipEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal)
 
void DrawShipEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
 
{
 
	SpriteID sprite = GetShipIcon(engine);
 
	SpriteID sprite = GetShipIcon(engine, image_type);
 
	const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
 
	preferred_x = Clamp(preferred_x, left - real_sprite->x_offs, right - real_sprite->width - real_sprite->x_offs);
 
	DrawSprite(sprite, pal, preferred_x, y);
 
@@ -91,20 +91,20 @@ void DrawShipEngine(int left, int right,
 
 * @param width The width of the sprite
 
 * @param height The height of the sprite
 
 */
 
void GetShipSpriteSize(EngineID engine, uint &width, uint &height)
 
void GetShipSpriteSize(EngineID engine, uint &width, uint &height, EngineImageType image_type)
 
{
 
	const Sprite *spr = GetSprite(GetShipIcon(engine), ST_NORMAL);
 
	const Sprite *spr = GetSprite(GetShipIcon(engine, image_type), ST_NORMAL);
 

	
 
	width  = spr->width;
 
	height = spr->height;
 
}
 

	
 
SpriteID Ship::GetImage(Direction direction) const
 
SpriteID Ship::GetImage(Direction direction, EngineImageType image_type) const
 
{
 
	uint8 spritenum = this->spritenum;
 

	
 
	if (is_custom_sprite(spritenum)) {
 
		SpriteID sprite = GetCustomVehicleSprite(this, direction);
 
		SpriteID sprite = GetCustomVehicleSprite(this, direction, image_type);
 
		if (sprite != 0) return sprite;
 

	
 
		spritenum = this->GetEngine()->original_image_index;
src/ship_gui.cpp
Show inline comments
 
@@ -28,11 +28,11 @@
 
 * @param y         Vertical position to draw at
 
 * @param selection Selected vehicle to draw a frame around
 
 */
 
void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection)
 
void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
 
{
 
	bool rtl = _current_text_dir == TD_RTL;
 

	
 
	SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W);
 
	SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W, image_type);
 
	const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
 

	
 
	int x = rtl ? right - real_sprite->width - real_sprite->x_offs : left - real_sprite->x_offs;
src/train.h
Show inline comments
 
@@ -96,7 +96,7 @@ struct Train : public GroundVehicle<Trai
 
	ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_TRAIN_INC : EXPENSES_TRAIN_RUN; }
 
	void PlayLeaveStationSound() const;
 
	bool IsPrimaryVehicle() const { return this->IsFrontEngine(); }
 
	SpriteID GetImage(Direction direction) const;
 
	SpriteID GetImage(Direction direction, EngineImageType image_type) const;
 
	int GetDisplaySpeed() const { return this->gcache.last_speed; }
 
	int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed; }
 
	Money GetRunningCost() const;
src/train_cmd.cpp
Show inline comments
 
@@ -473,7 +473,7 @@ static SpriteID GetDefaultTrainSprite(ui
 
	return ((direction + _engine_sprite_add[spritenum]) & _engine_sprite_and[spritenum]) + _engine_sprite_base[spritenum];
 
}
 

	
 
SpriteID Train::GetImage(Direction direction) const
 
SpriteID Train::GetImage(Direction direction, EngineImageType image_type) const
 
{
 
	uint8 spritenum = this->spritenum;
 
	SpriteID sprite;
 
@@ -481,7 +481,7 @@ SpriteID Train::GetImage(Direction direc
 
	if (HasBit(this->flags, VRF_REVERSE_DIRECTION)) direction = ReverseDir(direction);
 

	
 
	if (is_custom_sprite(spritenum)) {
 
		sprite = GetCustomVehicleSprite(this, (Direction)(direction + 4 * IS_CUSTOM_SECONDHEAD_SPRITE(spritenum)));
 
		sprite = GetCustomVehicleSprite(this, (Direction)(direction + 4 * IS_CUSTOM_SECONDHEAD_SPRITE(spritenum)), image_type);
 
		if (sprite != 0) return sprite;
 

	
 
		spritenum = this->GetEngine()->original_image_index;
 
@@ -494,14 +494,14 @@ SpriteID Train::GetImage(Direction direc
 
	return sprite;
 
}
 

	
 
static SpriteID GetRailIcon(EngineID engine, bool rear_head, int &y)
 
static SpriteID GetRailIcon(EngineID engine, bool rear_head, int &y, EngineImageType image_type)
 
{
 
	const Engine *e = Engine::Get(engine);
 
	Direction dir = rear_head ? DIR_E : DIR_W;
 
	uint8 spritenum = e->u.rail.image_index;
 

	
 
	if (is_custom_sprite(spritenum)) {
 
		SpriteID sprite = GetCustomVehicleIcon(engine, dir);
 
		SpriteID sprite = GetCustomVehicleIcon(engine, dir, image_type);
 
		if (sprite != 0) {
 
			if (e->GetGRF() != NULL) {
 
				y += e->GetGRF()->traininfo_vehicle_pitch;
 
@@ -517,14 +517,14 @@ static SpriteID GetRailIcon(EngineID eng
 
	return GetDefaultTrainSprite(spritenum, DIR_W);
 
}
 

	
 
void DrawTrainEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal)
 
void DrawTrainEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
 
{
 
	if (RailVehInfo(engine)->railveh_type == RAILVEH_MULTIHEAD) {
 
		int yf = y;
 
		int yr = y;
 

	
 
		SpriteID spritef = GetRailIcon(engine, false, yf);
 
		SpriteID spriter = GetRailIcon(engine, true, yr);
 
		SpriteID spritef = GetRailIcon(engine, false, yf, image_type);
 
		SpriteID spriter = GetRailIcon(engine, true, yr, image_type);
 
		const Sprite *real_spritef = GetSprite(spritef, ST_NORMAL);
 
		const Sprite *real_spriter = GetSprite(spriter, ST_NORMAL);
 

	
 
@@ -533,7 +533,7 @@ void DrawTrainEngine(int left, int right
 
		DrawSprite(spritef, pal, preferred_x - 14, yf);
 
		DrawSprite(spriter, pal, preferred_x + 15, yr);
 
	} else {
 
		SpriteID sprite = GetRailIcon(engine, false, y);
 
		SpriteID sprite = GetRailIcon(engine, false, y, image_type);
 
		const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
 
		preferred_x = Clamp(preferred_x, left - real_sprite->x_offs, right - real_sprite->width - real_sprite->x_offs);
 
		DrawSprite(sprite, pal, preferred_x, y);
 
@@ -2046,7 +2046,7 @@ static bool CheckTrainStayInDepot(Train 
 
	v->cur_speed = 0;
 

	
 
	v->UpdateDeltaXY(v->direction);
 
	v->cur_image = v->GetImage(v->direction);
 
	v->cur_image = v->GetImage(v->direction, EIT_ON_MAP);
 
	VehicleMove(v, false);
 
	UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR, v->owner);
 
	v->UpdateAcceleration();
 
@@ -3317,7 +3317,7 @@ static void ChangeTrainDirRandomly(Train
 
		if (!(v->vehstatus & VS_HIDDEN)) {
 
			v->direction = ChangeDir(v->direction, delta[GB(Random(), 0, 2)]);
 
			v->UpdateDeltaXY(v->direction);
 
			v->cur_image = v->GetImage(v->direction);
 
			v->cur_image = v->GetImage(v->direction, EIT_ON_MAP);
 
			/* Refrain from updating the z position of the vehicle when on
 
			 * a bridge, because UpdateInclination() will put the vehicle under
 
			 * the bridge in that case */
src/train_gui.cpp
Show inline comments
 
@@ -90,7 +90,7 @@ static int HighlightDragPosition(int px,
 
 * @param skip      Number of pixels to skip at the front (for scrolling)
 
 * @param drag_dest The vehicle another one is dragged over, \c INVALID_VEHICLE if none.
 
 */
 
void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, int skip, VehicleID drag_dest)
 
void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest)
 
{
 
	bool rtl = _current_text_dir == TD_RTL;
 
	Direction dir = rtl ? DIR_E : DIR_W;
 
@@ -122,7 +122,7 @@ void DrawTrainImage(const Train *v, int 
 

	
 
		if (rtl ? px + width > 0 : px - width < max_width) {
 
			PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
 
			DrawSprite(v->GetImage(dir), pal, px + (rtl ? -offset.x : offset.x), 7 + offset.y);
 
			DrawSprite(v->GetImage(dir, image_type), pal, px + (rtl ? -offset.x : offset.x), 7 + offset.y);
 
		}
 

	
 
		if (!v->IsArticulatedPart()) sel_articulated = false;
 
@@ -359,7 +359,7 @@ void DrawTrainDetails(const Train *v, in
 
				int width = u->GetDisplayImageWidth(&offset);
 
				if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) {
 
					PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
 
					DrawSprite(u->GetImage(dir), pal, px + (rtl ? -offset.x : offset.x), y - line_height * vscroll_pos + sprite_y_offset + offset.y);
 
					DrawSprite(u->GetImage(dir, EIT_IN_DETAILS), pal, px + (rtl ? -offset.x : offset.x), y - line_height * vscroll_pos + sprite_y_offset + offset.y);
 
				}
 
				px += rtl ? -width : width;
 
				dx += width;
src/vehicle_base.h
Show inline comments
 
@@ -347,7 +347,7 @@ public:
 
	 * @param direction the direction the vehicle is facing
 
	 * @return the sprite for the given vehicle in the given direction
 
	 */
 
	virtual SpriteID GetImage(Direction direction) const { return 0; }
 
	virtual SpriteID GetImage(Direction direction, EngineImageType image_type) const { return 0; }
 

	
 
	const GRFFile *GetGRF() const;
 
	uint32 GetGRFID() const;
 
@@ -992,7 +992,7 @@ struct SpecializedVehicle : public Vehic
 
		 * it gives ~3% runtime improvements in games with many vehicles */
 
		if (turned) ((T *)this)->T::UpdateDeltaXY(this->direction);
 
		SpriteID old_image = this->cur_image;
 
		this->cur_image = ((T *)this)->T::GetImage(this->direction);
 
		this->cur_image = ((T *)this)->T::GetImage(this->direction, EIT_ON_MAP);
 
		if (moved || this->cur_image != old_image) VehicleMove(this, true);
 
	}
 
};
src/vehicle_gui.cpp
Show inline comments
 
@@ -612,7 +612,7 @@ struct RefitWindow : public Window {
 
			case VRW_VEHICLE_PANEL_DISPLAY: {
 
				Vehicle *v = Vehicle::Get(this->window_number);
 
				DrawVehicleImage(v, this->sprite_left + WD_FRAMERECT_LEFT, this->sprite_right - WD_FRAMERECT_RIGHT,
 
					r.top + WD_FRAMERECT_TOP, INVALID_VEHICLE, this->hscroll != NULL ? this->hscroll->GetPosition() : 0);
 
					r.top + WD_FRAMERECT_TOP, INVALID_VEHICLE, EIT_IN_DETAILS, this->hscroll != NULL ? this->hscroll->GetPosition() : 0);
 

	
 
				/* Highlight selected vehicles. */
 
				if (this->order != INVALID_VEH_ORDER_ID) break;
 
@@ -705,7 +705,7 @@ struct RefitWindow : public Window {
 
				this->BuildRefitList();
 

	
 
				/* The vehicle width has changed too. */
 
				this->vehicle_width = GetVehicleWidth(Vehicle::Get(this->window_number));
 
				this->vehicle_width = GetVehicleWidth(Vehicle::Get(this->window_number), EIT_IN_DETAILS);
 
				uint max_width = 0;
 

	
 
				/* Check the width of all cargo information strings. */
 
@@ -866,7 +866,7 @@ struct RefitWindow : public Window {
 

	
 
	virtual void OnResize()
 
	{
 
		this->vehicle_width = GetVehicleWidth(Vehicle::Get(this->window_number));
 
		this->vehicle_width = GetVehicleWidth(Vehicle::Get(this->window_number), EIT_IN_DETAILS);
 
		this->vscroll->SetCapacityFromWidget(this, VRW_MATRIX);
 
		if (this->hscroll != NULL) this->hscroll->SetCapacityFromWidget(this, VRW_VEHICLE_PANEL_DISPLAY);
 
		this->GetWidget<NWidgetCore>(VRW_MATRIX)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
@@ -1237,13 +1237,13 @@ static void DrawSmallOrderList(const Veh
 
 * @param selection Selected vehicle to draw a frame around
 
 * @param skip      Number of pixels to skip at the front (for scrolling)
 
 */
 
void DrawVehicleImage(const Vehicle *v, int left, int right, int y, VehicleID selection, int skip)
 
void DrawVehicleImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip)
 
{
 
	switch (v->type) {
 
		case VEH_TRAIN:    DrawTrainImage(Train::From(v), left, right, y, selection, skip); break;
 
		case VEH_ROAD:     DrawRoadVehImage(v, left, right, y, selection, skip);  break;
 
		case VEH_SHIP:     DrawShipImage(v, left, right, y, selection);     break;
 
		case VEH_AIRCRAFT: DrawAircraftImage(v, left, right, y, selection); break;
 
		case VEH_TRAIN:    DrawTrainImage(Train::From(v), left, right, y, selection, image_type, skip); break;
 
		case VEH_ROAD:     DrawRoadVehImage(v, left, right, y, selection, image_type, skip);  break;
 
		case VEH_SHIP:     DrawShipImage(v, left, right, y, selection, image_type);     break;
 
		case VEH_AIRCRAFT: DrawAircraftImage(v, left, right, y, selection, image_type); break;
 
		default: NOT_REACHED();
 
	}
 
}
 
@@ -1303,7 +1303,7 @@ void BaseVehicleListWindow::DrawVehicleL
 
		SetDParam(0, v->GetDisplayProfitThisYear());
 
		SetDParam(1, v->GetDisplayProfitLastYear());
 

	
 
		DrawVehicleImage(v, image_left, image_right, y + FONT_HEIGHT_SMALL - 1, selected_vehicle, 0);
 
		DrawVehicleImage(v, image_left, image_right, y + FONT_HEIGHT_SMALL - 1, selected_vehicle, EIT_IN_LIST, 0);
 
		DrawString(text_left, text_right, y + line_height - FONT_HEIGHT_SMALL - WD_FRAMERECT_BOTTOM - 1, STR_VEHICLE_LIST_PROFIT_THIS_YEAR_LAST_YEAR);
 

	
 
		if (v->name != NULL) {
 
@@ -1996,19 +1996,19 @@ struct VehicleDetailsWindow : Window {
 
			case VLD_WIDGET_MIDDLE_DETAILS: {
 
				/* For other vehicles, at the place of the matrix. */
 
				bool rtl = _current_text_dir == TD_RTL;
 
				uint sprite_width = max<uint>(GetSprite(v->GetImage(rtl ? DIR_E : DIR_W), ST_NORMAL)->width, 70U) + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
				uint sprite_width = max<uint>(GetSprite(v->GetImage(rtl ? DIR_E : DIR_W, EIT_IN_DETAILS), ST_NORMAL)->width, 70U) + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 

	
 
				uint text_left  = r.left  + (rtl ? 0 : sprite_width);
 
				uint text_right = r.right - (rtl ? sprite_width : 0);
 

	
 
				/* Articulated road vehicles use a complete line. */
 
				if (v->type == VEH_ROAD && v->HasArticulatedPart()) {
 
					DrawVehicleImage(v, r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, INVALID_VEHICLE, 0);
 
					DrawVehicleImage(v, r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, INVALID_VEHICLE, EIT_IN_DETAILS, 0);
 
				} else {
 
					uint sprite_left  = rtl ? text_right : r.left;
 
					uint sprite_right = rtl ? r.right : text_left;
 

	
 
					DrawVehicleImage(v, sprite_left + WD_FRAMERECT_LEFT, sprite_right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, INVALID_VEHICLE, 0);
 
					DrawVehicleImage(v, sprite_left + WD_FRAMERECT_LEFT, sprite_right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, INVALID_VEHICLE, EIT_IN_DETAILS, 0);
 
				}
 
				DrawVehicleDetails(v, text_left + WD_FRAMERECT_LEFT, text_right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, 0, 0, this->tab);
 
				break;
 
@@ -2686,7 +2686,7 @@ void CcBuildPrimaryVehicle(const Command
 
 * @param v Vehicle to get the width for.
 
 * @return Width of the vehicle.
 
 */
 
int GetVehicleWidth(Vehicle *v)
 
int GetVehicleWidth(Vehicle *v, EngineImageType image_type)
 
{
 
	int vehicle_width = 0;
 

	
 
@@ -2705,7 +2705,7 @@ int GetVehicleWidth(Vehicle *v)
 

	
 
		default:
 
			bool rtl = _current_text_dir == TD_RTL;
 
			SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W);
 
			SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W, image_type);
 
			const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
 
			vehicle_width = real_sprite->width;
 

	
src/vehicle_gui.h
Show inline comments
 
@@ -48,10 +48,10 @@ enum TrainDetailsWindowTabs {
 

	
 
int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number);
 

	
 
void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, int skip, VehicleID drag_dest = INVALID_VEHICLE);
 
void DrawRoadVehImage(const Vehicle *v, int left, int right, int y, VehicleID selection, int skip = 0);
 
void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection);
 
void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID selection);
 
void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest = INVALID_VEHICLE);
 
void DrawRoadVehImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip = 0);
 
void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type);
 
void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type);
 

	
 
void ShowBuildVehicleWindow(TileIndex tile, VehicleType type);
 

	
 
@@ -73,7 +73,7 @@ static inline uint GetVehicleHeight(Vehi
 
	return (type == VEH_TRAIN || type == VEH_ROAD) ? 14 : 24;
 
}
 

	
 
int GetVehicleWidth(Vehicle *v);
 
int GetVehicleWidth(Vehicle *v, EngineImageType image_type);
 

	
 
/**
 
 * Get WindowClass for vehicle list of given vehicle type
 
@@ -99,6 +99,6 @@ void StartStopVehicle(const Vehicle *v, 
 

	
 
Vehicle *CheckClickOnVehicle(const struct ViewPort *vp, int x, int y);
 

	
 
void DrawVehicleImage(const Vehicle *v, int left, int right, int y, VehicleID selection, int skip);
 
void DrawVehicleImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip);
 

	
 
#endif /* VEHICLE_GUI_H */
src/vehicle_type.h
Show inline comments
 
@@ -83,4 +83,14 @@ enum AccelerationModel {
 
	AM_REALISTIC,
 
};
 

	
 
/** Visualisation contexts of vehicles and engines. */
 
enum EngineImageType {
 
	EIT_ON_MAP     = 0x00,  ///< Vehicle drawn in viewport.
 
	EIT_IN_DEPOT   = 0x10,  ///< Vehicle drawn in depot.
 
	EIT_IN_DETAILS = 0x11,  ///< Vehicle drawn in vehicle details, refit window, ...
 
	EIT_IN_LIST    = 0x12,  ///< Vehicle drawn in vehicle list, group list, ...
 
	EIT_PURCHASE   = 0x20,  ///< Vehicle drawn in purchase list, autoreplace gui, ...
 
	EIT_PREVIEW    = 0x21,  ///< Vehicle drawn in preview window, news, ...
 
};
 

	
 
#endif /* VEHICLE_TYPE_H */
0 comments (0 inline, 0 general)