mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-17 00:47:05 +00:00
Fixed table view updating to properly show changes after moving resources/directories
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "IUndoCommand.h"
|
||||
#include "Editor/CEditorApplication.h"
|
||||
#include "Editor/ResourceBrowser/CResourceBrowser.h"
|
||||
#include <Core/GameProject/CResourceEntry.h>
|
||||
|
||||
class CMoveResourceCommand : public IUndoCommand
|
||||
@@ -21,25 +22,24 @@ public:
|
||||
, mOldDirAutoGenerated(pEntry->HasFlag(eREF_AutoResDir))
|
||||
{}
|
||||
|
||||
void undo()
|
||||
{
|
||||
bool Success = mpEntry->Move(mOldDirPath, mOldDirAutoGenerated);
|
||||
ASSERT(Success); // todo better error handling
|
||||
gpEdApp->ResourceRenamed(mpEntry);
|
||||
}
|
||||
|
||||
void redo()
|
||||
{
|
||||
// note: it doesn't matter if the new directory was auto-generated, since the
|
||||
// purpose of tracking that flag is to detect which resources have been auto-categorized.
|
||||
// if this is being called, even if the new directory is auto-generated, it means the
|
||||
// user is intentionally placing it here, so it should be treated as a custom directory
|
||||
bool Success = mpEntry->Move(mNewDirPath);
|
||||
ASSERT(Success); // todo better error handling
|
||||
gpEdApp->ResourceRenamed(mpEntry);
|
||||
}
|
||||
|
||||
// note: for redo, it doesn't matter if the new directory was auto-generated, since the
|
||||
// purpose of tracking that flag is to detect which resources have been auto-categorized.
|
||||
// if this is being called, even if the new directory is auto-generated, it means the
|
||||
// user is intentionally placing it here, so it should be treated as a custom directory
|
||||
void undo() { DoMove(mOldDirPath, mOldDirAutoGenerated); }
|
||||
void redo() { DoMove(mNewDirPath, false); }
|
||||
bool AffectsCleanState() const { return false; }
|
||||
|
||||
protected:
|
||||
void DoMove(const TString& rkPath, bool IsAutoDir)
|
||||
{
|
||||
CVirtualDirectory *pOldDir = mpEntry->Directory();
|
||||
TString OldName = mpEntry->Name();
|
||||
bool Success = mpEntry->Move(rkPath, IsAutoDir);
|
||||
ASSERT(Success); // todo better error handling
|
||||
|
||||
gpEdApp->ResourceBrowser()->ResourceMoved(mpEntry, pOldDir, OldName);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CMOVERESOURCECOMMAND_H
|
||||
|
||||
Reference in New Issue
Block a user