Fix: ui, set a global progress on the download
This commit is contained in:
@@ -24,6 +24,7 @@ import com.formdev.flatlaf.FlatLaf;
|
||||
import com.formdev.flatlaf.FlatLightLaf;
|
||||
import com.sheepit.client.Client;
|
||||
import com.sheepit.client.Configuration;
|
||||
import com.sheepit.client.DownloadProgress;
|
||||
import com.sheepit.client.Gui;
|
||||
import com.sheepit.client.SettingsLoader;
|
||||
import com.sheepit.client.Stats;
|
||||
@@ -132,6 +133,7 @@ public class GuiSwing extends JFrame implements Gui {
|
||||
|
||||
private boolean waitingForAuthentication;
|
||||
private Client client;
|
||||
private DownloadProgress downloadProgress;
|
||||
|
||||
private BufferedImage iconSprites;
|
||||
private BufferedImage[] trayIconSprites;
|
||||
@@ -141,6 +143,7 @@ public class GuiSwing extends JFrame implements Gui {
|
||||
private ThreadClient threadClient;
|
||||
|
||||
public GuiSwing(boolean useSysTray_, String title_) {
|
||||
downloadProgress = new DownloadProgress(this);
|
||||
framesRendered = 0;
|
||||
useSysTray = useSysTray_;
|
||||
title = title_;
|
||||
@@ -272,10 +275,6 @@ public class GuiSwing extends JFrame implements Gui {
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void status(String msg, int progress, long size) {
|
||||
this.status(msg, progress);
|
||||
}
|
||||
|
||||
@Override public void setRenderingProjectName(String name_) {
|
||||
if (activityWorking != null) {
|
||||
this.activityWorking.setRenderingProjectName(name_);
|
||||
@@ -329,6 +328,10 @@ public class GuiSwing extends JFrame implements Gui {
|
||||
return client;
|
||||
}
|
||||
|
||||
@Override public DownloadProgress getDownloadProgress() {
|
||||
return downloadProgress;
|
||||
}
|
||||
|
||||
@Override public void setClient(Client cli) {
|
||||
client = cli;
|
||||
}
|
||||
@@ -496,5 +499,4 @@ public class GuiSwing extends JFrame implements Gui {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.Log;
|
||||
import com.sheepit.client.Stats;
|
||||
@@ -46,8 +47,10 @@ public class GuiText implements Gui {
|
||||
private String eta;
|
||||
|
||||
private Client client;
|
||||
private DownloadProgress downloadProgress;
|
||||
|
||||
public GuiText() {
|
||||
this.downloadProgress = new DownloadProgress(this);
|
||||
this.framesRendered = 0;
|
||||
this.log = Log.getInstance(null);
|
||||
this.df = new SimpleDateFormat("MMM dd HH:mm:ss");
|
||||
@@ -117,12 +120,8 @@ public class GuiText implements Gui {
|
||||
}
|
||||
|
||||
@Override public void status(String msg, int progress) {
|
||||
this.status(msg, progress, 0);
|
||||
}
|
||||
|
||||
@Override public void status(String msg, int progress, long size) {
|
||||
System.out.print("\r");
|
||||
System.out.print(String.format("%s %s", this.df.format(new Date()), showProgress(msg, progress, size)));
|
||||
System.out.print(String.format("%s %s", this.df.format(new Date()), showProgress(msg, progress)));
|
||||
}
|
||||
|
||||
@Override public void error(String err_) {
|
||||
@@ -178,11 +177,15 @@ public class GuiText implements Gui {
|
||||
return client;
|
||||
}
|
||||
|
||||
@Override public DownloadProgress getDownloadProgress() {
|
||||
return downloadProgress;
|
||||
}
|
||||
|
||||
@Override public void successfulAuthenticationEvent(String publickey) {
|
||||
|
||||
}
|
||||
|
||||
private String showProgress(String message, int progress, long size) {
|
||||
private String showProgress(String message, int progress) {
|
||||
StringBuilder progressBar = new StringBuilder(140);
|
||||
|
||||
if (progress < 100) {
|
||||
@@ -196,10 +199,6 @@ public class GuiText implements Gui {
|
||||
.append(String.join("", Collections.nCopies(20 - (int)(progress / 5), " ")))
|
||||
.append(']');
|
||||
|
||||
if (size > 0) {
|
||||
progressBar.append(String.format(" %dMB", (size / 1024 / 1024)));
|
||||
}
|
||||
|
||||
if (!this.eta.equals("")) {
|
||||
progressBar.append(String.format(" ETA %s", this.eta));
|
||||
}
|
||||
|
||||
@@ -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