Added "edit" button to resource selector context menu
This commit is contained in:
parent
4e8ecdb79c
commit
c51d79cc42
|
@ -178,19 +178,24 @@ u32 CAnimationParameters::Unknown(u32 Index)
|
||||||
|
|
||||||
void CAnimationParameters::SetResource(const CAssetID& rkID)
|
void CAnimationParameters::SetResource(const CAssetID& rkID)
|
||||||
{
|
{
|
||||||
mCharacterID = rkID;
|
if (mCharacterID != rkID)
|
||||||
mCharIndex = 0;
|
|
||||||
mAnimIndex = 0;
|
|
||||||
|
|
||||||
// Validate ID
|
|
||||||
if (mCharacterID.IsValid())
|
|
||||||
{
|
{
|
||||||
CResourceEntry *pEntry = gpResourceStore->FindEntry(rkID);
|
mCharacterID = rkID;
|
||||||
|
mCharIndex = 0;
|
||||||
|
mAnimIndex = 0;
|
||||||
|
mUnknown2 = 0;
|
||||||
|
mUnknown3 = 0;
|
||||||
|
|
||||||
if (!pEntry)
|
// Validate ID
|
||||||
Log::Error("Invalid resource ID passed to CAnimationParameters: " + rkID.ToString());
|
if (mCharacterID.IsValid())
|
||||||
else if (pEntry->ResourceType() != eAnimSet)
|
{
|
||||||
Log::Error("Resource with invalid type passed to CAnimationParameters: " + pEntry->CookedAssetPath().GetFileName());
|
CResourceEntry *pEntry = gpResourceStore->FindEntry(rkID);
|
||||||
|
|
||||||
|
if (!pEntry)
|
||||||
|
Log::Error("Invalid resource ID passed to CAnimationParameters: " + rkID.ToString());
|
||||||
|
else if (pEntry->ResourceType() != eAnimSet)
|
||||||
|
Log::Error("Resource with invalid type passed to CAnimationParameters: " + pEntry->CookedAssetPath().GetFileName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -297,6 +297,7 @@ void CResTypeInfo::CResTypeInfoFactory::InitTypes()
|
||||||
{
|
{
|
||||||
CResTypeInfo *pType = new CResTypeInfo(eSaveWorld, "World Save Info");
|
CResTypeInfo *pType = new CResTypeInfo(eSaveWorld, "World Save Info");
|
||||||
AddExtension(pType, "SAVW", ePrime, eReturns);
|
AddExtension(pType, "SAVW", ePrime, eReturns);
|
||||||
|
pType->mHidden = true;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
CResTypeInfo *pType = new CResTypeInfo(eScan, "Scan");
|
CResTypeInfo *pType = new CResTypeInfo(eScan, "Scan");
|
||||||
|
|
|
@ -2,11 +2,14 @@
|
||||||
#include "IEditor.h"
|
#include "IEditor.h"
|
||||||
#include "CBasicViewport.h"
|
#include "CBasicViewport.h"
|
||||||
#include "CProjectOverviewDialog.h"
|
#include "CProjectOverviewDialog.h"
|
||||||
|
#include "Editor/CharacterEditor/CCharacterEditor.h"
|
||||||
|
#include "Editor/ModelEditor/CModelEditorWindow.h"
|
||||||
#include "Editor/ResourceBrowser/CResourceBrowser.h"
|
#include "Editor/ResourceBrowser/CResourceBrowser.h"
|
||||||
#include "Editor/WorldEditor/CWorldEditor.h"
|
#include "Editor/WorldEditor/CWorldEditor.h"
|
||||||
#include <Common/AssertMacro.h>
|
#include <Common/AssertMacro.h>
|
||||||
#include <Common/CTimer.h>
|
#include <Common/CTimer.h>
|
||||||
#include <Core/GameProject/CGameProject.h>
|
#include <Core/GameProject/CGameProject.h>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
CEditorApplication::CEditorApplication(int& rArgc, char **ppArgv)
|
CEditorApplication::CEditorApplication(int& rArgc, char **ppArgv)
|
||||||
: QApplication(rArgc, ppArgv)
|
: QApplication(rArgc, ppArgv)
|
||||||
|
@ -23,7 +26,6 @@ CEditorApplication::CEditorApplication(int& rArgc, char **ppArgv)
|
||||||
CEditorApplication::~CEditorApplication()
|
CEditorApplication::~CEditorApplication()
|
||||||
{
|
{
|
||||||
delete mpWorldEditor;
|
delete mpWorldEditor;
|
||||||
delete mpResourceBrowser;
|
|
||||||
delete mpProjectDialog;
|
delete mpProjectDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +37,53 @@ void CEditorApplication::InitEditor()
|
||||||
connect(mpProjectDialog, SIGNAL(ActiveProjectChanged(CGameProject*)), mpResourceBrowser, SLOT(RefreshResources()));
|
connect(mpProjectDialog, SIGNAL(ActiveProjectChanged(CGameProject*)), mpResourceBrowser, SLOT(RefreshResources()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CEditorApplication::EditResource(CResourceEntry *pEntry)
|
||||||
|
{
|
||||||
|
ASSERT(pEntry != nullptr);
|
||||||
|
|
||||||
|
// Check if we're already editing this resource
|
||||||
|
if (mEditingMap.contains(pEntry))
|
||||||
|
{
|
||||||
|
IEditor *pEd = mEditingMap[pEntry];
|
||||||
|
pEd->show();
|
||||||
|
pEd->raise();
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Attempt to load asset
|
||||||
|
CResource *pRes = pEntry->Load();
|
||||||
|
|
||||||
|
if (!pRes)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(nullptr, "Error", "Failed to load resource!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Launch editor window
|
||||||
|
IEditor *pEd = nullptr;
|
||||||
|
|
||||||
|
switch (pEntry->ResourceType())
|
||||||
|
{
|
||||||
|
case eModel:
|
||||||
|
pEd = new CModelEditorWindow((CModel*) pRes, mpWorldEditor);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case eAnimSet:
|
||||||
|
pEd = new CCharacterEditor((CAnimSet*) pRes, mpWorldEditor);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pEd)
|
||||||
|
{
|
||||||
|
pEd->show();
|
||||||
|
mEditingMap[pEntry] = pEd;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
QMessageBox::information(0, "Unsupported Resource", "This resource type is currently unsupported for editing.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CEditorApplication::AddEditor(IEditor *pEditor)
|
void CEditorApplication::AddEditor(IEditor *pEditor)
|
||||||
{
|
{
|
||||||
mEditorWindows << pEditor;
|
mEditorWindows << pEditor;
|
||||||
|
@ -80,6 +129,15 @@ void CEditorApplication::OnEditorClose()
|
||||||
|
|
||||||
if (qobject_cast<CWorldEditor*>(pEditor) == nullptr)
|
if (qobject_cast<CWorldEditor*>(pEditor) == nullptr)
|
||||||
{
|
{
|
||||||
|
for (auto Iter = mEditingMap.begin(); Iter != mEditingMap.end(); Iter++)
|
||||||
|
{
|
||||||
|
if (Iter.value() == pEditor)
|
||||||
|
{
|
||||||
|
mEditingMap.erase(Iter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mEditorWindows.removeOne(pEditor);
|
mEditorWindows.removeOne(pEditor);
|
||||||
delete pEditor;
|
delete pEditor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
class CBasicViewport;
|
class CBasicViewport;
|
||||||
class CProjectOverviewDialog;
|
class CProjectOverviewDialog;
|
||||||
class CResourceBrowser;
|
class CResourceBrowser;
|
||||||
|
class CResourceEntry;
|
||||||
class CWorldEditor;
|
class CWorldEditor;
|
||||||
class IEditor;
|
class IEditor;
|
||||||
|
|
||||||
|
@ -20,12 +21,14 @@ class CEditorApplication : public QApplication
|
||||||
CResourceBrowser *mpResourceBrowser;
|
CResourceBrowser *mpResourceBrowser;
|
||||||
CProjectOverviewDialog *mpProjectDialog;
|
CProjectOverviewDialog *mpProjectDialog;
|
||||||
QVector<IEditor*> mEditorWindows;
|
QVector<IEditor*> mEditorWindows;
|
||||||
|
QMap<CResourceEntry*,IEditor*> mEditingMap;
|
||||||
double mLastUpdate;
|
double mLastUpdate;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CEditorApplication(int& rArgc, char **ppArgv);
|
CEditorApplication(int& rArgc, char **ppArgv);
|
||||||
~CEditorApplication();
|
~CEditorApplication();
|
||||||
void InitEditor();
|
void InitEditor();
|
||||||
|
void EditResource(CResourceEntry *pEntry);
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
inline CWorldEditor* WorldEditor() const { return mpWorldEditor; }
|
inline CWorldEditor* WorldEditor() const { return mpWorldEditor; }
|
||||||
|
|
|
@ -23,8 +23,6 @@ CStartWindow::CStartWindow(QWidget *parent)
|
||||||
|
|
||||||
mpWorld = nullptr;
|
mpWorld = nullptr;
|
||||||
mpWorldEditor = new CWorldEditor(0);
|
mpWorldEditor = new CWorldEditor(0);
|
||||||
mpModelEditor = new CModelEditorWindow(this);
|
|
||||||
mpCharEditor = new CCharacterEditor(this);
|
|
||||||
|
|
||||||
connect(ui->ActionAbout, SIGNAL(triggered()), this, SLOT(About()));
|
connect(ui->ActionAbout, SIGNAL(triggered()), this, SLOT(About()));
|
||||||
connect(ui->ActionCharacterEditor, SIGNAL(triggered()), this, SLOT(LaunchCharacterEditor()));
|
connect(ui->ActionCharacterEditor, SIGNAL(triggered()), this, SLOT(LaunchCharacterEditor()));
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
const CVector3f CCharacterEditor::skDefaultOrbitTarget = CVector3f(0,0,1);
|
const CVector3f CCharacterEditor::skDefaultOrbitTarget = CVector3f(0,0,1);
|
||||||
const float CCharacterEditor::skDefaultOrbitDistance = 4.f;
|
const float CCharacterEditor::skDefaultOrbitDistance = 4.f;
|
||||||
|
|
||||||
CCharacterEditor::CCharacterEditor(QWidget *parent)
|
CCharacterEditor::CCharacterEditor(CAnimSet *pSet, QWidget *parent)
|
||||||
: IEditor(parent)
|
: IEditor(parent)
|
||||||
, ui(new Ui::CCharacterEditor)
|
, ui(new Ui::CCharacterEditor)
|
||||||
, mpScene(new CScene())
|
, mpScene(new CScene())
|
||||||
|
@ -74,6 +74,8 @@ CCharacterEditor::CCharacterEditor(QWidget *parent)
|
||||||
ui->splitter->setSizes(SplitterSizes);
|
ui->splitter->setSizes(SplitterSizes);
|
||||||
|
|
||||||
connect(ui->SkeletonHierarchyTreeView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(OnSkeletonTreeSelectionChanged(QModelIndex)));
|
connect(ui->SkeletonHierarchyTreeView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(OnSkeletonTreeSelectionChanged(QModelIndex)));
|
||||||
|
|
||||||
|
SetActiveAnimSet(pSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCharacterEditor::~CCharacterEditor()
|
CCharacterEditor::~CCharacterEditor()
|
||||||
|
|
|
@ -44,7 +44,7 @@ class CCharacterEditor : public IEditor
|
||||||
static const float skDefaultOrbitDistance;
|
static const float skDefaultOrbitDistance;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CCharacterEditor(QWidget *parent = 0);
|
explicit CCharacterEditor(CAnimSet *pSet, QWidget *parent = 0);
|
||||||
~CCharacterEditor();
|
~CCharacterEditor();
|
||||||
void EditorTick(float DeltaTime);
|
void EditorTick(float DeltaTime);
|
||||||
void UpdateAnimTime(float DeltaTime);
|
void UpdateAnimTime(float DeltaTime);
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
|
||||||
CModelEditorWindow::CModelEditorWindow(QWidget *pParent)
|
CModelEditorWindow::CModelEditorWindow(CModel *pModel, QWidget *pParent)
|
||||||
: IEditor(pParent)
|
: IEditor(pParent)
|
||||||
, ui(new Ui::CModelEditorWindow)
|
, ui(new Ui::CModelEditorWindow)
|
||||||
, mpScene(new CScene())
|
, mpScene(new CScene())
|
||||||
|
@ -145,6 +145,8 @@ CModelEditorWindow::CModelEditorWindow(QWidget *pParent)
|
||||||
connect(ui->AnimParamCSpinBox, SIGNAL(valueChanged(double)), this, SLOT(UpdateMaterial(double)));
|
connect(ui->AnimParamCSpinBox, SIGNAL(valueChanged(double)), this, SLOT(UpdateMaterial(double)));
|
||||||
connect(ui->AnimParamDSpinBox, SIGNAL(valueChanged(double)), this, SLOT(UpdateMaterial(double)));
|
connect(ui->AnimParamDSpinBox, SIGNAL(valueChanged(double)), this, SLOT(UpdateMaterial(double)));
|
||||||
// That was fun
|
// That was fun
|
||||||
|
|
||||||
|
SetActiveModel(pModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
CModelEditorWindow::~CModelEditorWindow()
|
CModelEditorWindow::~CModelEditorWindow()
|
||||||
|
|
|
@ -31,7 +31,7 @@ class CModelEditorWindow : public IEditor
|
||||||
bool mIgnoreSignals;
|
bool mIgnoreSignals;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CModelEditorWindow(QWidget *pParent = 0);
|
explicit CModelEditorWindow(CModel *pModel, QWidget *pParent = 0);
|
||||||
~CModelEditorWindow();
|
~CModelEditorWindow();
|
||||||
void SetActiveModel(CModel *pModel);
|
void SetActiveModel(CModel *pModel);
|
||||||
CModelEditorViewport* Viewport() const;
|
CModelEditorViewport* Viewport() const;
|
||||||
|
|
|
@ -667,10 +667,6 @@ void CPropertyDelegate::SetCharacterModelData(QWidget *pEditor, const QModelInde
|
||||||
if (Type == eAssetProperty)
|
if (Type == eAssetProperty)
|
||||||
{
|
{
|
||||||
Params.SetResource( static_cast<CResourceSelector*>(pEditor)->Entry()->ID() );
|
Params.SetResource( static_cast<CResourceSelector*>(pEditor)->Entry()->ID() );
|
||||||
// Reset all other parameters to 0
|
|
||||||
Params.SetCharIndex(0);
|
|
||||||
for (u32 iUnk = 0; iUnk < 3; iUnk++)
|
|
||||||
Params.SetUnknown(iUnk, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (Type == eEnumProperty)
|
else if (Type == eEnumProperty)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "CResourceBrowser.h"
|
#include "CResourceBrowser.h"
|
||||||
#include "ui_CResourceBrowser.h"
|
#include "ui_CResourceBrowser.h"
|
||||||
#include "Editor/ModelEditor/CModelEditorWindow.h"
|
#include "Editor/CEditorApplication.h"
|
||||||
#include "Editor/CharacterEditor/CCharacterEditor.h"
|
|
||||||
#include <Core/GameProject/AssetNameGeneration.h>
|
#include <Core/GameProject/AssetNameGeneration.h>
|
||||||
#include <Core/GameProject/CAssetNameMap.h>
|
#include <Core/GameProject/CAssetNameMap.h>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
@ -111,37 +110,7 @@ void CResourceBrowser::OnDoubleClickResource(QModelIndex Index)
|
||||||
{
|
{
|
||||||
QModelIndex SourceIndex = mpProxyModel->mapToSource(Index);
|
QModelIndex SourceIndex = mpProxyModel->mapToSource(Index);
|
||||||
CResourceEntry *pEntry = mpModel->IndexEntry(SourceIndex);
|
CResourceEntry *pEntry = mpModel->IndexEntry(SourceIndex);
|
||||||
|
gpEdApp->EditResource(pEntry);
|
||||||
if (pEntry->ResourceType() == eModel)
|
|
||||||
{
|
|
||||||
CModel *pModel = (CModel*) pEntry->Load();
|
|
||||||
|
|
||||||
if (pModel)
|
|
||||||
{
|
|
||||||
CModelEditorWindow *pModelEd = new CModelEditorWindow(parentWidget());
|
|
||||||
pModelEd->SetActiveModel(pModel);
|
|
||||||
pModelEd->show();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
QMessageBox::warning(this, "Error", "Failed to load resource");
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (pEntry->ResourceType() == eAnimSet)
|
|
||||||
{
|
|
||||||
CAnimSet *pSet = (CAnimSet*) pEntry->Load();
|
|
||||||
|
|
||||||
if (pSet)
|
|
||||||
{
|
|
||||||
CCharacterEditor *pCharEd = new CCharacterEditor(parentWidget());
|
|
||||||
pCharEd->SetActiveAnimSet(pSet);
|
|
||||||
pCharEd->show();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
QMessageBox::warning(this, "Error", "Failed to load resource");
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
QMessageBox::information(this, "Unsupported Resource", "The selected resource type is currently unsupported for editing.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CResourceBrowser::OnResourceSelectionChanged(const QModelIndex& rkNewIndex, const QModelIndex& /*rkPrevIndex*/)
|
void CResourceBrowser::OnResourceSelectionChanged(const QModelIndex& rkNewIndex, const QModelIndex& /*rkPrevIndex*/)
|
||||||
|
|
|
@ -77,30 +77,10 @@ public:
|
||||||
for (CResourceIterator It(pStore); It; ++It)
|
for (CResourceIterator It(pStore); It; ++It)
|
||||||
{
|
{
|
||||||
if (It->IsTransient()) continue;
|
if (It->IsTransient()) continue;
|
||||||
EResType Type = It->ResourceType();
|
|
||||||
|
|
||||||
switch (Type)
|
CResTypeInfo *pInfo = It->TypeInfo();
|
||||||
{
|
if (pInfo->IsVisibleInBrowser() && !It->IsHidden())
|
||||||
case eArea:
|
|
||||||
case eAreaCollision:
|
|
||||||
case eAreaLights:
|
|
||||||
case eAreaMaterials:
|
|
||||||
case eAreaSurfaceBounds:
|
|
||||||
case eAreaOctree:
|
|
||||||
case eAreaVisibilityTree:
|
|
||||||
case eMapArea:
|
|
||||||
case eMapWorld:
|
|
||||||
case ePathfinding:
|
|
||||||
case ePortalArea:
|
|
||||||
case eSaveArea:
|
|
||||||
case eSaveWorld:
|
|
||||||
case eStaticGeometryMap:
|
|
||||||
case eTweak:
|
|
||||||
case eWorld:
|
|
||||||
continue;
|
|
||||||
default:
|
|
||||||
mEntries << *It;
|
mEntries << *It;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ CResourceSelector::CResourceSelector(QWidget *pParent /*= 0*/)
|
||||||
mpResNameLabel = new QLabel(this);
|
mpResNameLabel = new QLabel(this);
|
||||||
|
|
||||||
mpSetButton = new QPushButton(this);
|
mpSetButton = new QPushButton(this);
|
||||||
mpSetButton->setToolTip("Set");
|
mpSetButton->setToolTip("Use selected asset in Resource Browser");
|
||||||
mpSetButton->setIcon(QIcon(":/icons/ArrowL_16px.png"));
|
mpSetButton->setIcon(QIcon(":/icons/ArrowL_16px.png"));
|
||||||
mpSetButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
mpSetButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
mpSetButton->setFixedSize(16, 16);
|
mpSetButton->setFixedSize(16, 16);
|
||||||
|
@ -44,28 +44,38 @@ CResourceSelector::CResourceSelector(QWidget *pParent /*= 0*/)
|
||||||
mpLayout->addWidget(mpClearButton);
|
mpLayout->addWidget(mpClearButton);
|
||||||
setLayout(mpLayout);
|
setLayout(mpLayout);
|
||||||
|
|
||||||
UpdateUI();
|
|
||||||
|
|
||||||
// UI Connections
|
// UI Connections
|
||||||
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(CreateContextMenu(QPoint)));
|
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(CreateContextMenu(QPoint)));
|
||||||
connect(mpSetButton, SIGNAL(clicked()), this, SLOT(Set()));
|
connect(mpSetButton, SIGNAL(clicked()), this, SLOT(Set()));
|
||||||
connect(mpClearButton, SIGNAL(clicked()), this, SLOT(Clear()));
|
connect(mpClearButton, SIGNAL(clicked()), this, SLOT(Clear()));
|
||||||
|
|
||||||
// Set up context menu
|
// Set up context menu
|
||||||
|
mpEditAssetAction = new QAction("Edit", this);
|
||||||
mpCopyNameAction = new QAction("Copy name", this);
|
mpCopyNameAction = new QAction("Copy name", this);
|
||||||
mpCopyPathAction = new QAction("Copy path", this);
|
mpCopyPathAction = new QAction("Copy path", this);
|
||||||
|
|
||||||
// Context menu connections
|
// Context menu connections
|
||||||
|
connect(mpEditAssetAction, SIGNAL(triggered()), this, SLOT(EditAsset()));
|
||||||
connect(mpCopyNameAction, SIGNAL(triggered()), this, SLOT(CopyName()));
|
connect(mpCopyNameAction, SIGNAL(triggered()), this, SLOT(CopyName()));
|
||||||
connect(mpCopyPathAction, SIGNAL(triggered()), this, SLOT(CopyPath()));
|
connect(mpCopyPathAction, SIGNAL(triggered()), this, SLOT(CopyPath()));
|
||||||
|
|
||||||
|
UpdateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CResourceSelector::UpdateUI()
|
void CResourceSelector::UpdateUI()
|
||||||
{
|
{
|
||||||
mpResNameLabel->setText(mpResEntry ? TO_QSTRING(mpResEntry->Name()) + "." + TO_QSTRING(mpResEntry->CookedExtension().ToString()) : "");
|
bool HasResource = mpResEntry != nullptr;
|
||||||
mpResNameLabel->setToolTip(mpResEntry ? TO_QSTRING(mpResEntry->CookedAssetPath(true)) : "");
|
|
||||||
mpFindButton->setEnabled(mpResEntry != nullptr);
|
// Update main UI
|
||||||
mpClearButton->setEnabled(mpResEntry != nullptr);
|
mpResNameLabel->setText(HasResource ? TO_QSTRING(mpResEntry->Name()) + "." + TO_QSTRING(mpResEntry->CookedExtension().ToString()) : "");
|
||||||
|
mpResNameLabel->setToolTip(HasResource ? TO_QSTRING(mpResEntry->CookedAssetPath(true)) : "");
|
||||||
|
mpFindButton->setEnabled(HasResource);
|
||||||
|
mpClearButton->setEnabled(HasResource);
|
||||||
|
|
||||||
|
// Update context menu
|
||||||
|
mpEditAssetAction->setEnabled(HasResource);
|
||||||
|
mpCopyNameAction->setEnabled(HasResource);
|
||||||
|
mpCopyPathAction->setEnabled(HasResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CResourceSelector::SetAllowedExtensions(const QString& /*rkExtension*/)
|
void CResourceSelector::SetAllowedExtensions(const QString& /*rkExtension*/)
|
||||||
|
@ -99,11 +109,18 @@ void CResourceSelector::SetResource(CResource *pRes)
|
||||||
void CResourceSelector::CreateContextMenu(const QPoint& rkPoint)
|
void CResourceSelector::CreateContextMenu(const QPoint& rkPoint)
|
||||||
{
|
{
|
||||||
QMenu Menu;
|
QMenu Menu;
|
||||||
|
Menu.addAction(mpEditAssetAction);
|
||||||
|
Menu.addSeparator();
|
||||||
Menu.addAction(mpCopyNameAction);
|
Menu.addAction(mpCopyNameAction);
|
||||||
Menu.addAction(mpCopyPathAction);
|
Menu.addAction(mpCopyPathAction);
|
||||||
Menu.exec(mapToGlobal(rkPoint));
|
Menu.exec(mapToGlobal(rkPoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CResourceSelector::EditAsset()
|
||||||
|
{
|
||||||
|
gpEdApp->EditResource(mpResEntry);
|
||||||
|
}
|
||||||
|
|
||||||
void CResourceSelector::CopyName()
|
void CResourceSelector::CopyName()
|
||||||
{
|
{
|
||||||
gpEdApp->clipboard()->setText(mpResNameLabel->text());
|
gpEdApp->clipboard()->setText(mpResNameLabel->text());
|
||||||
|
@ -118,8 +135,13 @@ void CResourceSelector::CopyPath()
|
||||||
void CResourceSelector::Set()
|
void CResourceSelector::Set()
|
||||||
{
|
{
|
||||||
// todo - validate this resource is a valid type
|
// todo - validate this resource is a valid type
|
||||||
mpResEntry = gpEdApp->ResourceBrowser()->SelectedEntry();
|
CResourceBrowser *pBrowser = gpEdApp->ResourceBrowser();
|
||||||
OnResourceChanged();
|
|
||||||
|
if (pBrowser->isVisible() && pBrowser->SelectedEntry())
|
||||||
|
{
|
||||||
|
mpResEntry = gpEdApp->ResourceBrowser()->SelectedEntry();
|
||||||
|
OnResourceChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CResourceSelector::Clear()
|
void CResourceSelector::Clear()
|
||||||
|
|
|
@ -21,6 +21,7 @@ class CResourceSelector : public QWidget
|
||||||
QPushButton *mpClearButton;
|
QPushButton *mpClearButton;
|
||||||
|
|
||||||
// Context Menu
|
// Context Menu
|
||||||
|
QAction *mpEditAssetAction;
|
||||||
QAction *mpCopyNameAction;
|
QAction *mpCopyNameAction;
|
||||||
QAction *mpCopyPathAction;
|
QAction *mpCopyPathAction;
|
||||||
|
|
||||||
|
@ -39,6 +40,7 @@ public slots:
|
||||||
void CreateContextMenu(const QPoint& rkPoint);
|
void CreateContextMenu(const QPoint& rkPoint);
|
||||||
void Set();
|
void Set();
|
||||||
void Clear();
|
void Clear();
|
||||||
|
void EditAsset();
|
||||||
void CopyName();
|
void CopyName();
|
||||||
void CopyPath();
|
void CopyPath();
|
||||||
void OnResourceChanged();
|
void OnResourceChanged();
|
||||||
|
|
Loading…
Reference in New Issue