diff --git a/osuMapCombiner/osuMapCombiner.jar b/osuMapCombiner/osuMapCombiner.jar index 7cb44d6..a047abd 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 dd3552b..a679dba 100644 --- a/osuMapCombiner/src/osuMapCombiner/AddMap.java +++ b/osuMapCombiner/src/osuMapCombiner/AddMap.java @@ -4,8 +4,30 @@ import java.io.File; import java.io.FileFilter; import javax.swing.JFileChooser; +import javax.swing.SwingWorker; import javax.swing.filechooser.FileNameExtensionFilter; +class Task extends SwingWorker{ + File f; + Task(File f) { + this.f=f; + } + /* + * Main task. Executed in background thread. + */ + @Override + public Void doInBackground() { + ListItem temp = new ListItem(f); + if (!temp.failed) { + osuMapCombiner.model.addElement(temp); + if (osuMapCombiner.model.getSize()>=2) { + osuMapCombiner.main.button2.setEnabled(true); + } + } + return null; + } +} + public class AddMap { JFileChooser chooser = new JFileChooser(); @@ -19,14 +41,13 @@ public class AddMap { public void openDialog() { int val = chooser.showOpenDialog(null); if (val==JFileChooser.APPROVE_OPTION) { - ListItem temp = new ListItem(chooser.getSelectedFile()); - if (!temp.failed) { - osuMapCombiner.model.addElement(temp); - if (osuMapCombiner.model.getSize()>=2) { - osuMapCombiner.main.button2.setEnabled(true); - } - } + AddMap(chooser.getSelectedFile()); } } + + public static void AddMap(File f) { + Task task = new Task(f); + task.execute(); + } } \ No newline at end of file diff --git a/osuMapCombiner/src/osuMapCombiner/Convert.java b/osuMapCombiner/src/osuMapCombiner/Convert.java index ee74d58..74fc4bf 100644 --- a/osuMapCombiner/src/osuMapCombiner/Convert.java +++ b/osuMapCombiner/src/osuMapCombiner/Convert.java @@ -155,8 +155,10 @@ BeatmapSetID:-1 * */ marathonMap.add("[Events]"); - marathonMap.add("//Background and Video events\r\n" + - "//Break Periods\r\n"); + marathonMap.add("//Background and Video events\r\n"); + ListItem firstmap = maps.get(0); + marathonMap.add("0,0,\""+firstmap.songTitle+"_BG.png\""); + marathonMap.add("//Break Periods\r\n"); timePoint=0; remainder=0; @@ -187,8 +189,24 @@ BeatmapSetID:-1 } 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" + + marathonMap.add("//Storyboard Layer 0 (Background)\r\n"); + timePoint=firstmap.songDuration; + remainder=0; + for (int i=1;i=1) { + timePoint++; + remainder--; + } + + marathonMap.add("Sprite,Background,Centre,\""+map.songTitle+"_BG.png\",320,240"); + marathonMap.add(" F,0,"+(int)(timePoint-5000)+","+(int)(timePoint)+",0,1"); + marathonMap.add(" F,0,"+(int)(timePoint)+","+(int)(timePoint+map.songDuration-5000)+",1"); + marathonMap.add(" F,0,"+(int)(timePoint+map.songDuration-5000)+","+(int)(timePoint+map.songDuration)+",1,0"); + + timePoint += map.songDuration; + } + marathonMap.add("//Storyboard Layer 1 (Fail)\r\n" + "//Storyboard Layer 2 (Pass)\r\n" + "//Storyboard Layer 3 (Foreground)\r\n" + "//Storyboard Layer 4 (Overlay)\r\n" + @@ -276,6 +294,9 @@ BeatmapSetID:-1 File filer = new File(maps.get(i).songLoc.getName()); utils.copyFile(maps.get(i).songLoc, filer); filer.deleteOnExit(); + filer = new File(maps.get(i).songTitle+"_BG.png"); + utils.copyFile(filer, new File(targetDir,maps.get(i).songTitle+"_BG.png")); + filer.deleteOnExit(); } catch (IOException e) { e.printStackTrace(); } diff --git a/osuMapCombiner/src/osuMapCombiner/ListItem.java b/osuMapCombiner/src/osuMapCombiner/ListItem.java index 39cc765..9d01834 100644 --- a/osuMapCombiner/src/osuMapCombiner/ListItem.java +++ b/osuMapCombiner/src/osuMapCombiner/ListItem.java @@ -16,6 +16,7 @@ public class ListItem{ String songTitle; File file; File songLoc; + File bgloc; double songDuration=0; double hpDrainRate=7; double circleSize=7; @@ -30,7 +31,12 @@ public class ListItem{ List breaks; boolean failed=false; public ListItem(File f) { + + final int taskAmt = 5; + osuMapCombiner.updateProgressBarAmt(0,5); + //this.songTitle=s; + this.file=f; timingPoints = new ArrayList(); hitObjects = new ArrayList(); breaks = new ArrayList(); @@ -41,7 +47,8 @@ public class ListItem{ int i =0 ; String targetString = "AudioFilename: "; - + /////// + osuMapCombiner.updateProgressBarAmt(1,5); do { line = data[i++]; } while (!line.contains(targetString)); @@ -49,9 +56,28 @@ public class ListItem{ System.out.println("SongLoc: "+songLoc); File filer = new File(songTitle.replace(".osu", ".mp3")); + if (!new File(songTitle.replace(".osu", ".mp3")).exists()) { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream); + String command = "ffmpeg -i \""+songLoc.getAbsolutePath()+"\" -f mp3 -b:a 128k -ar 44100 -ac 2 \""+songTitle.replace(".osu", ".mp3")+"\""; + CommandLine cmdLine = CommandLine.parse(command); + DefaultExecutor exec = new DefaultExecutor(); + exec.setStreamHandler(streamHandler); + try { + exec.execute(cmdLine); + //System.out.println(filer.getName()+": "+mp3utils.GetSongDuration(filer.getAbsolutePath())); + } catch (IOException e) { + e.printStackTrace(); + } + filer.deleteOnExit(); + + ParseTimestamp(outputStream); + } + ////// + osuMapCombiner.updateProgressBarAmt(2,5); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream); - String command = "ffmpeg -i \""+songLoc.getAbsolutePath()+"\" -f mp3 -b:a 128k -ar 44100 -ac 2 \""+songTitle.replace(".osu", ".mp3")+"\""; + String command = "ffmpeg -i \""+songTitle.replace(".osu", ".mp3")+"\""; CommandLine cmdLine = CommandLine.parse(command); DefaultExecutor exec = new DefaultExecutor(); exec.setStreamHandler(streamHandler); @@ -61,24 +87,19 @@ public class ListItem{ } catch (IOException e) { e.printStackTrace(); } - filer.deleteOnExit(); - - String[] data2 = outputStream.toString().split("\n"); - for (int h=0;h3) { if (line.trim().startsWith("2,") && line.split(",").length==3) { breaks.add(line); + } else + if (line.trim().startsWith("0,0,")/* && line.split(",").length==5*/) { + bgloc = new File(f.getParent()+File.separatorChar+line.split(",")[2].replace("\"", "")); + try { + utils.copyFile(bgloc, new File(songTitle+"_BG.png")); + } catch (IOException e) { + e.printStackTrace(); + } + //System.out.println("Background location found: "+bgloc); + /*File temp = new File(songTitle.split(".")[0]); + System.out.println(temp.getAbsolutePath()); + if (!(temp.exists())) { + System.out.println("Does not exist"); + }*/ } } } while (line.trim().length()>3); @@ -165,6 +200,26 @@ public class ListItem{ } } } while (i3); + //////// + osuMapCombiner.updateProgressBarAmt(5,5); + } + private void ParseTimestamp(ByteArrayOutputStream outputStream) { + String[] data2 = outputStream.toString().split("\n"); + songDuration=0; + for (int h=0;h=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 "+ @@ -142,4 +180,16 @@ public class osuMapCombiner extends JPanel implements ActionListener{ }break; } } + + @Override + public void valueChanged(ListSelectionEvent e) { + button3.setEnabled(l.getSelectedIndex()!=-1); + button4.setEnabled(l.getSelectedIndex()!=-1); + } + + public static void updateProgressBarAmt(int i, int j) { + progressBar.setMaximum(j); + progressBar.setMinimum(0); + progressBar.setValue(i); + } }