diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..6098e1f
--- /dev/null
+++ b/.clang-format
@@ -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']
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..f869712
--- /dev/null
+++ b/.gitattributes
@@ -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
diff --git a/src/base_script.cpp b/src/base_script.cpp
index aeedf00..0826612 100644
--- a/src/base_script.cpp
+++ b/src/base_script.cpp
@@ -15,6 +15,8 @@ You should have received a copy of the GNU General Public License
along with Mod Organizer. If not, see .
*/
+// clang-format off
+
#include "base_script.h"
#include
@@ -678,4 +680,4 @@ namespace CSharp {
return true;
}
-}
\ No newline at end of file
+}
diff --git a/src/base_script.h b/src/base_script.h
index 2dab450..065e5ec 100644
--- a/src/base_script.h
+++ b/src/base_script.h
@@ -15,6 +15,8 @@ You should have received a copy of the GNU General Public License
along with Mod Organizer. If not, see .
*/
+// clang-format off
+
#ifndef BASE_SCRIPT_H
#define BASE_SCRIPT_H
@@ -268,7 +270,7 @@ namespace CSharp {
/// The items, previews, and descriptions are repectively ordered. In other words,
/// the i-th item in uses the i-th preview in
/// and the i-th description in .
- ///
+ ///
/// Similarly, the idices return as results correspond to the indices of the items in
/// .
///
@@ -294,7 +296,7 @@ namespace CSharp {
/// The items, previews, and descriptions are repectively ordered. In other words,
/// the i-th item in uses the i-th preview in
/// and the i-th description in .
- ///
+ ///
/// Similarly, the idices return as results correspond to the indices of the items in
/// .
///
@@ -492,7 +494,7 @@ namespace CSharp {
/// The specified value as a string.
///
static String^ GetPrefsIniString(String^ p_strSection, String^ p_strKey) {
- // This looks wrong? Yes! But that's what used in other mod managers...
+ // This looks wrong? Yes! But that's what used in other mod managers...
return GetIniString("FalloutPrefs.ini", p_strSection, p_strKey);
}
@@ -504,7 +506,7 @@ namespace CSharp {
/// The specified value as an integer.
///
static int GetPrefsIniInt(String^ p_strSection, String^ p_strKey) {
- // This looks wrong? Yes! But that's what used in other mod managers...
+ // This looks wrong? Yes! But that's what used in other mod managers...
return GetIniInt("FalloutPrefs.ini", p_strSection, p_strKey);
}
@@ -520,7 +522,7 @@ namespace CSharp {
static bool EditIni(String^ p_strSettingsFileName, String^ p_strSection, String^ p_strKey, String^ p_strValue);
///
- /// Sets the specified value in the Fallout.ini file to the given value.
+ /// Sets the specified value in the Fallout.ini file to the given value.
///
/// The section in the Ini file to edit.
/// The key in the Ini file to edit.
@@ -541,10 +543,10 @@ namespace CSharp {
}
// BaseScript cannot be in a namespace:
-public ref struct SelectOption: public CSharp::SelectOption {
- SelectOption(System::String^ item, System::String^ preview, System::String^ desc) :
+public ref struct SelectOption: public CSharp::SelectOption {
+ SelectOption(System::String^ item, System::String^ preview, System::String^ desc) :
CSharp::SelectOption(item, preview, desc) { }
};
public ref class BaseScript: public CSharp::BaseScriptImpl { };
-#endif
\ No newline at end of file
+#endif
diff --git a/src/csharp_interface.cpp b/src/csharp_interface.cpp
index 8edc896..fe5ea6e 100644
--- a/src/csharp_interface.cpp
+++ b/src/csharp_interface.cpp
@@ -1,3 +1,5 @@
+// clang-format off
+
#include "csharp_interface.h"
#include
@@ -153,4 +155,4 @@ namespace CSharp {
return postInstall(tree);
}
-}
\ No newline at end of file
+}
diff --git a/src/csharp_interface.h b/src/csharp_interface.h
index f5b4680..fa209ca 100644
--- a/src/csharp_interface.h
+++ b/src/csharp_interface.h
@@ -6,35 +6,35 @@
#include "ifiletree.h"
#include "iplugininstaller.h"
-namespace CSharp {
+namespace CSharp
+{
- void init(MOBase::IOrganizer* moInfo);
+void init(MOBase::IOrganizer* moInfo);
- /**
- * @brief Initialize the C# interface before starting an installation.
- *
- * @param installer The FOMOD C# installer.
- * @param manager The installation manager from the installer.
- * @param parentWidget The parent widget from the installer.
- * @param tree The archive tree.
- * @param extractedEntries A map from extracted entries to their extracted path.
- */
- void beforeInstall(
- MOBase::IPlugin const* installer,
- MOBase::IInstallationManager* manager,
- QWidget* parentWidget,
- std::shared_ptr tree,
+/**
+ * @brief Initialize the C# interface before starting an installation.
+ *
+ * @param installer The FOMOD C# installer.
+ * @param manager The installation manager from the installer.
+ * @param parentWidget The parent widget from the installer.
+ * @param tree The archive tree.
+ * @param extractedEntries A map from extracted entries to their extracted path.
+ */
+void beforeInstall(
+ MOBase::IPlugin const* installer, MOBase::IInstallationManager* manager,
+ QWidget* parentWidget, std::shared_ptr tree,
std::map, QString> extractedEntries);
- /**
- * @brief Clear the C# interface after an installation.
- *
- * @param scriptPath Path to the script to execute.
- * @param tree Reference where the final tree will be stored (in case of success.
- *
- * @return the installation result after performing post-installation.
- */
- MOBase::IPluginInstaller::EInstallResult executeCSharpScript(QString scriptPath, std::shared_ptr& tree);
+/**
+ * @brief Clear the C# interface after an installation.
+ *
+ * @param scriptPath Path to the script to execute.
+ * @param tree Reference where the final tree will be stored (in case of success.
+ *
+ * @return the installation result after performing post-installation.
+ */
+MOBase::IPluginInstaller::EInstallResult
+executeCSharpScript(QString scriptPath, std::shared_ptr& tree);
-}
-#endif
\ No newline at end of file
+} // namespace CSharp
+#endif
diff --git a/src/csharp_utils.h b/src/csharp_utils.h
index a816eda..5ede874 100644
--- a/src/csharp_utils.h
+++ b/src/csharp_utils.h
@@ -1,3 +1,5 @@
+// clang-format off
+
#ifndef CSHARP_UTILS_H
#define CSHARP_UTILS_H
@@ -17,7 +19,7 @@ namespace CSharp {
*/
inline std::string to_string(System::String^ value) {
return msclr::interop::marshal_as(value);
- }
+ }
inline std::wstring to_wstring(System::String^ value) {
return msclr::interop::marshal_as(value);
}
@@ -36,4 +38,4 @@ namespace CSharp {
}
-#endif
\ No newline at end of file
+#endif
diff --git a/src/installer_fomod_csharp.cpp b/src/installer_fomod_csharp.cpp
index 8b31780..ba461f4 100644
--- a/src/installer_fomod_csharp.cpp
+++ b/src/installer_fomod_csharp.cpp
@@ -17,20 +17,22 @@ along with Mod Organizer. If not, see .
#include "iinstallationmanager.h"
+#include "csharp_interface.h"
+#include "installer_fomod_csharp.h"
#include "installer_fomod_predialog.h"
#include "xml_info_reader.h"
-#include "installer_fomod_csharp.h"
-#include "csharp_interface.h"
using namespace MOBase;
-bool InstallerFomodCSharp::init(IOrganizer* moInfo) {
+bool InstallerFomodCSharp::init(IOrganizer* moInfo)
+{
m_MOInfo = moInfo;
CSharp::init(moInfo);
return true;
}
-std::shared_ptr InstallerFomodCSharp::findFomodDirectory(std::shared_ptr tree) const
+std::shared_ptr
+InstallerFomodCSharp::findFomodDirectory(std::shared_ptr tree) const
{
auto entry = tree->find("fomod", FileTreeEntry::DIRECTORY);
@@ -55,7 +57,9 @@ std::shared_ptr InstallerFomodCSharp::findFomodDirectory(std::s
return findFomodDirectory(tree->at(0)->astree());
}
-std::shared_ptr InstallerFomodCSharp::findScriptFile(std::shared_ptr tree) const {
+std::shared_ptr
+InstallerFomodCSharp::findScriptFile(std::shared_ptr tree) const
+{
auto fomodDirectory = findFomodDirectory(tree);
if (fomodDirectory == nullptr) {
@@ -71,7 +75,9 @@ std::shared_ptr InstallerFomodCSharp::findScriptFile(std::s
return nullptr;
}
-std::shared_ptr InstallerFomodCSharp::findInfoFile(std::shared_ptr tree) const {
+std::shared_ptr
+InstallerFomodCSharp::findInfoFile(std::shared_ptr tree) const
+{
auto fomodDirectory = findFomodDirectory(tree);
if (fomodDirectory == nullptr) {
@@ -87,14 +93,19 @@ std::shared_ptr InstallerFomodCSharp::findInfoFile(std::sha
return nullptr;
}
-bool InstallerFomodCSharp::isArchiveSupported(std::shared_ptr tree) const {
+bool InstallerFomodCSharp::isArchiveSupported(
+ std::shared_ptr tree) const
+{
return findScriptFile(tree) != nullptr;
}
-InstallerFomodCSharp::EInstallResult InstallerFomodCSharp::install(MOBase::GuessedValue& modName, std::shared_ptr& tree,
- QString& version, int& modID)
+InstallerFomodCSharp::EInstallResult
+InstallerFomodCSharp::install(MOBase::GuessedValue& modName,
+ std::shared_ptr& tree,
+ QString& version, int& modID)
{
- static std::set imageSuffixes{ "png", "jpg", "jpeg", "gif", "bmp" };
+ static std::set imageSuffixes{"png", "jpg", "jpeg",
+ "gif", "bmp"};
// Extract the script file:
auto scriptFile = findScriptFile(tree);
@@ -106,7 +117,7 @@ InstallerFomodCSharp::EInstallResult InstallerFomodCSharp::install(MOBase::Guess
auto infoFile = findInfoFile(tree);
// Set containing everything to extract except the script and the info file:
- std::set> toExtractSet{ scriptFile };
+ std::set> toExtractSet{scriptFile};
if (infoFile != nullptr) {
toExtractSet.insert(infoFile);
@@ -118,7 +129,7 @@ InstallerFomodCSharp::EInstallResult InstallerFomodCSharp::install(MOBase::Guess
toExtractSet.insert(entry);
}
return IFileTree::WalkReturn::CONTINUE;
- });
+ });
// Extract everything from the fomod/ folder:
auto fomodFolder = findFomodDirectory(tree);
@@ -127,7 +138,7 @@ InstallerFomodCSharp::EInstallResult InstallerFomodCSharp::install(MOBase::Guess
toExtractSet.insert(entry);
}
return IFileTree::WalkReturn::CONTINUE;
- });
+ });
// Convert to vector:
std::vector toExtract(std::begin(toExtractSet), std::end(toExtractSet));
@@ -166,8 +177,7 @@ InstallerFomodCSharp::EInstallResult InstallerFomodCSharp::install(MOBase::Guess
if (dialog.manualRequested()) {
modName.update(dialog.getName(), GUESS_USER);
return EInstallResult::RESULT_MANUALREQUESTED;
- }
- else {
+ } else {
return EInstallResult::RESULT_CANCELED;
}
}
@@ -175,6 +185,9 @@ InstallerFomodCSharp::EInstallResult InstallerFomodCSharp::install(MOBase::Guess
// Run the C# script:
const QString scriptPath = entryToPath[scriptFile];
- CSharp::beforeInstall(this, manager(), parentWidget(), std::const_pointer_cast(scriptFile->parent()->parent()), std::move(entryToPath));
+ CSharp::beforeInstall(
+ this, manager(), parentWidget(),
+ std::const_pointer_cast(scriptFile->parent()->parent()),
+ std::move(entryToPath));
return CSharp::executeCSharpScript(scriptPath, tree);
-}
\ No newline at end of file
+}
diff --git a/src/installer_fomod_csharp.h b/src/installer_fomod_csharp.h
index 382dd13..166b966 100644
--- a/src/installer_fomod_csharp.h
+++ b/src/installer_fomod_csharp.h
@@ -20,67 +20,65 @@ along with Mod Organizer. If not, see .
#include "iplugininstallersimple.h"
-class InstallerFomodCSharp : public MOBase::IPluginInstallerSimple
+class InstallerFomodCSharp : public MOBase::IPluginInstallerSimple
{
Q_OBJECT
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginInstaller MOBase::IPluginInstallerSimple)
Q_PLUGIN_METADATA(IID "org.holt59.InstallerFomodCSharp")
public:
-
- InstallerFomodCSharp() { }
+ InstallerFomodCSharp() {}
virtual bool init(MOBase::IOrganizer* moInfo) override;
- virtual QString name() const override {
- return "Fomod Installer C#";
- }
+ virtual QString name() const override { return "Fomod Installer C#"; }
- virtual QString localizedName() const override {
- return tr("Fomod Installer C#");
- }
+ virtual QString localizedName() const override { return tr("Fomod Installer C#"); }
- virtual QString author() const override {
- return "Holt59";
- }
+ virtual QString author() const override { return "Holt59"; }
- virtual QString description() const override {
+ virtual QString description() const override
+ {
return tr("Installer for C# based FOMOD archives.");
}
- virtual MOBase::VersionInfo version() const override {
+ virtual MOBase::VersionInfo version() const override
+ {
return MOBase::VersionInfo(1, 0, 0, MOBase::VersionInfo::RELEASE_BETA);
}
- virtual QList settings() const override {
+ virtual QList settings() const override
+ {
return {
- MOBase::PluginSetting("enabled", "check to enable this plugin", QVariant(true)),
- MOBase::PluginSetting("prefer", "prefer this over the NCC based plugin", QVariant(true))
- };
+ MOBase::PluginSetting("enabled", "check to enable this plugin", QVariant(true)),
+ MOBase::PluginSetting("prefer", "prefer this over the NCC based plugin",
+ QVariant(true))};
}
- virtual unsigned int priority() const override {
+ virtual unsigned int priority() const override
+ {
// It's the same priority as the FOMOD installer but those should never conflict:
return m_MOInfo->pluginSetting(name(), "prefer").toBool() ? 110 : 90;
}
- virtual bool isManualInstaller() const override {
- return false;
- }
+ virtual bool isManualInstaller() const override { return false; }
- virtual bool isArchiveSupported(std::shared_ptr tree) const override;
+ virtual bool
+ isArchiveSupported(std::shared_ptr tree) const override;
- virtual EInstallResult install(MOBase::GuessedValue& modName, std::shared_ptr& tree,
- QString& version, int& modID) override;
+ virtual EInstallResult install(MOBase::GuessedValue& modName,
+ std::shared_ptr& tree,
+ QString& version, int& modID) override;
private:
-
MOBase::IOrganizer* m_MOInfo;
- std::shared_ptr findFomodDirectory(std::shared_ptr tree) const;
- std::shared_ptr findScriptFile(std::shared_ptr tree) const;
- std::shared_ptr findInfoFile(std::shared_ptr tree) const;
-
+ std::shared_ptr
+ findFomodDirectory(std::shared_ptr tree) const;
+ std::shared_ptr
+ findScriptFile(std::shared_ptr tree) const;
+ std::shared_ptr
+ findInfoFile(std::shared_ptr tree) const;
};
-#endif
\ No newline at end of file
+#endif
diff --git a/src/installer_fomod_postdialog.h b/src/installer_fomod_postdialog.h
index ae19a90..9804610 100644
--- a/src/installer_fomod_postdialog.h
+++ b/src/installer_fomod_postdialog.h
@@ -16,8 +16,8 @@ class InstallerFomodPostDialog : public QDialog
Q_OBJECT
public:
-
- enum class Result {
+ enum class Result
+ {
APPLY,
DISCARD,
MOVE,
@@ -29,13 +29,14 @@ public:
* @param preset suggested name for the mod
* @param parent parent widget
**/
- explicit InstallerFomodPostDialog(QWidget* parent = 0) :
- QDialog(parent), ui(new Ui::FomodCSharpPostDialog) {
+ explicit InstallerFomodPostDialog(QWidget* parent = 0)
+ : QDialog(parent), ui(new Ui::FomodCSharpPostDialog)
+ {
ui->setupUi(this);
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
}
- ~InstallerFomodPostDialog() { }
+ ~InstallerFomodPostDialog() {}
/**
* @return the result of this dialog if the user did not cancel.
@@ -45,7 +46,8 @@ public:
/**
*
*/
- void setIniSettings(std::map const& settings) {
+ void setIniSettings(std::map const& settings)
+ {
for (auto p : settings) {
QTextEdit* widget = new QTextEdit(this);
widget->append(p.second.toString());
@@ -56,29 +58,30 @@ public:
private slots:
- void on_discardBtn_clicked() {
+ void on_discardBtn_clicked()
+ {
m_Result = Result::DISCARD;
this->accept();
}
- void on_applyBtn_clicked() {
+ void on_applyBtn_clicked()
+ {
m_Result = Result::APPLY;
this->accept();
}
- void on_moveBtn_clicked() {
+ void on_moveBtn_clicked()
+ {
m_Result = Result::MOVE;
this->accept();
}
- void on_cancelBtn_clicked() {
- this->reject();
- }
+ void on_cancelBtn_clicked() { this->reject(); }
private:
std::unique_ptr ui;
- Result m_Result{ Result::APPLY };
+ Result m_Result{Result::APPLY};
};
-#endif
\ No newline at end of file
+#endif
diff --git a/src/installer_fomod_predialog.h b/src/installer_fomod_predialog.h
index 3903c68..4c5dbd3 100644
--- a/src/installer_fomod_predialog.h
+++ b/src/installer_fomod_predialog.h
@@ -7,7 +7,6 @@
#include
-
/**
* @brief Dialog for the installation of a simple archive
* a simple archive is one that doesn't require any manual changes to work correctly
@@ -23,13 +22,16 @@ public:
* @param preset suggested name for the mod
* @param parent parent widget
**/
- explicit InstallerFomodPredialog(const MOBase::GuessedValue& preset, QWidget* parent = 0) :
- QDialog(parent), ui(new Ui::FomodCSharpPredialog), m_Manual(false) {
+ explicit InstallerFomodPredialog(const MOBase::GuessedValue& preset,
+ QWidget* parent = 0)
+ : QDialog(parent), ui(new Ui::FomodCSharpPredialog), m_Manual(false)
+ {
ui->setupUi(this);
setWindowTitle(preset + " - " + windowTitle());
- for (auto iter = preset.variants().begin(); iter != preset.variants().end(); ++iter) {
+ for (auto iter = preset.variants().begin(); iter != preset.variants().end();
+ ++iter) {
ui->nameCombo->addItem(*iter);
}
@@ -38,7 +40,7 @@ public:
ui->nameCombo->completer()->setCaseSensitivity(Qt::CaseSensitive);
}
- ~InstallerFomodPredialog() { }
+ ~InstallerFomodPredialog() {}
/**
* @return true if the user requested a manual installation.
@@ -52,15 +54,12 @@ public:
private slots:
- void on_okBtn_clicked() {
- this->accept();
- }
+ void on_okBtn_clicked() { this->accept(); }
- void on_cancelBtn_clicked() {
- this->reject();
- }
+ void on_cancelBtn_clicked() { this->reject(); }
- void on_manualBtn_clicked() {
+ void on_manualBtn_clicked()
+ {
m_Manual = true;
this->reject();
}
@@ -70,4 +69,4 @@ private:
bool m_Manual;
};
-#endif
\ No newline at end of file
+#endif
diff --git a/src/psettings.h b/src/psettings.h
index 7319c1a..649c7da 100644
--- a/src/psettings.h
+++ b/src/psettings.h
@@ -1,9 +1,9 @@
#ifndef PSETTINGS_H
#define PSETTINGS_H
-#include