blob: 1ba8ed8c2ba1e8376d5fb20787133b39c4d011be (
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
|
#ifndef INSTALLERFOMOD_H
#define INSTALLERFOMOD_H
#include <uibase/iplugindiagnose.h>
#include <uibase/iplugininstallersimple.h>
#include <uibase/ipluginlist.h>
class InstallerFomod : public MOBase::IPluginInstallerSimple,
public MOBase::IPluginDiagnose
{
Q_OBJECT
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginInstaller MOBase::IPluginInstallerSimple
MOBase::IPluginDiagnose)
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
Q_PLUGIN_METADATA(IID "org.tannin.InstallerFomod")
#endif
public:
InstallerFomod();
virtual bool init(MOBase::IOrganizer* moInfo) override;
virtual QString name() const override;
virtual QString localizedName() const override;
virtual QString author() const override;
virtual QString description() const override;
virtual MOBase::VersionInfo version() const override;
virtual QList<MOBase::PluginSetting> settings() const override;
virtual unsigned int priority() const override;
virtual bool isManualInstaller() const override;
virtual bool
isArchiveSupported(std::shared_ptr<const MOBase::IFileTree> tree) const override;
virtual EInstallResult install(MOBase::GuessedValue<QString>& modName,
std::shared_ptr<MOBase::IFileTree>& tree,
QString& version, int& modID) override;
virtual void onInstallationStart(QString const& archive, bool reinstallation,
MOBase::IModInterface* currentMod) override;
virtual void onInstallationEnd(EInstallResult result,
MOBase::IModInterface* newMod) override;
public: // IPluginDiagnose interface
virtual std::vector<unsigned int> activeProblems() const;
virtual QString shortDescription(unsigned int key) const;
virtual QString fullDescription(unsigned int key) const;
virtual bool hasGuidedFix(unsigned int key) const;
virtual void startGuidedFix(unsigned int key) const;
private:
/**
* @brief Retrieve the tree entry corresponding to the fomod directory.
*
* @param tree Tree to look-up the directory in.
*
* @return the entry corresponding to the fomod directory in the tree, or a null
* pointer if the entry was not found.
*/
std::shared_ptr<const MOBase::IFileTree>
findFomodDirectory(std::shared_ptr<const MOBase::IFileTree> tree) const;
/**
* @brief Build a list of entries that should be extracted sincce the FOMOD installer
* may require access to (currently the .xml files in the FOMOD directory and the
* pictures in the archive).
*
* @param tree Base tree of the archive.
*
* @return a list of file entries that need to be extracted.
*/
std::vector<std::shared_ptr<const MOBase::FileTreeEntry>>
buildFomodTree(std::shared_ptr<const MOBase::IFileTree> tree) const;
/**
* @brief Recurse through the given tree and add all the images to the given vector.
*
* @param result Vector of entries to add the images.
* @param tree The tree to look files in.
*/
void
appendImageFiles(std::vector<std::shared_ptr<const MOBase::FileTreeEntry>>& entries,
std::shared_ptr<const MOBase::IFileTree> tree) const;
MOBase::IPluginList::PluginStates fileState(const QString& fileName) const;
private:
static const unsigned int PROBLEM_IMAGETYPE_UNSUPPORTED = 1;
private:
MOBase::IOrganizer* m_MOInfo;
bool allowAnyFile() const;
bool checkDisabledMods() const;
bool m_InstallerUsed;
QString m_Url;
};
#endif // INSTALLERFOMOD_H
|