move SetupNameWidget function into new LobbyUtils static class

This commit is contained in:
Chris Forbes
2011-10-06 22:37:26 +13:00
parent d3b5939613
commit 2a48e01d91

View File

@@ -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<TextFieldWidget>("NAME"));
LobbyUtils.SetupNameWidget(orderManager, c, template.GetWidget<TextFieldWidget>("NAME"));
var color = template.GetWidget<DropDownButtonWidget>("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<TextFieldWidget>("NAME"));
LobbyUtils.SetupNameWidget(orderManager, c, template.GetWidget<TextFieldWidget>("NAME"));
var color = template.GetWidget<DropDownButtonWidget>("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"));
}
}
}