Initial work towards making the World Editor the main application window

This commit is contained in:
Aruki
2017-02-11 18:35:33 -07:00
parent 568cd67994
commit 9928a599be
25 changed files with 323 additions and 136 deletions

View File

@@ -142,7 +142,8 @@ void CScriptInstanceDependency::ParseStructDependencies(CScriptInstanceDependenc
if (SoundID != -1)
{
SSoundInfo Info = CGameProject::ActiveProject()->AudioManager()->GetSoundInfo(SoundID);
CGameProject *pProj = pStruct->Instance()->Area()->Entry()->Project();
SSoundInfo Info = pProj->AudioManager()->GetSoundInfo(SoundID);
if (Info.pAudioGroup)
{

View File

@@ -53,8 +53,6 @@ bool CGameExporter::Export(nod::DiscBase *pDisc, const TString& rkOutputDir, CAs
return false;
// Create project
CGameProject *pOldActiveProj = CGameProject::ActiveProject();
mpProject = CGameProject::CreateProjectForExport(
this,
mExportDir,
@@ -68,11 +66,13 @@ bool CGameExporter::Export(nod::DiscBase *pDisc, const TString& rkOutputDir, CAs
mFilesystemAddress);
mpProject->SetProjectName(mGameName);
mpProject->SetActive();
mpStore = mpProject->ResourceStore();
mContentDir = mpStore->RawDir(false);
mCookedDir = mpStore->CookedDir(false);
CResourceStore *pOldStore = gpResourceStore;
gpResourceStore = mpStore;
// Export game data
LoadPaks();
ExportCookedResources();
@@ -82,7 +82,7 @@ bool CGameExporter::Export(nod::DiscBase *pDisc, const TString& rkOutputDir, CAs
// Export finished!
mProjectPath = mpProject->ProjectPath();
delete mpProject;
if (pOldActiveProj) pOldActiveProj->SetActive();
if (pOldStore) gpResourceStore = pOldStore;
return true;
}

View File

@@ -3,19 +3,14 @@
#include "Core/Resource/Script/CMasterTemplate.h"
#include <Common/Serialization/XML.h>
CGameProject *CGameProject::mspActiveProject = nullptr;
CGameProject::~CGameProject()
{
if (mpResourceStore)
{
ASSERT(!mpResourceStore->IsDirty());
}
if (IsActive())
{
mspActiveProject = nullptr;
gpResourceStore = nullptr;
if (gpResourceStore == mpResourceStore)
gpResourceStore = nullptr;
}
for (u32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
@@ -99,15 +94,6 @@ void CGameProject::Serialize(IArchive& rArc)
}
}
void CGameProject::SetActive()
{
if (mspActiveProject != this)
{
mspActiveProject = this;
gpResourceStore = mpResourceStore;
}
}
void CGameProject::GetWorldList(std::list<CAssetID>& rOut) const
{
for (u32 iPkg = 0; iPkg < mPackages.size(); iPkg++)

View File

@@ -45,8 +45,6 @@ class CGameProject
eVer_Current = eVer_Max - 1
};
static CGameProject *mspActiveProject;
// Private Constructor
CGameProject()
: mProjectName("Unnamed Project")
@@ -67,7 +65,6 @@ public:
bool Save();
void Serialize(IArchive& rArc);
void SetActive();
void GetWorldList(std::list<CAssetID>& rOut) const;
CAssetID FindNamedResource(const TString& rkName) const;
@@ -107,10 +104,7 @@ public:
inline CAudioManager* AudioManager() const { return mpAudioManager; }
inline EGame Game() const { return mGame; }
inline float BuildVersion() const { return mBuildVersion; }
inline bool IsActive() const { return mspActiveProject == this; }
inline bool IsWiiBuild() const { return mBuildVersion >= 3.f; }
static inline CGameProject* ActiveProject() { return mspActiveProject; }
};
#endif // CGAMEPROJECT_H

View File

@@ -497,3 +497,8 @@ void CResourceEntry::RemoveFromProject()
Log::Error("RemoveFromProject called on transient resource entry: " + CookedAssetPath(true));
}
}
CGameProject* CResourceEntry::Project() const
{
return mpStore->Project();
}

View File

@@ -11,6 +11,7 @@
class CResource;
class CResourceStore;
class CGameProject;
class CDependencyTree;
enum EResEntryFlag
@@ -68,6 +69,7 @@ public:
bool Move(const TWideString& rkDir, const TWideString& rkName);
void AddToProject(const TWideString& rkDir, const TWideString& rkName);
void RemoveFromProject();
CGameProject* Project() const;
// Accessors
void SetDirty() { mFlags.SetFlag(eREF_NeedsRecook); }