diff --git a/src/com/sheepit/client/Gui.java b/src/com/sheepit/client/Gui.java index f5e39c3..71df53d 100644 --- a/src/com/sheepit/client/Gui.java +++ b/src/com/sheepit/client/Gui.java @@ -28,6 +28,8 @@ public interface Gui { public void status(String msg_, boolean overwriteSuspendedMsg); + public void status(String msg_, int progress); + public void status(String msg_, int progress, long size); public void updateTrayIcon(Integer percentage_); diff --git a/src/com/sheepit/client/Job.java b/src/com/sheepit/client/Job.java index f23c763..3939c9c 100644 --- a/src/com/sheepit/client/Job.java +++ b/src/com/sheepit/client/Job.java @@ -293,10 +293,11 @@ import lombok.Getter; try { int progress = -1; - Pattern tilePattern = Pattern.compile(" ([0-9]+)\\s?\\/\\s?([0-9]+) "); + Pattern tilePattern = Pattern.compile(" (Rendered|Path Tracing Tile|Rendering) (\\d+)\\s?\\/\\s?(\\d+)( Tiles| samples|,)"); - // Initialise the progress bar in the icon (0% completed at this time) + // Initialise the progress bar in the icon and the UI (0% completed at this time) gui.updateTrayIcon(0); + gui.status("Preparing scene", 0); while ((line = input.readLine()) != null) { log.debug(line); @@ -458,15 +459,16 @@ import lombok.Getter; int newProgress = currentProgress; if (standardTileInfo.find()) { - int tileJustProcessed = Integer.parseInt(standardTileInfo.group(1)); - int totalTilesInJob = Integer.parseInt(standardTileInfo.group(2)); + int tileJustProcessed = Integer.parseInt(standardTileInfo.group(2)); + int totalTilesInJob = Integer.parseInt(standardTileInfo.group(3)); newProgress = Math.abs((tileJustProcessed * 100) / totalTilesInJob); } - // Only update the tray icon if percentage has changed + // Only update the tray icon and the screen if percentage has changed if (newProgress != currentProgress) { gui.updateTrayIcon(newProgress); + gui.status("Rendering", newProgress); } return newProgress; diff --git a/src/com/sheepit/client/standalone/GuiSwing.java b/src/com/sheepit/client/standalone/GuiSwing.java index ac38ceb..b4e15ce 100644 --- a/src/com/sheepit/client/standalone/GuiSwing.java +++ b/src/com/sheepit/client/standalone/GuiSwing.java @@ -191,12 +191,16 @@ public class GuiSwing extends JFrame implements Gui { } } - @Override public void status(String msg, int progress, long size) { + @Override public void status(String msg, int progress) { if (activityWorking != null) { this.activityWorking.setStatus(String.format("%s %d%%", msg, progress)); } } + @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_); diff --git a/src/com/sheepit/client/standalone/GuiText.java b/src/com/sheepit/client/standalone/GuiText.java index b0a892d..d65a8c8 100644 --- a/src/com/sheepit/client/standalone/GuiText.java +++ b/src/com/sheepit/client/standalone/GuiText.java @@ -42,6 +42,7 @@ public class GuiText implements Gui { private int sigIntCount = 0; private Log log; private DateFormat df; + private String eta; private Client client; @@ -49,6 +50,7 @@ public class GuiText implements Gui { this.framesRendered = 0; this.log = Log.getInstance(null); this.df = new SimpleDateFormat("MMM dd HH:mm:ss"); + this.eta = ""; } @Override public void start() { @@ -111,6 +113,10 @@ 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))); @@ -144,7 +150,7 @@ public class GuiText implements Gui { } @Override public void setRemainingTime(String time_) { - System.out.println(String.format("%s Rendering (remaining %s)", this.df.format(new Date()), time_)); + this.eta = time_; } @Override public void setRenderingTime(String time_) { @@ -169,23 +175,35 @@ public class GuiText implements Gui { private String showProgress(String message, int progress, long size) { StringBuilder progressBar = new StringBuilder(140); - progressBar - .append(message) - .append(" ") - .append(String.join("", Collections.nCopies(progress == 0 ? 2 : 2 - (int) (Math.log10(progress)), " "))) - .append(String.format("%d%% [", progress)) - .append(String.join("", Collections.nCopies((int)(progress/5), "="))) - .append('>') - .append(String.join("", Collections.nCopies(20 - (int)(progress / 5), " "))) - .append(']'); - if (size > 0) { - progressBar.append(String.format(" %dMB", (size / 1024 / 1024))); + if (progress < 100) { + progressBar + .append(message) + .append(" ") + .append(String.join("", Collections.nCopies(progress == 0 ? 2 : 2 - (int) (Math.log10(progress)), " "))) + .append(String.format("%d%% [", progress)) + .append(String.join("", Collections.nCopies((int)(progress/5), "="))) + .append('>') + .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)); + } + + progressBar.append(String.join("", Collections.nCopies(60 - progressBar.length(), " "))); } - - // Once the process has completed, show the output in a new line - if (progress == 100) { - progressBar.append("\n"); + // If progress has reached 100% + else { + progressBar + .append(message) + .append(" done") + .append(String.join("", Collections.nCopies(60 - progressBar.length(), " "))) + .append("\n"); } return progressBar.toString(); diff --git a/src/com/sheepit/client/standalone/GuiTextOneLine.java b/src/com/sheepit/client/standalone/GuiTextOneLine.java index f470be3..0c6e8d2 100644 --- a/src/com/sheepit/client/standalone/GuiTextOneLine.java +++ b/src/com/sheepit/client/standalone/GuiTextOneLine.java @@ -46,6 +46,7 @@ public class GuiTextOneLine implements Gui { private String computeMethod; private String status; private String line; + private String eta; private int uploadQueueSize; private long uploadQueueVolume; @@ -65,6 +66,7 @@ public class GuiTextOneLine implements Gui { uploadQueueSize = 0; uploadQueueVolume = 0; df = new SimpleDateFormat("MMM dd HH:mm:ss"); + eta = ""; } @Override public void start() { @@ -123,6 +125,10 @@ public class GuiTextOneLine 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) { status = showProgress(msg, progress, size); updateLine(); @@ -160,7 +166,7 @@ public class GuiTextOneLine implements Gui { } @Override public void setRemainingTime(String time_) { - status = "Rendering (remaining " + time_ + ")"; + this.eta = time_; updateLine(); } @@ -226,6 +232,10 @@ public class GuiTextOneLine implements Gui { progressBar.append(String.format(" %dMB", (size / 1024 / 1024))); } + if (!this.eta.equals("")) { + progressBar.append(String.format(" ETA %s", this.eta)); + } + return progressBar.toString(); } }