mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-16 08:27:01 +00:00
Added ability to rename resources/directories in the resource table view
This commit is contained in:
@@ -106,7 +106,13 @@ bool CResourceStore::SerializeDatabaseCache(IArchive& rArc)
|
||||
if (rArc.IsReader())
|
||||
{
|
||||
for (auto Iter = EmptyDirectories.begin(); Iter != EmptyDirectories.end(); Iter++)
|
||||
CreateVirtualDirectory(*Iter);
|
||||
{
|
||||
// Don't create empty virtual directories that don't actually exist in the filesystem
|
||||
TString AbsPath = ResourcesDir() + *Iter;
|
||||
|
||||
if (FileUtil::Exists(AbsPath))
|
||||
CreateVirtualDirectory(*Iter);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -247,6 +247,30 @@ bool CVirtualDirectory::RemoveChildResource(CResourceEntry *pEntry)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CVirtualDirectory::Rename(const TString& rkNewName)
|
||||
{
|
||||
Log::Write("MOVING DIRECTORY: " + FullPath() + " -> " + mpParent->FullPath() + rkNewName + '/');
|
||||
|
||||
if (!IsRoot())
|
||||
{
|
||||
if (!mpParent->FindChildDirectory(rkNewName, false))
|
||||
{
|
||||
TString AbsPath = AbsolutePath();
|
||||
TString NewPath = mpParent->AbsolutePath() + rkNewName + "/";
|
||||
|
||||
if (FileUtil::MoveDirectory(AbsPath, NewPath))
|
||||
{
|
||||
mName = rkNewName;
|
||||
mpStore->SetCacheDirty();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log::Error("DIRECTORY MOVE FAILED");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CVirtualDirectory::Delete()
|
||||
{
|
||||
ASSERT(IsEmpty(true) && !IsRoot());
|
||||
@@ -257,6 +281,7 @@ bool CVirtualDirectory::Delete()
|
||||
{
|
||||
if (!mpParent || mpParent->RemoveChildDirectory(this))
|
||||
{
|
||||
mpStore->SetCacheDirty();
|
||||
delete this;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
bool AddChild(CVirtualDirectory *pDir);
|
||||
bool RemoveChildDirectory(CVirtualDirectory *pSubdir);
|
||||
bool RemoveChildResource(CResourceEntry *pEntry);
|
||||
bool Rename(const TString& rkNewName);
|
||||
bool Delete();
|
||||
void DeleteEmptySubdirectories();
|
||||
bool SetParent(CVirtualDirectory *pParent);
|
||||
|
||||
Reference in New Issue
Block a user