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. 23
      osuMapCombiner/src/osuMapCombiner/osuMapCombiner.java

Binary file not shown.

@ -19,7 +19,13 @@ public class AddMap {
public void openDialog() {
int val = chooser.showOpenDialog(null);
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("Title:"+marathonName);
marathonMap.add("TitleUnicode:"+marathonName);
marathonMap.add("Artist:"+marathonName);
marathonMap.add("Creator:"+marathonName);
marathonMap.add("Artist:["+maps.size()+" songs]");
marathonMap.add("Creator:osu!Marathon");
marathonMap.add("Version:Marathon");
marathonMap.add("Source:"+marathonName);
marathonMap.add("Tags:"+marathonName);
@ -156,8 +156,38 @@ BeatmapSetID:-1
*/
marathonMap.add("[Events]");
marathonMap.add("//Background and Video events\r\n" +
"//Break Periods\r\n" +
"//Storyboard Layer 0 (Background)\r\n" +
"//Break Periods\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 2 (Pass)\r\n" +
"//Storyboard Layer 3 (Foreground)\r\n" +
@ -174,6 +204,8 @@ BeatmapSetID:-1
timePoint=0;
remainder=0;
Integer breakStartPoint = -1;
Integer breakEndPoint = -1;
for (int i=0;i<maps.size();i++) {
ListItem map = maps.get(i);
remainder = timePoint-Math.floor(timePoint);
@ -186,6 +218,22 @@ BeatmapSetID:-1
String hitobject = map.hitObjects.get(j);
String[] split = hitobject.split(",");
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) {
//Might be a spinner.
if (!split[5].contains("|") && !split[5].contains(":")) {
@ -309,6 +357,8 @@ BeatmapSetID:-1
} catch (IOException e) {
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) {

@ -6,6 +6,8 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.PumpStreamHandler;
@ -25,10 +27,13 @@ public class ListItem{
String[] data;
List<String> timingPoints;
List<String> hitObjects;
List<String> breaks;
boolean failed=false;
public ListItem(File f) {
//this.songTitle=s;
timingPoints = new ArrayList<String>();
hitObjects = new ArrayList<String>();
breaks = new ArrayList<String>();
songTitle = f.getName();
System.out.println("Song Title: "+songTitle);
data = utils.readFromFile(f.getAbsolutePath());
@ -74,9 +79,22 @@ public class ListItem{
}
}
osuMapCombiner.duration += songDuration;
//osuMapCombiner.duration += songDuration = mp3utils.GetSongDuration(songLoc.getAbsolutePath());
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]";
do {
line = data[i++];
@ -105,6 +123,20 @@ public class ListItem{
}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]";
do {
line = data[i++];

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

Loading…
Cancel
Save