mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-17 00:47:05 +00:00
Added support for dragging/dropping resources; you can use drag/drop to rearrange resources/folders in the resource browser now, and you can drag/drop resources onto resource selector widgets
This commit is contained in:
45
src/Editor/Undo/CMoveResourceCommand.h
Normal file
45
src/Editor/Undo/CMoveResourceCommand.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef CMOVERESOURCECOMMAND_H
|
||||
#define CMOVERESOURCECOMMAND_H
|
||||
|
||||
#include "IUndoCommand.h"
|
||||
#include "Editor/CEditorApplication.h"
|
||||
#include <Core/GameProject/CResourceEntry.h>
|
||||
|
||||
class CMoveResourceCommand : public IUndoCommand
|
||||
{
|
||||
CResourceEntry *mpEntry;
|
||||
TString mOldDirPath;
|
||||
TString mNewDirPath;
|
||||
bool mOldDirAutoGenerated;
|
||||
|
||||
public:
|
||||
CMoveResourceCommand(CResourceEntry *pEntry, CVirtualDirectory *pNewDir)
|
||||
: IUndoCommand("Move Resource")
|
||||
, mpEntry(pEntry)
|
||||
, mOldDirPath(pEntry->DirectoryPath())
|
||||
, mNewDirPath(pNewDir->FullPath())
|
||||
, 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);
|
||||
}
|
||||
|
||||
bool AffectsCleanState() const { return false; }
|
||||
};
|
||||
|
||||
#endif // CMOVERESOURCECOMMAND_H
|
||||
Reference in New Issue
Block a user