aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/net/sowgro/npehero/editor/DiffEditor.java
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2024-07-28 01:07:41 -0400
committersowgro <tpoke.ferrari@gmail.com>2024-07-28 01:07:41 -0400
commit0ce09f72f4af26412356b9699d402b52dbcfc94f (patch)
treeb01b94b1b80d1f3fc5aea559b3718024b79cfe91 /src/main/java/net/sowgro/npehero/editor/DiffEditor.java
parentd04c277edff957d14b6261dd38da43c18b7ba189 (diff)
downloadNPEhero-0ce09f72f4af26412356b9699d402b52dbcfc94f.tar.gz
NPEhero-0ce09f72f4af26412356b9699d402b52dbcfc94f.tar.bz2
NPEhero-0ce09f72f4af26412356b9699d402b52dbcfc94f.zip
Finalize level API and new Json library
Diffstat (limited to 'src/main/java/net/sowgro/npehero/editor/DiffEditor.java')
-rwxr-xr-xsrc/main/java/net/sowgro/npehero/editor/DiffEditor.java26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/main/java/net/sowgro/npehero/editor/DiffEditor.java b/src/main/java/net/sowgro/npehero/editor/DiffEditor.java
index 6940485..0eb4968 100755
--- a/src/main/java/net/sowgro/npehero/editor/DiffEditor.java
+++ b/src/main/java/net/sowgro/npehero/editor/DiffEditor.java
@@ -11,8 +11,12 @@ import net.sowgro.npehero.gameplay.Block;
import net.sowgro.npehero.gui.LevelSurround;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
+import net.sowgro.npehero.levelapi.Difficulty;
+import net.sowgro.npehero.levelapi.Note;
import net.sowgro.npehero.main.*;
+import java.io.IOException;
+
public class DiffEditor extends Page
{
Difficulty diff;
@@ -37,13 +41,15 @@ public class DiffEditor extends Page
editNotes.setOnAction(_ -> {
if (diff.level.song == null) {
Driver.setMenu(new ErrorDisplay("You must import a song file before editing the notes!", this));
+ return;
}
if (diff.bpm != 0.0) {
Driver.setMenu(new ErrorDisplay(
- "Note:\nThe new notes editor does not support bpm and beat based songs. If you continue the beats will be converted to seconds.",
+ "Note:\nThe new notes editor does not support bpm and beat based songs. If you continue, the notes will be converted.",
this,
new NotesEditor2(diff, this)
));
+ return;
}
Driver.setMenu(new NotesEditor2(diff, this));
});
@@ -57,7 +63,15 @@ public class DiffEditor extends Page
Label scoresLable = new Label("Scores");
Button editScores = new Button("Clear leaderboard");
- editScores.setOnAction(_ -> diff.leaderboard.entries.clear());
+ editScores.setOnAction(_ -> {
+ diff.leaderboard.entries.clear();
+ try {
+ diff.leaderboard.save();
+ } catch (IOException e) {
+ e.printStackTrace();
+ Driver.setMenu(new ErrorDisplay("Failed to clear the leaderboard:\n"+e, this));
+ }
+ });
Button playLevel = new Button("Play level");
playLevel.setOnAction(_ -> {
@@ -74,7 +88,13 @@ public class DiffEditor extends Page
diff.title = title.getText();
// diff.bpm = Double.parseDouble(bpm.getText());
// diff.numBeats = Integer.parseInt(numBeats.getText());
- diff.write();
+ try {
+ diff.writeMetadata();
+ } catch (IOException e) {
+ e.printStackTrace();
+ //TODO
+ throw new RuntimeException(e);
+ }
});
HBox scrollContent = new HBox();