Added Unmap All button to the EGMC editor dialog

This commit is contained in:
parax0 2016-01-16 13:51:38 -07:00
parent af94b54acf
commit f25042125f
3 changed files with 35 additions and 27 deletions

View File

@ -22,7 +22,6 @@ CPoiMapEditDialog::CPoiMapEditDialog(CWorldEditor *pEditor, QWidget *parent)
, mHighlightMode(eHighlightSelected) , mHighlightMode(eHighlightSelected)
, mPickType(eNotPicking) , mPickType(eNotPicking)
, mPickTool(eNormalTool) , mPickTool(eNormalTool)
, mHoverModelIsMapped(false)
, mpHoverModel(nullptr) , mpHoverModel(nullptr)
{ {
mModel.setSourceModel(&mSourceModel); mModel.setSourceModel(&mSourceModel);
@ -47,6 +46,7 @@ CPoiMapEditDialog::CPoiMapEditDialog(CWorldEditor *pEditor, QWidget *parent)
connect(ui->AddMeshButton, SIGNAL(clicked()), this, SLOT(PickButtonClicked())); connect(ui->AddMeshButton, SIGNAL(clicked()), this, SLOT(PickButtonClicked()));
connect(ui->RemoveMeshButton, SIGNAL(clicked()), this, SLOT(PickButtonClicked())); connect(ui->RemoveMeshButton, SIGNAL(clicked()), this, SLOT(PickButtonClicked()));
connect(ui->ToolComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(OnToolComboBoxChanged(int))); connect(ui->ToolComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(OnToolComboBoxChanged(int)));
connect(ui->UnmapAllButton, SIGNAL(clicked()), this, SLOT(OnUnmapAllPressed()));
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()));
} }
@ -108,9 +108,9 @@ void CPoiMapEditDialog::UnhighlightModel(CModelNode *pNode)
pNode->SetScanOverlayEnabled(false); pNode->SetScanOverlayEnabled(false);
} }
void CPoiMapEditDialog::RevertHoverModelOverlay() void CPoiMapEditDialog::RevertModelOverlay(CModelNode *pModel)
{ {
if (mpHoverModel) if (pModel)
{ {
if (mHighlightMode == eHighlightAll) if (mHighlightMode == eHighlightAll)
{ {
@ -118,34 +118,28 @@ void CPoiMapEditDialog::RevertHoverModelOverlay()
{ {
QModelIndex Index = mSourceModel.index(iRow, 0); QModelIndex Index = mSourceModel.index(iRow, 0);
if (mSourceModel.IsModelMapped(Index, mpHoverModel)) if (mSourceModel.IsModelMapped(Index, pModel))
{ {
HighlightModel(Index, mpHoverModel); HighlightModel(Index, pModel);
return; return;
} }
} }
UnhighlightModel(mpHoverModel); UnhighlightModel(pModel);
} }
else if (mHighlightMode == eHighlightSelected) else if (mHighlightMode == eHighlightSelected)
{ {
QModelIndex Index = GetSelectedRow(); QModelIndex Index = GetSelectedRow();
if (mSourceModel.IsModelMapped(Index, mpHoverModel)) if (mSourceModel.IsModelMapped(Index, pModel))
{ HighlightModel(Index, pModel);
HighlightModel(Index, mpHoverModel);
mHoverModelIsMapped = true;
}
else else
{ UnhighlightModel(pModel);
UnhighlightModel(mpHoverModel);
mHoverModelIsMapped = false;
}
} }
else else
UnhighlightModel(mpHoverModel); UnhighlightModel(pModel);
} }
} }
@ -212,9 +206,6 @@ void CPoiMapEditDialog::SetHighlightSelected()
for (int iIdx = 0; iIdx < SelectedIndices.size(); iIdx++) for (int iIdx = 0; iIdx < SelectedIndices.size(); iIdx++)
HighlightPoiModels(SelectedIndices[iIdx]); HighlightPoiModels(SelectedIndices[iIdx]);
if (mpHoverModel && !mHoverModelIsMapped)
HighlightModel(GetSelectedRow(), mpHoverModel);
mHighlightMode = eHighlightSelected; mHighlightMode = eHighlightSelected;
} }
@ -277,6 +268,18 @@ void CPoiMapEditDialog::OnToolComboBoxChanged(int NewIndex)
mPickTool = eSprayCanTool; mPickTool = eSprayCanTool;
} }
void CPoiMapEditDialog::OnUnmapAllPressed()
{
QModelIndex Index = GetSelectedRow();
QList<CModelNode*> ModelList = mSourceModel.GetPoiMeshList(Index);
foreach (CModelNode *pModel, ModelList)
{
mSourceModel.RemoveMapping(Index, pModel);
RevertModelOverlay(pModel);
}
}
void CPoiMapEditDialog::PickButtonClicked() void CPoiMapEditDialog::PickButtonClicked()
{ {
QPushButton *pButton = qobject_cast<QPushButton*>(sender()); QPushButton *pButton = qobject_cast<QPushButton*>(sender());
@ -312,7 +315,7 @@ void CPoiMapEditDialog::StopPicking()
ui->RemoveMeshButton->setChecked(false); ui->RemoveMeshButton->setChecked(false);
mPickType = eNotPicking; mPickType = eNotPicking;
RevertHoverModelOverlay(); RevertModelOverlay(mpHoverModel);
mpHoverModel = nullptr; mpHoverModel = nullptr;
disconnect(mpEditor, 0, this, 0); disconnect(mpEditor, 0, this, 0);
@ -345,8 +348,6 @@ void CPoiMapEditDialog::OnNodePicked(const SRayIntersection& rkRayIntersect, QMo
if (mHighlightMode != eHighlightNone) if (mHighlightMode != eHighlightNone)
HighlightModel(SourceIndices.front(), pModel); HighlightModel(SourceIndices.front(), pModel);
mHoverModelIsMapped = true;
} }
// Remove meshes // Remove meshes
@ -356,7 +357,7 @@ void CPoiMapEditDialog::OnNodePicked(const SRayIntersection& rkRayIntersect, QMo
mSourceModel.RemoveMapping(*it, pModel); mSourceModel.RemoveMapping(*it, pModel);
if (mHighlightMode != eHighlightNone) if (mHighlightMode != eHighlightNone)
RevertHoverModelOverlay(); RevertModelOverlay(mpHoverModel);
else else
UnhighlightModel(pModel); UnhighlightModel(pModel);
} }
@ -366,7 +367,7 @@ void CPoiMapEditDialog::OnNodeHover(const SRayIntersection& rkIntersect, QMouseE
{ {
// 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)
RevertHoverModelOverlay(); RevertModelOverlay(mpHoverModel);
mpHoverModel = static_cast<CModelNode*>(rkIntersect.pNode); mpHoverModel = static_cast<CModelNode*>(rkIntersect.pNode);

View File

@ -41,7 +41,6 @@ class CPoiMapEditDialog : public QMainWindow
eSprayCanTool eSprayCanTool
} mPickTool; } mPickTool;
bool mHoverModelIsMapped;
CModelNode *mpHoverModel; CModelNode *mpHoverModel;
static const CColor skNormalColor; static const CColor skNormalColor;
@ -57,7 +56,7 @@ public:
void HighlightModel(const QModelIndex& rkIndex, CModelNode *pNode); void HighlightModel(const QModelIndex& rkIndex, CModelNode *pNode);
void UnhighlightModel(CModelNode *pNode); void UnhighlightModel(CModelNode *pNode);
bool IsImportant(const QModelIndex& rkIndex); bool IsImportant(const QModelIndex& rkIndex);
void RevertHoverModelOverlay(); void RevertModelOverlay(CModelNode *pModel);
EPickType GetRealPickType(bool AltPressed) const; EPickType GetRealPickType(bool AltPressed) const;
QModelIndex GetSelectedRow() const; QModelIndex GetSelectedRow() const;
@ -69,6 +68,7 @@ public slots:
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 OnToolComboBoxChanged(int NewIndex);
void OnUnmapAllPressed();
void PickButtonClicked(); void PickButtonClicked();
void StopPicking(); void StopPicking();

View File

@ -45,11 +45,18 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="UnmapAllButton">
<property name="text">
<string>Unmap All</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QComboBox" name="ToolComboBox"> <widget class="QComboBox" name="ToolComboBox">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>80</width> <width>85</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>