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;
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);
AppendNum++;
}
@ -95,8 +98,12 @@ void GenerateAssetNames(CGameProject *pProj)
bool HasCustomName = !It->HasFlag(eREF_AutoResName);
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());
if (!HasCustomDir && pProj->Game() >= eCorruptionProto)
NewDir = NewDir.ToLower();
It->Move(NewDir, NewName, true, true);
}
#endif

View File

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

View File

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

View File

@ -1,6 +1,7 @@
#ifndef CRESOURCEENTRY_H
#define CRESOURCEENTRY_H
#include "CResourceStore.h"
#include "CVirtualDirectory.h"
#include "Core/Resource/CResTypeInfo.h"
#include "Core/Resource/EResType.h"
@ -10,7 +11,6 @@
#include <Common/types.h>
class CResource;
class CResourceStore;
class CGameProject;
class CDependencyTree;
@ -90,7 +90,7 @@ public:
inline bool IsHidden() const { return HasFlag(eREF_Hidden); }
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 CResource* Resource() const { return mpResource; }
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
{
if (!rkID.IsValid()) return nullptr;
@ -608,3 +613,8 @@ bool CResourceStore::IsValidResourcePath(const TString& rkPath, const TString& r
!rkName.Contains('/') &&
!rkName.Contains('\\') );
}
TString CResourceStore::StaticDefaultResourceDirPath(EGame Game)
{
return (Game < eCorruptionProto ? "Uncategorized/" : "uncategorized/");
}

View File

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

View File

@ -41,7 +41,7 @@ public:
// Accessors
inline CVirtualDirectory* Parent() 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 CVirtualDirectory* SubdirectoryByIndex(u32 Index) { return mSubdirectories[Index]; }

View File

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