15 #define GETTEXT_DOMAIN "wesnoth-lib"
36 #ifdef GUI2_EXPERIMENTAL_LISTBOX
98 bool str_up(
const config* cfg,
const std::string& prop_id,
unsigned i1,
unsigned i2)
100 return cfg->
child(
"campaign", i1)[prop_id].str() < cfg->
child(
"campaign", i2)[prop_id].str();
102 bool str_down(
const config* cfg,
const std::string& prop_id,
unsigned i1,
unsigned i2)
104 return cfg->
child(
"campaign", i1)[prop_id].str() > cfg->
child(
"campaign", i2)[prop_id].str();
106 bool num_up(
const config* cfg,
const std::string& prop_id,
unsigned i1,
unsigned i2)
108 return cfg->
child(
"campaign", i1)[prop_id].to_int() < cfg->
child(
"campaign", i2)[prop_id].to_int();
110 bool num_down(
const config* cfg,
const std::string& prop_id,
unsigned i1,
unsigned i2)
112 return cfg->
child(
"campaign", i1)[prop_id].to_int() > cfg->
child(
"campaign", i2)[prop_id].to_int();
115 struct filter_transform
117 filter_transform(
const std::vector<std::string>& filtertext) :
filtertext_(filtertext) {}
118 bool operator()(
const config& cfg)
const
126 if(std::search(val.begin(),
156 template <
typename MapT>
157 typename MapT::mapped_type
const& const_at(
typename MapT::key_type
const& key,
160 typename MapT::const_iterator it = map.find(key);
161 if(it == map.end()) {
162 assert(it != map.end());
163 throw std::out_of_range(
171 addons_list::const_iterator it = addons.find(
id);
172 assert(it != addons.end());
182 , cfg_iterators_(cfg_.child_range("campaign"))
194 std::vector<bool>
res;
198 res.push_back(
filter(child));
208 if(other != &selectable) {
212 tlistbox& listbox = find_widget<tlistbox>(&window,
"addons",
true);
216 listbox.
order_by(std::less<unsigned>());
229 tselectable_& selectable = find_widget<tselectable_>(&window,
id,
true);
230 orders_.push_back(&selectable);
237 std::bind(&str_up, &
cfg_, prop_id, _1, _2),
238 std::bind(&str_down, &
cfg_, prop_id, _1, _2)
245 std::bind(&num_up, &
cfg_, prop_id, _1, _2),
246 std::bind(&num_down, &
cfg_, prop_id, _1, _2)
255 switch(state.
state) {
260 colorname =
"#a69275";
264 colorname =
"#00ff00";
267 colorname =
"#ffff00";
270 colorname =
"#ff7f00";
273 colorname =
"#ff0000";
276 colorname =
"#777777";
280 return "<span color='" + colorname +
"'>" + str +
"</span>";
289 tx = info.
can_publish ?
_(
"addon_state^Published, not installed") :
_(
"addon_state^Not installed");
297 tx = info.
can_publish ?
_(
"addon_state^Published") :
_(
"addon_state^Installed");
301 tx = info.
can_publish ?
_(
"addon_state^Published, upgradable") :
_(
"addon_state^Installed, upgradable");
305 tx = info.
can_publish ?
_(
"addon_state^Published, outdated on server") :
_(
"addon_state^Installed, outdated on server");
309 tx = info.
can_publish ?
_(
"addon_state^Published, broken") :
_(
"addon_state^Installed, broken");
313 tx =
_(
"addon_state^Unknown");
326 switch(state.
state) {
329 s =
_(
"addon_state^Not installed");
331 s =
_(
"addon_state^Published, not installed");
336 s =
_(
"addon_state^Installed");
338 s =
_(
"addon_state^Published");
343 s =
_(
"addon_state^Installed, not tracking local version");
347 s =
_(
"addon_state^Published, not tracking local version");
353 ?
_(
"addon_state^Installed ($local_version|), "
355 :
_(
"addon_state^Published ($local_version| "
356 "installed), upgradable");
362 ?
_(
"addon_state^Installed ($local_version|), "
363 "outdated on server")
364 :
_(
"addon_state^Published ($local_version| "
365 "installed), outdated on server");
370 s =
_(
"addon_state^Installed, broken");
372 s =
_(
"addon_state^Published, broken");
376 s =
_(
"addon_state^Unknown");
384 tlistbox& list = find_widget<tlistbox>(&window,
"addons",
false);
388 ids_.push_back(
c[
"name"]);
392 std::map<std::string, string_map>
data;
396 data.insert(std::make_pair(
"icon", item));
399 data.insert(std::make_pair(
"name", item));
402 item[
"use_markup"] =
"true";
403 data.insert(std::make_pair(
"installation_status", item));
406 data.insert(std::make_pair(
"version", item));
408 item[
"label"] = info.
author;
409 data.insert(std::make_pair(
"author", item));
412 data.insert(std::make_pair(
"size", item));
414 item[
"label"] = std::to_string(info.
downloads);
415 data.insert(std::make_pair(
"downloads", item));
418 data.insert(std::make_pair(
"type", item));
424 tstacked_widget& install_update_stack = find_widget<tstacked_widget>(row_grid,
"install_update_stack",
false);
432 find_widget<tbutton>(row_grid,
"single_install",
false).set_active(!is_installed);
435 find_widget<tbutton>(row_grid,
"single_uninstall",
false).set_active(is_installed);
444 find_widget<ttext_box>(&window,
"filter",
false).set_text_changed_callback(
447 #ifdef GUI2_EXPERIMENTAL_LISTBOX
454 dialog_callback<taddon_list, &taddon_list::on_addon_select>);
457 tbutton& url_go_button = find_widget<tbutton>(&window,
"url_go",
false);
458 tbutton& url_copy_button = find_widget<tbutton>(&window,
"url_copy",
false);
459 ttext_box& url_textbox = find_widget<ttext_box>(&window,
"url",
false);
464 url_copy_button.set_active(
false);
465 url_copy_button.set_tooltip(
_(
"Clipboard support not found, contact your packager"));
483 find_widget<tbutton>(&window,
"options",
false),
487 find_widget<tbutton>(&window,
"show_help",
false),
527 char buf[1024] = { 0 };
528 struct std::tm*
const t = std::localtime(&time);
531 ?
"%Y-%m-%d %I:%M %p"
544 const int index = find_widget<tlistbox>(&window,
"addons",
false).get_selected_row();
557 find_widget<tcontrol>(&window,
"author",
false).
set_label(info.
author);
560 tcontrol& status = find_widget<tcontrol>(&window,
"status",
false);
562 status.set_use_markup(
true);
565 find_widget<tcontrol>(&window,
"downloads",
false).
set_label(std::to_string(info.
downloads));
571 if(!feedback_url.empty()) {
572 find_widget<tstacked_widget>(&window,
"feedback_stack",
false).select_layer(1);
573 find_widget<ttext_box>(&window,
"url",
false).set_value(feedback_url);
575 find_widget<tstacked_widget>(&window,
"feedback_stack",
false).select_layer(0);
child_itors child_range(const std::string &key)
size_t strftime(char *str, size_t count, const std::string &format, const std::tm *time)
static std::string describe_status_simple(const addon_tracking_info &info)
void show_help(CVideo &video, const std::string &show_topic, int xloc, int yloc)
Open the help browser, show topic with id show_topic.
void register_sort_button_alphabetical(twindow &window, const std::string &id, const std::string &prop_id)
std::string interpolate_variables_into_string(const std::string &str, const string_map *const symbols)
Function which will interpolate variables, starting with '$' in the string 'str' with the equivalent ...
void read_addons_list(const config &cfg, addons_list &dest)
void set_row_shown(const unsigned row, const bool shown)
Makes a row visible or invisible.
void options_button_callback(twindow &window)
virtual void set_callback_state_change(std::function< void(twidget &)> callback)=0
When the user does something to change the widget state this event is fired.
virtual unsigned get_value() const =0
Is the control selected?
bool available()
Whether wesnoth was compiled with support for a clipboard.
virtual void set_active(const bool active) override
See tcontrol::set_active.
std::string size_display_string(double size)
Get a human-readable representation of the specified byte count.
void connect_signal_notify_modified(tdispatcher &dispatcher, const tsignal_notification_function &signal)
Connects a signal handler for getting a notification upon modification.
void register_sort_button(twindow &window, const std::string &id, const tgenerator_::torder_func &up, const tgenerator_::torder_func &down)
REGISTER_DIALOG(label_settings)
virtual void set_label(const t_string &label)
GLuint const GLfloat * val
void connect_signal_mouse_left_click(tdispatcher &dispatcher, const tsignal_function &signal)
Connects a signal handler for a left mouse button click.
Class for a single line text area.
void on_addon_select(twindow &window)
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
void browse_url_callback(ttext_box &url_box)
Definitions for the interface to Wesnoth Markup Language (WML).
Define the common filters for the gui2::tpane class.
std::string get_value() const
std::function< bool(unsigned, unsigned)> torder_func
version_info installed_version
No tracking information available.
void register_sort_button_numeric(twindow &window, const std::string &id, const std::string &prop_id)
virtual void set_value(const unsigned)=0
Select the control.
base class of top level items, the only item which needs to store the final canvases to draw on ...
void show_help(twindow &window)
A class inherited from ttext_box that displays its input as stars.
Desktop environment interaction functions.
static UNUSEDNOWARN std::string _(const char *str)
Version in the server is older than local installation.
bool chars_equal_insensitive(char a, char b)
std::map< std::string, t_string > string_map
void on_order_button_click(twindow &window, const tgenerator_::torder_func &up, const tgenerator_::torder_func &down, twidget &w)
void order_by(const tgenerator_::torder_func &func)
unsigned get_item_count() const
Returns the number of items in the listbox.
void pre_show(twindow &window)
Inherited from tdialog.
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.
std::string display_title() const
Get a title or automatic title for display.
std::map< std::string, addon_info > addons_list
GLubyte GLubyte GLubyte GLubyte w
void copy_url_callback(ttext_box &url_box)
Version in the server is newer than local installation.
const config & cfg_
Config which contains the list with the campaigns.
GLenum GLuint GLsizei const char * buf
const std::string unicode_em_dash
static size_t id
Ids for the timers.
Dependencies not satisfied.
std::map< std::string, t_string > string_map
std::string str() const
Serializes the version number into string form.
Small abstract helper class.
std::string display_icon() const
Get an icon path fixed for display (e.g.
bool open_object(const std::string &path_or_url)
Opens the specified object with the default application configured for its type.
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
static std::string colorify_addon_state_string(const std::string &str, const addon_tracking_info &state, bool verbose=false)
std::string display_type() const
Get an add-on type identifier for display in the user's language.
const_attr_itors attribute_range() const
std::vector< tselectable_ * > orders_
unsigned child_count(const std::string &key) const
addons_tracking_list tracking_info_
Base class for all visible items.
static std::string describe_status_verbose(const addon_tracking_info &state)
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
bool open_object_is_supported()
Returns whether open_object() is supported/implemented for the current platform.
void copy_to_clipboard(const std::string &text, const bool)
Copies text to the clipboard.
void on_filtertext_changed(ttext_ *textbox, const std::string &text)
addon_tracking_info get_addon_tracking_info(const addon_info &addon)
Get information about an add-on comparing its local state with the add-ons server entry...
std::vector< std::string > ids_
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...
Shows the list of addons on the server.
void set_callback_value_change(const std::function< void(twidget &)> &callback)
static std::string format_addon_time(time_t time)
static void set_label(twindow &window, const std::string &id, const std::string &label)
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.
Stores additional status information about add-ons.
const std::vector< std::string > filtertext_
A config object defines a single node in a WML file, with access to child nodes.
GLsizei const GLcharARB ** string
bool use_twelve_hour_clock_format()
Abstract base class for text items.
const tgrid * get_row_grid(const unsigned row) const
Returns the grid of the wanted row.
Version in the server matches local installation.