16 #define GETTEXT_DOMAIN "wesnoth-lib"
22 #include "../../addon/manager.hpp"
37 void strip_trailing_dir_separators(std::string& str)
40 str.erase(str.size() - 1);
44 std::string format_file_list(
const std::vector<std::string>& files_original)
46 if(files_original.empty()) {
51 std::vector<std::string> files(files_original);
53 for(std::string & file : files)
57 std::string parent_path;
59 const bool is_main_cfg =
filename ==
"_main.cfg";
78 strip_trailing_dir_separators(base);
99 base.erase(suffix_pos);
110 if(!info_cfg.
empty() && !info_cfg[
"title"].
empty()) {
111 file = info_cfg[
"title"].str();
121 if(files.size() == 1) {
135 const std::
string& post_summary,
136 const std::vector<std::
string>& files,
137 const std::
string& details)
139 , have_files_(!files.empty())
140 , have_post_summary_(!post_summary.empty())
143 const std::string& file_list_text = format_file_list(files);
147 if(!file_list_text.empty()) {
148 report_ +=
"\n" + file_list_text;
151 if(!post_summary.empty()) {
152 report_ +=
"\n\n" + post_summary;
156 report_ +=
_(
"Details:");
162 register_label(
"summary",
true, summary);
163 register_label(
"post_summary",
true, post_summary);
164 register_label(
"files",
true, file_list_text);
165 register_label(
"details",
true, details);
171 styled_widget& filelist = find_widget<styled_widget>(
"files");
177 = find_widget<styled_widget>(
"post_summary");
181 button& copy_button = find_widget<button>(
"copy");
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.
virtual void pre_show() override
Actions to be taken before showing the window.
void copy_report_callback()
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)
Copies text to the 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.
std::string filename
Filename.