blob: 6d1289af9243bf3a31b370f7c38e6caf03cb1d5c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
#include "gamebryosavegameinfo.h"
#include "gamebryosavegame.h"
#include "gamebryosavegameinfowidget.h"
#include "gamegamebryo.h"
#include "imodinterface.h"
#include "imoinfo.h"
#include "iplugingame.h"
#include "ipluginlist.h"
#include <QDir>
#include <QString>
#include <QStringList>
GamebryoSaveGameInfo::GamebryoSaveGameInfo(GameGamebryo const* game) : m_Game(game) {}
GamebryoSaveGameInfo::~GamebryoSaveGameInfo() {}
GamebryoSaveGameInfo::MissingAssets
GamebryoSaveGameInfo::getMissingAssets(MOBase::ISaveGame const& save) const
{
GamebryoSaveGame const& gamebryoSave = dynamic_cast<GamebryoSaveGame const&>(save);
MOBase::IOrganizer* organizerCore = m_Game->m_Organizer;
// collect the list of missing plugins
MissingAssets missingAssets;
for (QString const& pluginName : gamebryoSave.getPlugins()) {
switch (organizerCore->pluginList()->state(pluginName)) {
case MOBase::IPluginList::STATE_INACTIVE:
missingAssets[pluginName] =
ProvidingModules{organizerCore->pluginList()->origin(pluginName)};
break;
case MOBase::IPluginList::STATE_MISSING:
missingAssets[pluginName] = ProvidingModules();
break;
}
}
for (QString const& pluginName : gamebryoSave.getLightPlugins()) {
switch (organizerCore->pluginList()->state(pluginName)) {
case MOBase::IPluginList::STATE_INACTIVE:
missingAssets[pluginName] =
ProvidingModules{organizerCore->pluginList()->origin(pluginName)};
break;
case MOBase::IPluginList::STATE_MISSING:
missingAssets[pluginName] = ProvidingModules();
break;
}
}
// Find out any other mods that might contain the esp/esm
QStringList espFilter({"*.esp", "*.esl", "*.esm"});
QString dataDir(organizerCore->managedGame()->dataDirectory().absolutePath());
// Search normal mods. A note: This will also find mods in data.
for (QString const& mod : organizerCore->modList()->allModsByProfilePriority()) {
MOBase::IModInterface* modInfo = organizerCore->modList()->getMod(mod);
QStringList esps = QDir(modInfo->absolutePath()).entryList(espFilter);
for (QString const& esp : esps) {
MissingAssets::iterator iter = missingAssets.find(esp);
if (modInfo->absolutePath() == dataDir) {
// We have to prune esps that reside in the data directory, otherwise
// you get all the unmanaged mods listed as potential candidates for
// enabling
if (modInfo->name() != organizerCore->pluginList()->origin(esp)) {
continue;
}
}
if (iter != missingAssets.end()) {
if (!iter->contains(modInfo->name())) {
iter->push_back(modInfo->name());
}
}
}
}
// search in overwrite
{
QDir overwriteDir(organizerCore->overwritePath());
QStringList esps = overwriteDir.entryList(espFilter);
for (const QString& esp : esps) {
MissingAssets::iterator iter = missingAssets.find(esp);
if (iter != missingAssets.end()) {
if (!iter->contains("<overwrite>")) {
iter->push_back("<overwrite>");
}
}
}
}
return missingAssets;
}
MOBase::ISaveGameInfoWidget*
GamebryoSaveGameInfo::getSaveGameWidget(QWidget* parent) const
{
return new GamebryoSaveGameInfoWidget(this, parent);
}
|