diff options
author | michi_cc <michi_cc@openttd.org> | 2012-04-17 19:44:16 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2012-04-17 19:44:16 +0000 |
commit | 37e321044a1c32873980fc6d75c45011639ca2f3 (patch) | |
tree | aefe8b92c5cc387d178e23fad1dafd7cbc2aa872 /src/group_gui.cpp | |
parent | 0daf3509227d476d7c869ce5c74906d7e3214565 (diff) | |
download | openttd-37e321044a1c32873980fc6d75c45011639ca2f3.tar.xz |
(svn r24139) -Add: Creating a new vehicle group by drag and drop. (Based on patch by Juanjo)
Diffstat (limited to 'src/group_gui.cpp')
-rw-r--r-- | src/group_gui.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 0c7a412c7..c68d4405f 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -646,9 +646,9 @@ public: this->SetDirty(); uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height); - if (id_g >= this->groups.Length()) return; + GroupID new_g = id_g >= this->groups.Length() ? NEW_GROUP : this->groups[id_g]->index; - DoCommandP(0, this->groups[id_g]->index, vindex | (_ctrl_pressed ? 1 << 31 : 0), CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE)); + DoCommandP(0, new_g, vindex | (_ctrl_pressed ? 1 << 31 : 0), CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE), new_g == NEW_GROUP ? CcAddVehicleNewGroup : NULL); break; } @@ -865,6 +865,21 @@ void CcCreateGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 } /** + * Open rename window after adding a vehicle to a new group via drag and drop. + * @param success Did command succeed? + * @param tile Unused. + * @param p1 Unused. + * @param p2 Bit 0-19: Vehicle ID. + */ +void CcAddVehicleNewGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) +{ + if (result.Failed()) return; + assert(Vehicle::IsValidID(GB(p2, 0, 20))); + + CcCreateGroup(result, 0, Vehicle::Get(GB(p2, 0, 20))->type, 0); +} + +/** * Removes the highlight of a vehicle in a group window * @param *v Vehicle to remove all highlights from */ |