Moved selection handling code to CNodeSelection, implemented instance spawning, half-implemented instance deleting (this build is buggy/crash prone)

This commit is contained in:
parax0
2016-03-13 22:30:04 -06:00
parent b2699eb96f
commit f02f7ada0f
64 changed files with 1259 additions and 754 deletions

View File

@@ -1,5 +1,8 @@
#include "WCreateTab.h"
#include "ui_WCreateTab.h"
#include "CTemplateMimeData.h"
#include "CWorldEditor.h"
#include "Editor/Undo/UndoCommands.h"
WCreateTab::WCreateTab(QWidget *parent) :
QWidget(parent),
@@ -12,3 +15,47 @@ WCreateTab::~WCreateTab()
{
delete ui;
}
bool WCreateTab::eventFilter(QObject *pObj, QEvent *pEvent)
{
if (pObj == mpEditor->Viewport())
{
if (pEvent->type() == QEvent::DragEnter)
{
QDragEnterEvent *pDragEvent = static_cast<QDragEnterEvent*>(pEvent);
if (qobject_cast<const CTemplateMimeData*>(pDragEvent->mimeData()))
{
pDragEvent->acceptProposedAction();
return true;
}
}
else if (pEvent->type() == QEvent::Drop)
{
QDropEvent *pDropEvent = static_cast<QDropEvent*>(pEvent);
const CTemplateMimeData *pMimeData = qobject_cast<const CTemplateMimeData*>(pDropEvent->mimeData());
if (pMimeData)
{
CVector3f SpawnPoint = mpEditor->Viewport()->HoverPoint();
CCreateInstanceCommand *pCmd = new CCreateInstanceCommand(mpEditor, pMimeData->Template(), mpEditor->ActiveArea()->GetScriptLayer(0), SpawnPoint);
mpEditor->UndoStack()->push(pCmd);
return true;
}
}
}
return false;
}
void WCreateTab::SetEditor(CWorldEditor *pEditor)
{
mpEditor = pEditor;
pEditor->Viewport()->installEventFilter(this);
}
void WCreateTab::SetMaster(CMasterTemplate *pMaster)
{
ui->TemplateView->SetMaster(pMaster);
}