diff options
author | peter1138 <peter1138@openttd.org> | 2014-04-11 18:14:44 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2014-04-11 18:14:44 +0000 |
commit | fc0646c2297f944dde2f85a7c6d78713ca8f7ff8 (patch) | |
tree | fca6d837e1fa19a991490ff78f4c16eed4f9af81 /src/group_gui.cpp | |
parent | 396f4ad6a81ed3dc55aaccff2e79da3451c49a40 (diff) | |
download | openttd-fc0646c2297f944dde2f85a7c6d78713ca8f7ff8.tar.xz |
(svn r26455) -Change: Prompt for confirmation when deleting a vehicle group.
Diffstat (limited to 'src/group_gui.cpp')
-rw-r--r-- | src/group_gui.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 698f9a71f..0b6c860dd 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -110,6 +110,7 @@ private: GroupID group_sel; ///< Selected group (for drag/drop) GroupID group_rename; ///< Group being renamed, INVALID_GROUP if none GroupID group_over; ///< Group over which a vehicle is dragged, INVALID_GROUP if none + GroupID group_confirm; ///< Group awaiting delete confirmation GUIGroupList groups; ///< List of groups uint tiny_step_height; ///< Step height for the group list Scrollbar *group_sb; @@ -565,6 +566,15 @@ public: } } + static void DeleteGroupCallback(Window *win, bool confirmed) + { + if (confirmed) { + VehicleGroupWindow *w = (VehicleGroupWindow*)win; + w->vli.index = ALL_GROUP; + DoCommandP(0, w->group_confirm, 0, CMD_DELETE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_DELETE)); + } + } + virtual void OnClick(Point pt, int widget, int click_count) { switch (widget) { @@ -629,10 +639,8 @@ public: } case WID_GL_DELETE_GROUP: { // Delete the selected group - GroupID group = this->vli.index; - this->vli.index = ALL_GROUP; - - DoCommandP(0, group, 0, CMD_DELETE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_DELETE)); + this->group_confirm = this->vli.index; + ShowQuery(STR_QUERY_GROUP_DELETE_CAPTION, STR_GROUP_DELETE_QUERY_TEXT, this, DeleteGroupCallback); break; } |