2017-02-15 08:00:48 +00:00
|
|
|
#include "CProjectSettingsDialog.h"
|
|
|
|
#include "ui_CProjectSettingsDialog.h"
|
2017-02-01 15:43:42 +00:00
|
|
|
#include "CEditorApplication.h"
|
2017-02-06 16:20:18 +00:00
|
|
|
#include "CExportGameDialog.h"
|
2017-05-22 00:01:09 +00:00
|
|
|
#include "CProgressDialog.h"
|
2016-07-08 07:10:07 +00:00
|
|
|
#include "UICommon.h"
|
2016-07-10 12:58:23 +00:00
|
|
|
#include "Editor/ResourceBrowser/CResourceBrowser.h"
|
2016-07-08 07:10:07 +00:00
|
|
|
#include <Common/AssertMacro.h>
|
|
|
|
#include <Core/GameProject/CGameExporter.h>
|
|
|
|
#include <QFileDialog>
|
2017-05-22 00:01:09 +00:00
|
|
|
#include <QFuture>
|
|
|
|
#include <QFutureWatcher>
|
2016-07-08 07:10:07 +00:00
|
|
|
#include <QMessageBox>
|
2017-05-22 00:01:09 +00:00
|
|
|
#include <QtConcurrent/QtConcurrentRun>
|
2016-07-08 07:10:07 +00:00
|
|
|
|
2017-02-15 08:00:48 +00:00
|
|
|
CProjectSettingsDialog::CProjectSettingsDialog(QWidget *pParent)
|
2016-07-08 07:10:07 +00:00
|
|
|
: QDialog(pParent)
|
2017-02-15 08:00:48 +00:00
|
|
|
, mpUI(new Ui::CProjectSettingsDialog)
|
2016-07-08 07:10:07 +00:00
|
|
|
, mpProject(nullptr)
|
|
|
|
{
|
|
|
|
mpUI->setupUi(this);
|
|
|
|
|
2016-08-12 10:27:19 +00:00
|
|
|
connect(mpUI->CookPackageButton, SIGNAL(clicked()), this, SLOT(CookPackage()));
|
2017-02-09 17:54:38 +00:00
|
|
|
connect(mpUI->CookAllDirtyPackagesButton, SIGNAL(clicked(bool)), this, SLOT(CookAllDirtyPackages()));
|
2017-05-21 05:29:09 +00:00
|
|
|
connect(mpUI->BuildIsoButton, SIGNAL(clicked(bool)), this, SLOT(BuildISO()));
|
2017-02-08 18:20:33 +00:00
|
|
|
|
2017-02-12 21:19:51 +00:00
|
|
|
connect(gpEdApp, SIGNAL(ActiveProjectChanged(CGameProject*)), this, SLOT(ActiveProjectChanged(CGameProject*)));
|
2017-02-08 18:20:33 +00:00
|
|
|
connect(gpEdApp, SIGNAL(AssetsModified()), this, SLOT(SetupPackagesList()));
|
2017-05-22 00:01:09 +00:00
|
|
|
connect(gpEdApp, SIGNAL(PackagesCooked()), this, SLOT(SetupPackagesList()));
|
2017-05-21 05:29:09 +00:00
|
|
|
|
|
|
|
// Set build ISO button color
|
|
|
|
QPalette Palette = mpUI->BuildIsoButton->palette();
|
|
|
|
QBrush ButtonBrush = Palette.button();
|
|
|
|
ButtonBrush.setColor( UICommon::kImportantButtonColor );
|
|
|
|
Palette.setBrush(QPalette::Button, ButtonBrush);
|
|
|
|
mpUI->BuildIsoButton->setPalette(Palette);
|
2016-07-08 07:10:07 +00:00
|
|
|
}
|
|
|
|
|
2017-02-15 08:00:48 +00:00
|
|
|
CProjectSettingsDialog::~CProjectSettingsDialog()
|
2016-07-08 07:10:07 +00:00
|
|
|
{
|
|
|
|
delete mpUI;
|
|
|
|
}
|
|
|
|
|
2017-02-15 08:00:48 +00:00
|
|
|
void CProjectSettingsDialog::ActiveProjectChanged(CGameProject *pProj)
|
2017-02-12 21:19:51 +00:00
|
|
|
{
|
|
|
|
mpProject = pProj;
|
2017-02-15 08:00:48 +00:00
|
|
|
|
|
|
|
if (mpProject)
|
|
|
|
{
|
|
|
|
// Set up project info
|
|
|
|
mpUI->ProjectNameLineEdit->setText( TO_QSTRING(pProj->Name()) );
|
|
|
|
mpUI->GameLineEdit->setText( TO_QSTRING(GetGameName(pProj->Game())) );
|
|
|
|
mpUI->GameIdLineEdit->setText( TO_QSTRING(pProj->GameID()) );
|
|
|
|
|
|
|
|
float BuildVer = pProj->BuildVersion();
|
|
|
|
ERegion Region = pProj->Region();
|
|
|
|
TString BuildName = pProj->GameInfo()->GetBuildName(BuildVer, Region);
|
|
|
|
mpUI->BuildLineEdit->setText( QString("%1 (%2)").arg(BuildVer).arg( TO_QSTRING(BuildName) ) );
|
|
|
|
mpUI->RegionLineEdit->setText( TO_QSTRING(GetRegionName(Region)) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Clear project info
|
|
|
|
mpUI->ProjectNameLineEdit->clear();
|
|
|
|
mpUI->GameLineEdit->clear();
|
|
|
|
mpUI->GameIdLineEdit->clear();
|
|
|
|
mpUI->BuildLineEdit->clear();
|
|
|
|
mpUI->RegionLineEdit->clear();
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
2017-05-21 05:29:09 +00:00
|
|
|
mpUI->BuildIsoButton->setEnabled( pProj && !pProj->IsWiiBuild() );
|
2017-02-12 21:19:51 +00:00
|
|
|
SetupPackagesList();
|
|
|
|
}
|
|
|
|
|
2017-02-15 08:00:48 +00:00
|
|
|
void CProjectSettingsDialog::SetupPackagesList()
|
2016-08-12 10:27:19 +00:00
|
|
|
{
|
|
|
|
mpUI->PackagesList->clear();
|
2017-02-13 20:44:02 +00:00
|
|
|
if (!mpProject) return;
|
2016-08-12 10:27:19 +00:00
|
|
|
|
|
|
|
for (u32 iPkg = 0; iPkg < mpProject->NumPackages(); iPkg++)
|
|
|
|
{
|
|
|
|
CPackage *pPackage = mpProject->PackageByIndex(iPkg);
|
|
|
|
ASSERT(pPackage != nullptr);
|
2017-02-08 18:20:33 +00:00
|
|
|
|
|
|
|
QString PackageName = TO_QSTRING(pPackage->Name());
|
|
|
|
if (pPackage->NeedsRecook()) PackageName += '*';
|
|
|
|
mpUI->PackagesList->addItem(PackageName);
|
2016-08-12 10:27:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-15 08:00:48 +00:00
|
|
|
void CProjectSettingsDialog::CookPackage()
|
2016-08-12 10:27:19 +00:00
|
|
|
{
|
|
|
|
u32 PackageIdx = mpUI->PackagesList->currentRow();
|
2017-05-09 20:16:41 +00:00
|
|
|
|
|
|
|
if (PackageIdx != -1)
|
|
|
|
{
|
|
|
|
CPackage *pPackage = mpProject->PackageByIndex(PackageIdx);
|
2017-05-22 00:01:09 +00:00
|
|
|
gpEdApp->CookPackage(pPackage);
|
2017-05-09 20:16:41 +00:00
|
|
|
}
|
2017-02-09 17:54:38 +00:00
|
|
|
}
|
|
|
|
|
2017-02-15 08:00:48 +00:00
|
|
|
void CProjectSettingsDialog::CookAllDirtyPackages()
|
2017-02-09 17:54:38 +00:00
|
|
|
{
|
|
|
|
gpEdApp->CookAllDirtyPackages();
|
2016-08-12 10:27:19 +00:00
|
|
|
}
|
2017-05-21 05:29:09 +00:00
|
|
|
|
|
|
|
void CProjectSettingsDialog::BuildISO()
|
|
|
|
{
|
|
|
|
CGameProject *pProj = gpEdApp->ActiveProject();
|
|
|
|
ASSERT(pProj && !pProj->IsWiiBuild());
|
|
|
|
|
2017-05-22 00:01:09 +00:00
|
|
|
QString DefaultPath = TO_QSTRING( pProj->ProjectRoot() + FileUtil::SanitizeName(pProj->Name(), false) + ".gcm" );
|
2017-05-21 05:29:09 +00:00
|
|
|
QString IsoPath = UICommon::SaveFileDialog(this, "Choose output ISO path", "*.gcm", DefaultPath);
|
|
|
|
|
|
|
|
if (!IsoPath.isEmpty())
|
|
|
|
{
|
2017-05-22 00:01:09 +00:00
|
|
|
if (gpEdApp->CookAllDirtyPackages())
|
|
|
|
{
|
2017-07-04 10:59:22 +00:00
|
|
|
CProgressDialog Dialog("Building ISO", false, true, this);
|
2017-05-22 00:01:09 +00:00
|
|
|
Dialog.DisallowCanceling();
|
|
|
|
QFuture<void> Future = QtConcurrent::run(pProj, &CGameProject::BuildISO, TO_TSTRING(IsoPath), &Dialog);
|
|
|
|
Dialog.WaitForResults(Future);
|
|
|
|
}
|
2017-05-21 05:29:09 +00:00
|
|
|
}
|
|
|
|
}
|