From 636b2a8ea7d16c5f03d487f541cac4f0c3ba0d29 Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 25 Sep 2010 19:25:34 +1200 Subject: [PATCH] fix Direct Connect window --- OpenRA.Game/TraitCreator.cs | 25 +++++++++++++++++++ .../Delegates/ServerBrowserDelegate.cs | 12 ++++----- mods/ra/chrome/serverbrowser.yaml | 2 +- 3 files changed, 32 insertions(+), 7 deletions(-) create mode 100755 OpenRA.Game/TraitCreator.cs diff --git a/OpenRA.Game/TraitCreator.cs b/OpenRA.Game/TraitCreator.cs new file mode 100755 index 0000000000..673dd57678 --- /dev/null +++ b/OpenRA.Game/TraitCreator.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using OpenRA.FileFormats; +using OpenRA.Traits; + +namespace OpenRA +{ + class TraitCreator + { + public static object Create( string traitName, World world, Actor actor, ITraitInfo info, TypeDictionary init ) + { + var argsDict = new Dictionary + { + { "world", world }, + { "self", actor }, + { "initDict", init }, + { "init", new ActorInitializer( actor, init ) }, + { "info", info }, + }; + return Game.modData.ObjectCreator.CreateObject( traitName, argsDict ); + } + } +} diff --git a/OpenRA.Game/Widgets/Delegates/ServerBrowserDelegate.cs b/OpenRA.Game/Widgets/Delegates/ServerBrowserDelegate.cs index a9e2131d3a..3965fb4af2 100644 --- a/OpenRA.Game/Widgets/Delegates/ServerBrowserDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/ServerBrowserDelegate.cs @@ -30,8 +30,8 @@ namespace OpenRA.Widgets.Delegates MasterServerQuery.OnComplete += games => RefreshServerList(games); - widget.GetWidget("JOINSERVER_PROGRESS_TITLE").Visible = true; - widget.GetWidget("JOINSERVER_PROGRESS_TITLE").Text = "Fetching game list..."; + bg.GetWidget("JOINSERVER_PROGRESS_TITLE").Visible = true; + bg.GetWidget("JOINSERVER_PROGRESS_TITLE").Text = "Fetching game list..."; bg.Children.RemoveAll(a => GameButtons.Contains(a)); GameButtons.Clear(); @@ -62,8 +62,8 @@ namespace OpenRA.Widgets.Delegates bg.GetWidget("REFRESH_BUTTON").OnMouseUp = mi => { - widget.GetWidget("JOINSERVER_PROGRESS_TITLE").Visible = true; - widget.GetWidget("JOINSERVER_PROGRESS_TITLE").Text = "Fetching game list..."; + bg.GetWidget("JOINSERVER_PROGRESS_TITLE").Visible = true; + bg.GetWidget("JOINSERVER_PROGRESS_TITLE").Text = "Fetching game list..."; bg.Children.RemoveAll(a => GameButtons.Contains(a)); GameButtons.Clear(); @@ -184,7 +184,6 @@ namespace OpenRA.Widgets.Delegates dc.GetWidget("JOIN_BUTTON").OnMouseUp = mi => { - var address = dc.GetWidget("SERVER_ADDRESS").Text; var cpts = address.Split(':').ToArray(); if (cpts.Length != 2) @@ -201,7 +200,8 @@ namespace OpenRA.Widgets.Delegates dc.GetWidget("CANCEL_BUTTON").OnMouseUp = mi => { Widget.CloseWindow(); - return widget.GetWidget("MAINMENU_BUTTON_JOIN").OnMouseUp(mi); + Widget.OpenWindow("MAINMENU_BG"); + return true; }; } } diff --git a/mods/ra/chrome/serverbrowser.yaml b/mods/ra/chrome/serverbrowser.yaml index c4898f0278..fa2ab20936 100644 --- a/mods/ra/chrome/serverbrowser.yaml +++ b/mods/ra/chrome/serverbrowser.yaml @@ -247,7 +247,7 @@ Background@JOINSERVER_BG: Bold:True Background@DIRECTCONNECT_BG: Id:DIRECTCONNECT_BG - Delegate:ServerBrowserDelegate + Delegate:DirectConnectDelegate X:(WINDOW_RIGHT - WIDTH)/2 Y:(WINDOW_BOTTOM - HEIGHT)/2 Width:400