From 4df036a837b749f3beba98b5fbc6d372199e628e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 28 Jun 2020 06:20:29 -0400 Subject: [PATCH] CWorldEditor: Make use of in-class initializers where applicable --- src/Editor/WorldEditor/CWorldEditor.cpp | 8 +----- src/Editor/WorldEditor/CWorldEditor.h | 38 ++++++++++++++----------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/Editor/WorldEditor/CWorldEditor.cpp b/src/Editor/WorldEditor/CWorldEditor.cpp index 6db2143d..3f70375f 100644 --- a/src/Editor/WorldEditor/CWorldEditor.cpp +++ b/src/Editor/WorldEditor/CWorldEditor.cpp @@ -37,15 +37,10 @@ CWorldEditor::CWorldEditor(QWidget *parent) : INodeEditor(parent) - , ui(new Ui::CWorldEditor) - , mpArea(nullptr) - , mpWorld(nullptr) + , ui(std::make_unique()) , mpLinkDialog(new CLinkDialog(this, this)) , mpGeneratePropertyNamesDialog(new CGeneratePropertyNamesDialog(this)) , mpTweakEditor(new CTweakEditor(this)) - , mIsMakingLink(false) - , mpNewLinkSender(nullptr) - , mpNewLinkReceiver(nullptr) { debugf("Creating World Editor"); ui->setupUi(this); @@ -226,7 +221,6 @@ CWorldEditor::~CWorldEditor() gpResourceStore->DestroyUnreferencedResources(); // this should destroy the area! delete mpScriptSidebar; // For some reason WCreateTab filters an event during the viewport's destructor - delete ui; } bool CWorldEditor::CloseWorld() diff --git a/src/Editor/WorldEditor/CWorldEditor.h b/src/Editor/WorldEditor/CWorldEditor.h index 06e440b9..084ca10f 100644 --- a/src/Editor/WorldEditor/CWorldEditor.h +++ b/src/Editor/WorldEditor/CWorldEditor.h @@ -33,6 +33,9 @@ #include #include +#include +#include + namespace Ui { class CWorldEditor; } @@ -47,11 +50,11 @@ enum EWorldEditorMode class CWorldEditor : public INodeEditor { Q_OBJECT - static const int mskMaxRecentProjects = 10; + static constexpr int mskMaxRecentProjects = 10; - Ui::CWorldEditor* ui; + std::unique_ptr ui; QMenu* mpOpenRecentMenu; - QAction* mRecentProjectsActions[ mskMaxRecentProjects ]; + std::array mRecentProjectsActions; TResPtr mpWorld; TResPtr mpArea; @@ -61,9 +64,9 @@ class CWorldEditor : public INodeEditor CGeneratePropertyNamesDialog* mpGeneratePropertyNamesDialog; CTweakEditor* mpTweakEditor; - bool mIsMakingLink; - CScriptObject* mpNewLinkSender; - CScriptObject* mpNewLinkReceiver; + bool mIsMakingLink = false; + CScriptObject* mpNewLinkSender = nullptr; + CScriptObject* mpNewLinkReceiver = nullptr; // Quickplay QAction* mpQuickplayAction; @@ -81,27 +84,28 @@ class CWorldEditor : public INodeEditor QAction* mpPoiMapAction; public: - explicit CWorldEditor(QWidget *parent = 0); - ~CWorldEditor(); + explicit CWorldEditor(QWidget *parent = nullptr); + ~CWorldEditor() override; + bool CloseWorld(); bool SetArea(CWorld *pWorld, int AreaIndex); void ResetCamera(); bool HasAnyScriptNodesSelected() const; bool IsQuickplayEnabled() const; - inline CWorld* ActiveWorld() const { return mpWorld; } - inline CGameArea* ActiveArea() const { return mpArea; } - inline EGame CurrentGame() const { return gpEdApp->CurrentGame(); } - inline CLinkDialog* LinkDialog() const { return mpLinkDialog; } - inline CGeneratePropertyNamesDialog* NameGeneratorDialog() const { return mpGeneratePropertyNamesDialog; } - inline CTweakEditor* TweakEditor() { return mpTweakEditor; } + CWorld* ActiveWorld() const { return mpWorld; } + CGameArea* ActiveArea() const { return mpArea; } + EGame CurrentGame() const { return gpEdApp->CurrentGame(); } + CLinkDialog* LinkDialog() const { return mpLinkDialog; } + CGeneratePropertyNamesDialog* NameGeneratorDialog() const { return mpGeneratePropertyNamesDialog; } + CTweakEditor* TweakEditor() { return mpTweakEditor; } CResourceBrowser* ResourceBrowser() const; CSceneViewport* Viewport() const override; public slots: - virtual void EditorTick(float) override; - virtual void NotifyNodeAboutToBeDeleted(CSceneNode *pNode) override; - virtual bool Save() override; + void EditorTick(float) override; + void NotifyNodeAboutToBeDeleted(CSceneNode *pNode) override; + bool Save() override; void Cut(); void Copy();