Implemented spawn layer on the create tab
This commit is contained in:
parent
2bcf29dd7f
commit
b774f08097
|
@ -4,11 +4,14 @@
|
||||||
#include "CWorldEditor.h"
|
#include "CWorldEditor.h"
|
||||||
#include "Editor/Undo/UndoCommands.h"
|
#include "Editor/Undo/UndoCommands.h"
|
||||||
|
|
||||||
WCreateTab::WCreateTab(QWidget *parent) :
|
WCreateTab::WCreateTab(QWidget *parent)
|
||||||
QWidget(parent),
|
: QWidget(parent)
|
||||||
ui(new Ui::WCreateTab)
|
, ui(new Ui::WCreateTab)
|
||||||
|
, mpSpawnLayer(nullptr)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
connect(ui->SpawnLayerComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(OnSpawnLayerChanged(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
WCreateTab::~WCreateTab()
|
WCreateTab::~WCreateTab()
|
||||||
|
@ -39,7 +42,7 @@ bool WCreateTab::eventFilter(QObject *pObj, QEvent *pEvent)
|
||||||
if (pMimeData)
|
if (pMimeData)
|
||||||
{
|
{
|
||||||
CVector3f SpawnPoint = mpEditor->Viewport()->HoverPoint();
|
CVector3f SpawnPoint = mpEditor->Viewport()->HoverPoint();
|
||||||
CCreateInstanceCommand *pCmd = new CCreateInstanceCommand(mpEditor, pMimeData->Template(), mpEditor->ActiveArea()->GetScriptLayer(0), SpawnPoint);
|
CCreateInstanceCommand *pCmd = new CCreateInstanceCommand(mpEditor, pMimeData->Template(), mpSpawnLayer, SpawnPoint);
|
||||||
mpEditor->UndoStack()->push(pCmd);
|
mpEditor->UndoStack()->push(pCmd);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -53,9 +56,31 @@ void WCreateTab::SetEditor(CWorldEditor *pEditor)
|
||||||
{
|
{
|
||||||
mpEditor = pEditor;
|
mpEditor = pEditor;
|
||||||
pEditor->Viewport()->installEventFilter(this);
|
pEditor->Viewport()->installEventFilter(this);
|
||||||
|
connect(mpEditor, SIGNAL(LayersModified()), this, SLOT(OnLayersChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WCreateTab::SetMaster(CMasterTemplate *pMaster)
|
void WCreateTab::SetMaster(CMasterTemplate *pMaster)
|
||||||
{
|
{
|
||||||
ui->TemplateView->SetMaster(pMaster);
|
ui->TemplateView->SetMaster(pMaster);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ************ PUBLIC SLOTS ************
|
||||||
|
void WCreateTab::OnLayersChanged()
|
||||||
|
{
|
||||||
|
CGameArea *pArea = mpEditor->ActiveArea();
|
||||||
|
|
||||||
|
ui->SpawnLayerComboBox->blockSignals(true);
|
||||||
|
ui->SpawnLayerComboBox->clear();
|
||||||
|
|
||||||
|
for (u32 iLyr = 0; iLyr < pArea->GetScriptLayerCount(); iLyr++)
|
||||||
|
ui->SpawnLayerComboBox->addItem(TO_QSTRING(pArea->GetScriptLayer(iLyr)->Name()));
|
||||||
|
|
||||||
|
ui->SpawnLayerComboBox->blockSignals(false);
|
||||||
|
ui->SpawnLayerComboBox->setCurrentIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WCreateTab::OnSpawnLayerChanged(int LayerIndex)
|
||||||
|
{
|
||||||
|
CGameArea *pArea = mpEditor->ActiveArea();
|
||||||
|
mpSpawnLayer = pArea->GetScriptLayer(LayerIndex);
|
||||||
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ class WCreateTab : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
CWorldEditor *mpEditor;
|
CWorldEditor *mpEditor;
|
||||||
|
CScriptLayer *mpSpawnLayer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit WCreateTab(QWidget *parent = 0);
|
explicit WCreateTab(QWidget *parent = 0);
|
||||||
|
@ -20,6 +21,11 @@ public:
|
||||||
bool eventFilter(QObject *, QEvent *);
|
bool eventFilter(QObject *, QEvent *);
|
||||||
void SetEditor(CWorldEditor *pEditor);
|
void SetEditor(CWorldEditor *pEditor);
|
||||||
void SetMaster(CMasterTemplate *pMaster);
|
void SetMaster(CMasterTemplate *pMaster);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void OnLayersChanged();
|
||||||
|
void OnSpawnLayerChanged(int LayerIndex);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::WCreateTab *ui;
|
Ui::WCreateTab *ui;
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,14 +35,14 @@
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="SpawnLayerLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Spawn Layer:</string>
|
<string>Spawn Layer:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="comboBox">
|
<widget class="QComboBox" name="SpawnLayerComboBox">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
<horstretch>1</horstretch>
|
<horstretch>1</horstretch>
|
||||||
|
|
Loading…
Reference in New Issue