-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsbsarloader.cpp
50 lines (41 loc) · 1.35 KB
/
sbsarloader.cpp
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
#include "sbsarloader.h"
#include <QFile>
#include <QProcess>
#include "logger.h"
#include "substancemanagerapp.h"
SBSARLoader::SBSARLoader(QString fileName)
{
gfLog(fileName);
QProcess p;
p.start(SubstanceManagerApp::sbs7zExe, QStringList() << "l" << fileName << "-slt" );
p.waitForFinished();
QString output = p.readAll();
//gfInfo(output);
// We need to parse all the graphs in the SBSAR and create Template Presets from them
QStringList lines = output.split("\r\n");
QStringList files;
for(auto line: lines)
if(line.startsWith("Path = ") && line.endsWith(".xml"))
files.append(line.mid(7));
for(auto file: files)
{
p.start(SubstanceManagerApp::sbs7zExe, QStringList() << "e" << fileName << file << "-so");
p.waitForFinished();
QString xml = p.readAll();
QString rpath = SubstanceManagerApp::instance->ConvertToRelativePath(fileName);
auto items = SBSPreset::TemplatePresetsFromSBSARMeta(xml);
for(auto preset: items)
{
preset->relativeSBSARPath = rpath;
m_presets.push_back(preset);
}
if(items.size() == 0)
{
gfError(QString("Failed to load graphs XML Meta file %1 from %2").arg(file).arg(fileName));
}
}
}
QList<SBSPreset *> SBSARLoader::GetPresets()
{
return m_presets;
}