Skip to content

Commit

Permalink
Add vertex adds it to the level's pipe, don't add a vertex if there's…
Browse files Browse the repository at this point in the history
… no pipe
  • Loading branch information
meh2481 committed Dec 25, 2023
1 parent 071f038 commit be43dc5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/WooGLEFX/Engine/FXCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ public static void buttons(VBox vBox) throws IOException {
addCompositegeomButton.setOnAction(e -> Main.addCompositegeom(Main.getLevel().getSceneObject()));
addHingeButton.setOnAction(e -> Main.addHinge(Main.getLevel().getSceneObject()));
autoPipeButton.setOnAction(e -> Main.autoPipe());
addVertexButton.setOnAction(e -> Main.addPipeVertex(Main.getLevel().getSceneObject()));
addVertexButton.setOnAction(e -> Main.addPipeVertex(Main.getLevel().getLevelObject()));
addFireButton.setOnAction(e -> Main.addFire(Main.getLevel().getLevelObject()));
addLinearforcefieldButton.setOnAction(e -> Main.addLinearForcefield(Main.getLevel().getSceneObject()));
addRadialforcefieldButton.setOnAction(e -> Main.addRadialForcefield(Main.getLevel().getSceneObject()));
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/com/WooGLEFX/Engine/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -1740,13 +1740,27 @@ public static void autoPipe() {

public static void addPipeVertex(EditorObject parent) {
// get the previous vertex before this one
EditorObject pipe = null;
if (parent instanceof Pipe) {
pipe = parent;
} else {
for (EditorObject child : parent.getChildren()) {
if (child instanceof Pipe) {
pipe = child;
break;
}
}
if (pipe == null) {
Alarms.errorMessage("You must create a pipe to add the vertex to.");
}
}
Vertex previous = null;
for (EditorObject child : parent.getChildren()) {
for (EditorObject child : pipe.getChildren()) {
if (child instanceof Vertex) {
previous = (Vertex) child;
}
}
Vertex obj = (Vertex) EditorObject.create("Vertex", new EditorAttribute[0], parent);
Vertex obj = (Vertex) EditorObject.create("Vertex", new EditorAttribute[0], pipe);
obj.setPrevious(previous);
obj.setAttribute("x", getScreenCenter().getX());
obj.setAttribute("y", -getScreenCenter().getY());
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/WooGLEFX/GUI/Alarms.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ public static void errorMessage(Exception error) {
logger.error("", error);
}

public static void errorMessage(String error) {
Alert alert = new Alert(AlertType.ERROR);
alert.setResizable(true);
alert.setHeaderText("Error");
alert.setContentText(error);
alert.show();
// Show the message in the console
logger.error(error);
}

public static void loadingResourcesError(String error) {
Alert alert = new Alert(AlertType.ERROR);
alert.setResizable(true);
Expand Down

0 comments on commit be43dc5

Please sign in to comment.