- Rotate slider ball image along the curve.
- Show download speed and time remaining when hovering over the download info button.
- Maintain aspect ratio of beatmap background image during gameplay.
- Clear beatmap background image cache after reaching OsuFile.MAX_CACHE_SIZE.
- Multiply hit circle size by OsuHitObject.getXMultiplier().
- Scale MENU_BUTTON_BG based on SongMenu.MAX_SONG_BUTTONS.
- Fixed download search TextField retaining focus even after leaving the downloads menu.
- Include Unicode title/artist strings in searches.
- Parse x,y beatmap coordinates as floats (instead of integers), and only read Kiai time if present.
- Added 1600x1200 resolution.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han
2015-02-09 21:40:38 -05:00
parent 8d00a0f81e
commit f56c02864b
15 changed files with 125 additions and 18 deletions

View File

@@ -44,6 +44,9 @@ public class Download {
/** Read timeout, in ms. */
public static final int READ_TIMEOUT = 10000;
/** Time between download speed and ETA updates, in ms. */
private static final int UPDATE_INTERVAL = 1000;
/** Download statuses. */
public enum Status {
WAITING ("Waiting"),
@@ -90,6 +93,18 @@ public class Download {
/** The download status. */
private Status status = Status.WAITING;
/** Time when lastReadSoFar was updated. */
private long lastReadSoFarTime = -1;
/** Last readSoFar amount. */
private long lastReadSoFar = -1;
/** Last calculated download speed string. */
private String lastDownloadSpeed;
/** Last calculated ETA string. */
private String lastTimeRemaining;
/**
* Constructor.
* @param remoteURL the download URL
@@ -234,6 +249,60 @@ public class Download {
}
}
/**
* Returns the last calculated download speed, or null if not downloading.
*/
public String getDownloadSpeed() {
updateReadSoFar();
return lastDownloadSpeed;
}
/**
* Returns the last calculated ETA, or null if not downloading.
*/
public String getTimeRemaining() {
updateReadSoFar();
return lastTimeRemaining;
}
/**
* Updates the last readSoFar and related fields.
*/
private void updateReadSoFar() {
// only update while downloading
if (status != Status.DOWNLOADING) {
this.lastDownloadSpeed = null;
this.lastTimeRemaining = null;
return;
}
// update download speed and ETA
if (System.currentTimeMillis() > lastReadSoFarTime + UPDATE_INTERVAL) {
long readSoFar = readSoFar();
long readSoFarTime = System.currentTimeMillis();
long dlspeed = (readSoFar - lastReadSoFar) * 1000 / (readSoFarTime - lastReadSoFarTime);
if (dlspeed > 0) {
this.lastDownloadSpeed = String.format("%s/s", Utils.bytesToString(dlspeed));
long t = (contentLength - readSoFar) / dlspeed;
if (t >= 3600)
this.lastTimeRemaining = String.format("%dh%dm%ds", t / 3600, (t / 60) % 60, t % 60);
else
this.lastTimeRemaining = String.format("%dm%ds", t / 60, t % 60);
} else {
this.lastDownloadSpeed = String.format("%s/s", Utils.bytesToString(0));
this.lastTimeRemaining = "?";
}
this.lastReadSoFarTime = readSoFarTime;
this.lastReadSoFar = readSoFar;
}
// first call
else if (lastReadSoFarTime <= 0) {
this.lastReadSoFar = readSoFar();
this.lastReadSoFarTime = System.currentTimeMillis();
}
}
/**
* Cancels the download, if running.
*/

View File

@@ -348,9 +348,13 @@ public class DownloadNode {
info = status.getName();
else if (status == Download.Status.WAITING)
info = String.format("%s...", status.getName());
else
info = String.format("%s: %.1f%% (%s/%s)", status.getName(), progress,
Utils.bytesToString(download.readSoFar()), Utils.bytesToString(download.contentLength()));
else {
if (hover)
info = String.format("%s: %s left (%s)", status.getName(), download.getTimeRemaining(), download.getDownloadSpeed());
else
info = String.format("%s: %.1f%% (%s/%s)", status.getName(), progress,
Utils.bytesToString(download.readSoFar()), Utils.bytesToString(download.contentLength()));
}
Utils.FONT_BOLD.drawString(textX, y + marginY, getTitle(), Color.white);
Utils.FONT_DEFAULT.drawString(textX, y + marginY + Utils.FONT_BOLD.getLineHeight(), info, Color.white);