Remove GameInitInfoWidget and routing startup via widgets in RA.

This commit is contained in:
Paul Chote
2011-07-23 02:04:17 +12:00
parent 2d269155b1
commit abf63b3054
8 changed files with 240 additions and 208 deletions

View File

@@ -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<string, string> 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<string, string> 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<ChatDisplayWidget>("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");
}
}
}
}