Facilitated spawn choice at game setup screen.

This commit is contained in:
Matija H
2014-04-25 21:56:01 +01:00
committed by matija-hustic
parent a7c77d4155
commit a0f6038ea6
17 changed files with 175 additions and 54 deletions

View File

@@ -608,6 +608,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
LobbyUtils.SetupEditableColorWidget(template, slot, client, orderManager, colorPreview);
LobbyUtils.SetupEditableFactionWidget(template, slot, client, orderManager, countryNames);
LobbyUtils.SetupEditableTeamWidget(template, slot, client, orderManager, Map);
LobbyUtils.SetupEditableSpawnWidget(template, slot, client, orderManager, Map);
LobbyUtils.SetupEditableReadyWidget(template, slot, client, orderManager, Map);
}
else
@@ -623,6 +624,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
LobbyUtils.SetupColorWidget(template, slot, client);
LobbyUtils.SetupFactionWidget(template, slot, client, countryNames);
LobbyUtils.SetupTeamWidget(template, slot, client);
LobbyUtils.SetupSpawnWidget(template, slot, client);
LobbyUtils.SetupReadyWidget(template, slot, client);
}

View File

@@ -88,6 +88,22 @@ namespace OpenRA.Mods.RA.Widgets.Logic
dropdown.ShowDropDown("TEAM_DROPDOWN_TEMPLATE", 150, options, setupItem);
}
public static void ShowSpawnDropDown(DropDownButtonWidget dropdown, Session.Client client,
OrderManager orderManager, int teamCount)
{
Func<int, ScrollItemWidget, ScrollItemWidget> setupItem = (ii, itemTemplate) =>
{
var item = ScrollItemWidget.Setup(itemTemplate,
() => client.SpawnPoint == ii,
() => orderManager.IssueOrder(Order.Command("spawn {0} {1}".F(client.Index, ii))));
item.Get<LabelWidget>("LABEL").GetText = () => ii == 0 ? "-" : ii.ToString();
return item;
};
var options = Exts.MakeArray(teamCount + 1, i => i).ToList();
dropdown.ShowDropDown("SPAWN_DROPDOWN_TEMPLATE", 150, options, setupItem);
}
public static void ShowRaceDropDown(DropDownButtonWidget dropdown, Session.Client client,
OrderManager orderManager, Dictionary<string, string> countryNames)
{
@@ -384,6 +400,19 @@ namespace OpenRA.Mods.RA.Widgets.Logic
parent.Get<LabelWidget>("TEAM").GetText = () => (c.Team == 0) ? "-" : c.Team.ToString();
}
public static void SetupEditableSpawnWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, MapPreview map)
{
var dropdown = parent.Get<DropDownButtonWidget>("SPAWN");
dropdown.IsDisabled = () => s.LockSpawn || orderManager.LocalClient.IsReady;
dropdown.OnMouseDown = _ => ShowSpawnDropDown(dropdown, c, orderManager, map.PlayerCount);
dropdown.GetText = () => (c.SpawnPoint == 0) ? "-" : c.SpawnPoint.ToString();
}
public static void SetupSpawnWidget(Widget parent, Session.Slot s, Session.Client c)
{
parent.Get<LabelWidget>("SPAWN").GetText = () => (c.SpawnPoint == 0) ? "-" : c.SpawnPoint.ToString();
}
public static void SetupEditableReadyWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, MapPreview map)
{
var status = parent.Get<CheckboxWidget>("STATUS_CHECKBOX");