diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
index 35370560fc..e8ebf9f1c6 100644
--- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
+++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
@@ -327,8 +327,6 @@
-
-
@@ -356,6 +354,8 @@
+
+
diff --git a/OpenRA.Mods.RA/RALoadScreen.cs b/OpenRA.Mods.RA/RALoadScreen.cs
index d66f1a32ed..bd7cddf1f4 100644
--- a/OpenRA.Mods.RA/RALoadScreen.cs
+++ b/OpenRA.Mods.RA/RALoadScreen.cs
@@ -11,14 +11,17 @@
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
-using OpenRA.Support;
+using OpenRA.FileFormats;
using OpenRA.Graphics;
+using OpenRA.Network;
+using OpenRA.Support;
using OpenRA.Widgets;
namespace OpenRA.Mods.RA
{
public class RALoadScreen : ILoadScreen
{
+ Dictionary Info;
static string[] Comments = new[] { "Filling Crates...", "Charging Capacitors...", "Reticulating Splines...",
"Planting Trees...", "Building Bridges...", "Aging Empires...",
"Compiling EVA...", "Constructing Pylons...", "Activating Skynet...",
@@ -33,6 +36,7 @@ namespace OpenRA.Mods.RA
Renderer r;
public void Init(Dictionary info)
{
+ Info = info;
// Avoid standard loading mechanisms so we
// can display loadscreen as early as possible
r = Game.Renderer;
@@ -64,11 +68,57 @@ namespace OpenRA.Mods.RA
r.Fonts["Bold"].DrawText(text, new float2(Renderer.Resolution.Width - textSize.X - 20, Renderer.Resolution.Height - textSize.Y - 20), Color.White);
r.EndFrame( new NullInputHandler() );
}
-
+
public void StartGame()
+ {
+ Game.ConnectionStateChanged += orderManager =>
+ {
+ Widget.CloseWindow();
+ switch (orderManager.Connection.ConnectionState)
+ {
+ case ConnectionState.PreConnecting:
+ Widget.LoadWidget("MAINMENU_BG", Widget.RootWidget, new WidgetArgs());
+ break;
+ case ConnectionState.Connecting:
+ Widget.OpenWindow("CONNECTING_BG",
+ new WidgetArgs() { { "host", orderManager.Host }, { "port", orderManager.Port } });
+ break;
+ case ConnectionState.NotConnected:
+ Widget.OpenWindow("CONNECTION_FAILED_BG",
+ new WidgetArgs() { { "orderManager", orderManager } });
+ break;
+ case ConnectionState.Connected:
+ var lobby = Game.OpenWindow(orderManager.world, "SERVER_LOBBY");
+ lobby.GetWidget("CHAT_DISPLAY").ClearChat();
+ lobby.GetWidget("CHANGEMAP_BUTTON").Visible = true;
+ lobby.GetWidget("LOCKTEAMS_CHECKBOX").Visible = true;
+ lobby.GetWidget("ALLOWCHEATS_CHECKBOX").Visible = true;
+ lobby.GetWidget("DISCONNECT_BUTTON").Visible = true;
+ break;
+ }
+ };
+
+ TestAndContinue();
+ }
+
+ void TestAndContinue()
{
Widget.ResetAll();
- Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Widget.RootWidget, "INIT_SETUP" );
+ if (!FileSystem.Exists(Info["TestFile"]))
+ {
+ var args = new WidgetArgs()
+ {
+ { "continueLoading", () => TestAndContinue() },
+ { "installData", Info }
+ };
+ Widget.OpenWindow(Info["InstallerMenuWidget"], args);
+ }
+ else
+ {
+ Game.LoadShellMap();
+ Widget.ResetAll();
+ Widget.OpenWindow("MAINMENU_BG");
+ }
}
}
}
diff --git a/OpenRA.Mods.RA/Widgets/GameInitInfoWidget.cs b/OpenRA.Mods.RA/Widgets/GameInitInfoWidget.cs
deleted file mode 100755
index 14cc0ad35d..0000000000
--- a/OpenRA.Mods.RA/Widgets/GameInitInfoWidget.cs
+++ /dev/null
@@ -1,25 +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 OpenRA.Widgets;
-
-namespace OpenRA.Mods.RA.Widgets
-{
- class GameInitInfoWidget : Widget
- {
- public string TestFile = "";
- public string GameTitle = "";
- public string PackageURL = "";
- public string PackagePath = "";
- public string InstallMode = "";
-
- public string ResolvedPackagePath { get { return PackagePath.Replace("^", Platform.SupportDir); } }
- }
-}
\ No newline at end of file
diff --git a/OpenRA.Mods.RA/Widgets/Logic/GameInitLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/GameInitLogic.cs
deleted file mode 100644
index 77182f9058..0000000000
--- a/OpenRA.Mods.RA/Widgets/Logic/GameInitLogic.cs
+++ /dev/null
@@ -1,148 +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.ComponentModel;
-using System.IO;
-using System.Net;
-using System.Threading;
-using OpenRA.FileFormats;
-using OpenRA.Network;
-using OpenRA.Widgets;
-
-namespace OpenRA.Mods.RA.Widgets.Logic
-{
- public class GameInitLogic : ILogicWithInit
- {
- GameInitInfoWidget Info;
-
- [ObjectCreator.UseCtor]
- public GameInitLogic([ObjectCreator.Param] Widget widget)
- {
- Info = (widget as GameInitInfoWidget);
- }
-
- void ILogicWithInit.Init()
- {
- Game.ConnectionStateChanged += orderManager =>
- {
- Widget.CloseWindow();
- switch (orderManager.Connection.ConnectionState)
- {
- case ConnectionState.PreConnecting:
- Widget.LoadWidget("MAINMENU_BG", Widget.RootWidget, new WidgetArgs());
- break;
- case ConnectionState.Connecting:
- Widget.OpenWindow("CONNECTING_BG",
- new WidgetArgs() { { "host", orderManager.Host }, { "port", orderManager.Port } });
- break;
- case ConnectionState.NotConnected:
- Widget.OpenWindow("CONNECTION_FAILED_BG",
- new WidgetArgs() { { "orderManager", orderManager } });
- break;
- case ConnectionState.Connected:
- var lobby = Game.OpenWindow(orderManager.world, "SERVER_LOBBY");
- lobby.GetWidget("CHAT_DISPLAY").ClearChat();
- lobby.GetWidget("CHANGEMAP_BUTTON").Visible = true;
- lobby.GetWidget("LOCKTEAMS_CHECKBOX").Visible = true;
- lobby.GetWidget("ALLOWCHEATS_CHECKBOX").Visible = true;
- lobby.GetWidget("DISCONNECT_BUTTON").Visible = true;
- break;
- }
- };
-
- TestAndContinue();
- }
-
- void TestAndContinue()
- {
- if (FileSystem.Exists(Info.TestFile))
- {
- Game.LoadShellMap();
- Widget.ResetAll();
- Widget.OpenWindow("MAINMENU_BG");
- }
- else
- {
- MainMenuButtonsLogic.DisplayModSelector();
- ShowInstallMethodDialog();
- }
- }
-
- void ShowInstallMethodDialog()
- {
- var window = Widget.OpenWindow("INIT_CHOOSEINSTALL");
-
- var args = new WidgetArgs()
- {
- { "continueLoading", () => { Widget.CloseWindow(); TestAndContinue(); } },
- };
-
- window.GetWidget("DOWNLOAD").OnClick = () => ShowDownloadDialog();
- window.GetWidget("FROMCD").OnClick = () =>
- Widget.OpenWindow("INSTALL_FROMCD_PANEL", args);
-
- window.GetWidget("QUIT").OnClick = () => Game.Exit();
- }
-
- void ShowDownloadDialog()
- {
- var window = Widget.OpenWindow("INIT_DOWNLOAD");
- var status = window.GetWidget("STATUS");
- status.GetText = () => "Initializing...";
- var progress = window.GetWidget("PROGRESS");
-
- // Save the package to a temp file
- var file = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
- Action onDownloadChange = i =>
- {
- status.GetText = () => "Downloading {1}/{2} kB ({0}%)".F(i.ProgressPercentage, i.BytesReceived / 1024, i.TotalBytesToReceive / 1024);
- progress.Percentage = i.ProgressPercentage;
- };
-
- Action onDownloadComplete = (i, cancelled) =>
- {
- if (i.Error != null)
- ShowError(window, i.Error.Message);
- else if (!cancelled)
- {
- // Automatically extract
- status.GetText = () => "Extracting...";
- progress.Indeterminate = true;
-
- if (ExtractZip(window, file, Info.ResolvedPackagePath))
- Game.RunAfterTick(TestAndContinue);
- }
- };
-
- var dl = new Download(Info.PackageURL, file, onDownloadChange, onDownloadComplete);
- window.GetWidget("CANCEL").OnClick = () => { dl.Cancel(); ShowInstallMethodDialog(); };
- window.GetWidget("RETRY").OnClick = () => { dl.Cancel(); ShowDownloadDialog(); };
- }
-
- void ShowError(Widget window, string e)
- {
- if (window.GetWidget("STATUS") != null) /* ugh */
- {
- window.GetWidget("STATUS").GetText = () => e;
- window.GetWidget("RETRY").IsVisible = () => true;
- window.GetWidget("CANCEL").IsVisible = () => true;
- }
- }
-
- bool ExtractZip(Widget window, string zipFile, string dest)
- {
- var status = window.GetWidget("STATUS");
- return InstallUtils.ExtractZip( zipFile, dest,
- s => status.GetText = () => s,
- e => ShowError(window, e));
- }
- }
-}
diff --git a/OpenRA.Mods.RA/Widgets/Logic/RADownloadPackagesLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/RADownloadPackagesLogic.cs
new file mode 100644
index 0000000000..d0cf8fcc90
--- /dev/null
+++ b/OpenRA.Mods.RA/Widgets/Logic/RADownloadPackagesLogic.cs
@@ -0,0 +1,113 @@
+#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.Collections.Generic;
+using System.ComponentModel;
+using System.IO;
+using System.Linq;
+using System.Net;
+using OpenRA.FileFormats;
+using OpenRA.Widgets;
+
+namespace OpenRA.Mods.RA.Widgets.Logic
+{
+ public class RADownloadPackagesLogic
+ {
+ Widget panel;
+ Dictionary installData;
+ ProgressBarWidget progressBar;
+ LabelWidget statusLabel;
+ Action continueLoading;
+
+ [ObjectCreator.UseCtor]
+ public RADownloadPackagesLogic([ObjectCreator.Param] Widget widget,
+ [ObjectCreator.Param] Dictionary installData,
+ [ObjectCreator.Param] Action continueLoading)
+ {
+ this.installData = installData;
+ this.continueLoading = continueLoading;
+
+ panel = widget.GetWidget("INSTALL_DOWNLOAD_PANEL");
+ progressBar = panel.GetWidget("PROGRESS_BAR");
+ statusLabel = panel.GetWidget("STATUS_LABEL");
+
+ ShowDownloadDialog();
+ }
+
+ void ShowDownloadDialog()
+ {
+ statusLabel.GetText = () => "Initializing...";
+ progressBar.SetIndeterminate(true);
+ var retryButton = panel.GetWidget("RETRY_BUTTON");
+ retryButton.IsVisible = () => false;
+
+ var cancelButton = panel.GetWidget("CANCEL_BUTTON");
+
+ // Save the package to a temp file
+ var file = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
+ var dest = new string[] { Platform.SupportDir, "Content", "ra" }.Aggregate(Path.Combine);
+
+ Action onDownloadProgress = i =>
+ {
+ if (progressBar.Indeterminate)
+ progressBar.SetIndeterminate(false);
+
+ progressBar.Percentage = i.ProgressPercentage;
+ statusLabel.GetText = () => "Downloading {1}/{2} kB ({0}%)".F(i.ProgressPercentage, i.BytesReceived / 1024, i.TotalBytesToReceive / 1024);
+ };
+
+ Action onExtractProgress = s =>
+ {
+ Game.RunAfterTick(() => statusLabel.GetText = () => s);
+ };
+
+ Action onError = s =>
+ {
+ Game.RunAfterTick(() =>
+ {
+ statusLabel.GetText = () => "Error: "+s;
+ retryButton.IsVisible = () => true;
+ });
+ };
+
+ Action onDownloadComplete = (i, cancelled) =>
+ {
+ if (i.Error != null)
+ {
+ onError(Download.FormatErrorMessage(i.Error));
+ return;
+ }
+ else if (cancelled)
+ {
+ onError("Download cancelled");
+ return;
+ }
+
+ // Automatically extract
+ statusLabel.GetText = () => "Extracting...";
+ progressBar.SetIndeterminate(true);
+ if (InstallUtils.ExtractZip(file, dest, onExtractProgress, onError))
+ {
+ Game.RunAfterTick(() =>
+ {
+ Widget.CloseWindow();
+ continueLoading();
+ });
+ }
+ };
+
+ var dl = new Download(installData["PackageURL"], file, onDownloadProgress, onDownloadComplete);
+
+ cancelButton.OnClick = () => { dl.Cancel(); Widget.CloseWindow(); };
+ retryButton.OnClick = () => { dl.Cancel(); ShowDownloadDialog(); };
+ }
+ }
+}
diff --git a/OpenRA.Mods.RA/Widgets/Logic/RAInstallLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/RAInstallLogic.cs
new file mode 100644
index 0000000000..d5cb7a1440
--- /dev/null
+++ b/OpenRA.Mods.RA/Widgets/Logic/RAInstallLogic.cs
@@ -0,0 +1,42 @@
+#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.Collections.Generic;
+using OpenRA.Widgets;
+
+namespace OpenRA.Mods.RA.Widgets.Logic
+{
+ public class RAInstallLogic
+ {
+ [ObjectCreator.UseCtor]
+ public RAInstallLogic([ObjectCreator.Param] Widget widget,
+ [ObjectCreator.Param] Dictionary installData,
+ [ObjectCreator.Param] Action continueLoading)
+ {
+ var panel = widget.GetWidget("INSTALL_PANEL");
+ var args = new WidgetArgs()
+ {
+ { "continueLoading", () => { Widget.CloseWindow(); continueLoading(); } },
+ { "installData", installData }
+ };
+
+ panel.GetWidget("DOWNLOAD_BUTTON").OnClick = () =>
+ Widget.OpenWindow("INSTALL_DOWNLOAD_PANEL", args);
+
+ panel.GetWidget("INSTALL_BUTTON").OnClick = () =>
+ Widget.OpenWindow("INSTALL_FROMCD_PANEL", args);
+
+ panel.GetWidget("QUIT_BUTTON").OnClick = Game.Exit;
+
+ MainMenuButtonsLogic.DisplayModSelector();
+ }
+ }
+}
diff --git a/mods/ra/chrome/gameinit.yaml b/mods/ra/chrome/gameinit.yaml
index b9d541483a..053a66d930 100644
--- a/mods/ra/chrome/gameinit.yaml
+++ b/mods/ra/chrome/gameinit.yaml
@@ -1,14 +1,6 @@
-GameInitInfo@INIT_SETUP:
- Id:INIT_SETUP
- TestFile: redalert.mix
- GameTitle: Red Alert
- PackageURL:http://open-ra.org/get-dependency.php?file=ra-packages
- PackagePath:^/Content/ra
- InstallMode:ra
- Logic:GameInitLogic
-
-Background@INIT_CHOOSEINSTALL:
- Id:INIT_CHOOSEINSTALL
+Background@INSTALL_PANEL:
+ Id:INSTALL_PANEL
+ Logic:RAInstallLogic
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:500
@@ -36,24 +28,24 @@ Background@INIT_CHOOSEINSTALL:
Height:25
Text:Content can be downloaded, or copied from the install CD.
Align:Center
- Button@DOWNLOAD:
- Id:DOWNLOAD
+ Button@DOWNLOAD_BUTTON:
+ Id:DOWNLOAD_BUTTON
X:PARENT_RIGHT - 280
Y:PARENT_BOTTOM - 45
Width:120
Height:25
Text:Download
Font:Bold
- Button@FROMCD:
- Id:FROMCD
+ Button@INSTALL_BUTTON:
+ Id:INSTALL_BUTTON
X:PARENT_RIGHT - 420
Y:PARENT_BOTTOM - 45
Width:120
Height:25
- Text:From CD
+ Text:Use CD
Font:Bold
- Button@QUIT:
- Id:QUIT
+ Button@QUIT_BUTTON:
+ Id:QUIT_BUTTON
X:PARENT_RIGHT - 140
Y:PARENT_BOTTOM - 45
Width:120
@@ -61,8 +53,9 @@ Background@INIT_CHOOSEINSTALL:
Text:Quit
Font:Bold
-Background@INIT_DOWNLOAD:
- Id:INIT_DOWNLOAD
+Background@INSTALL_DOWNLOAD_PANEL:
+ Id:INSTALL_DOWNLOAD_PANEL
+ Logic:RADownloadPackagesLogic
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:500
@@ -76,21 +69,21 @@ Background@INIT_DOWNLOAD:
Text:Downloading Red Alert Content
Align:Center
Font:Bold
- ProgressBar@PROGRESS:
- Id:PROGRESS
+ ProgressBar@PROGRESS_BAR:
+ Id:PROGRESS_BAR
X:50
Y:55
Width:PARENT_RIGHT - 100
Height:25
- Label@STATUS:
- Id:STATUS
+ Label@STATUS_LABEL:
+ Id:STATUS_LABEL
X:50
Y:80
Width:PARENT_RIGHT - 100
Height:25
Align:Left
- Button@RETRY:
- Id:RETRY
+ Button@RETRY_BUTTON:
+ Id:RETRY_BUTTON
X:PARENT_RIGHT - 280
Y:PARENT_BOTTOM - 45
Width:120
@@ -98,15 +91,16 @@ Background@INIT_DOWNLOAD:
Visible: false
Text:Retry
Font:Bold
- Button@CANCEL:
- Id:CANCEL
+ Key:return
+ Button@CANCEL_BUTTON:
+ Id:CANCEL_BUTTON
X:PARENT_RIGHT - 140
Y:PARENT_BOTTOM - 45
Width:120
Height:25
Text:Cancel
Font:Bold
-
+ Key:escape
Background@INSTALL_FROMCD_PANEL:
Id:INSTALL_FROMCD_PANEL
Logic:RAInstallFromCDLogic
@@ -168,6 +162,7 @@ Background@INSTALL_FROMCD_PANEL:
Height:25
Text:Retry
Font:Bold
+ Key:return
Button@BACK_BUTTON:
Id:BACK_BUTTON
X:PARENT_RIGHT - 140
@@ -175,4 +170,5 @@ Background@INSTALL_FROMCD_PANEL:
Width:120
Height:25
Text:Cancel
- Font:Bold
\ No newline at end of file
+ Font:Bold
+ Key:escape
diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml
index 901addadd9..e95f6d326f 100644
--- a/mods/ra/mod.yaml
+++ b/mods/ra/mod.yaml
@@ -84,6 +84,10 @@ Movies:
mods/ra/movies2.yaml
LoadScreen: RALoadScreen
+ InstallerMenuWidget: INSTALL_PANEL
+ TestFile: redalert.mix
+ PackageURL: http://open-ra.org/get-dependency.php?file=ra-packages
+
ServerTraits:
PlayerCommands
LobbyCommands