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