mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-05-25 08:41:26 +00:00
Fixed some issues with asset name generation in MP3/DKCR and fixed a memory leak in the character editor
This commit is contained in:
parent
21efd3999f
commit
cbdebd2f7e
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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; }
|
||||
|
@ -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/");
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user