Added preliminary support for building new ISOs

This commit is contained in:
Aruki 2017-05-20 23:29:09 -06:00
parent 4ffd1f0a2d
commit 31621874a6
7 changed files with 68 additions and 1 deletions

View File

@ -2,6 +2,7 @@
#include "Core/Resource/Factory/CTemplateLoader.h"
#include "Core/Resource/Script/CMasterTemplate.h"
#include <Common/Serialization/XML.h>
#include <nod/nod.hpp>
CGameProject::~CGameProject()
{
@ -94,6 +95,30 @@ void CGameProject::Serialize(IArchive& rArc)
}
}
void ProgressDummy(size_t, const nod::SystemString&, size_t) {}
bool CGameProject::BuildISO(const TString& rkIsoPath)
{
ASSERT( FileUtil::IsValidPath(rkIsoPath, false) );
if (IsWiiBuild())
{
Log::Error("Wii ISO building not supported!");
return false;
}
else
{
nod::DiscBuilderGCN *pBuilder = new nod::DiscBuilderGCN(*rkIsoPath.ToUTF16(), *mGameID, *mProjectName, mFilesystemAddress, &ProgressDummy);
TWideString ProjRoot = ProjectRoot().ToUTF16();
TWideString DiscRoot = DiscDir(false).ToUTF16();
TWideString DolPath = ProjRoot + mDolPath.ToUTF16();
TWideString ApploaderPath = ProjRoot + mApploaderPath.ToUTF16();
return pBuilder->buildFromDirectory(*DiscRoot, *DolPath, *ApploaderPath);
}
}
void CGameProject::GetWorldList(std::list<CAssetID>& rOut) const
{
for (u32 iPkg = 0; iPkg < mPackages.size(); iPkg++)

View File

@ -65,6 +65,7 @@ public:
bool Save();
void Serialize(IArchive& rArc);
bool BuildISO(const TString& rkIsoPath);
void GetWorldList(std::list<CAssetID>& rOut) const;
CAssetID FindNamedResource(const TString& rkName) const;
CPackage* FindPackage(const TString& rkName) const;
@ -108,6 +109,7 @@ public:
inline TString GameID() const { return mGameID; }
inline float BuildVersion() const { return mBuildVersion; }
inline bool IsWiiBuild() const { return mBuildVersion >= 3.f; }
inline bool IsTrilogy() const { return mGame <= eCorruption && mBuildVersion >= 3.593f; }
};
#endif // CGAMEPROJECT_H

View File

@ -18,9 +18,17 @@ CProjectSettingsDialog::CProjectSettingsDialog(QWidget *pParent)
connect(mpUI->CookPackageButton, SIGNAL(clicked()), this, SLOT(CookPackage()));
connect(mpUI->CookAllDirtyPackagesButton, SIGNAL(clicked(bool)), this, SLOT(CookAllDirtyPackages()));
connect(mpUI->BuildIsoButton, SIGNAL(clicked(bool)), this, SLOT(BuildISO()));
connect(gpEdApp, SIGNAL(ActiveProjectChanged(CGameProject*)), this, SLOT(ActiveProjectChanged(CGameProject*)));
connect(gpEdApp, SIGNAL(AssetsModified()), this, SLOT(SetupPackagesList()));
// 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);
}
CProjectSettingsDialog::~CProjectSettingsDialog()
@ -56,6 +64,7 @@ void CProjectSettingsDialog::ActiveProjectChanged(CGameProject *pProj)
close();
}
mpUI->BuildIsoButton->setEnabled( pProj && !pProj->IsWiiBuild() );
SetupPackagesList();
}
@ -92,3 +101,18 @@ void CProjectSettingsDialog::CookAllDirtyPackages()
gpEdApp->CookAllDirtyPackages();
SetupPackagesList();
}
void CProjectSettingsDialog::BuildISO()
{
CGameProject *pProj = gpEdApp->ActiveProject();
ASSERT(pProj && !pProj->IsWiiBuild());
QString DefaultPath = TO_QSTRING(pProj->ProjectRoot() + pProj->Name()) + ".gcm";
QString IsoPath = UICommon::SaveFileDialog(this, "Choose output ISO path", "*.gcm", DefaultPath);
if (!IsoPath.isEmpty())
{
if (!pProj->BuildISO( TO_TSTRING(IsoPath) ))
UICommon::ErrorMsg(this, "Failed to build ISO! Check the log for details.");
}
}

View File

@ -29,6 +29,7 @@ public slots:
void SetupPackagesList();
void CookPackage();
void CookAllDirtyPackages();
void BuildISO();
};
#endif // CPROJECTSETTINGSDIALOG_H

View File

@ -141,6 +141,18 @@
</layout>
</widget>
</item>
<item>
<widget class="QPushButton" name="BuildIsoButton">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Build ISO</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>

View File

@ -112,6 +112,9 @@ inline void ErrorMsg(QWidget *pParent, QString ErrorText)
QMessageBox::warning(pParent, "Error", ErrorText);
}
// Constants
const QColor kImportantButtonColor(36, 100, 100);
} // UICommon Namespace End
#endif // UICOMMON

View File

@ -119,7 +119,7 @@ CWorldEditor::CWorldEditor(QWidget *parent)
QPalette Palette = pBrowserButton->palette();
QBrush ButtonBrush = Palette.button();
ButtonBrush.setColor( QColor(36, 100, 100) );
ButtonBrush.setColor( UICommon::kImportantButtonColor );
Palette.setBrush(QPalette::Button, ButtonBrush);
pBrowserButton->setPalette(Palette);