Fix StyleCop warnings in OpenRA.Mods.RA

This commit is contained in:
Hellhake
2015-01-01 23:03:55 +01:00
parent e9989496c4
commit b6410bc1e0
134 changed files with 261 additions and 267 deletions

View File

@@ -10,10 +10,10 @@
using System;
using System.Linq;
using OpenRA.Mods.Common.Widgets;
using OpenRA.Mods.RA.Widgets;
using OpenRA.Network;
using OpenRA.Widgets;
using OpenRA.Mods.Common.Widgets;
namespace OpenRA.Mods.RA.Widgets.Logic
{

View File

@@ -46,8 +46,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
tooltipContainer.BeforeRender = () =>
{
var latencyPrefixSize = latencyPrefix.Bounds.X + latencyPrefixFont.Measure(latencyPrefix.GetText() + " ").X;
var width = Math.Max(locationFont.Measure(location.GetText()).X, Math.Max(adminFont.Measure(admin.GetText()).X,
Math.Max(addressFont.Measure(ip.GetText()).X, latencyPrefixSize + latencyFont.Measure(latency.GetText()).X)));
var width = Math.Max(locationFont.Measure(location.GetText()).X, Math.Max(adminFont.Measure(admin.GetText()).X, Math.Max(addressFont.Measure(ip.GetText()).X, latencyPrefixSize + latencyFont.Measure(latency.GetText()).X)));
widget.Bounds.Width = width + 2 * margin;
latency.Bounds.Width = widget.Bounds.Width;
ip.Bounds.Width = widget.Bounds.Width;

View File

@@ -9,8 +9,8 @@
#endregion
using System;
using OpenRA.Support;
using OpenRA.Mods.RA.Traits;
using OpenRA.Support;
using OpenRA.Traits;
using OpenRA.Widgets;

View File

@@ -81,7 +81,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Func<Stance, ScrollItemWidget, ScrollItemWidget> setupItem = (s, template) =>
{
var item = ScrollItemWidget.Setup(template,
() => s == world.LocalPlayer.Stances[ p ],
() => s == world.LocalPlayer.Stances[p],
() => SetStance(dropdown, p, s));
item.Get<LabelWidget>("LABEL").GetText = () => s.ToString();

View File

@@ -76,8 +76,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
dataReceived = i.BytesReceived / (float)(1L << (mag * 10));
dataSuffix = SizeSuffixes[mag];
}
progressBar.Indeterminate = false;
progressBar.Percentage = i.ProgressPercentage;
@@ -143,6 +142,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (!string.IsNullOrEmpty(line))
mirrorList.Add(line);
}
mirror = mirrorList.Random(new MersenneTwister());
// Save the package to a temp file

View File

@@ -10,9 +10,9 @@
using System;
using System.Linq;
using OpenRA.Widgets;
using OpenRA.Traits;
using OpenRA.Mods.RA;
using OpenRA.Traits;
using OpenRA.Widgets;
namespace OpenRA.Mods.RA.Widgets.Logic
{

View File

@@ -10,13 +10,13 @@
using System;
using System.Linq;
using OpenRA.Widgets;
using OpenRA.Traits;
using OpenRA.Mods.RA;
using OpenRA.Traits;
using OpenRA.Widgets;
namespace OpenRA.Mods.RA.Widgets.Logic
{
public enum IngameInfoPanel { AutoSelect, Map, Objectives, Debug };
public enum IngameInfoPanel { AutoSelect, Map, Objectives, Debug }
class GameInfoLogic
{

View File

@@ -9,8 +9,8 @@
#endregion
using System;
using System.Linq;
using System.Drawing;
using System.Linq;
using OpenRA.Mods.Common.Traits;
using OpenRA.Traits;
using OpenRA.Widgets;

View File

@@ -11,9 +11,9 @@
using System;
using System.Drawing;
using System.Linq;
using OpenRA.Widgets;
using OpenRA.Traits;
using OpenRA.Mods.RA;
using OpenRA.Traits;
using OpenRA.Widgets;
namespace OpenRA.Mods.RA.Widgets.Logic
{

View File

@@ -9,8 +9,8 @@
#endregion
using System.Drawing;
using OpenRA.Mods.Common.Widgets;
using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.Common.Widgets;
using OpenRA.Widgets;
namespace OpenRA.Mods.RA.Widgets.Logic

View File

@@ -9,8 +9,8 @@
#endregion
using System.Drawing;
using OpenRA.Mods.Common.Widgets;
using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.Common.Widgets;
using OpenRA.Widgets;
namespace OpenRA.Mods.RA.Widgets.Logic

View File

@@ -123,6 +123,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
return false;
};
}
chatScrollPanel = chatChrome.Get<ScrollPanelWidget>("CHAT_SCROLLPANEL");
chatTemplate = chatScrollPanel.Get<ContainerWidget>("CHAT_TEMPLATE");
chatScrollPanel.RemoveChildren();

View File

@@ -46,6 +46,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Game.RunAfterDelay(exitDelay, () => mpe.Fade(MenuPaletteEffect.EffectType.Black));
exitDelay += 40 * mpe.Info.FadeLength;
}
Game.RunAfterDelay(exitDelay, () =>
{
Game.Disconnect();

View File

@@ -90,7 +90,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var onError = (Action<string>)(s => Game.RunAfterTick(() =>
{
statusLabel.GetText = () => "Error: "+s;
statusLabel.GetText = () => "Error: " + s;
backButton.IsDisabled = () => false;
retryButton.IsDisabled = () => false;
}));
@@ -121,7 +121,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
continueLoading();
});
}
catch(Exception e)
catch (Exception e)
{
onError("Installation failed.\n{0}".F(e.Message));
Log.Write("debug", e.ToString());

View File

@@ -653,7 +653,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
}).Start();
}
else if (Game.Settings.Game.AllowDownloading)
Game.modData.MapCache.QueryRemoteMapDetails(new [] { uid });
Game.modData.MapCache.QueryRemoteMapDetails(new[] { uid });
}
void UpdatePlayerList()

View File

@@ -143,7 +143,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (lobby.Map.Status == MapStatus.DownloadError)
lobby.Map.Install();
else if (lobby.Map.Status == MapStatus.Unavailable)
Game.modData.MapCache.QueryRemoteMapDetails(new [] { lobby.Map.Uid });
Game.modData.MapCache.QueryRemoteMapDetails(new[] { lobby.Map.Uid });
};
retry.GetText = () => lobby.Map.Status == MapStatus.DownloadError ? "Retry Install" : "Retry Search";

View File

@@ -41,11 +41,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public static void ShowSlotDropDown(Ruleset rules, DropDownButtonWidget dropdown, Session.Slot slot,
Session.Client client, OrderManager orderManager)
{
var options = new Dictionary<string, IEnumerable<SlotDropDownOption>>() {{"Slot", new List<SlotDropDownOption>()
var options = new Dictionary<string, IEnumerable<SlotDropDownOption>>() { { "Slot", new List<SlotDropDownOption>()
{
new SlotDropDownOption("Open", "slot_open "+slot.PlayerReference, () => (!slot.Closed && client == null)),
new SlotDropDownOption("Closed", "slot_close "+slot.PlayerReference, () => slot.Closed)
}}};
new SlotDropDownOption("Open", "slot_open " + slot.PlayerReference, () => (!slot.Closed && client == null)),
new SlotDropDownOption("Closed", "slot_close " + slot.PlayerReference, () => slot.Closed)
} } };
var bots = new List<SlotDropDownOption>();
if (slot.AllowBots)
@@ -59,6 +59,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
() => client != null && client.Bot == bot));
}
}
options.Add(bots.Any() ? "Bots" : "Bots Disabled", bots);
Func<SlotDropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
@@ -350,8 +351,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
orderManager.IssueOrders(
orderManager.LobbyInfo.Clients.Where(
c => c.IsObserver && !c.IsAdmin).Select(
client => Order.Command(String.Format("kick {0} {1}", client.Index, client.Name
))).ToArray());
client => Order.Command("kick {0} {1}".F(client.Index, client.Name))).ToArray());
after();
};
@@ -431,8 +431,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
var dropdown = parent.Get<DropDownButtonWidget>("SPAWN");
dropdown.IsDisabled = () => s.LockSpawn || orderManager.LocalClient.IsReady;
dropdown.OnMouseDown = _ => ShowSpawnDropDown(dropdown, c, orderManager, Enumerable.Range(0, map.SpawnPoints.Count + 1)
.Except(orderManager.LobbyInfo.Clients.Where(client => client != c && client.SpawnPoint != 0).Select(client => client.SpawnPoint)));
dropdown.OnMouseDown = _ => ShowSpawnDropDown(dropdown, c, orderManager, Enumerable.Range(0, map.SpawnPoints.Count + 1).Except(orderManager.LobbyInfo.Clients.Where(client => client != c && client.SpawnPoint != 0).Select(client => client.SpawnPoint)));
dropdown.GetText = () => (c.SpawnPoint == 0) ? "-" : Convert.ToChar('A' - 1 + c.SpawnPoint).ToString();
}

View File

@@ -86,6 +86,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
mapFilter = mapfilterInput.Text = null;
EnumerateMaps(onSelect, filter);
}
return true;
};
mapfilterInput.OnEnterKey = () => { approving(); return true; };

View File

@@ -115,7 +115,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
currentSong = song;
// TODO: We leak the currentSong MusicInfo across map load, so compare the Filename instead.
var item = ScrollItemWidget.Setup(song.Filename, itemTemplate, () => currentSong.Filename == song.Filename, () => { currentSong = song; Play(); }, () => {});
var item = ScrollItemWidget.Setup(song.Filename, itemTemplate, () => currentSong.Filename == song.Filename, () => { currentSong = song; Play(); }, () => { });
item.Get<LabelWidget>("TITLE").GetText = () => song.Title;
item.Get<LabelWidget>("LENGTH").GetText = () => SongLengthLabel(song);
musicList.AddChild(item);

View File

@@ -168,8 +168,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
players.Select(p => new LineGraphSeries(
p.PlayerName,
p.Color.RGB,
(p.PlayerActor.TraitOrDefault<PlayerStatistics>() ?? new PlayerStatistics(p.PlayerActor)).EarnedSamples.Select(s => (float)s)
));
(p.PlayerActor.TraitOrDefault<PlayerStatistics>() ?? new PlayerStatistics(p.PlayerActor)).EarnedSamples.Select(s => (float)s)));
playerStatsPanel.AddChild(template);
}

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
public class ServerBrowserLogic
{
readonly static Action DoNothing = () => { };
static readonly Action DoNothing = () => { };
GameServer currentServer;
ScrollItemWidget serverTemplate;
@@ -159,7 +159,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Game.RunAfterTick(() => RefreshServerListInner(games));
};
currentQuery = new Download(Game.Settings.Server.MasterServer + "games", _ => {}, onComplete);
currentQuery = new Download(Game.Settings.Server.MasterServer + "games", _ => { }, onComplete);
}
int GroupSortOrder(GameServer testEntry)
@@ -191,7 +191,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (modGames.All(Filtered))
continue;
var header = ScrollItemWidget.Setup(headerTemplate, () => true, () => {});
var header = ScrollItemWidget.Setup(headerTemplate, () => true, () => { });
var headerTitle = modGames.First().ModLabel;
header.Get<LabelWidget>("LABEL").GetText = () => headerTitle;
@@ -246,7 +246,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (ip != null)
{
ip.GetText = () => game.Address;
ip.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : ip.TextColor;
ip.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : ip.TextColor;
}
var location = item.GetOrNull<LabelWidget>("LOCATION");

View File

@@ -44,8 +44,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Ui.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs()
{
{ "initialMap", preview.Uid },
{ "onExit", () => {} },
{ "onSelect", (Action<String>)(uid => preview = Game.modData.MapCache[uid]) }
{ "onExit", () => { } },
{ "onSelect", (Action<string>)(uid => preview = Game.modData.MapCache[uid]) }
});
};

View File

@@ -30,12 +30,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (textWidth != cachedWidth)
{
label.Bounds.Width = textWidth;
widget.Bounds.Width = 2*label.Bounds.X + textWidth;
widget.Bounds.Width = 2 * label.Bounds.X + textWidth;
}
};
label.GetText = () => labelText;
}
}
}
}

View File

@@ -63,10 +63,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (textWidth != cachedWidth)
{
label.Bounds.Width = textWidth;
widget.Bounds.Width = 2*label.Bounds.X + textWidth;
widget.Bounds.Width = 2 * label.Bounds.X + textWidth;
}
widget.Bounds.Width = Math.Max(teamWidth + 2*labelMargin, label.Bounds.Right + labelMargin);
widget.Bounds.Width = Math.Max(teamWidth + 2 * labelMargin, label.Bounds.Right + labelMargin);
team.Bounds.Width = widget.Bounds.Width;
};
@@ -78,5 +78,4 @@ namespace OpenRA.Mods.RA.Widgets.Logic
team.IsVisible = () => playerTeam > 0;
}
}
}
}

View File

@@ -60,6 +60,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
suffix = ": ";
toComplete = text;
}
candidates = Names.Where(x => x.StartsWith(toComplete, StringComparison.InvariantCultureIgnoreCase)).ToList();
}
else

View File

@@ -55,16 +55,17 @@ namespace OpenRA.Mods.RA.Widgets.Logic
o = viewport.ActorTooltip.Owner;
showOwner = !o.NonCombatant && viewport.ActorTooltip.TooltipInfo.IsOwnerRowVisible;
var stance = o == null || world.RenderPlayer == null? Stance.None : o.Stances[world.RenderPlayer];
var stance = o == null || world.RenderPlayer == null ? Stance.None : o.Stances[world.RenderPlayer];
labelText = viewport.ActorTooltip.TooltipInfo.TooltipForPlayerStance(stance);
break;
}
case WorldTooltipType.FrozenActor:
{
o = viewport.FrozenActorTooltip.TooltipOwner;
showOwner = !o.NonCombatant && viewport.FrozenActorTooltip.TooltipInfo.IsOwnerRowVisible;
var stance = o == null || world.RenderPlayer == null? Stance.None : o.Stances[world.RenderPlayer];
var stance = o == null || world.RenderPlayer == null ? Stance.None : o.Stances[world.RenderPlayer];
labelText = viewport.FrozenActorTooltip.TooltipInfo.TooltipForPlayerStance(stance);
break;
}
@@ -74,7 +75,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (textWidth != cachedWidth)
{
label.Bounds.Width = textWidth;
widget.Bounds.Width = 2*label.Bounds.X + textWidth;
widget.Bounds.Width = 2 * label.Bounds.X + textWidth;
}
if (showOwner)
@@ -100,4 +101,3 @@ namespace OpenRA.Mods.RA.Widgets.Logic
}
}
}

View File

@@ -53,6 +53,7 @@ namespace OpenRA.Mods.RA.Widgets
{
return;
}
var queues = world.ActorsWithTrait<ProductionQueue>()
.Where(a => a.Actor.Owner == player)
.Select((a, i) => new { a.Trait, i });

View File

@@ -33,7 +33,6 @@ namespace OpenRA.Mods.RA.Widgets
[ObjectCreator.UseCtor]
public ObserverSupportPowerIconsWidget(World world, WorldRenderer worldRenderer)
{
this.world = world;
this.worldRenderer = worldRenderer;
clocks = new Dictionary<string, Animation>();
@@ -57,6 +56,7 @@ namespace OpenRA.Mods.RA.Widgets
{
return;
}
var powers = player.PlayerActor.Trait<SupportPowerManager>().Powers
.Select((a, i) => new { a, i });
foreach (var power in powers)

View File

@@ -14,8 +14,8 @@ using System.Drawing;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.RA.Traits;
using OpenRA.Mods.RA.Orders;
using OpenRA.Mods.RA.Traits;
using OpenRA.Network;
using OpenRA.Widgets;
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.RA.Widgets
[Translate] public readonly string HoldText = "";
public int IconCount { get; private set; }
public event Action<int, int> OnIconCountChanged = (a, b) => {};
public event Action<int, int> OnIconCountChanged = (a, b) => { };
public ProductionIcon TooltipIcon { get; private set; }
public readonly World World;
@@ -293,13 +293,9 @@ namespace OpenRA.Mods.RA.Widgets
if (first.Done)
{
if (ReadyTextStyle == ReadyTextStyleOptions.Solid || orderManager.LocalFrameNumber / 9 % 2 == 0)
overlayFont.DrawTextWithContrast(ReadyText,
icon.Pos + readyOffset,
Color.White, Color.Black, 1);
overlayFont.DrawTextWithContrast(ReadyText, icon.Pos + readyOffset, Color.White, Color.Black, 1);
else if (ReadyTextStyle == ReadyTextStyleOptions.AlternatingColor)
overlayFont.DrawTextWithContrast(ReadyText,
icon.Pos + readyOffset,
ReadyTextAltColor, Color.Black, 1);
overlayFont.DrawTextWithContrast(ReadyText, icon.Pos + readyOffset, ReadyTextAltColor, Color.Black, 1);
}
else if (first.Paused)
overlayFont.DrawTextWithContrast(HoldText,

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA.Widgets
public readonly string TooltipTemplate = "SUPPORT_POWER_TOOLTIP";
public int IconCount { get; private set; }
public event Action<int, int> OnIconCountChanged = (a, b) => {};
public event Action<int, int> OnIconCountChanged = (a, b) => { };
readonly WorldRenderer worldRenderer;
readonly SupportPowerManager spm;
@@ -191,4 +191,4 @@ namespace OpenRA.Mods.RA.Widgets
return true;
}
}
}
}

View File

@@ -63,8 +63,7 @@ namespace OpenRA.Mods.RA.Widgets
if (key == ks.ToSelectionKey)
return ToSelection();
// Put all functions that aren't unit-specific before this line!
if (!world.Selection.Actors.Any())
return false;