Added ability to double click a resource in the resource browser to open it for editing

This commit is contained in:
parax0 2016-08-28 04:07:17 -06:00
parent 20bddd5ed7
commit d263610d43
9 changed files with 101 additions and 45 deletions

View File

@ -31,6 +31,10 @@ CGameExporter::CGameExporter(const TString& rkInputDir, const TString& rkOutputD
mStore.SetActiveProject(mpProject);
}
#if PUBLIC_RELEASE
#error Fix export directory being cleared!
#endif
bool CGameExporter::Export()
{
SCOPED_TIMER(ExportGame);

View File

@ -175,6 +175,50 @@ CAnimation* CCharacterEditor::CurrentAnimation() const
return nullptr;
}
void CCharacterEditor::SetActiveAnimSet(CAnimSet *pSet)
{
mpSet = pSet;
mpCharNode->SetCharSet(mpSet);
SET_WINDOWTITLE_APPVARS("%APP_FULL_NAME% - Character Editor: " + TO_QSTRING(mpSet->Source()));
// Clear selected bone
ui->SkeletonHierarchyTreeView->selectionModel()->clear();
SetSelectedBone(nullptr);
// Set up character combo box
mpCharComboBox->blockSignals(true);
mpCharComboBox->clear();
for (u32 iChar = 0; iChar < mpSet->NumNodes(); iChar++)
mpCharComboBox->addItem( TO_QSTRING(mpSet->NodeName(iChar)) );
SetActiveCharacterIndex(0);
mpCharComboBox->blockSignals(false);
// Set up anim combo box
mpAnimComboBox->blockSignals(true);
mpAnimComboBox->clear();
for (u32 iAnim = 0; iAnim < mpSet->NumAnims(); iAnim++)
mpAnimComboBox->addItem( TO_QSTRING(mpSet->AnimName(iAnim)) );
SetActiveAnimation(0);
mpAnimComboBox->blockSignals(false);
// Set up skeleton tree view
CSkeleton *pSkel = mpSet->NodeSkeleton(mCurrentChar);
mSkeletonModel.SetSkeleton(pSkel);
ui->SkeletonHierarchyTreeView->expandAll();
ui->SkeletonHierarchyTreeView->resizeColumnToContents(0);
// Select first child bone of root (which should be Skeleton_Root) to line up the camera for orbiting.
QModelIndex RootIndex = mSkeletonModel.index(0, 0, QModelIndex());
ui->SkeletonHierarchyTreeView->selectionModel()->setCurrentIndex( mSkeletonModel.index(0, 0, RootIndex), QItemSelectionModel::ClearAndSelect );
// Run CCamera::SetOrbit to reset orbit distance.
ui->Viewport->Camera().SetOrbit(mpCharNode->AABox(), 4.f);
}
void CCharacterEditor::SetSelectedBone(CBone *pBone)
{
if (pBone != mpSelectedBone)
@ -195,46 +239,7 @@ void CCharacterEditor::Open()
if (pSet)
{
mpSet = pSet;
mpCharNode->SetCharSet(mpSet);
SET_WINDOWTITLE_APPVARS("%APP_FULL_NAME% - Character Editor: " + TO_QSTRING(mpSet->Source()));
// Clear selected bone
ui->SkeletonHierarchyTreeView->selectionModel()->clear();
SetSelectedBone(nullptr);
// Set up character combo box
mpCharComboBox->blockSignals(true);
mpCharComboBox->clear();
for (u32 iChar = 0; iChar < mpSet->NumNodes(); iChar++)
mpCharComboBox->addItem( TO_QSTRING(mpSet->NodeName(iChar)) );
SetActiveCharacterIndex(0);
mpCharComboBox->blockSignals(false);
// Set up anim combo box
mpAnimComboBox->blockSignals(true);
mpAnimComboBox->clear();
for (u32 iAnim = 0; iAnim < mpSet->NumAnims(); iAnim++)
mpAnimComboBox->addItem( TO_QSTRING(mpSet->AnimName(iAnim)) );
SetActiveAnimation(0);
mpAnimComboBox->blockSignals(false);
// Set up skeleton tree view
CSkeleton *pSkel = mpSet->NodeSkeleton(mCurrentChar);
mSkeletonModel.SetSkeleton(pSkel);
ui->SkeletonHierarchyTreeView->expandAll();
ui->SkeletonHierarchyTreeView->resizeColumnToContents(0);
// Select first child bone of root (which should be Skeleton_Root) to line up the camera for orbiting.
QModelIndex RootIndex = mSkeletonModel.index(0, 0, QModelIndex());
ui->SkeletonHierarchyTreeView->selectionModel()->setCurrentIndex( mSkeletonModel.index(0, 0, RootIndex), QItemSelectionModel::ClearAndSelect );
// Run CCamera::SetOrbit to reset orbit distance.
ui->Viewport->Camera().SetOrbit(mpCharNode->AABox(), 4.f);
SetActiveAnimSet(pSet);
}
else

View File

@ -51,6 +51,7 @@ public:
void UpdateCameraOrbit();
CSkeleton* CurrentSkeleton() const;
CAnimation* CurrentAnimation() const;
void SetActiveAnimSet(CAnimSet *pSet);
void SetSelectedBone(CBone *pBone);
public slots:

View File

@ -1,11 +1,15 @@
#include "CResourceBrowser.h"
#include "ui_CResourceBrowser.h"
#include "Editor/ModelEditor/CModelEditorWindow.h"
#include "Editor/CharacterEditor/CCharacterEditor.h"
#include <QMessageBox>
CResourceBrowser::CResourceBrowser(QWidget *pParent)
: QDialog(pParent)
, mpUI(new Ui::CResourceBrowser)
{
mpUI->setupUi(this);
setWindowFlags(windowFlags() | Qt::WindowMinimizeButtonHint);
// Set up table models
mpModel = new CResourceTableModel(this);
@ -29,6 +33,7 @@ CResourceBrowser::CResourceBrowser(QWidget *pParent)
connect(mpUI->SearchBar, SIGNAL(textChanged(QString)), this, SLOT(OnSearchStringChanged()));
connect(mpUI->SortComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(OnSortModeChanged(int)));
connect(mpUI->DirectoryTreeView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(OnDirectorySelectionChanged(QModelIndex,QModelIndex)));
connect(mpUI->ResourceTableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(OnDoubleClickResource(QModelIndex)));
}
CResourceBrowser::~CResourceBrowser()
@ -61,3 +66,40 @@ void CResourceBrowser::OnDirectorySelectionChanged(const QModelIndex& rkNewIndex
mpProxyModel->SetDirectory(pDir);
}
void CResourceBrowser::OnDoubleClickResource(QModelIndex Index)
{
QModelIndex SourceIndex = mpProxyModel->mapToSource(Index);
CResourceEntry *pEntry = mpModel->IndexEntry(SourceIndex);
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.");
}

View File

@ -27,6 +27,7 @@ public slots:
void OnSortModeChanged(int Index);
void OnSearchStringChanged();
void OnDirectorySelectionChanged(const QModelIndex& rkNewIndex, const QModelIndex& rkPrevIndex);
void OnDoubleClickResource(QModelIndex Index);
};
#endif // CRESOURCEBROWSER_H

View File

@ -126,7 +126,10 @@
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>

View File

@ -3,7 +3,7 @@
<objects>
<object ID="0x00" template="Script/Actor.xml"/>
<object ID="0x02" template="Script/Waypoint.xml"/>
<object ID="0x03" template="Script/DoorArea.xml"/>
<object ID="0x03" template="Script/Door.xml"/>
<object ID="0x04" template="Script/Trigger.xml"/>
<object ID="0x05" template="Script/Timer.xml"/>
<object ID="0x06" template="Script/Counter.xml"/>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<ScriptTemplate version="4">
<name>DoorArea</name>
<name>Door</name>
<properties>
<property ID="0x00" name="Name" type="string"/>
<property ID="0x01" name="Position" type="vector3f"/>

View File

@ -8,9 +8,9 @@
<property ID="0x03" name="Scale" type="vector3f"/>
<struct ID="0x04" name="PatternedInfo" template="Structs/PatternedInfo.xml"/>
<struct ID="0x05" name="ActorParameters" template="Structs/ActorParameters.xml"/>
<property ID="0x06" name="Unknown 1" type="bool"/>
<property ID="0x06" name="Unused" type="bool"/>
<property ID="0x07" name="ELSC" type="file" extensions="ELSC"/>
<property ID="0x08" name="Unknown 2" type="string"/>
<property ID="0x08" name="Target Locator" type="string"/>
</properties>
<states/>
<messages/>