added (broken) content installer, moved instruction to GUI
still depends on the hacky bash script and CD extractor crashes
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,8 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="D2kLoadScreen.cs" />
|
||||
<Compile Include="Widgets\Logic\D2kInstallFromCDLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\D2kInstallLogic.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
119
OpenRA.Mods.D2k/Widgets/Logic/D2kInstallFromCDLogic.cs
Normal file
119
OpenRA.Mods.D2k/Widgets/Logic/D2kInstallFromCDLogic.cs
Normal file
@@ -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<ProgressBarWidget>("PROGRESS_BAR");
|
||||
statusLabel = panel.Get<LabelWidget>("STATUS_LABEL");
|
||||
|
||||
backButton = panel.Get<ButtonWidget>("BACK_BUTTON");
|
||||
backButton.OnClick = Ui.CloseWindow;
|
||||
|
||||
retryButton = panel.Get<ButtonWidget>("RETRY_BUTTON");
|
||||
retryButton.OnClick = CheckForDisk;
|
||||
|
||||
installingContainer = panel.Get("INSTALLING");
|
||||
insertDiskContainer = panel.Get("INSERT_DISK");
|
||||
CheckForDisk();
|
||||
}
|
||||
|
||||
void CheckForDisk()
|
||||
{
|
||||
Func<string, bool> 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<string>)(s => Game.RunAfterTick(() =>
|
||||
{
|
||||
progressBar.Percentage = installCounter*100/installTotal;
|
||||
installCounter++;
|
||||
|
||||
statusLabel.GetText = () => s;
|
||||
}));
|
||||
|
||||
var onError = (Action<string>)(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();
|
||||
}
|
||||
}
|
||||
}
|
||||
35
OpenRA.Mods.D2k/Widgets/Logic/D2kInstallLogic.cs
Normal file
35
OpenRA.Mods.D2k/Widgets/Logic/D2kInstallLogic.cs
Normal file
@@ -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<string,string> installData, Action continueLoading)
|
||||
{
|
||||
var panel = widget.Get("INSTALL_PANEL");
|
||||
var args = new WidgetArgs()
|
||||
{
|
||||
{ "afterInstall", () => { Ui.CloseWindow(); continueLoading(); } },
|
||||
{ "installData", installData }
|
||||
};
|
||||
|
||||
panel.Get<ButtonWidget>("INSTALL_BUTTON").OnClick = () =>
|
||||
Ui.OpenWindow("INSTALL_FROMCD_PANEL", args);
|
||||
|
||||
panel.Get<ButtonWidget>("QUIT_BUTTON").OnClick = Game.Exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user