Copy/paste bugfixes

This commit is contained in:
parax0 2016-03-20 18:22:11 -06:00
parent 0b1f419142
commit bb921dc613
2 changed files with 9 additions and 2 deletions

View File

@ -55,6 +55,7 @@ void CPasteNodesCommand::redo()
CMemoryInStream In(rkNode.InstanceData.data(), rkNode.InstanceData.size(), IOUtil::eBigEndian); CMemoryInStream In(rkNode.InstanceData.data(), rkNode.InstanceData.size(), IOUtil::eBigEndian);
CScriptObject *pInstance = CScriptLoader::LoadInstance(In, pArea, mpLayer, pArea->Version(), true); CScriptObject *pInstance = CScriptLoader::LoadInstance(In, pArea, mpLayer, pArea->Version(), true);
pArea->AddInstanceToArea(pInstance); pArea->AddInstanceToArea(pInstance);
mpLayer->AddInstance(pInstance);
pInstance->SetPosition(rkNode.Position + mPastePoint); pInstance->SetPosition(rkNode.Position + mPastePoint);
pInstance->SetRotation(rkNode.Rotation.ToEuler()); pInstance->SetRotation(rkNode.Rotation.ToEuler());
@ -107,7 +108,9 @@ void CPasteNodesCommand::redo()
CScriptObject *pReceiver = pLink->Receiver(); CScriptObject *pReceiver = pLink->Receiver();
if (pSender) pSender->RemoveLink(eOutgoing, pLink); if (pSender) pSender->RemoveLink(eOutgoing, pLink);
if (pReceiver) pReceiver->RemoveLink(eIncoming, pLink); if (pReceiver) pReceiver->RemoveLink(eIncoming, pLink);
delete pLink; delete pLink;
iLink--;
} }
} }
} }

View File

@ -227,6 +227,9 @@ void CWorldEditor::SetArea(CWorld *pWorld, CGameArea *pArea)
Log::Write("Loaded level: World " + mpWorld->Source() + " / Area " + mpArea->Source() + " (" + TO_TSTRING(LevelName) + ")"); Log::Write("Loaded level: World " + mpWorld->Source() + " / Area " + mpArea->Source() + " (" + TO_TSTRING(LevelName) + ")");
} }
// Update paste action
OnClipboardDataModified();
// Emit signals // Emit signals
emit LayersModified(); emit LayersModified();
} }
@ -650,8 +653,9 @@ void CWorldEditor::GizmoModeChanged(CGizmo::EGizmoMode mode)
// ************ PRIVATE SLOTS ************ // ************ PRIVATE SLOTS ************
void CWorldEditor::OnClipboardDataModified() void CWorldEditor::OnClipboardDataModified()
{ {
const QMimeData *pkMimeData = qApp->clipboard()->mimeData(); const QMimeData *pkClipboardMimeData = qApp->clipboard()->mimeData();
bool ValidMimeData = (qobject_cast<const CNodeCopyMimeData*>(pkMimeData) != nullptr); const CNodeCopyMimeData *pkMimeData = qobject_cast<const CNodeCopyMimeData*>(pkClipboardMimeData);
bool ValidMimeData = (pkMimeData && pkMimeData->Game() == CurrentGame());
ui->ActionPaste->setEnabled(ValidMimeData); ui->ActionPaste->setEnabled(ValidMimeData);
} }