diff --git a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj
index 982507eeb7..48f3fd5a8a 100644
--- a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj
+++ b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj
@@ -84,6 +84,7 @@
+
diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallMusicLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallMusicLogic.cs
new file mode 100644
index 0000000000..b548ae2618
--- /dev/null
+++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallMusicLogic.cs
@@ -0,0 +1,116 @@
+#region Copyright & License Information
+/*
+ * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
+ * This file is part of OpenRA, which is free software. It is made
+ * available to you under the terms of the GNU General Public License
+ * as published by the Free Software Foundation. For more information,
+ * see COPYING.
+ */
+#endregion
+
+using System;
+using System.IO;
+using System.Linq;
+using System.Threading;
+using OpenRA.FileFormats;
+using OpenRA.Widgets;
+
+namespace OpenRA.Mods.Cnc.Widgets.Logic
+{
+ public class CncInstallMusicLogic
+ {
+ Widget panel;
+ ProgressBarWidget progressBar;
+ LabelWidget statusLabel;
+ Action afterInstall;
+ ButtonWidget retryButton, backButton;
+ Widget installingContainer, insertDiskContainer;
+
+ [ObjectCreator.UseCtor]
+ public CncInstallMusicLogic([ObjectCreator.Param] Widget widget,
+ [ObjectCreator.Param] Action afterInstall)
+ {
+ this.afterInstall = afterInstall;
+ panel = widget.GetWidget("INSTALL_MUSIC_PANEL");
+ progressBar = panel.GetWidget("PROGRESS_BAR");
+ statusLabel = panel.GetWidget("STATUS_LABEL");
+
+ backButton = panel.GetWidget("BACK_BUTTON");
+ backButton.OnClick = Widget.CloseWindow;
+
+ retryButton = panel.GetWidget("RETRY_BUTTON");
+ retryButton.OnClick = CheckForDisk;
+
+ installingContainer = panel.GetWidget("INSTALLING");
+ insertDiskContainer = panel.GetWidget("INSERT_DISK");
+ CheckForDisk();
+ }
+
+ void CheckForDisk()
+ {
+ var path = InstallUtils.GetMountedDisk(CncInstallFromCDLogic.IsValidDisk);
+
+ if (path != null)
+ Install(path);
+ else
+ {
+ insertDiskContainer.IsVisible = () => true;
+ installingContainer.IsVisible = () => false;
+ }
+ }
+
+ void Install(string source)
+ {
+ backButton.IsDisabled = () => true;
+ retryButton.IsDisabled = () => true;
+ insertDiskContainer.IsVisible = () => false;
+ installingContainer.IsVisible = () => true;
+
+ var dest = new string[] { Platform.SupportDir, "Content", "cnc" }.Aggregate(Path.Combine);
+ var copyFiles = new string[] { "SCORES.MIX" };
+
+ var extractPackage = "INSTALL/SETUP.Z";
+ var extractFiles = new string[] { "transit.mix" };
+
+ var installCounter = 0;
+ var installTotal = copyFiles.Count() + extractFiles.Count();
+ var onProgress = (Action)(s => Game.RunAfterTick(() =>
+ {
+ progressBar.Percentage = installCounter * 100 / installTotal;
+ installCounter++;
+
+ statusLabel.GetText = () => s;
+ }));
+
+ var onError = (Action)(s => Game.RunAfterTick(() =>
+ {
+ statusLabel.GetText = () => "Error: " + s;
+ backButton.IsDisabled = () => false;
+ retryButton.IsDisabled = () => false;
+ }));
+
+ var t = new Thread(_ =>
+ {
+ try
+ {
+ if (!InstallUtils.CopyFiles(source, copyFiles, dest, onProgress, onError))
+ return;
+
+ if (!InstallUtils.ExtractFromPackage(source, extractPackage, extractFiles, dest, onProgress, onError))
+ return;
+
+ Game.RunAfterTick(() =>
+ {
+ Widget.CloseWindow();
+ afterInstall();
+ });
+ }
+ catch
+ {
+ onError("Installation failed");
+ }
+ }) { IsBackground = true };
+ t.Start();
+ }
+ }
+}
diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs
index 60f072aaaf..b889d60ba8 100644
--- a/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs
+++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs
@@ -182,102 +182,4 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
.Skip(1).FirstOrDefault() ?? songs.Reverse().FirstOrDefault();
}
}
-
-
- public class CncInstallMusicLogic
- {
- Widget panel;
- ProgressBarWidget progressBar;
- LabelWidget statusLabel;
- Action afterInstall;
- ButtonWidget retryButton, backButton;
- Widget installingContainer, insertDiskContainer;
-
- [ObjectCreator.UseCtor]
- public CncInstallMusicLogic([ObjectCreator.Param] Widget widget,
- [ObjectCreator.Param] Action afterInstall)
- {
- this.afterInstall = afterInstall;
- panel = widget.GetWidget("INSTALL_MUSIC_PANEL");
- progressBar = panel.GetWidget("PROGRESS_BAR");
- statusLabel = panel.GetWidget("STATUS_LABEL");
-
- backButton = panel.GetWidget("BACK_BUTTON");
- backButton.OnClick = Widget.CloseWindow;
-
- retryButton = panel.GetWidget("RETRY_BUTTON");
- retryButton.OnClick = CheckForDisk;
-
- installingContainer = panel.GetWidget("INSTALLING");
- insertDiskContainer = panel.GetWidget("INSERT_DISK");
- CheckForDisk();
- }
-
- void CheckForDisk()
- {
- var path = InstallUtils.GetMountedDisk(CncInstallFromCDLogic.IsValidDisk);
-
- if (path != null)
- Install(path);
- else
- {
- insertDiskContainer.IsVisible = () => true;
- installingContainer.IsVisible = () => false;
- }
- }
-
- void Install(string source)
- {
- backButton.IsDisabled = () => true;
- retryButton.IsDisabled = () => true;
- insertDiskContainer.IsVisible = () => false;
- installingContainer.IsVisible = () => true;
-
- var dest = new string[] { Platform.SupportDir, "Content", "cnc" }.Aggregate(Path.Combine);
- var copyFiles = new string[] { "SCORES.MIX" };
-
- var extractPackage = "INSTALL/SETUP.Z";
- var extractFiles = new string[] { "transit.mix" };
-
- var installCounter = 0;
- var installTotal = copyFiles.Count() + extractFiles.Count();
- var onProgress = (Action)(s => Game.RunAfterTick(() =>
- {
- progressBar.Percentage = installCounter*100/installTotal;
- installCounter++;
-
- statusLabel.GetText = () => s;
- }));
-
- var onError = (Action)(s => Game.RunAfterTick(() =>
- {
- statusLabel.GetText = () => "Error: "+s;
- backButton.IsDisabled = () => false;
- retryButton.IsDisabled = () => false;
- }));
-
- var t = new Thread( _ =>
- {
- try
- {
- if (!InstallUtils.CopyFiles(source, copyFiles, dest, onProgress, onError))
- return;
-
- if (!InstallUtils.ExtractFromPackage(source, extractPackage, extractFiles, dest, onProgress, onError))
- return;
-
- Game.RunAfterTick(() =>
- {
- Widget.CloseWindow();
- afterInstall();
- });
- }
- catch
- {
- onError("Installation failed");
- }
- }) { IsBackground = true };
- t.Start();
- }
- }
}