Implemented an internal beatmap downloader (using Bloodcat).
The downloads menu can be accessed through the button on the right side of the main menu. The downloader supports searching and concurrent downloads (NOTE: this is limited by the download server!). Double-click any search result to begin downloading it to the SongPacks directory; cancel the download by hitting the red 'x' in the upper-right corner. A confirmation will appear if trying to quit opsu! while downloads are running. New classes: - Download: represents an individual download from a remote address to a local path, and provides status and progress information; downloads files using Java NIO. - DownloadNode: holds a Download object as well as additional beatmap fields, and handles drawing. - DownloadList: manages the current list of downloads. - DownloadsMenu: game state controller. - DownloadServer: interface for a beatmap download server. - BloodcatServer: implements DownloadServer using Bloodcat. - ReadableByteChannelWrapper: wrapper for ReadableByteChannel that tracks progress. Added images: - "downloads" image by @kouyang. - "search-background" image from "Minimalist Miku" skin (listed in credits). - "delete" icon by Visual Pharm (https://www.iconfinder.com/icons/27842/) under CC BY-ND 3.0. Other changes: - Added up/down/left/right Expand directions to MenuButton class. - Removed width/height parameters from OsuParser (leftovers). Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -20,6 +20,7 @@ package itdelatrisu.opsu;
|
||||
|
||||
import itdelatrisu.opsu.audio.SoundController;
|
||||
import itdelatrisu.opsu.audio.SoundEffect;
|
||||
import itdelatrisu.opsu.downloads.DownloadNode;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -71,7 +72,8 @@ public class Utils {
|
||||
COLOR_ORANGE_OBJECT = new Color(255, 200, 32),
|
||||
COLOR_YELLOW_ALPHA = new Color(255, 255, 0, 0.4f),
|
||||
COLOR_WHITE_FADE = new Color(255, 255, 255, 1f),
|
||||
COLOR_RED_HOVER = new Color(255, 112, 112);
|
||||
COLOR_RED_HOVER = new Color(255, 112, 112),
|
||||
COLOR_GREEN = new Color(137, 201, 79);
|
||||
|
||||
/** The default map colors, used when a map does not provide custom colors. */
|
||||
public static final Color[] DEFAULT_COMBO = {
|
||||
@@ -201,6 +203,9 @@ public class Utils {
|
||||
// initialize score data buttons
|
||||
ScoreData.init(width, height);
|
||||
|
||||
// initialize download nodes
|
||||
DownloadNode.init(width, height);
|
||||
|
||||
// back button
|
||||
Image back = GameImage.MENU_BACK.getImage();
|
||||
backButton = new MenuButton(back,
|
||||
@@ -685,4 +690,18 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a human-readable representation of a given number of bytes.
|
||||
* @param bytes the number of bytes
|
||||
* @return the string representation
|
||||
* @author aioobe (http://stackoverflow.com/a/3758880)
|
||||
*/
|
||||
public static String bytesToString(long bytes) {
|
||||
if (bytes < 1024)
|
||||
return bytes + " B";
|
||||
int exp = (int) (Math.log(bytes) / Math.log(1024));
|
||||
char pre = "KMGTPE".charAt(exp - 1);
|
||||
return String.format("%.1f %cB", bytes / Math.pow(1024, exp), pre);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user