Fix: ui, set a global progress on the download
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
package com.sheepit.client.standalone;
|
||||
|
||||
import com.sheepit.client.Client;
|
||||
import com.sheepit.client.DownloadProgress;
|
||||
import com.sheepit.client.Gui;
|
||||
import com.sheepit.client.Stats;
|
||||
import com.sheepit.client.TransferStats;
|
||||
@@ -55,8 +56,10 @@ public class GuiTextOneLine implements Gui {
|
||||
private boolean exiting = false;
|
||||
|
||||
private Client client;
|
||||
private DownloadProgress downloadProgress;
|
||||
|
||||
public GuiTextOneLine() {
|
||||
downloadProgress = new DownloadProgress(this);
|
||||
project = "";
|
||||
rendered = 0;
|
||||
remaining = 0;
|
||||
@@ -118,22 +121,19 @@ public class GuiTextOneLine implements Gui {
|
||||
@Override public void status(String msg_, boolean overwriteSuspendedMsg) {
|
||||
if (client != null && client.isSuspended()) {
|
||||
if (overwriteSuspendedMsg) {
|
||||
status = msg_;
|
||||
status = msg_.replace("%", "%%"); // escape %
|
||||
updateLine();
|
||||
}
|
||||
}
|
||||
else {
|
||||
status = msg_;
|
||||
status = msg_.replace("%", "%%"); // escape %
|
||||
updateLine();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override public void status(String msg, int progress) {
|
||||
this.status(msg, progress, 0);
|
||||
}
|
||||
|
||||
@Override public void status(String msg, int progress, long size) {
|
||||
status = showProgress(msg, progress, size);
|
||||
status = showProgress(msg, progress);
|
||||
updateLine();
|
||||
}
|
||||
|
||||
@@ -186,6 +186,10 @@ public class GuiTextOneLine implements Gui {
|
||||
client = cli;
|
||||
}
|
||||
|
||||
@Override public DownloadProgress getDownloadProgress() {
|
||||
return downloadProgress;
|
||||
}
|
||||
|
||||
@Override public void setComputeMethod(String computeMethod_) {
|
||||
computeMethod = computeMethod_;
|
||||
}
|
||||
@@ -224,7 +228,7 @@ public class GuiTextOneLine implements Gui {
|
||||
}
|
||||
}
|
||||
|
||||
private String showProgress(String message, int progress, long size) {
|
||||
private String showProgress(String message, int progress) {
|
||||
StringBuilder progressBar = new StringBuilder(140);
|
||||
progressBar
|
||||
.append(message)
|
||||
@@ -235,10 +239,6 @@ public class GuiTextOneLine implements Gui {
|
||||
.append(String.join("", Collections.nCopies(10 - (int) (progress / 10), " ")))
|
||||
.append(']');
|
||||
|
||||
if (size > 0) {
|
||||
progressBar.append(String.format(" %dMB", (size / 1024 / 1024)));
|
||||
}
|
||||
|
||||
if (!this.eta.equals("")) {
|
||||
progressBar.append(String.format(" ETA %s", this.eta));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user