mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-17 17:05:37 +00:00
Moved selection handling code to CNodeSelection, implemented instance spawning, half-implemented instance deleting (this build is buggy/crash prone)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user