Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Crazydiamonde committed Aug 17, 2024
1 parent 839b538 commit 1a71358
Show file tree
Hide file tree
Showing 54 changed files with 863 additions and 664 deletions.
Binary file modified WooGLE.jar
Binary file not shown.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@
<version>1.26.2</version>
</dependency>
<dependency>
<groupId>com.github.luben</groupId>
<artifactId>zstd-jni</artifactId>
<version>1.5.6-3</version>
</dependency>
<groupId>com.github.luben</groupId>
<artifactId>zstd-jni</artifactId>
<version>1.5.6-3</version>
</dependency>


</dependencies>
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/woogleFX/editorObjects/EditorObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.woogleFX.editorObjects.attributes.InputField;
import com.woogleFX.editorObjects.attributes.MetaEditorAttribute;
import com.woogleFX.editorObjects.objectComponents.ObjectComponent;
import com.woogleFX.editorObjects.objectCreators.ObjectCreator;
import com.woogleFX.gameData.level.GameVersion;

import javafx.scene.control.TreeItem;
Expand Down
70 changes: 63 additions & 7 deletions src/main/java/com/woogleFX/editorObjects/ObjectManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.woogleFX.editorObjects.objectCreators.ObjectAdder;
import com.woogleFX.editorObjects.objectCreators.ObjectCreator;
import com.woogleFX.engine.LevelManager;
import com.woogleFX.engine.SelectionManager;
import com.woogleFX.engine.fx.hierarchy.FXHierarchy;
import com.woogleFX.engine.fx.FXPropertiesView;
import com.woogleFX.engine.undoHandling.UndoManager;
Expand All @@ -29,7 +30,6 @@ public class ObjectManager {
public static void create(_Level _level, EditorObject _object, int row) {

EditorObject object = _object;
object.update();

if (object instanceof _2_Level_BallInstance) {
ObjectAdder.fixGooBall(object);
Expand All @@ -56,8 +56,19 @@ public static void create(_Level _level, EditorObject _object, int row) {

level.getObjects().add(object);

if (object instanceof _2_Level_BallInstance ballInstance)
BallInstanceHelper.addTerrainBall(level, ballInstance);
int i = switch (level.getCurrentlySelectedSection()) {
case "Terrain" -> 0;
case "Balls" -> 1;
case "Items" -> 2;
case "Pins" -> 3;
case "Camera" -> 4;
default -> -1;
};
FXHierarchy.getNewHierarchySwitcherButtons().getSelectionModel().select((i + 1) % 5);
FXHierarchy.getNewHierarchySwitcherButtons().getSelectionModel().select(i);

FXHierarchy.getHierarchy().getSelectionModel().clearSelection();
FXHierarchy.getHierarchy().getSelectionModel().select(object.getTreeItem());

} else {

Expand Down Expand Up @@ -95,6 +106,8 @@ public static void create(_Level _level, EditorObject _object, int row) {

}

object.update();

}


Expand Down Expand Up @@ -142,19 +155,62 @@ public static void deleteItem(_Level _level, EditorObject _item, boolean parentD

} else if (_level instanceof WOG2Level level) {

if (_item instanceof _2_Level_BallInstance ballInstance) {
deleteItem(level, level.getLevel().getChildren("terrainBalls").get(level.getLevel().getChildren("balls").indexOf(ballInstance)), false);
}

level.getObjects().remove(_item);

if (!parentDeleted) {
_item.getParent().getChildren().remove(_item);
_item.getParent().getTreeItem().getChildren().remove(_item.getTreeItem());
}

if (_item instanceof _2_Level_BallInstance ballInstance) {

String id = ballInstance.getAttribute("uid").stringValue();

for (EditorObject EditorObject : level.getObjects())
if (EditorObject instanceof _2_Level_Strand strand) {

String gb1 = strand.getAttribute("ball1UID").stringValue();
if (gb1.equals(id)) {
strand.setGoo1(null);
strand.update();
}

String gb2 = strand.getAttribute("ball2UID").stringValue();
if (gb2.equals(id)) {
strand.setGoo2(null);
strand.update();
}

}

}

if (_item instanceof _2_Level_Strand strand) {

String gb1 = strand.getAttribute("ball1UID").stringValue();
String gb2 = strand.getAttribute("ball2UID").stringValue();

for (EditorObject EditorObject : level.getObjects())
if (EditorObject instanceof _2_Level_BallInstance ballInstance) {

String id = ballInstance.getAttribute("uid").stringValue();

if (gb1.equals(id)) {
ballInstance.update();
}

if (gb2.equals(id)) {
ballInstance.update();
}

}

}

}

_item.update();

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public String actualValue() {
}

public String stringValue() {
if (value.getValue().isEmpty()) return defaultValue;
if (value.getValue().isEmpty()) return defaultValue == null ? "" : defaultValue;
else return value.getValue();
}

Expand Down Expand Up @@ -90,7 +90,7 @@ public void addChangeListener(ChangeListener<String> changeListener) {
}


private String defaultValue = "";
private String defaultValue = null;
public String getDefaultValue() {
return defaultValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ public enum InputField {

;

public static boolean verify(EditorObject object, InputField type, String potential) {
public static boolean verify(EditorObject object, InputField type, String potential, boolean required) {

if (type == null) return true;
if (type == _2_LIST_STRING || type == _2_LIST_NUMBER || type == _2_LIST_CHILD || type == _2_LIST_CHILD_HIDDEN) return true;

if (potential.isEmpty()) return !(type == _1_IMAGE_REQUIRED);
if (potential == null) return !(type == _1_IMAGE_REQUIRED || required);

switch (type) {

Expand Down Expand Up @@ -245,7 +246,7 @@ private static boolean verifyResource(EditorObject object, InputField type, Stri

case _1_BALL -> {
String dir = FileManager.getGameDir(object.getVersion());
File[] ballFiles = new File(dir + "\\res\\balls").listFiles();
File[] ballFiles = new File(dir + "/res/balls").listFiles();
if (ballFiles == null) return false;
for (File ballFile : ballFiles) {
if (ballFile.getName().equals(potential)) {
Expand Down Expand Up @@ -315,7 +316,7 @@ private static boolean verifyFilePath(EditorObject object, InputField type, Stri
String adjustedPath = resrcImage.getAdjustedPath();
String setDefaultsPart = adjustedPath.substring(0, adjustedPath.length() - path.length());
String dir = FileManager.getGameDir(resrcImage.getVersion());
return new File(dir + "\\" + setDefaultsPart + potential + ".png").exists();
return new File(dir + "/" + setDefaultsPart + potential + ".png").exists();
} else return false;
}

Expand All @@ -325,7 +326,7 @@ private static boolean verifyFilePath(EditorObject object, InputField type, Stri
String adjustedPath = sound.getAdjustedPath();
String setDefaultsPart = adjustedPath.substring(0, adjustedPath.length() - path.length());
String dir = FileManager.getGameDir(sound.getVersion());
return new File(dir + "\\" + setDefaultsPart + potential + ".ogg").exists();
return new File(dir + "/" + setDefaultsPart + potential + ".ogg").exists();
} else return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ public static void paste() {

for (EditorObject object : selectedList) {

ObjectAdder.adjustObjectLocation(object);

if (object instanceof BallInstance) {
ObjectAdder.fixGooBall(object);
for (EditorObject EditorObject : ((WOG1Level)level).getLevel()) {
Expand All @@ -73,7 +71,9 @@ public static void paste() {
ObjectAdder.fixGooBall(object);
for (EditorObject EditorObject : ((WOG2Level)level).getObjects()) {
if (EditorObject instanceof _2_Level_Strand strand) {
strand.update();
if (strand.getAttribute("ball1UID").stringValue().equals(object.getAttribute("uid").stringValue())
|| strand.getAttribute("ball2UID").stringValue().equals(object.getAttribute("uid").stringValue()))
strand.update();
}
}
}
Expand All @@ -83,9 +83,14 @@ public static void paste() {
wog2Level.getObjects().add(object);
object.update();
object.onLoaded();
ObjectManager.create(level, object, wog2Level.getLevel().getChildren().size());
} else {
ObjectManager.create(level, object, 0);
}
ObjectManager.create(level, object, 0);
objectCreationActions.add(new ObjectCreationAction(object, object.getParent().getChildren().indexOf(object)));

ObjectAdder.adjustObjectLocation(object);

}

UndoManager.registerChange(objectCreationActions.toArray(new UserAction[0]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import com.worldOfGoo.text.TextString;
import com.worldOfGoo.text.TextStrings;
import com.worldOfGoo2.level._2_Level_BallInstance;
import com.worldOfGoo2.level._2_Level_Item;
import com.worldOfGoo2.level._2_Level_TerrainBall;
import com.worldOfGoo2.level._2_Level_TerrainGroup;
import com.worldOfGoo2.util.BallInstanceHelper;
import javafx.geometry.Point2D;

Expand Down Expand Up @@ -167,8 +169,38 @@ public static EditorObject addObject2(String name, String typeID, EditorObject p

level.getObjects().add(obj);

if (obj instanceof _2_Level_TerrainGroup) {
EditorObject point = ObjectCreator.create2("_2_Point", obj, GameVersion.VERSION_WOG2);
point.setAttribute("x", 0);
point.setAttribute("y", 0);
point.setTypeID("textureOffset");
} else if (obj instanceof _2_Level_Item) {
EditorObject pos = ObjectCreator.create2("_2_Point", obj, GameVersion.VERSION_WOG2);
pos.setAttribute("x", 0);
pos.setAttribute("y", 0);
pos.setTypeID("pos");
EditorObject scale = ObjectCreator.create2("_2_Point", obj, GameVersion.VERSION_WOG2);
scale.setAttribute("x", 1);
scale.setAttribute("y", 1);
scale.setTypeID("scale");
}

addAnything(obj);

int i = switch (level.getCurrentlySelectedSection()) {
case "Terrain" -> 0;
case "Balls" -> 1;
case "Items" -> 2;
case "Pins" -> 3;
case "Camera" -> 4;
default -> -1;
};
FXHierarchy.getNewHierarchySwitcherButtons().getSelectionModel().select((i + 1) % 5);
FXHierarchy.getNewHierarchySwitcherButtons().getSelectionModel().select(i);

FXHierarchy.getHierarchy().getSelectionModel().clearSelection();
FXHierarchy.getHierarchy().getSelectionModel().select(obj.getTreeItem());

return obj;

}
Expand All @@ -183,9 +215,6 @@ public static void addAnything(EditorObject obj) {
LevelManager.getLevel().setSelected(selected);
FXPropertiesView.changeTableView(selected);

if (obj instanceof _2_Level_BallInstance ballInstance)
BallInstanceHelper.addTerrainBall((WOG2Level)LevelManager.getLevel(), ballInstance);

UndoManager.registerChange(new ObjectCreationAction(obj, obj.getParent().getChildren().indexOf(obj)));
}

Expand Down Expand Up @@ -246,6 +275,7 @@ public static void fixGooBall(EditorObject obj) {
// Find the smallest available number to use as an ID and set the ball's ID
// attribute accordingly.
int count = 0;
if (!taken.contains(obj.getAttribute("uid").stringValue())) return;
while (taken.contains(String.valueOf(count))) {
count++;
}
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/com/woogleFX/engine/Initializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,17 @@ public static void startWithWorldOfGooVersion() {
}
}

// KTXFileManager.readKTXImage(Path.of(FileManager.getGameDir(GameVersion.VERSION_WOG2) + "\\res\\balls\\_atlas.image"));
// KTXFileManager.readKTXImage(Path.of(FileManager.getGameDir(GameVersion.VERSION_WOG2) + "/res/balls/_atlas.image"));

// AnimBinReader.attemptToRead(Path.of(FileManager.getGameDir(GameVersion.VERSION_WOG2) + "\\res\\anim\\TransitionBlackScreen\\TransitionBlackScreen.anim.bin"));
// AnimBinReader.attemptToRead(Path.of(FileManager.getGameDir(GameVersion.VERSION_WOG2) + "\\res\\anim\\DishConnectedLadyHair\\LadyHair.anim.bin"));
// AnimBinReader.attemptToRead(Path.of(FileManager.getGameDir(GameVersion.VERSION_WOG2) + "/res/anim/LevelArrow/LevelArrow.anim.bin"), null);
// AnimBinReader.attemptToRead(Path.of(FileManager.getGameDir(GameVersion.VERSION_WOG2) + "/res/anim/TransitionBlackScreen/TransitionBlackScreen.anim.bin"), null);
// AnimBinReader.attemptToRead(Path.of(FileManager.getGameDir(GameVersion.VERSION_WOG2) + "/res/anim/DishConnectedLadyHair/LadyHair.anim.bin"), null);

// AnimBinReader.attemptToRead(Path.of(FileManager.getGameDir(GameVersion.VERSION_WOG2) + "/res/anim/IslandMap1_islands/IslandMap1_islands.anim.bin"), null);

// AnimBinReader.attemptToRead(Path.of(FileManager.getGameDir(GameVersion.VERSION_WOG2) + "/res/anim/Cutscene5Scene1/Cutscene5Scene1.anim.bin"), null);

// System.exit(0);

}

Expand Down
15 changes: 7 additions & 8 deletions src/main/java/com/woogleFX/engine/fx/FXEditorButtons.java
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,10 @@ public static Button createTemplateFor2Ball(int size, _2Ball ball) {
String name = ball.getObjects().get(0).getAttribute("name").stringValue();

EditorObject ballInstance = ObjectCreator.create2("_2_Level_Ball", ((WOG2Level)LevelManager.getLevel()).getLevel(), ball.getVersion());
ballInstance.setAttribute("type", name);
ballInstance.setTypeID("balls");
EditorObject point = ObjectCreator.create2("_2_Point", ballInstance, ball.getVersion());
point.setTypeID("pos");
ballInstance.getChildren().add(point);
ballInstance.setAttribute("type", name);
ballInstance.setTypeID("balls");

((WOG2Level)LevelManager.getLevel()).getObjects().add(ballInstance);

Expand Down Expand Up @@ -422,7 +421,7 @@ public static void addBallsTo() {

private static void level(ToolBar toolBar) {

String prefix = "ButtonIcons\\Level\\";
String prefix = "ButtonIcons/Level/";

setIcon(buttonNewOld, prefix + "new_lvl_old.png");
buttonNewOld.setOnAction(e -> LevelLoader.newLevel(GameVersion.VERSION_WOG1_OLD));
Expand Down Expand Up @@ -505,7 +504,7 @@ private static void level(ToolBar toolBar) {

private static void edit(ToolBar toolBar) {

String prefix = "ButtonIcons\\Edit\\";
String prefix = "ButtonIcons/Edit/";

setIcon(buttonUndo, prefix + "undo.png");
buttonUndo.setOnAction(e -> UndoManager.undo());
Expand Down Expand Up @@ -571,7 +570,7 @@ private static void edit(ToolBar toolBar) {

private static void resources(ToolBar toolBar) {

String prefix = "ButtonIcons\\Resources\\";
String prefix = "ButtonIcons/Resources/";

setIcon(buttonUpdateLevelResources, prefix + "update_level_resources.png");
buttonUpdateLevelResources.setOnAction(e -> LevelResourceManager.updateLevelResources(LevelManager.getLevel()));
Expand Down Expand Up @@ -650,7 +649,7 @@ public static void sceneBGGraphic(Image image) {

private static void showHide(ToolBar toolBar) {

String prefix = "ButtonIcons\\ShowHide\\";
String prefix = "ButtonIcons/ShowHide/";

setIcon(buttonShowHideCamera, prefix + "showhide_cam.png");
buttonShowHideCamera.setOnAction(e -> VisibilityManager.showHideCameras());
Expand Down Expand Up @@ -742,7 +741,7 @@ public static void updateTerrainGroupSelector(WOG2Level level) {

private static void addObjects(ToolBar toolBar) {

String prefix = "ButtonIcons\\AddObject\\";
String prefix = "ButtonIcons/AddObject/";

setIcon(addLineButton, prefix + "line.png");
addLineButton.setOnAction(e -> ObjectAdder.addObject("line"));
Expand Down
Loading

0 comments on commit 1a71358

Please sign in to comment.