Better install menu and package downloading.
This commit is contained in:
@@ -252,7 +252,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
JoinLocal();
|
JoinLocal();
|
||||||
viewport = new Viewport(new int2(Renderer.Resolution), Rectangle.Empty, Renderer);
|
viewport = new Viewport(new int2(Renderer.Resolution), Rectangle.Empty, Renderer);
|
||||||
modData.WidgetLoader.LoadWidget( new Dictionary<string,object>(), Widget.RootWidget, "MAINMENU_INIT" );
|
modData.WidgetLoader.LoadWidget( new Dictionary<string,object>(), Widget.RootWidget, "INIT_SETUP" );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LoadShellMap()
|
public static void LoadShellMap()
|
||||||
@@ -273,6 +273,7 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool quit;
|
static bool quit;
|
||||||
|
public static event Action OnQuit = () => {};
|
||||||
internal static void Run()
|
internal static void Run()
|
||||||
{
|
{
|
||||||
while (!quit)
|
while (!quit)
|
||||||
@@ -280,6 +281,7 @@ namespace OpenRA
|
|||||||
Tick( orderManager, viewport );
|
Tick( orderManager, viewport );
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
}
|
}
|
||||||
|
OnQuit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Exit() { quit = true; }
|
public static void Exit() { quit = true; }
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ using OpenRA.Server;
|
|||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Widgets.Delegates
|
namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||||
{
|
{
|
||||||
@@ -25,7 +27,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
|||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public GameInitDelegate([ObjectCreator.Param] Widget widget)
|
public GameInitDelegate([ObjectCreator.Param] Widget widget)
|
||||||
{
|
{
|
||||||
Info = widget.GetWidget<GameInitInfoWidget>("INFO");
|
Info = (widget as GameInitInfoWidget);
|
||||||
Game.ConnectionStateChanged += orderManager =>
|
Game.ConnectionStateChanged += orderManager =>
|
||||||
{
|
{
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
@@ -56,22 +58,35 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
|||||||
ContinueLoading(widget);
|
ContinueLoading(widget);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
widget.GetWidget("INIT_DOWNLOAD").OnMouseUp = mi =>
|
ShowInstallMethodDialog();
|
||||||
{
|
}
|
||||||
ContinueLoading(widget);
|
}
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
widget.GetWidget("INIT_FROMCD").OnMouseUp = mi =>
|
void ShowInstallMethodDialog()
|
||||||
|
{
|
||||||
|
var window = Widget.OpenWindow("INIT_CHOOSEINSTALL");
|
||||||
|
window.GetWidget("DOWNLOAD").OnMouseUp = mi => { ShowDownloadDialog(); return true; };
|
||||||
|
window.GetWidget("FROMCD").OnMouseUp = mi =>
|
||||||
{
|
{
|
||||||
SelectDisk(path => System.Console.WriteLine(path));
|
SelectDisk(path => System.Console.WriteLine(path));
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
widget.GetWidget("INIT_QUIT").OnMouseUp = mi => { Game.Exit(); return true; };
|
window.GetWidget("QUIT").OnMouseUp = mi => { Game.Exit(); return true; };
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShowDownloadDialog()
|
||||||
|
{
|
||||||
|
var window = Widget.OpenWindow("INIT_DOWNLOAD");
|
||||||
|
var status = window.GetWidget<LabelWidget>("STATUS");
|
||||||
|
status.GetText = () => "Initializing...";
|
||||||
|
|
||||||
|
var dl = DownloadUrl(Info.PackageURL, Info.PackagePath,
|
||||||
|
(_,i) => status.GetText = () => "{0}% {1}/{2} bytes".F(i.ProgressPercentage, i.BytesReceived, i.TotalBytesToReceive),
|
||||||
|
(_,i) => status.GetText = () => "Download Complete");
|
||||||
|
|
||||||
|
window.GetWidget("CANCEL").OnMouseUp = mi => { CancelDownload(dl); ShowInstallMethodDialog(); return true; };
|
||||||
|
}
|
||||||
|
|
||||||
void SelectDisk(Action<string> withPath)
|
void SelectDisk(Action<string> withPath)
|
||||||
{
|
{
|
||||||
@@ -94,5 +109,24 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
|||||||
Widget.RootWidget.Children.Remove(widget);
|
Widget.RootWidget.Children.Remove(widget);
|
||||||
Widget.OpenWindow("MAINMENU_BG");
|
Widget.OpenWindow("MAINMENU_BG");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static WebClient DownloadUrl(string url, string path, DownloadProgressChangedEventHandler onProgress, AsyncCompletedEventHandler onComplete)
|
||||||
|
{
|
||||||
|
WebClient wc = new WebClient();
|
||||||
|
wc.Proxy = null;
|
||||||
|
|
||||||
|
wc.DownloadProgressChanged += onProgress;
|
||||||
|
wc.DownloadFileCompleted += onComplete;
|
||||||
|
wc.DownloadFileCompleted += (_,a) => {};
|
||||||
|
wc.DownloadFileAsync(new Uri(url), path);
|
||||||
|
Game.OnQuit += () => CancelDownload(wc);
|
||||||
|
return wc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CancelDownload(WebClient wc)
|
||||||
|
{
|
||||||
|
Game.OnQuit -= () => CancelDownload(wc);
|
||||||
|
wc.CancelAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
{
|
{
|
||||||
public string TestFile;
|
public string TestFile;
|
||||||
public string GameTitle;
|
public string GameTitle;
|
||||||
|
public string PackageURL;
|
||||||
|
public string PackagePath;
|
||||||
|
|
||||||
public override void DrawInner() {}
|
public override void DrawInner() {}
|
||||||
}
|
}
|
||||||
|
|||||||
97
mods/cnc/chrome/gameinit.yaml
Normal file
97
mods/cnc/chrome/gameinit.yaml
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
GameInitInfo@INIT_SETUP:
|
||||||
|
Id:INIT_SETUP
|
||||||
|
TestFile: fakefile.mix
|
||||||
|
GameTitle: Command & Conquer
|
||||||
|
PackageURL:http://open-ra.org/get-dependency.php?file=cnc-packages
|
||||||
|
PackagePath:cnc-packages.zip
|
||||||
|
Delegate:GameInitDelegate
|
||||||
|
|
||||||
|
Background@INIT_CHOOSEINSTALL:
|
||||||
|
Id:INIT_CHOOSEINSTALL
|
||||||
|
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:Install Required
|
||||||
|
Align:Center
|
||||||
|
Bold:True
|
||||||
|
Label@DESC1:
|
||||||
|
X:0
|
||||||
|
Y:50
|
||||||
|
Width:PARENT_RIGHT
|
||||||
|
Height:25
|
||||||
|
Text:OpenRA requires the original C&C game content.
|
||||||
|
Align:Center
|
||||||
|
Label@DESC2:
|
||||||
|
X:0
|
||||||
|
Y:70
|
||||||
|
Width:PARENT_RIGHT
|
||||||
|
Height:25
|
||||||
|
Text:Content can be downloaded automatically or installed from CD.
|
||||||
|
Align:Center
|
||||||
|
Button@DOWNLOAD:
|
||||||
|
Id:DOWNLOAD
|
||||||
|
X:PARENT_RIGHT - 420
|
||||||
|
Y:PARENT_BOTTOM - 45
|
||||||
|
Width:120
|
||||||
|
Height:25
|
||||||
|
Text:Download
|
||||||
|
Bold:True
|
||||||
|
Button@FROMCD:
|
||||||
|
Id:FROMCD
|
||||||
|
X:PARENT_RIGHT - 280
|
||||||
|
Y:PARENT_BOTTOM - 45
|
||||||
|
Width:120
|
||||||
|
Height:25
|
||||||
|
Text:From CD
|
||||||
|
Bold:True
|
||||||
|
Button@QUIT:
|
||||||
|
Id:QUIT
|
||||||
|
X:PARENT_RIGHT - 140
|
||||||
|
Y:PARENT_BOTTOM - 45
|
||||||
|
Width:120
|
||||||
|
Height:25
|
||||||
|
Text:Quit
|
||||||
|
Bold:True
|
||||||
|
|
||||||
|
Background@INIT_DOWNLOAD:
|
||||||
|
Id:INIT_DOWNLOAD
|
||||||
|
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 C&C Content
|
||||||
|
Align:Center
|
||||||
|
Bold:True
|
||||||
|
TextField@PROGRESS:
|
||||||
|
X:50
|
||||||
|
Y:65
|
||||||
|
Width:PARENT_RIGHT - 100
|
||||||
|
Height:25
|
||||||
|
Label@STATUS:
|
||||||
|
Id:STATUS
|
||||||
|
X:50
|
||||||
|
Y:PARENT_BOTTOM - 50
|
||||||
|
Width:PARENT_RIGHT - 100
|
||||||
|
Height:25
|
||||||
|
Align:Left
|
||||||
|
Button@CANCEL:
|
||||||
|
Id:CANCEL
|
||||||
|
X:PARENT_RIGHT - 140
|
||||||
|
Y:PARENT_BOTTOM - 45
|
||||||
|
Width:120
|
||||||
|
Height:25
|
||||||
|
Text:Cancel
|
||||||
|
Bold:True
|
||||||
@@ -1,49 +1,3 @@
|
|||||||
Background@MAINMENU_INIT:
|
|
||||||
Id:MAINMENU_INIT
|
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
|
||||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
|
||||||
Width:250
|
|
||||||
Height:330
|
|
||||||
Visible:true
|
|
||||||
Delegate:GameInitDelegate
|
|
||||||
Children:
|
|
||||||
GameInitInfo:
|
|
||||||
Id:INFO
|
|
||||||
TestFile: fakefile.mix
|
|
||||||
GameTitle: Command & Conquer
|
|
||||||
Label@MAINMENU_LABEL_TITLE:
|
|
||||||
Id:MAINMENU_LABEL_TITLE
|
|
||||||
X:0
|
|
||||||
Y:20
|
|
||||||
Width:250
|
|
||||||
Height:25
|
|
||||||
Text:Install Game Content
|
|
||||||
Align:Center
|
|
||||||
Bold:True
|
|
||||||
Button@INIT_DOWNLOAD:
|
|
||||||
Id:INIT_DOWNLOAD
|
|
||||||
X:45
|
|
||||||
Y:70
|
|
||||||
Width:160
|
|
||||||
Height:25
|
|
||||||
Text:Download
|
|
||||||
Bold:True
|
|
||||||
Button@INIT_FROMCD:
|
|
||||||
Id:INIT_FROMCD
|
|
||||||
X:45
|
|
||||||
Y:110
|
|
||||||
Width:160
|
|
||||||
Height:25
|
|
||||||
Text:From CD
|
|
||||||
Bold:True
|
|
||||||
Button@INIT_QUIT:
|
|
||||||
Id:INIT_QUIT
|
|
||||||
X:45
|
|
||||||
Y:150
|
|
||||||
Width:160
|
|
||||||
Height:25
|
|
||||||
Text:Quit
|
|
||||||
Bold:True
|
|
||||||
Background@MAINMENU_BG:
|
Background@MAINMENU_BG:
|
||||||
Id:MAINMENU_BG
|
Id:MAINMENU_BG
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ Assemblies:
|
|||||||
mods/cnc/OpenRA.Mods.Cnc.dll
|
mods/cnc/OpenRA.Mods.Cnc.dll
|
||||||
|
|
||||||
ChromeLayout:
|
ChromeLayout:
|
||||||
|
mods/cnc/chrome/gameinit.yaml
|
||||||
mods/cnc/chrome/ingame.yaml
|
mods/cnc/chrome/ingame.yaml
|
||||||
mods/cnc/chrome/mainmenu.yaml
|
mods/cnc/chrome/mainmenu.yaml
|
||||||
mods/cnc/chrome/videoplayer.yaml
|
mods/cnc/chrome/videoplayer.yaml
|
||||||
|
|||||||
Reference in New Issue
Block a user