Merge 1.7.0-RC1

This commit is contained in:
Pavel Stupnikov
2017-04-09 22:34:33 +03:00
262 changed files with 4673 additions and 3860 deletions

View File

@@ -1,4 +1,4 @@
/* $Id: vehicle_gui.cpp 27587 2016-05-29 18:52:56Z frosch $ */
/* $Id: vehicle_gui.cpp 27677 2016-11-05 19:16:59Z frosch $ */
/*
* This file is part of OpenTTD.
@@ -1639,7 +1639,7 @@ public:
break;
case WID_VL_MANAGE_VEHICLES_DROPDOWN: {
DropDownList *list = this->BuildActionDropdownList(VehicleListIdentifier(this->window_number).type == VL_STANDARD, false);
DropDownList *list = this->BuildActionDropdownList(VehicleListIdentifier::UnPack(this->window_number).type == VL_STANDARD, false);
ShowDropDownList(this, list, 0, WID_VL_MANAGE_VEHICLES_DROPDOWN);
break;
}
@@ -2101,9 +2101,7 @@ struct VehicleDetailsWindow : Window {
case WID_VD_MIDDLE_DETAILS: {
/* For other vehicles, at the place of the matrix. */
bool rtl = _current_text_dir == TD_RTL;
uint sprite_width = UnScaleGUI(
max<uint>(GetSprite(v->GetImage(rtl ? DIR_E : DIR_W, EIT_IN_DETAILS), ST_NORMAL)->width, 70U)) +
WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
uint sprite_width = GetSingleVehicleWidth(v, EIT_IN_DETAILS) + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
uint text_left = r.left + (rtl ? 0 : sprite_width);
uint text_right = r.right - (rtl ? sprite_width : 0);
@@ -2356,8 +2354,8 @@ static const uint32 _vehicle_command_translation_table[][4] = {
};
/**
* This is the Callback method after the cloning attempt of a vehicle
* @param result the result of the cloning command
* This is the Callback method after attempting to start/stop a vehicle
* @param result the result of the start/stop command
* @param tile unused
* @param p1 vehicle ID
* @param p2 unused
@@ -2849,36 +2847,85 @@ void CcBuildPrimaryVehicle(const CommandCost &result, TileIndex tile, uint32 p1,
ShowVehicleViewWindow(v);
}
/**
* Get the width of a vehicle (part) in pixels.
* @param v Vehicle to get the width for.
* @return Width of the vehicle.
*/
int GetSingleVehicleWidth(const Vehicle *v, EngineImageType image_type)
{
switch (v->type) {
case VEH_TRAIN:
return Train::From(v)->GetDisplayImageWidth();
case VEH_ROAD:
return RoadVehicle::From(v)->GetDisplayImageWidth();
default:
bool rtl = _current_text_dir == TD_RTL;
VehicleSpriteSeq seq;
v->GetImage(rtl ? DIR_E : DIR_W, image_type, &seq);
Rect rec;
seq.GetBounds(&rec);
return UnScaleGUI(rec.right - rec.left + 1);
}
}
/**
* Get the width of a vehicle (including all parts of the consist) in pixels.
* @param v Vehicle to get the width for.
* @return Width of the vehicle.
*/
int GetVehicleWidth(Vehicle *v, EngineImageType image_type)
int GetVehicleWidth(const Vehicle *v, EngineImageType image_type)
{
int vehicle_width = 0;
if (v->type == VEH_TRAIN || v->type == VEH_ROAD) {
int vehicle_width = 0;
for (const Vehicle *u = v; u != NULL; u = u->Next()) {
vehicle_width += GetSingleVehicleWidth(u, image_type);
}
return vehicle_width;
} else {
return GetSingleVehicleWidth(v, image_type);
}
}
switch (v->type) {
case VEH_TRAIN:
for (const Train *u = Train::From(v); u != NULL; u = u->Next()) {
vehicle_width += u->GetDisplayImageWidth();
}
break;
/**
* Set the mouse cursor to look like a vehicle.
* @param v Vehicle
* @param image_type Type of vehicle image to use.
*/
void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type)
{
bool rtl = _current_text_dir == TD_RTL;
case VEH_ROAD:
for (const RoadVehicle *u = RoadVehicle::From(v); u != NULL; u = u->Next()) {
vehicle_width += u->GetDisplayImageWidth();
}
break;
_cursor.sprite_count = 0;
int total_width = 0;
for (; v != NULL; v = v->HasArticulatedPart() ? v->GetNextArticulatedPart() : NULL) {
if (total_width >= 2 * (int)VEHICLEINFO_FULL_VEHICLE_WIDTH) break;
default:
bool rtl = _current_text_dir == TD_RTL;
SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W, image_type);
const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
vehicle_width = UnScaleGUI(real_sprite->width);
PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
VehicleSpriteSeq seq;
v->GetImage(rtl ? DIR_E : DIR_W, image_type, &seq);
break;
if (_cursor.sprite_count + seq.count > lengthof(_cursor.sprite_seq)) break;
for (uint i = 0; i < seq.count; ++i) {
PaletteID pal2 = (v->vehstatus & VS_CRASHED) || !seq.seq[i].pal ? pal : seq.seq[i].pal;
_cursor.sprite_seq[_cursor.sprite_count].sprite = seq.seq[i].sprite;
_cursor.sprite_seq[_cursor.sprite_count].pal = pal2;
_cursor.sprite_pos[_cursor.sprite_count].x = rtl ? -total_width : total_width;
_cursor.sprite_pos[_cursor.sprite_count].y = 0;
_cursor.sprite_count++;
}
total_width += GetSingleVehicleWidth(v, image_type);
}
return vehicle_width;
int offs = ((int)VEHICLEINFO_FULL_VEHICLE_WIDTH - total_width) / 2;
if (rtl) offs = -offs;
for (uint i = 0; i < _cursor.sprite_count; ++i) {
_cursor.sprite_pos[i].x += offs;
}
UpdateCursorSize();
}