StyleCop clean OpenRA.Game
This commit is contained in:
@@ -43,7 +43,7 @@ namespace OpenRA.Widgets
|
||||
var color = GetColor();
|
||||
var colorDisabled = GetColorDisabled();
|
||||
|
||||
WidgetUtils.DrawRGBA(image, stateOffset + new float2(rb.Right - rb.Height + 4, rb.Top + (rb.Height - image.bounds.Height) / 2));
|
||||
WidgetUtils.DrawRGBA(image, stateOffset + new float2(rb.Right - rb.Height + 4, rb.Top + (rb.Height - image.Bounds.Height) / 2));
|
||||
|
||||
WidgetUtils.FillRectWithColor(new Rectangle(stateOffset.X + rb.Right - rb.Height,
|
||||
stateOffset.Y + rb.Top + 3, 1, rb.Height - 6),
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace OpenRA.Widgets
|
||||
public int2 ConvertToPreview(CPos cell)
|
||||
{
|
||||
var preview = Preview();
|
||||
var tileShape = Game.modData.Manifest.TileShape;
|
||||
var tileShape = Game.ModData.Manifest.TileShape;
|
||||
var point = Map.CellToMap(tileShape, cell);
|
||||
var dx = (int)(previewScale * (point.X - preview.Bounds.Left));
|
||||
var dy = (int)(previewScale * (point.Y - preview.Bounds.Top));
|
||||
@@ -152,9 +152,9 @@ namespace OpenRA.Widgets
|
||||
return;
|
||||
|
||||
// Update map rect
|
||||
previewScale = Math.Min(RenderBounds.Width / minimap.size.X, RenderBounds.Height / minimap.size.Y);
|
||||
var w = (int)(previewScale * minimap.size.X);
|
||||
var h = (int)(previewScale * minimap.size.Y);
|
||||
previewScale = Math.Min(RenderBounds.Width / minimap.Size.X, RenderBounds.Height / minimap.Size.Y);
|
||||
var w = (int)(previewScale * minimap.Size.X);
|
||||
var h = (int)(previewScale * minimap.Size.Y);
|
||||
var x = RenderBounds.X + (RenderBounds.Width - w) / 2;
|
||||
var y = RenderBounds.Y + (RenderBounds.Height - h) / 2;
|
||||
mapRect = new Rectangle(x, y, w, h);
|
||||
@@ -172,10 +172,10 @@ namespace OpenRA.Widgets
|
||||
var owned = colors.ContainsKey(p);
|
||||
var pos = ConvertToPreview(p);
|
||||
var sprite = owned ? spawnClaimed : spawnUnclaimed;
|
||||
var offset = new int2(sprite.bounds.Width, sprite.bounds.Height) / 2;
|
||||
var offset = new int2(sprite.Bounds.Width, sprite.Bounds.Height) / 2;
|
||||
|
||||
if (owned)
|
||||
WidgetUtils.FillEllipseWithColor(new Rectangle(pos.X - offset.X + 1, pos.Y - offset.Y + 1, sprite.bounds.Width - 2, sprite.bounds.Height - 2), colors[p]);
|
||||
WidgetUtils.FillEllipseWithColor(new Rectangle(pos.X - offset.X + 1, pos.Y - offset.Y + 1, sprite.Bounds.Width - 2, sprite.Bounds.Height - 2), colors[p]);
|
||||
|
||||
Game.Renderer.RgbaSpriteRenderer.DrawSprite(sprite, pos - offset);
|
||||
var number = Convert.ToChar('A' + spawnPoints.IndexOf(p)).ToString();
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
if (hk == Game.Settings.Keys.DevReloadChromeKey)
|
||||
{
|
||||
ChromeProvider.Initialize(Game.modData.Manifest.Chrome);
|
||||
ChromeProvider.Initialize(Game.ModData.Manifest.Chrome);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
2
OpenRA.Game/Widgets/SliderWidget.cs
Executable file → Normal file
2
OpenRA.Game/Widgets/SliderWidget.cs
Executable file → Normal file
@@ -118,7 +118,7 @@ namespace OpenRA.Widgets
|
||||
for (var i = 0; i < Ticks; i++)
|
||||
{
|
||||
var tickPos = new float2(
|
||||
trackOrigin + (i * (trackRect.Width - (int)tick.size.X) / (Ticks - 1)) - tick.size.X / 2,
|
||||
trackOrigin + (i * (trackRect.Width - (int)tick.Size.X) / (Ticks - 1)) - tick.Size.X / 2,
|
||||
trackRect.Bottom);
|
||||
|
||||
WidgetUtils.DrawRGBA(tick, tickPos);
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
if (Unit != null && Sequence != null)
|
||||
{
|
||||
var anim = new Animation(WorldRenderer.world, Unit, () => Facing);
|
||||
var anim = new Animation(WorldRenderer.World, Unit, () => Facing);
|
||||
anim.PlayFetchIndex(Sequence, () => Frame);
|
||||
GetAnimation = () => anim;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
if (sprite != cachedSprite)
|
||||
{
|
||||
offset = 0.5f * (new float2(RenderBounds.Size) - sprite.size);
|
||||
offset = 0.5f * (new float2(RenderBounds.Size) - sprite.Size);
|
||||
cachedSprite = sprite;
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace OpenRA.Widgets
|
||||
while (nextFrame > video.CurrentFrame)
|
||||
{
|
||||
video.AdvanceFrame();
|
||||
videoSprite.sheet.GetTexture().SetData(video.FrameData);
|
||||
videoSprite.Sheet.GetTexture().SetData(video.FrameData);
|
||||
skippedFrames++;
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace OpenRA.Widgets
|
||||
paused = true;
|
||||
Sound.StopVideo();
|
||||
video.Reset();
|
||||
videoSprite.sheet.GetTexture().SetData(video.FrameData);
|
||||
videoSprite.Sheet.GetTexture().SetData(video.FrameData);
|
||||
world.AddFrameEndTask(_ => onComplete());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
public static Widget OpenWindow(string id, WidgetArgs args)
|
||||
{
|
||||
var window = Game.modData.WidgetLoader.LoadWidget(args, Root, id);
|
||||
var window = Game.ModData.WidgetLoader.LoadWidget(args, Root, id);
|
||||
if (WindowList.Count > 0)
|
||||
Root.RemoveChild(WindowList.Peek());
|
||||
WindowList.Push(window);
|
||||
@@ -67,7 +67,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
public static Widget LoadWidget(string id, Widget parent, WidgetArgs args)
|
||||
{
|
||||
return Game.modData.WidgetLoader.LoadWidget(args, parent, id);
|
||||
return Game.ModData.WidgetLoader.LoadWidget(args, parent, id);
|
||||
}
|
||||
|
||||
public static void Tick() { Root.TickOuter(); }
|
||||
@@ -235,7 +235,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
args["widget"] = this;
|
||||
|
||||
LogicObject = Game.modData.ObjectCreator.CreateObject<object>(Logic, args);
|
||||
LogicObject = Game.ModData.ObjectCreator.CreateObject<object>(Logic, args);
|
||||
|
||||
args.Remove("widget");
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace OpenRA
|
||||
static Widget NewWidget(string widgetType, WidgetArgs args)
|
||||
{
|
||||
widgetType = widgetType.Split('@')[0];
|
||||
return Game.modData.ObjectCreator.CreateObject<Widget>(widgetType + "Widget", args);
|
||||
return Game.ModData.ObjectCreator.CreateObject<Widget>(widgetType + "Widget", args);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,33 +29,33 @@ namespace OpenRA.Widgets
|
||||
|
||||
public static void DrawSHPCentered(Sprite s, float2 pos, WorldRenderer wr)
|
||||
{
|
||||
Game.Renderer.SpriteRenderer.DrawSprite(s, pos - 0.5f * s.size, wr.Palette("chrome"));
|
||||
Game.Renderer.SpriteRenderer.DrawSprite(s, pos - 0.5f * s.Size, wr.Palette("chrome"));
|
||||
}
|
||||
|
||||
public static void DrawSHPCentered(Sprite s, float2 pos, WorldRenderer wr, float scale)
|
||||
{
|
||||
Game.Renderer.SpriteRenderer.DrawSprite(s, pos - 0.5f * scale * s.size, wr.Palette("chrome"), scale * s.size);
|
||||
Game.Renderer.SpriteRenderer.DrawSprite(s, pos - 0.5f * scale * s.Size, wr.Palette("chrome"), scale * s.Size);
|
||||
}
|
||||
|
||||
public static void DrawPanel(string collection, Rectangle Bounds)
|
||||
public static void DrawPanel(string collection, Rectangle bounds)
|
||||
{
|
||||
DrawPanelPartial(collection, Bounds, PanelSides.All);
|
||||
DrawPanelPartial(collection, bounds, PanelSides.All);
|
||||
}
|
||||
|
||||
public static void FillRectWithSprite(Rectangle r, Sprite s)
|
||||
{
|
||||
for (var x = r.Left; x < r.Right; x += (int)s.size.X)
|
||||
for (var y = r.Top; y < r.Bottom; y += (int)s.size.Y)
|
||||
for (var x = r.Left; x < r.Right; x += (int)s.Size.X)
|
||||
for (var y = r.Top; y < r.Bottom; y += (int)s.Size.Y)
|
||||
{
|
||||
var ss = s;
|
||||
var left = new int2(r.Right - x, r.Bottom - y);
|
||||
if (left.X < (int)s.size.X || left.Y < (int)s.size.Y)
|
||||
if (left.X < (int)s.Size.X || left.Y < (int)s.Size.Y)
|
||||
{
|
||||
var rr = new Rectangle(s.bounds.Left,
|
||||
s.bounds.Top,
|
||||
Math.Min(left.X, (int)s.size.X),
|
||||
Math.Min(left.Y, (int)s.size.Y));
|
||||
ss = new Sprite(s.sheet, rr, s.channel);
|
||||
var rr = new Rectangle(s.Bounds.Left,
|
||||
s.Bounds.Top,
|
||||
Math.Min(left.X, (int)s.Size.X),
|
||||
Math.Min(left.Y, (int)s.Size.Y));
|
||||
ss = new Sprite(s.Sheet, rr, s.Channel);
|
||||
}
|
||||
|
||||
DrawRGBA(ss, new float2(x, y));
|
||||
@@ -76,7 +76,7 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
var images = new[] { "border-t", "border-b", "border-l", "border-r" };
|
||||
var ss = images.Select(i => ChromeProvider.GetImage(collection, i)).ToArray();
|
||||
return new[] { (int)ss[0].size.Y, (int)ss[1].size.Y, (int)ss[2].size.X, (int)ss[3].size.X };
|
||||
return new[] { (int)ss[0].Size.Y, (int)ss[1].Size.Y, (int)ss[2].Size.X, (int)ss[3].Size.X };
|
||||
}
|
||||
|
||||
static bool HasFlags(this PanelSides a, PanelSides b) { return (a & b) == b; }
|
||||
@@ -95,10 +95,10 @@ namespace OpenRA.Widgets
|
||||
|
||||
public static void DrawPanelPartial(Sprite[] ss, Rectangle bounds, PanelSides ps)
|
||||
{
|
||||
var marginLeft = ss[2] == null ? 0 : (int)ss[2].size.X;
|
||||
var marginTop = ss[0] == null ? 0 : (int)ss[0].size.Y;
|
||||
var marginRight = ss[3] == null ? 0 : (int)ss[3].size.X;
|
||||
var marginBottom = ss[1] == null ? 0 : (int)ss[1].size.Y;
|
||||
var marginLeft = ss[2] == null ? 0 : (int)ss[2].Size.X;
|
||||
var marginTop = ss[0] == null ? 0 : (int)ss[0].Size.Y;
|
||||
var marginRight = ss[3] == null ? 0 : (int)ss[3].Size.X;
|
||||
var marginBottom = ss[1] == null ? 0 : (int)ss[1].Size.Y;
|
||||
var marginWidth = marginRight + marginLeft;
|
||||
var marginHeight = marginBottom + marginTop;
|
||||
|
||||
@@ -135,11 +135,11 @@ namespace OpenRA.Widgets
|
||||
if (ps.HasFlags(PanelSides.Left | PanelSides.Top) && ss[4] != null)
|
||||
DrawRGBA(ss[4], new float2(bounds.Left, bounds.Top));
|
||||
if (ps.HasFlags(PanelSides.Right | PanelSides.Top) && ss[5] != null)
|
||||
DrawRGBA(ss[5], new float2(bounds.Right - ss[5].size.X, bounds.Top));
|
||||
DrawRGBA(ss[5], new float2(bounds.Right - ss[5].Size.X, bounds.Top));
|
||||
if (ps.HasFlags(PanelSides.Left | PanelSides.Bottom) && ss[6] != null)
|
||||
DrawRGBA(ss[6], new float2(bounds.Left, bounds.Bottom - ss[6].size.Y));
|
||||
DrawRGBA(ss[6], new float2(bounds.Left, bounds.Bottom - ss[6].Size.Y));
|
||||
if (ps.HasFlags(PanelSides.Right | PanelSides.Bottom) && ss[7] != null)
|
||||
DrawRGBA(ss[7], new float2(bounds.Right - ss[7].size.X, bounds.Bottom - ss[7].size.Y));
|
||||
DrawRGBA(ss[7], new float2(bounds.Right - ss[7].Size.X, bounds.Bottom - ss[7].Size.Y));
|
||||
}
|
||||
|
||||
public static string FormatTime(int ticks)
|
||||
@@ -215,7 +215,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
public static string ChooseInitialMap(string initialUid)
|
||||
{
|
||||
if (string.IsNullOrEmpty(initialUid) || Game.modData.MapCache[initialUid].Status != MapStatus.Available)
|
||||
if (string.IsNullOrEmpty(initialUid) || Game.ModData.MapCache[initialUid].Status != MapStatus.Available)
|
||||
{
|
||||
Func<MapPreview, bool> isIdealMap = m =>
|
||||
{
|
||||
@@ -237,8 +237,8 @@ namespace OpenRA.Widgets
|
||||
return true;
|
||||
};
|
||||
|
||||
var selected = Game.modData.MapCache.Where(m => isIdealMap(m)).RandomOrDefault(Game.CosmeticRandom) ??
|
||||
Game.modData.MapCache.First(m => m.Status == MapStatus.Available && m.Map.Visibility.HasFlag(MapVisibility.Lobby));
|
||||
var selected = Game.ModData.MapCache.Where(m => isIdealMap(m)).RandomOrDefault(Game.CosmeticRandom) ??
|
||||
Game.ModData.MapCache.First(m => m.Status == MapStatus.Available && m.Map.Visibility.HasFlag(MapVisibility.Lobby));
|
||||
return selected.Uid;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user