blob: 8f88c045b729397b0b9e76cf95cdd9307c81767e (
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
#ifndef MODORGANIZER_LOOT_H
#define MODORGANIZER_LOOT_H
#include "envmodule.h"
#include <QWidget>
#include <log.h>
#include <lootcli/lootcli.h>
#include <windows.h>
Q_DECLARE_METATYPE(lootcli::Progress);
Q_DECLARE_METATYPE(MOBase::log::Levels);
class OrganizerCore;
class AsyncPipe;
class Loot : public QObject
{
Q_OBJECT;
public:
struct Message
{
MOBase::log::Levels type;
QString text;
QString toMarkdown() const;
};
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 toMarkdown(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;
QString toMarkdown() const;
};
struct Stats
{
qint64 time = 0;
QString lootcliVersion;
QString lootVersion;
QString toMarkdown() const;
};
struct Report
{
bool okay = false;
std::vector<QString> errors, warnings;
std::vector<Message> messages;
std::vector<Plugin> plugins;
Stats stats;
QString toMarkdown() const;
private:
QString successMarkdown() const;
QString errorsMarkdown() const;
};
Loot(OrganizerCore& core);
~Loot();
bool start(QWidget* parent, bool didUpdateMasterList);
void cancel();
bool result() const;
const QString& reportPath() const;
const QString& sortedPluginListPath() const;
const Report& report() const;
const QString getSortedPluginListMarkdown() const;
const std::vector<QString>& errors() const;
const std::vector<QString>& warnings() const;
signals:
void output(const QString& s);
void progress(const lootcli::Progress p);
void log(MOBase::log::Levels level, const QString& s) const;
void finished();
private:
OrganizerCore& m_core;
std::unique_ptr<QThread> m_thread;
std::atomic<bool> m_cancel;
std::atomic<bool> m_result;
env::HandlePtr m_lootProcess;
std::unique_ptr<AsyncPipe> m_pipe;
std::string m_outputBuffer;
std::vector<QString> m_errors, m_warnings;
Report m_report;
bool spawnLootcli(QWidget* parent, bool didUpdateMasterList,
env::HandlePtr stdoutHandle);
void lootThread();
bool waitForCompletion();
void processStdout(const std::string& lootOut);
void processMessage(const lootcli::Message& m);
Report createReport() const;
void processReport(Report& r) const;
void deleteReportFile();
void deleteSortedLoadOrder();
Message reportMessage(const QJsonObject& message) const;
std::vector<Plugin> reportPlugins(const QJsonArray& plugins) const;
Loot::Plugin reportPlugin(const QJsonObject& plugin) const;
Loot::Stats reportStats(const QJsonObject& stats) 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
|