mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-21 02:39:17 +00:00
Initial work towards making the World Editor the main application window
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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++)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -497,3 +497,8 @@ void CResourceEntry::RemoveFromProject()
|
||||
Log::Error("RemoveFromProject called on transient resource entry: " + CookedAssetPath(true));
|
||||
}
|
||||
}
|
||||
|
||||
CGameProject* CResourceEntry::Project() const
|
||||
{
|
||||
return mpStore->Project();
|
||||
}
|
||||
|
||||
@@ -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); }
|
||||
|
||||
@@ -41,7 +41,7 @@ TResPtr<CTexture> CDrawUtil::mpLightMasks[4];
|
||||
bool CDrawUtil::mDrawUtilInitialized = false;
|
||||
|
||||
// ************ PUBLIC ************
|
||||
void CDrawUtil::DrawGrid()
|
||||
void CDrawUtil::DrawGrid(CColor LineColor, CColor BoldLineColor)
|
||||
{
|
||||
Init();
|
||||
|
||||
@@ -55,11 +55,13 @@ void CDrawUtil::DrawGrid()
|
||||
glDepthMask(GL_TRUE);
|
||||
|
||||
glLineWidth(1.0f);
|
||||
UseColorShader(CColor(0.6f, 0.6f, 0.6f, 0.f));
|
||||
LineColor.A = 0.f;
|
||||
UseColorShader(LineColor);
|
||||
mGridIndices.DrawElements(0, mGridIndices.GetSize() - 4);
|
||||
|
||||
glLineWidth(1.5f);
|
||||
UseColorShader(CColor::skTransparentBlack);
|
||||
BoldLineColor.A = 0.f;
|
||||
UseColorShader(BoldLineColor);
|
||||
mGridIndices.DrawElements(mGridIndices.GetSize() - 4, 4);
|
||||
}
|
||||
|
||||
@@ -405,25 +407,32 @@ void CDrawUtil::Init()
|
||||
void CDrawUtil::InitGrid()
|
||||
{
|
||||
Log::Write("Creating grid");
|
||||
mGridVertices.SetVertexDesc(ePosition);
|
||||
mGridVertices.Reserve(64);
|
||||
|
||||
for (s32 i = -7; i < 8; i++)
|
||||
const int kGridSize = 501; // must be odd
|
||||
const float kGridSpacing = 1.f;
|
||||
int MinIdx = (kGridSize - 1) / -2;
|
||||
int MaxIdx = (kGridSize - 1) / 2;
|
||||
|
||||
mGridVertices.SetVertexDesc(ePosition);
|
||||
mGridVertices.Reserve(kGridSize * 4);
|
||||
|
||||
for (s32 i = MinIdx; i <= MaxIdx; i++)
|
||||
{
|
||||
if (i == 0) continue;
|
||||
mGridVertices.AddVertex(CVector3f(-7.0f, float(i), 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f( 7.0f, float(i), 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(float(i), -7.0f, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(float(i), 7.0f, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(MinIdx * kGridSpacing, i * kGridSpacing, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(MaxIdx * kGridSpacing, i * kGridSpacing, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(i * kGridSpacing, MinIdx * kGridSpacing, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(i * kGridSpacing, MaxIdx * kGridSpacing, 0.0f));
|
||||
}
|
||||
|
||||
mGridVertices.AddVertex(CVector3f(-7.0f, 0, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f( 7.0f, 0, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(0, -7.0f, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(0, 7.0f, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(MinIdx * kGridSpacing, 0, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(MaxIdx * kGridSpacing, 0, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(0, MinIdx * kGridSpacing, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(0, MaxIdx * kGridSpacing, 0.0f));
|
||||
|
||||
mGridIndices.Reserve(60);
|
||||
for (u16 i = 0; i < 60; i++) mGridIndices.AddIndex(i);
|
||||
int NumIndices = kGridSize * 4;
|
||||
mGridIndices.Reserve(NumIndices);
|
||||
for (u16 i = 0; i < NumIndices; i++) mGridIndices.AddIndex(i);
|
||||
mGridIndices.SetPrimitiveType(GL_LINES);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class CDrawUtil
|
||||
static bool mDrawUtilInitialized;
|
||||
|
||||
public:
|
||||
static void DrawGrid();
|
||||
static void DrawGrid(CColor LineColor, CColor BoldLineColor);
|
||||
|
||||
static void DrawSquare();
|
||||
static void DrawSquare(const CVector2f& TexUL, const CVector2f& TexUR, const CVector2f& TexBR, const CVector2f& TexBL);
|
||||
|
||||
@@ -67,7 +67,7 @@ void CAnimEventLoader::LoadEvents(IInputStream& rEVNT, bool IsEchoes)
|
||||
|
||||
if (SoundID != 0xFFFF)
|
||||
{
|
||||
SSoundInfo SoundInfo = CGameProject::ActiveProject()->AudioManager()->GetSoundInfo(SoundID);
|
||||
SSoundInfo SoundInfo = mpEventData->Entry()->Project()->AudioManager()->GetSoundInfo(SoundID);
|
||||
|
||||
if (SoundInfo.pAudioGroup)
|
||||
mpEventData->AddEvent(CharIndex, SoundInfo.pAudioGroup->ID());
|
||||
|
||||
@@ -1298,7 +1298,7 @@ void CUnsupportedParticleLoader::ParseSoundFunction(IInputStream& rFile)
|
||||
|
||||
if (SoundID != 0xFFFF)
|
||||
{
|
||||
SSoundInfo SoundInfo = CGameProject::ActiveProject()->AudioManager()->GetSoundInfo(SoundID);
|
||||
SSoundInfo SoundInfo = mpGroup->Entry()->Project()->AudioManager()->GetSoundInfo(SoundID);
|
||||
mpGroup->AddDependency(SoundInfo.pAudioGroup);
|
||||
}
|
||||
|
||||
|
||||
@@ -293,8 +293,6 @@ void CSceneNode::Rotate(const CQuaternion& rkRotation, ETransformSpace Transform
|
||||
|
||||
void CSceneNode::Rotate(const CQuaternion& rkRotation, const CVector3f& rkPivot, const CQuaternion& rkPivotRotation, ETransformSpace TransformSpace)
|
||||
{
|
||||
Rotate(rkRotation, TransformSpace);
|
||||
|
||||
switch (TransformSpace)
|
||||
{
|
||||
case eWorldTransform:
|
||||
@@ -304,7 +302,7 @@ void CSceneNode::Rotate(const CQuaternion& rkRotation, const CVector3f& rkPivot,
|
||||
mPosition = rkPivot + ((rkPivotRotation * rkRotation * rkPivotRotation.Inverse()) * (mPosition - rkPivot));
|
||||
break;
|
||||
}
|
||||
MarkTransformChanged();
|
||||
Rotate(rkRotation, TransformSpace);
|
||||
}
|
||||
|
||||
void CSceneNode::Scale(const CVector3f& rkScale)
|
||||
|
||||
Reference in New Issue
Block a user