From ecf9c260b6d285b8cd1cf053ddaf719a9b8e9934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 29 Sep 2013 17:40:46 +0200 Subject: [PATCH] minor StyleCop cleanups --- OpenRA.FileFormats/InstallUtils.cs | 22 +++++++++++-------- .../Widgets/Logic/DownloadPackagesLogic.cs | 8 +++---- .../Widgets/Logic/RAInstallLogic.cs | 7 +++--- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/OpenRA.FileFormats/InstallUtils.cs b/OpenRA.FileFormats/InstallUtils.cs index 9260fbcfd0..fd6b12ce41 100644 --- a/OpenRA.FileFormats/InstallUtils.cs +++ b/OpenRA.FileFormats/InstallUtils.cs @@ -21,7 +21,7 @@ namespace OpenRA.FileFormats { static IEnumerable GetEntries(this ZipInputStream z) { - for (; ; ) + for (;;) { var e = z.GetNextEntry(); if (e != null) yield return e; else break; @@ -43,9 +43,9 @@ namespace OpenRA.FileFormats if (!Directory.Exists(destPath)) Directory.CreateDirectory(destPath); - if (!Directory.Exists(srcPath)) { onError("Cannot find "+package); return false; } + if (!Directory.Exists(srcPath)) { onError("Cannot find " + package); return false; } FileSystem.Mount(srcPath); - if (!FileSystem.Exists(package)) { onError("Cannot find "+package); return false; } + if (!FileSystem.Exists(package)) { onError("Cannot find " + package); return false; } FileSystem.Mount(package); foreach (string s in files) @@ -54,10 +54,11 @@ namespace OpenRA.FileFormats using (var sourceStream = FileSystem.Open(s)) using (var destStream = File.Create(destFile)) { - onProgress("Extracting "+s); + onProgress("Extracting " + s); destStream.Write(sourceStream.ReadAllBytes()); } } + return true; } @@ -68,13 +69,15 @@ namespace OpenRA.FileFormats var fromPath = Path.Combine(srcPath, file); if (!File.Exists(fromPath)) { - onError("Cannot find "+file); + onError("Cannot find " + file); return false; } + var destFile = Path.GetFileName(file).ToLowerInvariant(); - onProgress("Extracting "+destFile); + onProgress("Extracting " + destFile); File.Copy(fromPath, Path.Combine(destPath, destFile), true); } + return true; } @@ -82,7 +85,7 @@ namespace OpenRA.FileFormats { if (!File.Exists(zipFile)) { - onError("Invalid path: "+zipFile); + onError("Invalid path: " + zipFile); return false; } @@ -90,16 +93,17 @@ namespace OpenRA.FileFormats try { var z = new ZipInputStream(File.OpenRead(zipFile)); - z.ExtractZip(dest, extracted, s => onProgress("Extracting "+s)); + z.ExtractZip(dest, extracted, s => onProgress("Extracting " + s)); } catch (SharpZipBaseException) { - foreach(var f in extracted) + foreach (var f in extracted) File.Delete(f); onError("Invalid archive"); return false; } + return true; } diff --git a/OpenRA.Mods.RA/Widgets/Logic/DownloadPackagesLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/DownloadPackagesLogic.cs index 7e18a35525..400f8778e6 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/DownloadPackagesLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/DownloadPackagesLogic.cs @@ -22,13 +22,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic public class DownloadPackagesLogic { Widget panel; - Dictionary installData; + Dictionary installData; ProgressBarWidget progressBar; LabelWidget statusLabel; Action afterInstall; - + [ObjectCreator.UseCtor] - public DownloadPackagesLogic(Widget widget, Dictionary installData, Action afterInstall) + public DownloadPackagesLogic(Widget widget, Dictionary installData, Action afterInstall) { this.installData = installData; this.afterInstall = afterInstall; @@ -71,7 +71,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic { Game.RunAfterTick(() => { - statusLabel.GetText = () => "Error: "+s; + statusLabel.GetText = () => "Error: " + s; retryButton.IsVisible = () => true; }); }; diff --git a/OpenRA.Mods.RA/Widgets/Logic/RAInstallLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/RAInstallLogic.cs index 1a7ec18550..cc51e0becc 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/RAInstallLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/RAInstallLogic.cs @@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic public class RAInstallLogic { [ObjectCreator.UseCtor] - public RAInstallLogic(Widget widget, Dictionary installData, Action continueLoading) + public RAInstallLogic(Widget widget, Dictionary installData, Action continueLoading) { var panel = widget.Get("INSTALL_PANEL"); var args = new WidgetArgs() @@ -38,9 +38,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic panel.Get("MODS_BUTTON").OnClick = () => { Ui.OpenWindow("MODS_PANEL", new WidgetArgs() - { - { "onExit", () => {} }, - // Close this panel + { + { "onExit", () => { } }, { "onSwitch", Ui.CloseWindow }, }); };