diff --git a/src/Editor/CEditorApplication.h b/src/Editor/CEditorApplication.h index 0a0c7bbb..cfc6f672 100644 --- a/src/Editor/CEditorApplication.h +++ b/src/Editor/CEditorApplication.h @@ -33,7 +33,8 @@ class CEditorApplication : public QApplication public: CEditorApplication(int& rArgc, char **ppArgv); - ~CEditorApplication(); + ~CEditorApplication() override; + void InitEditor(); bool CloseAllEditors(); bool CloseProject(); diff --git a/src/Editor/CErrorLogDialog.cpp b/src/Editor/CErrorLogDialog.cpp index 8d5886c5..16000b13 100644 --- a/src/Editor/CErrorLogDialog.cpp +++ b/src/Editor/CErrorLogDialog.cpp @@ -5,16 +5,13 @@ CErrorLogDialog::CErrorLogDialog(QWidget *pParent) : QDialog(pParent) - , ui(new Ui::CErrorLogDialog) + , ui(std::make_unique()) { ui->setupUi(this); connect(ui->CloseButton, SIGNAL(clicked()), this, SLOT(close())); } -CErrorLogDialog::~CErrorLogDialog() -{ - delete ui; -} +CErrorLogDialog::~CErrorLogDialog() = default; bool CErrorLogDialog::GatherErrors() { diff --git a/src/Editor/CErrorLogDialog.h b/src/Editor/CErrorLogDialog.h index 71c84a56..1067d754 100644 --- a/src/Editor/CErrorLogDialog.h +++ b/src/Editor/CErrorLogDialog.h @@ -3,6 +3,8 @@ #include +#include + namespace Ui { class CErrorLogDialog; } @@ -12,12 +14,13 @@ class CErrorLogDialog : public QDialog Q_OBJECT public: - explicit CErrorLogDialog(QWidget *pParent = 0); - ~CErrorLogDialog(); + explicit CErrorLogDialog(QWidget *pParent = nullptr); + ~CErrorLogDialog() override; + bool GatherErrors(); private: - Ui::CErrorLogDialog *ui; + std::unique_ptr ui; }; #endif // CERRORLOGDIALOG_H diff --git a/src/Editor/CExportGameDialog.h b/src/Editor/CExportGameDialog.h index 88d7b267..abaf96a7 100644 --- a/src/Editor/CExportGameDialog.h +++ b/src/Editor/CExportGameDialog.h @@ -36,7 +36,7 @@ class CExportGameDialog : public QDialog public: explicit CExportGameDialog(const QString& rkIsoPath, const QString& rkExportDir, QWidget *pParent = nullptr); - ~CExportGameDialog(); + ~CExportGameDialog() override; void InitUI(QString ExportDir); bool ValidateGame(); diff --git a/src/Editor/CFileNameValidator.h b/src/Editor/CFileNameValidator.h index 68556dc2..2e078081 100644 --- a/src/Editor/CFileNameValidator.h +++ b/src/Editor/CFileNameValidator.h @@ -11,12 +11,12 @@ class CFileNameValidator : public QValidator bool mIsDirectory; public: - CFileNameValidator(bool IsDirectory, QObject *pParent = 0) + CFileNameValidator(bool IsDirectory, QObject *pParent = nullptr) : QValidator(pParent) , mIsDirectory(IsDirectory) {} - QValidator::State validate(QString& rInput, int&) const + QValidator::State validate(QString& rInput, int&) const override { QValidator::State Out = QValidator::Acceptable; @@ -41,9 +41,9 @@ public: return Out; } - void fixup(QString& rInput) const + void fixup(QString& rInput) const override { - TString Sanitized = FileUtil::SanitizeName( TO_TSTRING(rInput), mIsDirectory ); + const TString Sanitized = FileUtil::SanitizeName(TO_TSTRING(rInput), mIsDirectory); rInput = TO_QSTRING(Sanitized); } }; diff --git a/src/Editor/CGeneratePropertyNamesDialog.h b/src/Editor/CGeneratePropertyNamesDialog.h index 26821dbf..96476cf3 100644 --- a/src/Editor/CGeneratePropertyNamesDialog.h +++ b/src/Editor/CGeneratePropertyNamesDialog.h @@ -59,7 +59,7 @@ class CGeneratePropertyNamesDialog : public QDialog public: explicit CGeneratePropertyNamesDialog(QWidget *pParent = nullptr); - ~CGeneratePropertyNamesDialog(); + ~CGeneratePropertyNamesDialog() override; /** Add a property to the ID pool */ void AddToIDPool(IProperty* pProperty); diff --git a/src/Editor/CGridRenderable.h b/src/Editor/CGridRenderable.h index c1cb3243..d4d3fd56 100644 --- a/src/Editor/CGridRenderable.h +++ b/src/Editor/CGridRenderable.h @@ -7,27 +7,24 @@ // Tiny helper to make sure the grid draws at the correct depth. class CGridRenderable : public IRenderable { - CColor mLineColor; - CColor mBoldLineColor; + CColor mLineColor{0.6f, 0.6f, 0.6f, 0.f}; + CColor mBoldLineColor{0.f, 0.f, 0.f, 0.f}; public: - CGridRenderable() - : mLineColor(0.6f, 0.6f, 0.6f, 0.f) - , mBoldLineColor(0.f, 0.f, 0.f, 0.f) - {} + CGridRenderable() = default; - inline void SetColor(const CColor& rkLineColor, const CColor& rkBoldColor) + void SetColor(const CColor& rkLineColor, const CColor& rkBoldColor) { mLineColor = rkLineColor; mBoldLineColor = rkBoldColor; } - void AddToRenderer(CRenderer *pRenderer, const SViewInfo&) + void AddToRenderer(CRenderer *pRenderer, const SViewInfo&) override { pRenderer->AddMesh(this, 0, CAABox::One(), false, ERenderCommand::DrawMesh); } - void Draw(FRenderOptions, int, ERenderCommand, const SViewInfo&) + void Draw(FRenderOptions, int, ERenderCommand, const SViewInfo&) override { CDrawUtil::DrawGrid(mLineColor, mBoldLineColor); } diff --git a/src/Editor/CLineRenderable.h b/src/Editor/CLineRenderable.h index e9e81037..f1ba4d9b 100644 --- a/src/Editor/CLineRenderable.h +++ b/src/Editor/CLineRenderable.h @@ -7,31 +7,33 @@ #include #include +#include + class CLineRenderable : public IRenderable { - CVector3f mPoints[2]; + std::array mPoints; CColor mColor; public: CLineRenderable() : IRenderable() {} - inline void SetPoints(const CVector3f& rkPointA, const CVector3f& rkPointB) + void SetPoints(const CVector3f& rkPointA, const CVector3f& rkPointB) { mPoints[0] = rkPointA; mPoints[1] = rkPointB; } - inline void SetColor(const CColor& rkColor) + void SetColor(const CColor& rkColor) { mColor = rkColor; } - void AddToRenderer(CRenderer *pRenderer, const SViewInfo& /*rkViewInfo*/) + void AddToRenderer(CRenderer *pRenderer, const SViewInfo& /*rkViewInfo*/) override { pRenderer->AddMesh(this, -1, CAABox::Infinite(), false, ERenderCommand::DrawMesh); } - void Draw(FRenderOptions, int, ERenderCommand, const SViewInfo&) + void Draw(FRenderOptions, int, ERenderCommand, const SViewInfo&) override { CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity; CGraphics::UpdateMVPBlock(); diff --git a/src/Editor/CNodeSelection.h b/src/Editor/CNodeSelection.h index d9b6f063..1f4f0893 100644 --- a/src/Editor/CNodeSelection.h +++ b/src/Editor/CNodeSelection.h @@ -11,18 +11,16 @@ class CNodeSelection : public QObject { Q_OBJECT - FNodeFlags mAllowedNodes; + FNodeFlags mAllowedNodes{ENodeType::All}; QList mSelectedNodes; mutable CAABox mCachedBounds; - mutable bool mBoundsDirty; + mutable bool mBoundsDirty = true; public: - CNodeSelection() - : mAllowedNodes(ENodeType::All) - , mBoundsDirty(true) {} + CNodeSelection() = default; - ~CNodeSelection() + ~CNodeSelection() override { foreach (CSceneNode *pNode, mSelectedNodes) pNode->SetSelected(false); @@ -107,17 +105,17 @@ public: return mCachedBounds; } - inline uint32 Size() const { return mSelectedNodes.size(); } - inline bool IsEmpty() const { return Size() == 0; } - inline CSceneNode* At(uint32 Index) const { return mSelectedNodes[Index]; } - inline CSceneNode* Front() const { return mSelectedNodes.front(); } - inline CSceneNode* Back() const { return mSelectedNodes.back(); } - inline CSceneNode* operator[](uint32 Index) const { return mSelectedNodes[Index]; } - inline void UpdateBounds() { mBoundsDirty = true; } - inline void SetAllowedNodeTypes(FNodeFlags Types) { mAllowedNodes = Types; } - inline bool IsAllowedType(ENodeType Type) const { return (mAllowedNodes & Type) != 0; } - inline bool IsAllowedType(CSceneNode *pNode) const { return (mAllowedNodes & pNode->NodeType()) != 0; } - inline QList SelectedNodeList() const { return mSelectedNodes; } + uint32 Size() const { return mSelectedNodes.size(); } + bool IsEmpty() const { return Size() == 0; } + CSceneNode* At(uint32 Index) const { return mSelectedNodes[Index]; } + CSceneNode* Front() const { return mSelectedNodes.front(); } + CSceneNode* Back() const { return mSelectedNodes.back(); } + CSceneNode* operator[](uint32 Index) const { return mSelectedNodes[Index]; } + void UpdateBounds() { mBoundsDirty = true; } + void SetAllowedNodeTypes(FNodeFlags Types) { mAllowedNodes = Types; } + bool IsAllowedType(ENodeType Type) const { return (mAllowedNodes & Type) != 0; } + bool IsAllowedType(CSceneNode *pNode) const { return (mAllowedNodes & pNode->NodeType()) != 0; } + QList SelectedNodeList() const { return mSelectedNodes; } signals: void Modified(); diff --git a/src/Editor/CProgressBarNotifier.h b/src/Editor/CProgressBarNotifier.h index 538a58c5..26008d97 100644 --- a/src/Editor/CProgressBarNotifier.h +++ b/src/Editor/CProgressBarNotifier.h @@ -9,36 +9,32 @@ class CProgressBarNotifier : public IProgressNotifier { /** The progress bar we are relaying updates to */ - QProgressBar* mpProgressBar; + QProgressBar* mpProgressBar = nullptr; /** Whether the user has requested to cancel */ - bool mCancel; + bool mCancel = false; public: - CProgressBarNotifier() - : IProgressNotifier() - , mpProgressBar(nullptr) - , mCancel(false) - {} + CProgressBarNotifier() = default; - inline void SetProgressBar(QProgressBar* pProgressBar) + void SetProgressBar(QProgressBar* pProgressBar) { mpProgressBar = pProgressBar; } - inline void SetCanceled(bool ShouldCancel) + void SetCanceled(bool ShouldCancel) { mCancel = ShouldCancel; } /** IProgressNotifier interface */ - virtual bool ShouldCancel() const + bool ShouldCancel() const override { return mCancel; } protected: - virtual void UpdateProgress(const TString &, const TString &, float ProgressPercent) + void UpdateProgress(const TString &, const TString &, float ProgressPercent) override { if (mpProgressBar) { diff --git a/src/Editor/CProgressDialog.h b/src/Editor/CProgressDialog.h index e47ea494..fe107b11 100644 --- a/src/Editor/CProgressDialog.h +++ b/src/Editor/CProgressDialog.h @@ -36,7 +36,7 @@ class CProgressDialog : public IProgressNotifierUI public: explicit CProgressDialog(QString OperationName, bool UseBusyIndicator, bool AlertOnFinish, QWidget *pParent = nullptr); - ~CProgressDialog(); + ~CProgressDialog() override; void DisallowCanceling(); diff --git a/src/Editor/CPropertyNameValidator.h b/src/Editor/CPropertyNameValidator.h index 3e4d20c1..ab3876a2 100644 --- a/src/Editor/CPropertyNameValidator.h +++ b/src/Editor/CPropertyNameValidator.h @@ -16,10 +16,10 @@ class CPropertyNameValidator : public QValidator QString mTypeNameOverride; public: - CPropertyNameValidator(QObject* pParent = 0); + explicit CPropertyNameValidator(QObject* pParent = nullptr); /** Perform validation */ - QValidator::State validate(QString& rInput, int& rPos) const; + QValidator::State validate(QString& rInput, int& rPos) const override; public slots: /** Set the property to validate against */ diff --git a/src/Editor/CUIRelay.h b/src/Editor/CUIRelay.h index 6c4b8ca0..9aea33fb 100644 --- a/src/Editor/CUIRelay.h +++ b/src/Editor/CUIRelay.h @@ -12,34 +12,34 @@ class CUIRelay : public QObject, public IUIRelay { Q_OBJECT - Qt::ConnectionType GetConnectionType() + Qt::ConnectionType GetConnectionType() const { - bool IsUIThread = (QThread::currentThread() == gpEdApp->thread()); + const bool IsUIThread = (QThread::currentThread() == gpEdApp->thread()); return IsUIThread ? Qt::DirectConnection : Qt::BlockingQueuedConnection; } public: - explicit CUIRelay(QObject *pParent = 0) + explicit CUIRelay(QObject *pParent = nullptr) : QObject(pParent) {} // Note: All function calls should be deferred with QMetaObject::invokeMethod to ensure // that they run on the UI thread instead of whatever thread we happen to be on. - virtual void ShowMessageBox(const TString& rkInfoBoxTitle, const TString& rkMessage) + void ShowMessageBox(const TString& rkInfoBoxTitle, const TString& rkMessage) override { QMetaObject::invokeMethod(this, "MessageBoxSlot", GetConnectionType(), Q_ARG(QString, TO_QSTRING(rkInfoBoxTitle)), Q_ARG(QString, TO_QSTRING(rkMessage)) ); } - virtual void ShowMessageBoxAsync(const TString& rkInfoBoxTitle, const TString& rkMessage) + void ShowMessageBoxAsync(const TString& rkInfoBoxTitle, const TString& rkMessage) override { QMetaObject::invokeMethod(this, "MessageBoxSlot", Qt::QueuedConnection, Q_ARG(QString, TO_QSTRING(rkInfoBoxTitle)), Q_ARG(QString, TO_QSTRING(rkMessage)) ); } - virtual bool AskYesNoQuestion(const TString& rkInfoBoxTitle, const TString& rkQuestion) + bool AskYesNoQuestion(const TString& rkInfoBoxTitle, const TString& rkQuestion) override { bool RetVal; QMetaObject::invokeMethod(this, "AskYesNoQuestionSlot", GetConnectionType(), @@ -49,7 +49,7 @@ public: return RetVal; } - virtual bool OpenProject(const TString& kPath = "") + bool OpenProject(const TString& kPath = "") override { bool RetVal; QMetaObject::invokeMethod(this, "OpenProjectSlot", GetConnectionType(), diff --git a/src/Editor/CharacterEditor/CCharacterEditor.h b/src/Editor/CharacterEditor/CCharacterEditor.h index aeb0993f..c03d33c5 100644 --- a/src/Editor/CharacterEditor/CCharacterEditor.h +++ b/src/Editor/CharacterEditor/CCharacterEditor.h @@ -43,15 +43,16 @@ class CCharacterEditor : public IEditor public: explicit CCharacterEditor(CAnimSet *pSet, QWidget *parent = nullptr); - ~CCharacterEditor(); - void EditorTick(float DeltaTime); + ~CCharacterEditor() override; + + void EditorTick(float DeltaTime) override; void UpdateAnimTime(float DeltaTime); void UpdateCameraOrbit(); CSkeleton* CurrentSkeleton() const; CAnimation* CurrentAnimation() const; void SetActiveAnimSet(CAnimSet *pSet); void SetSelectedBone(CBone *pBone); - CCharacterEditorViewport* Viewport() const; + CCharacterEditorViewport* Viewport() const override; public slots: void ToggleGrid(bool Enable); diff --git a/src/Editor/CharacterEditor/CCharacterEditorViewport.h b/src/Editor/CharacterEditor/CCharacterEditorViewport.h index 60d7e634..3468be04 100644 --- a/src/Editor/CharacterEditor/CCharacterEditorViewport.h +++ b/src/Editor/CharacterEditor/CCharacterEditorViewport.h @@ -18,7 +18,8 @@ class CCharacterEditorViewport : public CBasicViewport public: explicit CCharacterEditorViewport(QWidget* pParent = nullptr); - ~CCharacterEditorViewport(); + ~CCharacterEditorViewport() override; + void SetNode(CCharacterNode *pNode); void CheckUserInput() override; void Paint() override; diff --git a/src/Editor/IProgressNotifierUI.h b/src/Editor/IProgressNotifierUI.h index 5651edb4..48f8b847 100644 --- a/src/Editor/IProgressNotifierUI.h +++ b/src/Editor/IProgressNotifierUI.h @@ -9,7 +9,7 @@ class IProgressNotifierUI : public QDialog, public IProgressNotifier { public: - explicit IProgressNotifierUI(QWidget *pParent = 0) + explicit IProgressNotifierUI(QWidget *pParent = nullptr) : QDialog(pParent) {} @@ -17,7 +17,7 @@ public slots: virtual void UpdateUI(const QString& rkTaskDesc, const QString& rkStepDesc, float ProgressPercent) = 0; private: - virtual void UpdateProgress(const TString& rkTaskDesc, const TString& rkStepDesc, float ProgressPercent) final + void UpdateProgress(const TString& rkTaskDesc, const TString& rkStepDesc, float ProgressPercent) final { // Defer the function call to make sure UI updates are done on the main thread QMetaObject::invokeMethod(this, "UpdateUI", Qt::AutoConnection, diff --git a/src/Editor/TestDialog.cpp b/src/Editor/TestDialog.cpp index 3cbc5d1f..469ed439 100644 --- a/src/Editor/TestDialog.cpp +++ b/src/Editor/TestDialog.cpp @@ -5,7 +5,7 @@ TestDialog::TestDialog(QWidget *pParent) : QDialog(pParent) - , ui(new Ui::TestDialog) + , ui(std::make_unique()) { ui->setupUi(this); connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(OnSpinBoxChanged(int))); @@ -13,10 +13,7 @@ TestDialog::TestDialog(QWidget *pParent) connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(OnFind())); } -TestDialog::~TestDialog() -{ - delete ui; -} +TestDialog::~TestDialog() = default; void TestDialog::OnSpinBoxChanged(int NewValue) { diff --git a/src/Editor/TestDialog.h b/src/Editor/TestDialog.h index 82256027..6999205c 100644 --- a/src/Editor/TestDialog.h +++ b/src/Editor/TestDialog.h @@ -3,6 +3,8 @@ #include +#include + namespace Ui { class TestDialog; } @@ -12,15 +14,15 @@ class TestDialog : public QDialog Q_OBJECT public: - explicit TestDialog(QWidget *pParent = 0); - ~TestDialog(); + explicit TestDialog(QWidget *pParent = nullptr); + ~TestDialog() override; public slots: void OnSpinBoxChanged(int NewValue); void OnFind(); private: - Ui::TestDialog *ui; + std::unique_ptr ui; }; #endif // TESTDIALOG_H diff --git a/src/Editor/WorldEditor/CStateMessageModel.h b/src/Editor/WorldEditor/CStateMessageModel.h index e6758d64..e96a62ba 100644 --- a/src/Editor/WorldEditor/CStateMessageModel.h +++ b/src/Editor/WorldEditor/CStateMessageModel.h @@ -21,10 +21,10 @@ public: private: struct SEntry { - uint32 ID; + uint32 ID = 0; QString Name; - SEntry() {} + SEntry() = default; SEntry(uint32 _ID, const QString& rkName) : ID(_ID), Name(rkName) {} @@ -35,31 +35,29 @@ private: }; QList mEntries; - CGameTemplate *mpGame; - CScriptTemplate *mpScript; + CGameTemplate *mpGame = nullptr; + CScriptTemplate *mpScript = nullptr; EType mType; public: - explicit CStateMessageModel(EType Type, QObject *pParent = 0) + explicit CStateMessageModel(EType Type, QObject *pParent = nullptr) : QAbstractListModel(pParent) , mType(Type) - , mpGame(nullptr) - , mpScript(nullptr) {} - int rowCount(const QModelIndex& /*rkParent*/) const + int rowCount(const QModelIndex& /*rkParent*/) const override { return mEntries.size(); } - QVariant data(const QModelIndex& rkIndex, int Role) const + QVariant data(const QModelIndex& rkIndex, int Role) const override { if (Role == Qt::DisplayRole) { return mEntries[rkIndex.row()].Name; } - else return QVariant::Invalid; + return QVariant::Invalid; } void SetGameTemplate(CGameTemplate *pGame) @@ -101,7 +99,7 @@ public: return iState; } - return -1; + return UINT32_MAX; } uint32 MessageIndex(uint32 MessageID) const @@ -114,20 +112,20 @@ public: return iMsg; } - return -1; + return UINT32_MAX; } - inline void SetScriptTemplate(CScriptTemplate *pScript) + void SetScriptTemplate(CScriptTemplate *pScript) { mpScript = pScript; } - inline uint32 State(uint32 Index) const + uint32 State(uint32 Index) const { return (mType == EType::States ? mEntries[Index].ID : 0); } - inline uint32 Message(uint32 Index) const + uint32 Message(uint32 Index) const { return (mType == EType::Messages ? mEntries[Index].ID : 0); }