Fixed some issues with asset name generation in MP3/DKCR and fixed a memory leak in the character editor

This commit is contained in:
Aruki 2017-07-08 13:38:03 -06:00
parent 21efd3999f
commit cbdebd2f7e
10 changed files with 20917 additions and 20892 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -65,8 +65,11 @@ void ApplyGeneratedName(CResourceEntry *pEntry, const TString& rkDir, const TStr
NewName = SanitizedName; NewName = SanitizedName;
int AppendNum = 0; int AppendNum = 0;
while (pNewDir->FindChildResource(NewName, pEntry->ResourceType()) != nullptr) while (CResourceEntry *pConflict = pNewDir->FindChildResource(NewName, pEntry->ResourceType()))
{ {
if (pConflict == pEntry)
return;
NewName = TString::Format("%s_%d", *SanitizedName, AppendNum); NewName = TString::Format("%s_%d", *SanitizedName, AppendNum);
AppendNum++; AppendNum++;
} }
@ -95,8 +98,12 @@ void GenerateAssetNames(CGameProject *pProj)
bool HasCustomName = !It->HasFlag(eREF_AutoResName); bool HasCustomName = !It->HasFlag(eREF_AutoResName);
if (HasCustomDir && HasCustomName) continue; if (HasCustomDir && HasCustomName) continue;
TString NewDir = (HasCustomDir ? It->DirectoryPath() : "Uncategorized/"); TString NewDir = (HasCustomDir ? It->DirectoryPath() : pStore->DefaultResourceDirPath());
TString NewName = (HasCustomName ? It->Name() : It->ID().ToString()); TString NewName = (HasCustomName ? It->Name() : It->ID().ToString());
if (!HasCustomDir && pProj->Game() >= eCorruptionProto)
NewDir = NewDir.ToLower();
It->Move(NewDir, NewName, true, true); It->Move(NewDir, NewName, true, true);
} }
#endif #endif

View File

@ -58,7 +58,8 @@ bool CAssetNameMap::GetNameInfo(CAssetID ID, TString& rOutDirectory, TString& rO
else else
{ {
rOutDirectory = "Uncategorized/"; EGame Game = (ID.Length() == e32Bit ? ePrime : eCorruption);
rOutDirectory = CResourceStore::StaticDefaultResourceDirPath(Game);
rOutName = ID.ToString(); rOutName = ID.ToString();
rOutAutoGenDir = true; rOutAutoGenDir = true;
rOutAutoGenName = true; rOutAutoGenName = true;

View File

@ -564,7 +564,7 @@ void CGameExporter::ExportResource(SResourceInstance& rRes)
#if USE_ASSET_NAME_MAP #if USE_ASSET_NAME_MAP
mpNameMap->GetNameInfo(rRes.ResourceID, Directory, Name, AutoDir, AutoName); mpNameMap->GetNameInfo(rRes.ResourceID, Directory, Name, AutoDir, AutoName);
#else #else
Directory = "Uncategorized"; Directory = mpStore->DefaultAssetDirectoryPath(mpStore->Game());
Name = rRes.ResourceID.ToString(); Name = rRes.ResourceID.ToString();
#endif #endif
@ -607,9 +607,13 @@ TString CGameExporter::MakeWorldName(CAssetID WorldID)
{ {
const SNamedResource& rkRes = pPkg->NamedResourceByIndex(iRes); const SNamedResource& rkRes = pPkg->NamedResourceByIndex(iRes);
if (rkRes.ID == WorldID && !rkRes.Name.EndsWith("_NODEPEND")) if (rkRes.ID == WorldID)
{ {
WorldName = rkRes.Name; WorldName = rkRes.Name;
if (WorldName.EndsWith("_NODEPEND"))
WorldName = WorldName.ChopBack(9);
break; break;
} }
} }
@ -686,17 +690,15 @@ TString CGameExporter::MakeWorldName(CAssetID WorldID)
{ {
u32 LastUnderscore = WorldName.LastIndexOf('_'); u32 LastUnderscore = WorldName.LastIndexOf('_');
if (LastUnderscore != -1) if (LastUnderscore != -1 && !WorldName.StartsWith("front_end_"))
WorldName = WorldName.ChopBack(WorldName.Size() - LastUnderscore); WorldName = WorldName.ChopBack(WorldName.Size() - LastUnderscore);
} }
// DKCR - Remove text after second-to-last underscore // DKCR - Remove text prior to first underscore
else if (mGame == eReturns) else if (mGame == eReturns)
{ {
u32 Underscore = WorldName.LastIndexOf('_'); u32 Underscore = WorldName.IndexOf('_');
WorldName = WorldName.ChopBack(WorldName.Size() - Underscore); WorldName = WorldName.ChopFront(Underscore + 1);
Underscore = WorldName.LastIndexOf('_');
WorldName = WorldName.ChopBack(WorldName.Size() - Underscore);
} }
} }

View File

@ -1,6 +1,7 @@
#ifndef CRESOURCEENTRY_H #ifndef CRESOURCEENTRY_H
#define CRESOURCEENTRY_H #define CRESOURCEENTRY_H
#include "CResourceStore.h"
#include "CVirtualDirectory.h" #include "CVirtualDirectory.h"
#include "Core/Resource/CResTypeInfo.h" #include "Core/Resource/CResTypeInfo.h"
#include "Core/Resource/EResType.h" #include "Core/Resource/EResType.h"
@ -10,7 +11,6 @@
#include <Common/types.h> #include <Common/types.h>
class CResource; class CResource;
class CResourceStore;
class CGameProject; class CGameProject;
class CDependencyTree; class CDependencyTree;
@ -90,7 +90,7 @@ public:
inline bool IsHidden() const { return HasFlag(eREF_Hidden); } inline bool IsHidden() const { return HasFlag(eREF_Hidden); }
inline bool IsLoaded() const { return mpResource != nullptr; } inline bool IsLoaded() const { return mpResource != nullptr; }
inline bool IsCategorized() const { return mpDirectory && mpDirectory->FullPath() != "Uncategorized/"; } inline bool IsCategorized() const { return mpDirectory && !mpDirectory->FullPath().CaseInsensitiveCompare( mpStore->DefaultResourceDirPath() ); }
inline bool IsNamed() const { return mName != mID.ToString(); } inline bool IsNamed() const { return mName != mID.ToString(); }
inline CResource* Resource() const { return mpResource; } inline CResource* Resource() const { return mpResource; }
inline CResTypeInfo* TypeInfo() const { return mpTypeInfo; } inline CResTypeInfo* TypeInfo() const { return mpTypeInfo; }

View File

@ -246,6 +246,11 @@ void CResourceStore::ConditionalDeleteDirectory(CVirtualDirectory *pDir, bool Re
} }
} }
TString CResourceStore::DefaultResourceDirPath() const
{
return StaticDefaultResourceDirPath( mGame );
}
CResourceEntry* CResourceStore::FindEntry(const CAssetID& rkID) const CResourceEntry* CResourceStore::FindEntry(const CAssetID& rkID) const
{ {
if (!rkID.IsValid()) return nullptr; if (!rkID.IsValid()) return nullptr;
@ -608,3 +613,8 @@ bool CResourceStore::IsValidResourcePath(const TString& rkPath, const TString& r
!rkName.Contains('/') && !rkName.Contains('/') &&
!rkName.Contains('\\') ); !rkName.Contains('\\') );
} }
TString CResourceStore::StaticDefaultResourceDirPath(EGame Game)
{
return (Game < eCorruptionProto ? "Uncategorized/" : "uncategorized/");
}

View File

@ -1,5 +1,5 @@
#ifndef CRESOURCEDATABASE_H #ifndef CRESOURCESTORE_H
#define CRESOURCEDATABASE_H #define CRESOURCESTORE_H
#include "CVirtualDirectory.h" #include "CVirtualDirectory.h"
#include "Core/Resource/EResType.h" #include "Core/Resource/EResType.h"
@ -47,9 +47,11 @@ public:
void ConditionalSaveStore(); void ConditionalSaveStore();
void SetProject(CGameProject *pProj); void SetProject(CGameProject *pProj);
void CloseProject(); void CloseProject();
CVirtualDirectory* GetVirtualDirectory(const TString& rkPath, bool AllowCreate); CVirtualDirectory* GetVirtualDirectory(const TString& rkPath, bool AllowCreate);
void CreateVirtualDirectory(const TString& rkPath); void CreateVirtualDirectory(const TString& rkPath);
void ConditionalDeleteDirectory(CVirtualDirectory *pDir, bool Recurse); void ConditionalDeleteDirectory(CVirtualDirectory *pDir, bool Recurse);
TString DefaultResourceDirPath() const;
bool IsResourceRegistered(const CAssetID& rkID) const; bool IsResourceRegistered(const CAssetID& rkID) const;
CResourceEntry* RegisterResource(const CAssetID& rkID, EResType Type, const TString& rkDir, const TString& rkName); CResourceEntry* RegisterResource(const CAssetID& rkID, EResType Type, const TString& rkDir, const TString& rkName);
@ -71,6 +73,7 @@ public:
void ImportNamesFromPakContentsTxt(const TString& rkTxtPath, bool UnnamedOnly); void ImportNamesFromPakContentsTxt(const TString& rkTxtPath, bool UnnamedOnly);
static bool IsValidResourcePath(const TString& rkPath, const TString& rkName); static bool IsValidResourcePath(const TString& rkPath, const TString& rkName);
static TString StaticDefaultResourceDirPath(EGame Game);
// Accessors // Accessors
inline CGameProject* Project() const { return mpProj; } inline CGameProject* Project() const { return mpProj; }
@ -90,4 +93,4 @@ public:
extern CResourceStore *gpResourceStore; extern CResourceStore *gpResourceStore;
extern CResourceStore *gpEditorStore; extern CResourceStore *gpEditorStore;
#endif // CRESOURCEDATABASE_H #endif // CRESOURCESTORE_H

View File

@ -41,7 +41,7 @@ public:
// Accessors // Accessors
inline CVirtualDirectory* Parent() const { return mpParent; } inline CVirtualDirectory* Parent() const { return mpParent; }
inline bool IsRoot() const { return !mpParent; } inline bool IsRoot() const { return !mpParent; }
inline TString Name() const { return mName; } inline TString Name() const { return mName; }
inline u32 NumSubdirectories() const { return mSubdirectories.size(); } inline u32 NumSubdirectories() const { return mSubdirectories.size(); }
inline CVirtualDirectory* SubdirectoryByIndex(u32 Index) { return mSubdirectories[Index]; } inline CVirtualDirectory* SubdirectoryByIndex(u32 Index) { return mSubdirectories[Index]; }

View File

@ -14,7 +14,6 @@ CCharacterEditor::CCharacterEditor(CAnimSet *pSet, QWidget *parent)
: IEditor(parent) : IEditor(parent)
, ui(new Ui::CCharacterEditor) , ui(new Ui::CCharacterEditor)
, mpScene(new CScene()) , mpScene(new CScene())
, mpCharNode(new CCharacterNode(mpScene, -1))
, mpSelectedBone(nullptr) , mpSelectedBone(nullptr)
, mBindPose(false) , mBindPose(false)
, mPlayAnim(true) , mPlayAnim(true)
@ -25,6 +24,7 @@ CCharacterEditor::CCharacterEditor(CAnimSet *pSet, QWidget *parent)
ui->setupUi(this); ui->setupUi(this);
REPLACE_WINDOWTITLE_APPVARS; REPLACE_WINDOWTITLE_APPVARS;
mpCharNode = new CCharacterNode(mpScene, -1);
ui->Viewport->SetNode(mpCharNode); ui->Viewport->SetNode(mpCharNode);
CCamera& rCamera = ui->Viewport->Camera(); CCamera& rCamera = ui->Viewport->Camera();
@ -80,6 +80,8 @@ CCharacterEditor::CCharacterEditor(CAnimSet *pSet, QWidget *parent)
CCharacterEditor::~CCharacterEditor() CCharacterEditor::~CCharacterEditor()
{ {
delete ui; delete ui;
delete mpScene;
delete mpCharNode;
} }
void CCharacterEditor::EditorTick(float DeltaTime) void CCharacterEditor::EditorTick(float DeltaTime)