Skip to content

Commit

Permalink
List all particle resources in the list
Browse files Browse the repository at this point in the history
  • Loading branch information
meh2481 committed Dec 26, 2023
1 parent f8b2631 commit d6a3059
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
6 changes: 1 addition & 5 deletions src/main/java/com/WooGLEFX/Engine/FXCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -1466,11 +1466,7 @@ public static ContextMenu possibleAttributeValues(TextFieldTreeTableCell<EditorA
}
}
case InputField.PARTICLES -> {
// TODO Custom ones too
List<String> sortedParticleTypes = new ArrayList<>();
sortedParticleTypes.addAll(BaseGameResources.PARTICLE_FX);
sortedParticleTypes.sort(String::compareToIgnoreCase);
for (String particleType : sortedParticleTypes) {
for (String particleType : Main.sortedParticleNames) {
MenuItem setImageItem = new MenuItem(particleType);

setImageItem.setOnAction(event -> {
Expand Down
21 changes: 15 additions & 6 deletions src/main/java/com/WooGLEFX/Engine/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.imageio.ImageIO;
import javax.xml.parsers.ParserConfigurationException;
Expand Down Expand Up @@ -113,7 +115,6 @@
import javafx.scene.paint.Paint;
import javafx.scene.transform.Affine;
import javafx.stage.FileChooser;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;

Expand Down Expand Up @@ -162,6 +163,9 @@ public class Main extends Application {

private static TabPane levelSelectPane;

private static final List<EditorObject> particles = new ArrayList<>();
public static final List<String> sortedParticleNames = new ArrayList<>();

public static EditorObject getStrand1Gooball() {
return strand1Gooball;
}
Expand Down Expand Up @@ -2667,14 +2671,10 @@ public static void draw() {
}
}

private static final ArrayList<EditorObject> particles = new ArrayList<>();

public static ArrayList<EditorObject> getParticles() {
public static List<EditorObject> getParticles() {
return particles;
}

// TODO okay somehow a scenelayer got stuck to my cursor, fix that ok thanks

public static EditorObject generateBlankAddinObject(String levelName) {
EditorObject addin = EditorObject.create("Addin_addin", new EditorAttribute[0], null);
EditorObject.create("Addin_id", new EditorAttribute[0], addin);
Expand Down Expand Up @@ -2780,6 +2780,15 @@ private static void importGameResources(double version) {
}
}

// Load particle names, remove duplicates, and sort them alphabetically
Set<String> particleNames = new HashSet<>();
particles.stream()
.filter(particle -> particle.getAttribute("name") != null)
.forEach(particle -> particleNames.add(particle.getAttribute("name")));
sortedParticleNames.clear();
sortedParticleNames.addAll(particleNames);
sortedParticleNames.sort(String::compareToIgnoreCase);

// Load all animations from the game files
try {
if (version == 1.3 && FileManager.isHasOldWOG()) {
Expand Down

0 comments on commit d6a3059

Please sign in to comment.