Allow cloning trains directly from the template train list

See: #312
This commit is contained in:
Jonathan G Rennison
2021-08-22 14:59:33 +01:00
parent a4c73e71c3
commit a026d82c6b
7 changed files with 88 additions and 0 deletions

View File

@@ -28,6 +28,7 @@
#include "infrastructure_func.h"
#include "order_backup.h"
#include "zoom_func.h"
#include "tbtr_template_vehicle.h"
#include "widgets/depot_widget.h"
@@ -917,6 +918,21 @@ struct DepotWindow : Window {
return true;
}
/**
* Clones a vehicle
* @param v the original vehicle to clone
* @return Always true.
*/
bool OnTemplateVehicleSelect(const TemplateVehicle *v) override
{
/* Copy-clone, open viewport for new vehicle, and deselect the tool (assume player wants to changs things on new vehicle) */
if (DoCommandP(this->window_number, v->index, 0, CMD_CLONE_VEHICLE_FROM_TEMPLATE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN), CcCloneVehicle)) {
ResetObjectToPlace();
}
return true;
}
void OnPlaceObjectAbort() override
{
/* abort clone */