Compare commits

...
Author SHA1 Message Date
Mikaël Capelle 288e1b93c4 Add github actions. 2024-06-09 14:01:58 +02:00
Mikaël Capelle 5995bce5e6 Add .git-blame-ignore-revs. 2024-06-09 13:47:44 +02:00
Mikaël Capelle 988523cac1 Format files and add .gitattributes and .clang-format. 2024-06-09 13:47:44 +02:00
Mikaël Capelle 71b82656b1 Remove appveyor.yml. 2024-06-09 13:47:43 +02:00
Mikaël Capelle 6d89f9da86 Merge pull request #15 from ModOrganizer2/update-cmake-common-qt6
Update following cmake_common changes.
2022-04-28 18:16:31 +02:00
Mikaël Capelle 12d509e2d6 Update following cmake_common changes. 2022-04-19 23:33:24 +02:00
12 changed files with 226 additions and 193 deletions
+41
View File
@@ -0,0 +1,41 @@
---
# We'll use defaults from the LLVM style, but with 4 columns indentation.
BasedOnStyle: LLVM
IndentWidth: 2
---
Language: Cpp
DeriveLineEnding: false
UseCRLF: true
DerivePointerAlignment: false
PointerAlignment: Left
AlignConsecutiveAssignments: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Empty
AlwaysBreakTemplateDeclarations: Yes
AccessModifierOffset: -2
AlignTrailingComments: true
SpacesBeforeTrailingComments: 2
NamespaceIndentation: Inner
MaxEmptyLinesToKeep: 1
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: false
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: true
ColumnLimit: 88
ForEachMacros: ['Q_FOREACH', 'foreach']
+1
View File
@@ -0,0 +1 @@
988523cac10641c510fd711d80d59c82d473f6a5
+7
View File
@@ -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
+16
View File
@@ -0,0 +1,16 @@
name: Build Installer Bundle Plugin
on:
push:
branches: master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
runs-on: windows-2022
steps:
- name: Build Installer Bundle Plugin
uses: ModOrganizer2/build-with-mob-action@master
with:
mo2-dependencies: cmake_common uibase
+16
View File
@@ -0,0 +1,16 @@
name: Lint Installer Bundle Plugin
on:
push:
pull_request:
types: [opened, synchronize, reopened]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check format
uses: ModOrganizer2/check-formatting-action@master
with:
check-path: "."
+3 -4
View File
@@ -1,12 +1,11 @@
cmake_minimum_required(VERSION 3.16)
project(installer_bundle)
set(project_type plugin)
set(enable_warnings OFF)
if(DEFINED DEPENDENCIES_DIR)
include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/project.cmake)
include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/mo2.cmake)
else()
include(../cmake_common/project.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/../cmake_common/mo2.cmake)
endif()
add_subdirectory(src)
-40
View File
@@ -1,40 +0,0 @@
version: 1.0.{build}
skip_branch_with_pr: true
image: Visual Studio 2019
environment:
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\installer_bundle.dll
name: installer_bundle_dll
- path: vsbuild\src\RelWithDebInfo\installer_bundle.pdb
name: installer_bundle_pdb
- path: vsbuild\src\RelWithDebInfo\installer_bundle.lib
name: installer_bundle_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
+4 -5
View File
@@ -1,6 +1,5 @@
cmake_minimum_required(VERSION 3.16)
if(DEFINED DEPENDENCIES_DIR)
include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/src.cmake)
else()
include(../../cmake_common/src.cmake)
endif()
add_library(installer_bundle SHARED)
mo2_configure_plugin(installer_bundle WARNINGS OFF)
mo2_install_target(installer_bundle)
+26 -28
View File
@@ -26,13 +26,9 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
using namespace MOBase;
InstallerBundle::InstallerBundle() {}
InstallerBundle::InstallerBundle()
{
}
bool InstallerBundle::init(IOrganizer *organizer)
bool InstallerBundle::init(IOrganizer* organizer)
{
m_Organizer = organizer;
return true;
@@ -65,9 +61,10 @@ VersionInfo InstallerBundle::version() const
QList<PluginSetting> InstallerBundle::settings() const
{
return {
PluginSetting("auto_reinstall", "when reinstalling from an archive containing multiple mods, automatically select the previously installed", true)
};
return {PluginSetting("auto_reinstall",
"when reinstalling from an archive containing multiple mods, "
"automatically select the previously installed",
true)};
}
unsigned int InstallerBundle::priority() const
@@ -80,13 +77,14 @@ bool InstallerBundle::isManualInstaller() const
return false;
}
void InstallerBundle::onInstallationStart(QString const& archive, bool reinstallation, IModInterface* currentMod)
void InstallerBundle::onInstallationStart(QString const& archive, bool reinstallation,
IModInterface* currentMod)
{
// We reset some field and fetch the previously installed file:
m_InstallationFile = archive;
m_InstallerUsed = false;
m_SelectedFile = "";
m_PreviousFile = "";
m_InstallerUsed = false;
m_SelectedFile = "";
m_PreviousFile = "";
if (reinstallation && m_Organizer->pluginSetting(name(), "auto_reinstall").toBool()) {
m_PreviousFile = currentMod->pluginSetting(name(), "archive", QString()).toString();
@@ -102,7 +100,8 @@ void InstallerBundle::onInstallationEnd(EInstallResult result, IModInterface* ne
}
}
std::vector<std::shared_ptr<const MOBase::FileTreeEntry>> InstallerBundle::findObjects(std::shared_ptr<const IFileTree> tree) const
std::vector<std::shared_ptr<const MOBase::FileTreeEntry>>
InstallerBundle::findObjects(std::shared_ptr<const IFileTree> tree) const
{
std::vector<std::shared_ptr<const MOBase::FileTreeEntry>> entries;
// Check if we have an archive:
@@ -112,11 +111,11 @@ std::vector<std::shared_ptr<const MOBase::FileTreeEntry>> InstallerBundle::findO
int nDirs = 0;
for (auto entry : *tree) {
if (entry->isFile()) {
if (managerExtensions.contains(entry->suffix(), FileNameComparator::CaseSensitivity)) {
if (managerExtensions.contains(entry->suffix(),
FileNameComparator::CaseSensitivity)) {
entries.push_back(entry);
}
}
else {
} else {
nDirs++;
}
}
@@ -140,8 +139,9 @@ bool InstallerBundle::isArchiveSupported(std::shared_ptr<const IFileTree> tree)
return !findObjects(tree).empty();
}
IPluginInstaller::EInstallResult InstallerBundle::install(
GuessedValue<QString>& modName, std::shared_ptr<IFileTree>& tree, QString&, int &modId)
IPluginInstaller::EInstallResult
InstallerBundle::install(GuessedValue<QString>& modName,
std::shared_ptr<IFileTree>& tree, QString&, int& modId)
{
// Find a valid "object":
auto entries = findObjects(tree);
@@ -152,8 +152,7 @@ IPluginInstaller::EInstallResult InstallerBundle::install(
std::shared_ptr<const FileTreeEntry> entry = nullptr;
if (entries.size() == 1) {
entry = entries[0];
}
else {
} else {
if (!m_PreviousFile.isEmpty()) {
entry = tree->find(m_PreviousFile);
}
@@ -161,14 +160,12 @@ IPluginInstaller::EInstallResult InstallerBundle::install(
if (entry == nullptr) {
MultiArchiveDialog dialog(entries, parentWidget());
if (dialog.exec() == QDialog::Accepted) {
entry = dialog.selectedEntry();
entry = dialog.selectedEntry();
m_SelectedFile = entry->pathFrom(tree);
}
else {
} else {
if (dialog.manualRequested()) {
return IPluginInstaller::RESULT_MANUALREQUESTED;
}
else {
} else {
return IPluginInstaller::RESULT_CANCELED;
}
}
@@ -183,13 +180,14 @@ IPluginInstaller::EInstallResult InstallerBundle::install(
// Extract it:
QString tempFile = manager()->extractFile(entry);
IPluginInstaller::EInstallResult res = manager()->installArchive(modName, tempFile, modId);
IPluginInstaller::EInstallResult res =
manager()->installArchive(modName, tempFile, modId);
if (res == IPluginInstaller::RESULT_SUCCESS) {
res = IPluginInstaller::RESULT_SUCCESSCANCEL;
}
return res;
}
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
Q_EXPORT_PLUGIN2(installerBundle, InstallerBundle)
#endif
+88 -89
View File
@@ -1,89 +1,88 @@
/*
Copyright (C) 2012 Sebastian Herbord. All rights reserved.
This file is part of Mod Organizer.
Mod Organizer 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.
Mod Organizer 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 Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INSTALLERBUNDLE_H
#define INSTALLERBUNDLE_H
#include <iplugininstallersimple.h>
class InstallerBundle : public MOBase::IPluginInstallerSimple
{
Q_OBJECT
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginInstaller MOBase::IPluginInstallerSimple)
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
Q_PLUGIN_METADATA(IID "org.tannin.InstallerBundle" FILE "installerbundle.json")
#endif
public:
InstallerBundle();
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;
virtual unsigned int priority() const override;
virtual bool isManualInstaller() const override;
virtual void onInstallationStart(QString const& archive, bool reinstallation, MOBase::IModInterface* currentMod) override;
virtual void onInstallationEnd(EInstallResult result, MOBase::IModInterface* newMod) override;
virtual bool isArchiveSupported(std::shared_ptr<const MOBase::IFileTree> tree) const override;
virtual EInstallResult install(MOBase::GuessedValue<QString> &modName,
std::shared_ptr<MOBase::IFileTree> &tree,
QString &version, int &modID) override;
private:
/**
* @brief Find the entries that can be extracted from this archive.
*
* @param tree The tree to look the entry in.
*
* @return the entry, if one was found, or a null pointer.
*/
std::vector<std::shared_ptr<const MOBase::FileTreeEntry>> findObjects(std::shared_ptr<const MOBase::IFileTree> tree) const;
private:
MOBase::IOrganizer* m_Organizer;
// The archive being installed:
QString m_InstallationFile;
// Indicates if this installer was used during the installation process:
bool m_InstallerUsed;
// Contains the file installed (when multiple archives are present), or an
// empty string:
QString m_SelectedFile;
// Contains the file previously installed (when multiple archives are present), or an
// empty string:
QString m_PreviousFile;
};
#endif // INSTALLERBUNDLE_H
/*
Copyright (C) 2012 Sebastian Herbord. All rights reserved.
This file is part of Mod Organizer.
Mod Organizer 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.
Mod Organizer 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 Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INSTALLERBUNDLE_H
#define INSTALLERBUNDLE_H
#include <iplugininstallersimple.h>
class InstallerBundle : public MOBase::IPluginInstallerSimple
{
Q_OBJECT
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginInstaller MOBase::IPluginInstallerSimple)
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
Q_PLUGIN_METADATA(IID "org.tannin.InstallerBundle" FILE "installerbundle.json")
#endif
public:
InstallerBundle();
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;
virtual unsigned int priority() const override;
virtual bool isManualInstaller() const override;
virtual void onInstallationStart(QString const& archive, bool reinstallation,
MOBase::IModInterface* currentMod) override;
virtual void onInstallationEnd(EInstallResult result,
MOBase::IModInterface* newMod) override;
virtual bool
isArchiveSupported(std::shared_ptr<const MOBase::IFileTree> tree) const override;
virtual EInstallResult install(MOBase::GuessedValue<QString>& modName,
std::shared_ptr<MOBase::IFileTree>& tree,
QString& version, int& modID) override;
private:
/**
* @brief Find the entries that can be extracted from this archive.
*
* @param tree The tree to look the entry in.
*
* @return the entry, if one was found, or a null pointer.
*/
std::vector<std::shared_ptr<const MOBase::FileTreeEntry>>
findObjects(std::shared_ptr<const MOBase::IFileTree> tree) const;
private:
MOBase::IOrganizer* m_Organizer;
// The archive being installed:
QString m_InstallationFile;
// Indicates if this installer was used during the installation process:
bool m_InstallerUsed;
// Contains the file installed (when multiple archives are present), or an
// empty string:
QString m_SelectedFile;
// Contains the file previously installed (when multiple archives are present), or an
// empty string:
QString m_PreviousFile;
};
#endif // INSTALLERBUNDLE_H
+4 -8
View File
@@ -1,13 +1,12 @@
#include "multiarchivedialog.h"
#include "ui_multiarchivedialog.h"
using namespace MOBase;
MultiArchiveDialog::MultiArchiveDialog(
std::vector<std::shared_ptr<const MOBase::FileTreeEntry>> entries, QWidget* parent)
: QDialog(parent), ui(new Ui::MultiArchiveDialog), m_Manual(false), m_SelectedEntry(nullptr)
std::vector<std::shared_ptr<const MOBase::FileTreeEntry>> entries, QWidget* parent)
: QDialog(parent), ui(new Ui::MultiArchiveDialog), m_Manual(false),
m_SelectedEntry(nullptr)
{
ui->setupUi(this);
@@ -24,21 +23,18 @@ MultiArchiveDialog::MultiArchiveDialog(
}
}
MultiArchiveDialog::~MultiArchiveDialog()
{
delete ui;
}
void MultiArchiveDialog::on_cancelBtn_clicked()
{
this->reject();
}
void MultiArchiveDialog::on_manualBtn_clicked()
{
m_Manual = true;
this->reject();
}
}
+20 -19
View File
@@ -26,29 +26,32 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "ifiletree.h"
namespace Ui {
class MultiArchiveDialog;
namespace Ui
{
class MultiArchiveDialog;
}
/**
*
**/
class MultiArchiveDialog: public QDialog
class MultiArchiveDialog : public QDialog
{
Q_OBJECT
public:
/**
* @brief Constructor
*
* @param tree the directory tree of the archive. The caller is resonsible to verify this actually qualifies as a bain installer
* @param modName proposed name for the mod. The dialog allows the user to change this
* @param packageTXT path to the extracted package.txt file or an empty string if there is none
* @param parent parent widget
**/
explicit MultiArchiveDialog(std::vector<std::shared_ptr<const MOBase::FileTreeEntry>> entries, QWidget *parent);
/**
* @brief Constructor
*
* @param tree the directory tree of the archive. The caller is resonsible to verify
*this actually qualifies as a bain installer
* @param modName proposed name for the mod. The dialog allows the user to change this
* @param packageTXT path to the extracted package.txt file or an empty string if
*there is none
* @param parent parent widget
**/
explicit MultiArchiveDialog(
std::vector<std::shared_ptr<const MOBase::FileTreeEntry>> entries,
QWidget* parent);
~MultiArchiveDialog();
/**
@@ -67,11 +70,9 @@ private slots:
void on_cancelBtn_clicked();
private:
Ui::MultiArchiveDialog *ui;
Ui::MultiArchiveDialog* ui;
bool m_Manual;
std::shared_ptr<const MOBase::FileTreeEntry> m_SelectedEntry;
};
#endif // BAINCOMPLEXINSTALLERDIALOG_H
#endif // BAINCOMPLEXINSTALLERDIALOG_H