+41
-30
lines changedFilter options
+41
-30
lines changed Original file line number Diff line number Diff line change
@@ -473,15 +473,15 @@ class DialoguePane(graph: DialogueGraph = DialogueGraph()) : Pane() {
473
473
val startLayoutY = nodeView.properties["startLayoutY"] as Double
474
474
475
475
if (startLayoutX != nodeView.layoutX || startLayoutY != nodeView.layoutY) {
476
-
performUIAction(MoveNodeAction(nodeView, startLayoutX, startLayoutY, nodeView.layoutX, nodeView.layoutY))
476
+
performUIAction(MoveNodeAction(nodeView.node, this::getNodeView, startLayoutX, startLayoutY, nodeView.layoutX, nodeView.layoutY))
477
477
}
478
478
}
479
479
480
480
nodeView.cursor = Cursor.MOVE
481
481
nodeView.closeButton.cursor = Cursor.HAND
482
482
483
483
nodeView.closeButton.setOnMouseClicked {
484
-
graph.removeNode(nodeView.node)
484
+
performUIAction(RemoveNodeAction(graph, nodeView.node, nodeView.layoutX, nodeView.layoutY, this::getNodeView))
485
485
}
486
486
487
487
nodeView.outPoints.forEach { outPoint ->
Original file line number Diff line number Diff line change
@@ -28,21 +28,27 @@ interface EditorAction {
28
28
// * remove node (and its incident edges)
29
29
// * add edge
30
30
// * remove edge
31
+
// * TODO: node text editing
31
32
32
33
class MoveNodeAction(
33
-
private val nodeView: NodeView,
34
+
private val node: DialogueNode,
35
+
private val newNodeViewGetter: (DialogueNode) -> NodeView,
34
36
private val startX: Double,
35
37
private val startY: Double,
36
38
private val endX: Double,
37
39
private val endY: Double
38
40
) : EditorAction {
39
41
40
42
override fun run() {
43
+
val nodeView = newNodeViewGetter(node)
44
+
41
45
nodeView.layoutX = endX
42
46
nodeView.layoutY = endY
43
47
}
44
48
45
49
override fun undo() {
50
+
val nodeView = newNodeViewGetter(node)
51
+
46
52
nodeView.layoutX = startX
47
53
nodeView.layoutY = startY
48
54
}
@@ -66,32 +72,37 @@ class AddNodeAction(
66
72
}
67
73
}
68
74
69
-
//class RemoveNodeAction(
70
-
// private val graph: DialogueGraph,
71
-
// private val node: DialogueNode
72
-
//) : EditorAction {
73
-
//
74
-
// private val edges = arrayListOf<DialogueEdge>()
75
-
//
76
-
// override fun run() {
77
-
// graph.edges.filter { it.source === node || it.target === node }
78
-
// .forEach { edges += it }
79
-
//
80
-
// graph.removeNode(node)
81
-
// }
82
-
//
83
-
// override fun undo() {
84
-
// graph.addNode(node)
85
-
//
86
-
// edges.forEach {
87
-
// if (it.target === node) {
88
-
// graph.addEdge()
89
-
//
90
-
// graph.addChoiceEdge()
91
-
// }
92
-
// }
93
-
// }
94
-
//}
75
+
class RemoveNodeAction(
76
+
private val graph: DialogueGraph,
77
+
private val node: DialogueNode,
78
+
79
+
// where the node was during removal
80
+
private val layoutX: Double,
81
+
private val layoutY: Double,
82
+
83
+
// the newly created one (via undo) can be accessed through this
84
+
private val newNodeViewGetter: (DialogueNode) -> NodeView
85
+
) : EditorAction {
86
+
87
+
private val edges = arrayListOf<DialogueEdge>()
88
+
89
+
override fun run() {
90
+
graph.edges.filter { it.source === node || it.target === node }
91
+
.forEach { edges += it }
92
+
93
+
graph.removeNode(node)
94
+
}
95
+
96
+
override fun undo() {
97
+
graph.addNode(node)
98
+
99
+
newNodeViewGetter(node).relocate(layoutX, layoutY)
100
+
101
+
edges.forEach {
102
+
graph.addEdge(it)
103
+
}
104
+
}
105
+
}
95
106
96
107
class AddEdgeAction(
97
108
private val graph: DialogueGraph,
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ class MainUI : BorderPane() {
64
64
contextMenuFile.addItem("Exit") { getGameController().exit() }
65
65
66
66
val contextMenuEdit = FXGLContextMenu()
67
-
//contextMenuEdit.addItem("Undo (CTRL+Z)") { undo() }
67
+
contextMenuEdit.addItem("Undo (CTRL+Z)") { undo() }
68
68
//contextMenuEdit.addItem("Redo") { redo() }
69
69
//contextMenuEdit.addItem("Copy (CTRL+C)") { }
70
70
//contextMenuEdit.addItem("Paste (CTRL+V)") { }
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4