mirror of
https://github.com/ModOrganizer2/modorganizer-bsa_extractor.git
synced 2026-07-27 14:05:04 -07:00
Move to VCPKG. (#18)
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
# Set the default behavior, in case people don't have core.autocrlf set.
|
||||
* text=auto
|
||||
|
||||
# Explicitly declare text files you want to always be normalized and converted
|
||||
# to native line endings on checkout.
|
||||
*.cpp text eol=crlf
|
||||
*.h text eol=crlf
|
||||
@@ -0,0 +1,20 @@
|
||||
name: Build BSA Extractor
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
env:
|
||||
VCPKG_BINARY_SOURCES: clear;x-azblob,${{ vars.AZ_BLOB_VCPKG_URL }},${{ secrets.AZ_BLOB_SAS }},readwrite
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- name: Build BSA Extractor
|
||||
id: build-bsa-extractor
|
||||
uses: ModOrganizer2/build-with-mob-action
|
||||
with:
|
||||
mo2-dependencies: uibase bsatk
|
||||
@@ -0,0 +1,20 @@
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v5.0.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-merge-conflict
|
||||
- id: check-case-conflict
|
||||
# - repo: https://github.com/pre-commit/mirrors-clang-format
|
||||
# rev: v19.1.5
|
||||
# hooks:
|
||||
# - id: clang-format
|
||||
# 'types_or': [c++, c]
|
||||
|
||||
ci:
|
||||
autofix_commit_msg: "[pre-commit.ci] Auto fixes from pre-commit.com hooks."
|
||||
autofix_prs: true
|
||||
autoupdate_commit_msg: "[pre-commit.ci] Pre-commit autoupdate."
|
||||
autoupdate_schedule: quarterly
|
||||
submodules: false
|
||||
+1
-6
@@ -1,10 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
if(DEFINED DEPENDENCIES_DIR)
|
||||
include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/mo2.cmake)
|
||||
else()
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../cmake_common/mo2.cmake)
|
||||
endif()
|
||||
|
||||
project(bsa_extractor)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"configurePresets": [
|
||||
{
|
||||
"errors": {
|
||||
"deprecated": true
|
||||
},
|
||||
"hidden": true,
|
||||
"name": "cmake-dev",
|
||||
"warnings": {
|
||||
"deprecated": true,
|
||||
"dev": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"cacheVariables": {
|
||||
"VCPKG_MANIFEST_NO_DEFAULT_FEATURES": {
|
||||
"type": "BOOL",
|
||||
"value": "ON"
|
||||
}
|
||||
},
|
||||
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
|
||||
"hidden": true,
|
||||
"name": "vcpkg"
|
||||
},
|
||||
{
|
||||
"binaryDir": "${sourceDir}/vsbuild",
|
||||
"architecture": {
|
||||
"strategy": "set",
|
||||
"value": "x64"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"CMAKE_CXX_FLAGS": "/EHsc /MP /W4",
|
||||
"VCPKG_TARGET_TRIPLET": {
|
||||
"type": "STRING",
|
||||
"value": "x64-windows-static-md"
|
||||
}
|
||||
},
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"inherits": ["cmake-dev", "vcpkg"],
|
||||
"name": "vs2022-windows",
|
||||
"toolset": "v143"
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "vs2022-windows",
|
||||
"resolvePackageReferences": "on",
|
||||
"configurePreset": "vs2022-windows"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
version: 1.0.{build}
|
||||
skip_branch_with_pr: true
|
||||
image: Visual Studio 2019
|
||||
environment:
|
||||
APPVEYOR:
|
||||
WEBHOOK_URL:
|
||||
secure: gOKbXaZM9ImtMD5XrYITvdyZUW/az082G9OIN1EC1Vbg57wBaeLhi49uGjxPw5GVujHku6kxN6ab89zhbS5GVeluR76GM83IbKV4Sh7udXzoYZZdg6YudtYHzdhCgUeiedpswbuczTq9ceIkkfSEWZuh/lMAAVVwvcGsJAnoPFw=
|
||||
build_script:
|
||||
- pwsh: >-
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
git clone --depth=1 --no-single-branch https://github.com/ModOrganizer2/modorganizer-umbrella.git c:\projects\modorganizer-umbrella
|
||||
|
||||
New-Item -ItemType Directory -Path c:\projects\modorganizer-build
|
||||
|
||||
cd c:\projects\modorganizer-umbrella
|
||||
|
||||
($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH -eq $null) ? ($branch = $env:APPVEYOR_REPO_BRANCH) : ($branch = $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH)
|
||||
|
||||
git checkout $(git show-ref --verify --quiet refs/remotes/origin/${branch} || echo '-b') ${branch}
|
||||
|
||||
C:\Python37-x64\python.exe unimake.py -d c:\projects\modorganizer-build -s Appveyor_Build=True ${env:APPVEYOR_PROJECT_NAME}
|
||||
|
||||
if($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode ) }
|
||||
artifacts:
|
||||
- path: vsbuild\src\RelWithDebInfo\bsa_extractor.dll
|
||||
name: bsa_extractor_dll
|
||||
- path: vsbuild\src\RelWithDebInfo\bsa_extractor.pdb
|
||||
name: bsa_extractor_pdb
|
||||
- path: vsbuild\src\RelWithDebInfo\bsa_extractor.lib
|
||||
name: bsa_extractor_lib
|
||||
on_success:
|
||||
- ps: Set-Location -Path $env:APPVEYOR_BUILD_FOLDER
|
||||
- ps: Invoke-RestMethod https://raw.githubusercontent.com/DiscordHooks/appveyor-discord-webhook/master/send.ps1 -o send.ps1
|
||||
- ps: ./send.ps1 success $env:WEBHOOK_URL
|
||||
on_failure:
|
||||
- ps: Set-Location -Path $env:APPVEYOR_BUILD_FOLDER
|
||||
- ps: Push-AppveyorArtifact ${env:APPVEYOR_BUILD_FOLDER}\stdout.log
|
||||
- ps: Push-AppveyorArtifact ${env:APPVEYOR_BUILD_FOLDER}\stderr.log
|
||||
- ps: Invoke-RestMethod https://raw.githubusercontent.com/DiscordHooks/appveyor-discord-webhook/master/send.ps1 -o send.ps1
|
||||
- ps: ./send.ps1 failure $env:WEBHOOK_URL
|
||||
+11
-4
@@ -1,7 +1,14 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
find_package(mo2-cmake CONFIG REQUIRED)
|
||||
find_package(mo2-uibase CONFIG REQUIRED)
|
||||
find_package(mo2-dds-header CONFIG REQUIRED)
|
||||
find_package(mo2-bsatk CONFIG REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(lz4 CONFIG REQUIRED)
|
||||
find_package(Boost CONFIG REQUIRED COMPONENTS thread interprocess)
|
||||
|
||||
add_library(bsa_extractor SHARED)
|
||||
mo2_configure_plugin(bsa_extractor
|
||||
WARNINGS OFF
|
||||
PRIVATE_DEPENDS DirectXTex bsatk)
|
||||
mo2_install_target(bsa_extractor)
|
||||
mo2_configure_plugin(bsa_extractor WARNINGS OFF)
|
||||
target_link_libraries(bsa_extractor PRIVATE mo2::uibase mo2::bsatk)
|
||||
mo2_install_plugin(bsa_extractor)
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
Import('qt_env')
|
||||
|
||||
env = qt_env.Clone()
|
||||
|
||||
env.AddExtraMoc(env.Glob('*.h'))
|
||||
|
||||
env.AppendUnique(CPPDEFINES = [ 'BSAEXTRACTOR_LIBRARY' ])
|
||||
|
||||
env.RequireLibraries('bsatk')
|
||||
|
||||
env.AppendUnique(CPPPATH = [
|
||||
'${BOOSTPATH}'
|
||||
])
|
||||
|
||||
env.AppendUnique(LIBPATH = "${ZLIBPATH}/build")
|
||||
env.AppendUnique(LIBS = 'zlibstatic')
|
||||
|
||||
lib = env.SharedLibrary('bsaExtractor', env.Glob('*.cpp'))
|
||||
env.InstallModule(lib)
|
||||
|
||||
res = env['QT_USED_MODULES']
|
||||
Return('res')
|
||||
@@ -1,43 +0,0 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2014-05-19T20:05:08
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
TARGET = bsaExtractor
|
||||
TEMPLATE = lib
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
CONFIG += plugins
|
||||
CONFIG += dll
|
||||
|
||||
DEFINES += BSAEXTRACTOR_LIBRARY
|
||||
|
||||
SOURCES += bsaextractor.cpp
|
||||
|
||||
HEADERS += bsaextractor.h
|
||||
|
||||
OTHER_FILES += \
|
||||
bsaextractor.json \
|
||||
SConscript
|
||||
|
||||
include(../plugin_template.pri)
|
||||
|
||||
INCLUDEPATH += ../../bsatk "$${BOOSTPATH}"
|
||||
|
||||
CONFIG(debug, debug|release) {
|
||||
LIBS += -L"$${BOOSTPATH}/stage/lib" -L$$OUT_PWD/../../bsatk/debug -lbsatk
|
||||
PRE_TARGETDEPS += $$OUT_PWD/../../bsatk/debug/bsatk.lib
|
||||
} else {
|
||||
LIBS += -L"$${BOOSTPATH}/stage/lib" -L$$OUT_PWD/../../bsatk/release -lbsatk
|
||||
PRE_TARGETDEPS += $$OUT_PWD/../../bsatk/release/bsatk.lib
|
||||
}
|
||||
|
||||
|
||||
INCLUDEPATH += ../../bsatk "$${BOOSTPATH}"
|
||||
|
||||
LIBS += -L"$${BOOSTPATH}/stage/lib" -lbsatk
|
||||
LIBS += -L"$${ZLIBPATH}/build" -lzlibstatic
|
||||
OTHER_FILES += \
|
||||
bsaextractor.json
|
||||
@@ -4,49 +4,49 @@
|
||||
<context>
|
||||
<name>BsaExtractor</name>
|
||||
<message>
|
||||
<location filename="bsaextractor.cpp" line="44"/>
|
||||
<location filename="bsaextractor.cpp" line="42"/>
|
||||
<source>BSA Extractor</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="bsaextractor.cpp" line="55"/>
|
||||
<location filename="bsaextractor.cpp" line="53"/>
|
||||
<source>Offers a dialog during installation of a mod to unpack all its BSAs</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="bsaextractor.cpp" line="89"/>
|
||||
<location filename="bsaextractor.cpp" line="87"/>
|
||||
<source>invalid mod name</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="bsaextractor.cpp" line="90"/>
|
||||
<location filename="bsaextractor.cpp" line="88"/>
|
||||
<source>BSA extraction doesn't work on mods that have the same name as a non-MO mod.Please remove the mod then reinstall with a different name.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="bsaextractor.cpp" line="98"/>
|
||||
<location filename="bsaextractor.cpp" line="96"/>
|
||||
<source>Extract BSA</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="bsaextractor.cpp" line="99"/>
|
||||
<location filename="bsaextractor.cpp" line="97"/>
|
||||
<source>This mod contains at least one BSA. Do you want to unpack it?
|
||||
(If you don't know about BSAs, just select no)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="bsaextractor.cpp" line="103"/>
|
||||
<location filename="bsaextractor.cpp" line="101"/>
|
||||
<source>Remove extracted archives</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="bsaextractor.cpp" line="104"/>
|
||||
<location filename="bsaextractor.cpp" line="102"/>
|
||||
<source>Do you wish to remove BSAs after extraction completed?
|
||||
</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="bsaextractor.cpp" line="110"/>
|
||||
<location filename="bsaextractor.cpp" line="108"/>
|
||||
<source>failed to read %1: %2</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
||||
+140
-140
@@ -1,140 +1,140 @@
|
||||
#include "bsaextractor.h"
|
||||
|
||||
#include "iplugingame.h"
|
||||
#include "imodlist.h"
|
||||
#include <versioninfo.h>
|
||||
#include <imodinterface.h>
|
||||
#include <questionboxmemory.h>
|
||||
#include <bsaarchive.h>
|
||||
#include <report.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfoList>
|
||||
#include <QCoreApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QtPlugin>
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
using namespace MOBase;
|
||||
namespace bindph = std::placeholders;
|
||||
|
||||
|
||||
BsaExtractor::BsaExtractor()
|
||||
: m_Organizer(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
bool BsaExtractor::init(MOBase::IOrganizer *moInfo)
|
||||
{
|
||||
m_Organizer = moInfo;
|
||||
moInfo->modList()->onModInstalled(std::bind(&BsaExtractor::modInstalledHandler, this, bindph::_1));
|
||||
return true;
|
||||
}
|
||||
|
||||
QString BsaExtractor::name() const
|
||||
{
|
||||
return "BSA Extractor";
|
||||
}
|
||||
|
||||
QString BsaExtractor::localizedName() const
|
||||
{
|
||||
return tr("BSA Extractor");
|
||||
}
|
||||
|
||||
|
||||
QString BsaExtractor::author() const
|
||||
{
|
||||
return "Tannin & MO2 Team";
|
||||
}
|
||||
|
||||
QString BsaExtractor::description() const
|
||||
{
|
||||
return tr("Offers a dialog during installation of a mod to unpack all its BSAs");
|
||||
}
|
||||
|
||||
VersionInfo BsaExtractor::version() const
|
||||
{
|
||||
return VersionInfo(1, 5, 0, VersionInfo::RELEASE_FINAL);
|
||||
}
|
||||
|
||||
QList<PluginSetting> BsaExtractor::settings() const
|
||||
{
|
||||
return {
|
||||
PluginSetting("only_alternate_source", "only trigger bsa extraction for alternate game sources", true)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
bool BsaExtractor::extractProgress(QProgressDialog &progress, int percentage, std::string fileName)
|
||||
{
|
||||
progress.setLabelText(fileName.c_str());
|
||||
progress.setValue(percentage);
|
||||
qApp->processEvents();
|
||||
return !progress.wasCanceled();
|
||||
}
|
||||
|
||||
|
||||
void BsaExtractor::modInstalledHandler(IModInterface *mod)
|
||||
{
|
||||
|
||||
if (m_Organizer->pluginSetting(name(), "only_alternate_source").toBool() &&
|
||||
!(m_Organizer->modList()->state(mod->name()) & IModList::STATE_ALTERNATE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (QFileInfo(mod->absolutePath()) == QFileInfo(m_Organizer->managedGame()->dataDirectory().absolutePath())) {
|
||||
QMessageBox::information(nullptr, tr("invalid mod name"),
|
||||
tr("BSA extraction doesn't work on mods that have the same name as a non-MO mod."
|
||||
"Please remove the mod then reinstall with a different name."));
|
||||
return;
|
||||
}
|
||||
QDir dir(mod->absolutePath());
|
||||
|
||||
QFileInfoList archives = dir.entryInfoList(QStringList({ "*.bsa", "*.ba2" }));
|
||||
if (archives.length() != 0 &&
|
||||
(QuestionBoxMemory::query(nullptr, "unpackBSA", tr("Extract BSA"),
|
||||
tr("This mod contains at least one BSA. Do you want to unpack it?\n"
|
||||
"(If you don't know about BSAs, just select no)"),
|
||||
QDialogButtonBox::Yes | QDialogButtonBox::No, QDialogButtonBox::No) == QDialogButtonBox::Yes)) {
|
||||
|
||||
bool removeBSAs = (QuestionBoxMemory::query(nullptr, "removeUnpackedBSA", tr("Remove extracted archives"),
|
||||
tr("Do you wish to remove BSAs after extraction completed?\n"),
|
||||
QDialogButtonBox::Yes | QDialogButtonBox::No, QDialogButtonBox::No) == QDialogButtonBox::Yes);
|
||||
foreach (QFileInfo archiveInfo, archives) {
|
||||
BSA::Archive archive;
|
||||
BSA::EErrorCode result = archive.read(archiveInfo.absoluteFilePath().toLocal8Bit().constData(), true);
|
||||
if ((result != BSA::ERROR_NONE) && (result != BSA::ERROR_INVALIDHASHES)) {
|
||||
reportError(tr("failed to read %1: %2").arg(archiveInfo.fileName()).arg(result));
|
||||
return;
|
||||
}
|
||||
|
||||
QProgressDialog progress(nullptr);
|
||||
progress.setMaximum(100);
|
||||
progress.setValue(0);
|
||||
progress.show();
|
||||
|
||||
archive.extractAll(mod->absolutePath().toLocal8Bit().constData(),
|
||||
boost::bind(&BsaExtractor::extractProgress, this, boost::ref(progress), _1, _2),
|
||||
false);
|
||||
|
||||
if (result == BSA::ERROR_INVALIDHASHES) {
|
||||
reportError(tr("This archive contains invalid hashes. Some files may be broken."));
|
||||
}
|
||||
|
||||
archive.close();
|
||||
|
||||
if (removeBSAs) {
|
||||
if (!QFile::remove(archiveInfo.absoluteFilePath())) {
|
||||
qCritical("failed to remove archive %s", archiveInfo.absoluteFilePath().toUtf8().constData());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
|
||||
Q_EXPORT_PLUGIN2(bsaextractor, BsaExtractor)
|
||||
#endif
|
||||
#include "bsaextractor.h"
|
||||
|
||||
#include <uibase/iplugingame.h>
|
||||
#include <uibase/imodlist.h>
|
||||
#include <uibase/versioninfo.h>
|
||||
#include <uibase/imodinterface.h>
|
||||
#include <uibase/questionboxmemory.h>
|
||||
#include <uibase/report.h>
|
||||
|
||||
#include <bsatk/bsaarchive.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfoList>
|
||||
#include <QCoreApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QtPlugin>
|
||||
|
||||
#include <functional>
|
||||
|
||||
using namespace MOBase;
|
||||
|
||||
|
||||
BsaExtractor::BsaExtractor()
|
||||
: m_Organizer(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
bool BsaExtractor::init(MOBase::IOrganizer *moInfo)
|
||||
{
|
||||
m_Organizer = moInfo;
|
||||
moInfo->modList()->onModInstalled([this](auto* mod) { modInstalledHandler(mod); });
|
||||
return true;
|
||||
}
|
||||
|
||||
QString BsaExtractor::name() const
|
||||
{
|
||||
return "BSA Extractor";
|
||||
}
|
||||
|
||||
QString BsaExtractor::localizedName() const
|
||||
{
|
||||
return tr("BSA Extractor");
|
||||
}
|
||||
|
||||
|
||||
QString BsaExtractor::author() const
|
||||
{
|
||||
return "Tannin & MO2 Team";
|
||||
}
|
||||
|
||||
QString BsaExtractor::description() const
|
||||
{
|
||||
return tr("Offers a dialog during installation of a mod to unpack all its BSAs");
|
||||
}
|
||||
|
||||
VersionInfo BsaExtractor::version() const
|
||||
{
|
||||
return VersionInfo(1, 5, 0, VersionInfo::RELEASE_FINAL);
|
||||
}
|
||||
|
||||
QList<PluginSetting> BsaExtractor::settings() const
|
||||
{
|
||||
return {
|
||||
PluginSetting("only_alternate_source", "only trigger bsa extraction for alternate game sources", true)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
bool BsaExtractor::extractProgress(QProgressDialog &progress, int percentage, std::string fileName)
|
||||
{
|
||||
progress.setLabelText(fileName.c_str());
|
||||
progress.setValue(percentage);
|
||||
qApp->processEvents();
|
||||
return !progress.wasCanceled();
|
||||
}
|
||||
|
||||
|
||||
void BsaExtractor::modInstalledHandler(IModInterface *mod)
|
||||
{
|
||||
|
||||
if (m_Organizer->pluginSetting(name(), "only_alternate_source").toBool() &&
|
||||
!(m_Organizer->modList()->state(mod->name()) & IModList::STATE_ALTERNATE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (QFileInfo(mod->absolutePath()) == QFileInfo(m_Organizer->managedGame()->dataDirectory().absolutePath())) {
|
||||
QMessageBox::information(nullptr, tr("invalid mod name"),
|
||||
tr("BSA extraction doesn't work on mods that have the same name as a non-MO mod."
|
||||
"Please remove the mod then reinstall with a different name."));
|
||||
return;
|
||||
}
|
||||
QDir dir(mod->absolutePath());
|
||||
|
||||
QFileInfoList archives = dir.entryInfoList(QStringList({ "*.bsa", "*.ba2" }));
|
||||
if (archives.length() != 0 &&
|
||||
(QuestionBoxMemory::query(nullptr, "unpackBSA", tr("Extract BSA"),
|
||||
tr("This mod contains at least one BSA. Do you want to unpack it?\n"
|
||||
"(If you don't know about BSAs, just select no)"),
|
||||
QDialogButtonBox::Yes | QDialogButtonBox::No, QDialogButtonBox::No) == QDialogButtonBox::Yes)) {
|
||||
|
||||
bool removeBSAs = (QuestionBoxMemory::query(nullptr, "removeUnpackedBSA", tr("Remove extracted archives"),
|
||||
tr("Do you wish to remove BSAs after extraction completed?\n"),
|
||||
QDialogButtonBox::Yes | QDialogButtonBox::No, QDialogButtonBox::No) == QDialogButtonBox::Yes);
|
||||
foreach (QFileInfo archiveInfo, archives) {
|
||||
BSA::Archive archive;
|
||||
BSA::EErrorCode result = archive.read(archiveInfo.absoluteFilePath().toLocal8Bit().constData(), true);
|
||||
if ((result != BSA::ERROR_NONE) && (result != BSA::ERROR_INVALIDHASHES)) {
|
||||
reportError(tr("failed to read %1: %2").arg(archiveInfo.fileName()).arg(result));
|
||||
return;
|
||||
}
|
||||
|
||||
QProgressDialog progress(nullptr);
|
||||
progress.setMaximum(100);
|
||||
progress.setValue(0);
|
||||
progress.show();
|
||||
|
||||
archive.extractAll(mod->absolutePath().toLocal8Bit().constData(),
|
||||
[this, &progress](int value, std::string filename) {
|
||||
return extractProgress(progress, value, filename);
|
||||
},
|
||||
false);
|
||||
|
||||
if (result == BSA::ERROR_INVALIDHASHES) {
|
||||
reportError(tr("This archive contains invalid hashes. Some files may be broken."));
|
||||
}
|
||||
|
||||
archive.close();
|
||||
|
||||
if (removeBSAs) {
|
||||
if (!QFile::remove(archiveInfo.absoluteFilePath())) {
|
||||
qCritical("failed to remove archive %s", archiveInfo.absoluteFilePath().toUtf8().constData());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
|
||||
Q_EXPORT_PLUGIN2(bsaextractor, BsaExtractor)
|
||||
#endif
|
||||
|
||||
+34
-33
@@ -1,33 +1,34 @@
|
||||
#ifndef BSAEXTRACTOR_H
|
||||
#define BSAEXTRACTOR_H
|
||||
|
||||
#include <iplugin.h>
|
||||
#include <QProgressDialog>
|
||||
|
||||
class BsaExtractor : public QObject, public MOBase::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MOBase::IPlugin)
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||
Q_PLUGIN_METADATA(IID "org.tannin.BSAExtractor" FILE "bsaextractor.json")
|
||||
#endif
|
||||
|
||||
public:
|
||||
BsaExtractor();
|
||||
|
||||
virtual bool init(MOBase::IOrganizer *moInfo) override;
|
||||
virtual QString name() const override;
|
||||
virtual QString localizedName() const override;
|
||||
virtual QString author() const override;
|
||||
virtual QString description() const override;
|
||||
virtual MOBase::VersionInfo version() const override;
|
||||
virtual QList<MOBase::PluginSetting> settings() const override;
|
||||
|
||||
private:
|
||||
void modInstalledHandler(MOBase::IModInterface *mod);
|
||||
bool extractProgress(QProgressDialog &progress, int percentage, std::string fileName);
|
||||
private:
|
||||
MOBase::IOrganizer *m_Organizer;
|
||||
};
|
||||
|
||||
#endif // BSAEXTRACTOR_H
|
||||
#ifndef BSAEXTRACTOR_H
|
||||
#define BSAEXTRACTOR_H
|
||||
|
||||
#include <QProgressDialog>
|
||||
|
||||
#include <uibase/iplugin.h>
|
||||
|
||||
class BsaExtractor : public QObject, public MOBase::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MOBase::IPlugin)
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||
Q_PLUGIN_METADATA(IID "org.tannin.BSAExtractor")
|
||||
#endif
|
||||
|
||||
public:
|
||||
BsaExtractor();
|
||||
|
||||
virtual bool init(MOBase::IOrganizer *moInfo) override;
|
||||
virtual QString name() const override;
|
||||
virtual QString localizedName() const override;
|
||||
virtual QString author() const override;
|
||||
virtual QString description() const override;
|
||||
virtual MOBase::VersionInfo version() const override;
|
||||
virtual QList<MOBase::PluginSetting> settings() const override;
|
||||
|
||||
private:
|
||||
void modInstalledHandler(MOBase::IModInterface *mod);
|
||||
bool extractProgress(QProgressDialog &progress, int percentage, std::string fileName);
|
||||
private:
|
||||
MOBase::IOrganizer *m_Organizer;
|
||||
};
|
||||
|
||||
#endif // BSAEXTRACTOR_H
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"dependencies": [
|
||||
"mo2-dds-header",
|
||||
"boost-thread",
|
||||
"boost-interprocess",
|
||||
"zlib",
|
||||
"lz4"
|
||||
],
|
||||
"features": {
|
||||
"standalone": {
|
||||
"description": "Build Standalone.",
|
||||
"dependencies": ["mo2-cmake"]
|
||||
}
|
||||
},
|
||||
"vcpkg-configuration": {
|
||||
"default-registry": {
|
||||
"kind": "git",
|
||||
"repository": "https://github.com/Microsoft/vcpkg",
|
||||
"baseline": "294f76666c3000630d828703e675814c05a4fd43"
|
||||
},
|
||||
"registries": [
|
||||
{
|
||||
"kind": "git",
|
||||
"repository": "https://github.com/Microsoft/vcpkg",
|
||||
"baseline": "294f76666c3000630d828703e675814c05a4fd43",
|
||||
"packages": ["boost*", "boost-*"]
|
||||
},
|
||||
{
|
||||
"kind": "git",
|
||||
"repository": "https://github.com/ModOrganizer2/vcpkg-registry",
|
||||
"baseline": "8beb2e0efa9c17dd6d17bb05288dd1e40727f673",
|
||||
"packages": ["mo2-*"]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user