mirror of
https://github.com/ModOrganizer2/modorganizer-tool_inibakery.git
synced 2026-07-27 14:04:35 -07:00
Add pre-commit hook. (#19)
This commit is contained in:
@@ -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']
|
||||
@@ -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 @@
|
||||
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
|
||||
+12
-13
@@ -2,25 +2,25 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <QFile>
|
||||
#include <QCoreApplication>
|
||||
#include <QFile>
|
||||
#include <QStringList>
|
||||
#include <QtPlugin>
|
||||
|
||||
#include <uibase/iplugingame.h>
|
||||
#include <uibase/game_features/localsavegames.h>
|
||||
#include <uibase/game_features/bsainvalidation.h>
|
||||
#include <uibase/game_features/igamefeatures.h>
|
||||
|
||||
#include <uibase/game_features/localsavegames.h>
|
||||
#include <uibase/iplugingame.h>
|
||||
|
||||
using namespace MOBase;
|
||||
|
||||
|
||||
bool IniBakery::init(MOBase::IOrganizer *moInfo)
|
||||
bool IniBakery::init(MOBase::IOrganizer* moInfo)
|
||||
{
|
||||
using namespace std::placeholders;
|
||||
m_MOInfo = moInfo;
|
||||
m_MOInfo->onAboutToRun([this](const auto& binary) { return prepareIni(binary); });
|
||||
m_MOInfo->onAboutToRun([this](const auto& binary) {
|
||||
return prepareIni(binary);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -77,20 +77,19 @@ bool IniBakery::prepareIni(const QString&)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
MappingType IniBakery::mappings() const
|
||||
{
|
||||
MappingType result;
|
||||
|
||||
const IPluginGame *game = m_MOInfo->managedGame();
|
||||
const IPluginGame* game = m_MOInfo->managedGame();
|
||||
|
||||
IProfile *profile = m_MOInfo->profile();
|
||||
IProfile* profile = m_MOInfo->profile();
|
||||
|
||||
if (profile->localSettingsEnabled()) {
|
||||
for (const QString &iniFile : iniFileNames()) {
|
||||
for (const QString& iniFile : iniFileNames()) {
|
||||
result.push_back({m_MOInfo->profilePath() + "/" + QFileInfo(iniFile).fileName(),
|
||||
game->documentsDirectory().absoluteFilePath(iniFile),
|
||||
false, false});
|
||||
game->documentsDirectory().absoluteFilePath(iniFile), false,
|
||||
false});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-10
@@ -20,9 +20,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include <uibase/iplugin.h>
|
||||
#include <uibase/ipluginfilemapper.h>
|
||||
@@ -30,13 +30,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
/**
|
||||
* @brief The IniBakery class
|
||||
*/
|
||||
class IniBakery : public QObject, public MOBase::IPlugin, public MOBase::IPluginFileMapper {
|
||||
class IniBakery : public QObject,
|
||||
public MOBase::IPlugin,
|
||||
public MOBase::IPluginFileMapper
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginFileMapper)
|
||||
Q_PLUGIN_METADATA(IID "org.tannin.IniBakey")
|
||||
|
||||
public:
|
||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||
virtual bool init(MOBase::IOrganizer* moInfo);
|
||||
virtual QString name() const;
|
||||
virtual QString localizedName() const;
|
||||
virtual QString author() const;
|
||||
@@ -47,13 +50,9 @@ public:
|
||||
virtual MappingType mappings() const;
|
||||
|
||||
private:
|
||||
|
||||
QStringList iniFileNames() const;
|
||||
bool prepareIni(const QString &executable);
|
||||
bool prepareIni(const QString& executable);
|
||||
|
||||
private:
|
||||
|
||||
MOBase::IOrganizer *m_MOInfo;
|
||||
|
||||
MOBase::IOrganizer* m_MOInfo;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user