Rename LobbyCountry to LobbyFaction
This commit is contained in:
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
readonly ScrollPanelWidget players;
|
||||
|
||||
readonly Dictionary<string, LobbyCountry> countries = new Dictionary<string, LobbyCountry>();
|
||||
readonly Dictionary<string, LobbyFaction> factions = new Dictionary<string, LobbyFaction>();
|
||||
|
||||
readonly ColorPreviewManagerWidget colorPreview;
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
colorPreview.Color = Game.Settings.Player.Color;
|
||||
|
||||
foreach (var f in modRules.Actors["world"].Traits.WithInterface<FactionInfo>())
|
||||
countries.Add(f.InternalName, new LobbyCountry { Selectable = f.Selectable, Name = f.Name, Side = f.Side, Description = f.Description });
|
||||
factions.Add(f.InternalName, new LobbyFaction { Selectable = f.Selectable, Name = f.Name, Side = f.Side, Description = f.Description });
|
||||
|
||||
var gameStarting = false;
|
||||
Func<bool> configurationDisabled = () => !Game.IsHost || gameStarting ||
|
||||
@@ -714,7 +714,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
LobbyUtils.SetupEditableNameWidget(template, slot, client, orderManager);
|
||||
|
||||
LobbyUtils.SetupEditableColorWidget(template, slot, client, orderManager, shellmapWorld, colorPreview);
|
||||
LobbyUtils.SetupEditableFactionWidget(template, slot, client, orderManager, countries);
|
||||
LobbyUtils.SetupEditableFactionWidget(template, slot, client, orderManager, factions);
|
||||
LobbyUtils.SetupEditableTeamWidget(template, slot, client, orderManager, Map);
|
||||
LobbyUtils.SetupEditableSpawnWidget(template, slot, client, orderManager, Map);
|
||||
LobbyUtils.SetupEditableReadyWidget(template, slot, client, orderManager, Map);
|
||||
@@ -730,7 +730,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
LobbyUtils.SetupKickWidget(template, slot, client, orderManager, lobby,
|
||||
() => panel = PanelType.Kick, () => panel = PanelType.Players);
|
||||
LobbyUtils.SetupColorWidget(template, slot, client);
|
||||
LobbyUtils.SetupFactionWidget(template, slot, client, countries);
|
||||
LobbyUtils.SetupFactionWidget(template, slot, client, factions);
|
||||
LobbyUtils.SetupTeamWidget(template, slot, client);
|
||||
LobbyUtils.SetupSpawnWidget(template, slot, client);
|
||||
LobbyUtils.SetupReadyWidget(template, slot, client);
|
||||
@@ -834,7 +834,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
}
|
||||
|
||||
public class LobbyCountry
|
||||
public class LobbyFaction
|
||||
{
|
||||
public bool Selectable;
|
||||
public string Name;
|
||||
|
||||
@@ -105,24 +105,24 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
public static void ShowRaceDropDown(DropDownButtonWidget dropdown, Session.Client client,
|
||||
OrderManager orderManager, Dictionary<string, LobbyCountry> countries)
|
||||
OrderManager orderManager, Dictionary<string, LobbyFaction> factions)
|
||||
{
|
||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (race, itemTemplate) =>
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => client.Race == race,
|
||||
() => orderManager.IssueOrder(Order.Command("race {0} {1}".F(client.Index, race))));
|
||||
var country = countries[race];
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => country.Name;
|
||||
var faction = factions[race];
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => faction.Name;
|
||||
var flag = item.Get<ImageWidget>("FLAG");
|
||||
flag.GetImageCollection = () => "flags";
|
||||
flag.GetImageName = () => race;
|
||||
item.GetTooltipText = () => country.Description;
|
||||
item.GetTooltipText = () => faction.Description;
|
||||
return item;
|
||||
};
|
||||
|
||||
var options = countries.Where(c => c.Value.Selectable).GroupBy(c => c.Value.Side)
|
||||
.ToDictionary(g => g.Key ?? "", g => g.Select(c => c.Key));
|
||||
var options = factions.Where(f => f.Value.Selectable).GroupBy(f => f.Value.Side)
|
||||
.ToDictionary(g => g.Key ?? "", g => g.Select(f => f.Key));
|
||||
|
||||
dropdown.ShowDropDown("RACE_DROPDOWN_TEMPLATE", 150, options, setupItem);
|
||||
}
|
||||
@@ -395,21 +395,21 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
public static void SetupEditableFactionWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager,
|
||||
Dictionary<string, LobbyCountry> countries)
|
||||
Dictionary<string, LobbyFaction> factions)
|
||||
{
|
||||
var dropdown = parent.Get<DropDownButtonWidget>("FACTION");
|
||||
dropdown.IsDisabled = () => s.LockRace || orderManager.LocalClient.IsReady;
|
||||
dropdown.OnMouseDown = _ => ShowRaceDropDown(dropdown, c, orderManager, countries);
|
||||
var factionDescription = countries[c.Race].Description;
|
||||
dropdown.OnMouseDown = _ => ShowRaceDropDown(dropdown, c, orderManager, factions);
|
||||
var factionDescription = factions[c.Race].Description;
|
||||
dropdown.GetTooltipText = () => factionDescription;
|
||||
SetupFactionWidget(dropdown, s, c, countries);
|
||||
SetupFactionWidget(dropdown, s, c, factions);
|
||||
}
|
||||
|
||||
public static void SetupFactionWidget(Widget parent, Session.Slot s, Session.Client c,
|
||||
Dictionary<string, LobbyCountry> countries)
|
||||
Dictionary<string, LobbyFaction> factions)
|
||||
{
|
||||
var factionName = parent.Get<LabelWidget>("FACTIONNAME");
|
||||
factionName.GetText = () => countries[c.Race].Name;
|
||||
factionName.GetText = () => factions[c.Race].Name;
|
||||
var factionFlag = parent.Get<ImageWidget>("FACTIONFLAG");
|
||||
factionFlag.GetImageName = () => c.Race;
|
||||
factionFlag.GetImageCollection = () => "flags";
|
||||
|
||||
Reference in New Issue
Block a user