mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-14 06:40:40 +00:00
Merge branch 'loosey-goosey' into 'master'
Store original representation of paths in content lists. Also compare against existing content lists in a more forgiving way. See merge request OpenMW/openmw!4424
This commit is contained in:
commit
7bbb1bf05d
@ -301,7 +301,7 @@ void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName)
|
|||||||
[&](const Config::SettingValue& dir) { return mGameSettings.isUserSetting(dir); }),
|
[&](const Config::SettingValue& dir) { return mGameSettings.isUserSetting(dir); }),
|
||||||
directories.end());
|
directories.end());
|
||||||
for (const auto& dir : contentModelDirectories)
|
for (const auto& dir : contentModelDirectories)
|
||||||
directories.push_back({ dir });
|
directories.push_back(mGameSettings.processPathSettingValue({ dir }));
|
||||||
}
|
}
|
||||||
|
|
||||||
mDataLocal = mGameSettings.getDataLocal();
|
mDataLocal = mGameSettings.getDataLocal();
|
||||||
|
@ -178,9 +178,7 @@ bool Config::GameSettings::readFile(
|
|||||||
value.originalRepresentation = value.value;
|
value.originalRepresentation = value.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::filesystem::path path = Files::pathFromQString(value.value);
|
value = processPathSettingValue(value);
|
||||||
mCfgMgr.processPath(path, Files::pathFromQString(context));
|
|
||||||
value.value = Files::pathToQString(path);
|
|
||||||
}
|
}
|
||||||
if (ignoreContent && (key == QLatin1String("content") || key == QLatin1String("data")))
|
if (ignoreContent && (key == QLatin1String("content") || key == QLatin1String("data")))
|
||||||
continue;
|
continue;
|
||||||
@ -588,6 +586,14 @@ bool Config::GameSettings::isUserSetting(const SettingValue& settingValue) const
|
|||||||
return settingValue.context.isEmpty() || settingValue.context == getUserContext();
|
return settingValue.context.isEmpty() || settingValue.context == getUserContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Config::SettingValue Config::GameSettings::processPathSettingValue(const SettingValue& value)
|
||||||
|
{
|
||||||
|
std::filesystem::path path = Files::pathFromQString(value.value);
|
||||||
|
std::filesystem::path basePath = Files::pathFromQString(value.context.isEmpty() ? getUserContext() : value.context);
|
||||||
|
mCfgMgr.processPath(path, basePath);
|
||||||
|
return SettingValue{ Files::pathToQString(path), value.originalRepresentation, value.context };
|
||||||
|
}
|
||||||
|
|
||||||
void Config::GameSettings::clear()
|
void Config::GameSettings::clear()
|
||||||
{
|
{
|
||||||
mSettings.clear();
|
mSettings.clear();
|
||||||
|
@ -118,6 +118,8 @@ namespace Config
|
|||||||
const QString& getUserContext() const { return mContexts.back(); }
|
const QString& getUserContext() const { return mContexts.back(); }
|
||||||
bool isUserSetting(const SettingValue& settingValue) const;
|
bool isUserSetting(const SettingValue& settingValue) const;
|
||||||
|
|
||||||
|
SettingValue processPathSettingValue(const SettingValue& value);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "launchersettings.hpp"
|
#include "launchersettings.hpp"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
#include <QMultiMap>
|
#include <QMultiMap>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@ -263,8 +264,16 @@ void Config::LauncherSettings::setContentList(const GameSettings& gameSettings)
|
|||||||
for (const QString& listName : getContentLists())
|
for (const QString& listName : getContentLists())
|
||||||
{
|
{
|
||||||
const auto& listDirs = getDataDirectoryList(listName);
|
const auto& listDirs = getDataDirectoryList(listName);
|
||||||
if (!std::ranges::equal(
|
#ifdef Q_OS_WINDOWS
|
||||||
dirs, listDirs, [](const SettingValue& dir, const QString& listDir) { return dir.value == listDir; }))
|
constexpr auto caseSensitivity = Qt::CaseInsensitive;
|
||||||
|
#else
|
||||||
|
constexpr auto caseSensitivity = Qt::CaseSensitive;
|
||||||
|
#endif
|
||||||
|
constexpr auto compareDataDirectories = [](const SettingValue& dir, const QString& listDir) {
|
||||||
|
return dir.originalRepresentation == listDir
|
||||||
|
|| QDir::cleanPath(dir.originalRepresentation).compare(QDir::cleanPath(listDir), caseSensitivity) == 0;
|
||||||
|
};
|
||||||
|
if (!std::ranges::equal(dirs, listDirs, compareDataDirectories))
|
||||||
continue;
|
continue;
|
||||||
constexpr auto compareFiles
|
constexpr auto compareFiles
|
||||||
= [](const QString& a, const QString& b) { return a.compare(b, Qt::CaseInsensitive) == 0; };
|
= [](const QString& a, const QString& b) { return a.compare(b, Qt::CaseInsensitive) == 0; };
|
||||||
@ -281,7 +290,7 @@ void Config::LauncherSettings::setContentList(const GameSettings& gameSettings)
|
|||||||
setCurrentContentListName(newContentListName);
|
setCurrentContentListName(newContentListName);
|
||||||
QStringList newListDirs;
|
QStringList newListDirs;
|
||||||
for (const auto& dir : dirs)
|
for (const auto& dir : dirs)
|
||||||
newListDirs.push_back(dir.value);
|
newListDirs.push_back(dir.originalRepresentation);
|
||||||
setContentList(newContentListName, newListDirs, archives, files);
|
setContentList(newContentListName, newListDirs, archives, files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user