From 16017037e8b785b26dee996a0584702aa6a5fde4 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Mon, 12 Mar 2012 21:52:15 +0000 Subject: [PATCH] - Nixed the START step. - Allow multiple percentages to be specified for a step. The lowest one that's higher than the current percentage is used. - It seems sometimes the UI is shown after some progress is made. Track the percentage we're at when the UI is shown and reset that to be the new 0, scaling subsequent progress to fill the remainder. I added this convinced I needed it, but now I'm seeing that it's always at 0 when the UI is shown... Perhaps I'll revisit that after I do some other stuff... --- .../threerings/getdown/launcher/Getdown.java | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/threerings/getdown/launcher/Getdown.java b/src/main/java/com/threerings/getdown/launcher/Getdown.java index 392b347..d0ea86b 100644 --- a/src/main/java/com/threerings/getdown/launcher/Getdown.java +++ b/src/main/java/com/threerings/getdown/launcher/Getdown.java @@ -98,23 +98,22 @@ public abstract class Getdown extends Thread */ public enum Step { - START(1), UPDATE_JAVA(10), - VERIFY_METADATA(12), + VERIFY_METADATA(15, 65, 95), DOWNLOAD(40), PATCH(60), - VERIFY_RESOURCES(70), + VERIFY_RESOURCES(70, 97), REDOWNLOAD_RESOURCES(90), UNPACK(98), LAUNCH(99); /** What is the final percent value for this step? */ - public final int finalPercent; + public int[] finalPercents; /** Enum constructor. */ - Step (int finalPercent) + Step (int... finalPercents) { - this.finalPercent = finalPercent; + this.finalPercents = finalPercents; } } @@ -444,7 +443,7 @@ public abstract class Getdown extends Thread // we'll keep track of all the resources we unpack Set unpacked = new HashSet(); - setStep(Step.START); + //setStep(Step.START); for (int ii = 0; ii < MAX_LOOPS; ii++) { // if we aren't running in a JVM that meets our version requirements, either // complain or attempt to download and install the appropriate version @@ -920,6 +919,11 @@ public abstract class Getdown extends Thread _patchNotes.setBounds(_ifc.patchNotes); _patchNotes.setVisible(false); + + // we were displaying progress while the UI wasn't up. Now that it is, whatever progress + // is left is scaled into a 0-100 DISPLAYED progress. + _uiDisplayPercent = _lastGlobalPercent; + _stepMinPercent = _lastGlobalPercent = 0; } protected RotatingBackgrounds getBackground () @@ -973,11 +977,19 @@ public abstract class Getdown extends Thread */ protected void setStep (Step step) { - if (step.finalPercent < _stepMaxPercent) { - // we've gone backwards. Ignore it. + int finalPercent = -1; + for (int perc : step.finalPercents) { + if (perc > _stepMaxPercent) { + finalPercent = perc; + break; + } + } + if (finalPercent == -1) { + // we've gone backwards and this step will be ignored return; } - _stepMaxPercent = step.finalPercent; + + _stepMaxPercent = finalPercent; _stepMinPercent = _lastGlobalPercent; } @@ -996,8 +1008,10 @@ public abstract class Getdown extends Thread // maybe update the global percent, never letting it go backwards if (percent >= 0) { + int adjustedMaxPercent = + ((_stepMaxPercent - _uiDisplayPercent) * 100) / (100 - _uiDisplayPercent); _lastGlobalPercent = Math.max(_lastGlobalPercent, - _stepMinPercent + (percent * (_stepMaxPercent - _stepMinPercent)) / 100); + _stepMinPercent + (percent * (adjustedMaxPercent - _stepMinPercent)) / 100); } final int reportedPercent = (percent >= 0) ? _lastGlobalPercent : -1; @@ -1178,6 +1192,7 @@ public abstract class Getdown extends Thread protected int _stepMaxPercent; protected int _stepMinPercent; protected int _lastGlobalPercent; + protected int _uiDisplayPercent; protected static final int MAX_LOOPS = 5; protected static final long MIN_EXIST_TIME = 5000L;