Install cnc from cd

This commit is contained in:
Paul Chote
2011-05-04 17:52:14 +12:00
parent 4efebcd6b2
commit 07dac11144
3 changed files with 40 additions and 22 deletions

View File

@@ -72,7 +72,6 @@ namespace OpenRA.FileFormats
public static void Mount(string name) public static void Mount(string name)
{ {
var start = name;
var optional = name.StartsWith("~"); var optional = name.StartsWith("~");
if (optional) name = name.Substring(1); if (optional) name = name.Substring(1);

View File

@@ -60,14 +60,23 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
} }
}; };
if (FileSystem.Exists(Info.TestFile)) TestAndContinue();
ContinueLoading(); }
void TestAndContinue()
{
if (FileSystem.Exists(Info.TestFile))
{
Game.LoadShellMap();
Widget.RootWidget.RemoveChildren();
Widget.OpenWindow("MAINMENU_BG");
}
else else
{ {
MainMenuButtonsDelegate.DisplayModSelector(); MainMenuButtonsDelegate.DisplayModSelector();
ShowInstallMethodDialog(); ShowInstallMethodDialog();
} }
} }
void ShowInstallMethodDialog() void ShowInstallMethodDialog()
{ {
@@ -99,10 +108,20 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
window.GetWidget("CANCEL").OnMouseUp = mi => { ShowInstallMethodDialog(); return true; }; window.GetWidget("CANCEL").OnMouseUp = mi => { ShowInstallMethodDialog(); return true; };
window.GetWidget("RETRY").OnMouseUp = mi => PromptForCD(); window.GetWidget("RETRY").OnMouseUp = mi => PromptForCD();
if (Info.InstallMode != "ra") switch (Info.InstallMode)
ShowDownloadError(window, "Installing from CD not supported"); {
else if (InstallRAPackages(window, path, Info.ResolvedPackagePath)) case "ra":
Game.RunAfterTick(ContinueLoading); if (InstallRAPackages(window, path, Info.ResolvedPackagePath))
Game.RunAfterTick(TestAndContinue);
break;
case "cnc":
if (InstallCncPackages(window, path, Info.ResolvedPackagePath))
Game.RunAfterTick(TestAndContinue);
break;
default:
ShowDownloadError(window, "Installing from CD not supported");
break;
}
} }
void ShowDownloadDialog() void ShowDownloadDialog()
@@ -131,7 +150,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
progress.Indeterminate = true; progress.Indeterminate = true;
if (ExtractZip(window, file, Info.ResolvedPackagePath)) if (ExtractZip(window, file, Info.ResolvedPackagePath))
Game.RunAfterTick(ContinueLoading); Game.RunAfterTick(TestAndContinue);
} }
}; };
@@ -150,13 +169,6 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
window.GetWidget<ButtonWidget>("CANCEL").IsVisible = () => true; window.GetWidget<ButtonWidget>("CANCEL").IsVisible = () => true;
} }
} }
void ContinueLoading()
{
Game.LoadShellMap();
Widget.RootWidget.RemoveChildren();
Widget.OpenWindow("MAINMENU_BG");
}
// General support methods // General support methods
public class Download public class Download
@@ -265,6 +277,17 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
new string[] { "conquer.mix", "russian.mix", "allies.mix", "sounds.mix", new string[] { "conquer.mix", "russian.mix", "allies.mix", "sounds.mix",
"scores.mix", "snow.mix", "interior.mix", "temperat.mix" }, dest); "scores.mix", "snow.mix", "interior.mix", "temperat.mix" }, dest);
} }
bool InstallCncPackages(Widget window, string source, string dest)
{
if (!CopyFiles(window, source,
new string[] { "CONQUER.MIX", "DESERT.MIX", "GENERAL.MIX", "SCORES.MIX",
"SOUNDS.MIX", "TEMPERAT.MIX", "WINTER.MIX"},
dest))
return false;
return ExtractFromPackage(window, source, "INSTALL/SETUP.Z",
new string[] { "cclocal.mix", "speech.mix", "tempicnh.mix", "updatec.mix" }, dest);
}
} }
static class InstallUtils static class InstallUtils

View File

@@ -34,14 +34,11 @@ Background@INIT_CHOOSEINSTALL:
Y:70 Y:70
Width:PARENT_RIGHT Width:PARENT_RIGHT
Height:25 Height:25
# Text:Content can be downloaded, or copied from the install CD. Text:Content can be downloaded, or copied from the install CD.
Text:A 6.1MB download is required.
Align:Center Align:Center
Button@DOWNLOAD: Button@DOWNLOAD:
Id:DOWNLOAD Id:DOWNLOAD
# X:PARENT_RIGHT - 420 X:PARENT_RIGHT - 420
# Y:PARENT_BOTTOM - 45
X:PARENT_RIGHT - 280
Y:PARENT_BOTTOM - 45 Y:PARENT_BOTTOM - 45
Width:120 Width:120
Height:25 Height:25
@@ -54,7 +51,6 @@ Background@INIT_CHOOSEINSTALL:
Width:120 Width:120
Height:25 Height:25
Text:From CD Text:From CD
Visible:false
Bold:True Bold:True
Button@QUIT: Button@QUIT:
Id:QUIT Id:QUIT