Skip to content

Commit

Permalink
Major Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrisvenator committed Aug 7, 2023
1 parent 8d07ab4 commit 73d9a9e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 94 deletions.
52 changes: 0 additions & 52 deletions OnsetGeneration/SlicesToOnset.ps1

This file was deleted.

39 changes: 23 additions & 16 deletions src/CreatePatterns.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,25 @@ public static BeatSaberMap createMap(BeatSaberMap map, Pattern p, boolean oneHan
List<Note> notes = new ArrayList<>();
List<Note> timings = Arrays.asList(map._notes);
List<Bookmark> bookmarks = map.bookmarks == null ? map.calculateBookmarks() : map.bookmarks;
bookmarks.add(new Bookmark(timings.get(timings.size() - 1)._time + 10, "end", new float[]{(float) 0.0, (float) 0.0, (float) 0.0}));
String[] supportedTypes = new String[]{"complex", "linear", "1-2", "2-1", "2-2", "small_jumps", "normal_jumps", "big_jumps", "doubles", "pattern"};

//If the map is one-handed or there are no bookmarks, then there is not that much to do
if (oneHanded)
return new BeatSaberMap(complexPatternFromTemplate(map._notes, p, true, stacks, null, null), map.originalJSON);
if (bookmarks.size() <= 1)
return new BeatSaberMap(complexPatternFromTemplate(map._notes, p, true, stacks, null, null), map.originalJSON);
if (bookmarks.size() <= 1) {
Random random = new Random();
int min = 10;
int max = 40;

int randomNumber = random.nextInt(max - min + 1) + min;
for (int i = 0; i < randomNumber; i++) {
bookmarks.add(new Bookmark(timings.get(i * (int) (timings.size() / randomNumber))._time, supportedTypes[random.nextInt(supportedTypes.length - 1)], null));
if (bookmarks.get(bookmarks.size() - 1)._name.contains("jumps")) i--;
}
// return new BeatSaberMap(complexPatternFromTemplate(map._notes, p, oneHanded, stacks, null, null), map.originalJSON);
}
bookmarks.add(new Bookmark(timings.get(timings.size() - 1)._time + 10, "end", new float[]{(float) 0.0, (float) 0.0, (float) 0.0}));


Note prevBlue = null;
Note prevRed = null;
Expand All @@ -94,8 +106,7 @@ public static BeatSaberMap createMap(BeatSaberMap map, Pattern p, boolean oneHan
Note[] linearNotes = linearSlowPattern(currentNotes.toArray(new Note[0]), false, prevBlue, prevRed);
notes.addAll(Arrays.stream(linearNotes).toList());
}
case "1-2" ->
notes.addAll(twoRightOneLeft(currentNotes.toArray(new Note[0]), p, prevBlue, prevRed, stacks));
case "1-2" -> notes.addAll(twoRightOneLeft(currentNotes.toArray(new Note[0]), p, prevBlue, prevRed, stacks));

case "2-1" -> {
//prevRed and prevBlue must be inverted right here because in the next line we invert all the notes again.
Expand All @@ -105,19 +116,15 @@ public static BeatSaberMap createMap(BeatSaberMap map, Pattern p, boolean oneHan
}

case "2-2" -> notes.addAll(twoLeftTwoRight(currentNotes.toArray(new Note[0]), prevBlue, prevRed));
case "small-jumps", "smalljumps", "small jumps" ->
notes.addAll(createSmallJumps(currentNotes, false, prevBlue, prevRed));
case "jumps", "normal jumps", "normal_jumps", "normal-jumps" ->
notes.addAll(createJumps(currentNotes, false, prevBlue, prevRed));
case "big-jumps", "bigjumps", "big jumps" ->
notes.addAll(createBigJumps(currentNotes, false, prevBlue, prevRed));
case "doubles", "double-handed" ->
notes.addAll(createDoubles(currentNotes.toArray(new Note[0]), prevBlue, prevRed));
case "sequence", "seq", "s", "pattern", "pat", "rand-seq", "random-sequence" ->
notes.addAll(createPatternSequence(currentNotes.toArray(new Note[0]), prevBlue, prevRed, "jumps.txt"));
case "small-jumps", "smalljumps", "small_jumps", "small jumps" -> notes.addAll(createSmallJumps(currentNotes, false, prevBlue, prevRed));
case "jumps", "normal jumps", "normal_jumps", "normal-jumps" -> notes.addAll(createJumps(currentNotes, false, prevBlue, prevRed));
case "big-jumps", "bigjumps", "big_jumps", "big jumps" -> notes.addAll(createBigJumps(currentNotes, false, prevBlue, prevRed));
case "doubles", "double-handed" -> notes.addAll(createDoubles(currentNotes.toArray(new Note[0]), prevBlue, prevRed));
case "sequence", "seq", "s", "pattern", "pat", "rand-seq", "random-sequence" -> notes.addAll(createPatternSequence(currentNotes.toArray(new Note[0]), prevBlue, prevRed, "jumps.txt"));

default -> {
System.err.println("There is no such flag as: \"" + bookmarks.get(i)._name + "\" with " + currentNotes.size() + " notes.");
System.err.println("There is no such flag as: \"" + bookmarks.get(i)._name + "\" with " + currentNotes.size() + " notes. Please have a look at the supported ones in the README");
System.err.println("Supported types: " + Arrays.toString(supportedTypes));
Note[] complexNotes = complexPatternFromTemplate(currentNotes.toArray(new Note[0]), p, false, stacks, prevBlue, prevRed);
notes.addAll(Arrays.stream(complexNotes).toList());
}
Expand Down
31 changes: 5 additions & 26 deletions src/UserInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class UserInterface extends JFrame {
private String filePath;
private BeatSaberMap map;
private Pattern pattern;
private float bpm = 120;

//config.txt:
private boolean verbose = true; //For debugging purposes. It prints EVERYTHING
Expand Down Expand Up @@ -71,28 +70,6 @@ public UserInterface() {
add(openSongButton);


//BPM Buttons are currently disabled!
JTextField bpmTextField = new JFormattedTextField("BPM");
bpmTextField.setBounds(50, 70, 100, 30);
bpmTextField.setVisible(false);
add(bpmTextField);


// Button erstellen und positionieren
//BPM Buttons are currently disabled!
JButton submitBPM = new JButton("save BPM");
submitBPM.setBounds(160, 70, 100, 30);
submitBPM.setVisible(false);
submitBPM.addActionListener(e -> {
try {
bpm = Float.parseFloat(bpmTextField.getText());
} catch (NumberFormatException ex) {
System.err.println("The BPM you typed in is not a number!");
}
});
add(submitBPM);


//Status Bar:
statusCheck = new TextArea("config: \nverbose: " + verbose + "\npath: " + DEFAULT_PATH + "\n");
statusCheck.setBounds(50, 235, 1090, 510);
Expand Down Expand Up @@ -475,9 +452,6 @@ public UserInterface() {
new Thread(() -> {
while (true) {
if (mapSuccessfullyLoaded) {
// bpmTextField.setVisible(true);
// submitBPM.setVisible(true);

labelMapDiff.setText("Successfully loaded difficulty");
labelMapDiff.setBackground(Color.GREEN);

Expand All @@ -503,10 +477,15 @@ public UserInterface() {

private void convertMp3ToMap() {
try {
statusCheck.setBackground(Color.GRAY);
openSongButton.setText("In Progress...");
statusCheck.setText(statusCheck.getText() + "\nINFO: Converting all Songs from OnsetGeneration/mp3Files/ to timing maps.\nThis might take a while if there are a lot of songs.\n");
statusCheck.setText(statusCheck.getText() + "You can always check the progress when heading to \"OnsetGeneration/output/\"\n");
Thread.sleep(1000);
BatchWavToMaps.generateOnsets("./OnsetGeneration/mp3Files/", "./OnsetGeneration/output/", true);
statusCheck.setText(statusCheck.getText() + "\nSuccessfully created Map. You can find your map in \"OnsetGeneration/output/\"\n\n");
statusCheck.setBackground(Color.WHITE);
openSongButton.setText("Convert MP3s to timing maps");
} catch (Exception e) {
System.err.println("ERROR: Something went wrong during conversion. Is it the right file extension?\n" + e);
statusCheck.setText("ERROR: Something went wrong during conversion. Is it the right file extension?\n" + e + "\n\n");
Expand Down

0 comments on commit 73d9a9e

Please sign in to comment.