diff --git a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromDiscLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromDiscLogic.cs index 0dbf4e9fe1..1a5b152b68 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromDiscLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromDiscLogic.cs @@ -23,6 +23,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class InstallFromDiscLogic : ChromeLogic { + // Hide percentage indicators for files smaller than 25 MB + const int ShowPercentageThreshold = 26214400; + enum Mode { Progress, Message, List } readonly ModContent content; @@ -181,7 +184,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic var displayFilename = Path.GetFileName(targetPath); var length = source.Length; - Action onProgress = b => message = "Copying " + displayFilename + " ({0}%)".F(100 * b / length); + Action onProgress = null; + if (length < ShowPercentageThreshold) + message = "Copying " + displayFilename; + else + onProgress = b => message = "Copying " + displayFilename + " ({0}%)".F(100 * b / length); + CopyStream(source, target, length, onProgress); } } @@ -287,13 +295,26 @@ namespace OpenRA.Mods.Common.Widgets.Logic extractedFiles.Add(targetPath); Directory.CreateDirectory(Path.GetDirectoryName(targetPath)); var displayFilename = Path.GetFileName(Path.GetFileName(targetPath)); - Action onProgress = b => updateMessage("Extracting " + displayFilename + " ({0}%)".F(100 * b / length)); + + Action onProgress = null; + if (length < ShowPercentageThreshold) + updateMessage("Extracting " + displayFilename); + else + onProgress = b => updateMessage("Extracting " + displayFilename + " ({0}%)".F(100 * b / length)); using (var target = File.OpenWrite(targetPath)) { Log.Write("install", "Extracting {0} -> {1}".F(sourcePath, targetPath)); if (type == ExtractionType.Blast) - Blast.Decompress(source, target, (read, _) => onProgress(read)); + { + Action onBlastProgress = (read, _) => + { + if (onProgress != null) + onProgress(read); + }; + + Blast.Decompress(source, target, onBlastProgress); + } else CopyStream(source, target, length, onProgress); }