From 027edcf688131642229cf3c97e5eae2594c328c0 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Wed, 19 Dec 2018 10:59:53 -0600 Subject: Enable per-profile game INI files by default again --- src/profile.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/profile.cpp') diff --git a/src/profile.cpp b/src/profile.cpp index 821be4b4..e2274346 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -171,10 +171,8 @@ void Profile::findProfileSettings() if (m_Directory.exists(backupFile)) { storeSetting("LocalSettings", false); m_Directory.rename(backupFile, getIniFileName()); - } else if (m_Directory.exists(getIniFileName())) { - storeSetting("LocalSettings", true); } else { - storeSetting("LocalSettings", false); + storeSetting("LocalSettings", true); } } -- cgit v1.3.1 From 662772c2fc8ec598a64cc4cabe13a86f1e83fb2e Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Wed, 19 Dec 2018 11:19:03 -0600 Subject: Optionally delete and restore profile-specific game INI files when changing the setting --- src/profile.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/profile.cpp') diff --git a/src/profile.cpp b/src/profile.cpp index e2274346..536dfd98 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -773,6 +773,27 @@ bool Profile::localSettingsEnabled() const bool Profile::enableLocalSettings(bool enable) { + if (enable) { + m_GamePlugin->initializeProfile(m_Directory.absolutePath(), IPluginGame::CONFIGURATION); + } else { + QMessageBox::StandardButton res = QMessageBox::question( + QApplication::activeModalWidget(), tr("Delete profile-specific game INI files?"), + tr("Do you want to delete profile-specific game INI files? (If you select \"No\", the " + "save games will be used again if you re-enable profile-specific game INI files.)"), + QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, + QMessageBox::Cancel); + if (res == QMessageBox::Yes) { + QStringList filesToDelete; + for (QString file : m_GamePlugin->iniFiles()) { + filesToDelete << m_Directory.absoluteFilePath(file); + } + shellDelete(filesToDelete, true); + } else if (res == QMessageBox::No) { + // No action + } else { + return false; + } + } storeSetting("LocalSettings", enable); return true; } -- cgit v1.3.1 From 830b63c4e20ffe3fee1ebffc9b88c45305f6737d Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Wed, 19 Dec 2018 11:29:30 -0600 Subject: Re-initialize the profile configuration if INI files are missing --- src/profile.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/profile.cpp') diff --git a/src/profile.cpp b/src/profile.cpp index 536dfd98..f1bec4dd 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -768,7 +768,25 @@ bool Profile::enableLocalSaves(bool enable) bool Profile::localSettingsEnabled() const { - return setting("LocalSettings", false).toBool(); + bool enabled = setting("LocalSettings", false).toBool(); + if (enabled) { + bool reinitConfig = false; + for (QString file : m_GamePlugin->iniFiles()) { + if (!QFile::exists(m_Directory.filePath(file))) { + qWarning("missing %s in %s", qPrintable(file), qPrintable(m_Directory.path())); + reinitConfig = true; + } + } + if (reinitConfig) { + QMessageBox::StandardButton res = QMessageBox::warning( + QApplication::activeModalWidget(), tr("Missing profile-specific game INI files!"), + tr("Some of your profile-specific game INI files were missing. They will now be copied " + "from the vanilla game folder. You might want double-check your settings.") + ); + m_GamePlugin->initializeProfile(m_Directory, IPluginGame::CONFIGURATION); + } + } + return enabled; } bool Profile::enableLocalSettings(bool enable) -- cgit v1.3.1 From 37a6989ba831aa077d63234a8e8b64eb9e8f3eb1 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Wed, 19 Dec 2018 11:53:29 -0600 Subject: Make language about profile-specific settings and save games consistent --- src/mainwindow.ui | 2 +- src/profile.cpp | 8 ++++---- src/profilesdialog.cpp | 2 +- src/profilesdialog.ui | 6 +++--- src/transfersavesdialog.ui | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/profile.cpp') diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 41365768..e42bed27 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1197,7 +1197,7 @@ p, li { white-space: pre-wrap; } <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">This is a list of all savegames for this game. Hover over a list entry to get detailed information about the save including a list of esps/esms that were used at the time this save was created but aren't active now.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">This is a list of all save games for this game. Hover over a list entry to get detailed information about the save including a list of esps/esms that were used at the time this save was created but aren't active now.</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">If you click &quot;Fix Mods...&quot; in the context menu, MO will try to activate all mods and esps to fix those missing esps. It will not disable anything!</span></p></body></html> diff --git a/src/profile.cpp b/src/profile.cpp index f1bec4dd..9b93539d 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -748,9 +748,9 @@ bool Profile::enableLocalSaves(bool enable) } } else { QMessageBox::StandardButton res = QMessageBox::question( - QApplication::activeModalWidget(), tr("Delete savegames?"), - tr("Do you want to delete local savegames? (If you select \"No\", the " - "save games will show up again if you re-enable local savegames)"), + QApplication::activeModalWidget(), tr("Delete profile-specific save games?"), + tr("Do you want to delete the profile-specific save games? (If you select \"No\", the " + "save games will show up again if you re-enable profile-specific save games)"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Cancel); if (res == QMessageBox::Yes) { @@ -796,7 +796,7 @@ bool Profile::enableLocalSettings(bool enable) } else { QMessageBox::StandardButton res = QMessageBox::question( QApplication::activeModalWidget(), tr("Delete profile-specific game INI files?"), - tr("Do you want to delete profile-specific game INI files? (If you select \"No\", the " + tr("Do you want to delete the profile-specific game INI files? (If you select \"No\", the " "save games will be used again if you re-enable profile-specific game INI files.)"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Cancel); diff --git a/src/profilesdialog.cpp b/src/profilesdialog.cpp index ed54f33c..17844357 100644 --- a/src/profilesdialog.cpp +++ b/src/profilesdialog.cpp @@ -191,7 +191,7 @@ void ProfilesDialog::on_removeProfileButton_clicked() return; } - QMessageBox confirmBox(QMessageBox::Question, tr("Confirm"), tr("Are you sure you want to remove this profile (including local savegames if any)?"), + QMessageBox confirmBox(QMessageBox::Question, tr("Confirm"), tr("Are you sure you want to remove this profile (including profile-specific save games, if any)?"), QMessageBox::Yes | QMessageBox::No, this); if (confirmBox.exec() == QMessageBox::Yes) { diff --git a/src/profilesdialog.ui b/src/profilesdialog.ui index d33e2283..f040faed 100644 --- a/src/profilesdialog.ui +++ b/src/profilesdialog.ui @@ -35,13 +35,13 @@ p, li { white-space: pre-wrap; } - <html><head/><body><p>If checked, savegames are stored locally to this profile and will not appear when starting with a different profile.</p></body></html> + <html><head/><body><p>If checked, save games are stored locally to this profile and will not appear when starting with a different profile.</p></body></html> - If checked, savegames are local to this profile and will not appear when starting with a different profile. + If checked, save games are local to this profile and will not appear when starting with a different profile. - Use profile-specific Savegames + Use profile-specific Save Games diff --git a/src/transfersavesdialog.ui b/src/transfersavesdialog.ui index 1fcad54d..8bc23088 100644 --- a/src/transfersavesdialog.ui +++ b/src/transfersavesdialog.ui @@ -11,7 +11,7 @@ - Transfer Savegames + Transfer Save Games -- cgit v1.3.1 From 5e530becc2724731653e4e94473fe674f13da129 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Wed, 19 Dec 2018 12:56:11 -0600 Subject: Don't mention save games when dealing with INI files --- src/profile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/profile.cpp') diff --git a/src/profile.cpp b/src/profile.cpp index 9b93539d..8eb1c49a 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -797,7 +797,7 @@ bool Profile::enableLocalSettings(bool enable) QMessageBox::StandardButton res = QMessageBox::question( QApplication::activeModalWidget(), tr("Delete profile-specific game INI files?"), tr("Do you want to delete the profile-specific game INI files? (If you select \"No\", the " - "save games will be used again if you re-enable profile-specific game INI files.)"), + "INI files will be used again if you re-enable profile-specific game INI files.)"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Cancel); if (res == QMessageBox::Yes) { -- cgit v1.3.1 From ce02da497a1d18228bd3c31924212a5a432f1ab7 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Mon, 24 Dec 2018 00:59:54 -0600 Subject: Prevent missing INI dialog from popping up when creating a new instance with archive invalidation --- src/profile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/profile.cpp') diff --git a/src/profile.cpp b/src/profile.cpp index 8eb1c49a..d65ea255 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -85,7 +85,6 @@ Profile::Profile(const QString &name, IPluginGame const *gamePlugin, bool useDef m_Directory = QDir(fullPath); m_Settings = new QSettings(m_Directory.absoluteFilePath("settings.ini"), QSettings::IniFormat); - findProfileSettings(); try { // create files. Needs to happen after m_Directory was set! @@ -101,6 +100,7 @@ Profile::Profile(const QString &name, IPluginGame const *gamePlugin, bool useDef } gamePlugin->initializeProfile(fullPath, settings); + findProfileSettings(); } catch (...) { // clean up in case of an error shellDelete(QStringList(profileBase.absoluteFilePath(fixedName))); -- cgit v1.3.1 From a3110731ca275b857eb264d69996264be5e404f5 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Wed, 26 Dec 2018 16:18:52 -0600 Subject: Use WriteRegistryValue function to handle read-only files --- src/profile.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/profile.cpp') diff --git a/src/profile.cpp b/src/profile.cpp index d65ea255..d1741311 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -29,6 +29,8 @@ along with Mod Organizer. If not, see . #include #include #include +#include "util.h" +#include "registry.h" #include #include // for QFile @@ -279,7 +281,7 @@ void Profile::createTweakedIniFile() mergeTweak(getProfileTweaks(), tweakedIni); bool error = false; - if (!::WritePrivateProfileStringW(L"Archive", L"bInvalidateOlderFiles", L"1", ToWString(tweakedIni).c_str())) { + if (!MOBase::WriteRegistryValue(L"Archive", L"bInvalidateOlderFiles", L"1", ToWString(tweakedIni).c_str())) { error = true; } @@ -681,7 +683,7 @@ void Profile::mergeTweak(const QString &tweakName, const QString &tweakedIni) co //TODO this treats everything as strings but how could I differentiate the type? ::GetPrivateProfileStringW(iter->c_str(), keyIter->c_str(), nullptr, buffer.data(), bufferSize, ToWString(tweakName).c_str()); - ::WritePrivateProfileStringW(iter->c_str(), keyIter->c_str(), + MOBase::WriteRegistryValue(iter->c_str(), keyIter->c_str(), buffer.data(), tweakedIniW.c_str()); } } -- cgit v1.3.1