diff --git a/osuMapCombiner/osuMapCombiner.jar b/osuMapCombiner/osuMapCombiner.jar index 9cabe3b..7cb44d6 100644 Binary files a/osuMapCombiner/osuMapCombiner.jar and b/osuMapCombiner/osuMapCombiner.jar differ diff --git a/osuMapCombiner/src/osuMapCombiner/AddMap.java b/osuMapCombiner/src/osuMapCombiner/AddMap.java index 7be060f..dd3552b 100644 --- a/osuMapCombiner/src/osuMapCombiner/AddMap.java +++ b/osuMapCombiner/src/osuMapCombiner/AddMap.java @@ -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); + } + } } } diff --git a/osuMapCombiner/src/osuMapCombiner/Convert.java b/osuMapCombiner/src/osuMapCombiner/Convert.java index dd78fc6..ee74d58 100644 --- a/osuMapCombiner/src/osuMapCombiner/Convert.java +++ b/osuMapCombiner/src/osuMapCombiner/Convert.java @@ -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=1) { + timePoint++; + remainder--; + } + List breaks = maps.get(i).breaks; + if (timePoint==0) { + marathonMap.addAll(breaks); + } else { + for (int j=0;j=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 maps) { diff --git a/osuMapCombiner/src/osuMapCombiner/ListItem.java b/osuMapCombiner/src/osuMapCombiner/ListItem.java index cdfe62d..39cc765 100644 --- a/osuMapCombiner/src/osuMapCombiner/ListItem.java +++ b/osuMapCombiner/src/osuMapCombiner/ListItem.java @@ -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 timingPoints; List hitObjects; + List breaks; + boolean failed=false; public ListItem(File f) { //this.songTitle=s; timingPoints = new ArrayList(); hitObjects = new ArrayList(); + breaks = new ArrayList(); 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++]; diff --git a/osuMapCombiner/src/osuMapCombiner/osuMapCombiner.java b/osuMapCombiner/src/osuMapCombiner/osuMapCombiner.java index e00b519..874b8e8 100644 --- a/osuMapCombiner/src/osuMapCombiner/osuMapCombiner.java +++ b/osuMapCombiner/src/osuMapCombiner/osuMapCombiner.java @@ -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; } }