blob: 3a7c6aa9ffeaec22e1e2b397b54fba14da583810 (
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
#ifndef MODORGANIZER_LOOT_H
#define MODORGANIZER_LOOT_H
#include "envmodule.h"
#include <log.h>
#include <lootcli/lootcli.h>
#include <windows.h>
#include <QWidget>
Q_DECLARE_METATYPE(lootcli::Progress);
Q_DECLARE_METATYPE(MOBase::log::Levels);
class OrganizerCore;
class Loot : public QObject
{
Q_OBJECT;
public:
struct Message
{
MOBase::log::Levels type;
QString text;
};
struct File
{
QString name;
QString displayName;
};
struct Dirty
{
qint64 crc=0;
qint64 itm=0;
qint64 deletedReferences=0;
qint64 deletedNavmesh=0;
QString cleaningUtility;
QString info;
QString toString(bool isClean) const;
QString cleaningString() const;
};
struct Plugin
{
QString name;
std::vector<File> incompatibilities;
std::vector<Message> messages;
std::vector<Dirty> dirty, clean;
std::vector<QString> missingMasters;
bool loadsArchive = false;
bool isMaster = false;
bool isLightMaster = false;
};
struct Stats
{
qint64 time = 0;
QString version;
};
struct Report
{
std::vector<Message> messages;
std::vector<Plugin> plugins;
Stats stats;
};
Loot();
~Loot();
bool start(QWidget* parent, OrganizerCore& core, bool didUpdateMasterList);
void cancel();
bool result() const;
const QString& outPath() const;
const Report& report() const;
signals:
void output(const QString& s);
void progress(const lootcli::Progress p);
void log(MOBase::log::Levels level, const QString& s);
void finished();
private:
std::unique_ptr<QThread> m_thread;
std::atomic<bool> m_cancel;
std::atomic<bool> m_result;
QString m_outPath;
env::HandlePtr m_lootProcess;
env::HandlePtr m_stdout;
std::string m_outputBuffer;
Report m_report;
std::string readFromPipe();
void lootThread();
bool waitForCompletion();
void processStdout(const std::string &lootOut);
void processMessage(const lootcli::Message& m);
void processOutputFile();
Report createReport(const QJsonDocument& doc) const;
Message reportMessage(const QJsonObject& message) const;
std::vector<Plugin> reportPlugins(const QJsonArray& plugins) const;
Loot::Plugin reportPlugin(const QJsonObject& plugin) const;
std::vector<Message> reportMessages(const QJsonArray& array) const;
std::vector<Loot::File> reportFiles(const QJsonArray& array) const;
std::vector<Loot::Dirty> reportDirty(const QJsonArray& array) const;
std::vector<QString> reportStringArray(const QJsonArray& array) const;
};
bool runLoot(QWidget* parent, OrganizerCore& core, bool didUpdateMasterList);
#endif // MODORGANIZER_LOOT_H
|