StyleCop
This commit is contained in:
committed by
Paul Chote
parent
634567f98e
commit
e4d5404c6c
@@ -24,15 +24,17 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
PanelType panel = PanelType.Players;
|
||||
|
||||
Widget lobby;
|
||||
Widget EditablePlayerTemplate, NonEditablePlayerTemplate, EmptySlotTemplate,
|
||||
EditableSpectatorTemplate, NonEditableSpectatorTemplate, NewSpectatorTemplate;
|
||||
|
||||
Widget editablePlayerTemplate, nonEditablePlayerTemplate, emptySlotTemplate,
|
||||
editableSpectatorTemplate, nonEditableSpectatorTemplate, newSpectatorTemplate;
|
||||
|
||||
ScrollPanelWidget chatPanel;
|
||||
Widget chatTemplate;
|
||||
|
||||
ScrollPanelWidget Players;
|
||||
Dictionary<string, string> CountryNames;
|
||||
string MapUid;
|
||||
Map Map;
|
||||
ScrollPanelWidget players;
|
||||
Dictionary<string, string> countryNames;
|
||||
string mapUid;
|
||||
Map map;
|
||||
|
||||
ColorPreviewManagerWidget colorPreview;
|
||||
|
||||
@@ -105,54 +107,54 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
name.GetText = () => orderManager.LobbyInfo.GlobalSettings.ServerName;
|
||||
|
||||
UpdateCurrentMap();
|
||||
Players = Ui.LoadWidget<ScrollPanelWidget>("LOBBY_PLAYER_BIN", lobby.Get("PLAYER_BIN_ROOT"), new WidgetArgs());
|
||||
Players.IsVisible = () => panel == PanelType.Players;
|
||||
players = Ui.LoadWidget<ScrollPanelWidget>("LOBBY_PLAYER_BIN", lobby.Get("PLAYER_BIN_ROOT"), new WidgetArgs());
|
||||
players.IsVisible = () => panel == PanelType.Players;
|
||||
|
||||
EditablePlayerTemplate = Players.Get("TEMPLATE_EDITABLE_PLAYER");
|
||||
NonEditablePlayerTemplate = Players.Get("TEMPLATE_NONEDITABLE_PLAYER");
|
||||
EmptySlotTemplate = Players.Get("TEMPLATE_EMPTY");
|
||||
EditableSpectatorTemplate = Players.Get("TEMPLATE_EDITABLE_SPECTATOR");
|
||||
NonEditableSpectatorTemplate = Players.Get("TEMPLATE_NONEDITABLE_SPECTATOR");
|
||||
NewSpectatorTemplate = Players.Get("TEMPLATE_NEW_SPECTATOR");
|
||||
|
||||
var playerBinHeaders = lobby.GetOrNull<ContainerWidget>("LABEL_CONTAINER");
|
||||
if (playerBinHeaders != null)
|
||||
playerBinHeaders.IsVisible = () => panel == PanelType.Players;
|
||||
|
||||
editablePlayerTemplate = players.Get("TEMPLATE_EDITABLE_PLAYER");
|
||||
nonEditablePlayerTemplate = players.Get("TEMPLATE_NONEDITABLE_PLAYER");
|
||||
emptySlotTemplate = players.Get("TEMPLATE_EMPTY");
|
||||
editableSpectatorTemplate = players.Get("TEMPLATE_EDITABLE_SPECTATOR");
|
||||
nonEditableSpectatorTemplate = players.Get("TEMPLATE_NONEDITABLE_SPECTATOR");
|
||||
newSpectatorTemplate = players.Get("TEMPLATE_NEW_SPECTATOR");
|
||||
colorPreview = lobby.Get<ColorPreviewManagerWidget>("COLOR_MANAGER");
|
||||
colorPreview.Color = Game.Settings.Player.Color;
|
||||
|
||||
var mapPreview = lobby.Get<MapPreviewWidget>("MAP_PREVIEW");
|
||||
mapPreview.IsVisible = () => Map != null;
|
||||
mapPreview.Map = () => Map;
|
||||
mapPreview.OnMouseDown = mi => LobbyUtils.SelectSpawnPoint(orderManager, mapPreview, Map, mi);
|
||||
mapPreview.SpawnClients = () => LobbyUtils.GetSpawnClients(orderManager, Map);
|
||||
mapPreview.IsVisible = () => map != null;
|
||||
mapPreview.Map = () => map;
|
||||
mapPreview.OnMouseDown = mi => LobbyUtils.SelectSpawnPoint(orderManager, mapPreview, map, mi);
|
||||
mapPreview.SpawnClients = () => LobbyUtils.GetSpawnClients(orderManager, map);
|
||||
|
||||
var mapTitle = lobby.GetOrNull<LabelWidget>("MAP_TITLE");
|
||||
if (mapTitle != null)
|
||||
{
|
||||
mapTitle.IsVisible = () => Map != null;
|
||||
mapTitle.GetText = () => Map.Title;
|
||||
mapTitle.IsVisible = () => map != null;
|
||||
mapTitle.GetText = () => map.Title;
|
||||
}
|
||||
|
||||
var mapType = lobby.GetOrNull<LabelWidget>("MAP_TYPE");
|
||||
if (mapType != null)
|
||||
{
|
||||
mapType.IsVisible = () => Map != null;
|
||||
mapType.GetText = () => Map.Type;
|
||||
mapType.IsVisible = () => map != null;
|
||||
mapType.GetText = () => map.Type;
|
||||
}
|
||||
|
||||
var mapAuthor = lobby.GetOrNull<LabelWidget>("MAP_AUTHOR");
|
||||
if (mapAuthor != null)
|
||||
{
|
||||
mapAuthor.IsVisible = () => Map != null;
|
||||
mapAuthor.GetText = () => "Created by {0}".F(Map.Author);
|
||||
mapAuthor.IsVisible = () => map != null;
|
||||
mapAuthor.GetText = () => "Created by {0}".F(map.Author);
|
||||
}
|
||||
|
||||
CountryNames = Rules.Info["world"].Traits.WithInterface<CountryInfo>()
|
||||
countryNames = Rules.Info["world"].Traits.WithInterface<CountryInfo>()
|
||||
.Where(c => c.Selectable)
|
||||
.ToDictionary(a => a.Race, a => a.Name);
|
||||
CountryNames.Add("random", "Any");
|
||||
countryNames.Add("random", "Any");
|
||||
|
||||
var gameStarting = false;
|
||||
Func<bool> configurationDisabled = () => !Game.IsHost || gameStarting || panel == PanelType.Kick ||
|
||||
@@ -173,7 +175,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
|
||||
Ui.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs()
|
||||
{
|
||||
{ "initialMap", Map.Uid },
|
||||
{ "initialMap", map.Uid },
|
||||
{ "onExit", () => {} },
|
||||
{ "onSelect", onSelect }
|
||||
});
|
||||
@@ -304,7 +306,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
if (allowCheats != null)
|
||||
{
|
||||
allowCheats.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllowCheats;
|
||||
allowCheats.IsDisabled = () => Map.Options.Cheats.HasValue || configurationDisabled();
|
||||
allowCheats.IsDisabled = () => map.Options.Cheats.HasValue || configurationDisabled();
|
||||
allowCheats.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||
"allowcheats {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowCheats)));
|
||||
}
|
||||
@@ -313,7 +315,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
if (crates != null)
|
||||
{
|
||||
crates.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Crates;
|
||||
crates.IsDisabled = () => Map.Options.Crates.HasValue || configurationDisabled();
|
||||
crates.IsDisabled = () => map.Options.Crates.HasValue || configurationDisabled();
|
||||
crates.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||
"crates {0}".F(!orderManager.LobbyInfo.GlobalSettings.Crates)));
|
||||
}
|
||||
@@ -322,7 +324,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
if (allybuildradius != null)
|
||||
{
|
||||
allybuildradius.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllyBuildRadius;
|
||||
allybuildradius.IsDisabled = () => Map.Options.AllyBuildRadius.HasValue || configurationDisabled();
|
||||
allybuildradius.IsDisabled = () => map.Options.AllyBuildRadius.HasValue || configurationDisabled();
|
||||
allybuildradius.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||
"allybuildradius {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllyBuildRadius)));
|
||||
}
|
||||
@@ -331,7 +333,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
if (fragileAlliance != null)
|
||||
{
|
||||
fragileAlliance.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.FragileAlliances;
|
||||
fragileAlliance.IsDisabled = () => Map.Options.FragileAlliances.HasValue || configurationDisabled();
|
||||
fragileAlliance.IsDisabled = () => map.Options.FragileAlliances.HasValue || configurationDisabled();
|
||||
fragileAlliance.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||
"fragilealliance {0}".F(!orderManager.LobbyInfo.GlobalSettings.FragileAlliances)));
|
||||
}
|
||||
@@ -339,12 +341,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
var difficulty = optionsBin.GetOrNull<DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON");
|
||||
if (difficulty != null)
|
||||
{
|
||||
difficulty.IsVisible = () => Map.Options.Difficulties.Any();
|
||||
difficulty.IsVisible = () => map.Options.Difficulties.Any();
|
||||
difficulty.IsDisabled = configurationDisabled;
|
||||
difficulty.GetText = () => orderManager.LobbyInfo.GlobalSettings.Difficulty;
|
||||
difficulty.OnMouseDown = _ =>
|
||||
{
|
||||
var options = Map.Options.Difficulties.Select(d => new DropDownOption
|
||||
var options = map.Options.Difficulties.Select(d => new DropDownOption
|
||||
{
|
||||
Title = d,
|
||||
IsSelected = () => orderManager.LobbyInfo.GlobalSettings.Difficulty == d,
|
||||
@@ -376,8 +378,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
var classes = Rules.Info["world"].Traits.WithInterface<MPStartUnitsInfo>()
|
||||
.Select(a => a.Class).Distinct();
|
||||
|
||||
startingUnits.IsDisabled = () => !Map.Options.ConfigurableStartingUnits || configurationDisabled();
|
||||
startingUnits.GetText = () => !Map.Options.ConfigurableStartingUnits ? "Not Available" : className(orderManager.LobbyInfo.GlobalSettings.StartingUnitsClass);
|
||||
startingUnits.IsDisabled = () => !map.Options.ConfigurableStartingUnits || configurationDisabled();
|
||||
startingUnits.GetText = () => !map.Options.ConfigurableStartingUnits ? "Not Available" : className(orderManager.LobbyInfo.GlobalSettings.StartingUnitsClass);
|
||||
startingUnits.OnMouseDown = _ =>
|
||||
{
|
||||
var options = classes.Select(c => new DropDownOption
|
||||
@@ -403,8 +405,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
var startingCash = optionsBin.GetOrNull<DropDownButtonWidget>("STARTINGCASH_DROPDOWNBUTTON");
|
||||
if (startingCash != null)
|
||||
{
|
||||
startingCash.IsDisabled = () => Map.Options.StartingCash.HasValue || configurationDisabled();
|
||||
startingCash.GetText = () => Map.Options.StartingCash.HasValue ? "Not Available" : "${0}".F(orderManager.LobbyInfo.GlobalSettings.StartingCash);
|
||||
startingCash.IsDisabled = () => map.Options.StartingCash.HasValue || configurationDisabled();
|
||||
startingCash.GetText = () => map.Options.StartingCash.HasValue ? "Not Available" : "${0}".F(orderManager.LobbyInfo.GlobalSettings.StartingCash);
|
||||
startingCash.OnMouseDown = _ =>
|
||||
{
|
||||
var options = Rules.Info["player"].Traits.Get<PlayerResourcesInfo>().SelectableCash.Select(c => new DropDownOption
|
||||
@@ -429,7 +431,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
if (enableShroud != null)
|
||||
{
|
||||
enableShroud.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Shroud;
|
||||
enableShroud.IsDisabled = () => Map.Options.Shroud.HasValue || configurationDisabled();
|
||||
enableShroud.IsDisabled = () => map.Options.Shroud.HasValue || configurationDisabled();
|
||||
enableShroud.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||
"shroud {0}".F(!orderManager.LobbyInfo.GlobalSettings.Shroud)));
|
||||
}
|
||||
@@ -438,7 +440,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
if (enableFog != null)
|
||||
{
|
||||
enableFog.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Fog;
|
||||
enableFog.IsDisabled = () => Map.Options.Fog.HasValue || configurationDisabled();
|
||||
enableFog.IsDisabled = () => map.Options.Fog.HasValue || configurationDisabled();
|
||||
enableFog.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||
"fog {0}".F(!orderManager.LobbyInfo.GlobalSettings.Fog)));
|
||||
}
|
||||
@@ -525,23 +527,24 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
|
||||
void UpdateCurrentMap()
|
||||
{
|
||||
if (MapUid == orderManager.LobbyInfo.GlobalSettings.Map)
|
||||
if (mapUid == orderManager.LobbyInfo.GlobalSettings.Map)
|
||||
return;
|
||||
MapUid = orderManager.LobbyInfo.GlobalSettings.Map;
|
||||
|
||||
if (!Game.modData.AvailableMaps.ContainsKey (MapUid))
|
||||
mapUid = orderManager.LobbyInfo.GlobalSettings.Map;
|
||||
|
||||
if (!Game.modData.AvailableMaps.ContainsKey(mapUid))
|
||||
if (Game.Settings.Game.AllowDownloading)
|
||||
{
|
||||
Game.DownloadMap (MapUid);
|
||||
Game.DownloadMap(mapUid);
|
||||
Game.Debug("A new map has been downloaded...");
|
||||
}
|
||||
else
|
||||
throw new InvalidOperationException("Server's new map doesn't exist on your system and Downloading turned off");
|
||||
Map = new Map(Game.modData.AvailableMaps[MapUid].Path);
|
||||
map = new Map(Game.modData.AvailableMaps[mapUid].Path);
|
||||
|
||||
// Restore default starting cash if the last map set it to something invalid
|
||||
var pri = Rules.Info["player"].Traits.Get<PlayerResourcesInfo>();
|
||||
if (!Map.Options.StartingCash.HasValue && !pri.SelectableCash.Contains(orderManager.LobbyInfo.GlobalSettings.StartingCash))
|
||||
if (!map.Options.StartingCash.HasValue && !pri.SelectableCash.Contains(orderManager.LobbyInfo.GlobalSettings.StartingCash))
|
||||
orderManager.IssueOrder(Order.Command("startingcash {0}".F(pri.DefaultCash)));
|
||||
}
|
||||
|
||||
@@ -556,14 +559,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
Widget template = null;
|
||||
|
||||
// get template for possible reuse
|
||||
if (idx < Players.Children.Count)
|
||||
template = Players.Children[idx];
|
||||
if (idx < players.Children.Count)
|
||||
template = players.Children[idx];
|
||||
|
||||
// Empty slot
|
||||
if (client == null)
|
||||
{
|
||||
if (template == null || template.Id != EmptySlotTemplate.Id)
|
||||
template = EmptySlotTemplate.Clone();
|
||||
if (template == null || template.Id != emptySlotTemplate.Id)
|
||||
template = emptySlotTemplate.Clone();
|
||||
|
||||
if (Game.IsHost)
|
||||
LobbyUtils.SetupEditableSlotWidget(template, slot, client, orderManager);
|
||||
@@ -580,8 +583,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
else if ((client.Index == orderManager.LocalClient.Index) ||
|
||||
(client.Bot != null && Game.IsHost))
|
||||
{
|
||||
if (template == null || template.Id != EditablePlayerTemplate.Id)
|
||||
template = EditablePlayerTemplate.Clone();
|
||||
if (template == null || template.Id != editablePlayerTemplate.Id)
|
||||
template = editablePlayerTemplate.Clone();
|
||||
|
||||
LobbyUtils.SetupClientWidget(template, slot, client, orderManager, client.Bot == null);
|
||||
|
||||
@@ -591,31 +594,31 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
LobbyUtils.SetupEditableNameWidget(template, slot, client, orderManager);
|
||||
|
||||
LobbyUtils.SetupEditableColorWidget(template, slot, client, orderManager, colorPreview);
|
||||
LobbyUtils.SetupEditableFactionWidget(template, slot, client, orderManager, CountryNames);
|
||||
LobbyUtils.SetupEditableTeamWidget(template, slot, client, orderManager, Map.GetSpawnPoints().Length);
|
||||
LobbyUtils.SetupEditableFactionWidget(template, slot, client, orderManager, countryNames);
|
||||
LobbyUtils.SetupEditableTeamWidget(template, slot, client, orderManager, map.GetSpawnPoints().Length);
|
||||
LobbyUtils.SetupEditableReadyWidget(template, slot, client, orderManager);
|
||||
}
|
||||
else
|
||||
{ // Non-editable player in slot
|
||||
if (template == null || template.Id != NonEditablePlayerTemplate.Id)
|
||||
template = NonEditablePlayerTemplate.Clone();
|
||||
if (template == null || template.Id != nonEditablePlayerTemplate.Id)
|
||||
template = nonEditablePlayerTemplate.Clone();
|
||||
|
||||
LobbyUtils.SetupClientWidget(template, slot, client, orderManager, client.Bot == null);
|
||||
LobbyUtils.SetupNameWidget(template, slot, client);
|
||||
LobbyUtils.SetupKickWidget(template, slot, client, orderManager, lobby,
|
||||
() => panel = PanelType.Kick, () => panel = PanelType.Players);
|
||||
LobbyUtils.SetupColorWidget(template, slot, client);
|
||||
LobbyUtils.SetupFactionWidget(template, slot, client, CountryNames);
|
||||
LobbyUtils.SetupFactionWidget(template, slot, client, countryNames);
|
||||
LobbyUtils.SetupTeamWidget(template, slot, client);
|
||||
LobbyUtils.SetupReadyWidget(template, slot, client);
|
||||
}
|
||||
|
||||
template.IsVisible = () => true;
|
||||
|
||||
if (idx >= Players.Children.Count)
|
||||
Players.AddChild(template);
|
||||
else if (Players.Children[idx].Id != template.Id)
|
||||
Players.ReplaceChild(Players.Children[idx], template);
|
||||
if (idx >= players.Children.Count)
|
||||
players.AddChild(template);
|
||||
else if (players.Children[idx].Id != template.Id)
|
||||
players.ReplaceChild(players.Children[idx], template);
|
||||
|
||||
idx++;
|
||||
}
|
||||
@@ -627,22 +630,22 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
var c = client;
|
||||
|
||||
// get template for possible reuse
|
||||
if (idx < Players.Children.Count)
|
||||
template = Players.Children[idx];
|
||||
if (idx < players.Children.Count)
|
||||
template = players.Children[idx];
|
||||
|
||||
// Editable spectator
|
||||
if (c.Index == orderManager.LocalClient.Index)
|
||||
{
|
||||
if (template == null || template.Id != EditableSpectatorTemplate.Id)
|
||||
template = EditableSpectatorTemplate.Clone();
|
||||
if (template == null || template.Id != editableSpectatorTemplate.Id)
|
||||
template = editableSpectatorTemplate.Clone();
|
||||
|
||||
LobbyUtils.SetupEditableNameWidget(template, null, c, orderManager);
|
||||
}
|
||||
// Non-editable spectator
|
||||
else
|
||||
{
|
||||
if (template == null || template.Id != NonEditableSpectatorTemplate.Id)
|
||||
template = NonEditableSpectatorTemplate.Clone();
|
||||
if (template == null || template.Id != nonEditableSpectatorTemplate.Id)
|
||||
template = nonEditableSpectatorTemplate.Clone();
|
||||
|
||||
LobbyUtils.SetupNameWidget(template, null, client);
|
||||
LobbyUtils.SetupKickWidget(template, null, client, orderManager, lobby,
|
||||
@@ -652,10 +655,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
LobbyUtils.SetupClientWidget(template, null, c, orderManager, true);
|
||||
template.IsVisible = () => true;
|
||||
|
||||
if (idx >= Players.Children.Count)
|
||||
Players.AddChild(template);
|
||||
else if (Players.Children[idx].Id != template.Id)
|
||||
Players.ReplaceChild(Players.Children[idx], template);
|
||||
if (idx >= players.Children.Count)
|
||||
players.AddChild(template);
|
||||
else if (players.Children[idx].Id != template.Id)
|
||||
players.ReplaceChild(players.Children[idx], template);
|
||||
|
||||
idx++;
|
||||
}
|
||||
@@ -664,10 +667,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
if (orderManager.LocalClient.Slot != null)
|
||||
{
|
||||
Widget spec = null;
|
||||
if (idx < Players.Children.Count)
|
||||
spec = Players.Children[idx];
|
||||
if (spec == null || spec.Id != NewSpectatorTemplate.Id)
|
||||
spec = NewSpectatorTemplate.Clone();
|
||||
if (idx < players.Children.Count)
|
||||
spec = players.Children[idx];
|
||||
if (spec == null || spec.Id != newSpectatorTemplate.Id)
|
||||
spec = newSpectatorTemplate.Clone();
|
||||
|
||||
LobbyUtils.SetupKickSpectatorsWidget(spec, orderManager, lobby,
|
||||
() => panel = PanelType.Kick, () => panel = PanelType.Players, this.skirmishMode);
|
||||
@@ -679,17 +682,17 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
|| orderManager.LocalClient.IsAdmin;
|
||||
|
||||
spec.IsVisible = () => true;
|
||||
|
||||
if (idx >= Players.Children.Count)
|
||||
Players.AddChild(spec);
|
||||
else if (Players.Children[idx].Id != spec.Id)
|
||||
Players.ReplaceChild(Players.Children[idx], spec);
|
||||
|
||||
if (idx >= players.Children.Count)
|
||||
players.AddChild(spec);
|
||||
else if (players.Children[idx].Id != spec.Id)
|
||||
players.ReplaceChild(players.Children[idx], spec);
|
||||
|
||||
idx++;
|
||||
}
|
||||
|
||||
while (Players.Children.Count > idx)
|
||||
Players.RemoveChild(Players.Children[idx]);
|
||||
while (players.Children.Count > idx)
|
||||
players.RemoveChild(players.Children[idx]);
|
||||
}
|
||||
|
||||
class DropDownOption
|
||||
|
||||
Reference in New Issue
Block a user