Prevent downloading songs that are already loaded. (base: fluddokt/opsu/76778f8)
- All beatmap set IDs are now stored in a set in OsuGroupList. - OsuParser now checks the directory name for beatmap set IDs if the OsuFile doesn't contain one (for older beatmap formats). Tweaks: - Clear completed downloads when hitting "Import All". - Call Download.updateReadSoFar() upon starting downloads instead of waiting for user to hover over the button (causing an unnecessary delay). Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -165,6 +165,7 @@ public class Download {
|
||||
rbc = new ReadableByteChannelWrapper(readableByteChannel);
|
||||
fos = fileOutputStream;
|
||||
status = Status.DOWNLOADING;
|
||||
updateReadSoFar();
|
||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||
if (status == Status.DOWNLOADING) { // not interrupted
|
||||
status = Status.COMPLETE;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package itdelatrisu.opsu.downloads;
|
||||
|
||||
import itdelatrisu.opsu.ErrorHandler;
|
||||
import itdelatrisu.opsu.downloads.Download.Status;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -143,6 +144,23 @@ public class DownloadList {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all downloads with the given status from the list.
|
||||
* @param status the download status
|
||||
*/
|
||||
public void clearDownloads(Status status) {
|
||||
Iterator<DownloadNode> iter = nodes.iterator();
|
||||
while (iter.hasNext()) {
|
||||
DownloadNode node = iter.next();
|
||||
Download dl = node.getDownload();
|
||||
if (dl != null && dl.getStatus() == status) {
|
||||
node.clearDownload();
|
||||
iter.remove();
|
||||
map.remove(node.getID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a confirmation dialog (used before exiting the game).
|
||||
* @return true if user selects "yes", false otherwise
|
||||
|
||||
@@ -21,6 +21,7 @@ package itdelatrisu.opsu.downloads;
|
||||
import itdelatrisu.opsu.ErrorHandler;
|
||||
import itdelatrisu.opsu.GameImage;
|
||||
import itdelatrisu.opsu.Options;
|
||||
import itdelatrisu.opsu.OsuGroupList;
|
||||
import itdelatrisu.opsu.Utils;
|
||||
import itdelatrisu.opsu.downloads.Download.Status;
|
||||
|
||||
@@ -296,6 +297,12 @@ public class DownloadNode {
|
||||
g.setColor((focus) ? BG_FOCUS : (hover) ? BG_HOVER : BG_NORMAL);
|
||||
g.fillRect(buttonBaseX, y, buttonWidth, buttonHeight);
|
||||
|
||||
// map is already loaded
|
||||
if (OsuGroupList.get().containsBeatmapSetID(beatmapSetID)) {
|
||||
g.setColor(Utils.COLOR_BLUE_BUTTON);
|
||||
g.fillRect(buttonBaseX, y, buttonWidth, buttonHeight);
|
||||
}
|
||||
|
||||
// download progress
|
||||
if (dl != null) {
|
||||
float progress = dl.getProgress();
|
||||
@@ -349,7 +356,7 @@ public class DownloadNode {
|
||||
else if (status == Download.Status.WAITING)
|
||||
info = String.format("%s...", status.getName());
|
||||
else {
|
||||
if (hover)
|
||||
if (hover && status == Download.Status.DOWNLOADING)
|
||||
info = String.format("%s: %s left (%s)", status.getName(), download.getTimeRemaining(), download.getDownloadSpeed());
|
||||
else
|
||||
info = String.format("%s: %.1f%% (%s/%s)", status.getName(), progress,
|
||||
|
||||
Reference in New Issue
Block a user