15 #define GETTEXT_DOMAIN "wesnoth-lib"
25 #ifdef GUI2_EXPERIMENTAL_LISTBOX
36 #define WRN_WML LOG_STREAM(warn, log_wml)
78 , campaign_id_(campaign["
id"])
79 , selected_difficulty_()
84 difficulties_.append_children(campaign,
"difficulty");
87 if(difficulties_.empty()) {
88 WRN_WML <<
"[campaign] difficulties,difficulty_descriptions= is deprecated. Use [difficulty] instead" << std::endl;
90 std::vector<std::string> difficulty_list =
utils::split(campaign[
"difficulties"]);
91 std::vector<std::string> difficulty_opts =
utils::split(campaign[
"difficulty_descriptions"],
';');
93 if(difficulty_opts.size() != difficulty_list.size()) {
94 difficulty_opts = difficulty_list;
97 for(std::size_t
i = 0;
i < difficulty_opts.size();
i++)
102 temp[
"define"] = difficulty_list[
i];
103 temp[
"image"] = parsed.
icon();
104 temp[
"label"] = parsed.
label();
107 temp[
"old_markup"] =
true;
109 difficulties_.
add_child(
"difficulty", temp);
116 tlistbox& list = find_widget<tlistbox>(&window,
"listbox",
false);
117 window.keyboard_capture(&list);
119 std::map<std::string, string_map>
data;
123 data[
"icon"][
"label"] =
d[
"image"];
124 data[
"label"][
"label"] =
d[
"label"];
125 data[
"label"][
"use_markup"] =
"true";
126 data[
"description"][
"label"] =
d[
"old_markup"].to_bool() ||
d[
"description"].empty() ?
d[
"description"]
128 data[
"description"][
"use_markup"] =
"true";
134 if(
d[
"default"].to_bool(
false)) {
155 tlistbox& list = find_widget<tlistbox>(&window,
"listbox",
false);
child_itors child_range(const std::string &key)
bool is_campaign_completed(const std::string &campaign_id)
bool select_row(const unsigned row, const bool select=true)
Selectes a row.
REGISTER_DIALOG(label_settings)
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
Definitions for the interface to Wesnoth Markup Language (WML).
base class of top level items, the only item which needs to store the final canvases to draw on ...
A class inherited from ttext_box that displays its input as stars.
Dialog is closed with ok button.
unsigned get_item_count() const
Returns the number of items in the listbox.
void add_row(const string_map &item, const int index=-1)
When an item in the list is selected by the user we need to update the state.
config & add_child(const std::string &key)
void pre_show(twindow &window)
Inherited from tdialog.
static lg::log_domain log_wml("wml")
config & child(const std::string &key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
Standard logging facilities (interface).
std::string selected_difficulty_
twidget * find(const std::string &id, const bool must_be_active) override
See twidget::find.
std::vector< std::string > split(std::string const &val, const char c, const int flags)
Splits a (comma-)separated string into a vector of pieces.
A config object defines a single node in a WML file, with access to child nodes.
int get_selected_row() const
Returns the first selected row.
void post_show(twindow &window)
Inherited from tdialog.
GLsizei const GLcharARB ** string
const tgrid * get_row_grid(const unsigned row) const
Returns the grid of the wanted row.