diff options
-rw-r--r-- | src/aircraft.h | 6 | ||||
-rw-r--r-- | src/aircraft_cmd.cpp | 30 | ||||
-rw-r--r-- | src/aircraft_gui.cpp | 6 | ||||
-rw-r--r-- | src/build_vehicle_gui.cpp | 2 | ||||
-rw-r--r-- | src/depot_gui.cpp | 16 | ||||
-rw-r--r-- | src/engine_gui.cpp | 12 | ||||
-rw-r--r-- | src/engine_gui.h | 10 | ||||
-rw-r--r-- | src/group_gui.cpp | 2 | ||||
-rw-r--r-- | src/newgrf_engine.cpp | 7 | ||||
-rw-r--r-- | src/newgrf_engine.h | 12 | ||||
-rw-r--r-- | src/news_gui.cpp | 2 | ||||
-rw-r--r-- | src/roadveh.h | 2 | ||||
-rw-r--r-- | src/roadveh_cmd.cpp | 12 | ||||
-rw-r--r-- | src/roadveh_gui.cpp | 4 | ||||
-rw-r--r-- | src/saveload/vehicle_sl.cpp | 6 | ||||
-rw-r--r-- | src/ship.h | 4 | ||||
-rw-r--r-- | src/ship_cmd.cpp | 16 | ||||
-rw-r--r-- | src/ship_gui.cpp | 4 | ||||
-rw-r--r-- | src/train.h | 2 | ||||
-rw-r--r-- | src/train_cmd.cpp | 20 | ||||
-rw-r--r-- | src/train_gui.cpp | 6 | ||||
-rw-r--r-- | src/vehicle_base.h | 4 | ||||
-rw-r--r-- | src/vehicle_gui.cpp | 28 | ||||
-rw-r--r-- | src/vehicle_gui.h | 12 | ||||
-rw-r--r-- | src/vehicle_type.h | 10 |
25 files changed, 124 insertions, 111 deletions
diff --git a/src/aircraft.h b/src/aircraft.h index a35159b70..5aa032d97 100644 --- a/src/aircraft.h +++ b/src/aircraft.h @@ -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 SpecializedVehicle<Aircraft, VEH_AIRCRAFT> { 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 SpecializedVehicle<Aircraft, VEH_AIRCRAFT> { */ #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); diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 4eec698b3..ab441dc3e 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -143,12 +143,12 @@ static StationID FindNearestHangar(const Aircraft *v) 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 direction) const 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 engine) 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 right, int preferred_x, int y, EngineID en * @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(Aircraft *v) 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, int x, int y, int z) 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::GetOrderStationLocation(StationID station) 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); } diff --git a/src/aircraft_gui.cpp b/src/aircraft_gui.cpp index fafa7195f..360c02a7f 100644 --- a/src/aircraft_gui.cpp +++ b/src/aircraft_gui.cpp @@ -76,11 +76,11 @@ void DrawAircraftDetails(const Aircraft *v, int left, int right, int y) * @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, int left, int right, int y, VehicleID s 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); } diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 2475a90ae..e68dc8ccb 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -878,7 +878,7 @@ void DrawEngineList(VehicleType type, int l, int r, int y, const GUIEngineList * 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); diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 57a0c789d..07fd635a8 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -180,8 +180,8 @@ static void InitBlocksizeForShipAircraft(VehicleType type) 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; diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index 1c89d3a36..9dde1a7e1 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -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 engine) * @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(); diff --git a/src/engine_gui.h b/src/engine_gui.h index ef508cc29..4f6ec656c 100644 --- a/src/engine_gui.h +++ b/src/engine_gui.h @@ -25,10 +25,10 @@ void EngList_SortPartial(GUIEngineList *el, EngList_SortTypeFunction compare, ui 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 */ diff --git a/src/group_gui.cpp b/src/group_gui.cpp index b0a6e4886..3740bcb56 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -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; diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index 2fe393dea..991fe2aea 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -964,13 +964,15 @@ static const SpriteGroup *GetVehicleSpriteGroup(EngineID engine, const Vehicle * } -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 engine, const Vehicle *v, Direction dire } -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 engine, const Aircraft *v, bool info_vi NewVehicleResolver(&object, engine, v); + object.callback_param1 = image_type; object.u.vehicle.info_view = info_view; const SpriteGroup *group = GetWagonOverrideSpriteSet(engine, CT_DEFAULT, engine); diff --git a/src/newgrf_engine.h b/src/newgrf_engine.h index de47fb141..017a7e87b 100644 --- a/src/newgrf_engine.h +++ b/src/newgrf_engine.h @@ -26,10 +26,10 @@ static const uint VEHICLEINFO_FULL_VEHICLE_WIDTH = 32; 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 struct GRFFile *file); 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 */ diff --git a/src/news_gui.cpp b/src/news_gui.cpp index bdb0c50f4..51b4ee9e4 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -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; } diff --git a/src/roadveh.h b/src/roadveh.h index c10bb1503..fbc865636 100644 --- a/src/roadveh.h +++ b/src/roadveh.h @@ -107,7 +107,7 @@ struct RoadVehicle : public GroundVehicle<RoadVehicle, VEH_ROAD> { 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; diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 15e29f3e5..ee6961b39 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -103,13 +103,13 @@ int RoadVehicle::GetDisplayImageWidth(Point *offset) const 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 engine) 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 direction) const * @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); diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp index 0cbaee06c..0bc57962c 100644 --- a/src/roadveh_gui.cpp +++ b/src/roadveh_gui.cpp @@ -128,7 +128,7 @@ void DrawRoadVehDetails(const Vehicle *v, int left, int right, int y) * @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, int left, int right, int y, VehicleID se 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; diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp index f801e9988..05e0e4ca7 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -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)); diff --git a/src/ship.h b/src/ship.h index b40697087..d24d29db2 100644 --- a/src/ship.h +++ b/src/ship.h @@ -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<Ship, VEH_SHIP> { 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; diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index b6e0387b3..bfb3b5674 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -62,13 +62,13 @@ static inline TrackBits GetTileShipTrackStatus(TileIndex tile) 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 engine) 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, int preferred_x, int y, EngineID engine * @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; diff --git a/src/ship_gui.cpp b/src/ship_gui.cpp index 9580d578e..4cdfb5f81 100644 --- a/src/ship_gui.cpp +++ b/src/ship_gui.cpp @@ -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; diff --git a/src/train.h b/src/train.h index 815aef839..49915631c 100644 --- a/src/train.h +++ b/src/train.h @@ -96,7 +96,7 @@ struct Train : public GroundVehicle<Train, VEH_TRAIN> { 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; diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 7fd6d6a8b..82f4293b4 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -473,7 +473,7 @@ static SpriteID GetDefaultTrainSprite(uint8 spritenum, Direction direction) 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 direction) const 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 direction) const 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 engine, bool rear_head, int &y) 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, int preferred_x, int y, EngineID engin 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) 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 *v) 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 */ diff --git a/src/train_gui.cpp b/src/train_gui.cpp index 7ae0103b8..a12bca0dd 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -90,7 +90,7 @@ static int HighlightDragPosition(int px, int max_width, VehicleID selection) * @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 left, int right, int y, VehicleID select 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, int left, int right, int y, int vscroll_po 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; diff --git a/src/vehicle_base.h b/src/vehicle_base.h index e822a0b86..9f94f63f4 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -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 Vehicle { * 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); } }; diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index a464a120e..2c3ee266e 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -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 Vehicle *v, int left, int right, int y, 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::DrawVehicleListItems(VehicleID selected_vehicle, int 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 CommandCost &result, TileIndex tile, uint32 p1, * @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; diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h index 6f4113028..1ef70170c 100644 --- a/src/vehicle_gui.h +++ b/src/vehicle_gui.h @@ -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(VehicleType type) 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, bool texteffect); 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 */ diff --git a/src/vehicle_type.h b/src/vehicle_type.h index 35f45320f..0921b39e3 100644 --- a/src/vehicle_type.h +++ b/src/vehicle_type.h @@ -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 */ |