Merge pull request #4129 from ScottNZ/refactor

Refactor
This commit is contained in:
Chris Forbes
2013-11-12 00:06:01 -08:00
319 changed files with 157 additions and 639 deletions

View File

@@ -21,7 +21,7 @@ namespace OpenRA
public static string FormatErrorMessage(Exception e)
{
var ex = e as System.Net.WebException;
var ex = e as WebException;
if (ex == null)
return e.Message;
@@ -46,15 +46,15 @@ namespace OpenRA
wc.DownloadProgressChanged += (_, a) => onProgress(a);
wc.DownloadFileCompleted += (_, a) => onComplete(a, cancelled);
Game.OnQuit += () => Cancel();
wc.DownloadFileCompleted += (_, a) => { Game.OnQuit -= () => Cancel(); };
Game.OnQuit += Cancel;
wc.DownloadFileCompleted += (_, a) => { Game.OnQuit -= Cancel; };
wc.DownloadFileAsync(new Uri(url), path);
}
public void Cancel()
{
Game.OnQuit -= () => Cancel();
Game.OnQuit -= Cancel;
wc.CancelAsync();
cancelled = true;
}

View File

@@ -11,7 +11,6 @@
using System;
using System.Collections.Generic;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Effects
{

View File

@@ -10,7 +10,6 @@
using System.Collections.Generic;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Effects
{

View File

@@ -9,10 +9,7 @@
#endregion
using System.Collections.Generic;
using OpenRA.Effects;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Effects
{

View File

@@ -103,7 +103,7 @@ namespace OpenRA
// Load a widget with world, orderManager, worldRenderer args, without adding it to the widget tree
public static Widget LoadWidget(World world, string id, Widget parent, WidgetArgs args)
{
return Game.modData.WidgetLoader.LoadWidget(new WidgetArgs(args)
return modData.WidgetLoader.LoadWidget(new WidgetArgs(args)
{
{ "world", world },
{ "orderManager", orderManager },
@@ -135,23 +135,23 @@ namespace OpenRA
// worldRenderer is null during the initial install/download screen
if (worldRenderer != null)
{
Game.Renderer.BeginFrame(worldRenderer.Viewport.TopLeft.ToFloat2(), worldRenderer.Viewport.Zoom);
Renderer.BeginFrame(worldRenderer.Viewport.TopLeft.ToFloat2(), worldRenderer.Viewport.Zoom);
Sound.SetListenerPosition(worldRenderer.Position(worldRenderer.Viewport.CenterLocation));
worldRenderer.Draw();
}
else
Game.Renderer.BeginFrame(float2.Zero, 1f);
Renderer.BeginFrame(float2.Zero, 1f);
using (new PerfSample("render_widgets"))
{
Ui.Draw();
var cursorName = Ui.Root.GetCursorOuter(Viewport.LastMousePos) ?? "default";
CursorProvider.DrawCursor(Game.Renderer, cursorName, Viewport.LastMousePos, (int)cursorFrame);
CursorProvider.DrawCursor(Renderer, cursorName, Viewport.LastMousePos, (int)cursorFrame);
}
using (new PerfSample("render_flip"))
{
Game.Renderer.EndFrame(new DefaultInputHandler(orderManager.world));
Renderer.EndFrame(new DefaultInputHandler(orderManager.world));
}
}
@@ -374,13 +374,13 @@ namespace OpenRA
JoinLocal();
if (Game.Settings.Server.Dedicated)
if (Settings.Server.Dedicated)
{
while (true)
{
Game.Settings.Server.Map = WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map);
Game.Settings.Save();
Game.CreateServer(new ServerSettings(Game.Settings.Server));
Settings.Server.Map = WidgetUtils.ChooseInitialMap(Settings.Server.Map);
Settings.Save();
CreateServer(new ServerSettings(Settings.Server));
while (true)
{
System.Threading.Thread.Sleep(100);
@@ -393,15 +393,14 @@ namespace OpenRA
break;
}
}
if (Game.Settings.Server.DedicatedLoop)
if (Settings.Server.DedicatedLoop)
{
Console.WriteLine("Starting a new server instance...");
continue;
}
else
break;
break;
}
System.Environment.Exit(0);
Environment.Exit(0);
}
else
{
@@ -420,7 +419,7 @@ namespace OpenRA
var shellmaps = modData.AvailableMaps
.Where(m => m.Value.UseAsShellmap);
if (shellmaps.Count() == 0)
if (!shellmaps.Any())
throw new InvalidDataException("No valid shellmaps available");
return shellmaps.Random(CosmeticRandom).Key;
@@ -482,7 +481,7 @@ namespace OpenRA
public static void CreateServer(ServerSettings settings)
{
server = new Server.Server(new IPEndPoint(IPAddress.Any, settings.ListenPort),
Game.Settings.Game.Mods, settings, modData);
Settings.Game.Mods, settings, modData);
}
public static int CreateLocalServer(string map)
@@ -496,7 +495,7 @@ namespace OpenRA
};
server = new Server.Server(new IPEndPoint(IPAddress.Loopback, 0),
Game.Settings.Game.Mods, settings, modData);
Settings.Game.Mods, settings, modData);
return server.Port;
}
@@ -510,7 +509,7 @@ namespace OpenRA
{
try
{
var mod = Game.CurrentMods.FirstOrDefault().Value.Id;
var mod = CurrentMods.First().Value.Id;
var dirPath = "{1}maps{0}{2}".F(Path.DirectorySeparatorChar, Platform.SupportDir, mod);
if(!Directory.Exists(dirPath))
Directory.CreateDirectory(dirPath);

View File

@@ -10,12 +10,9 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using OpenRA.FileFormats;
using OpenRA.FileFormats.Graphics;
using OpenRA.Server;
namespace OpenRA.GameRules
{

View File

@@ -8,7 +8,6 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.FileFormats;

View File

@@ -10,7 +10,6 @@
using System;
using System.Collections.Generic;
using OpenRA.Traits;
namespace OpenRA.Graphics
{

View File

@@ -8,7 +8,6 @@
*/
#endregion
using System.Collections.Generic;
using System.Drawing;
namespace OpenRA.Graphics

View File

@@ -8,8 +8,6 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;

View File

@@ -10,11 +10,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using OpenRA.FileFormats;
using OpenRA.Traits;
namespace OpenRA.Graphics
{

View File

@@ -8,7 +8,6 @@
*/
#endregion
using System.Xml;
using OpenRA.FileFormats;
namespace OpenRA.Graphics

View File

@@ -9,8 +9,6 @@
#endregion
using System.Drawing;
using System.IO;
using System.Xml;
using OpenRA.FileFormats;
using System.Collections.Generic;

View File

@@ -13,7 +13,6 @@ using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Traits;
namespace OpenRA.Graphics

View File

@@ -9,7 +9,6 @@
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.FileFormats.Graphics;

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Graphics
public static Sheet AllocateSheet()
{
return new Sheet(new Size(Renderer.SheetSize, Renderer.SheetSize));;
return new Sheet(new Size(Renderer.SheetSize, Renderer.SheetSize));
}
internal SheetBuilder(SheetType t)

View File

@@ -11,7 +11,6 @@
using System;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using OpenRA.FileFormats;
using SharpFont;

View File

@@ -8,7 +8,6 @@
*/
#endregion
using System.Drawing;
using System.IO;
using System.Linq;
using OpenRA.FileFormats;

View File

@@ -8,9 +8,6 @@
*/
#endregion
using System;
using System.Drawing;
using OpenRA.FileFormats;
using OpenRA.FileFormats.Graphics;
using OpenRA.Traits;

View File

@@ -9,7 +9,6 @@
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
namespace OpenRA.Graphics

View File

@@ -11,11 +11,8 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.FileFormats.Graphics;
using OpenRA.Traits;
namespace OpenRA.Graphics
{

View File

@@ -258,7 +258,7 @@ namespace OpenRA.Graphics
for (var i = 0; i < 8; i++)
{
var vec = new float[] {bounds[ix[i]], bounds[iy[i]], bounds[iz[i]], 1};
var tvec = Util.MatrixVectorMultiply(mtx, vec);
var tvec = MatrixVectorMultiply(mtx, vec);
ret[0] = Math.Min(ret[0], tvec[0]/tvec[3]);
ret[1] = Math.Min(ret[1], tvec[1]/tvec[3]);

View File

@@ -12,7 +12,6 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Support;
namespace OpenRA.Graphics
{

View File

@@ -9,11 +9,8 @@
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.FileFormats.Graphics;
namespace OpenRA.Graphics
{

View File

@@ -10,7 +10,6 @@
using System;
using System.Collections.Generic;
using OpenRA.Traits;
namespace OpenRA.Graphics
{

View File

@@ -8,7 +8,6 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;

View File

@@ -14,7 +14,6 @@ using System.IO;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using OpenRA.Traits;
using OpenRA.Widgets;
namespace OpenRA
@@ -163,7 +162,7 @@ namespace OpenRA
catch (Exception e)
{
Console.WriteLine("Failed to load map: {0}", path);
Console.WriteLine("Details: {0}", e.ToString());
Console.WriteLine("Details: {0}", e);
}
}

View File

@@ -8,7 +8,6 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;

View File

@@ -10,8 +10,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Threading;
namespace OpenRA.Network
{

View File

@@ -9,7 +9,6 @@
#endregion
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;

View File

@@ -10,7 +10,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using OpenRA.FileFormats;

View File

@@ -9,7 +9,6 @@
#endregion
using System;
using OpenRA.Network;
namespace OpenRA.Network
{

View File

@@ -11,8 +11,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace OpenRA.Network
{

View File

@@ -12,7 +12,6 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using OpenRA.Widgets;
namespace OpenRA.Network

View File

@@ -10,7 +10,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
@@ -43,11 +42,11 @@ namespace OpenRA.Network
break;
case "Client":
session.Clients.Add(FieldLoader.Load<Session.Client>(y.Value));
session.Clients.Add(FieldLoader.Load<Client>(y.Value));
break;
case "Slot":
var s = FieldLoader.Load<Session.Slot>(y.Value);
var s = FieldLoader.Load<Slot>(y.Value);
session.Slots.Add(s.PlayerReference, s);
break;
}
@@ -144,7 +143,7 @@ namespace OpenRA.Network
public Session(string[] mods)
{
this.GlobalSettings.Mods = mods.ToArray();
this.GlobalSettings.GameUid = System.Guid.NewGuid().ToString();
this.GlobalSettings.GameUid = Guid.NewGuid().ToString();
}
public string Serialize()

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Network
{
this.orderManager = orderManager;
for (var i = 0; i < NumSyncReports; i++)
syncReports[i] = new SyncReport.Report();
syncReports[i] = new Report();
}
internal void UpdateSyncReport()

View File

@@ -11,8 +11,6 @@
using System;
using Mono.Nat;
using Mono.Nat.Pmp;
using Mono.Nat.Upnp;
namespace OpenRA.Network
{

View File

@@ -9,9 +9,7 @@
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Orders
{

View File

@@ -12,8 +12,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Net.NetworkInformation;
using System.Threading;
namespace OpenRA.Server
{

View File

@@ -11,7 +11,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
namespace OpenRA.Server
{

View File

@@ -340,7 +340,7 @@ namespace OpenRA.Server
if (File.Exists("{0}motd_{1}.txt".F(Platform.SupportDir, LobbyInfo.GlobalSettings.Mods[0])))
{
var motd = System.IO.File.ReadAllText("{0}motd_{1}.txt".F(Platform.SupportDir, LobbyInfo.GlobalSettings.Mods[0]));
var motd = File.ReadAllText("{0}motd_{1}.txt".F(Platform.SupportDir, LobbyInfo.GlobalSettings.Mods[0]));
SendOrderTo(newConn, "Message", motd);
}

View File

@@ -272,7 +272,7 @@ namespace OpenRA
}
// Returns true if played successfully
public static bool PlayPredefined(Player p, Actor voicedUnit, string type, string definition, string variant, bool attentuateVolume)
public static bool PlayPredefined(Player p, Actor voicedUnit, string type, string definition, string variant, bool attenuateVolume)
{
if (definition == null) return false;
@@ -323,7 +323,7 @@ namespace OpenRA
if (!String.IsNullOrEmpty(name) && (p == null || p == p.World.LocalPlayer))
soundEngine.Play2D(sounds[name],
false, true, WPos.Zero,
InternalSoundVolume, attentuateVolume);
InternalSoundVolume, attenuateVolume);
return true;
}
@@ -604,8 +604,8 @@ namespace OpenRA
int state;
Al.alGetSourcei(b, Al.AL_SOURCE_STATE, out state);
return ((state == Al.AL_PLAYING || state == Al.AL_PAUSED) &&
((music != null) ? b != ((OpenAlSound)music).source : true) &&
((video != null) ? b != ((OpenAlSound)video).source : true));
((music == null) || b != ((OpenAlSound)music).source) &&
((video == null) || b != ((OpenAlSound)video).source));
}).ToList();
foreach (var s in sounds)
{

View File

@@ -21,11 +21,11 @@ namespace OpenRA
public Arguments(params string[] src)
{
Regex regex = new Regex("([^=]+)=(.*)");
foreach (string s in src)
var regex = new Regex("([^=]+)=(.*)");
foreach (var s in src)
{
Match m = regex.Match(s);
if (m == null || !m.Success)
if (!m.Success)
continue;
args[m.Groups[1].Value] = m.Groups[2].Value;

View File

@@ -8,10 +8,8 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OpenRA.Traits
{

View File

@@ -8,10 +8,6 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.FileFormats;
namespace OpenRA.Traits

View File

@@ -8,9 +8,6 @@
*/
#endregion
using System.Collections.Generic;
using OpenRA.Network;
namespace OpenRA.Traits
{
public class DebugPauseStateInfo : ITraitInfo

View File

@@ -10,7 +10,6 @@
using System.Drawing;
using OpenRA.Graphics;
using OpenRA.Effects;
using System.Collections.Generic;
namespace OpenRA.Traits

View File

@@ -8,8 +8,6 @@
*/
#endregion
using System;
namespace OpenRA.Traits
{
public class DeveloperModeInfo : ITraitInfo

View File

@@ -8,13 +8,10 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Traits
{

View File

@@ -8,7 +8,6 @@
*/
#endregion
using System.Drawing;
using OpenRA.FileFormats;
using OpenRA.Graphics;

View File

@@ -10,7 +10,6 @@
using System;
using System.Linq;
using OpenRA.GameRules;
namespace OpenRA.Traits
{

View File

@@ -9,7 +9,6 @@
#endregion
using System.Linq;
using OpenRA.Network;
namespace OpenRA.Traits
{

View File

@@ -12,7 +12,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.FileFormats;
namespace OpenRA.Traits
{

View File

@@ -10,7 +10,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.FileFormats;

View File

@@ -8,7 +8,6 @@
*/
#endregion
using System.Drawing;
using System.Linq;
using OpenRA.Graphics;
@@ -65,7 +64,7 @@ namespace OpenRA.Traits
return;
var pipSources = self.TraitsImplementing<IPips>();
if (pipSources.Count() == 0)
if (!pipSources.Any())
return;
var pipImages = new Animation("pips");

View File

@@ -32,14 +32,14 @@ namespace OpenRA.Traits
public static Target FromOrder(Order o)
{
return o.TargetActor != null
? Target.FromActor(o.TargetActor)
: Target.FromCell(o.TargetLocation);
? FromActor(o.TargetActor)
: FromCell(o.TargetLocation);
}
public static Target FromActor(Actor a)
{
if (a == null)
return Target.Invalid;
return Invalid;
return new Target
{

View File

@@ -10,7 +10,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Support;
@@ -135,7 +134,7 @@ namespace OpenRA.Traits
public static IEnumerable<CPos> AdjacentCells(Target target)
{
var cells = target.Positions.Select(p => p.ToCPos()).Distinct();
return Util.ExpandFootprint(cells, true);
return ExpandFootprint(cells, true);
}
}
}

View File

@@ -12,7 +12,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Traits;
namespace OpenRA.Traits
{

View File

@@ -10,7 +10,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Graphics;

View File

@@ -14,7 +14,6 @@ using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Traits
{

View File

@@ -12,7 +12,6 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Graphics;
namespace OpenRA.Traits
{

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Widgets
WidgetUtils.DrawPanel(Background, RenderBounds);
}
public BackgroundWidget() : base() { }
public BackgroundWidget() { }
bool moving;
int2? prevMouseLocation;

View File

@@ -9,10 +9,8 @@
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using OpenRA.FileFormats;
using OpenRA.Graphics;
namespace OpenRA.Widgets
{
@@ -48,7 +46,6 @@ namespace OpenRA.Widgets
public Action<KeyInput> OnKeyPress = _ => {};
public ButtonWidget()
: base()
{
GetText = () => { return Text; };
OnMouseUp = _ => OnClick();
@@ -188,7 +185,7 @@ namespace OpenRA.Widgets
public virtual void DrawBackground(Rectangle rect, bool disabled, bool pressed, bool hover, bool highlighted)
{
ButtonWidget.DrawBackground("button", rect, disabled, pressed, hover, highlighted);
DrawBackground("button", rect, disabled, pressed, hover, highlighted);
}
public static void DrawBackground(string baseName, Rectangle rect, bool disabled, bool pressed, bool hover, bool highlighted)

View File

@@ -26,9 +26,6 @@ namespace OpenRA.Widgets
internal List<ChatLine> recentLines = new List<ChatLine>();
public ChatDisplayWidget()
: base() { }
public override Rectangle EventBounds { get { return Rectangle.Empty; } }
public override void Draw()

View File

@@ -11,7 +11,6 @@
using System;
using System.Drawing;
using OpenRA.Graphics;
using System.Reflection;
namespace OpenRA.Widgets
{
@@ -25,7 +24,6 @@ namespace OpenRA.Widgets
public bool HasPressedState = ChromeMetrics.Get<bool>("CheckboxPressedState");
public CheckboxWidget()
: base()
{
GetCheckType = () => CheckType;
}

View File

@@ -8,13 +8,7 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Threading;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using OpenRA.Network;
namespace OpenRA.Widgets
@@ -27,7 +21,7 @@ namespace OpenRA.Widgets
OrderManager orderManager;
int clientIndex;
public ClientTooltipRegionWidget() : base()
public ClientTooltipRegionWidget()
{
tooltipContainer = Lazy.New(() => Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
}

View File

@@ -18,7 +18,6 @@ namespace OpenRA.Widgets
public Func<Color> GetColor;
public ColorBlockWidget()
: base()
{
GetColor = () => Color.White;
}

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Widgets
Widget panel;
MaskWidget fullscreenMask;
public DropDownButtonWidget() : base() { }
public DropDownButtonWidget() { }
protected DropDownButtonWidget(DropDownButtonWidget widget) : base(widget) { }
@@ -145,7 +145,7 @@ namespace OpenRA.Widgets
public class MaskWidget : Widget
{
public event Action<MouseInput> OnMouseDown = _ => {};
public MaskWidget() : base() { }
public MaskWidget() { }
public MaskWidget(MaskWidget other)
: base(other)
{

View File

@@ -11,8 +11,6 @@
using System;
using System.Drawing;
using System.Linq;
using OpenRA.Traits;
using OpenRA.Graphics;
namespace OpenRA.Widgets
{
@@ -31,7 +29,7 @@ namespace OpenRA.Widgets
public Color DisabledColor = Color.Gray;
public string Font = "Regular";
public HotkeyEntryWidget() : base() {}
public HotkeyEntryWidget() {}
protected HotkeyEntryWidget(HotkeyEntryWidget widget)
: base(widget)
{

View File

@@ -21,7 +21,6 @@ namespace OpenRA.Widgets
public Func<string> GetImageCollection;
public ImageWidget()
: base()
{
GetImageName = () => ImageName;
GetImageCollection = () => ImageCollection;

View File

@@ -33,7 +33,6 @@ namespace OpenRA.Widgets
public Func<Color> GetContrastColor;
public LabelWidget()
: base()
{
GetText = () => Text;
GetColor = () => Color;

View File

@@ -12,7 +12,6 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
namespace OpenRA.Widgets
{
@@ -41,7 +40,6 @@ namespace OpenRA.Widgets
public string AxisFont;
public LineGraphWidget()
: base()
{
GetValueFormat = () => ValueFormat;
GetXAxisValueFormat = () => XAxisValueFormat;

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Widgets
Lazy<TooltipContainerWidget> tooltipContainer;
public int TooltipSpawnIndex = -1;
public MapPreviewWidget() : base()
public MapPreviewWidget()
{
tooltipContainer = Lazy.New(() => Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
}

View File

@@ -12,7 +12,7 @@ namespace OpenRA.Widgets
{
public class PasswordFieldWidget : TextFieldWidget
{
public PasswordFieldWidget() : base() { }
public PasswordFieldWidget() { }
protected PasswordFieldWidget(PasswordFieldWidget widget) : base(widget) { }
protected override string GetApparentText() { return new string('*', Text.Length); }

View File

@@ -16,8 +16,6 @@ namespace OpenRA.Widgets
{
public class PerfGraphWidget : Widget
{
public PerfGraphWidget() : base() { }
public override void Draw()
{
var rect = RenderBounds;

View File

@@ -8,7 +8,6 @@
*/
#endregion
using System;
using System.Drawing;
namespace OpenRA.Widgets
@@ -22,7 +21,7 @@ namespace OpenRA.Widgets
float offset = 0f;
float tickStep = 0.04f;
public ProgressBarWidget() : base() {}
public ProgressBarWidget() {}
protected ProgressBarWidget(ProgressBarWidget widget)
: base(widget)
{

View File

@@ -18,7 +18,6 @@ namespace OpenRA.Widgets
public string BaseName = "scrollitem";
public ScrollItemWidget()
: base()
{
IsVisible = () => false;
VisualHeight = 0;

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Widgets
protected Rectangle scrollbarRect;
protected Rectangle thumbRect;
public ScrollPanelWidget() : base() { Layout = new ListLayout(this); }
public ScrollPanelWidget() { Layout = new ListLayout(this); }
public override void RemoveChildren()
{

View File

@@ -28,7 +28,6 @@ namespace OpenRA.Widgets
[ObjectCreator.UseCtor]
public ShpImageWidget(WorldRenderer worldRenderer)
: base()
{
GetImage = () => { return Image; };
GetFrame = () => { return Frame; };

View File

@@ -29,7 +29,6 @@ namespace OpenRA.Widgets
protected bool isMoving = false;
public SliderWidget()
: base()
{
GetValue = () => Value;
}

View File

@@ -10,8 +10,6 @@
using System;
using System.Drawing;
using OpenRA.Traits;
using OpenRA.Graphics;
namespace OpenRA.Widgets
{
@@ -40,7 +38,7 @@ namespace OpenRA.Widgets
public Color DisabledColor = Color.Gray;
public string Font = "Regular";
public TextFieldWidget() : base() {}
public TextFieldWidget() {}
protected TextFieldWidget(TextFieldWidget widget)
: base(widget)
{

View File

@@ -8,12 +8,8 @@
*/
#endregion
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using OpenRA.Widgets;
using System;
namespace OpenRA.Widgets

View File

@@ -61,7 +61,6 @@ namespace OpenRA.Widgets
[ObjectCreator.UseCtor]
public ViewportControllerWidget(World world, WorldRenderer worldRenderer)
: base()
{
this.world = world;
this.worldRenderer = worldRenderer;

View File

@@ -446,7 +446,7 @@ namespace OpenRA.Widgets
public class ContainerWidget : Widget
{
public ContainerWidget() : base() { IgnoreMouseOver = true; }
public ContainerWidget() { IgnoreMouseOver = true; }
public ContainerWidget(ContainerWidget other)
: base(other) { IgnoreMouseOver = true; }
@@ -458,7 +458,7 @@ namespace OpenRA.Widgets
public class WidgetArgs : Dictionary<string, object>
{
public WidgetArgs() : base() { }
public WidgetArgs() { }
public WidgetArgs(Dictionary<string, object> args) : base(args) { }
public void Add(string key, Action val) { base.Add(key, val); }
}

View File

@@ -57,8 +57,8 @@ namespace OpenRA.Widgets
var useClassicMouseStyle = Game.Settings.Game.UseClassicMouseStyle;
var hasBox = (SelectionBox != null) ? true : false;
var multiClick = (mi.MultiTapCount >= 2) ? true : false;
var hasBox = SelectionBox != null;
var multiClick = mi.MultiTapCount >= 2;
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Down)
{
@@ -68,7 +68,7 @@ namespace OpenRA.Widgets
dragStart = dragEnd = xy;
// place buildings
if (!useClassicMouseStyle || (useClassicMouseStyle && !World.Selection.Actors.Any()))
if (!useClassicMouseStyle || !World.Selection.Actors.Any())
ApplyOrders(World, xy, mi);
}

View File

@@ -91,7 +91,7 @@ namespace OpenRA
public static string GetTerrainType(this World world, CPos cell)
{
var custom = world.Map.CustomTerrain[cell.X, cell.Y];
return custom != null ? custom : world.TileSet.GetTerrainType(world.Map.MapTiles.Value[cell.X, cell.Y]);
return custom ?? world.TileSet.GetTerrainType(world.Map.MapTiles.Value[cell.X, cell.Y]);
}
public static TerrainTypeInfo GetTerrainInfo(this World world, CPos cell)