StyleCop clean OpenRA.Game

This commit is contained in:
Matthias Mailänder
2015-01-04 11:56:13 +01:00
parent d2d715765c
commit bc3acfeee7
345 changed files with 835 additions and 833 deletions

View File

@@ -52,9 +52,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var cancelButton = panel.Get<ButtonWidget>("CANCEL_BUTTON");
var mirrorsFile = Platform.ResolvePath("^", "Content", Game.modData.Manifest.Mod.Id, "mirrors.txt");
var mirrorsFile = Platform.ResolvePath("^", "Content", Game.ModData.Manifest.Mod.Id, "mirrors.txt");
var file = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
var dest = Platform.ResolvePath("^", "Content", Game.modData.Manifest.Mod.Id);
var dest = Platform.ResolvePath("^", "Content", Game.ModData.Manifest.Mod.Id);
Action<DownloadProgressChangedEventArgs> onDownloadProgress = i =>
{

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public GameInfoBriefingLogic(Widget widget, World world)
{
var previewWidget = widget.Get<MapPreviewWidget>("MAP_PREVIEW");
previewWidget.Preview = () => Game.modData.MapCache[world.Map.Uid];
previewWidget.Preview = () => Game.ModData.MapCache[world.Map.Uid];
var mapDescriptionPanel = widget.Get<ScrollPanelWidget>("MAP_DESCRIPTION_PANEL");
var mapDescription = widget.Get<LabelWidget>("MAP_DESCRIPTION");

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Widgets
if (mpe != null)
mpe.Fade(mpe.Info.MenuEffect);
widget.Get<LabelWidget>("VERSION_LABEL").Text = Game.modData.Manifest.Mod.Version;
widget.Get<LabelWidget>("VERSION_LABEL").Text = Game.ModData.Manifest.Mod.Version;
var showStats = false;

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (mpe != null)
mpe.Fade(mpe.Info.MenuEffect);
menu.Get<LabelWidget>("VERSION_LABEL").Text = Game.modData.Manifest.Mod.Version;
menu.Get<LabelWidget>("VERSION_LABEL").Text = Game.ModData.Manifest.Mod.Version;
var hideMenu = false;
menu.Get("MENU_BUTTONS").IsVisible = () => !hideMenu;

View File

@@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
bool IsValidDisk(string diskRoot)
{
return Game.modData.Manifest.ContentInstaller.DiskTestFiles.All(f => File.Exists(Path.Combine(diskRoot, f)));
return Game.ModData.Manifest.ContentInstaller.DiskTestFiles.All(f => File.Exists(Path.Combine(diskRoot, f)));
}
void CheckForDisk()
@@ -69,14 +69,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
insertDiskContainer.IsVisible = () => false;
installingContainer.IsVisible = () => true;
var dest = Platform.ResolvePath("^", "Content", Game.modData.Manifest.Mod.Id);
var copyFiles = Game.modData.Manifest.ContentInstaller.CopyFilesFromCD;
var dest = Platform.ResolvePath("^", "Content", Game.ModData.Manifest.Mod.Id);
var copyFiles = Game.ModData.Manifest.ContentInstaller.CopyFilesFromCD;
var packageToExtract = Game.modData.Manifest.ContentInstaller.PackageToExtractFromCD.Split(':');
var packageToExtract = Game.ModData.Manifest.ContentInstaller.PackageToExtractFromCD.Split(':');
var extractPackage = packageToExtract.First();
var annotation = packageToExtract.Length > 1 ? packageToExtract.Last() : null;
var extractFiles = Game.modData.Manifest.ContentInstaller.ExtractFilesFromCD;
var extractFiles = Game.ModData.Manifest.ContentInstaller.ExtractFilesFromCD;
var installCounter = 0;
var installTotal = copyFiles.Count() + extractFiles.Count();

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
[ObjectCreator.UseCtor]
public InstallLogic(Widget widget, Action continueLoading)
{
var mirrorListUrl = Game.modData.Manifest.ContentInstaller.PackageMirrorList;
var mirrorListUrl = Game.ModData.Manifest.ContentInstaller.PackageMirrorList;
var panel = widget.Get("INSTALL_PANEL");
var widgetArgs = new WidgetArgs()
{
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = () =>
{
Game.Settings.Game.PreviousMod = Game.modData.Manifest.Mod.Id;
Game.Settings.Game.PreviousMod = Game.ModData.Manifest.Mod.Id;
Game.InitializeMod("modchooser", null);
};
}

View File

@@ -44,7 +44,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var downloadButton = installMusicContainer.GetOrNull<ButtonWidget>("DOWNLOAD_BUTTON");
if (downloadButton != null)
{
var mirrorListUrl = Game.modData.Manifest.ContentInstaller.MusicPackageMirrorList;
var mirrorListUrl = Game.ModData.Manifest.ContentInstaller.MusicPackageMirrorList;
downloadButton.IsVisible = () => !string.IsNullOrEmpty(mirrorListUrl);
downloadButton.OnClick = () =>
{

View File

@@ -625,7 +625,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (Map.Uid == uid)
return;
Map = Game.modData.MapCache[uid];
Map = Game.ModData.MapCache[uid];
if (Map.Status == MapStatus.Available)
{
// Maps need to be validated and pre-loaded before they can be accessed
@@ -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

@@ -177,7 +177,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (!orderManager.LocalClient.IsObserver && orderManager.LocalClient.State == Session.ClientState.Ready)
return;
var spawnSize = new float2(ChromeProvider.GetImage("lobby-bits", "spawn-unclaimed").bounds.Size);
var spawnSize = new float2(ChromeProvider.GetImage("lobby-bits", "spawn-unclaimed").Bounds.Size);
var selectedSpawn = preview.SpawnPoints
.Select((sp, i) => Pair.New(mapPreview.ConvertToPreview(sp), i))
.Where(a => ((a.First - mi.Location).ToFloat2() / spawnSize * 2).LengthSquared <= 1)

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public MainMenuLogic(Widget widget, World world)
{
rootMenu = widget;
rootMenu.Get<LabelWidget>("VERSION_LABEL").Text = Game.modData.Manifest.Mod.Version;
rootMenu.Get<LabelWidget>("VERSION_LABEL").Text = Game.ModData.Manifest.Mod.Version;
// Menu buttons
var mainMenu = widget.Get("MAIN_MENU");
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
mainMenu.Get<ButtonWidget>("MODS_BUTTON").OnClick = () =>
{
Game.Settings.Game.PreviousMod = Game.modData.Manifest.Mod.Id;
Game.Settings.Game.PreviousMod = Game.ModData.Manifest.Mod.Id;
Game.InitializeMod("modchooser", null);
};
@@ -88,8 +88,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
});
};
var hasCampaign = Game.modData.Manifest.Missions.Any();
var hasMissions = Game.modData.MapCache
var hasCampaign = Game.ModData.Manifest.Missions.Any();
var hasMissions = Game.ModData.MapCache
.Any(p => p.Status == MapStatus.Available && p.Map.Visibility.HasFlag(MapVisibility.MissionSelector));
missionsButton.Disabled = !hasCampaign && !hasMissions;

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var gameModeDropdown = widget.GetOrNull<DropDownButtonWidget>("GAMEMODE_FILTER");
if (gameModeDropdown != null)
{
var selectableMaps = Game.modData.MapCache.Where(m => m.Status == MapStatus.Available && (m.Map.Visibility & filter) != 0);
var selectableMaps = Game.ModData.MapCache.Where(m => m.Status == MapStatus.Available && (m.Map.Visibility & filter) != 0);
var gameModes = selectableMaps
.GroupBy(m => m.Type)
.Select(g => Pair.New(g.Key, g.Count())).ToList();
@@ -111,7 +111,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
void EnumerateMaps(Action<string> onSelect, MapVisibility filter)
{
var maps = Game.modData.MapCache
var maps = Game.ModData.MapCache
.Where(m => m.Status == MapStatus.Available && (m.Map.Visibility & filter) != 0)
.Where(m => gameMode == null || m.Type == gameMode)
.Where(m => mapFilter == null || m.Title.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0 || m.Author.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0)

View File

@@ -92,15 +92,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic
missionList.RemoveChildren();
// Add a group for each campaign
if (Game.modData.Manifest.Missions.Any())
if (Game.ModData.Manifest.Missions.Any())
{
var yaml = Game.modData.Manifest.Missions.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergeLiberal);
var yaml = Game.ModData.Manifest.Missions.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergeLiberal);
foreach (var kv in yaml)
{
var missionMapPaths = kv.Value.Nodes.Select(n => Path.GetFullPath(n.Key));
var maps = Game.modData.MapCache
var maps = Game.ModData.MapCache
.Where(p => p.Status == MapStatus.Available && missionMapPaths.Contains(Path.GetFullPath(p.Map.Path)))
.Select(p => p.Map);
@@ -110,7 +110,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
}
// Add an additional group for loose missions
var looseMissions = Game.modData.MapCache
var looseMissions = Game.ModData.MapCache
.Where(p => p.Status == MapStatus.Available && p.Map.Visibility.HasFlag(MapVisibility.MissionSelector) && !allMaps.Contains(p.Map))
.Select(p => p.Map);
@@ -158,7 +158,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
void SelectMap(Map map)
{
selectedMapPreview = Game.modData.MapCache[map.Uid];
selectedMapPreview = Game.ModData.MapCache[map.Uid];
// Cache the rules on a background thread to avoid jank
new Thread(selectedMapPreview.CacheRules).Start();

View File

@@ -88,11 +88,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var args = new string[] { "Install.Music=true" };
installButton.OnClick = () =>
{
Game.modData.LoadScreen.Display(); // HACK: prevent a flicker when transitioning to the installation dialog
Game.ModData.LoadScreen.Display(); // HACK: prevent a flicker when transitioning to the installation dialog
Game.InitializeMod(Game.Settings.Game.Mod, new Arguments(args));
};
var installData = Game.modData.Manifest.ContentInstaller;
var installData = Game.ModData.Manifest.ContentInstaller;
installButton.IsVisible = () => modRules.InstalledMusic.ToArray().Length <= installData.ShippedSoundtracks;
}

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
replayList = panel.Get<ScrollPanelWidget>("REPLAY_LIST");
var template = panel.Get<ScrollItemWidget>("REPLAY_TEMPLATE");
var mod = Game.modData.Manifest.Mod;
var mod = Game.ModData.Manifest.Mod;
var dir = Platform.ResolvePath("^", "Replays", mod.Id, mod.Version);
replayList.RemoveChildren();

View File

@@ -169,7 +169,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
return 0;
// Games for the current mod+version are sorted first
if (testEntry.ModId == Game.modData.Manifest.Mod.Id)
if (testEntry.ModId == Game.ModData.Manifest.Mod.Id)
return 2;
// Followed by games for different mods that are joinable
@@ -208,7 +208,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var item = ScrollItemWidget.Setup(serverTemplate, () => currentServer == game, () => currentServer = game, () => Join(game));
var map = Game.modData.MapCache[game.Map];
var map = Game.ModData.MapCache[game.Map];
var preview = item.GetOrNull<MapPreviewWidget>("MAP_PREVIEW");
if (preview != null)
preview.Preview = () => map;
@@ -283,7 +283,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
// Search for any unknown maps
if (Game.Settings.Game.AllowDownloading)
Game.modData.MapCache.QueryRemoteMapDetails(games.Where(g => !Filtered(g)).Select(g => g.Map));
Game.ModData.MapCache.QueryRemoteMapDetails(games.Where(g => !Filtered(g)).Select(g => g.Map));
foreach (var row in rows)
serverList.AddChild(row);

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
this.onExit = onExit;
var settings = Game.Settings;
preview = Game.modData.MapCache[WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map)];
preview = Game.ModData.MapCache[WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map)];
panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); };
panel.Get<ButtonWidget>("CREATE_BUTTON").OnClick = CreateAndJoin;
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
{ "initialMap", preview.Uid },
{ "onExit", () => { } },
{ "onSelect", (Action<string>)(uid => preview = Game.modData.MapCache[uid]) }
{ "onSelect", (Action<string>)(uid => preview = Game.ModData.MapCache[uid]) }
});
};