2017-10-09 08:35:48 +02:00
|
|
|
/*****************************************************************************
|
2018-05-24 22:32:00 +02:00
|
|
|
* gta5view Grand Theft Auto V Profile Viewer
|
2017-10-09 08:35:48 +02:00
|
|
|
* Copyright (C) 2016-2017 Syping
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include "ProfileLoader.h"
|
|
|
|
#include "SnapmaticPicture.h"
|
|
|
|
#include "SavegameData.h"
|
|
|
|
#include "CrewDatabase.h"
|
|
|
|
#include <QStringBuilder>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QString>
|
2017-10-12 22:21:45 +02:00
|
|
|
#include <QThread>
|
|
|
|
#include <QList>
|
2017-10-09 08:35:48 +02:00
|
|
|
#include <QFile>
|
|
|
|
#include <QDir>
|
|
|
|
|
|
|
|
ProfileLoader::ProfileLoader(QString profileFolder, CrewDatabase *crewDB, QObject *parent) : QThread(parent), profileFolder(profileFolder), crewDB(crewDB)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProfileLoader::run()
|
|
|
|
{
|
|
|
|
int curFile = 1;
|
|
|
|
QDir profileDir;
|
|
|
|
QList<int> crewList;
|
|
|
|
profileDir.setPath(profileFolder);
|
|
|
|
|
|
|
|
// Seek pictures and savegames
|
2020-11-05 18:32:20 +01:00
|
|
|
profileDir.setNameFilters(QStringList("SGTA5*"));
|
2017-10-09 08:35:48 +02:00
|
|
|
QStringList SavegameFiles = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort);
|
|
|
|
QStringList BackupFiles = SavegameFiles.filter(".bak", Qt::CaseInsensitive);
|
2020-11-05 18:32:20 +01:00
|
|
|
profileDir.setNameFilters(QStringList("PGTA5*"));
|
2017-10-09 08:35:48 +02:00
|
|
|
QStringList SnapmaticPics = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort);
|
|
|
|
BackupFiles += SnapmaticPics.filter(".bak", Qt::CaseInsensitive);
|
|
|
|
|
|
|
|
SavegameFiles.removeDuplicates();
|
|
|
|
SnapmaticPics.removeDuplicates();
|
2017-10-21 05:59:10 +02:00
|
|
|
for (QString BackupFile : BackupFiles)
|
2017-10-09 08:35:48 +02:00
|
|
|
{
|
|
|
|
SavegameFiles.removeAll(BackupFile);
|
|
|
|
SnapmaticPics.removeAll(BackupFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
int maximumV = SavegameFiles.length() + SnapmaticPics.length();
|
|
|
|
|
|
|
|
// Loading pictures and savegames
|
|
|
|
emit loadingProgress(curFile, maximumV);
|
2017-10-21 05:59:10 +02:00
|
|
|
for (QString SavegameFile : SavegameFiles)
|
2017-10-09 08:35:48 +02:00
|
|
|
{
|
|
|
|
emit loadingProgress(curFile, maximumV);
|
2017-10-12 22:21:45 +02:00
|
|
|
QString sgdPath = profileFolder % "/" % SavegameFile;
|
2017-10-09 08:35:48 +02:00
|
|
|
SavegameData *savegame = new SavegameData(sgdPath);
|
|
|
|
if (savegame->readingSavegame())
|
|
|
|
{
|
|
|
|
emit savegameLoaded(savegame, sgdPath);
|
|
|
|
}
|
|
|
|
curFile++;
|
|
|
|
}
|
2017-10-21 05:59:10 +02:00
|
|
|
for (QString SnapmaticPic : SnapmaticPics)
|
2017-10-09 08:35:48 +02:00
|
|
|
{
|
|
|
|
emit loadingProgress(curFile, maximumV);
|
2017-10-12 22:21:45 +02:00
|
|
|
QString picturePath = profileFolder % "/" % SnapmaticPic;
|
2017-10-09 08:35:48 +02:00
|
|
|
SnapmaticPicture *picture = new SnapmaticPicture(picturePath);
|
2020-11-09 01:42:11 +01:00
|
|
|
if (picture->readingPicture(true))
|
2017-10-09 08:35:48 +02:00
|
|
|
{
|
2017-11-22 20:23:36 +01:00
|
|
|
if (picture->isFormatSwitched())
|
|
|
|
{
|
|
|
|
picture->setSnapmaticFormat(SnapmaticFormat::PGTA_Format);
|
|
|
|
if (picture->exportPicture(picturePath, SnapmaticFormat::PGTA_Format))
|
|
|
|
{
|
|
|
|
emit pictureFixed(picture);
|
|
|
|
}
|
|
|
|
}
|
2017-10-09 08:35:48 +02:00
|
|
|
emit pictureLoaded(picture);
|
|
|
|
int crewNumber = picture->getSnapmaticProperties().crewID;
|
|
|
|
if (!crewList.contains(crewNumber))
|
|
|
|
{
|
|
|
|
crewList += crewNumber;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
curFile++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// adding found crews
|
|
|
|
crewDB->setAddingCrews(true);
|
2017-10-21 05:59:10 +02:00
|
|
|
for (int crewID : crewList)
|
2017-10-09 08:35:48 +02:00
|
|
|
{
|
|
|
|
crewDB->addCrew(crewID);
|
|
|
|
}
|
|
|
|
crewDB->setAddingCrews(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProfileLoader::preloaded()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProfileLoader::loaded()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|