diff --git a/src/editor/C4ConsoleQtMainWindow.ui b/src/editor/C4ConsoleQtMainWindow.ui
index c0254542e..107e2c8e4 100644
--- a/src/editor/C4ConsoleQtMainWindow.ui
+++ b/src/editor/C4ConsoleQtMainWindow.ui
@@ -993,6 +993,9 @@
IDS_MNU_DUPLICATE
+
+ F2
+
diff --git a/src/editor/C4ConsoleQtState.cpp b/src/editor/C4ConsoleQtState.cpp
index be4bac66c..52ea6e40a 100644
--- a/src/editor/C4ConsoleQtState.cpp
+++ b/src/editor/C4ConsoleQtState.cpp
@@ -342,6 +342,9 @@ bool C4ConsoleQtMainWindow::HandleEditorKeyDown(QKeyEvent *event)
case Qt::Key_Delete:
::Console.EditCursor.Delete();
return true;
+ case Qt::Key_F2:
+ ::Console.EditCursor.Duplicate();
+ return true;
}
uint32_t shift = 0;
if (event->modifiers() & Qt::AltModifier) shift |= MK_ALT;
diff --git a/src/editor/C4EditCursor.cpp b/src/editor/C4EditCursor.cpp
index deee5fe54..aa35c8eb2 100644
--- a/src/editor/C4EditCursor.cpp
+++ b/src/editor/C4EditCursor.cpp
@@ -726,13 +726,25 @@ void C4EditCursor::PerformDuplication(int32_t *object_numbers, int32_t object_co
if (obj) obj->Call(PSF_EditCursorDeselection);
}
if (local_call) selection.clear();
+ int64_t X_all = 0, Y_all = 0, n_selected = 0;
for (C4Object *obj : ::Objects)
if (obj->Number > prev_oei)
{
obj->Call(PSF_EditCursorSelection);
- if (local_call) selection.push_back(C4VObj(obj));
- // TODO: Reset editor X/Y to center objects on cursor
+ if (local_call)
+ {
+ selection.push_back(C4VObj(obj));
+ X_all += obj->GetX();
+ Y_all += obj->GetY();
+ ++n_selected;
+ }
}
+ // Reset EditCursor pos to center of duplicated objects, so they will be dragged along with the cursor
+ if (n_selected)
+ {
+ X = X_all / n_selected;
+ Y = Y_all / n_selected;
+ }
SetHold(true);
OnSelectionChanged();
}