Merge branch 'save_ext' into improved_breakdowns
# Conflicts: # src/train_cmd.cpp
This commit is contained in:
@@ -727,7 +727,10 @@ struct RefitWindow : public Window {
|
||||
if (_returned_mail_refit_capacity > 0) {
|
||||
SetDParam(2, CT_MAIL);
|
||||
SetDParam(3, _returned_mail_refit_capacity);
|
||||
if (money <= 0) {
|
||||
if (this->order != INVALID_VEH_ORDER_ID) {
|
||||
/* No predictable cost */
|
||||
return STR_PURCHASE_INFO_AIRCRAFT_CAPACITY;
|
||||
} else if (money <= 0) {
|
||||
SetDParam(4, -money);
|
||||
return STR_REFIT_NEW_CAPACITY_INCOME_FROM_AIRCRAFT_REFIT;
|
||||
} else {
|
||||
@@ -735,7 +738,11 @@ struct RefitWindow : public Window {
|
||||
return STR_REFIT_NEW_CAPACITY_COST_OF_AIRCRAFT_REFIT;
|
||||
}
|
||||
} else {
|
||||
if (money <= 0) {
|
||||
if (this->order != INVALID_VEH_ORDER_ID) {
|
||||
/* No predictable cost */
|
||||
SetDParam(2, STR_EMPTY);
|
||||
return STR_PURCHASE_INFO_CAPACITY;
|
||||
} else if (money <= 0) {
|
||||
SetDParam(2, -money);
|
||||
return STR_REFIT_NEW_CAPACITY_INCOME_FROM_REFIT;
|
||||
} else {
|
||||
@@ -1657,7 +1664,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;
|
||||
}
|
||||
@@ -2136,9 +2143,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);
|
||||
@@ -2314,22 +2319,22 @@ static const NWidgetPart _nested_vehicle_view_widgets[] = {
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_CENTER_MAIN_VIEW), SetMinimalSize(18, 18), SetFill(1, 1), SetDataTip(SPR_CENTRE_VIEW_VEHICLE, 0x0 /* filled later */),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_CENTER_MAIN_VIEW), SetMinimalSize(18, 18), SetDataTip(SPR_CENTRE_VIEW_VEHICLE, 0x0 /* filled later */),
|
||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_VV_SELECT_DEPOT_CLONE),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_GOTO_DEPOT), SetMinimalSize(18, 18), SetFill(1, 1), SetDataTip(0x0 /* filled later */, 0x0 /* filled later */),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_CLONE), SetMinimalSize(18, 18), SetFill(1, 1), SetDataTip(0x0 /* filled later */, 0x0 /* filled later */),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_GOTO_DEPOT), SetMinimalSize(18, 18), SetDataTip(0x0 /* filled later */, 0x0 /* filled later */),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_CLONE), SetMinimalSize(18, 18), SetDataTip(0x0 /* filled later */, 0x0 /* filled later */),
|
||||
EndContainer(),
|
||||
/* For trains only, 'ignore signal' button. */
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_FORCE_PROCEED), SetMinimalSize(18, 18), SetFill(1, 1),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_FORCE_PROCEED), SetMinimalSize(18, 18),
|
||||
SetDataTip(SPR_IGNORE_SIGNALS, STR_VEHICLE_VIEW_TRAIN_IGNORE_SIGNAL_TOOLTIP),
|
||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_VV_SELECT_REFIT_TURN),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_REFIT), SetMinimalSize(18, 18), SetFill(1, 1), SetDataTip(SPR_REFIT_VEHICLE, 0x0 /* filled later */),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_TURN_AROUND), SetMinimalSize(18, 18), SetFill(1, 1),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_REFIT), SetMinimalSize(18, 18), SetDataTip(SPR_REFIT_VEHICLE, 0x0 /* filled later */),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_TURN_AROUND), SetMinimalSize(18, 18),
|
||||
SetDataTip(SPR_FORCE_VEHICLE_TURN, STR_VEHICLE_VIEW_ROAD_VEHICLE_REVERSE_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_SHOW_ORDERS), SetFill(1, 1), SetMinimalSize(18, 18), SetDataTip(SPR_SHOW_ORDERS, 0x0 /* filled later */),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_SHOW_DETAILS), SetFill(1, 1), SetMinimalSize(18, 18), SetDataTip(SPR_SHOW_VEHICLE_DETAILS, 0x0 /* filled later */),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), SetMinimalSize(18, 0), SetResize(0, 1), EndContainer(),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_SHOW_ORDERS), SetMinimalSize(18, 18), SetDataTip(SPR_SHOW_ORDERS, 0x0 /* filled later */),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_SHOW_DETAILS), SetMinimalSize(18, 18), SetDataTip(SPR_SHOW_VEHICLE_DETAILS, 0x0 /* filled later */),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(18, 0), SetResize(0, 1), EndContainer(),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
@@ -2408,8 +2413,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
|
||||
@@ -2902,36 +2907,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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user