16 #define GETTEXT_DOMAIN "wesnoth-lib"
22 #include "../../addon/manager.hpp"
39 void strip_trailing_dir_separators(std::string& str)
42 str.erase(str.size() - 1);
46 std::string format_file_list(
const std::vector<std::string>& files_original)
48 if(files_original.empty()) {
53 std::vector<std::string> files(files_original);
55 for(std::string & file : files)
59 std::string parent_path;
61 const bool is_main_cfg = filename ==
"_main.cfg";
80 strip_trailing_dir_separators(base);
98 static const std::string wml_suffix =
".cfg";
100 if(base.size() > wml_suffix.size()) {
101 const std::size_t suffix_pos = base.size() - wml_suffix.size();
102 if(base.substr(suffix_pos) == wml_suffix) {
103 base.erase(suffix_pos);
114 if(!info_cfg.
empty() && !info_cfg[
"title"].
empty()) {
115 file = info_cfg[
"title"].str();
125 if(files.size() == 1) {
139 const std::
string& post_summary,
140 const std::vector<std::
string>& files,
141 const std::
string& details)
143 , have_files_(!files.empty())
144 , have_post_summary_(!post_summary.empty())
147 const std::string& file_list_text = format_file_list(files);
151 if(!file_list_text.empty()) {
152 report_ +=
"\n" + file_list_text;
155 if(!post_summary.empty()) {
156 report_ +=
"\n\n" + post_summary;
160 report_ +=
_(
"Details:");
166 register_label(
"summary",
true, summary);
167 register_label(
"post_summary",
true, post_summary);
168 register_label(
"files",
true, file_list_text);
169 register_label(
"details",
true, details);
181 = find_widget<styled_widget>(&
window,
"post_summary",
false);
185 button& copy_button = find_widget<button>(&
window,
"copy",
false);
192 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.
WML preprocessor/parser error report dialog.
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.
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
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.
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.
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.
This file contains the settings handling of the widget library.