mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-07-01 19:03:36 +00:00
CExportGameDialog: Make use of in-class initializers where applicable
This commit is contained in:
parent
fea1c4e115
commit
c4b29106f1
@ -20,25 +20,17 @@
|
|||||||
|
|
||||||
CExportGameDialog::CExportGameDialog(const QString& rkIsoPath, const QString& rkExportDir, QWidget *pParent /*= 0*/)
|
CExportGameDialog::CExportGameDialog(const QString& rkIsoPath, const QString& rkExportDir, QWidget *pParent /*= 0*/)
|
||||||
: QDialog(pParent)
|
: QDialog(pParent)
|
||||||
, mpUI(new Ui::CExportGameDialog)
|
, mpUI(std::make_unique<Ui::CExportGameDialog>())
|
||||||
, mpDisc(nullptr)
|
|
||||||
, mpExporter(nullptr)
|
|
||||||
, mDiscType(EDiscType::Normal)
|
|
||||||
, mGame(EGame::Invalid)
|
|
||||||
, mRegion(ERegion::Unknown)
|
|
||||||
, mBuildVer(0.f)
|
|
||||||
, mWiiFrontend(false)
|
|
||||||
, mExportSuccess(false)
|
|
||||||
{
|
{
|
||||||
mpUI->setupUi(this);
|
mpUI->setupUi(this);
|
||||||
|
|
||||||
// Set up disc
|
// Set up disc
|
||||||
mpDisc = nod::OpenDiscFromImage(QStringToNodString(rkIsoPath)).release();
|
mpDisc = nod::OpenDiscFromImage(QStringToNodString(rkIsoPath));
|
||||||
|
|
||||||
if (ValidateGame())
|
if (ValidateGame())
|
||||||
{
|
{
|
||||||
mBuildVer = FindBuildVersion();
|
mBuildVer = FindBuildVersion();
|
||||||
mpExporter = new CGameExporter(mDiscType, mGame, mWiiFrontend, mRegion, mGameTitle, mGameID, mBuildVer);
|
mpExporter = std::make_unique<CGameExporter>(mDiscType, mGame, mWiiFrontend, mRegion, mGameTitle, mGameID, mBuildVer);
|
||||||
InitUI(rkExportDir);
|
InitUI(rkExportDir);
|
||||||
|
|
||||||
TString IsoName = TO_TSTRING(rkIsoPath).GetFileName();
|
TString IsoName = TO_TSTRING(rkIsoPath).GetFileName();
|
||||||
@ -46,17 +38,11 @@ CExportGameDialog::CExportGameDialog(const QString& rkIsoPath, const QString& rk
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete mpDisc;
|
|
||||||
mpDisc = nullptr;
|
mpDisc = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CExportGameDialog::~CExportGameDialog()
|
CExportGameDialog::~CExportGameDialog() = default;
|
||||||
{
|
|
||||||
delete mpUI;
|
|
||||||
delete mpDisc;
|
|
||||||
delete mpExporter;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RecursiveAddToTree(const nod::Node *pkNode, QTreeWidgetItem *pParent);
|
void RecursiveAddToTree(const nod::Node *pkNode, QTreeWidgetItem *pParent);
|
||||||
|
|
||||||
@ -457,7 +443,7 @@ void CExportGameDialog::Export()
|
|||||||
StrExportDir.EnsureEndsWith('/');
|
StrExportDir.EnsureEndsWith('/');
|
||||||
|
|
||||||
CProgressDialog Dialog("Creating new game project", false, true, parentWidget());
|
CProgressDialog Dialog("Creating new game project", false, true, parentWidget());
|
||||||
QFuture<bool> Future = QtConcurrent::run(mpExporter, &CGameExporter::Export, mpDisc, StrExportDir, &NameMap, &GameInfo, &Dialog);
|
QFuture<bool> Future = QtConcurrent::run(mpExporter.get(), &CGameExporter::Export, mpDisc.get(), StrExportDir, &NameMap, &GameInfo, &Dialog);
|
||||||
mExportSuccess = Dialog.WaitForResults(Future);
|
mExportSuccess = Dialog.WaitForResults(Future);
|
||||||
|
|
||||||
if (!mExportSuccess)
|
if (!mExportSuccess)
|
||||||
@ -466,5 +452,7 @@ void CExportGameDialog::Export()
|
|||||||
UICommon::ErrorMsg(this, "Export failed!");
|
UICommon::ErrorMsg(this, "Export failed!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
mNewProjectPath = TO_QSTRING(mpExporter->ProjectPath());
|
mNewProjectPath = TO_QSTRING(mpExporter->ProjectPath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <nod/DiscBase.hpp>
|
#include <nod/DiscBase.hpp>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class CExportGameDialog;
|
class CExportGameDialog;
|
||||||
@ -16,25 +17,25 @@ class CExportGameDialog : public QDialog
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Ui::CExportGameDialog *mpUI;
|
std::unique_ptr<Ui::CExportGameDialog> mpUI;
|
||||||
nod::DiscBase *mpDisc;
|
std::unique_ptr<nod::DiscBase> mpDisc;
|
||||||
CGameExporter *mpExporter;
|
std::unique_ptr<CGameExporter> mpExporter;
|
||||||
|
|
||||||
TString mGameTitle;
|
TString mGameTitle;
|
||||||
TString mGameID;
|
TString mGameID;
|
||||||
|
|
||||||
// Build Info
|
// Build Info
|
||||||
EDiscType mDiscType;
|
EDiscType mDiscType{EDiscType::Normal};
|
||||||
EGame mGame;
|
EGame mGame{EGame::Invalid};
|
||||||
ERegion mRegion;
|
ERegion mRegion{ERegion::Unknown};
|
||||||
float mBuildVer;
|
float mBuildVer = 0.0f;
|
||||||
bool mWiiFrontend;
|
bool mWiiFrontend = false;
|
||||||
|
|
||||||
bool mExportSuccess;
|
bool mExportSuccess = false;
|
||||||
QString mNewProjectPath;
|
QString mNewProjectPath;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CExportGameDialog(const QString& rkIsoPath, const QString& rkExportDir, QWidget *pParent = 0);
|
explicit CExportGameDialog(const QString& rkIsoPath, const QString& rkExportDir, QWidget *pParent = nullptr);
|
||||||
~CExportGameDialog();
|
~CExportGameDialog();
|
||||||
|
|
||||||
void InitUI(QString ExportDir);
|
void InitUI(QString ExportDir);
|
||||||
@ -46,9 +47,9 @@ public:
|
|||||||
void RecursiveAddToTree(const nod::Node *pkNode, class QTreeWidgetItem *pParent);
|
void RecursiveAddToTree(const nod::Node *pkNode, class QTreeWidgetItem *pParent);
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
inline bool HasValidDisc() const { return mpDisc != nullptr; }
|
bool HasValidDisc() const { return mpDisc != nullptr; }
|
||||||
inline bool ExportSucceeded() const { return mExportSuccess; }
|
bool ExportSucceeded() const { return mExportSuccess; }
|
||||||
inline QString ProjectPath() const { return mNewProjectPath; }
|
QString ProjectPath() const { return mNewProjectPath; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void BrowseOutputDirectory();
|
void BrowseOutputDirectory();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user