diff --git a/OpenRA.Mods.D2k/D2kLoadScreen.cs b/OpenRA.Mods.D2k/D2kLoadScreen.cs index bfa77774ea..146d1e250e 100644 --- a/OpenRA.Mods.D2k/D2kLoadScreen.cs +++ b/OpenRA.Mods.D2k/D2kLoadScreen.cs @@ -37,7 +37,7 @@ namespace OpenRA.Mods.D2k // can display loadscreen as early as possible r = Game.Renderer; if (r == null) return; - var s = new Sheet(Path.Combine(Path.Combine(Path.Combine("mods", "d2k"), "uibits"), "loadscreen.png")); + var s = new Sheet("mods/d2k/uibits/loadscreen.png"); Logo = new Sprite(s, new Rectangle(0,0,256,256), TextureChannel.Alpha); Stripe = new Sprite(s, new Rectangle(256,0,256,256), TextureChannel.Alpha); StripeRect = new Rectangle(0, Renderer.Resolution.Height/2 - 128, Renderer.Resolution.Width, 256); @@ -73,9 +73,21 @@ namespace OpenRA.Mods.D2k void TestAndContinue() { Ui.ResetAll(); - Game.LoadShellMap(); - Ui.ResetAll(); - Ui.OpenWindow("MAINMENU_BG"); + if (!FileSystem.Exists(Info["TestFile"])) + { + var args = new WidgetArgs() + { + { "continueLoading", () => TestAndContinue() }, + { "installData", Info } + }; + Ui.OpenWindow(Info["InstallerMenuWidget"], args); + } + else + { + Game.LoadShellMap(); + Ui.ResetAll(); + Ui.OpenWindow("MAINMENU_BG"); + } } } } \ No newline at end of file diff --git a/OpenRA.Mods.D2k/OpenRA.Mods.D2k.csproj b/OpenRA.Mods.D2k/OpenRA.Mods.D2k.csproj index 42540d4f24..1c47421063 100644 --- a/OpenRA.Mods.D2k/OpenRA.Mods.D2k.csproj +++ b/OpenRA.Mods.D2k/OpenRA.Mods.D2k.csproj @@ -58,6 +58,8 @@ + + diff --git a/OpenRA.Mods.D2k/Widgets/Logic/D2kInstallFromCDLogic.cs b/OpenRA.Mods.D2k/Widgets/Logic/D2kInstallFromCDLogic.cs new file mode 100644 index 0000000000..340a462624 --- /dev/null +++ b/OpenRA.Mods.D2k/Widgets/Logic/D2kInstallFromCDLogic.cs @@ -0,0 +1,119 @@ +#region Copyright & License Information +/* + * Copyright 2007-2012 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.FileFormats.Graphics; +using OpenRA.Widgets; + +namespace OpenRA.Mods.D2k.Widgets.Logic +{ + public class D2kInstallFromCDLogic + { + Widget panel; + ProgressBarWidget progressBar; + LabelWidget statusLabel; + Action continueLoading; + ButtonWidget retryButton, backButton; + Widget installingContainer, insertDiskContainer; + + [ObjectCreator.UseCtor] + public D2kInstallFromCDLogic(Widget widget, Action continueLoading) + { + this.continueLoading = continueLoading; + panel = widget.Get("INSTALL_FROMCD_PANEL"); + progressBar = panel.Get("PROGRESS_BAR"); + statusLabel = panel.Get("STATUS_LABEL"); + + backButton = panel.Get("BACK_BUTTON"); + backButton.OnClick = Ui.CloseWindow; + + retryButton = panel.Get("RETRY_BUTTON"); + retryButton.OnClick = CheckForDisk; + + installingContainer = panel.Get("INSTALLING"); + insertDiskContainer = panel.Get("INSERT_DISK"); + CheckForDisk(); + } + + void CheckForDisk() + { + Func ValidDiskFilter = diskRoot => File.Exists(diskRoot+Path.DirectorySeparatorChar+"MAIN.MIX") && + File.Exists(new string[] { diskRoot, "setup", "setup.z" }.Aggregate(Path.Combine)); + + var path = InstallUtils.GetMountedDisk(ValidDiskFilter); + + 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", "d2k" }.Aggregate(Path.Combine); + var copyFiles = new string[] { "music/ambush.aud" }; + + var extractPackage = "setup/setup.z"; + var extractFiles = new string[] { "DATA.R8", "MOUSE.R8", "BLOXBASE.R8" }; + + 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(() => + { + Ui.CloseWindow(); + continueLoading(); + }); + } + catch + { + onError("Installation failed"); + } + }) { IsBackground = true }; + t.Start(); + } + } +} diff --git a/OpenRA.Mods.D2k/Widgets/Logic/D2kInstallLogic.cs b/OpenRA.Mods.D2k/Widgets/Logic/D2kInstallLogic.cs new file mode 100644 index 0000000000..712355ffa7 --- /dev/null +++ b/OpenRA.Mods.D2k/Widgets/Logic/D2kInstallLogic.cs @@ -0,0 +1,35 @@ +#region Copyright & License Information +/* + * Copyright 2007-2012 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.D2k.Widgets.Logic +{ + public class D2kInstallLogic + { + [ObjectCreator.UseCtor] + public D2kInstallLogic(Widget widget, Dictionary installData, Action continueLoading) + { + var panel = widget.Get("INSTALL_PANEL"); + var args = new WidgetArgs() + { + { "afterInstall", () => { Ui.CloseWindow(); continueLoading(); } }, + { "installData", installData } + }; + + panel.Get("INSTALL_BUTTON").OnClick = () => + Ui.OpenWindow("INSTALL_FROMCD_PANEL", args); + + panel.Get("QUIT_BUTTON").OnClick = Game.Exit; + } + } +} diff --git a/README b/README index c4b4efc183..97a5a6d9d8 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ OpenRA is a Libre/Free Real Time Strategy game engine supporting early Westwood games like Command & Conquer and Command & Conquer: Red Alert. -Distributed mods include a reimagining and updating of both the Red Alert and Command & Conquer multiplayer games. This repository tries to add Dune 2000. It is already a standalone mod, but still falls back to Red Alert gamefiles at some times. +Distributed mods include a reimagining and updating of both the Red Alert and Command & Conquer multiplayer games. -Please read INSTALL on how to install an OpenRA development environment, HACKING for an overview of the engine and mods/d2k/TODO to find out about the still missing features. You need to copy "Dune 2000/Data/GAMESFX" and "Dune 2000/DATA/DATA.R8" and "Dune 2000/DATA/MOUSE.R8" to ~/.openra/Content/d2k/ and run the bash script ripD2kGameFiles.sh before starting the d2k mod. \ No newline at end of file +Please read INSTALL on how to install an OpenRA development environment and HACKING for an overview of the engine. \ No newline at end of file diff --git a/mods/d2k/chrome/gameinit.yaml b/mods/d2k/chrome/gameinit.yaml index 41b0fba569..b7b0296b56 100644 --- a/mods/d2k/chrome/gameinit.yaml +++ b/mods/d2k/chrome/gameinit.yaml @@ -1,16 +1,16 @@ Background@INSTALL_PANEL: - Logic:RAInstallLogic + Logic:D2kInstallLogic X:(WINDOW_RIGHT - WIDTH)/2 Y:(WINDOW_BOTTOM - HEIGHT)/2 - Width:500 - Height:160 + Width:600 + Height:300 Children: Label@TITLE: X:0 Y:20 Width:PARENT_RIGHT Height:25 - Text:Install Required + Text:Content files missing Align:Center Font:Bold Label@DESC1: @@ -18,28 +18,56 @@ Background@INSTALL_PANEL: Y:50 Width:PARENT_RIGHT Height:25 - Text:OpenRA requires the original Red Alert game content. + Text:This is the work in progress Dune 2000 mod. Align:Center Label@DESC2: X:0 Y:70 Width:PARENT_RIGHT Height:25 - Text:Content can be downloaded, or copied from the install CD. + Text:It requires the original Dune 2000 (and still some Red Alert game) content. Align:Center - Button@DOWNLOAD_BUTTON: - X:PARENT_RIGHT - 280 - Y:PARENT_BOTTOM - 45 - Width:120 + Label@DESC4: + X:0 + Y:110 + Width:PARENT_RIGHT Height:25 - Text:Download - Font:Bold + Text:You need to copy "Dune 2000/Data/GAMESFX", "Dune 2000/DATA/DATA.R8" + Align:Center + Label@DESC5: + X:0 + Y:130 + Width:PARENT_RIGHT + Height:25 + Text:and "Dune 2000/DATA/MOUSE.R8" from your local Dune 2000 installation + Align:Center + Label@DESC6: + X:0 + Y:150 + Width:PARENT_RIGHT + Height:25 + Text:to ~/.openra/Content/d2k/ and run the bash script ripD2kGameFiles.sh + Align:Center + Label@DESC7: + X:0 + Y:170 + Width:PARENT_RIGHT + Height:25 + Text:to convert the content. In the future this GUI should do this + Align:Center + Label@DESC8: + X:0 + Y:190 + Width:PARENT_RIGHT + Height:25 + Text:automatically using your Dune 2000 CD (won't work yet). + Align:Center Button@INSTALL_BUTTON: X:PARENT_RIGHT - 420 Y:PARENT_BOTTOM - 45 - Width:120 + Width:150 Height:25 - Text:Use CD + Text:Use CD (will crash) Font:Bold Button@QUIT_BUTTON: X:PARENT_RIGHT - 140 @@ -49,51 +77,8 @@ Background@INSTALL_PANEL: Text:Quit Font:Bold -Background@INSTALL_DOWNLOAD_PANEL: - Logic:DownloadPackagesLogic - X:(WINDOW_RIGHT - WIDTH)/2 - Y:(WINDOW_BOTTOM - HEIGHT)/2 - Width:500 - Height:160 - Children: - Label@TITLE: - X:0 - Y:20 - Width:PARENT_RIGHT - Height:25 - Text:Downloading Red Alert Content - Align:Center - Font:Bold - ProgressBar@PROGRESS_BAR: - X:50 - Y:55 - Width:PARENT_RIGHT - 100 - Height:25 - Label@STATUS_LABEL: - X:50 - Y:80 - Width:PARENT_RIGHT - 100 - Height:25 - Align:Left - Button@RETRY_BUTTON: - X:PARENT_RIGHT - 280 - Y:PARENT_BOTTOM - 45 - Width:120 - Height:25 - Visible: false - Text:Retry - Font:Bold - Key:return - Button@CANCEL_BUTTON: - X:PARENT_RIGHT - 140 - Y:PARENT_BOTTOM - 45 - Width:120 - Height:25 - Text:Cancel - Font:Bold - Key:escape Background@INSTALL_FROMCD_PANEL: - Logic:RAInstallFromCDLogic + Logic:D2kInstallFromCDLogic X:(WINDOW_RIGHT - WIDTH)/2 Y:(WINDOW_BOTTOM - HEIGHT)/2 Width:500 @@ -138,7 +123,7 @@ Background@INSTALL_FROMCD_PANEL: Y:70 Width:PARENT_RIGHT Height:25 - Text:Please insert one of the Red Alert install CDs then click Retry. + Text:Please insert the Dune 2000 install CDs then click Retry. Align:Center Button@RETRY_BUTTON: X:PARENT_RIGHT - 280 diff --git a/mods/d2k/mod.yaml b/mods/d2k/mod.yaml index 03e759d772..eba4fbec75 100644 --- a/mods/d2k/mod.yaml +++ b/mods/d2k/mod.yaml @@ -81,6 +81,7 @@ Voices: TileSets: mods/d2k/tilesets/arrakis.yaml +# mods/d2k/tilesets/bloxbase.yaml TileSize: 32 @@ -90,6 +91,8 @@ Music: Movies: LoadScreen: D2kLoadScreen + InstallerMenuWidget: INSTALL_PANEL + TestFile: DATA.R8 ServerTraits: LobbyCommands