Merge pull request #31 from ModOrganizer2/write_thread

Thread BSA writing
This commit is contained in:
Jeremy Rimpo
2023-10-17 02:03:04 -05:00
committed by GitHub
3 changed files with 27 additions and 8 deletions
+25 -6
View File
@@ -1,15 +1,34 @@
#include <bsapacker/ArchiveAutoService.h>
#include <QProgressDialog>
#include <QtConcurrent>
#include <QLabel>
namespace BsaPacker
{
bool ArchiveAutoService::CreateBSA(libbsarch::bs_archive_auto* archive, const QString& archiveName, const bsa_archive_type_e type) const
{
try {
archive->save_to_disk(archiveName.toStdString());
QProgressDialog savingDialog;
savingDialog.setWindowFlags(savingDialog.windowFlags() & ~Qt::WindowCloseButtonHint);
savingDialog.setWindowTitle(QObject::tr("Writing Archive"));
savingDialog.setCancelButton(0);
QLabel text;
text.setText(QObject::tr("Writing %1").arg(archiveName));
savingDialog.setLabel(&text);
savingDialog.setRange(0, 0);
savingDialog.show();
auto future = QtConcurrent::run([=]() -> bool {
try {
archive->save_to_disk(archiveName.toStdString());
} catch (std::exception e) {
return false;
}
return true;
});
while (!future.isFinished())
{
QCoreApplication::processEvents();
}
catch (std::exception e) {
return false;
}
return true;
savingDialog.hide();
return future.result();
}
} // namespace BsaPacker
+1 -1
View File
@@ -18,7 +18,7 @@ namespace BsaPacker
{
return false;
}
const std::string& absoluteFileName = fileNameNoExtension.toStdString() + ".esp";
const std::string& absoluteFileName = fileNameNoExtension.toStdString() + ".esl";
return this->m_FileWriterService->Write(absoluteFileName,
reinterpret_cast<const char*>(StarfieldDummyPluginService::RAW_STARFIELD),
sizeof(StarfieldDummyPluginService::RAW_STARFIELD));
+1 -1
View File
@@ -18,7 +18,7 @@ namespace BsaPacker
const QString& archiveNameBase) const override;
static constexpr unsigned char RAW_STARFIELD[] = {
0x54, 0x45, 0x53, 0x34, 0x19, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
0x54, 0x45, 0x53, 0x34, 0x19, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2B, 0x02, 0x00, 0x00,
0x48, 0x45, 0x44, 0x52, 0x0C, 0x00, 0x8F, 0xC2, 0x75, 0x3F, 0x00, 0x00,
0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x43, 0x4E, 0x41, 0x4D, 0x01, 0x00,