mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-19 12:02:24 +02:00
make sonar cloud (a little bit) happy
This commit is contained in:
parent
9b3a5c7925
commit
e31ace2661
@ -100,7 +100,7 @@ bool ChroniclesExtractor::extractGogInstaller(QString file)
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
process_file(file.toStdString(), o, [this](float progress) {
|
process_file(file.toStdString(), o, [this](float progress) {
|
||||||
float overallProgress = ((1.0 / float(fileCount)) * float(extractionFile)) + (progress / float(fileCount));
|
float overallProgress = ((1.0 / static_cast<float>(fileCount)) * static_cast<float>(extractionFile)) + (progress / static_cast<float>(fileCount));
|
||||||
if(cb)
|
if(cb)
|
||||||
cb(overallProgress);
|
cb(overallProgress);
|
||||||
});
|
});
|
||||||
@ -133,7 +133,7 @@ bool ChroniclesExtractor::extractGogInstaller(QString file)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChroniclesExtractor::createBaseMod()
|
void ChroniclesExtractor::createBaseMod() const
|
||||||
{
|
{
|
||||||
QDir dir(pathToQString(VCMIDirs::get().userDataPath() / "Mods"));
|
QDir dir(pathToQString(VCMIDirs::get().userDataPath() / "Mods"));
|
||||||
dir.mkdir("chronicles");
|
dir.mkdir("chronicles");
|
||||||
@ -180,7 +180,7 @@ void ChroniclesExtractor::createChronicleMod(int no)
|
|||||||
extractFiles(no);
|
extractFiles(no);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChroniclesExtractor::extractFiles(int no)
|
void ChroniclesExtractor::extractFiles(int no) const
|
||||||
{
|
{
|
||||||
QByteArray tmpChronicles = chronicles.at(no);
|
QByteArray tmpChronicles = chronicles.at(no);
|
||||||
tmpChronicles.replace('\0', "");
|
tmpChronicles.replace('\0', "");
|
||||||
@ -202,14 +202,14 @@ void ChroniclesExtractor::extractFiles(int no)
|
|||||||
archive.extractToFolder(dest.absolutePath().toStdString(), "", entry.second, true);
|
archive.extractToFolder(dest.absolutePath().toStdString(), "", entry.second, true);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(auto & item : files)
|
for(const auto & item : files)
|
||||||
if(!boost::algorithm::to_lower_copy(entry.second.name).find(boost::algorithm::to_lower_copy(item)))
|
if(!boost::algorithm::to_lower_copy(entry.second.name).find(boost::algorithm::to_lower_copy(item)))
|
||||||
archive.extractToFolder(dest.absolutePath().toStdString(), "", entry.second, true);
|
archive.extractToFolder(dest.absolutePath().toStdString(), "", entry.second, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
auto rename = [no](QDir dest){
|
auto rename = [no](QDir dest){
|
||||||
dest.refresh();
|
dest.refresh();
|
||||||
for(auto & entry : dest.entryList())
|
for(const auto & entry : dest.entryList())
|
||||||
{
|
{
|
||||||
if(entry.toUpper().startsWith("HPS") || entry.toUpper().startsWith("HPL"))
|
if(entry.toUpper().startsWith("HPS") || entry.toUpper().startsWith("HPL"))
|
||||||
dest.rename(entry, "Hc_" + entry);
|
dest.rename(entry, "Hc_" + entry);
|
||||||
@ -229,7 +229,7 @@ void ChroniclesExtractor::extractFiles(int no)
|
|||||||
if(tmpDir.entryList({"maps"}, QDir::Filter::Dirs).size())
|
if(tmpDir.entryList({"maps"}, QDir::Filter::Dirs).size())
|
||||||
{
|
{
|
||||||
QDir tmpDirMaps = tmpDir.filePath(tmpDir.entryList({"maps"}, QDir::Filter::Dirs).front());
|
QDir tmpDirMaps = tmpDir.filePath(tmpDir.entryList({"maps"}, QDir::Filter::Dirs).front());
|
||||||
for(auto & entry : tmpDirMaps.entryList())
|
for(const auto & entry : tmpDirMaps.entryList())
|
||||||
QFile(tmpDirMaps.filePath(entry)).copy(outDirData.filePath(entry));
|
QFile(tmpDirMaps.filePath(entry)).copy(outDirData.filePath(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,9 +25,9 @@ class ChroniclesExtractor : public QObject
|
|||||||
bool handleTempDir(bool create);
|
bool handleTempDir(bool create);
|
||||||
int getChronicleNo(QFile & file);
|
int getChronicleNo(QFile & file);
|
||||||
bool extractGogInstaller(QString filePath);
|
bool extractGogInstaller(QString filePath);
|
||||||
void createBaseMod();
|
void createBaseMod() const;
|
||||||
void createChronicleMod(int no);
|
void createChronicleMod(int no);
|
||||||
void extractFiles(int no);
|
void extractFiles(int no) const;
|
||||||
|
|
||||||
const std::map<int, QByteArray> chronicles = {
|
const std::map<int, QByteArray> chronicles = {
|
||||||
{1, QByteArray{reinterpret_cast<const char*>(u"Warlords of the Wasteland"), 50}},
|
{1, QByteArray{reinterpret_cast<const char*>(u"Warlords of the Wasteland"), 50}},
|
||||||
|
@ -854,7 +854,7 @@ void CModListView::installFiles(QStringList files)
|
|||||||
|
|
||||||
while(futureExtract.wait_for(std::chrono::milliseconds(10)) != std::future_status::ready)
|
while(futureExtract.wait_for(std::chrono::milliseconds(10)) != std::future_status::ready)
|
||||||
{
|
{
|
||||||
emit extractionProgress(int(prog * 1000.f), 1000);
|
emit extractionProgress(static_cast<int>(prog * 1000.f), 1000);
|
||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,36 +481,36 @@ void Campaign::overrideCampaign(bool scenario)
|
|||||||
{
|
{
|
||||||
JsonNode node = JsonUtils::assembleFromFiles("config/campaignOverrides.json");
|
JsonNode node = JsonUtils::assembleFromFiles("config/campaignOverrides.json");
|
||||||
for (auto & entry : node.Struct())
|
for (auto & entry : node.Struct())
|
||||||
if(filename == entry.first)
|
if(filename == entry.first)
|
||||||
{
|
|
||||||
if(!scenario)
|
|
||||||
{
|
{
|
||||||
if(!entry.second["regions"].isNull() && !entry.second["scenarioCount"].isNull())
|
if(!scenario)
|
||||||
loadLegacyData(CampaignRegions::fromJson(entry.second["regions"]), entry.second["scenarioCount"].Integer());
|
|
||||||
if(!entry.second["loadingBackground"].isNull())
|
|
||||||
loadingBackground = ImagePath::builtin(entry.second["loadingBackground"].String());
|
|
||||||
if(!entry.second["introVideoRim"].isNull())
|
|
||||||
introVideoRim = ImagePath::builtin(entry.second["introVideoRim"].String());
|
|
||||||
if(!entry.second["introVideo"].isNull())
|
|
||||||
introVideo = VideoPath::builtin(entry.second["introVideo"].String());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(!entry.second["scenarios"].isNull())
|
|
||||||
{
|
{
|
||||||
auto sc = entry.second["scenarios"].Vector();
|
if(!entry.second["regions"].isNull() && !entry.second["scenarioCount"].isNull())
|
||||||
for(int i = 0; i < sc.size(); i++)
|
loadLegacyData(CampaignRegions::fromJson(entry.second["regions"]), entry.second["scenarioCount"].Integer());
|
||||||
|
if(!entry.second["loadingBackground"].isNull())
|
||||||
|
loadingBackground = ImagePath::builtin(entry.second["loadingBackground"].String());
|
||||||
|
if(!entry.second["introVideoRim"].isNull())
|
||||||
|
introVideoRim = ImagePath::builtin(entry.second["introVideoRim"].String());
|
||||||
|
if(!entry.second["introVideo"].isNull())
|
||||||
|
introVideo = VideoPath::builtin(entry.second["introVideo"].String());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!entry.second["scenarios"].isNull())
|
||||||
{
|
{
|
||||||
auto it = scenarios.begin();
|
auto sc = entry.second["scenarios"].Vector();
|
||||||
std::advance(it, i);
|
for(int i = 0; i < sc.size(); i++)
|
||||||
if(!sc.at(i)["voiceProlog"].isNull())
|
{
|
||||||
it->second.prolog.prologVoice = AudioPath::builtin(sc.at(i)["voiceProlog"].String());
|
auto it = scenarios.begin();
|
||||||
if(!sc.at(i)["voiceEpilog"].isNull())
|
std::advance(it, i);
|
||||||
it->second.epilog.prologVoice = AudioPath::builtin(sc.at(i)["voiceEpilog"].String());
|
if(!sc.at(i)["voiceProlog"].isNull())
|
||||||
|
it->second.prolog.prologVoice = AudioPath::builtin(sc.at(i)["voiceProlog"].String());
|
||||||
|
if(!sc.at(i)["voiceEpilog"].isNull())
|
||||||
|
it->second.epilog.prologVoice = AudioPath::builtin(sc.at(i)["voiceEpilog"].String());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Campaign::scenariosCount() const
|
int Campaign::scenariosCount() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user