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:
Aruki
2017-07-14 18:41:56 -06:00
parent fe9a074029
commit dbe8b7922c
25 changed files with 897 additions and 198 deletions

View 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