Added the ability to add/remove POIs to the EGMC editor
This commit is contained in:
parent
f25042125f
commit
8611e692a9
|
@ -129,7 +129,8 @@ HEADERS += \
|
||||||
Undo/CSelectAllCommand.h \
|
Undo/CSelectAllCommand.h \
|
||||||
Undo/CInvertSelectionCommand.h \
|
Undo/CInvertSelectionCommand.h \
|
||||||
WorldEditor/CPoiMapEditDialog.h \
|
WorldEditor/CPoiMapEditDialog.h \
|
||||||
WorldEditor/CPoiMapModel.h
|
WorldEditor/CPoiMapModel.h \
|
||||||
|
WorldEditor/CPoiListDialog.h
|
||||||
|
|
||||||
# Source Files
|
# Source Files
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
|
|
@ -0,0 +1,152 @@
|
||||||
|
#ifndef CPOILISTDIALOG_H
|
||||||
|
#define CPOILISTDIALOG_H
|
||||||
|
|
||||||
|
#include "CPoiMapModel.h"
|
||||||
|
#include "Editor/UICommon.h"
|
||||||
|
|
||||||
|
#include <Core/Resource/CScan.h>
|
||||||
|
#include <Core/Resource/Script/CScriptTemplate.h>
|
||||||
|
#include <Core/Scene/CScene.h>
|
||||||
|
#include <Core/ScriptExtra/CPointOfInterestExtra.h>
|
||||||
|
|
||||||
|
#include <QAbstractListModel>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QListView>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
class CPoiListModel : public QAbstractListModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
CScriptTemplate *mpPoiTemplate;
|
||||||
|
QList<CScriptNode*> mObjList;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CPoiListModel(CScriptTemplate *pPoiTemplate, CPoiMapModel *pMapModel, CScene *pScene, QWidget *pParent = 0)
|
||||||
|
: QAbstractListModel(pParent)
|
||||||
|
, mpPoiTemplate(pPoiTemplate)
|
||||||
|
{
|
||||||
|
const std::list<CScriptObject*>& rkObjList = mpPoiTemplate->ObjectList();
|
||||||
|
|
||||||
|
for (auto it = rkObjList.begin(); it != rkObjList.end(); it++)
|
||||||
|
{
|
||||||
|
CScriptNode *pNode = pScene->NodeForObject(*it);
|
||||||
|
|
||||||
|
if (!pMapModel->IsPoiTracked(pNode))
|
||||||
|
mObjList << pNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int rowCount(const QModelIndex&) const
|
||||||
|
{
|
||||||
|
return mObjList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant data(const QModelIndex& rkIndex, int Role) const
|
||||||
|
{
|
||||||
|
if (!rkIndex.isValid()) return QVariant::Invalid;
|
||||||
|
|
||||||
|
if (Role == Qt::DisplayRole)
|
||||||
|
return TO_QSTRING(mObjList[rkIndex.row()]->Object()->InstanceName());
|
||||||
|
|
||||||
|
if (Role == Qt::DecorationRole)
|
||||||
|
{
|
||||||
|
CScriptNode *pNode = mObjList[rkIndex.row()];
|
||||||
|
CScan *pScan = static_cast<CPointOfInterestExtra*>(pNode->Extra())->GetScan();
|
||||||
|
bool IsImportant = (pScan ? pScan->IsImportant() : false);
|
||||||
|
|
||||||
|
if (IsImportant)
|
||||||
|
return QIcon(":/icons/POI Important.png");
|
||||||
|
else
|
||||||
|
return QIcon(":/icons/POI Normal.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
return QVariant::Invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
CScriptNode* PoiForIndex(const QModelIndex& rkIndex) const
|
||||||
|
{
|
||||||
|
return mObjList[rkIndex.row()];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class CPoiListDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
CPoiListModel mSourceModel;
|
||||||
|
QSortFilterProxyModel mModel;
|
||||||
|
QList<CScriptNode*> mSelection;
|
||||||
|
|
||||||
|
QListView *mpListView;
|
||||||
|
QDialogButtonBox *mpButtonBox;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CPoiListDialog(CScriptTemplate *pPoiTemplate, CPoiMapModel *pMapModel, CScene *pScene, QWidget *pParent = 0)
|
||||||
|
: QDialog(pParent)
|
||||||
|
, mSourceModel(pPoiTemplate, pMapModel, pScene)
|
||||||
|
{
|
||||||
|
mpListView = new QListView(this);
|
||||||
|
mpButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
|
||||||
|
|
||||||
|
QHBoxLayout *pButtonLayout = new QHBoxLayout();
|
||||||
|
pButtonLayout->addStretch();
|
||||||
|
pButtonLayout->addWidget(mpButtonBox);
|
||||||
|
|
||||||
|
QVBoxLayout *pLayout = new QVBoxLayout();
|
||||||
|
pLayout->addWidget(mpListView);
|
||||||
|
pLayout->addLayout(pButtonLayout);
|
||||||
|
setLayout(pLayout);
|
||||||
|
|
||||||
|
mModel.setSourceModel(&mSourceModel);
|
||||||
|
mpListView->setModel(&mModel);
|
||||||
|
mModel.sort(0);
|
||||||
|
|
||||||
|
setWindowTitle("Add POIs");
|
||||||
|
mpListView->setEditTriggers(QListView::NoEditTriggers);
|
||||||
|
mpListView->setSelectionMode(QListView::ExtendedSelection);
|
||||||
|
mpListView->setVerticalScrollMode(QListView::ScrollPerPixel);
|
||||||
|
|
||||||
|
connect(mpListView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(OnDoubleClickItem(QModelIndex)));
|
||||||
|
connect(mpButtonBox, SIGNAL(accepted()), this, SLOT(OnOkClicked()));
|
||||||
|
connect(mpButtonBox, SIGNAL(rejected()), this, SLOT(OnCancelClicked()));
|
||||||
|
}
|
||||||
|
|
||||||
|
const QList<CScriptNode*>& Selection() const
|
||||||
|
{
|
||||||
|
return mSelection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void OnDoubleClickItem(QModelIndex Index)
|
||||||
|
{
|
||||||
|
QModelIndex SourceIndex = mModel.mapToSource(Index);
|
||||||
|
mSelection.clear();
|
||||||
|
mSelection << mSourceModel.PoiForIndex(SourceIndex);
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnOkClicked()
|
||||||
|
{
|
||||||
|
QModelIndexList SelectedIndices = mpListView->selectionModel()->selectedRows();
|
||||||
|
|
||||||
|
foreach (const QModelIndex& rkIndex, SelectedIndices)
|
||||||
|
{
|
||||||
|
QModelIndex SourceIndex = mModel.mapToSource(rkIndex);
|
||||||
|
mSelection << mSourceModel.PoiForIndex(SourceIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnCancelClicked()
|
||||||
|
{
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CPOILISTDIALOG_H
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include <Core/Resource/CScan.h>
|
#include <Core/Resource/CScan.h>
|
||||||
#include <Core/Resource/Cooker/CPoiToWorldCooker.h>
|
#include <Core/Resource/Cooker/CPoiToWorldCooker.h>
|
||||||
|
#include <Core/Resource/Script/CMasterTemplate.h>
|
||||||
#include <Core/ScriptExtra/CPointOfInterestExtra.h>
|
#include <Core/ScriptExtra/CPointOfInterestExtra.h>
|
||||||
|
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
@ -21,7 +22,6 @@ CPoiMapEditDialog::CPoiMapEditDialog(CWorldEditor *pEditor, QWidget *parent)
|
||||||
, mSourceModel(pEditor, this)
|
, mSourceModel(pEditor, this)
|
||||||
, mHighlightMode(eHighlightSelected)
|
, mHighlightMode(eHighlightSelected)
|
||||||
, mPickType(eNotPicking)
|
, mPickType(eNotPicking)
|
||||||
, mPickTool(eNormalTool)
|
|
||||||
, mpHoverModel(nullptr)
|
, mpHoverModel(nullptr)
|
||||||
{
|
{
|
||||||
mModel.setSourceModel(&mSourceModel);
|
mModel.setSourceModel(&mSourceModel);
|
||||||
|
@ -43,18 +43,18 @@ CPoiMapEditDialog::CPoiMapEditDialog(CWorldEditor *pEditor, QWidget *parent)
|
||||||
connect(ui->ListView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
|
connect(ui->ListView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
|
||||||
this, SLOT(OnSelectionChanged(QItemSelection,QItemSelection)));
|
this, SLOT(OnSelectionChanged(QItemSelection,QItemSelection)));
|
||||||
connect(ui->ListView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(OnItemDoubleClick(QModelIndex)));
|
connect(ui->ListView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(OnItemDoubleClick(QModelIndex)));
|
||||||
connect(ui->AddMeshButton, SIGNAL(clicked()), this, SLOT(PickButtonClicked()));
|
connect(ui->MapMeshesButton, SIGNAL(clicked()), this, SLOT(OnPickButtonClicked()));
|
||||||
connect(ui->RemoveMeshButton, SIGNAL(clicked()), this, SLOT(PickButtonClicked()));
|
connect(ui->UnmapMeshesButton, SIGNAL(clicked()), this, SLOT(OnPickButtonClicked()));
|
||||||
connect(ui->ToolComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(OnToolComboBoxChanged(int)));
|
|
||||||
connect(ui->UnmapAllButton, SIGNAL(clicked()), this, SLOT(OnUnmapAllPressed()));
|
connect(ui->UnmapAllButton, SIGNAL(clicked()), this, SLOT(OnUnmapAllPressed()));
|
||||||
|
connect(ui->AddPoiFromViewportButton, SIGNAL(clicked()), this, SLOT(OnPickButtonClicked()));
|
||||||
|
connect(ui->AddPoiFromInstanceListButton, SIGNAL(clicked()), this, SLOT(OnInstanceListButtonClicked()));
|
||||||
|
connect(ui->RemovePoiButton, SIGNAL(clicked()), this, SLOT(OnRemovePoiButtonClicked()));
|
||||||
connect(ui->ButtonBox->button(QDialogButtonBox::Close), SIGNAL(clicked()), this, SLOT(close()));
|
connect(ui->ButtonBox->button(QDialogButtonBox::Close), SIGNAL(clicked()), this, SLOT(close()));
|
||||||
connect(ui->ButtonBox->button(QDialogButtonBox::Save), SIGNAL(clicked()), this, SLOT(Save()));
|
connect(ui->ButtonBox->button(QDialogButtonBox::Save), SIGNAL(clicked()), this, SLOT(Save()));
|
||||||
}
|
}
|
||||||
|
|
||||||
CPoiMapEditDialog::~CPoiMapEditDialog()
|
CPoiMapEditDialog::~CPoiMapEditDialog()
|
||||||
{
|
{
|
||||||
delete ui;
|
|
||||||
|
|
||||||
// Clear model tints
|
// Clear model tints
|
||||||
if (mHighlightMode != eHighlightNone)
|
if (mHighlightMode != eHighlightNone)
|
||||||
SetHighlightNone();
|
SetHighlightNone();
|
||||||
|
@ -62,6 +62,8 @@ CPoiMapEditDialog::~CPoiMapEditDialog()
|
||||||
// Stop picking
|
// Stop picking
|
||||||
if (mPickType != eNotPicking)
|
if (mPickType != eNotPicking)
|
||||||
StopPicking();
|
StopPicking();
|
||||||
|
|
||||||
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPoiMapEditDialog::closeEvent(QCloseEvent* /*pEvent*/)
|
void CPoiMapEditDialog::closeEvent(QCloseEvent* /*pEvent*/)
|
||||||
|
@ -93,7 +95,7 @@ void CPoiMapEditDialog::UnhighlightPoiModels(const QModelIndex& rkIndex)
|
||||||
const QList<CModelNode*>& rkModels = mSourceModel.GetPoiMeshList(SourceIndex);
|
const QList<CModelNode*>& rkModels = mSourceModel.GetPoiMeshList(SourceIndex);
|
||||||
|
|
||||||
for (int iMdl = 0; iMdl < rkModels.size(); iMdl++)
|
for (int iMdl = 0; iMdl < rkModels.size(); iMdl++)
|
||||||
rkModels[iMdl]->SetScanOverlayEnabled(false);
|
RevertModelOverlay(rkModels[iMdl]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPoiMapEditDialog::HighlightModel(const QModelIndex& rkIndex, CModelNode *pNode)
|
void CPoiMapEditDialog::HighlightModel(const QModelIndex& rkIndex, CModelNode *pNode)
|
||||||
|
@ -114,18 +116,28 @@ void CPoiMapEditDialog::RevertModelOverlay(CModelNode *pModel)
|
||||||
{
|
{
|
||||||
if (mHighlightMode == eHighlightAll)
|
if (mHighlightMode == eHighlightAll)
|
||||||
{
|
{
|
||||||
for (int iRow = 0; iRow < mSourceModel.rowCount(QModelIndex()); iRow++)
|
// Prioritize the selected POI over others.
|
||||||
|
QModelIndex Selected = GetSelectedRow();
|
||||||
|
|
||||||
|
if (mSourceModel.IsModelMapped(Selected, pModel))
|
||||||
|
HighlightModel(Selected, pModel);
|
||||||
|
|
||||||
|
// If it's not mapped to the selected POI, then check whether it's mapped to any others.
|
||||||
|
else
|
||||||
{
|
{
|
||||||
QModelIndex Index = mSourceModel.index(iRow, 0);
|
for (int iRow = 0; iRow < mSourceModel.rowCount(QModelIndex()); iRow++)
|
||||||
|
|
||||||
if (mSourceModel.IsModelMapped(Index, pModel))
|
|
||||||
{
|
{
|
||||||
HighlightModel(Index, pModel);
|
QModelIndex Index = mSourceModel.index(iRow, 0);
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UnhighlightModel(pModel);
|
if (mSourceModel.IsModelMapped(Index, pModel))
|
||||||
|
{
|
||||||
|
HighlightModel(Index, pModel);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UnhighlightModel(pModel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (mHighlightMode == eHighlightSelected)
|
else if (mHighlightMode == eHighlightSelected)
|
||||||
|
@ -187,6 +199,8 @@ void CPoiMapEditDialog::Save()
|
||||||
|
|
||||||
void CPoiMapEditDialog::SetHighlightSelected()
|
void CPoiMapEditDialog::SetHighlightSelected()
|
||||||
{
|
{
|
||||||
|
mHighlightMode = eHighlightSelected;
|
||||||
|
|
||||||
const QItemSelection kSelection = ui->ListView->selectionModel()->selection();
|
const QItemSelection kSelection = ui->ListView->selectionModel()->selection();
|
||||||
QList<QModelIndex> SelectedIndices;
|
QList<QModelIndex> SelectedIndices;
|
||||||
QList<QModelIndex> UnselectedIndices;
|
QList<QModelIndex> UnselectedIndices;
|
||||||
|
@ -205,12 +219,12 @@ void CPoiMapEditDialog::SetHighlightSelected()
|
||||||
UnhighlightPoiModels(UnselectedIndices[iIdx]);
|
UnhighlightPoiModels(UnselectedIndices[iIdx]);
|
||||||
for (int iIdx = 0; iIdx < SelectedIndices.size(); iIdx++)
|
for (int iIdx = 0; iIdx < SelectedIndices.size(); iIdx++)
|
||||||
HighlightPoiModels(SelectedIndices[iIdx]);
|
HighlightPoiModels(SelectedIndices[iIdx]);
|
||||||
|
|
||||||
mHighlightMode = eHighlightSelected;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPoiMapEditDialog::SetHighlightAll()
|
void CPoiMapEditDialog::SetHighlightAll()
|
||||||
{
|
{
|
||||||
|
mHighlightMode = eHighlightAll;
|
||||||
|
|
||||||
for (int iRow = 0; iRow < mModel.rowCount(QModelIndex()); iRow++)
|
for (int iRow = 0; iRow < mModel.rowCount(QModelIndex()); iRow++)
|
||||||
HighlightPoiModels(mModel.index(iRow, 0));
|
HighlightPoiModels(mModel.index(iRow, 0));
|
||||||
|
|
||||||
|
@ -220,19 +234,17 @@ void CPoiMapEditDialog::SetHighlightAll()
|
||||||
|
|
||||||
if (mpHoverModel)
|
if (mpHoverModel)
|
||||||
HighlightModel(GetSelectedRow(), mpHoverModel);
|
HighlightModel(GetSelectedRow(), mpHoverModel);
|
||||||
|
|
||||||
mHighlightMode = eHighlightAll;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPoiMapEditDialog::SetHighlightNone()
|
void CPoiMapEditDialog::SetHighlightNone()
|
||||||
{
|
{
|
||||||
|
mHighlightMode = eHighlightNone;
|
||||||
|
|
||||||
for (int iRow = 0; iRow < mModel.rowCount(QModelIndex()); iRow++)
|
for (int iRow = 0; iRow < mModel.rowCount(QModelIndex()); iRow++)
|
||||||
UnhighlightPoiModels(mModel.index(iRow, 0));
|
UnhighlightPoiModels(mModel.index(iRow, 0));
|
||||||
|
|
||||||
if (mpHoverModel)
|
if (mpHoverModel)
|
||||||
UnhighlightModel(mpHoverModel);
|
UnhighlightModel(mpHoverModel);
|
||||||
|
|
||||||
mHighlightMode = eHighlightNone;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPoiMapEditDialog::OnSelectionChanged(const QItemSelection& rkSelected, const QItemSelection& rkDeselected)
|
void CPoiMapEditDialog::OnSelectionChanged(const QItemSelection& rkSelected, const QItemSelection& rkDeselected)
|
||||||
|
@ -260,14 +272,6 @@ void CPoiMapEditDialog::OnItemDoubleClick(QModelIndex Index)
|
||||||
mpEditor->ClearAndSelectNode(pPOI);
|
mpEditor->ClearAndSelectNode(pPOI);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPoiMapEditDialog::OnToolComboBoxChanged(int NewIndex)
|
|
||||||
{
|
|
||||||
if (NewIndex == 0)
|
|
||||||
mPickTool = eNormalTool;
|
|
||||||
else
|
|
||||||
mPickTool = eSprayCanTool;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CPoiMapEditDialog::OnUnmapAllPressed()
|
void CPoiMapEditDialog::OnUnmapAllPressed()
|
||||||
{
|
{
|
||||||
QModelIndex Index = GetSelectedRow();
|
QModelIndex Index = GetSelectedRow();
|
||||||
|
@ -280,39 +284,55 @@ void CPoiMapEditDialog::OnUnmapAllPressed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPoiMapEditDialog::PickButtonClicked()
|
void CPoiMapEditDialog::OnPickButtonClicked()
|
||||||
{
|
{
|
||||||
QPushButton *pButton = qobject_cast<QPushButton*>(sender());
|
QPushButton *pButton = qobject_cast<QPushButton*>(sender());
|
||||||
|
|
||||||
if (!pButton->isChecked())
|
if (pButton == ui->AddPoiFromViewportButton)
|
||||||
mpEditor->ExitPickMode();
|
{
|
||||||
|
mpEditor->EnterPickMode(eScriptNode, true, false, false);
|
||||||
|
connect(mpEditor, SIGNAL(PickModeExited()), this, SLOT(StopPicking()));
|
||||||
|
connect(mpEditor, SIGNAL(PickModeClick(SRayIntersection,QMouseEvent*)), this, SLOT(OnPoiPicked(SRayIntersection,QMouseEvent*)));
|
||||||
|
|
||||||
|
pButton->setChecked(true);
|
||||||
|
ui->MapMeshesButton->setChecked(false);
|
||||||
|
ui->UnmapMeshesButton->setChecked(false);
|
||||||
|
|
||||||
|
mPickType = eAddPOIs;
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mpEditor->EnterPickMode(eModelNode, false, false, true);
|
if (!pButton->isChecked())
|
||||||
connect(mpEditor, SIGNAL(PickModeExited()), this, SLOT(StopPicking()));
|
mpEditor->ExitPickMode();
|
||||||
connect(mpEditor, SIGNAL(PickModeClick(SRayIntersection,QMouseEvent*)), this, SLOT(OnNodePicked(SRayIntersection,QMouseEvent*)));
|
|
||||||
connect(mpEditor, SIGNAL(PickModeHoverChanged(SRayIntersection,QMouseEvent*)), this, SLOT(OnNodeHover(SRayIntersection,QMouseEvent*)));
|
|
||||||
pButton->setChecked(true);
|
|
||||||
|
|
||||||
if (pButton == ui->AddMeshButton)
|
else
|
||||||
{
|
{
|
||||||
mPickType = eAddMeshes;
|
mpEditor->EnterPickMode(eModelNode, false, false, true);
|
||||||
ui->RemoveMeshButton->setChecked(false);
|
connect(mpEditor, SIGNAL(PickModeExited()), this, SLOT(StopPicking()));
|
||||||
}
|
connect(mpEditor, SIGNAL(PickModeHoverChanged(SRayIntersection,QMouseEvent*)), this, SLOT(OnModelHover(SRayIntersection,QMouseEvent*)));
|
||||||
|
pButton->setChecked(true);
|
||||||
|
|
||||||
else if (pButton == ui->RemoveMeshButton)
|
if (pButton == ui->MapMeshesButton)
|
||||||
{
|
{
|
||||||
mPickType = eRemoveMeshes;
|
mPickType = eAddMeshes;
|
||||||
ui->AddMeshButton->setChecked(false);
|
ui->UnmapMeshesButton->setChecked(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (pButton == ui->UnmapMeshesButton)
|
||||||
|
{
|
||||||
|
mPickType = eRemoveMeshes;
|
||||||
|
ui->MapMeshesButton->setChecked(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPoiMapEditDialog::StopPicking()
|
void CPoiMapEditDialog::StopPicking()
|
||||||
{
|
{
|
||||||
ui->AddMeshButton->setChecked(false);
|
ui->MapMeshesButton->setChecked(false);
|
||||||
ui->RemoveMeshButton->setChecked(false);
|
ui->UnmapMeshesButton->setChecked(false);
|
||||||
|
ui->AddPoiFromViewportButton->setChecked(false);
|
||||||
mPickType = eNotPicking;
|
mPickType = eNotPicking;
|
||||||
|
|
||||||
RevertModelOverlay(mpHoverModel);
|
RevertModelOverlay(mpHoverModel);
|
||||||
|
@ -321,7 +341,50 @@ void CPoiMapEditDialog::StopPicking()
|
||||||
disconnect(mpEditor, 0, this, 0);
|
disconnect(mpEditor, 0, this, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPoiMapEditDialog::OnNodePicked(const SRayIntersection& rkRayIntersect, QMouseEvent* pEvent)
|
void CPoiMapEditDialog::OnInstanceListButtonClicked()
|
||||||
|
{
|
||||||
|
EGame Game = mpEditor->ActiveArea()->Version();
|
||||||
|
CScriptTemplate *pPoiTemplate = CMasterTemplate::GetMasterForGame(Game)->TemplateByID("POIN");
|
||||||
|
|
||||||
|
CPoiListDialog Dialog(pPoiTemplate, &mSourceModel, mpEditor->Scene(), this);
|
||||||
|
Dialog.exec();
|
||||||
|
|
||||||
|
const QList<CScriptNode*>& rkSelection = Dialog.Selection();
|
||||||
|
|
||||||
|
if (!rkSelection.empty())
|
||||||
|
{
|
||||||
|
foreach (CScriptNode *pNode, rkSelection)
|
||||||
|
mSourceModel.AddPOI(pNode);
|
||||||
|
|
||||||
|
mModel.sort(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPoiMapEditDialog::OnRemovePoiButtonClicked()
|
||||||
|
{
|
||||||
|
if (ui->ListView->selectionModel()->hasSelection())
|
||||||
|
{
|
||||||
|
QModelIndex Index = ui->ListView->selectionModel()->selectedRows().front();
|
||||||
|
UnhighlightPoiModels(Index);
|
||||||
|
Index = mModel.mapToSource(Index);
|
||||||
|
mSourceModel.RemovePOI(Index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPoiMapEditDialog::OnPoiPicked(const SRayIntersection& rkIntersect, QMouseEvent *pEvent)
|
||||||
|
{
|
||||||
|
CScriptNode *pPOI = static_cast<CScriptNode*>(rkIntersect.pNode);
|
||||||
|
if (pPOI->Object()->ObjectTypeID() != CFourCC("POIN").ToLong()) return;
|
||||||
|
|
||||||
|
mSourceModel.AddPOI(pPOI);
|
||||||
|
mModel.sort(0);
|
||||||
|
|
||||||
|
// Exit pick mode unless the user is holding the Ctrl key
|
||||||
|
if (!(pEvent->modifiers() & Qt::ControlModifier))
|
||||||
|
mpEditor->ExitPickMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPoiMapEditDialog::OnModelPicked(const SRayIntersection& rkRayIntersect, QMouseEvent* pEvent)
|
||||||
{
|
{
|
||||||
if (!rkRayIntersect.pNode) return;
|
if (!rkRayIntersect.pNode) return;
|
||||||
|
|
||||||
|
@ -363,7 +426,7 @@ void CPoiMapEditDialog::OnNodePicked(const SRayIntersection& rkRayIntersect, QMo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPoiMapEditDialog::OnNodeHover(const SRayIntersection& rkIntersect, QMouseEvent *pEvent)
|
void CPoiMapEditDialog::OnModelHover(const SRayIntersection& rkIntersect, QMouseEvent *pEvent)
|
||||||
{
|
{
|
||||||
// Restore old hover model to correct overlay color, and set new hover model
|
// Restore old hover model to correct overlay color, and set new hover model
|
||||||
if (mpHoverModel)
|
if (mpHoverModel)
|
||||||
|
@ -371,9 +434,9 @@ void CPoiMapEditDialog::OnNodeHover(const SRayIntersection& rkIntersect, QMouseE
|
||||||
|
|
||||||
mpHoverModel = static_cast<CModelNode*>(rkIntersect.pNode);
|
mpHoverModel = static_cast<CModelNode*>(rkIntersect.pNode);
|
||||||
|
|
||||||
// If we're using the spray can and the mouse is pressed, treat this as a click.
|
// If the left mouse button is pressed, treat this as a click.
|
||||||
if (mPickTool == eSprayCanTool && (pEvent->buttons() & Qt::LeftButton))
|
if (pEvent->buttons() & Qt::LeftButton)
|
||||||
OnNodePicked(rkIntersect, pEvent);
|
OnModelPicked(rkIntersect, pEvent);
|
||||||
|
|
||||||
// Otherwise, process as a mouseover
|
// Otherwise, process as a mouseover
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
#ifndef CPOIMAPEDITDIALOG_H
|
#ifndef CPOIMAPEDITDIALOG_H
|
||||||
#define CPOIMAPEDITDIALOG_H
|
#define CPOIMAPEDITDIALOG_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
|
||||||
#include "CPoiMapModel.h"
|
#include "CPoiMapModel.h"
|
||||||
|
#include "CPoiListDialog.h"
|
||||||
|
|
||||||
#include <QItemSelection>
|
#include <QItemSelection>
|
||||||
|
#include <QMainWindow>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -27,6 +29,7 @@ class CPoiMapEditDialog : public QMainWindow
|
||||||
QSortFilterProxyModel mModel;
|
QSortFilterProxyModel mModel;
|
||||||
EHighlightMode mHighlightMode;
|
EHighlightMode mHighlightMode;
|
||||||
|
|
||||||
|
// Viewport Picking
|
||||||
enum EPickType
|
enum EPickType
|
||||||
{
|
{
|
||||||
eNotPicking,
|
eNotPicking,
|
||||||
|
@ -35,12 +38,6 @@ class CPoiMapEditDialog : public QMainWindow
|
||||||
eAddPOIs
|
eAddPOIs
|
||||||
} mPickType;
|
} mPickType;
|
||||||
|
|
||||||
enum EPickTool
|
|
||||||
{
|
|
||||||
eNormalTool,
|
|
||||||
eSprayCanTool
|
|
||||||
} mPickTool;
|
|
||||||
|
|
||||||
CModelNode *mpHoverModel;
|
CModelNode *mpHoverModel;
|
||||||
|
|
||||||
static const CColor skNormalColor;
|
static const CColor skNormalColor;
|
||||||
|
@ -67,13 +64,15 @@ public slots:
|
||||||
void SetHighlightNone();
|
void SetHighlightNone();
|
||||||
void OnSelectionChanged(const QItemSelection& rkSelected, const QItemSelection& rkDeselected);
|
void OnSelectionChanged(const QItemSelection& rkSelected, const QItemSelection& rkDeselected);
|
||||||
void OnItemDoubleClick(QModelIndex Index);
|
void OnItemDoubleClick(QModelIndex Index);
|
||||||
void OnToolComboBoxChanged(int NewIndex);
|
|
||||||
void OnUnmapAllPressed();
|
void OnUnmapAllPressed();
|
||||||
|
|
||||||
void PickButtonClicked();
|
void OnPickButtonClicked();
|
||||||
void StopPicking();
|
void StopPicking();
|
||||||
void OnNodePicked(const SRayIntersection& rkIntersect, QMouseEvent *pEvent);
|
void OnInstanceListButtonClicked();
|
||||||
void OnNodeHover(const SRayIntersection& rkIntersect, QMouseEvent *pEvent);
|
void OnRemovePoiButtonClicked();
|
||||||
|
void OnPoiPicked(const SRayIntersection& rkIntersect, QMouseEvent *pEvent);
|
||||||
|
void OnModelPicked(const SRayIntersection& rkIntersect, QMouseEvent *pEvent);
|
||||||
|
void OnModelHover(const SRayIntersection& rkIntersect, QMouseEvent *pEvent);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void Closed();
|
void Closed();
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>274</width>
|
<width>263</width>
|
||||||
<height>308</height>
|
<height>306</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -16,11 +16,11 @@
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="AddMeshButton">
|
<widget class="QPushButton" name="MapMeshesButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string>Map</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../Icons.qrc">
|
<iconset resource="../Icons.qrc">
|
||||||
|
@ -32,9 +32,9 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="RemoveMeshButton">
|
<widget class="QPushButton" name="UnmapMeshesButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string>Unmap</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../Icons.qrc">
|
<iconset resource="../Icons.qrc">
|
||||||
|
@ -52,26 +52,10 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
</layout>
|
||||||
<widget class="QComboBox" name="ToolComboBox">
|
</item>
|
||||||
<property name="minimumSize">
|
<item>
|
||||||
<size>
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<width>85</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Normal Tool</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Spray Can</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -85,6 +69,51 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="AddPoiFromViewportButton">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Add from Viewport</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../Icons.qrc">
|
||||||
|
<normaloff>:/icons/SelectMode.png</normaloff>:/icons/SelectMode.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="AddPoiFromInstanceListButton">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Add from Instance List</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../Icons.qrc">
|
||||||
|
<normaloff>:/icons/Instances.png</normaloff>:/icons/Instances.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="RemovePoiButton">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Remove</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../Icons.qrc">
|
||||||
|
<normaloff>:/icons/Minus v2.png</normaloff>:/icons/Minus v2.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -107,9 +107,14 @@ void CPoiMapModel::AddPOI(CScriptNode *pPOI)
|
||||||
{
|
{
|
||||||
if (!mModelMap.contains(pPOI))
|
if (!mModelMap.contains(pPOI))
|
||||||
{
|
{
|
||||||
|
int NewIndex = mpPoiToWorld->NumMappedPOIs();
|
||||||
|
beginInsertRows(QModelIndex(), NewIndex, NewIndex);
|
||||||
|
|
||||||
QList<CModelNode*> *pList = new QList<CModelNode*>;
|
QList<CModelNode*> *pList = new QList<CModelNode*>;
|
||||||
mModelMap[pPOI] = pList;
|
mModelMap[pPOI] = pList;
|
||||||
mpPoiToWorld->AddPoi(pPOI->Object()->InstanceID());
|
mpPoiToWorld->AddPoi(pPOI->Object()->InstanceID());
|
||||||
|
|
||||||
|
endInsertRows();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,6 +132,7 @@ void CPoiMapModel::AddMapping(const QModelIndex& rkIndex, CModelNode *pNode)
|
||||||
|
|
||||||
void CPoiMapModel::RemovePOI(const QModelIndex& rkIndex)
|
void CPoiMapModel::RemovePOI(const QModelIndex& rkIndex)
|
||||||
{
|
{
|
||||||
|
beginRemoveRows(QModelIndex(), rkIndex.row(), rkIndex.row());
|
||||||
CScriptNode *pPOI = PoiNodePointer(rkIndex);
|
CScriptNode *pPOI = PoiNodePointer(rkIndex);
|
||||||
|
|
||||||
if (mModelMap.contains(pPOI))
|
if (mModelMap.contains(pPOI))
|
||||||
|
@ -136,6 +142,7 @@ void CPoiMapModel::RemovePOI(const QModelIndex& rkIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
mpPoiToWorld->RemovePoi(pPOI->Object()->InstanceID());
|
mpPoiToWorld->RemovePoi(pPOI->Object()->InstanceID());
|
||||||
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPoiMapModel::RemoveMapping(const QModelIndex& rkIndex, CModelNode *pNode)
|
void CPoiMapModel::RemoveMapping(const QModelIndex& rkIndex, CModelNode *pNode)
|
||||||
|
@ -152,6 +159,11 @@ void CPoiMapModel::RemoveMapping(const QModelIndex& rkIndex, CModelNode *pNode)
|
||||||
mpPoiToWorld->RemovePoiMeshMap(pPOI->Object()->InstanceID(), pNode->FindMeshID());
|
mpPoiToWorld->RemovePoiMeshMap(pPOI->Object()->InstanceID(), pNode->FindMeshID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CPoiMapModel::IsPoiTracked(CScriptNode *pPOI) const
|
||||||
|
{
|
||||||
|
return mModelMap.contains(pPOI);
|
||||||
|
}
|
||||||
|
|
||||||
bool CPoiMapModel::IsModelMapped(const QModelIndex& rkIndex, CModelNode *pNode) const
|
bool CPoiMapModel::IsModelMapped(const QModelIndex& rkIndex, CModelNode *pNode) const
|
||||||
{
|
{
|
||||||
if (!pNode) return false;
|
if (!pNode) return false;
|
||||||
|
|
|
@ -31,6 +31,7 @@ public:
|
||||||
void AddMapping(const QModelIndex& rkIndex, CModelNode *pNode);
|
void AddMapping(const QModelIndex& rkIndex, CModelNode *pNode);
|
||||||
void RemovePOI(const QModelIndex& rkIndex);
|
void RemovePOI(const QModelIndex& rkIndex);
|
||||||
void RemoveMapping(const QModelIndex& rkIndex, CModelNode *pNode);
|
void RemoveMapping(const QModelIndex& rkIndex, CModelNode *pNode);
|
||||||
|
bool IsPoiTracked(CScriptNode *pPOI) const;
|
||||||
bool IsModelMapped(const QModelIndex& rkIndex, CModelNode *pNode) const;
|
bool IsModelMapped(const QModelIndex& rkIndex, CModelNode *pNode) const;
|
||||||
|
|
||||||
CScriptNode* PoiNodePointer(const QModelIndex& rkIndex) const;
|
CScriptNode* PoiNodePointer(const QModelIndex& rkIndex) const;
|
||||||
|
|
Loading…
Reference in New Issue