16 #define GETTEXT_DOMAIN "wesnoth-lib"
22 #include "../../addon/manager.hpp"
38 void strip_trailing_dir_separators(std::string& str)
41 str.erase(str.size() - 1);
45 std::string format_file_list(
const std::vector<std::string>& files_original)
47 if(files_original.empty()) {
52 std::vector<std::string> files(files_original);
54 for(std::string & file : files)
58 std::string parent_path;
60 const bool is_main_cfg = filename ==
"_main.cfg";
79 strip_trailing_dir_separators(base);
100 base.erase(suffix_pos);
111 if(!info_cfg.
empty() && !info_cfg[
"title"].
empty()) {
112 file = info_cfg[
"title"].str();
122 if(files.size() == 1) {
136 const std::
string& post_summary,
137 const std::vector<std::
string>& files,
138 const std::
string& details)
140 , have_files_(!files.empty())
141 , have_post_summary_(!post_summary.empty())
144 const std::string& file_list_text = format_file_list(files);
148 if(!file_list_text.empty()) {
149 report_ +=
"\n" + file_list_text;
152 if(!post_summary.empty()) {
153 report_ +=
"\n\n" + post_summary;
157 report_ +=
_(
"Details:");
163 register_label(
"summary",
true, summary);
164 register_label(
"post_summary",
true, post_summary);
165 register_label(
"files",
true, file_list_text);
166 register_label(
"details",
true, details);
178 = find_widget<styled_widget>(&
window,
"post_summary",
false);
182 button& copy_button = find_widget<button>(&
window,
"copy",
false);
189 copy_button.
set_tooltip(
_(
"Clipboard support not found, contact your packager"));
void get_addon_install_info(const std::string &addon_name, config &cfg)
Gets the installation info (_info.cfg) for an add-on.
bool have_addon_install_info(const std::string &addon_name)
Returns true if there is a local installation info (_info.cfg) file for the add-on.
A config object defines a single node in a WML file, with access to child nodes.
Abstract base class for all modal dialogs.
void copy_report_callback()
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
base class of top level items, the only item which needs to store the final canvases to draw on.
Declarations for File-IO.
static std::string _(const char *str)
std::string make_addon_title(const std::string &id)
Replaces underscores to dress up file or dirnames as add-on titles.
void copy_to_clipboard(const std::string &text, const bool)
Copies text to the clipboard.
bool available()
Whether wesnoth was compiled with support for a clipboard.
const std::string wml_extension
std::string base_name(const std::string &file, const bool remove_extension)
Returns the base filename of a file, with directory name stripped.
std::string directory_name(const std::string &file)
Returns the directory name of a file, with filename stripped.
std::string get_addons_dir()
bool is_path_sep(char c)
Returns whether c is a path separator.
std::string normalize_path(const std::string &fpath, bool normalize_separators, bool resolve_dot_entries)
Returns the absolute path of a file.
REGISTER_DIALOG(editor_edit_unit)
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button click.
std::string indent(const std::string &string, std::size_t indent_size)
Indent a block of text.
std::string bullet_list(const T &v, std::size_t indent=4, const std::string &bullet=font::unicode_bullet)
Generates a new string containing a bullet list.