The Battle for Wesnoth  1.15.1+dev
depcheck_confirm_change.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 2018 by Boldizs√°r Lipka <lipkab@zoho.com>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #define GETTEXT_DOMAIN "wesnoth-lib"
16 
18 
19 #include "gui/widgets/settings.hpp"
20 #include "gui/widgets/window.hpp"
21 #include "formula/string_utils.hpp"
22 #include "gettext.hpp"
23 
24 namespace gui2
25 {
26 namespace dialogs
27 {
28 
29 /*WIKI
30  * @page = GUIWindowDefinitionWML
31  * @order = 2_depcheck_confirm_change
32  *
33  * == SP/MP Dependency Check: Confirm Change ==
34  *
35  * Asks the user to confirm a change required to proceed. Currently used
36  * for enabling/disabling modifications
37  *
38  * @begin{table}{dialog_widgets}
39  *
40  * message & & label & m &
41  * displays the details of the required changes $
42  *
43  * itemlist & & scroll_label & m &
44  * displays the list of affected items $
45  *
46  * cancel & & button & m &
47  * refuse to apply changes $
48  *
49  * ok & & button & m &
50  * agree to apply changes $
51  *
52  * @end{table}
53  */
54 
55 REGISTER_DIALOG(depcheck_confirm_change)
56 
58  bool action,
59  const std::vector<std::string>& mods,
60  const std::string& requester)
61 {
62  utils::string_map symbols;
63  symbols["requester"] = requester;
64  std::string message;
65  if(action) {
66  message = VGETTEXT("$requester requires the following modifications to "
67  "be enabled:",
68  symbols);
69  } else {
70  message = VGETTEXT("$requester requires the following modifications to "
71  "be disabled:",
72  symbols);
73  }
74 
75  std::string list = "\t";
76  list += utils::join(mods, "\n\t");
77 
78  register_label("message", false, message);
79 
80  register_label("itemlist", false, list);
81 }
82 } // namespace dialogs
83 } // namespace gui2
std::map< std::string, t_string > string_map
std::string join(const T &v, const std::string &s=",")
Generates a new string joining container items in a list.
Main class to show messages to the user.
Definition: message.hpp:34
This file contains the window object, this object is a top level container which has the event manage...
STL namespace.
Generic file dialog.
Definition: field-fwd.hpp:22
This file contains the settings handling of the widget library.
Various uncategorised dialogs.
#define VGETTEXT(msgid,...)
Handy wrappers around interpolate_variables_into_string and gettext.