From 2a48e01d91c0275093dadd3befaccbaec1772912 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Thu, 6 Oct 2011 22:37:26 +1300 Subject: [PATCH] move SetupNameWidget function into new LobbyUtils static class --- OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs index aa57ac454b..3af6b45448 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs @@ -355,7 +355,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic else if (c.Index == orderManager.LocalClient.Index && c.State != Session.ClientState.Ready) { template = LocalPlayerTemplate.Clone(); - SetupNameWidget(c, template.GetWidget("NAME")); + LobbyUtils.SetupNameWidget(orderManager, c, template.GetWidget("NAME")); var color = template.GetWidget("COLOR"); color.IsDisabled = () => s.LockColor; @@ -423,7 +423,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic if (c.Index == orderManager.LocalClient.Index && c.State != Session.ClientState.Ready) { template = LocalSpectatorTemplate.Clone(); - SetupNameWidget(c, template.GetWidget("NAME")); + LobbyUtils.SetupNameWidget(orderManager, c, template.GetWidget("NAME")); var color = template.GetWidget("COLOR"); color.OnMouseDown = _ => ShowColorDropDown(color, c); @@ -468,7 +468,17 @@ namespace OpenRA.Mods.RA.Widgets.Logic } } - void SetupNameWidget(Session.Client c, TextFieldWidget name) + bool SpawnPointAvailable(int index) { return (index == 0) || orderManager.LobbyInfo.Clients.All(c => c.SpawnPoint != index); } + + void CycleReady() + { + orderManager.IssueOrder(Order.Command("ready")); + } + } + + public static class LobbyUtils + { + public static void SetupNameWidget(OrderManager orderManager, Session.Client c, TextFieldWidget name) { name.Text = c.Name; name.OnEnterKey = () => @@ -488,12 +498,5 @@ namespace OpenRA.Mods.RA.Widgets.Logic }; name.OnLoseFocus = () => name.OnEnterKey(); } - - bool SpawnPointAvailable(int index) { return (index == 0) || orderManager.LobbyInfo.Clients.All(c => c.SpawnPoint != index); } - - void CycleReady() - { - orderManager.IssueOrder(Order.Command("ready")); - } } }