(svn r23080) -Feature: [NewGRF] Use variable 10 to enable vehicle GRFs to draw different sprites on the map and in various GUIs.

This commit is contained in:
frosch
2011-11-01 16:51:47 +00:00
parent e802dc66b9
commit bbc3409942
25 changed files with 124 additions and 111 deletions

View File

@@ -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;