|
@@ -1012,51 +1012,51 @@ struct RefitWindow : public Window {
|
|
|
if (!_ctrl_pressed) {
|
|
|
SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
|
|
|
} else {
|
|
|
/* The vehicle selection has changed. */
|
|
|
this->InvalidateData(2);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
case WID_VR_MATRIX: { // listbox
|
|
|
this->SetSelection(this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_VR_MATRIX));
|
|
|
this->SetWidgetDisabledState(WID_VR_REFIT, this->sel[0] < 0);
|
|
|
this->InvalidateData(1);
|
|
|
|
|
|
if (click_count == 1) break;
|
|
|
FALLTHROUGH;
|
|
|
}
|
|
|
|
|
|
case WID_VR_REFIT: // refit button
|
|
|
if (this->cargo != nullptr) {
|
|
|
const Vehicle *v = Vehicle::Get(this->window_number);
|
|
|
|
|
|
if (this->order == INVALID_VEH_ORDER_ID) {
|
|
|
bool delete_window = this->selected_vehicle == v->index && this->num_vehicles == UINT8_MAX;
|
|
|
if (DoCommandP(v->tile, this->selected_vehicle, this->cargo->cargo | this->cargo->subtype << 8 | this->num_vehicles << 16, GetCmdRefitVeh(v)) && delete_window) delete this;
|
|
|
if (DoCommandP(v->tile, this->selected_vehicle, this->cargo->cargo | this->cargo->subtype << 8 | this->num_vehicles << 16, GetCmdRefitVeh(v)) && delete_window) this->Close();
|
|
|
} else {
|
|
|
if (DoCommandP(v->tile, v->index, this->cargo->cargo | this->order << 16, CMD_ORDER_REFIT)) delete this;
|
|
|
if (DoCommandP(v->tile, v->index, this->cargo->cargo | this->order << 16, CMD_ORDER_REFIT)) this->Close();
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void OnMouseDrag(Point pt, int widget) override
|
|
|
{
|
|
|
switch (widget) {
|
|
|
case WID_VR_VEHICLE_PANEL_DISPLAY: { // Vehicle image.
|
|
|
if (this->order != INVALID_VEH_ORDER_ID) break;
|
|
|
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_VR_VEHICLE_PANEL_DISPLAY);
|
|
|
this->SetSelectedVehicles(pt.x - nwi->pos_x);
|
|
|
this->SetWidgetDirty(WID_VR_VEHICLE_PANEL_DISPLAY);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void OnDragDrop(Point pt, int widget) override
|
|
|
{
|
|
|
switch (widget) {
|
|
|
case WID_VR_VEHICLE_PANEL_DISPLAY: { // Vehicle image.
|
|
|
if (this->order != INVALID_VEH_ORDER_ID) break;
|
|
@@ -2697,54 +2697,55 @@ public:
|
|
|
|
|
|
case VEH_SHIP:
|
|
|
case VEH_AIRCRAFT:
|
|
|
this->SelectPlane(SEL_RT_REFIT);
|
|
|
break;
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
}
|
|
|
this->FinishInitNested(window_number);
|
|
|
this->owner = v->owner;
|
|
|
this->GetWidget<NWidgetViewport>(WID_VV_VIEWPORT)->InitializeViewport(this, this->window_number | (1 << 31), _vehicle_view_zoom_levels[v->type]);
|
|
|
|
|
|
this->GetWidget<NWidgetCore>(WID_VV_START_STOP)->tool_tip = STR_VEHICLE_VIEW_TRAIN_STATUS_START_STOP_TOOLTIP + v->type;
|
|
|
this->GetWidget<NWidgetCore>(WID_VV_RENAME)->tool_tip = STR_VEHICLE_DETAILS_TRAIN_RENAME + v->type;
|
|
|
this->GetWidget<NWidgetCore>(WID_VV_LOCATION)->tool_tip = STR_VEHICLE_VIEW_TRAIN_CENTER_TOOLTIP + v->type;
|
|
|
this->GetWidget<NWidgetCore>(WID_VV_REFIT)->tool_tip = STR_VEHICLE_VIEW_TRAIN_REFIT_TOOLTIP + v->type;
|
|
|
this->GetWidget<NWidgetCore>(WID_VV_GOTO_DEPOT)->tool_tip = STR_VEHICLE_VIEW_TRAIN_SEND_TO_DEPOT_TOOLTIP + v->type;
|
|
|
this->GetWidget<NWidgetCore>(WID_VV_SHOW_ORDERS)->tool_tip = STR_VEHICLE_VIEW_TRAIN_ORDERS_TOOLTIP + v->type;
|
|
|
this->GetWidget<NWidgetCore>(WID_VV_SHOW_DETAILS)->tool_tip = STR_VEHICLE_VIEW_TRAIN_SHOW_DETAILS_TOOLTIP + v->type;
|
|
|
this->GetWidget<NWidgetCore>(WID_VV_CLONE)->tool_tip = STR_VEHICLE_VIEW_CLONE_TRAIN_INFO + v->type;
|
|
|
|
|
|
this->UpdateButtonStatus();
|
|
|
}
|
|
|
|
|
|
~VehicleViewWindow()
|
|
|
void Close() override
|
|
|
{
|
|
|
DeleteWindowById(WC_VEHICLE_ORDERS, this->window_number, false);
|
|
|
DeleteWindowById(WC_VEHICLE_REFIT, this->window_number, false);
|
|
|
DeleteWindowById(WC_VEHICLE_DETAILS, this->window_number, false);
|
|
|
DeleteWindowById(WC_VEHICLE_TIMETABLE, this->window_number, false);
|
|
|
this->Window::Close();
|
|
|
}
|
|
|
|
|
|
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
|
|
{
|
|
|
const Vehicle *v = Vehicle::Get(this->window_number);
|
|
|
switch (widget) {
|
|
|
case WID_VV_START_STOP:
|
|
|
size->height = std::max(size->height, std::max(GetSpriteSize(SPR_FLAG_VEH_STOPPED).height, GetSpriteSize(SPR_FLAG_VEH_RUNNING).height) + WD_IMGBTN_TOP + WD_IMGBTN_BOTTOM);
|
|
|
break;
|
|
|
|
|
|
case WID_VV_FORCE_PROCEED:
|
|
|
if (v->type != VEH_TRAIN) {
|
|
|
size->height = 0;
|
|
|
size->width = 0;
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case WID_VV_VIEWPORT:
|
|
|
size->width = VV_INITIAL_VIEWPORT_WIDTH;
|
|
|
size->height = (v->type == VEH_TRAIN) ? VV_INITIAL_VIEWPORT_HEIGHT_TRAIN : VV_INITIAL_VIEWPORT_HEIGHT;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|