diff --git a/src/Core/Resource/CCollisionMaterial.cpp b/src/Core/Resource/CCollisionMaterial.cpp
index a76a9aac..f918d2b2 100644
--- a/src/Core/Resource/CCollisionMaterial.cpp
+++ b/src/Core/Resource/CCollisionMaterial.cpp
@@ -79,5 +79,5 @@ bool CCollisionMaterial::IsFloor() const
bool CCollisionMaterial::IsUnstandable(EGame Game) const
{
- return HasFlag(eCF_JumpNotAllowed) || (Game >= eEchoesDemo && !HasFlag(eCF_Floor) && HasAnyFlags(eCF_Wall | eCF_Ceiling));
+ return HasFlag(eCF_JumpNotAllowed) || (Game >= eCorruptionProto && !HasFlag(eCF_Floor) && HasAnyFlags(eCF_Wall | eCF_Ceiling));
}
diff --git a/src/Core/Scene/CCollisionNode.cpp b/src/Core/Scene/CCollisionNode.cpp
index 99254ffe..c6b6fc77 100644
--- a/src/Core/Scene/CCollisionNode.cpp
+++ b/src/Core/Scene/CCollisionNode.cpp
@@ -1,4 +1,5 @@
#include "CCollisionNode.h"
+#include "CScene.h"
#include "Core/Render/CDrawUtil.h"
#include "Core/Render/CGraphics.h"
#include "Core/Render/CRenderer.h"
@@ -38,8 +39,8 @@ void CCollisionNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, ER
glDepthMask(GL_TRUE);
// Turn off backface culling
- EGame CollisionGame = mpCollision->Game();
- bool ForceDisableBackfaceCull = (rkViewInfo.CollisionSettings.DrawBackfaces || CollisionGame == eReturns) && glIsEnabled(GL_CULL_FACE);
+ EGame Game = mpScene->ActiveArea()->Game();
+ bool ForceDisableBackfaceCull = (rkViewInfo.CollisionSettings.DrawBackfaces || Game == eReturns) && glIsEnabled(GL_CULL_FACE);
if (ForceDisableBackfaceCull)
glDisable(GL_CULL_FACE);
@@ -65,11 +66,11 @@ void CCollisionNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, ER
if (rkViewInfo.CollisionSettings.HighlightMask != 0 && (rMat.RawFlags() & rkViewInfo.CollisionSettings.HighlightMask) == rkViewInfo.CollisionSettings.HighlightMask)
Tint *= CColor::skRed;
- else if (CollisionGame != eReturns && rkViewInfo.CollisionSettings.TintWithSurfaceColor)
- Tint *= rMat.SurfaceColor(CollisionGame);
+ else if (Game != eReturns && rkViewInfo.CollisionSettings.TintWithSurfaceColor)
+ Tint *= rMat.SurfaceColor(Game);
- bool IsFloor = (rkViewInfo.CollisionSettings.TintUnwalkableTris ? rMat.IsFloor() : true) || CollisionGame == eReturns;
- bool IsUnstandable = (rkViewInfo.CollisionSettings.TintUnwalkableTris ? rMat.IsUnstandable(CollisionGame) : false) && CollisionGame != eReturns;
+ bool IsFloor = (rkViewInfo.CollisionSettings.TintUnwalkableTris ? rMat.IsFloor() : true) || Game == eReturns;
+ bool IsUnstandable = (rkViewInfo.CollisionSettings.TintUnwalkableTris ? rMat.IsUnstandable(Game) : false) && Game != eReturns;
CDrawUtil::UseCollisionShader(IsFloor, IsUnstandable, Tint);
pMesh->DrawMaterial(iMat, false);
@@ -85,7 +86,7 @@ void CCollisionNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, ER
// Draw collision bounds for area collision
// note: right now checking parent is the best way to check whether this node is area collision instead of actor collision
// actor collision will have a script node parent whereas area collision will have a root node parent
- if (rkViewInfo.CollisionSettings.DrawAreaCollisionBounds && Parent()->NodeType() == eRootNode && CollisionGame != eReturns)
+ if (rkViewInfo.CollisionSettings.DrawAreaCollisionBounds && Parent()->NodeType() == eRootNode && Game != eReturns)
CDrawUtil::DrawWireCube( mpCollision->MeshByIndex(0)->BoundingBox(), CColor::skRed );
}
diff --git a/src/Editor/CEditorApplication.h b/src/Editor/CEditorApplication.h
index 645d3cc0..77164e5e 100644
--- a/src/Editor/CEditorApplication.h
+++ b/src/Editor/CEditorApplication.h
@@ -44,6 +44,7 @@ public:
inline CWorldEditor* WorldEditor() const { return mpWorldEditor; }
inline CResourceBrowser* ResourceBrowser() const { return mpResourceBrowser; }
inline CProjectSettingsDialog* ProjectDialog() const { return mpProjectDialog; }
+ inline EGame CurrentGame() const { return mpActiveProject ? mpActiveProject->Game() : eUnknownGame; }
inline void SetEditorTicksEnabled(bool Enabled) { Enabled ? mRefreshTimer.start(gkTickFrequencyMS) : mRefreshTimer.stop(); }
inline bool AreEditorTicksEnabled() const { return mRefreshTimer.isActive(); }
diff --git a/src/Editor/Editor.pro b/src/Editor/Editor.pro
index 4ef9a1a5..dea5cb07 100644
--- a/src/Editor/Editor.pro
+++ b/src/Editor/Editor.pro
@@ -131,7 +131,6 @@ HEADERS += \
CErrorLogDialog.h \
Undo/CSelectAllCommand.h \
Undo/CInvertSelectionCommand.h \
- WorldEditor/CPoiMapEditDialog.h \
WorldEditor/CPoiMapModel.h \
WorldEditor/CPoiListDialog.h \
PropertyEdit/CPropertyModel.h \
@@ -183,7 +182,9 @@ HEADERS += \
WorldEditor/CWorldInfoSidebar.h \
WorldEditor/CWorldTreeModel.h \
Widgets/CTimedLineEdit.h \
- CProjectSettingsDialog.h
+ CProjectSettingsDialog.h \
+ WorldEditor/CPoiMapSidebar.h \
+ WorldEditor/CWorldEditorSidebar.h
# Source Files
SOURCES += \
@@ -216,7 +217,6 @@ SOURCES += \
TestDialog.cpp \
UICommon.cpp \
CErrorLogDialog.cpp \
- WorldEditor/CPoiMapEditDialog.cpp \
WorldEditor/CPoiMapModel.cpp \
PropertyEdit/CPropertyModel.cpp \
PropertyEdit/CPropertyDelegate.cpp \
@@ -249,7 +249,9 @@ SOURCES += \
WorldEditor/CScriptEditSidebar.cpp \
WorldEditor/CWorldInfoSidebar.cpp \
WorldEditor/CWorldTreeModel.cpp \
- CProjectSettingsDialog.cpp
+ CProjectSettingsDialog.cpp \
+ WorldEditor/CPoiMapSidebar.cpp \
+ WorldEditor/CWorldEditorSidebar.cpp
# UI Files
FORMS += \
@@ -263,7 +265,6 @@ FORMS += \
WorldEditor/WInstancesTab.ui \
WorldEditor/WModifyTab.ui \
CErrorLogDialog.ui \
- WorldEditor/CPoiMapEditDialog.ui \
WorldEditor/CTemplateEditDialog.ui \
WorldEditor/CLinkDialog.ui \
WorldEditor/CSelectInstanceDialog.ui \
@@ -274,4 +275,5 @@ FORMS += \
ResourceBrowser/CResourceBrowser.ui \
CExportGameDialog.ui \
WorldEditor/CWorldInfoSidebar.ui \
- CProjectSettingsDialog.ui
+ CProjectSettingsDialog.ui \
+ WorldEditor/CPoiMapSidebar.ui
diff --git a/src/Editor/WorldEditor/CCollisionRenderSettingsDialog.cpp b/src/Editor/WorldEditor/CCollisionRenderSettingsDialog.cpp
index 2a9589b8..5a1e99bb 100644
--- a/src/Editor/WorldEditor/CCollisionRenderSettingsDialog.cpp
+++ b/src/Editor/WorldEditor/CCollisionRenderSettingsDialog.cpp
@@ -11,6 +11,7 @@ CCollisionRenderSettingsDialog::CCollisionRenderSettingsDialog(CWorldEditor *pEd
mpUi->setupUi(this);
SetupWidgets();
+ connect(gpEdApp, SIGNAL(ActiveProjectChanged(CGameProject*)), this, SLOT(SetupWidgets()));
connect(mpUi->HideMaskLineEdit, SIGNAL(textChanged(QString)), this, SLOT(OnHideMaskChanged(QString)));
connect(mpUi->HighlightMaskLineEdit, SIGNAL(textChanged(QString)), this, SLOT(OnHighlightMaskChanged(QString)));
connect(mpUi->WireframeCheckBox, SIGNAL(toggled(bool)), this, SLOT(OnWireframeToggled(bool)));
diff --git a/src/Editor/WorldEditor/CPoiMapEditDialog.ui b/src/Editor/WorldEditor/CPoiMapEditDialog.ui
deleted file mode 100644
index 4e7c66e1..00000000
--- a/src/Editor/WorldEditor/CPoiMapEditDialog.ui
+++ /dev/null
@@ -1,196 +0,0 @@
-
-
- CPoiMapEditDialog
-
-
-
- 0
- 0
- 263
- 306
-
-
-
- Edit POI to World Mappings
-
-
-
- -
-
-
-
-
-
- Map
-
-
-
- :/icons/Plus.png:/icons/Plus.png
-
-
- true
-
-
-
- -
-
-
- Unmap
-
-
-
- :/icons/Minus v2.png:/icons/Minus v2.png
-
-
- true
-
-
-
- -
-
-
- Unmap All
-
-
-
-
-
- -
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- Add from Viewport
-
-
-
-
-
-
- :/icons/SelectMode_16px.png:/icons/SelectMode_16px.png
-
-
- true
-
-
-
- -
-
-
- Add from Instance List
-
-
-
-
-
-
- :/icons/Instances_16px.png:/icons/Instances_16px.png
-
-
-
- -
-
-
- Remove
-
-
-
-
-
-
- :/icons/Minus v2.png:/icons/Minus v2.png
-
-
-
-
-
- -
-
-
- QAbstractItemView::NoEditTriggers
-
-
- QAbstractItemView::ScrollPerPixel
-
-
- QAbstractItemView::ScrollPerPixel
-
-
-
- -
-
-
- QDialogButtonBox::Close|QDialogButtonBox::Save
-
-
-
-
-
-
-
- toolBar
-
-
- TopToolBarArea
-
-
- false
-
-
-
-
-
-
-
- true
-
-
- false
-
-
- Highlight All
-
-
-
-
- true
-
-
- Highlight None
-
-
- Highlight None
-
-
-
-
- true
-
-
- true
-
-
- Highlight Selected
-
-
- Highlight Selected
-
-
-
-
-
-
-
-
diff --git a/src/Editor/WorldEditor/CPoiMapModel.cpp b/src/Editor/WorldEditor/CPoiMapModel.cpp
index af09805c..0be9e0a0 100644
--- a/src/Editor/WorldEditor/CPoiMapModel.cpp
+++ b/src/Editor/WorldEditor/CPoiMapModel.cpp
@@ -7,48 +7,10 @@
CPoiMapModel::CPoiMapModel(CWorldEditor *pEditor, QObject *pParent /*= 0*/)
: QAbstractListModel(pParent)
, mpEditor(pEditor)
- , mpArea(pEditor->ActiveArea())
- , mpPoiToWorld(mpArea->PoiToWorldMap())
+ , mpArea(nullptr)
+ , mpPoiToWorld(nullptr)
{
- if (mpPoiToWorld)
- {
- // Create an ID -> Model Node lookup map
- QMap NodeMap;
-
- for (CSceneIterator It(mpEditor->Scene(), eModelNode, true); !It.DoneIterating(); ++It)
- {
- CModelNode *pNode = static_cast(*It);
- NodeMap[pNode->FindMeshID()] = pNode;
- }
-
- // Create internal model map
- for (u32 iPoi = 0; iPoi < mpPoiToWorld->NumMappedPOIs(); iPoi++)
- {
- const CPoiToWorld::SPoiMap *pkMap = mpPoiToWorld->MapByIndex(iPoi);
- CScriptNode *pPoiNode = mpEditor->Scene()->NodeForInstanceID(pkMap->PoiID);
-
- if (pPoiNode)
- {
- QList *pModelList = new QList;
-
- for (auto it = pkMap->ModelIDs.begin(); it != pkMap->ModelIDs.end(); it++)
- {
- if (NodeMap.contains(*it))
- *pModelList << NodeMap[*it];
- }
-
- mModelMap[pPoiNode] = pModelList;
- }
- }
- }
-}
-
-CPoiMapModel::~CPoiMapModel()
-{
- QList*> Lists = mModelMap.values();
-
- for (auto it = Lists.begin(); it != Lists.end(); it++)
- delete *it;
+ connect(pEditor, SIGNAL(MapChanged(CWorld*,CGameArea*)), this, SLOT(OnMapChange(CWorld*,CGameArea*)));
}
QVariant CPoiMapModel::headerData(int Section, Qt::Orientation Orientation, int Role) const
@@ -61,7 +23,7 @@ QVariant CPoiMapModel::headerData(int Section, Qt::Orientation Orientation, int
int CPoiMapModel::rowCount(const QModelIndex& /*rkParent*/) const
{
- return mpPoiToWorld->NumMappedPOIs();
+ return mpPoiToWorld ? mpPoiToWorld->NumMappedPOIs() : 0;
}
QVariant CPoiMapModel::data(const QModelIndex& rkIndex, int Role) const
@@ -199,3 +161,54 @@ const QList& CPoiMapModel::GetPoiMeshList(CScriptNode *pPOI) const
{
return *mModelMap[pPOI];
}
+
+void CPoiMapModel::OnMapChange(CWorld*, CGameArea *pArea)
+{
+ beginResetModel();
+ mpArea = pArea;
+ mpPoiToWorld = (pArea ? pArea->PoiToWorldMap() : nullptr);
+
+ if (mpPoiToWorld)
+ {
+ // Create an ID -> Model Node lookup map
+ QMap NodeMap;
+
+ for (CSceneIterator It(mpEditor->Scene(), eModelNode, true); !It.DoneIterating(); ++It)
+ {
+ CModelNode *pNode = static_cast(*It);
+ NodeMap[pNode->FindMeshID()] = pNode;
+ }
+
+ // Create internal model map
+ for (u32 iPoi = 0; iPoi < mpPoiToWorld->NumMappedPOIs(); iPoi++)
+ {
+ const CPoiToWorld::SPoiMap *pkMap = mpPoiToWorld->MapByIndex(iPoi);
+ CScriptNode *pPoiNode = mpEditor->Scene()->NodeForInstanceID(pkMap->PoiID);
+
+ if (pPoiNode)
+ {
+ QList *pModelList = new QList;
+
+ for (auto it = pkMap->ModelIDs.begin(); it != pkMap->ModelIDs.end(); it++)
+ {
+ if (NodeMap.contains(*it))
+ *pModelList << NodeMap[*it];
+ }
+
+ mModelMap[pPoiNode] = pModelList;
+ }
+ }
+ }
+
+ else
+ {
+ QList*> Lists = mModelMap.values();
+
+ for (auto it = Lists.begin(); it != Lists.end(); it++)
+ delete *it;
+
+ mModelMap.clear();
+ }
+
+ endResetModel();
+}
diff --git a/src/Editor/WorldEditor/CPoiMapModel.h b/src/Editor/WorldEditor/CPoiMapModel.h
index 45fa38dd..217b2570 100644
--- a/src/Editor/WorldEditor/CPoiMapModel.h
+++ b/src/Editor/WorldEditor/CPoiMapModel.h
@@ -2,6 +2,7 @@
#define CPOIMAPMODEL_H
#include
+#include
#include
#include
#include
@@ -22,7 +23,6 @@ class CPoiMapModel : public QAbstractListModel
public:
explicit CPoiMapModel(CWorldEditor *pEditor, QObject *pParent = 0);
- ~CPoiMapModel();
QVariant headerData(int Section, Qt::Orientation Orientation, int Role) const;
int rowCount(const QModelIndex& rkParent) const;
QVariant data(const QModelIndex& rkIndex, int Role) const;
@@ -37,6 +37,9 @@ public:
CScriptNode* PoiNodePointer(const QModelIndex& rkIndex) const;
const QList& GetPoiMeshList(const QModelIndex& rkIndex) const;
const QList& GetPoiMeshList(CScriptNode *pPOI) const;
+
+public slots:
+ void OnMapChange(CWorld*, CGameArea *pArea);
};
#endif // CPOIMAPMODEL_H
diff --git a/src/Editor/WorldEditor/CPoiMapEditDialog.cpp b/src/Editor/WorldEditor/CPoiMapSidebar.cpp
similarity index 69%
rename from src/Editor/WorldEditor/CPoiMapEditDialog.cpp
rename to src/Editor/WorldEditor/CPoiMapSidebar.cpp
index c008312f..5a75d6f9 100644
--- a/src/Editor/WorldEditor/CPoiMapEditDialog.cpp
+++ b/src/Editor/WorldEditor/CPoiMapSidebar.cpp
@@ -1,5 +1,5 @@
-#include "CPoiMapEditDialog.h"
-#include "ui_CPoiMapEditDialog.h"
+#include "CPoiMapSidebar.h"
+#include "ui_CPoiMapSidebar.h"
#include "CWorldEditor.h"
#include "Editor/UICommon.h"
@@ -11,14 +11,13 @@
#include
#include
-const CColor CPoiMapEditDialog::skNormalColor(0.137255f, 0.184314f, 0.776471f, 0.5f);
-const CColor CPoiMapEditDialog::skImportantColor(0.721569f, 0.066667f, 0.066667f, 0.5f);
-const CColor CPoiMapEditDialog::skHoverColor(0.047059f, 0.2f, 0.003922f, 0.5f);
+const CColor CPoiMapSidebar::skNormalColor(0.137255f, 0.184314f, 0.776471f, 0.5f);
+const CColor CPoiMapSidebar::skImportantColor(0.721569f, 0.066667f, 0.066667f, 0.5f);
+const CColor CPoiMapSidebar::skHoverColor(0.047059f, 0.2f, 0.003922f, 0.5f);
-CPoiMapEditDialog::CPoiMapEditDialog(CWorldEditor *pEditor, QWidget *pParent)
- : QMainWindow(pParent)
- , ui(new Ui::CPoiMapEditDialog)
- , mpEditor(pEditor)
+CPoiMapSidebar::CPoiMapSidebar(CWorldEditor *pEditor)
+ : CWorldEditorSidebar(pEditor)
+ , ui(new Ui::CPoiMapSidebar)
, mSourceModel(pEditor, this)
, mHighlightMode(eHighlightSelected)
, mPickType(eNotPicking)
@@ -30,16 +29,11 @@ CPoiMapEditDialog::CPoiMapEditDialog(CWorldEditor *pEditor, QWidget *pParent)
ui->setupUi(this);
ui->ListView->setModel(&mModel);
ui->ListView->selectionModel()->select(mModel.index(0,0), QItemSelectionModel::Select | QItemSelectionModel::Current);
-
- QActionGroup *pGroup = new QActionGroup(this);
- pGroup->addAction(ui->ActionHighlightSelected);
- pGroup->addAction(ui->ActionHighlightAll);
- pGroup->addAction(ui->ActionHighlightNone);
SetHighlightSelected();
- connect(ui->ActionHighlightSelected, SIGNAL(triggered()), this, SLOT(SetHighlightSelected()));
- connect(ui->ActionHighlightAll, SIGNAL(triggered()), this, SLOT(SetHighlightAll()));
- connect(ui->ActionHighlightNone, SIGNAL(triggered()), this, SLOT(SetHighlightNone()));
+ connect(ui->HighlightSelectedButton, SIGNAL(pressed()), this, SLOT(SetHighlightSelected()));
+ connect(ui->HighlightAllButton, SIGNAL(pressed()), this, SLOT(SetHighlightAll()));
+ connect(ui->HighlightNoneButton, SIGNAL(pressed()), this, SLOT(SetHighlightNone()));
connect(ui->ListView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(OnSelectionChanged(QItemSelection,QItemSelection)));
connect(ui->ListView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(OnItemDoubleClick(QModelIndex)));
@@ -49,32 +43,38 @@ CPoiMapEditDialog::CPoiMapEditDialog(CWorldEditor *pEditor, QWidget *pParent)
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::Save), SIGNAL(clicked()), this, SLOT(Save()));
}
-CPoiMapEditDialog::~CPoiMapEditDialog()
+CPoiMapSidebar::~CPoiMapSidebar()
{
- // Clear model tints
+ delete ui;
+}
+
+void CPoiMapSidebar::SidebarOpen()
+{
+ Editor()->SetRenderingMergedWorld(false);
+ UpdateModelHighlights();
+}
+
+void CPoiMapSidebar::SidebarClose()
+{
+ // Clear model highlights
if (mHighlightMode != eHighlightNone)
+ {
+ EHighlightMode OldHighlightMode = mHighlightMode;
SetHighlightNone();
+ mHighlightMode = OldHighlightMode;
+ }
// Stop picking
if (mPickType != eNotPicking)
StopPicking();
- delete ui;
+ // Disable unmerged world rendering
+ Editor()->SetRenderingMergedWorld(true);
}
-void CPoiMapEditDialog::closeEvent(QCloseEvent* /*pEvent*/)
-{
- if (mPickType != eNotPicking)
- mpEditor->ExitPickMode();
-
- emit Closed();
-}
-
-void CPoiMapEditDialog::HighlightPoiModels(const QModelIndex& rkIndex)
+void CPoiMapSidebar::HighlightPoiModels(const QModelIndex& rkIndex)
{
// Get POI and models
QModelIndex SourceIndex = mModel.mapToSource(rkIndex);
@@ -89,7 +89,7 @@ void CPoiMapEditDialog::HighlightPoiModels(const QModelIndex& rkIndex)
}
}
-void CPoiMapEditDialog::UnhighlightPoiModels(const QModelIndex& rkIndex)
+void CPoiMapSidebar::UnhighlightPoiModels(const QModelIndex& rkIndex)
{
QModelIndex SourceIndex = mModel.mapToSource(rkIndex);
const QList& rkModels = mSourceModel.GetPoiMeshList(SourceIndex);
@@ -98,19 +98,19 @@ void CPoiMapEditDialog::UnhighlightPoiModels(const QModelIndex& rkIndex)
RevertModelOverlay(rkModels[iMdl]);
}
-void CPoiMapEditDialog::HighlightModel(const QModelIndex& rkIndex, CModelNode *pNode)
+void CPoiMapSidebar::HighlightModel(const QModelIndex& rkIndex, CModelNode *pNode)
{
bool Important = IsImportant(rkIndex);
pNode->SetScanOverlayEnabled(true);
pNode->SetScanOverlayColor(Important ? skImportantColor : skNormalColor);
}
-void CPoiMapEditDialog::UnhighlightModel(CModelNode *pNode)
+void CPoiMapSidebar::UnhighlightModel(CModelNode *pNode)
{
pNode->SetScanOverlayEnabled(false);
}
-void CPoiMapEditDialog::RevertModelOverlay(CModelNode *pModel)
+void CPoiMapSidebar::RevertModelOverlay(CModelNode *pModel)
{
if (pModel)
{
@@ -155,14 +155,14 @@ void CPoiMapEditDialog::RevertModelOverlay(CModelNode *pModel)
}
}
-CPoiMapEditDialog::EPickType CPoiMapEditDialog::GetRealPickType(bool AltPressed) const
+CPoiMapSidebar::EPickType CPoiMapSidebar::GetRealPickType(bool AltPressed) const
{
if (!AltPressed) return mPickType;
if (mPickType == eAddMeshes) return eRemoveMeshes;
return eAddMeshes;
}
-bool CPoiMapEditDialog::IsImportant(const QModelIndex& rkIndex)
+bool CPoiMapSidebar::IsImportant(const QModelIndex& rkIndex)
{
CScriptNode *pPOI = mSourceModel.PoiNodePointer(rkIndex);
@@ -175,32 +175,14 @@ bool CPoiMapEditDialog::IsImportant(const QModelIndex& rkIndex)
return Important;
}
-QModelIndex CPoiMapEditDialog::GetSelectedRow() const
+QModelIndex CPoiMapSidebar::GetSelectedRow() const
{
QModelIndexList Indices = ui->ListView->selectionModel()->selectedRows();
return ( Indices.isEmpty() ? QModelIndex() : mModel.mapToSource(Indices.front()) );
}
-void CPoiMapEditDialog::Save()
+void CPoiMapSidebar::UpdateModelHighlights()
{
- CPoiToWorld *pPoiToWorld = mpEditor->ActiveArea()->PoiToWorldMap();
-
- TString FileName = pPoiToWorld->FullSource();
- CFileOutStream Out(FileName.ToStdString(), IOUtil::eBigEndian);
-
- if (Out.IsValid())
- {
- CPoiToWorldCooker::CookEGMC(pPoiToWorld, Out);
- QMessageBox::information(this, "Saved", QString("Saved to %1!").arg(TO_QSTRING(pPoiToWorld->Source())));
- }
- else
- QMessageBox::warning(this, "Error", "Couldn't save EGMC; unable to open output file");
-}
-
-void CPoiMapEditDialog::SetHighlightSelected()
-{
- mHighlightMode = eHighlightSelected;
-
const QItemSelection kSelection = ui->ListView->selectionModel()->selection();
QList SelectedIndices;
QList UnselectedIndices;
@@ -209,45 +191,55 @@ void CPoiMapEditDialog::SetHighlightSelected()
{
QModelIndex Index = mModel.index(iRow, 0);
- if (kSelection.contains(Index))
+ switch (mHighlightMode)
+ {
+ case eHighlightSelected:
+ if (kSelection.contains(Index))
+ SelectedIndices << Index;
+ else
+ UnselectedIndices << Index;
+ break;
+
+ case eHighlightAll:
SelectedIndices << Index;
- else
+ break;
+
+ case eHighlightNone:
UnselectedIndices << Index;
+ break;
+ }
}
- for (int iIdx = 0; iIdx < UnselectedIndices.size(); iIdx++)
- UnhighlightPoiModels(UnselectedIndices[iIdx]);
- for (int iIdx = 0; iIdx < SelectedIndices.size(); iIdx++)
- HighlightPoiModels(SelectedIndices[iIdx]);
+ foreach (const QModelIndex& rkIndex, UnselectedIndices)
+ UnhighlightPoiModels(rkIndex);
+
+ foreach (const QModelIndex& rkIndex, SelectedIndices)
+ HighlightPoiModels(rkIndex);
}
-void CPoiMapEditDialog::SetHighlightAll()
+void CPoiMapSidebar::SetHighlightSelected()
+{
+ mHighlightMode = eHighlightSelected;
+ UpdateModelHighlights();
+}
+
+void CPoiMapSidebar::SetHighlightAll()
{
mHighlightMode = eHighlightAll;
-
- for (int iRow = 0; iRow < mModel.rowCount(QModelIndex()); iRow++)
- HighlightPoiModels(mModel.index(iRow, 0));
+ UpdateModelHighlights();
// Call HighlightPoiModels again on the selected index to prioritize it over the non-selected POIs.
if (ui->ListView->selectionModel()->hasSelection())
HighlightPoiModels(ui->ListView->selectionModel()->selectedRows().front());
-
- if (mpHoverModel)
- HighlightModel(GetSelectedRow(), mpHoverModel);
}
-void CPoiMapEditDialog::SetHighlightNone()
+void CPoiMapSidebar::SetHighlightNone()
{
mHighlightMode = eHighlightNone;
-
- for (int iRow = 0; iRow < mModel.rowCount(QModelIndex()); iRow++)
- UnhighlightPoiModels(mModel.index(iRow, 0));
-
- if (mpHoverModel)
- UnhighlightModel(mpHoverModel);
+ UpdateModelHighlights();
}
-void CPoiMapEditDialog::OnSelectionChanged(const QItemSelection& rkSelected, const QItemSelection& rkDeselected)
+void CPoiMapSidebar::OnSelectionChanged(const QItemSelection& rkSelected, const QItemSelection& rkDeselected)
{
if (mHighlightMode == eHighlightSelected)
{
@@ -265,14 +257,14 @@ void CPoiMapEditDialog::OnSelectionChanged(const QItemSelection& rkSelected, con
}
}
-void CPoiMapEditDialog::OnItemDoubleClick(QModelIndex Index)
+void CPoiMapSidebar::OnItemDoubleClick(QModelIndex Index)
{
QModelIndex SourceIndex = mModel.mapToSource(Index);
CScriptNode *pPOI = mSourceModel.PoiNodePointer(SourceIndex);
- mpEditor->ClearAndSelectNode(pPOI);
+ Editor()->ClearAndSelectNode(pPOI);
}
-void CPoiMapEditDialog::OnUnmapAllPressed()
+void CPoiMapSidebar::OnUnmapAllPressed()
{
QModelIndex Index = GetSelectedRow();
QList ModelList = mSourceModel.GetPoiMeshList(Index);
@@ -284,15 +276,15 @@ void CPoiMapEditDialog::OnUnmapAllPressed()
}
}
-void CPoiMapEditDialog::OnPickButtonClicked()
+void CPoiMapSidebar::OnPickButtonClicked()
{
QPushButton *pButton = qobject_cast(sender());
if (pButton == ui->AddPoiFromViewportButton)
{
- mpEditor->EnterPickMode(eScriptNode, true, false, false);
- connect(mpEditor, SIGNAL(PickModeExited()), this, SLOT(StopPicking()));
- connect(mpEditor, SIGNAL(PickModeClick(SRayIntersection,QMouseEvent*)), this, SLOT(OnPoiPicked(SRayIntersection,QMouseEvent*)));
+ Editor()->EnterPickMode(eScriptNode, true, false, false);
+ connect(Editor(), SIGNAL(PickModeExited()), this, SLOT(StopPicking()));
+ connect(Editor(), SIGNAL(PickModeClick(SRayIntersection,QMouseEvent*)), this, SLOT(OnPoiPicked(SRayIntersection,QMouseEvent*)));
pButton->setChecked(true);
ui->MapMeshesButton->setChecked(false);
@@ -304,13 +296,13 @@ void CPoiMapEditDialog::OnPickButtonClicked()
else
{
if (!pButton->isChecked())
- mpEditor->ExitPickMode();
+ Editor()->ExitPickMode();
else
{
- mpEditor->EnterPickMode(eModelNode, false, false, true);
- connect(mpEditor, SIGNAL(PickModeExited()), this, SLOT(StopPicking()));
- connect(mpEditor, SIGNAL(PickModeHoverChanged(SRayIntersection,QMouseEvent*)), this, SLOT(OnModelHover(SRayIntersection,QMouseEvent*)));
+ Editor()->EnterPickMode(eModelNode, false, false, true);
+ connect(Editor(), SIGNAL(PickModeExited()), this, SLOT(StopPicking()));
+ connect(Editor(), SIGNAL(PickModeHoverChanged(SRayIntersection,QMouseEvent*)), this, SLOT(OnModelHover(SRayIntersection,QMouseEvent*)));
pButton->setChecked(true);
if (pButton == ui->MapMeshesButton)
@@ -328,7 +320,7 @@ void CPoiMapEditDialog::OnPickButtonClicked()
}
}
-void CPoiMapEditDialog::StopPicking()
+void CPoiMapSidebar::StopPicking()
{
ui->MapMeshesButton->setChecked(false);
ui->UnmapMeshesButton->setChecked(false);
@@ -338,15 +330,18 @@ void CPoiMapEditDialog::StopPicking()
RevertModelOverlay(mpHoverModel);
mpHoverModel = nullptr;
- disconnect(mpEditor, 0, this, 0);
+ Editor()->ExitPickMode();
+ disconnect(Editor(), SIGNAL(PickModeExited()), this, 0);
+ disconnect(Editor(), SIGNAL(PickModeHoverChanged(SRayIntersection,QMouseEvent*)), this, 0);
+ disconnect(Editor(), SIGNAL(PickModeClick(SRayIntersection,QMouseEvent*)), this, 0);
}
-void CPoiMapEditDialog::OnInstanceListButtonClicked()
+void CPoiMapSidebar::OnInstanceListButtonClicked()
{
- EGame Game = mpEditor->CurrentGame();
+ EGame Game = Editor()->CurrentGame();
CScriptTemplate *pPoiTemplate = CMasterTemplate::MasterForGame(Game)->TemplateByID("POIN");
- CPoiListDialog Dialog(pPoiTemplate, &mSourceModel, mpEditor->Scene(), this);
+ CPoiListDialog Dialog(pPoiTemplate, &mSourceModel, Editor()->Scene(), this);
Dialog.exec();
const QList& rkSelection = Dialog.Selection();
@@ -360,7 +355,7 @@ void CPoiMapEditDialog::OnInstanceListButtonClicked()
}
}
-void CPoiMapEditDialog::OnRemovePoiButtonClicked()
+void CPoiMapSidebar::OnRemovePoiButtonClicked()
{
if (ui->ListView->selectionModel()->hasSelection())
{
@@ -371,7 +366,7 @@ void CPoiMapEditDialog::OnRemovePoiButtonClicked()
}
}
-void CPoiMapEditDialog::OnPoiPicked(const SRayIntersection& rkIntersect, QMouseEvent *pEvent)
+void CPoiMapSidebar::OnPoiPicked(const SRayIntersection& rkIntersect, QMouseEvent *pEvent)
{
CScriptNode *pPOI = static_cast(rkIntersect.pNode);
if (pPOI->Instance()->ObjectTypeID() != CFourCC("POIN").ToLong()) return;
@@ -381,10 +376,10 @@ void CPoiMapEditDialog::OnPoiPicked(const SRayIntersection& rkIntersect, QMouseE
// Exit pick mode unless the user is holding the Ctrl key
if (!(pEvent->modifiers() & Qt::ControlModifier))
- mpEditor->ExitPickMode();
+ Editor()->ExitPickMode();
}
-void CPoiMapEditDialog::OnModelPicked(const SRayIntersection& rkRayIntersect, QMouseEvent* pEvent)
+void CPoiMapSidebar::OnModelPicked(const SRayIntersection& rkRayIntersect, QMouseEvent* pEvent)
{
if (!rkRayIntersect.pNode) return;
@@ -426,7 +421,7 @@ void CPoiMapEditDialog::OnModelPicked(const SRayIntersection& rkRayIntersect, QM
}
}
-void CPoiMapEditDialog::OnModelHover(const SRayIntersection& rkIntersect, QMouseEvent *pEvent)
+void CPoiMapSidebar::OnModelHover(const SRayIntersection& rkIntersect, QMouseEvent *pEvent)
{
// Restore old hover model to correct overlay color, and set new hover model
if (mpHoverModel)
diff --git a/src/Editor/WorldEditor/CPoiMapEditDialog.h b/src/Editor/WorldEditor/CPoiMapSidebar.h
similarity index 82%
rename from src/Editor/WorldEditor/CPoiMapEditDialog.h
rename to src/Editor/WorldEditor/CPoiMapSidebar.h
index 550ac40c..354eef09 100644
--- a/src/Editor/WorldEditor/CPoiMapEditDialog.h
+++ b/src/Editor/WorldEditor/CPoiMapSidebar.h
@@ -1,21 +1,22 @@
-#ifndef CPOIMAPEDITDIALOG_H
-#define CPOIMAPEDITDIALOG_H
+#ifndef CPOIMAPSIDEBAR_H
+#define CPOIMAPSIDEBAR_H
#include "CPoiMapModel.h"
#include "CPoiListDialog.h"
+#include "CWorldEditorSidebar.h"
#include
#include
#include
namespace Ui {
-class CPoiMapEditDialog;
+class CPoiMapSidebar;
}
-class CPoiMapEditDialog : public QMainWindow
+class CPoiMapSidebar : public CWorldEditorSidebar
{
Q_OBJECT
- Ui::CPoiMapEditDialog *ui;
+ Ui::CPoiMapSidebar *ui;
enum EHighlightMode
{
@@ -24,7 +25,6 @@ class CPoiMapEditDialog : public QMainWindow
eHighlightSelected
};
- CWorldEditor *mpEditor;
CPoiMapModel mSourceModel;
QSortFilterProxyModel mModel;
EHighlightMode mHighlightMode;
@@ -45,9 +45,10 @@ class CPoiMapEditDialog : public QMainWindow
static const CColor skHoverColor;
public:
- explicit CPoiMapEditDialog(CWorldEditor *pEditor, QWidget *pParent = 0);
- ~CPoiMapEditDialog();
- void closeEvent(QCloseEvent *pEvent);
+ explicit CPoiMapSidebar(CWorldEditor *pEditor);
+ ~CPoiMapSidebar();
+ void SidebarOpen();
+ void SidebarClose();
void HighlightPoiModels(const QModelIndex& rkIndex);
void UnhighlightPoiModels(const QModelIndex& rkIndex);
void HighlightModel(const QModelIndex& rkIndex, CModelNode *pNode);
@@ -58,7 +59,7 @@ public:
QModelIndex GetSelectedRow() const;
public slots:
- void Save();
+ void UpdateModelHighlights();
void SetHighlightSelected();
void SetHighlightAll();
void SetHighlightNone();
@@ -73,9 +74,6 @@ public slots:
void OnPoiPicked(const SRayIntersection& rkIntersect, QMouseEvent *pEvent);
void OnModelPicked(const SRayIntersection& rkIntersect, QMouseEvent *pEvent);
void OnModelHover(const SRayIntersection& rkIntersect, QMouseEvent *pEvent);
-
-signals:
- void Closed();
};
#endif // CPOIMAPEDITDIALOG_H
diff --git a/src/Editor/WorldEditor/CPoiMapSidebar.ui b/src/Editor/WorldEditor/CPoiMapSidebar.ui
new file mode 100644
index 00000000..83f0a12c
--- /dev/null
+++ b/src/Editor/WorldEditor/CPoiMapSidebar.ui
@@ -0,0 +1,171 @@
+
+
+ CPoiMapSidebar
+
+
+
+ 0
+ 0
+ 274
+ 438
+
+
+
+ Edit POI to World Mappings
+
+
+ -
+
+
-
+
+
+ Highlight:
+
+
+
+ -
+
+
+ Selected
+
+
+ true
+
+
+
+ -
+
+
+ All
+
+
+
+ -
+
+
+ None
+
+
+
+
+
+ -
+
+
-
+
+
-
+
+
+ Map
+
+
+
+ :/icons/Plus.png:/icons/Plus.png
+
+
+ true
+
+
+
+ -
+
+
+ Unmap
+
+
+
+ :/icons/Minus v2.png:/icons/Minus v2.png
+
+
+ true
+
+
+
+ -
+
+
+ Unmap All
+
+
+
+
+
+ -
+
+
+
+ 10
+
+
+
+ QAbstractItemView::NoEditTriggers
+
+
+ true
+
+
+ QAbstractItemView::ScrollPerPixel
+
+
+ QAbstractItemView::ScrollPerPixel
+
+
+
+ -
+
+
-
+
+
+ Add from Viewport
+
+
+
+
+
+
+ :/icons/SelectMode_16px.png:/icons/SelectMode_16px.png
+
+
+ true
+
+
+
+ -
+
+
+ Add from Instance List
+
+
+
+
+
+
+ :/icons/Instances_16px.png:/icons/Instances_16px.png
+
+
+
+ -
+
+
+ Remove
+
+
+
+
+
+
+ :/icons/Minus v2.png:/icons/Minus v2.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Editor/WorldEditor/CScriptEditSidebar.cpp b/src/Editor/WorldEditor/CScriptEditSidebar.cpp
index 810dfc0f..8fd66e2b 100644
--- a/src/Editor/WorldEditor/CScriptEditSidebar.cpp
+++ b/src/Editor/WorldEditor/CScriptEditSidebar.cpp
@@ -6,7 +6,7 @@
#include "CWorldEditor.h"
CScriptEditSidebar::CScriptEditSidebar(CWorldEditor *pEditor)
- : QWidget(pEditor)
+ : CWorldEditorSidebar(pEditor)
{
QVBoxLayout *pLayout = new QVBoxLayout(this);
pLayout->setContentsMargins(1, 1, 1, 1);
diff --git a/src/Editor/WorldEditor/CScriptEditSidebar.h b/src/Editor/WorldEditor/CScriptEditSidebar.h
index 87c60277..5bf15791 100644
--- a/src/Editor/WorldEditor/CScriptEditSidebar.h
+++ b/src/Editor/WorldEditor/CScriptEditSidebar.h
@@ -1,6 +1,7 @@
#ifndef CSCRIPTEDITSIDEBAR_H
#define CSCRIPTEDITSIDEBAR_H
+#include "CWorldEditorSidebar.h"
#include
class CWorldEditor;
@@ -9,7 +10,7 @@ class WCreateTab;
class WModifyTab;
class WInstancesTab;
-class CScriptEditSidebar : public QWidget
+class CScriptEditSidebar : public CWorldEditorSidebar
{
Q_OBJECT
diff --git a/src/Editor/WorldEditor/CWorldEditor.cpp b/src/Editor/WorldEditor/CWorldEditor.cpp
index a2c239e0..d246cb10 100644
--- a/src/Editor/WorldEditor/CWorldEditor.cpp
+++ b/src/Editor/WorldEditor/CWorldEditor.cpp
@@ -38,14 +38,13 @@ CWorldEditor::CWorldEditor(QWidget *parent)
, mpArea(nullptr)
, mpWorld(nullptr)
, mpLinkDialog(new CLinkDialog(this, this))
- , mpPoiDialog(nullptr)
, mIsMakingLink(false)
, mpNewLinkSender(nullptr)
, mpNewLinkReceiver(nullptr)
{
Log::Write("Creating World Editor");
ui->setupUi(this);
- REPLACE_WINDOWTITLE_APPVARS;
+ UpdateWindowTitle();
mpSelection->SetAllowedNodeTypes(eScriptNode | eLightNode);
@@ -69,15 +68,14 @@ CWorldEditor::CWorldEditor(QWidget *parent)
ui->menuEdit->insertSeparator(ui->ActionCut);
// Initialize sidebar
- mpCurSidebarWidget = nullptr;
+ mpCurSidebar = nullptr;
mpRightSidebarLayout = new QVBoxLayout();
mpRightSidebarLayout->setContentsMargins(0, 0, 0, 0);
ui->RightSidebarFrame->setLayout(mpRightSidebarLayout);
mpWorldInfoSidebar = new CWorldInfoSidebar(this);
- mpWorldInfoSidebar->setHidden(true);
mpScriptSidebar = new CScriptEditSidebar(this);
- mpScriptSidebar->setHidden(true);
+ mpPoiMapSidebar = new CPoiMapSidebar(this);
// Initialize edit mode toolbar
mpEditModeButtonGroup = new QButtonGroup(this);
@@ -85,6 +83,8 @@ CWorldEditor::CWorldEditor(QWidget *parent)
AddEditModeButton( QIcon(":/icons/World.png"), "Edit World Info",eWEM_EditWorldInfo );
AddEditModeButton( QIcon(":/icons/Modify.png"), "Edit Script", eWEM_EditScript );
+ mpPoiMapButton = AddEditModeButton( QIcon(":/icons/POI Normal.png"), "Edit POI Mappings", eWEM_EditPOIMappings );
+ mpPoiMapButton->setEnabled(false);
ChangeEditMode(eWEM_EditWorldInfo);
@@ -187,7 +187,6 @@ CWorldEditor::CWorldEditor(QWidget *parent)
connect(ui->ActionResourceBrowser, SIGNAL(triggered()), this, SLOT(OpenResourceBrowser()));
connect(ui->ActionEditLayers, SIGNAL(triggered()), this, SLOT(EditLayers()));
- connect(ui->ActionEditPoiToWorldMap, SIGNAL(triggered()), this, SLOT(EditPoiToWorldMap()));
connect(ui->ActionDrawWorld, SIGNAL(triggered()), this, SLOT(ToggleDrawWorld()));
connect(ui->ActionDrawObjects, SIGNAL(triggered()), this, SLOT(ToggleDrawObjects()));
@@ -224,10 +223,6 @@ void CWorldEditor::closeEvent(QCloseEvent *pEvent)
mUndoStack.clear();
mpCollisionDialog->close();
mpLinkDialog->close();
-
- if (mpPoiDialog)
- mpPoiDialog->close();
-
IEditor::closeEvent(pEvent);
}
else
@@ -249,12 +244,10 @@ bool CWorldEditor::CloseWorld()
mpCollisionDialog->close();
mpLinkDialog->close();
- if (mpPoiDialog)
- mpPoiDialog->close();
-
mpArea = nullptr;
mpWorld = nullptr;
gpResourceStore->DestroyUnreferencedResources(); // this should destroy the area!
+ UpdateWindowTitle();
emit MapChanged(mpWorld, mpArea);
return true;
@@ -272,12 +265,6 @@ bool CWorldEditor::SetArea(CWorld *pWorld, int AreaIndex)
ClearSelection();
mUndoStack.clear();
- if (mpPoiDialog)
- {
- delete mpPoiDialog;
- mpPoiDialog = nullptr;
- }
-
// Load new area
mpWorld = pWorld;
CAssetID AreaID = mpWorld->AreaResourceID(AreaIndex);
@@ -301,36 +288,20 @@ bool CWorldEditor::SetArea(CWorld *pWorld, int AreaIndex)
UpdateCameraOrbit();
- // Default bloom to Fake Bloom for Metroid Prime 3; disable for other games
- bool AllowBloom = (mpWorld->Game() == eCorruptionProto || mpWorld->Game() == eCorruption);
- AllowBloom ? SetFakeBloom() : SetNoBloom();
- ui->menuBloom->setEnabled(AllowBloom);
+ // Update UI stuff
+ UpdateWindowTitle();
- // Disable EGMC editing for Prime 1 and DKCR
- bool AllowEGMC = ( (mpWorld->Game() >= eEchoesDemo) && (mpWorld->Game() <= eCorruption) );
- ui->ActionEditPoiToWorldMap->setEnabled(AllowEGMC);
-
- // Set up dialogs
CMasterTemplate *pMaster = CMasterTemplate::MasterForGame(mpArea->Game());
- mpCollisionDialog->SetupWidgets(); // Won't modify any settings but will update widget visibility status if we've changed games
mpLinkDialog->SetMaster(pMaster);
- // Set window title
QString ProjectName = TO_QSTRING(gpEdApp->ActiveProject()->Name());
QString WorldName = TO_QSTRING(mpWorld->InGameName());
QString AreaName = TO_QSTRING(mpWorld->AreaInGameName(AreaIndex));
if (CurrentGame() < eReturns)
- {
- SET_WINDOWTITLE_APPVARS( QString("%APP_FULL_NAME% - %1 - %2 - %3[*]").arg(ProjectName, WorldName, AreaName) );
Log::Write("Loaded area: " + mpArea->Entry()->Name().ToUTF8() + " (" + TO_TSTRING(AreaName) + ")");
- }
-
else
- {
- SET_WINDOWTITLE_APPVARS( QString("%APP_FULL_NAME% - %1 - %2[*]").arg(AreaName) );
Log::Write("Loaded level: World " + mpWorld->Entry()->Name().ToUTF8() + " / Area " + mpArea->Entry()->Name().ToUTF8() + " (" + TO_TSTRING(AreaName) + ")");
- }
// Update paste action
OnClipboardDataModified();
@@ -517,6 +488,7 @@ void CWorldEditor::ExportGame()
void CWorldEditor:: CloseProject()
{
gpEdApp->CloseProject();
+ SET_WINDOWTITLE_APPVARS( QString("%APP_FULL_NAME%") );
}
void CWorldEditor::ChangeEditMode(int Mode)
@@ -534,11 +506,15 @@ void CWorldEditor::ChangeEditMode(EWorldEditorMode Mode)
switch (Mode)
{
case eWEM_EditWorldInfo:
- SetSidebarWidget(mpWorldInfoSidebar);
+ SetSidebar(mpWorldInfoSidebar);
break;
case eWEM_EditScript:
- SetSidebarWidget(mpScriptSidebar);
+ SetSidebar(mpScriptSidebar);
+ break;
+
+ case eWEM_EditPOIMappings:
+ SetSidebar(mpPoiMapSidebar);
break;
default:
@@ -547,6 +523,11 @@ void CWorldEditor::ChangeEditMode(EWorldEditorMode Mode)
}
}
+void CWorldEditor::SetRenderingMergedWorld(bool RenderMerged)
+{
+ Viewport()->SetRenderMergedWorld(RenderMerged);
+}
+
void CWorldEditor::OpenProjectSettings()
{
CProjectSettingsDialog *pDialog = gpEdApp->ProjectDialog();
@@ -565,13 +546,23 @@ void CWorldEditor::OnActiveProjectChanged(CGameProject *pProj)
{
ui->ActionProjectSettings->setEnabled( pProj != nullptr );
ui->ActionCloseProject->setEnabled( pProj != nullptr );
+ mpPoiMapButton->setEnabled( pProj != nullptr && pProj->Game() >= eEchoesDemo && pProj->Game() <= eCorruption );
ResetCamera();
- if (!pProj) return;
+ UpdateWindowTitle();
- // Update recent projects list
- UpdateOpenRecentActions();
+ // Default bloom to Fake Bloom for Metroid Prime 3; disable for other games
+ bool AllowBloom = (CurrentGame() == eCorruptionProto || CurrentGame() == eCorruption);
+ AllowBloom ? SetFakeBloom() : SetNoBloom();
+ ui->menuBloom->setEnabled(AllowBloom);
- ChangeEditMode(eWEM_EditWorldInfo);
+ if (!pProj)
+ {
+ // Update recent projects list
+ UpdateOpenRecentActions();
+
+ // Reset editor mode
+ ChangeEditMode(eWEM_EditWorldInfo);
+ }
}
void CWorldEditor::OnLinksModified(const QList& rkInstances)
@@ -740,6 +731,28 @@ void CWorldEditor::UpdateOpenRecentActions()
}
}
+void CWorldEditor::UpdateWindowTitle()
+{
+ QString WindowTitle = "%APP_FULL_NAME%";
+ CGameProject *pProj = gpEdApp->ActiveProject();
+
+ if (pProj)
+ {
+ WindowTitle += " - " + TO_QSTRING( pProj->Name() );
+
+ if (mpWorld)
+ {
+ WindowTitle += " - " + TO_QSTRING(mpWorld->InGameName());
+
+ if (mpArea && CurrentGame() < eReturns)
+ WindowTitle += " - " + TO_QSTRING( mpWorld->AreaInGameName(mpArea->WorldIndex()) );
+ }
+ }
+
+ WindowTitle += "[*]";
+ SET_WINDOWTITLE_APPVARS(WindowTitle);
+}
+
void CWorldEditor::UpdateStatusBar()
{
// Would be cool to do more frequent status bar updates with more info. Unfortunately, this causes lag.
@@ -912,7 +925,7 @@ void CWorldEditor::UpdateNewLinkLine()
}
// ************ PROTECTED ************
-void CWorldEditor::AddEditModeButton(QIcon Icon, QString ToolTip, EWorldEditorMode Mode)
+QPushButton* CWorldEditor::AddEditModeButton(QIcon Icon, QString ToolTip, EWorldEditorMode Mode)
{
ASSERT(mpEditModeButtonGroup->button(Mode) == nullptr);
@@ -923,22 +936,28 @@ void CWorldEditor::AddEditModeButton(QIcon Icon, QString ToolTip, EWorldEditorMo
ui->EditModeToolBar->addWidget(pButton);
mpEditModeButtonGroup->addButton(pButton, Mode);
+ return pButton;
}
-void CWorldEditor::SetSidebarWidget(QWidget *pWidget)
+void CWorldEditor::SetSidebar(CWorldEditorSidebar *pSidebar)
{
- if (mpCurSidebarWidget)
+ if (mpCurSidebar == pSidebar)
+ return;
+
+ if (mpCurSidebar)
{
- mpRightSidebarLayout->removeWidget(mpCurSidebarWidget);
- mpCurSidebarWidget->setHidden(true);
+ mpCurSidebar->SidebarClose();
+ mpRightSidebarLayout->removeWidget(mpCurSidebar);
+ mpCurSidebar->setHidden(true);
}
- mpCurSidebarWidget = pWidget;
+ mpCurSidebar = pSidebar;
- if (mpCurSidebarWidget)
+ if (mpCurSidebar)
{
- mpRightSidebarLayout->addWidget(pWidget);
- mpCurSidebarWidget->setHidden(false);
+ mpCurSidebar->SidebarOpen();
+ mpRightSidebarLayout->addWidget(mpCurSidebar);
+ mpCurSidebar->setHidden(false);
}
}
@@ -1208,13 +1227,6 @@ void CWorldEditor::OnTransformSpinBoxEdited(CVector3f)
UpdateGizmoUI();
}
-void CWorldEditor::OnClosePoiEditDialog()
-{
- delete mpPoiDialog;
- mpPoiDialog = nullptr;
- ui->MainViewport->SetRenderMergedWorld(true);
-}
-
void CWorldEditor::SelectAllTriggered()
{
FNodeFlags NodeFlags = CScene::NodeFlagsForShowFlags(ui->MainViewport->ShowFlags());
@@ -1351,18 +1363,3 @@ void CWorldEditor::EditLayers()
Editor.SetArea(mpArea);
Editor.exec();
}
-
-void CWorldEditor::EditPoiToWorldMap()
-{
- if (!mpPoiDialog)
- {
- mpPoiDialog = new CPoiMapEditDialog(this, this);
- mpPoiDialog->show();
- ui->MainViewport->SetRenderMergedWorld(false);
- connect(mpPoiDialog, SIGNAL(Closed()), this, SLOT(OnClosePoiEditDialog()));
- }
- else
- {
- mpPoiDialog->show();
- }
-}
diff --git a/src/Editor/WorldEditor/CWorldEditor.h b/src/Editor/WorldEditor/CWorldEditor.h
index 7080a611..7c5fe801 100644
--- a/src/Editor/WorldEditor/CWorldEditor.h
+++ b/src/Editor/WorldEditor/CWorldEditor.h
@@ -2,8 +2,9 @@
#define CWORLDEDITOR_H
#include "CCollisionRenderSettingsDialog.h"
+#include "CEditorApplication.h"
#include "CLinkDialog.h"
-#include "CPoiMapEditDialog.h"
+#include "CPoiMapSidebar.h"
#include "CScriptEditSidebar.h"
#include "CWorldInfoSidebar.h"
#include "Editor/INodeEditor.h"
@@ -36,7 +37,8 @@ class CWorldEditor;
enum EWorldEditorMode
{
eWEM_EditWorldInfo,
- eWEM_EditScript
+ eWEM_EditScript,
+ eWEM_EditPOIMappings
};
class CWorldEditor : public INodeEditor
@@ -53,7 +55,6 @@ class CWorldEditor : public INodeEditor
CCollisionRenderSettingsDialog *mpCollisionDialog;
CLinkDialog *mpLinkDialog;
- CPoiMapEditDialog *mpPoiDialog;
bool mIsMakingLink;
CScriptObject *mpNewLinkSender;
@@ -65,11 +66,14 @@ class CWorldEditor : public INodeEditor
// Sidebars
QVBoxLayout *mpRightSidebarLayout;
- QWidget *mpCurSidebarWidget;
+ CWorldEditorSidebar *mpCurSidebar;
QButtonGroup *mpEditModeButtonGroup;
CWorldInfoSidebar *mpWorldInfoSidebar;
CScriptEditSidebar *mpScriptSidebar;
+ CPoiMapSidebar *mpPoiMapSidebar;
+
+ QPushButton *mpPoiMapButton;
public:
explicit CWorldEditor(QWidget *parent = 0);
@@ -83,7 +87,7 @@ public:
inline CWorld* ActiveWorld() const { return mpWorld; }
inline CGameArea* ActiveArea() const { return mpArea; }
- inline EGame CurrentGame() const { return mpArea ? mpArea->Game() : eUnknownGame; }
+ inline EGame CurrentGame() const { return gpEdApp->CurrentGame(); }
inline CLinkDialog* LinkDialog() const { return mpLinkDialog; }
CSceneViewport* Viewport() const;
@@ -109,6 +113,7 @@ public slots:
void ChangeEditMode(int Mode);
void ChangeEditMode(EWorldEditorMode Mode);
+ void SetRenderingMergedWorld(bool RenderMerged);
void OpenProjectSettings();
void OpenResourceBrowser();
@@ -121,6 +126,7 @@ public slots:
void DeleteSelection();
void UpdateOpenRecentActions();
+ void UpdateWindowTitle();
void UpdateStatusBar();
void UpdateGizmoUI();
void UpdateSelectionUI();
@@ -128,8 +134,8 @@ public slots:
void UpdateNewLinkLine();
protected:
- void AddEditModeButton(QIcon Icon, QString ToolTip, EWorldEditorMode Mode);
- void SetSidebarWidget(QWidget *pWidget);
+ QPushButton* AddEditModeButton(QIcon Icon, QString ToolTip, EWorldEditorMode Mode);
+ void SetSidebar(CWorldEditorSidebar *pSidebar);
void GizmoModeChanged(CGizmo::EGizmoMode Mode);
private slots:
@@ -149,7 +155,6 @@ private slots:
void OnCameraSpeedChange(double Speed);
void OnTransformSpinBoxModified(CVector3f Value);
void OnTransformSpinBoxEdited(CVector3f Value);
- void OnClosePoiEditDialog();
void SelectAllTriggered();
void InvertSelectionTriggered();
@@ -172,7 +177,6 @@ private slots:
void DecrementGizmo();
void EditCollisionRenderSettings();
void EditLayers();
- void EditPoiToWorldMap();
signals:
void MapChanged(CWorld *pNewWorld, CGameArea *pNewArea);
diff --git a/src/Editor/WorldEditor/CWorldEditor.ui b/src/Editor/WorldEditor/CWorldEditor.ui
index 29f3bcc9..b6893f36 100644
--- a/src/Editor/WorldEditor/CWorldEditor.ui
+++ b/src/Editor/WorldEditor/CWorldEditor.ui
@@ -11,7 +11,7 @@
- %APP_FULL_NAME%
+
@@ -342,7 +342,6 @@
-
@@ -638,11 +637,6 @@
Ctrl+I
-
-
- Edit POI to World Map
-
-
false
diff --git a/src/Editor/WorldEditor/CWorldEditorSidebar.cpp b/src/Editor/WorldEditor/CWorldEditorSidebar.cpp
new file mode 100644
index 00000000..3bb56318
--- /dev/null
+++ b/src/Editor/WorldEditor/CWorldEditorSidebar.cpp
@@ -0,0 +1,14 @@
+#include "CWorldEditorSidebar.h"
+#include "CWorldEditor.h"
+
+CWorldEditorSidebar::CWorldEditorSidebar(CWorldEditor *pEditor)
+ : QWidget(pEditor)
+ , mpWorldEditor(pEditor)
+{
+ setHidden(true);
+}
+
+CWorldEditor* CWorldEditorSidebar::Editor() const
+{
+ return mpWorldEditor;
+}
diff --git a/src/Editor/WorldEditor/CWorldEditorSidebar.h b/src/Editor/WorldEditor/CWorldEditorSidebar.h
new file mode 100644
index 00000000..c33b5622
--- /dev/null
+++ b/src/Editor/WorldEditor/CWorldEditorSidebar.h
@@ -0,0 +1,19 @@
+#ifndef CWORLDEDITORSIDEBAR_H
+#define CWORLDEDITORSIDEBAR_H
+
+#include
+class CWorldEditor;
+
+class CWorldEditorSidebar : public QWidget
+{
+ Q_OBJECT
+ CWorldEditor *mpWorldEditor;
+
+public:
+ explicit CWorldEditorSidebar(CWorldEditor *pEditor);
+ CWorldEditor* Editor() const;
+ virtual void SidebarOpen() {}
+ virtual void SidebarClose() {}
+};
+
+#endif // CWORLDEDITORSIDEBAR_H
diff --git a/src/Editor/WorldEditor/CWorldInfoSidebar.cpp b/src/Editor/WorldEditor/CWorldInfoSidebar.cpp
index 3e5e08f7..ba7a231b 100644
--- a/src/Editor/WorldEditor/CWorldInfoSidebar.cpp
+++ b/src/Editor/WorldEditor/CWorldInfoSidebar.cpp
@@ -4,7 +4,7 @@
#include "Editor/CEditorApplication.h"
CWorldInfoSidebar::CWorldInfoSidebar(CWorldEditor *pEditor)
- : QWidget(pEditor)
+ : CWorldEditorSidebar(pEditor)
, mpUI(new Ui::CWorldInfoSidebar)
, mModel(pEditor)
{
diff --git a/src/Editor/WorldEditor/CWorldInfoSidebar.h b/src/Editor/WorldEditor/CWorldInfoSidebar.h
index 706ec191..bbf0cc6f 100644
--- a/src/Editor/WorldEditor/CWorldInfoSidebar.h
+++ b/src/Editor/WorldEditor/CWorldInfoSidebar.h
@@ -3,6 +3,7 @@
#include
#include
+#include "CWorldEditorSidebar.h"
#include "CWorldTreeModel.h"
class CWorldEditor;
@@ -11,7 +12,7 @@ namespace Ui {
class CWorldInfoSidebar;
}
-class CWorldInfoSidebar : public QWidget
+class CWorldInfoSidebar : public CWorldEditorSidebar
{
Q_OBJECT