Skip to content

Commit

Permalink
I did some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Crazydiamonde committed Aug 25, 2023
1 parent 9f21f00 commit 8941ba8
Show file tree
Hide file tree
Showing 24 changed files with 230 additions and 126 deletions.
28 changes: 24 additions & 4 deletions src/main/java/com/WooGLEFX/EditorObjects/GeometryImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ public void draw(GraphicsContext graphicsContext, GraphicsContext imageGraphicsC
if (Main.getLevel().isShowGraphics()) {
image = parent.getImage("image");

Position imagePos = parent.getPosition("imagepos");
Position imagePos;
if (parent.getAttribute("imagepos").equals("")) {
imagePos = new Position(parent.getDouble("x"), parent.getDouble("y"));
} else {
imagePos = parent.getPosition("imagepos");
}
double x = imagePos.getX();
double y = imagePos.getY();
if (parent.getParent() instanceof Compositegeom) {
Expand Down Expand Up @@ -129,7 +134,12 @@ public void dragFromMouse(double mouseX, double mouseY, double dragSourceX, doub

public DragSettings mouseIntersection(double mX2, double mY2) {

Position imagePos = Position.parse(parent.getAttribute("imagepos"));
Position imagePos;
if (parent.getAttribute("imagepos").equals("")) {
imagePos = new Position(parent.getDouble("x"), parent.getDouble("y"));
} else {
imagePos = parent.getPosition("imagepos");
}
double x = imagePos.getX();
double y = imagePos.getY();
if (parent.getParent() instanceof Compositegeom) {
Expand Down Expand Up @@ -166,7 +176,12 @@ public DragSettings mouseIntersection(double mX2, double mY2) {
public DragSettings mouseIntersectingCorners(double mX2, double mY2) {
if (Main.getLevel().isShowGraphics() && image != null) {

Position imagePos = Position.parse(parent.getAttribute("imagepos"));
Position imagePos;
if (parent.getAttribute("imagepos").equals("")) {
imagePos = new Position(parent.getDouble("x"), parent.getDouble("y"));
} else {
imagePos = parent.getPosition("imagepos");
}
double x = imagePos.getX();
double y = imagePos.getY();
if (parent.getParent() instanceof Compositegeom) {
Expand Down Expand Up @@ -327,7 +342,12 @@ public void resizeFromMouse(double mouseX, double mouseY, double resizeDragSourc

public void rotateFromMouse(double mouseX, double mouseY, double rotateAngleOffset){

Position imagePos = Position.parse(parent.getAttribute("imagepos"));
Position imagePos;
if (parent.getAttribute("imagepos").equals("")) {
imagePos = new Position(parent.getDouble("x"), parent.getDouble("y"));
} else {
imagePos = parent.getPosition("imagepos");
}
double x2 = imagePos.getX();
double y2 = imagePos.getY();
if (parent.getParent() instanceof Compositegeom) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ public class ParticleGraphicsInstance {
private final double initialScale;
private final double finalscale;
private final Position acceleration;
private double rotation;
private final double rotation;
private double displayRotation;
private final double initialDisplayRotation;
private double rotspeed;
private double speed;
private final double rotspeed;
private final double speed;
private final double lifespan;
private final boolean fade;
private double alpha;
Expand Down Expand Up @@ -55,15 +55,15 @@ public double getAlpha() {
return alpha;
}

public ParticleGraphicsInstance(Position pos, double scale, double finalscale, double rotation, double rotspeed, double speed, Position acceleration, double lifespan, boolean fade, boolean additive) {
public ParticleGraphicsInstance(Position pos, double scale, double finalscale, double visualrotation, double rotation, double rotspeed, double speed, Position acceleration, double lifespan, boolean fade, boolean additive) {
this.originalPos = new Position(pos.getX(), pos.getY());
this.pos = pos;
this.scale = scale;
this.initialScale = scale;
this.finalscale = finalscale;
this.rotation = rotation;
this.rotspeed = rotspeed;
this.initialDisplayRotation = 0;
this.initialDisplayRotation = visualrotation;
this.speed = speed;
this.acceleration = acceleration;
this.lifespan = lifespan;
Expand Down Expand Up @@ -94,7 +94,9 @@ public boolean update(){
if (lifespan != -1) {
double thing = dt / this.lifespan;
this.scale = this.initialScale * (1 - thing) + this.finalscale * thing;
this.alpha = 1 - thing;
if (fade) {
this.alpha = 1 - thing;
}
}
return false;
}
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/WooGLEFX/Engine/FXCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ public static ToolBar getNullGooballsToolbar() {
public static Button buttonShowHideParticles = new Button();
public static Button buttonShowHideLabels = new Button();
public static Button buttonShowHideAnim = new Button();
public static Button buttonShowHideSceneBGColor = new Button();



Expand Down Expand Up @@ -362,6 +363,7 @@ public static void buttons (VBox vBox) throws IOException {
buttonShowHideParticles.setGraphic(new ImageView(FileManager.getIcon("ButtonIcons\\ShowHide\\showhide_particles.png")));
buttonShowHideLabels.setGraphic(new ImageView(FileManager.getIcon("ButtonIcons\\ShowHide\\showhide_labels.png")));
buttonShowHideAnim.setGraphic(new ImageView(FileManager.getIcon("ButtonIcons\\ShowHide\\showhide_anim.png")));
buttonShowHideSceneBGColor.setGraphic(new ImageView(FileManager.getIcon("ButtonIcons\\ShowHide\\showhide_scenebgcolor.png")));

buttonNewOld.setOnAction(e -> Main.newLevel(1.3));
buttonNewNew.setOnAction(e -> Main.newLevel(1.5));
Expand Down Expand Up @@ -397,6 +399,7 @@ public static void buttons (VBox vBox) throws IOException {
buttonShowHideParticles.setOnAction(e -> Main.showHideParticles());
buttonShowHideLabels.setOnAction(e -> Main.showHideLabels());
buttonShowHideAnim.setOnAction(e -> Main.showHideAnim());
buttonShowHideSceneBGColor.setOnAction(e -> Main.showHideSceneBGColor());

buttonNewOld.setTooltip(new Tooltip("New Level (1.3)"));
buttonNewNew.setTooltip(new Tooltip("New Level (1.5)"));
Expand Down Expand Up @@ -432,6 +435,7 @@ public static void buttons (VBox vBox) throws IOException {
buttonShowHideParticles.setTooltip(new Tooltip("Show/Hide Particles"));
buttonShowHideLabels.setTooltip(new Tooltip("Show/Hide Labels"));
buttonShowHideAnim.setTooltip(new Tooltip("Show/Hide Animations"));
buttonShowHideSceneBGColor.setTooltip(new Tooltip("Show/Hide Scene Background Color"));

functionsToolbar.getItems().addAll(buttonNewOld, buttonOpenOld, buttonCloneOld, new Separator());
functionsToolbar.getItems().addAll(buttonNewNew, buttonOpenNew, buttonCloneNew, new Separator());
Expand All @@ -444,7 +448,7 @@ public static void buttons (VBox vBox) throws IOException {
functionsToolbar.getItems().addAll(buttonCleanResources, new Separator());
functionsToolbar.getItems().addAll(buttonSetMusic, buttonSetLoopsound, new Separator());
functionsToolbar.getItems().addAll(buttonSelectMoveAndResize, buttonZoomAndPanView, buttonStrandMode, new Separator());
functionsToolbar.getItems().addAll(buttonShowHideCamera, buttonShowHideForcefields, buttonShowHideGeometry, buttonShowHideGraphics, buttonShowHideGoos, buttonShowHideParticles, buttonShowHideLabels, buttonShowHideAnim, new Separator());
functionsToolbar.getItems().addAll(buttonShowHideCamera, buttonShowHideForcefields, buttonShowHideGeometry, buttonShowHideGraphics, buttonShowHideGoos, buttonShowHideParticles, buttonShowHideLabels, buttonShowHideAnim, buttonShowHideSceneBGColor, new Separator());

for (Node node : functionsToolbar.getItems()) {
node.setDisable(true);
Expand Down
47 changes: 27 additions & 20 deletions src/main/java/com/WooGLEFX/Engine/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import javafx.scene.image.ImageView;
import javafx.scene.input.*;
import javafx.scene.layout.*;
import javafx.scene.paint.Paint;
import javafx.scene.transform.Affine;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
Expand Down Expand Up @@ -166,6 +167,7 @@ public static void newLevel(String name, double version) {

level.getSceneObject().setRealName("scene");
level.getSceneObject().setTreeItem(new TreeItem<>(level.getSceneObject()));
level.getSceneObject().setAttribute("backgroundcolor", "255,255,255");
level.getLevelObject().setRealName("level");
level.getLevelObject().setTreeItem(new TreeItem<>(level.getLevelObject()));
level.getResourcesObject().setRealName("ResourceManifest");
Expand Down Expand Up @@ -297,18 +299,18 @@ public static void openLevel(String levelName, double version) {
}

for (EditorObject object : level.getScene()) {
object.update();
object.setLevel(level);
object.update();
}

for (EditorObject object : level.getLevel()) {
object.update();
object.setLevel(level);
object.update();
}

for (EditorObject object : level.getResources()) {
object.update();
object.setLevel(level);
object.update();
}

//Put everything in the hierarchy
Expand Down Expand Up @@ -928,6 +930,11 @@ public static void showHideAnim() {
level.setShowAnimations(!level.isShowAnimations());
}

public static void showHideSceneBGColor() {
System.out.println("Show/Hide Scene Background Color");
level.setShowSceneBGColor(!level.isShowSceneBGColor());
}

public static void addAnything(EditorObject obj, EditorObject parent) {
//obj.setTreeItem(new TreeItem<>(obj));
//parent.getTreeItem().getChildren().add(obj.getTreeItem());
Expand Down Expand Up @@ -1511,11 +1518,7 @@ public static void mouse_wheel_moved(ScrollEvent e) {
}

//Redraw the canvas.
try {
Renderer.drawEverything(level, canvas, imageCanvas);
} catch (FileNotFoundException e2) {
Alarms.errorMessage(e2);
}
Renderer.drawEverything(level, canvas, imageCanvas);
}
}

Expand Down Expand Up @@ -1628,6 +1631,7 @@ public static void onSetLevel() {
FXCreator.buttonShowHideGraphics.setGraphic(new ImageView(level.isShowGraphics() ? WorldLevel.showHideImages1 : WorldLevel.showHideImages0));
FXCreator.buttonShowHideLabels.setGraphic(new ImageView(level.isShowLabels() ? WorldLevel.showHideLabels1 : WorldLevel.showHideLabels0));
FXCreator.buttonShowHideParticles.setGraphic(new ImageView(level.isShowParticles() ? WorldLevel.showHideParticles1 : WorldLevel.showHideParticles0));
FXCreator.buttonShowHideSceneBGColor.setGraphic(new ImageView(level.isShowSceneBGColor() ? WorldLevel.showHideSceneBGColor1 : WorldLevel.showHideSceneBGColor0));
}
}

Expand Down Expand Up @@ -1743,13 +1747,14 @@ public static TreeTableView<EditorObject> getHierarchy() {
public static void draw() {

if (level != null) {
imageCanvas.getGraphicsContext2D().clearRect(-5000000, -5000000, 10000000, 10000000);
canvas.getGraphicsContext2D().clearRect(-5000000, -5000000, 10000000, 10000000);
try {
Renderer.drawEverything(level, canvas, imageCanvas);
} catch (FileNotFoundException e) {
Alarms.errorMessage(e);
if (level.isShowSceneBGColor()) {
imageCanvas.getGraphicsContext2D().setFill(Paint.valueOf(level.getSceneObject().getColor("backgroundcolor").toHexRGBA()));
imageCanvas.getGraphicsContext2D().fillRect(-5000000, -5000000, 10000000, 10000000);
} else {
imageCanvas.getGraphicsContext2D().clearRect(-5000000, -5000000, 10000000, 10000000);
}
canvas.getGraphicsContext2D().clearRect(-5000000, -5000000, 10000000, 10000000);
Renderer.drawEverything(level, canvas, imageCanvas);
} else {
Renderer.clear(level, canvas, imageCanvas);
}
Expand Down Expand Up @@ -1882,11 +1887,13 @@ private static void importGameResources(double version) {
File[] animationsArray = bruh1.listFiles();
if (animationsArray != null) {
for (File second : animationsArray) {
try (FileInputStream test2 = new FileInputStream(second)) {
byte[] allBytes = test2.readAllBytes();
animations.add(AnimationReader.readBinltl(allBytes, second.getName()));
} catch (Exception e) {
allFailedResources.add("Animation: " + second.getName() + " (version 1.3)");
if (!second.getName().substring(second.getName().lastIndexOf(".")).equals(".binltl64")) {
try (FileInputStream test2 = new FileInputStream(second)) {
byte[] allBytes = test2.readAllBytes();
animations.add(AnimationReader.readBinltl(allBytes, second.getName()));
} catch (Exception e) {
allFailedResources.add("Animation: " + second.getName() + " (version 1.3)");
}
}
}
}
Expand All @@ -1905,7 +1912,7 @@ private static void importGameResources(double version) {
}
}
}
} catch (Exception e){
} catch (Exception e) {
Alarms.errorMessage(e);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/WooGLEFX/Engine/Renderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public static ArrayList<EditorObject> orderObjectsBySelectionDepth(WorldLevel le

}

public static void drawEverything(WorldLevel level, Canvas canvas, Canvas imageCanvas) throws FileNotFoundException {
public static void drawEverything(WorldLevel level, Canvas canvas, Canvas imageCanvas) {
GraphicsContext graphicsContext = canvas.getGraphicsContext2D();
GraphicsContext imageGraphicsContext = imageCanvas.getGraphicsContext2D();

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/WooGLEFX/GUI/PaletteReconfigurator.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public void start(Stage stage) throws ParserConfigurationException, SAXException

stage.setTitle("Configure Goo Ball Palette");

//TODO display version 1.3 balls and version 1.5 balls side by side instead of on top of each other

if (FileManager.isHasOldWOG()) {
File[] balls = new File(FileManager.getOldWOGdir() + "\\res\\balls").listFiles();
if (balls != null) {
Expand Down
67 changes: 44 additions & 23 deletions src/main/java/com/WooGLEFX/Structures/EditorObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,55 +324,76 @@ public boolean isValid() {
return false;
}
} else if (!attribute.getInput().verify(this, attribute.getValue())) {
System.out.println("failed to verify " + attribute.getValue());
//System.out.println("failed to verify " + attribute.getValue());
return false;
}
}
return true;
}

public double getDouble(String attributeName) {
try {
return Double.parseDouble(getAttribute(attributeName));
} catch (NumberFormatException e){
Alarms.errorMessage(e);
if (getAttribute(attributeName) == null) {
throw new RuntimeException("Could not find attribute " + attributeName + " for " + getRealName());
} else {
try {
return Double.parseDouble(getAttribute(attributeName));
} catch (NumberFormatException e) {
throw new RuntimeException("Could not parse double " + attributeName + " for " + getRealName());
}
}
throw new RuntimeException("Could not find double attribute " + attributeName + " for " + getRealName());
}

public Position getPosition(String attributeName) {
try {
return Position.parse(getAttribute(attributeName));
} catch (NumberFormatException e){
Alarms.errorMessage(e);
if (getAttribute(attributeName) == null) {
throw new RuntimeException("Could not find attribute " + attributeName + " for " + getRealName());
} else {
try {
return Position.parse(getAttribute(attributeName));
} catch (NumberFormatException e) {
throw new RuntimeException("Could not parse position " + attributeName + " for " + getRealName());
}
}
throw new RuntimeException("Could not find position attribute " + attributeName + " for " + getRealName());
}

public Color getColor(String attributeName) {
try {
return Color.parse(getAttribute(attributeName));
} catch (NumberFormatException e){
Alarms.errorMessage(e);
if (getAttribute(attributeName) == null) {
throw new RuntimeException("Could not find attribute " + attributeName + " for " + getRealName());
} else {
try {
return Color.parse(getAttribute(attributeName));
} catch (NumberFormatException e) {
throw new RuntimeException("Could not parse color " + attributeName + " for " + getRealName());
}
}
throw new RuntimeException("Could not find color attribute " + attributeName + " for " + getRealName());
}

public String getString(String attributeName) {
String attribute = getAttribute(attributeName);
if (attribute != null) {
return attribute;
} else {
throw new RuntimeException("Could not find string attribute " + attributeName + " for " + getRealName());
}
throw new RuntimeException("Could not find string attribute " + attributeName + " for " + getRealName());
}

public Image getImage(String attributeName) {
try {
return GlobalResourceManager.getImage(getAttribute(attributeName), level.getVersion());
} catch (FileNotFoundException e){
Alarms.errorMessage(e);
if (getAttribute(attributeName) == null) {
throw new RuntimeException("Could not find attribute " + attributeName + " for " + getRealName());
} else {
try {
return GlobalResourceManager.getImage(getAttribute(attributeName), level.getVersion());
} catch (FileNotFoundException e) {
throw new RuntimeException("Could not parse image " + attributeName + " for " + getRealName());
}
}
}

public Boolean getBoolean(String attributeName) {
if (getAttribute(attributeName) == null) {
throw new RuntimeException("Could not find attribute " + attributeName + " for " + getRealName());
} else {
return Boolean.parseBoolean(getAttribute(attributeName));
}
throw new RuntimeException("Could not find double attribute " + attributeName + " for " + getRealName());
}

public AttributeChangeAction[] getUserActions(EditorAttribute[] oldAttributes){
Expand Down Expand Up @@ -409,7 +430,7 @@ public void updateWithAnimation(WoGAnimation animation, float timer){

}

public void draw(GraphicsContext graphicsContext, GraphicsContext imageGraphicsContext) throws FileNotFoundException {
public void draw(GraphicsContext graphicsContext, GraphicsContext imageGraphicsContext) {

}

Expand Down
Loading

0 comments on commit 8941ba8

Please sign in to comment.