1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00

Merge pull request #1277 from Nordsoft91/editor-cutcopypaste

This commit is contained in:
Nordsoft91
2022-12-27 17:28:39 +04:00
committed by GitHub
9 changed files with 105 additions and 13 deletions

View File

@ -269,14 +269,17 @@ void MapView::mousePressEvent(QMouseEvent *event)
{
if(event->button() == Qt::LeftButton)
{
auto * obj = sc->selectionObjectsView.selectObjectAt(tileStart.x, tileStart.y);
if(obj)
//when paste, new object could be beyond initial object so we need to test two objects in order to select new one
//if object is pasted at place where is multiple objects then proper selection is not guaranteed
auto * firstSelectedObject = sc->selectionObjectsView.selectObjectAt(tileStart.x, tileStart.y);
auto * secondSelectedObject = sc->selectionObjectsView.selectObjectAt(tileStart.x, tileStart.y, firstSelectedObject);
if(firstSelectedObject)
{
if(sc->selectionObjectsView.isSelected(obj))
if(sc->selectionObjectsView.isSelected(firstSelectedObject))
{
if(qApp->keyboardModifiers() & Qt::ControlModifier)
{
sc->selectionObjectsView.deselectObject(obj);
sc->selectionObjectsView.deselectObject(firstSelectedObject);
sc->selectionObjectsView.selectionMode = SelectionObjectsLayer::SELECTION;
}
else
@ -284,10 +287,13 @@ void MapView::mousePressEvent(QMouseEvent *event)
}
else
{
if(!(qApp->keyboardModifiers() & Qt::ControlModifier))
sc->selectionObjectsView.clear();
if(!secondSelectedObject || !sc->selectionObjectsView.isSelected(secondSelectedObject))
{
if(!(qApp->keyboardModifiers() & Qt::ControlModifier))
sc->selectionObjectsView.clear();
sc->selectionObjectsView.selectObject(firstSelectedObject);
}
sc->selectionObjectsView.selectionMode = SelectionObjectsLayer::MOVEMENT;
sc->selectionObjectsView.selectObject(obj);
}
}
else