summaryrefslogtreecommitdiff
path: root/src/modinfo.cpp
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2015-01-03 15:58:52 +0100
committerTannin <devnull@localhost>2015-01-03 15:58:52 +0100
commita16e25380f088dc310fbed24d2dcef603357e99a (patch)
tree40fc3b5254f2797eb20bfac1d54a22652d469fa2 /src/modinfo.cpp
parent459816ab71ae6b350847cc93f1e03e49ecf75ade (diff)
parentf2f9e11fdd876821107cff0c1c5b9d8ecf66691f (diff)
Merge with branch1.2
Diffstat (limited to 'src/modinfo.cpp')
-rw-r--r--src/modinfo.cpp125
1 files changed, 77 insertions, 48 deletions
diff --git a/src/modinfo.cpp b/src/modinfo.cpp
index c06a50d6..af7cbaa5 100644
--- a/src/modinfo.cpp
+++ b/src/modinfo.cpp
@@ -72,7 +72,6 @@ ModInfo::Ptr ModInfo::createFrom(const QDir &dir, DirectoryEntry **directoryStru
return result;
}
-
ModInfo::Ptr ModInfo::createFromPlugin(const QString &espName, const QStringList &bsaNames
, DirectoryEntry ** directoryStructure)
{
@@ -82,6 +81,22 @@ ModInfo::Ptr ModInfo::createFromPlugin(const QString &espName, const QStringList
return result;
}
+QString ModInfo::getContentTypeName(int contentType)
+{
+ switch (contentType) {
+ case CONTENT_PLUGIN: return tr("Plugins");
+ case CONTENT_TEXTURE: return tr("Textures");
+ case CONTENT_MESH: return tr("Meshes");
+ case CONTENT_INTERFACE: return tr("UI Changes");
+ case CONTENT_MUSIC: return tr("Music");
+ case CONTENT_SOUND: return tr("Sound Effects");
+ case CONTENT_SCRIPT: return tr("Scripts");
+ case CONTENT_SKSE: return tr("SKSE Plugins");
+ case CONTENT_SKYPROC: return tr("SkyProc Tools");
+ case CONTENT_STRING: return tr("Strings");
+ default: throw MyException(tr("invalid content type %1").arg(contentType));
+ }
+}
void ModInfo::createFromOverwrite()
{
@@ -90,7 +105,6 @@ void ModInfo::createFromOverwrite()
s_Collection.push_back(ModInfo::Ptr(new ModInfoOverwrite));
}
-
unsigned int ModInfo::getNumMods()
{
QMutexLocker locker(&s_Mutex);
@@ -232,7 +246,7 @@ void ModInfo::updateIndices()
QRegExp backupRegEx(".*backup[0-9]*$");
for (unsigned int i = 0; i < s_Collection.size(); ++i) {
- QString modName = s_Collection[i]->name();
+ QString modName = s_Collection[i]->internalName();
int modID = s_Collection[i]->getNexusID();
s_ModsByName[modName] = i;
s_ModsByModID[modID].push_back(i);
@@ -288,6 +302,11 @@ bool ModInfo::hasFlag(ModInfo::EFlag flag) const
return std::find(flags.begin(), flags.end(), flag) != flags.end();
}
+bool ModInfo::hasContent(ModInfo::EContent content) const
+{
+ std::vector<EContent> contents = getContents();
+ return std::find(contents.begin(), contents.end(), content) != contents.end();
+}
bool ModInfo::categorySet(int categoryID) const
{
@@ -359,62 +378,72 @@ std::vector<ModInfo::EFlag> ModInfoWithConflictInfo::getFlags() const
}
-ModInfoWithConflictInfo::EConflictType ModInfoWithConflictInfo::isConflicted() const
+void ModInfoWithConflictInfo::doConflictCheck() const
{
- // this is costy so cache the result
- QTime now = QTime::currentTime();
- if (m_LastConflictCheck.isNull() || (m_LastConflictCheck.secsTo(now) > 10)) {
- bool overwrite = false;
- bool overwritten = false;
- bool regular = false;
+ m_OverwriteList.clear();
+ m_OverwrittenList.clear();
+ bool regular = false;
- int dataID = 0;
- if ((*m_DirectoryStructure)->originExists(L"data")) {
- dataID = (*m_DirectoryStructure)->getOriginByName(L"data").getID();
- }
+ int dataID = 0;
+ if ((*m_DirectoryStructure)->originExists(L"data")) {
+ dataID = (*m_DirectoryStructure)->getOriginByName(L"data").getID();
+ }
- std::wstring name = ToWString(this->name());
- if ((*m_DirectoryStructure)->originExists(name)) {
- FilesOrigin &origin = (*m_DirectoryStructure)->getOriginByName(name);
- std::vector<FileEntry::Ptr> files = origin.getFiles();
- for (auto iter = files.begin(); iter != files.end() && (!overwrite || !overwritten || !regular); ++iter) {
- const std::vector<int> &alternatives = (*iter)->getAlternatives();
- if (alternatives.size() == 0) {
- // no alternatives -> no conflict
- regular = true;
- } else {
- for (auto altIter = alternatives.begin(); altIter != alternatives.end(); ++altIter) {
- // don't treat files overwritten in data as "conflict"
- if (*altIter != dataID) {
- bool ignore = false;
- if ((*iter)->getOrigin(ignore) == origin.getID()) {
- overwrite = true;
- break;
- } else {
- overwritten = true;
- break;
- }
- } else if (alternatives.size() == 1) {
- // only alternative is data -> no conflict
- regular = true;
+ std::wstring name = ToWString(this->name());
+ if ((*m_DirectoryStructure)->originExists(name)) {
+ FilesOrigin &origin = (*m_DirectoryStructure)->getOriginByName(name);
+ std::vector<FileEntry::Ptr> files = origin.getFiles();
+ // for all files in this origin
+ for (auto iter = files.begin(); iter != files.end(); ++iter) {
+ const std::vector<int> &alternatives = (*iter)->getAlternatives();
+ if ((alternatives.size() == 0)
+ || (alternatives[0] == dataID)) {
+ // no alternatives -> no conflict
+ regular = true;
+ } else {
+ if ((*iter)->getOrigin() != origin.getID()) {
+ FilesOrigin &altOrigin = (*m_DirectoryStructure)->getOriginByID((*iter)->getOrigin());
+ unsigned int altIndex = ModInfo::getIndex(ToQString(altOrigin.getName()));
+ m_OverwrittenList.insert(altIndex);
+ }
+ // for all non-providing alternative origins
+ for (auto altIter = alternatives.begin(); altIter != alternatives.end(); ++altIter) {
+ if ((*altIter != dataID) && (*altIter != origin.getID())) {
+ FilesOrigin &altOrigin = (*m_DirectoryStructure)->getOriginByID(*altIter);
+ unsigned int altIndex = ModInfo::getIndex(ToQString(altOrigin.getName()));
+ if (origin.getPriority() > altOrigin.getPriority()) {
+ m_OverwriteList.insert(altIndex);
+ } else {
+ m_OverwrittenList.insert(altIndex);
}
}
}
}
}
+ }
- m_LastConflictCheck = QTime::currentTime();
+ m_LastConflictCheck = QTime::currentTime();
- if (overwrite && overwritten) m_CurrentConflictState = CONFLICT_MIXED;
- else if (overwrite) m_CurrentConflictState = CONFLICT_OVERWRITE;
- else if (overwritten) {
- if (!regular) {
- m_CurrentConflictState = CONFLICT_REDUNDANT;
- } else {
- m_CurrentConflictState = CONFLICT_OVERWRITTEN;
- }
+ if (!m_OverwriteList.empty() && !m_OverwrittenList.empty())
+ m_CurrentConflictState = CONFLICT_MIXED;
+ else if (!m_OverwriteList.empty())
+ m_CurrentConflictState = CONFLICT_OVERWRITE;
+ else if (!m_OverwrittenList.empty()) {
+ if (!regular) {
+ m_CurrentConflictState = CONFLICT_REDUNDANT;
+ } else {
+ m_CurrentConflictState = CONFLICT_OVERWRITTEN;
}
- else m_CurrentConflictState = CONFLICT_NONE;
+ }
+ else m_CurrentConflictState = CONFLICT_NONE;
+}
+
+ModInfoWithConflictInfo::EConflictType ModInfoWithConflictInfo::isConflicted() const
+{
+ // this is costy so cache the result
+ QTime now = QTime::currentTime();
+ if (m_LastConflictCheck.isNull() || (m_LastConflictCheck.secsTo(now) > 10)) {
+ doConflictCheck();
}
return m_CurrentConflictState;