diff --git a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj
index 48f3fd5a8a..982507eeb7 100644
--- a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj
+++ b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj
@@ -84,7 +84,6 @@
-
diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncDownloadPackagesLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncDownloadPackagesLogic.cs
index c1ca3bd83f..b528960a1e 100644
--- a/OpenRA.Mods.Cnc/Widgets/Logic/CncDownloadPackagesLogic.cs
+++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncDownloadPackagesLogic.cs
@@ -25,15 +25,15 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Dictionary installData;
ProgressBarWidget progressBar;
LabelWidget statusLabel;
- Action continueLoading;
+ Action afterInstall;
[ObjectCreator.UseCtor]
public CncDownloadPackagesLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] Dictionary installData,
- [ObjectCreator.Param] Action continueLoading)
+ [ObjectCreator.Param] Action afterInstall)
{
this.installData = installData;
- this.continueLoading = continueLoading;
+ this.afterInstall = afterInstall;
panel = widget.GetWidget("INSTALL_DOWNLOAD_PANEL");
progressBar = panel.GetWidget("PROGRESS_BAR");
@@ -99,7 +99,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Game.RunAfterTick(() =>
{
Widget.CloseWindow();
- continueLoading();
+ afterInstall();
});
}
};
diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallFromCDLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallFromCDLogic.cs
index 0c599ba566..15e3fab742 100644
--- a/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallFromCDLogic.cs
+++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallFromCDLogic.cs
@@ -22,15 +22,22 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Widget panel;
ProgressBarWidget progressBar;
LabelWidget statusLabel;
- Action continueLoading;
+ Action afterInstall;
ButtonWidget retryButton, backButton;
Widget installingContainer, insertDiskContainer;
+ string[] filesToCopy, filesToExtract;
+
[ObjectCreator.UseCtor]
public CncInstallFromCDLogic([ObjectCreator.Param] Widget widget,
- [ObjectCreator.Param] Action continueLoading)
+ [ObjectCreator.Param] Action afterInstall,
+ [ObjectCreator.Param] string[] filesToCopy,
+ [ObjectCreator.Param] string[] filesToExtract)
{
- this.continueLoading = continueLoading;
+ this.afterInstall = afterInstall;
+ this.filesToCopy = filesToCopy;
+ this.filesToExtract = filesToExtract;
+
panel = widget.GetWidget("INSTALL_FROMCD_PANEL");
progressBar = panel.GetWidget("PROGRESS_BAR");
statusLabel = panel.GetWidget("STATUS_LABEL");
@@ -78,14 +85,10 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
installingContainer.IsVisible = () => true;
var dest = new string[] { Platform.SupportDir, "Content", "cnc" }.Aggregate(Path.Combine);
- var copyFiles = new string[] { "CONQUER.MIX", "DESERT.MIX",
- "SCORES.MIX", "SOUNDS.MIX", "TEMPERAT.MIX", "WINTER.MIX" };
-
var extractPackage = "INSTALL/SETUP.Z";
- var extractFiles = new string[] { "speech.mix", "tempicnh.mix", "transit.mix" };
var installCounter = 0;
- var installTotal = copyFiles.Count() + extractFiles.Count();
+ var installTotal = filesToExtract.Count() + filesToExtract.Count();
var onProgress = (Action)(s => Game.RunAfterTick(() =>
{
progressBar.Percentage = installCounter*100/installTotal;
@@ -105,16 +108,16 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{
try
{
- if (!InstallUtils.CopyFiles(source, copyFiles, dest, onProgress, onError))
+ if (!InstallUtils.CopyFiles(source, filesToCopy, dest, onProgress, onError))
return;
- if (!InstallUtils.ExtractFromPackage(source, extractPackage, extractFiles, dest, onProgress, onError))
+ if (!InstallUtils.ExtractFromPackage(source, extractPackage, filesToExtract, dest, onProgress, onError))
return;
Game.RunAfterTick(() =>
{
Widget.CloseWindow();
- continueLoading();
+ afterInstall();
});
}
catch
diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallLogic.cs
index 282e65a0a4..87866f698a 100644
--- a/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallLogic.cs
+++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallLogic.cs
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var panel = widget.GetWidget("INSTALL_PANEL");
var args = new WidgetArgs()
{
- { "continueLoading", () => { Widget.CloseWindow(); continueLoading(); } },
+ { "afterInstall", () => { Widget.CloseWindow(); continueLoading(); } },
{ "installData", installData }
};
@@ -32,7 +32,12 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Widget.OpenWindow("INSTALL_DOWNLOAD_PANEL", args);
panel.GetWidget("INSTALL_BUTTON").OnClick = () =>
- Widget.OpenWindow("INSTALL_FROMCD_PANEL", args);
+ Widget.OpenWindow("INSTALL_FROMCD_PANEL", new WidgetArgs(args)
+ {
+ { "filesToCopy", new[] { "CONQUER.MIX", "DESERT.MIX", "SCORES.MIX",
+ "SOUNDS.MIX", "TEMPERAT.MIX", "WINTER.MIX" } },
+ { "filesToExtract", new[] { "speech.mix", "tempicnh.mix", "transit.mix" } },
+ });
panel.GetWidget("QUIT_BUTTON").OnClick = Game.Exit;
diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallMusicLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallMusicLogic.cs
deleted file mode 100644
index b548ae2618..0000000000
--- a/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallMusicLogic.cs
+++ /dev/null
@@ -1,116 +0,0 @@
-#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 b889d60ba8..ec366c6a1e 100644
--- a/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs
+++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs
@@ -64,7 +64,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var installButton = panel.GetWidget("INSTALL_BUTTON");
installButton.OnClick = () =>
- Widget.OpenWindow("INSTALL_MUSIC_PANEL", new WidgetArgs() {{ "afterInstall", afterInstall }});
+ Widget.OpenWindow("INSTALL_MUSIC_PANEL", new WidgetArgs() {
+ { "afterInstall", afterInstall },
+ { "filesToCopy", new [] { "SCORES.MIX" } },
+ { "filesToExtract", new [] { "transit.mix" } },
+ });
installButton.IsVisible = () => music.Length < 3; // Hack around music being split between transit.mix and scores.mix
panel.GetWidget("NO_MUSIC_LABEL").IsVisible = noMusic;
diff --git a/mods/cnc/chrome/music.yaml b/mods/cnc/chrome/music.yaml
index c3c9efabd8..91f738c888 100644
--- a/mods/cnc/chrome/music.yaml
+++ b/mods/cnc/chrome/music.yaml
@@ -202,7 +202,7 @@ Container@MUSIC_PANEL:
Container@INSTALL_MUSIC_PANEL:
Id:INSTALL_MUSIC_PANEL
- Logic:CncInstallMusicLogic
+ Logic:CncInstallFromCDLogic
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - 150)/2
Width:640