15 #define GETTEXT_DOMAIN "wesnoth-lib"
29 #include <boost/algorithm/string.hpp>
32 #define ERR_LOG_VERSION_MIGRATION LOG_STREAM(err, log_version_migration)
33 #define WRN_LOG_VERSION_MIGRATION LOG_STREAM(warn, log_version_migration)
34 #define LOG_LOG_VERSION_MIGRATION LOG_STREAM(info, log_version_migration)
35 #define DBG_LOG_VERSION_MIGRATION LOG_STREAM(debug, log_version_migration)
47 gui2::show_message(
_(
"No Other Version Found"),
_(
"This would import settings from a previous version of Wesnoth, but no other version was found on this device"), gui2::dialogs::message::button_style::auto_close);
58 std::string previous_version_str = std::to_string(current_version.
major_version()) +
"."
60 std::string previous_addons_dir
64 versions_.push_back(previous_version_str);
71 listbox& version_list = find_widget<listbox>(
"versions_listbox");
77 item_label[
"label"] = version;
78 data[
"version_label"] = item_label;
88 listbox& version_list = find_widget<listbox>(
"versions_listbox");
92 std::string migrate_addons_dir
94 std::string migrate_synced_prefs_file
96 std::string migrate_unsynced_prefs_file
98 std::string migrate_credentials_file
104 std::vector<std::string> old_addons;
105 std::vector<std::string> current_addons;
106 std::vector<std::string> migrate_addons;
111 std::set_difference(old_addons.begin(), old_addons.end(), current_addons.begin(), current_addons.end(), std::back_inserter(migrate_addons));
113 if(migrate_addons.size() > 0) {
118 #if !defined(_WIN32) && !defined(__APPLE__)
119 bool already_migrated =
false;
121 std::string old_migrate_prefs_file = linux_old_config_dir +
"/preferences";
122 std::string old_migrate_credentials_file = linux_old_config_dir +
"/credentials-aes";
125 already_migrated =
true;
129 already_migrated =
true;
133 if(!already_migrated)
154 char const* xdg_config = getenv(
"XDG_CONFIG_HOME");
157 if(!xdg_config || xdg_config[0] ==
'\0') {
158 xdg_config = getenv(
"HOME");
This shows the dialog to select a previous version of Wesnoth to migrate preferences from and redownl...
virtual void post_show() override
Actions to be taken after the window has been shown.
std::string old_config_dir()
Prior to 1.19 linux installs would usually store the credentials and preferences file under XDG_CONFI...
migrate_version_selection()
std::vector< std::string > versions_
void migrate_credentials(const std::string &credentials_dir)
virtual void pre_show() override
Actions to be taken before showing the window.
Abstract base class for all modal dialogs.
bool show(const unsigned auto_close_time=0)
Shows the window.
int get_retval() const
Returns the cached window exit code.
grid & add_row(const widget_item &item, const int index=-1)
When an item in the list is selected by the user we need to update the state.
int get_selected_row() const
Returns the first selected row.
void migrate_preferences(const std::string &prefs_dir)
void reload_preferences()
Represents version numbers.
unsigned int minor_version() const
Retrieves the minor version number (x2 in "x1.x2.x3").
unsigned int major_version() const
Retrieves the major version number (x1 in "x1.x2.x3").
Declarations for File-IO.
Interfaces for manipulating version numbers of engine, add-ons, etc.
static std::string _(const char *str)
bool ad_hoc_addon_fetch_session(const std::vector< std::string > &addon_ids)
Conducts an ad-hoc add-ons server connection to download an add-on with a particular id and all it's ...
static lg::log_domain log_version_migration
void get_files_in_dir(const std::string &dir, std::vector< std::string > *files, std::vector< std::string > *dirs, name_mode mode, filter_mode filter, reorder_mode reorder, file_tree_checksum *checksum)
Get a list of all files and/or directories in a given directory.
std::string get_user_data_dir()
void copy_file(const std::string &src, const std::string &dest)
Read a file and then writes it back out.
static bool file_exists(const bfs::path &fpath)
std::string get_synced_prefs_file()
location of preferences file containing preferences that are synced between computers note that wesno...
std::string get_unsynced_prefs_file()
location of preferences file containing preferences that aren't synced between computers
std::string get_credentials_file()
std::string get_addons_dir()
const std::string get_version_path_suffix(const version_info &version)
const version_info wesnoth_version(VERSION)
REGISTER_DIALOG(editor_edit_unit)
std::map< std::string, widget_item > widget_data
std::map< std::string, t_string > widget_item
void show_message(const std::string &title, const std::string &msg, const std::string &button_caption, const bool auto_close, const bool message_use_markup, const bool title_use_markup)
Shows a message to the user.
@ OK
Dialog was closed with the OK button.