Added breaks, fixed bugs, added sanity checks. As far as I'm concerned,

it is now beta testing material. More quality of life and beautification
features to come.
master
sigonasr2 5 years ago
parent fe43fa7b11
commit 6128ed9475
  1. BIN
      osuMapCombiner/osuMapCombiner.jar
  2. 8
      osuMapCombiner/src/osuMapCombiner/AddMap.java
  3. 58
      osuMapCombiner/src/osuMapCombiner/Convert.java
  4. 32
      osuMapCombiner/src/osuMapCombiner/ListItem.java
  5. 13
      osuMapCombiner/src/osuMapCombiner/osuMapCombiner.java

Binary file not shown.

@ -19,7 +19,13 @@ public class AddMap {
public void openDialog() { public void openDialog() {
int val = chooser.showOpenDialog(null); int val = chooser.showOpenDialog(null);
if (val==JFileChooser.APPROVE_OPTION) { if (val==JFileChooser.APPROVE_OPTION) {
osuMapCombiner.model.addElement(new ListItem(chooser.getSelectedFile())); ListItem temp = new ListItem(chooser.getSelectedFile());
if (!temp.failed) {
osuMapCombiner.model.addElement(temp);
if (osuMapCombiner.model.getSize()>=2) {
osuMapCombiner.main.button2.setEnabled(true);
}
}
} }
} }

@ -116,8 +116,8 @@ BeatmapSetID:-1
marathonMap.add("[Metadata]"); marathonMap.add("[Metadata]");
marathonMap.add("Title:"+marathonName); marathonMap.add("Title:"+marathonName);
marathonMap.add("TitleUnicode:"+marathonName); marathonMap.add("TitleUnicode:"+marathonName);
marathonMap.add("Artist:"+marathonName); marathonMap.add("Artist:["+maps.size()+" songs]");
marathonMap.add("Creator:"+marathonName); marathonMap.add("Creator:osu!Marathon");
marathonMap.add("Version:Marathon"); marathonMap.add("Version:Marathon");
marathonMap.add("Source:"+marathonName); marathonMap.add("Source:"+marathonName);
marathonMap.add("Tags:"+marathonName); marathonMap.add("Tags:"+marathonName);
@ -156,8 +156,38 @@ BeatmapSetID:-1
*/ */
marathonMap.add("[Events]"); marathonMap.add("[Events]");
marathonMap.add("//Background and Video events\r\n" + marathonMap.add("//Background and Video events\r\n" +
"//Break Periods\r\n" + "//Break Periods\r\n");
"//Storyboard Layer 0 (Background)\r\n" +
timePoint=0;
remainder=0;
for (int i=0;i<maps.size();i++) {
ListItem map = maps.get(i);
remainder = timePoint-Math.floor(timePoint);
while (remainder>=1) {
timePoint++;
remainder--;
}
List<String> breaks = maps.get(i).breaks;
if (timePoint==0) {
marathonMap.addAll(breaks);
} else {
for (int j=0;j<breaks.size();j++) {
String[] b = breaks.get(j).split(",");
b[1] = Integer.toString(Integer.parseInt(b[1])+(int)timePoint);
b[2] = Integer.toString(Integer.parseInt(b[2])+(int)timePoint);
StringBuilder breakString = new StringBuilder(b[0]);
for (int k=1;k<b.length;k++) {
breakString.append(",");
breakString.append(b[k]);
}
marathonMap.add(breakString.toString());
}
}
timePoint += map.songDuration;
}
int breaksEndIndex = marathonMap.size()-1; // Store the last break so we can append to it a little later.
marathonMap.add("//Storyboard Layer 0 (Background)\r\n" +
"//Storyboard Layer 1 (Fail)\r\n" + "//Storyboard Layer 1 (Fail)\r\n" +
"//Storyboard Layer 2 (Pass)\r\n" + "//Storyboard Layer 2 (Pass)\r\n" +
"//Storyboard Layer 3 (Foreground)\r\n" + "//Storyboard Layer 3 (Foreground)\r\n" +
@ -174,6 +204,8 @@ BeatmapSetID:-1
timePoint=0; timePoint=0;
remainder=0; remainder=0;
Integer breakStartPoint = -1;
Integer breakEndPoint = -1;
for (int i=0;i<maps.size();i++) { for (int i=0;i<maps.size();i++) {
ListItem map = maps.get(i); ListItem map = maps.get(i);
remainder = timePoint-Math.floor(timePoint); remainder = timePoint-Math.floor(timePoint);
@ -186,6 +218,22 @@ BeatmapSetID:-1
String hitobject = map.hitObjects.get(j); String hitobject = map.hitObjects.get(j);
String[] split = hitobject.split(","); String[] split = hitobject.split(",");
split[2] = Integer.toString(Integer.parseInt(split[2])+(int)timePoint); split[2] = Integer.toString(Integer.parseInt(split[2])+(int)timePoint);
if (j==0 && breakStartPoint!=-1) {
//Setup a break.
breakEndPoint = Integer.parseInt(split[2])-1000;
marathonMap.add(breaksEndIndex,"2,"+breakStartPoint+","+breakEndPoint); // Store the last break so we can append to it a little later.
breakStartPoint = -1;
} else {
breakStartPoint = Integer.parseInt(split[2])+1000;
}
if (j==0) {
//Reset the combo color if this is the first note of the next song. (Third bit indicates new combo)
int numb = Integer.parseInt(split[3]);
if (numb==1 || numb==2 || numb==8) {
numb+=4;
}
split[3] = Integer.toString(numb);
}
if (split.length>=6) { if (split.length>=6) {
//Might be a spinner. //Might be a spinner.
if (!split[5].contains("|") && !split[5].contains(":")) { if (!split[5].contains("|") && !split[5].contains(":")) {
@ -309,6 +357,8 @@ BeatmapSetID:-1
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
JOptionPane.showMessageDialog(osuMapCombiner.main.f, "Marathon map successfully created! Search for "+marathonName+" in osu! to play it!");
} }
public static double AverageValues(DifficultyValues val,List<ListItem> maps) { public static double AverageValues(DifficultyValues val,List<ListItem> maps) {

@ -6,6 +6,8 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.swing.JOptionPane;
import org.apache.commons.exec.CommandLine; import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor; import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.PumpStreamHandler; import org.apache.commons.exec.PumpStreamHandler;
@ -25,10 +27,13 @@ public class ListItem{
String[] data; String[] data;
List<String> timingPoints; List<String> timingPoints;
List<String> hitObjects; List<String> hitObjects;
List<String> breaks;
boolean failed=false;
public ListItem(File f) { public ListItem(File f) {
//this.songTitle=s; //this.songTitle=s;
timingPoints = new ArrayList<String>(); timingPoints = new ArrayList<String>();
hitObjects = new ArrayList<String>(); hitObjects = new ArrayList<String>();
breaks = new ArrayList<String>();
songTitle = f.getName(); songTitle = f.getName();
System.out.println("Song Title: "+songTitle); System.out.println("Song Title: "+songTitle);
data = utils.readFromFile(f.getAbsolutePath()); data = utils.readFromFile(f.getAbsolutePath());
@ -74,9 +79,22 @@ public class ListItem{
} }
} }
osuMapCombiner.duration += songDuration;
//osuMapCombiner.duration += songDuration = mp3utils.GetSongDuration(songLoc.getAbsolutePath()); //osuMapCombiner.duration += songDuration = mp3utils.GetSongDuration(songLoc.getAbsolutePath());
System.out.println("Song duration of "+songTitle+" : "+songDuration+"ms"); System.out.println("Song duration of "+songTitle+" : "+songDuration+"ms");
targetString = "Mode: ";
do {
line = data[i++];
} while (!line.contains(targetString));
int mode = Integer.parseInt(line.replace(targetString, "").trim());
if (mode!=0) {
JOptionPane.showMessageDialog(osuMapCombiner.main.f, "This is not an osu! mode map! Parsing has been canceled.");
failed=true;
return;
}
targetString="[Difficulty]"; targetString="[Difficulty]";
do { do {
line = data[i++]; line = data[i++];
@ -105,6 +123,20 @@ public class ListItem{
}break; }break;
} }
} }
targetString="[Events]";
do {
line = data[i++];
} while (!line.contains(targetString));
do {
line=data[i++];
if (line.trim().length()>3) {
if (line.trim().startsWith("2,") && line.split(",").length==3) {
breaks.add(line);
}
}
} while (line.trim().length()>3);
targetString="[TimingPoints]"; targetString="[TimingPoints]";
do { do {
line = data[i++]; line = data[i++];

@ -41,6 +41,8 @@ public class osuMapCombiner extends JPanel implements ActionListener{
public static JFrame f = new JFrame(); public static JFrame f = new JFrame();
public static osuMapCombiner main; public static osuMapCombiner main;
public JButton button = new JButton("+");
public JButton button2 = new JButton("Combine");
osuMapCombiner() { osuMapCombiner() {
osuMapCombiner.main = this; osuMapCombiner.main = this;
@ -56,16 +58,16 @@ public class osuMapCombiner extends JPanel implements ActionListener{
Component c = Box.createRigidArea(new Dimension(240,32)); Component c = Box.createRigidArea(new Dimension(240,32));
JButton button = new JButton("+");
button.setActionCommand("Add"); button.setActionCommand("Add");
button.setPreferredSize(new Dimension(42,42)); button.setPreferredSize(new Dimension(42,42));
button.addActionListener(this); button.addActionListener(this);
JButton button2 = new JButton("Combine");
button2.setActionCommand("Combine"); button2.setActionCommand("Combine");
button2.setPreferredSize(new Dimension(360,24)); button2.setPreferredSize(new Dimension(360,24));
button2.addActionListener(this); button2.addActionListener(this);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setResizable(false);
button2.setEnabled(false);
FlowLayout layout = new FlowLayout(); FlowLayout layout = new FlowLayout();
f.setLayout(layout); f.setLayout(layout);
@ -126,12 +128,17 @@ public class osuMapCombiner extends JPanel implements ActionListener{
mapdialog.openDialog(); mapdialog.openDialog();
}break; }break;
case "Combine":{ case "Combine":{
if (model.getSize()>=2) {
int pane = JOptionPane.showConfirmDialog(f,"A marathon map with all "+model.getSize()+" maps will be created. The total duration of the marathon map will be "+ int pane = JOptionPane.showConfirmDialog(f,"A marathon map with all "+model.getSize()+" maps will be created. The total duration of the marathon map will be "+
Math.floor(duration/1000)+"s long. Proceed?" (int)Math.floor(duration/1000)+"s long. Proceed?"
); );
if (pane == JOptionPane.YES_OPTION) { if (pane == JOptionPane.YES_OPTION) {
Convert.Convert(); Convert.Convert();
} }
} else {
button2.setEnabled(false);
JOptionPane.showMessageDialog(f, "You must have selected at least 2 songs to create a marathon map!");
}
}break; }break;
} }
} }

Loading…
Cancel
Save