moved migration code to save, and added notice

This commit is contained in:
connlost 2024-10-11 09:20:49 +08:00
parent 79f82989e7
commit 13c1c34c82

View File

@ -525,7 +525,7 @@ void load(const std::filesystem::path& path) {
} }
if (data.contains("GUI")) { if (data.contains("GUI")) {
toml::value& gui = data.at("GUI"); const toml::value& gui = data.at("GUI");
m_icon_size = toml::find_or<int>(gui, "iconSize", 0); m_icon_size = toml::find_or<int>(gui, "iconSize", 0);
m_icon_size_grid = toml::find_or<int>(gui, "iconSizeGrid", 0); m_icon_size_grid = toml::find_or<int>(gui, "iconSizeGrid", 0);
@ -538,10 +538,6 @@ void load(const std::filesystem::path& path) {
auto old_game_install_dir = toml::find_fs_path_or(gui, "installDir", {}); auto old_game_install_dir = toml::find_fs_path_or(gui, "installDir", {});
if (!old_game_install_dir.empty()) { if (!old_game_install_dir.empty()) {
addGameInstallDir(old_game_install_dir); addGameInstallDir(old_game_install_dir);
gui.as_table().erase("installDir");
std::ofstream file(path, std::ios::out);
file << data;
file.close();
} }
const auto install_dir_array = const auto install_dir_array =
@ -647,6 +643,9 @@ void save(const std::filesystem::path& path) {
data["Settings"]["consoleLanguage"] = m_language; data["Settings"]["consoleLanguage"] = m_language;
// TODO Migration code, after a major release this should be removed.
data.at("GUI").as_table().erase("installDir");
std::ofstream file(path, std::ios::out); std::ofstream file(path, std::ios::out);
file << data; file << data;
file.close(); file.close();