Merge pull request #5412 from RoosterDragon/formatting

Formatting
This commit is contained in:
Paul Chote
2014-05-28 12:09:47 +12:00
18 changed files with 69 additions and 69 deletions

View File

@@ -85,7 +85,7 @@ namespace OpenRA
{ {
var si = Info.Traits.GetOrDefault<SelectableInfo>(); var si = Info.Traits.GetOrDefault<SelectableInfo>();
var size = (si != null && si.Bounds != null) ? new int2(si.Bounds[0], si.Bounds[1]) : var size = (si != null && si.Bounds != null) ? new int2(si.Bounds[0], si.Bounds[1]) :
TraitsImplementing<IAutoSelectionSize>().Select(x => x.SelectionSize(this)).FirstOrDefault(); TraitsImplementing<IAutoSelectionSize>().Select(x => x.SelectionSize(this)).FirstOrDefault();
var offset = -size / 2; var offset = -size / 2;
if (si != null && si.Bounds != null && si.Bounds.Length > 2) if (si != null && si.Bounds != null && si.Bounds.Length > 2)

View File

@@ -69,7 +69,7 @@ namespace OpenRA.FileSystem
index = entries.ToDictionaryWithConflictLog(x => x.Hash, index = entries.ToDictionaryWithConflictLog(x => x.Hash,
"{0} ({1} format, Encrypted: {2}, DataStart: {3})".F(filename, (isCncMix ? "C&C" : "RA/TS/RA2"), isEncrypted, dataStart), "{0} ({1} format, Encrypted: {2}, DataStart: {3})".F(filename, (isCncMix ? "C&C" : "RA/TS/RA2"), isEncrypted, dataStart),
null, x => "(offs={0}, len={1})".F(x.Offset, x.Length) null, x => "(offs={0}, len={1})".F(x.Offset, x.Length)
); );
} }

View File

@@ -185,7 +185,7 @@ namespace OpenRA.GameRules
var cellInfo = world.GetTerrainInfo(cell); var cellInfo = world.GetTerrainInfo(cell);
if (!ValidTargets.Intersect(cellInfo.TargetTypes).Any() if (!ValidTargets.Intersect(cellInfo.TargetTypes).Any()
|| InvalidTargets.Intersect(cellInfo.TargetTypes).Any()) || InvalidTargets.Intersect(cellInfo.TargetTypes).Any())
return false; return false;
return true; return true;

View File

@@ -71,7 +71,7 @@ namespace OpenRA.Scripting
throw new InvalidOperationException("[LuaGlobal] attribute not found for global table '{0}'".F(type)); throw new InvalidOperationException("[LuaGlobal] attribute not found for global table '{0}'".F(type));
Name = names.First().Name; Name = names.First().Name;
Bind(new [] { this }); Bind(new[] { this });
} }
} }
@@ -143,7 +143,7 @@ namespace OpenRA.Scripting
if (ctor == null) if (ctor == null)
throw new InvalidOperationException("{0} must define a constructor that takes a ScriptContext context parameter".F(b.Name)); throw new InvalidOperationException("{0} must define a constructor that takes a ScriptContext context parameter".F(b.Name));
var binding = (ScriptGlobal)ctor.Invoke(new [] { this }); var binding = (ScriptGlobal)ctor.Invoke(new[] { this });
using (var obj = binding.ToLuaValue(this)) using (var obj = binding.ToLuaValue(this))
registerGlobal.Call(binding.Name, obj).Dispose(); registerGlobal.Call(binding.Name, obj).Dispose();
} }

View File

@@ -50,7 +50,7 @@ namespace OpenRA
static void EmitSyncOpcodes(Type type, ILGenerator il) static void EmitSyncOpcodes(Type type, ILGenerator il)
{ {
if (hashFunctions.ContainsKey(type)) if (hashFunctions.ContainsKey(type))
il.EmitCall(OpCodes.Call, hashFunctions[type], null); il.EmitCall(OpCodes.Call, hashFunctions[type], null);
else if (type == typeof(bool)) else if (type == typeof(bool))
{ {
var l = il.DefineLabel(); var l = il.DefineLabel();

View File

@@ -162,8 +162,8 @@ namespace OpenRA.Traits
}; };
foreach (var s in states) foreach (var s in states)
if (state >= s.First && anim.HasSequence(s.Second+baseSequence)) if (state >= s.First && anim.HasSequence(s.Second + baseSequence))
return s.Second+baseSequence; return s.Second + baseSequence;
return baseSequence; return baseSequence;
} }

View File

@@ -113,7 +113,7 @@ namespace OpenRA.Traits
void DrawTags(WorldRenderer wr, Actor self, int2 basePosition) void DrawTags(WorldRenderer wr, Actor self, int2 basePosition)
{ {
if (!self.Owner.IsAlliedWith(self.World.RenderPlayer)) if (!self.Owner.IsAlliedWith(self.World.RenderPlayer))
return; return;
var tagImages = new Animation(self.World, "pips"); var tagImages = new Animation(self.World, "pips");
var pal = wr.Palette(Info.Palette); var pal = wr.Palette(Info.Palette);

View File

@@ -107,7 +107,7 @@ namespace OpenRA.Widgets
if (ps.HasFlags(PanelSides.Center) && ss[8] != null) if (ps.HasFlags(PanelSides.Center) && ss[8] != null)
FillRectWithSprite(new Rectangle(bounds.Left + marginLeft, bounds.Top + marginTop, FillRectWithSprite(new Rectangle(bounds.Left + marginLeft, bounds.Top + marginTop,
bounds.Width - marginWidth, bounds.Height - marginHeight), bounds.Width - marginWidth, bounds.Height - marginHeight),
ss[8]); ss[8]);
// Left border // Left border
if (ps.HasFlags(PanelSides.Left) && ss[2] != null) if (ps.HasFlags(PanelSides.Left) && ss[2] != null)

View File

@@ -881,7 +881,7 @@ namespace OpenRA.Mods.RA.AI
// Protected harvesters or building // Protected harvesters or building
if ((self.HasTrait<Harvester>() || self.HasTrait<Building>()) && if ((self.HasTrait<Harvester>() || self.HasTrait<Building>()) &&
p.Stances[e.Attacker.Owner] == Stance.Enemy) p.Stances[e.Attacker.Owner] == Stance.Enemy)
{ {
defenseCenter = e.Attacker.Location; defenseCenter = e.Attacker.Location;
ProtectOwn(e.Attacker); ProtectOwn(e.Attacker);

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA.Air
return this; return this;
if (HeliFly.AdjustAltitude(self, helicopter, helicopter.Info.LandAltitude)) if (HeliFly.AdjustAltitude(self, helicopter, helicopter.Info.LandAltitude))
return this; return this;
return NextActivity; return NextActivity;
} }

View File

@@ -68,7 +68,7 @@ namespace OpenRA.Mods.RA
foreach (var a in Armaments.Where(a => a.Info.Name == info.Guns)) foreach (var a in Armaments.Where(a => a.Info.Name == info.Guns))
{ {
if (!target.IsInRange(self.CenterPosition, a.Weapon.Range)) if (!target.IsInRange(self.CenterPosition, a.Weapon.Range))
continue; continue;
var t = Target.FromPos(cp - new WVec(0, a.Weapon.Range.Range / 2, cp.Z).Rotate(WRot.FromFacing(f))); var t = Target.FromPos(cp - new WVec(0, a.Weapon.Range.Range / 2, cp.Z).Rotate(WRot.FromFacing(f)));
inAttackRange = true; inAttackRange = true;

View File

@@ -92,7 +92,7 @@ namespace OpenRA.Mods.RA
// This isn't the bridge you're looking for // This isn't the bridge you're looking for
if (!w.Map.IsInMap(x, y) || w.Map.MapTiles.Value[x, y].Type != tile || if (!w.Map.IsInMap(x, y) || w.Map.MapTiles.Value[x, y].Type != tile ||
w.Map.MapTiles.Value[x, y].Index != ind) w.Map.MapTiles.Value[x, y].Index != ind)
continue; continue;
subTiles.Add(new CPos(x, y), ind); subTiles.Add(new CPos(x, y), ind);

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA
// Steal and reset the owners exploration // Steal and reset the owners exploration
infiltrator.Owner.Shroud.Explore(self.Owner.Shroud); infiltrator.Owner.Shroud.Explore(self.Owner.Shroud);
if (!self.Owner.HasFogVisibility()) if (!self.Owner.HasFogVisibility())
self.Owner.Shroud.ResetExploration(); self.Owner.Shroud.ResetExploration();
} }
} }
} }

View File

@@ -217,7 +217,7 @@ namespace OpenRA.Mods.RA.Move
public void SetPosition(Actor self, CPos cell) public void SetPosition(Actor self, CPos cell)
{ {
SetLocation(cell,fromSubCell, cell,fromSubCell); SetLocation(cell, fromSubCell, cell, fromSubCell);
SetVisualPosition(self, fromCell.CenterPosition + MobileInfo.SubCellOffsets[fromSubCell]); SetVisualPosition(self, fromCell.CenterPosition + MobileInfo.SubCellOffsets[fromSubCell]);
FinishedMoving(self); FinishedMoving(self);
} }
@@ -225,7 +225,7 @@ namespace OpenRA.Mods.RA.Move
public void SetPosition(Actor self, WPos pos) public void SetPosition(Actor self, WPos pos)
{ {
var cell = pos.ToCPos(); var cell = pos.ToCPos();
SetLocation(cell,fromSubCell, cell,fromSubCell); SetLocation(cell, fromSubCell, cell, fromSubCell);
SetVisualPosition(self, pos); SetVisualPosition(self, pos);
FinishedMoving(self); FinishedMoving(self);
} }
@@ -355,14 +355,14 @@ namespace OpenRA.Mods.RA.Move
public string VoicePhraseForOrder(Actor self, Order order) public string VoicePhraseForOrder(Actor self, Order order)
{ {
switch( order.OrderString ) switch (order.OrderString)
{ {
case "Move": case "Move":
case "Scatter": case "Scatter":
case "Stop": case "Stop":
return "Move"; return "Move";
default: default:
return null; return null;
} }
} }
@@ -390,7 +390,7 @@ namespace OpenRA.Mods.RA.Move
return new[]{ fromSubCell, SubCell.TopLeft, SubCell.TopRight, SubCell.Center, return new[]{ fromSubCell, SubCell.TopLeft, SubCell.TopRight, SubCell.Center,
SubCell.BottomLeft, SubCell.BottomRight}.First(b => SubCell.BottomLeft, SubCell.BottomRight}.First(b =>
{ {
var blockingActors = self.World.ActorMap.GetUnitsAt(a,b).Where(c => c != ignoreActor); var blockingActors = self.World.ActorMap.GetUnitsAt(a, b).Where(c => c != ignoreActor);
if (blockingActors.Any()) if (blockingActors.Any())
{ {
// Non-sharable unit can enter a cell with shareable units only if it can crush all of them // Non-sharable unit can enter a cell with shareable units only if it can crush all of them
@@ -577,5 +577,5 @@ namespace OpenRA.Mods.RA.Move
var facing = Util.GetFacing(toPos - fromPos, Facing); var facing = Util.GetFacing(toPos - fromPos, Facing);
return Util.SequenceActivities(new Turn(facing), new Drag(fromPos, toPos, length)); return Util.SequenceActivities(new Turn(facing), new Drag(fromPos, toPos, length));
} }
} }
} }

View File

@@ -14,7 +14,7 @@ namespace OpenRA.Mods.RA
{ {
public static bool HasFogVisibility( this Player a ) public static bool HasFogVisibility( this Player a )
{ {
var gpsWatcher = a.PlayerActor.TraitOrDefault<GpsWatcher>(); var gpsWatcher = a.PlayerActor.TraitOrDefault<GpsWatcher>();
return gpsWatcher != null && (gpsWatcher.Granted || gpsWatcher.GrantedAllies); return gpsWatcher != null && (gpsWatcher.Granted || gpsWatcher.GrantedAllies);
} }

View File

@@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA
{ {
var position = self.CenterPosition; var position = self.CenterPosition;
if (position.Z > 0 && self.GetDamageState() >= info.MinDamage && if (position.Z > 0 && self.GetDamageState() >= info.MinDamage &&
!self.World.FogObscures(position.ToCPos())) !self.World.FogObscures(position.ToCPos()))
{ {
var offset = info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation)); var offset = info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation));
var pos = position + body.LocalToWorld(offset); var pos = position + body.LocalToWorld(offset);

View File

@@ -75,7 +75,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
panel.Get<LabelWidget>("TIME_LABEL").GetText = () => (currentSong == null) ? "" : panel.Get<LabelWidget>("TIME_LABEL").GetText = () => (currentSong == null) ? "" :
"{0:D2}:{1:D2} / {2:D2}:{3:D2}".F((int)Sound.MusicSeekPosition / 60, (int)Sound.MusicSeekPosition % 60, "{0:D2}:{1:D2} / {2:D2}:{3:D2}".F((int)Sound.MusicSeekPosition / 60, (int)Sound.MusicSeekPosition % 60,
currentSong.Length / 60, currentSong.Length % 60); currentSong.Length / 60, currentSong.Length % 60);
var musicSlider = panel.Get<SliderWidget>("MUSIC_SLIDER"); var musicSlider = panel.Get<SliderWidget>("MUSIC_SLIDER");
musicSlider.OnChange += x => Sound.MusicVolume = x; musicSlider.OnChange += x => Sound.MusicVolume = x;

View File

@@ -36,43 +36,43 @@ namespace OpenRA.TilesetBuilder
return Math.Abs(color.R - curr.R) + Math.Abs(color.G - curr.G) + Math.Abs(color.B - curr.B); return Math.Abs(color.R - curr.R) + Math.Abs(color.G - curr.G) + Math.Abs(color.B - curr.B);
} }
public void CreateNewTileset() public void CreateNewTileset()
{
this.Show();
using (var formNew = new FormNew { })
if (DialogResult.OK == formNew.ShowDialog())
{ {
PaletteFromImage = formNew.PaletteFromImage; this.Show();
PaletteFile = formNew.PaletteFile; using (var formNew = new FormNew { })
ImageFile = formNew.ImageFile; if (DialogResult.OK == formNew.ShowDialog())
TileSize = formNew.TileSize;
srcfile = ImageFile;
this.size = TileSize;
surface1.TileSize = TileSize;
Bitmap fbitmap = new Bitmap(ImageFile);
Bitmap rbitmap = fbitmap.Clone(new Rectangle(0, 0, fbitmap.Width, fbitmap.Height),
fbitmap.PixelFormat);
int[] shadowIndex = { };
if (!PaletteFromImage)
{ {
TerrainPalette = Palette.Load(PaletteFile, shadowIndex); PaletteFromImage = formNew.PaletteFromImage;
rbitmap.Palette = TerrainPalette.AsSystemPalette(); PaletteFile = formNew.PaletteFile;
} ImageFile = formNew.ImageFile;
TileSize = formNew.TileSize;
srcfile = ImageFile;
this.size = TileSize;
surface1.TileSize = TileSize;
Bitmap fbitmap = new Bitmap(ImageFile);
Bitmap rbitmap = fbitmap.Clone(new Rectangle(0, 0, fbitmap.Width, fbitmap.Height),
fbitmap.PixelFormat);
int[] shadowIndex = { };
if (!PaletteFromImage)
{
TerrainPalette = Palette.Load(PaletteFile, shadowIndex);
rbitmap.Palette = TerrainPalette.AsSystemPalette();
}
surface1.Image = (Bitmap)rbitmap; surface1.Image = (Bitmap)rbitmap;
surface1.TilesPerRow = surface1.Image.Size.Width / surface1.TileSize; surface1.TilesPerRow = surface1.Image.Size.Width / surface1.TileSize;
surface1.Image.SetResolution(96, 96); // people keep being noobs about DPI, and GDI+ cares. surface1.Image.SetResolution(96, 96); // people keep being noobs about DPI, and GDI+ cares.
surface1.TerrainTypes = new int[surface1.Image.Width / size, surface1.Image.Height / size]; /* all passable by default */ surface1.TerrainTypes = new int[surface1.Image.Width / size, surface1.Image.Height / size]; /* all passable by default */
surface1.Templates = new List<Template>(); surface1.Templates = new List<Template>();
surface1.Size = surface1.Image.Size; surface1.Size = surface1.Image.Size;
surface1.Enabled = true; surface1.Enabled = true;
Load(); Load();
}
} }
}
public FormBuilder(string src, string tsize, bool autoExport, string outputDir) public FormBuilder(string src, string tsize, bool autoExport, string outputDir)
{ {
@@ -426,13 +426,13 @@ namespace OpenRA.TilesetBuilder
// TemplateID CellID tilenr TemplateW TemplateH XinTilesPNG YinTilesPNG // TemplateID CellID tilenr TemplateW TemplateH XinTilesPNG YinTilesPNG
Console.WriteLine("{0} {1} {2} {3} {4} {5} {6}", Console.WriteLine("{0} {1} {2} {3} {4} {5} {6}",
cur, cur,
idx, idx,
((t.Key.Y * surface1.TilesPerRow) + t.Key.X), ((t.Key.Y * surface1.TilesPerRow) + t.Key.X),
tp.Width, tp.Width,
tp.Height, tp.Height,
t.Key.X, t.Key.X,
t.Key.Y); t.Key.Y);
} }
cur++; cur++;