File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed
fxgl-tools/src/main/kotlin/com/almasb/fxgl/tools/dialogues Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -465,7 +465,7 @@ class DialoguePane(graph: DialogueGraph = DialogueGraph()) : Pane() {
465
465
}
466
466
467
467
private fun onSelectedNodeViewChanged (newNodeView : NodeView ? ) {
468
-
468
+
469
469
}
470
470
471
471
/* *
@@ -635,6 +635,17 @@ class DialoguePane(graph: DialogueGraph = DialogueGraph()) : Pane() {
635
635
showMessage(" TODO: Sorry, not implemented yet." )
636
636
}
637
637
638
+ fun duplicate () {
639
+ selectedNodeView.value?.let { nodeView ->
640
+ // currently we do not allow multiple start nodes
641
+ if (nodeView.node.type != START ) {
642
+ val node = nodeView.node.copy()
643
+
644
+ performUIAction(AddNodeAction (graph, node))
645
+ }
646
+ }
647
+ }
648
+
638
649
fun save (): SerializableGraph {
639
650
isDirtyProperty.value = false
640
651
Original file line number Diff line number Diff line change @@ -83,8 +83,7 @@ class MainUI : BorderPane() {
83
83
val contextMenuEdit = FXGLContextMenu ()
84
84
contextMenuEdit.addItem(" Undo (CTRL+Z)" ) { undo() }
85
85
// contextMenuEdit.addItem("Redo") { redo() }
86
- // contextMenuEdit.addItem("Copy (CTRL+C)") { }
87
- // contextMenuEdit.addItem("Paste (CTRL+V)") { }
86
+ contextMenuEdit.addItem(" Duplicate Node (CTRL+D)" ) { duplicate() }
88
87
contextMenuEdit.addItem(" Preferences" ) { openPreferencesDialog() }
89
88
90
89
val contextMenuAdd = FXGLContextMenu ()
@@ -152,6 +151,12 @@ class MainUI : BorderPane() {
152
151
undo()
153
152
}
154
153
}, KeyCode .Z , InputModifier .CTRL )
154
+
155
+ getInput().addAction(object : UserAction (" Duplicate" ) {
156
+ override fun onActionBegin () {
157
+ duplicate()
158
+ }
159
+ }, KeyCode .D , InputModifier .CTRL )
155
160
}
156
161
157
162
private fun makeRunButton (): Node {
@@ -270,6 +275,10 @@ class MainUI : BorderPane() {
270
275
currentTab?.pane?.redo()
271
276
}
272
277
278
+ private fun duplicate () {
279
+ currentTab?.pane?.duplicate()
280
+ }
281
+
273
282
private fun openAboutDialog () {
274
283
showMessage(
275
284
" ${getSettings().title} : v.${getSettings().version} \n\n "
You can’t perform that action at this time.
0 commit comments