use of com.github.mob41.osumer.queue.Queue in project osumer by mob41.
the class BeatmapImportAction method run.
@Override
public void run(Queue queue) {
Downloader dwn = queue.getDownloader();
String path = dwn.getDownloadFolder() + dwn.getFileName();
File file = new File(path + ".osz");
if (!file.exists()) {
System.out.println("File not exists: " + path + ".osz");
return;
}
int action = config.getDefaultOpenBeatmapAction();
if (action == 1 || action == 2) {
String loc = null;
if (action == 1) {
loc = System.getenv("LOCALAPPDATA") + "\\osu!\\Songs";
} else {
loc = config.getDefaultBeatmapSaveLocation();
}
File songsFolder = new File(loc);
if (!songsFolder.exists()) {
songsFolder.mkdirs();
}
File toFile = new File(loc + "\\" + dwn.getFileName() + ".osz");
if (toFile.exists()) {
toFile.delete();
}
FileOutputStream toFileOut;
try {
toFileOut = new FileOutputStream(toFile);
Files.copy(file.toPath(), toFileOut);
toFileOut.close();
} catch (IOException e) {
JOptionPane.showMessageDialog(null, "osumer Song Copy failed:\n\nFrom: " + path + "\nTo: " + loc + "\n\nMake sure you have access to that folder.\n" + e, "Error", JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}
} else {
try {
Desktop.getDesktop().open(file);
} catch (IOException e) {
e.printStackTrace();
}
}
}
use of com.github.mob41.osumer.queue.Queue in project osumer by mob41.
the class AfterSoundAction method run.
@Override
public void run(Queue queue) {
Thread thread = new Thread(new Runnable() {
public void run() {
try {
Media m = new Media(new File(config.getToneAfterDownloadPath()).toURI().toString());
MediaPlayer mp = new MediaPlayer(m);
mp.play();
} catch (Exception e) {
e.printStackTrace();
DumpManager.addDump(new DebugDump(null, "---", "Play after download sound", "---", "Error occurred when trying to play sound", false, e));
}
}
});
thread.setDaemon(true);
thread.start();
}
use of com.github.mob41.osumer.queue.Queue in project osumer by mob41.
the class BeforeSoundAction method run.
@Override
public void run(Queue queue) {
Thread thread = new Thread(new Runnable() {
public void run() {
try {
Media m = new Media(new File(config.getToneBeforeDownloadPath()).toURI().toString());
MediaPlayer mp = new MediaPlayer(m);
mp.play();
} catch (Exception e) {
e.printStackTrace();
DumpManager.addDump(new DebugDump(null, "---", "Play before download sound", "---", "Error occurred when trying to play sound", false, e));
}
}
});
thread.setDaemon(true);
thread.start();
}
use of com.github.mob41.osumer.queue.Queue in project osumer by mob41.
the class UpdaterRunAction method run.
@Override
public void run(Queue queue) {
try {
System.out.println("Starting: \"" + filePath + "\"");
Runtime.getRuntime().exec("cmd.exe /c \"" + filePath + "\" -install");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.exit(0);
return;
} catch (IOException e1) {
e1.printStackTrace();
DebugDump dump = new DebugDump(null, "(If[openFile] scope) (UI) Set status to lblStatus", "(Try scope) Open file loc using Desktop.getDesktop.open()", "(Try scope) Sleep 2000 ms (2 sec)", "Unable to open file", false, e1);
DumpManager.addDump(dump);
// TODO
/*
ErrorDumpDialog dialog = new ErrorDumpDialog(dump);
dialog.setModal(true);
dialog.setVisible(true);
*/
}
}
use of com.github.mob41.osumer.queue.Queue in project osumer by mob41.
the class Daemon method getQueues.
@Override
public QueueStatus[] getQueues() throws RemoteException {
List<Queue> queues = queueManager.getList();
QueueStatus[] status = new QueueStatus[queues.size()];
Downloader dwn;
Queue q;
QueueStatus s;
for (int i = 0; i < status.length; i++) {
q = queues.get(i);
dwn = q.getDownloader();
long elapsedTime = System.nanoTime() - q.getStartTime();
long allTimeForDownloading = dwn.getDownloaded() != 0 ? (elapsedTime * dwn.getSize() / dwn.getDownloaded()) : -1;
long eta = allTimeForDownloading - elapsedTime;
s = new QueueStatus(q.getName(), dwn.getFileName(), q.getThumbUrl(), (int) dwn.getProgress(), eta, elapsedTime, dwn.getStatus());
status[i] = s;
}
return status;
}
Aggregations