Formatted all files.

Automatically formatted all files via VS. This generally corrects indentation, removes trailing whitespace and corrects misplaced tabs or spaces. Manually tweaked a few files where required.
This commit is contained in:
RoosterDragon
2015-01-04 22:09:32 +00:00
parent 6468c0b6e6
commit a6cda967c2
153 changed files with 740 additions and 698 deletions

View File

@@ -77,7 +77,7 @@ namespace OpenRA.Mods.RA.AI
"and ((EnemyHealth is NearDead) or (EnemyHealth is Injured) or (EnemyHealth is Normal)) " +
"and ((RelativeAttackPower is Weak) or (RelativeAttackPower is Equal) or (RelativeAttackPower is Strong)) " +
"and ((RelativeSpeed is Slow) or (RelativeSpeed is Equal) or (RelativeSpeed is Fast))) " +
"then AttackOrFlee is Attack");
"then AttackOrFlee is Attack");
}
protected virtual void AddingRulesForInjuredOwnHealth()
@@ -212,7 +212,7 @@ namespace OpenRA.Mods.RA.AI
return RelativeValue(own, enemy, 100, Average<Mobile>, (Actor a) => a.Trait<Mobile>().Info.Speed);
}
protected static float RelativeValue(IEnumerable<Actor> own, IEnumerable<Actor> enemy, float normalizeByValue,
protected static float RelativeValue(IEnumerable<Actor> own, IEnumerable<Actor> enemy, float normalizeByValue,
Func<IEnumerable<Actor>, Func<Actor, int>, float> relativeFunc, Func<Actor, int> getValue)
{
if (!enemy.Any())

View File

@@ -180,7 +180,7 @@ namespace OpenRA.Mods.RA.AI
{
Info = info;
World = init.World;
foreach (var decision in info.PowerDecisions)
powerDecisions.Add(decision.OrderName, decision);
}
@@ -200,9 +200,9 @@ namespace OpenRA.Mods.RA.AI
supportPowerMngr = p.PlayerActor.Trait<SupportPowerManager>();
playerResource = p.PlayerActor.Trait<PlayerResources>();
foreach (var building in Info.BuildingQueues)
foreach (var building in Info.BuildingQueues)
builders.Add(new BaseBuilder(this, building, p, playerPower, playerResource));
foreach (var defense in Info.DefenseQueues)
foreach (var defense in Info.DefenseQueues)
builders.Add(new BaseBuilder(this, defense, p, playerPower, playerResource));
Random = new MersenneTwister((int)p.PlayerActor.ActorID);
@@ -310,7 +310,7 @@ namespace OpenRA.Mods.RA.AI
// For mods like RA (number of building must match the number of aircraft)
bool HasAdequateAirUnits(ActorInfo actorInfo)
{
if (!actorInfo.Traits.Contains<ReloadsInfo>() && actorInfo.Traits.Contains<LimitedAmmoInfo>()
if (!actorInfo.Traits.Contains<ReloadsInfo>() && actorInfo.Traits.Contains<LimitedAmmoInfo>()
&& actorInfo.Traits.Contains<AircraftInfo>())
{
var countOwnAir = CountUnits(actorInfo.Name, Player);
@@ -387,7 +387,7 @@ namespace OpenRA.Mods.RA.AI
}
// Can't find a build location
return null;
return null;
}
public void Tick(Actor self)
@@ -402,7 +402,7 @@ namespace OpenRA.Mods.RA.AI
if (ticks % FeedbackTime == 0)
ProductionUnits(self);
AssignRolesToIdleUnits(self);
SetRallyPointsForNewProductionBuildings(self);
TryToUseSupportPower(self);
@@ -504,7 +504,7 @@ namespace OpenRA.Mods.RA.AI
void AssignRolesToIdleUnits(Actor self)
{
CleanSquads();
activeUnits.RemoveAll(a => a.IsDead || a.Owner != Player);
activeUnits.RemoveAll(a => a.IsDead || a.Owner != Player);
unitsHangingAroundTheBase.RemoveAll(a => a.IsDead || a.Owner != Player);
if (--rushTicks <= 0)
@@ -555,7 +555,7 @@ namespace OpenRA.Mods.RA.AI
// Tell the idle harvester to quit slacking:
World.IssueOrder(new Order("Harvest", a, false));
}
}
}
void FindNewUnits(Actor self)
@@ -582,7 +582,7 @@ namespace OpenRA.Mods.RA.AI
}
activeUnits.Add(a);
}
}
}
void CreateAttackForce()
@@ -616,7 +616,7 @@ namespace OpenRA.Mods.RA.AI
{
var enemies = World.FindActorsInCircle(b.CenterPosition, WRange.FromCells(Info.RushAttackScanRadius))
.Where(unit => Player.Stances[unit.Owner] == Stance.Enemy && unit.HasTrait<AttackBase>()).ToList();
if (rushFuzzy.CanAttack(ownUnits, enemies))
{
var target = enemies.Any() ? enemies.Random(Random) : b;
@@ -626,7 +626,7 @@ namespace OpenRA.Mods.RA.AI
foreach (var a3 in ownUnits)
rush.Units.Add(a3);
return;
}
}
@@ -803,7 +803,7 @@ namespace OpenRA.Mods.RA.AI
var tl = World.Map.CenterOfCell(new CPos(i, j));
var br = World.Map.CenterOfCell(new CPos(i + checkRadius, j + checkRadius));
var targets = World.ActorMap.ActorsInBox(tl, br);
consideredAttractiveness = powerDecision.GetAttractiveness(targets, Player);
if (consideredAttractiveness <= bestAttractiveness || consideredAttractiveness < powerDecision.MinimumAttractiveness)
continue;
@@ -881,7 +881,7 @@ namespace OpenRA.Mods.RA.AI
return;
var unit = buildRandom ?
ChooseRandomUnitToBuild(queue) :
ChooseRandomUnitToBuild(queue) :
ChooseUnitToBuild(queue);
if (unit != null && Info.UnitsToBuild.Any(u => u.Key == unit.Name))
@@ -914,8 +914,7 @@ namespace OpenRA.Mods.RA.AI
{
BotDebug("Bot noticed damage {0} {1}->{2}, repairing.",
self, e.PreviousDamageState, e.DamageState);
World.IssueOrder(new Order("RepairBuilding", self.Owner.PlayerActor, false)
{ TargetActor = self });
World.IssueOrder(new Order("RepairBuilding", self.Owner.PlayerActor, false) { TargetActor = self });
}
}

View File

@@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA.Activities
if (ml.Minefield.Length > 0)
{
// dont get stuck forever here
for (var n = 0; n < 20; n++)
for (var n = 0; n < 20; n++)
{
var p = ml.Minefield.Random(self.World.SharedRandom);
if (ShouldLayMine(self, p))

View File

@@ -47,7 +47,8 @@ namespace OpenRA.Mods.RA
state = State.Dock;
return Util.SequenceActivities(new Turn(self, angle), this);
case State.Dock:
ru.PlayCustomAnimation(self, "dock", () => {
ru.PlayCustomAnimation(self, "dock", () =>
{
ru.PlayCustomAnimRepeating(self, "dock-loop");
if (proc.IsInWorld && !proc.IsDead)
foreach (var nd in proc.TraitsImplementing<INotifyDocking>())

View File

@@ -1,12 +1,12 @@
#region Copyright & License Information
/*
#region Copyright & License Information
/*
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
#endregion
using System;
using OpenRA.Traits;

View File

@@ -38,8 +38,8 @@ namespace OpenRA.Mods.RA.Effects
public void Tick(World world)
{
if (!building.IsInWorld || building.IsDead ||
rb == null || !rb.Repairers.Any())
if (!building.IsInWorld || building.IsDead ||
rb == null || !rb.Repairers.Any())
world.AddFrameEndTask(w => w.Remove(this));
anim.Tick();
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA.Effects
return anim.Render(building.CenterPosition, palette);
}
void CycleRepairer()
void CycleRepairer()
{
anim.PlayThen("repair", CycleRepairer);

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA.Traits
var pilot = self.World.CreateActor(false, info.PilotActor.ToLowerInvariant(),
new TypeDictionary { new OwnerInit(self.Owner), new LocationInit(self.Location) });
if (info.AllowUnsuitableCell || IsSuitableCell(self, pilot))
{
if (cp.Z > 0)

View File

@@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA.Graphics
public PaletteReference Palette { get { return null; } }
public int ZOffset { get { return zOffset; } }
public bool IsDecoration { get { return true; } }
public IRenderable WithScale(float newScale) { return new TeslaZapRenderable(pos, zOffset, length, image, brightZaps, dimZaps, palette); }
public IRenderable WithPalette(PaletteReference newPalette) { return new TeslaZapRenderable(pos, zOffset, length, image, brightZaps, dimZaps, palette); }
public IRenderable WithZOffset(int newOffset) { return new TeslaZapRenderable(pos, zOffset, length, image, brightZaps, dimZaps, palette); }
@@ -81,10 +81,10 @@ namespace OpenRA.Mods.RA.Graphics
{
var bright = wr.World.Map.SequenceProvider.GetSequence(image, "bright");
var dim = wr.World.Map.SequenceProvider.GetSequence(image, "dim");
var source = wr.ScreenPosition(pos);
var target = wr.ScreenPosition(pos + length);
for (var n = 0; n < dimZaps; n++)
foreach (var z in DrawZapWandering(wr, source, target, dim, palette))
yield return z;

View File

@@ -20,9 +20,9 @@ namespace OpenRA.Mods.RA
{
if (map.Bounds.Left == 0 || map.Bounds.Top == 0
|| map.Bounds.Right == map.MapSize.X || map.Bounds.Bottom == map.MapSize.Y)
emitError("This map does not define a valid cordon.\n"
+ "A one cell (or greater) border is required on all four sides "
+ "between the playable bounds and the map edges");
emitError("This map does not define a valid cordon.\n"
+ "A one cell (or greater) border is required on all four sides "
+ "between the playable bounds and the map edges");
}
}
}

View File

@@ -12,7 +12,6 @@ using OpenRA.Mods.Common;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Traits
{
[Desc("Attach this to the player actor to allow building repair by team mates.")]
class AllyRepairInfo : TraitInfo<AllyRepair> { }

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA
if (queue == null)
return;
var buildingInfo = unit.Traits.Get<BuildingInfo>();
if (order.OrderString == "LineBuild")

View File

@@ -17,8 +17,8 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
[Desc("Attach this to an actor (usually a building) to let it produce units or construct buildings.",
"If one builds another actor of this type, he will get a separate queue to create two actors",
[Desc("Attach this to an actor (usually a building) to let it produce units or construct buildings.",
"If one builds another actor of this type, he will get a separate queue to create two actors",
"at the same time. Will only work together with the Production: trait.")]
public class ProductionQueueInfo : ITraitInfo
{
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA
[Desc("The build time is multiplied with this value on low power.")]
public readonly int LowPowerSlowdown = 3;
[Desc("Notification played when production is complete.",
[Desc("Notification played when production is complete.",
"The filename of the audio is defined per faction in notifications.yaml.")]
public readonly string ReadyAudio = "UnitReady";
@@ -254,70 +254,70 @@ namespace OpenRA.Mods.RA
switch (order.OrderString)
{
case "StartProduction":
{
var unit = self.World.Map.Rules.Actors[order.TargetString];
var bi = unit.Traits.Get<BuildableInfo>();
if (!bi.Queue.Contains(Info.Type))
return; /* Not built by this queue */
var cost = unit.Traits.Contains<ValuedInfo>() ? unit.Traits.Get<ValuedInfo>().Cost : 0;
var time = GetBuildTime(order.TargetString);
if (BuildableItems().All(b => b.Name != order.TargetString))
return; /* you can't build that!! */
// Check if the player is trying to build more units that they are allowed
var fromLimit = int.MaxValue;
if (bi.BuildLimit > 0)
case "StartProduction":
{
var inQueue = queue.Count(pi => pi.Item == order.TargetString);
var owned = self.Owner.World.ActorsWithTrait<Buildable>().Count(a => a.Actor.Info.Name == order.TargetString && a.Actor.Owner == self.Owner);
fromLimit = bi.BuildLimit - (inQueue + owned);
var unit = self.World.Map.Rules.Actors[order.TargetString];
var bi = unit.Traits.Get<BuildableInfo>();
if (!bi.Queue.Contains(Info.Type))
return; /* Not built by this queue */
if (fromLimit <= 0)
return;
}
var cost = unit.Traits.Contains<ValuedInfo>() ? unit.Traits.Get<ValuedInfo>().Cost : 0;
var time = GetBuildTime(order.TargetString);
var amountToBuild = Math.Min(fromLimit, order.ExtraData);
for (var n = 0; n < amountToBuild; n++)
{
var hasPlayedSound = false;
BeginProduction(new ProductionItem(this, order.TargetString, cost, playerPower, () => self.World.AddFrameEndTask(_ =>
if (BuildableItems().All(b => b.Name != order.TargetString))
return; /* you can't build that!! */
// Check if the player is trying to build more units that they are allowed
var fromLimit = int.MaxValue;
if (bi.BuildLimit > 0)
{
var isBuilding = unit.Traits.Contains<BuildingInfo>();
if (isBuilding && !hasPlayedSound)
var inQueue = queue.Count(pi => pi.Item == order.TargetString);
var owned = self.Owner.World.ActorsWithTrait<Buildable>().Count(a => a.Actor.Info.Name == order.TargetString && a.Actor.Owner == self.Owner);
fromLimit = bi.BuildLimit - (inQueue + owned);
if (fromLimit <= 0)
return;
}
var amountToBuild = Math.Min(fromLimit, order.ExtraData);
for (var n = 0; n < amountToBuild; n++)
{
var hasPlayedSound = false;
BeginProduction(new ProductionItem(this, order.TargetString, cost, playerPower, () => self.World.AddFrameEndTask(_ =>
{
hasPlayedSound = Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Country.Race);
}
else if (!isBuilding)
{
if (BuildUnit(order.TargetString))
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Country.Race);
else if (!hasPlayedSound && time > 0)
var isBuilding = unit.Traits.Contains<BuildingInfo>();
if (isBuilding && !hasPlayedSound)
{
hasPlayedSound = Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.BlockedAudio, self.Owner.Country.Race);
hasPlayedSound = Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Country.Race);
}
}
})));
else if (!isBuilding)
{
if (BuildUnit(order.TargetString))
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Country.Race);
else if (!hasPlayedSound && time > 0)
{
hasPlayedSound = Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.BlockedAudio, self.Owner.Country.Race);
}
}
})));
}
break;
}
break;
}
case "PauseProduction":
{
if (queue.Count > 0 && queue[0].Item == order.TargetString)
queue[0].Pause(order.ExtraData != 0);
case "PauseProduction":
{
if (queue.Count > 0 && queue[0].Item == order.TargetString)
queue[0].Pause(order.ExtraData != 0);
break;
}
break;
}
case "CancelProduction":
{
CancelProduction(order.TargetString, order.ExtraData);
break;
}
case "CancelProduction":
{
CancelProduction(order.TargetString, order.ExtraData);
break;
}
}
}

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA
// Queue-per-actor
var queue = world.Selection.Actors
.Where(a => a.IsInWorld && a.World.LocalPlayer == a.Owner)
.Where(a => a.IsInWorld && a.World.LocalPlayer == a.Owner)
.SelectMany(a => a.TraitsImplementing<ProductionQueue>())
.FirstOrDefault(q => q.Enabled);

View File

@@ -40,8 +40,11 @@ namespace OpenRA.Mods.RA.Traits
public IEnumerable<IOrderTargeter> Orders
{
get { yield return new EnterAlliedActorTargeter<Building>("Repair", 5,
target => CanRepairAt(target), _ => CanRepair()); }
get
{
yield return new EnterAlliedActorTargeter<Building>("Repair", 5,
target => CanRepairAt(target), _ => CanRepair());
}
}
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)

View File

@@ -87,7 +87,7 @@ namespace OpenRA.Mods.RA.Scripting
if (af != null)
{
actor.QueueActivity(new CallFunc(() =>
actor.QueueActivity(new CallFunc(() =>
{
af.Call(actor.ToLuaValue(Context));
af.Dispose();

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Scripting
public class PlayerProperties : ScriptPlayerProperties
{
public PlayerProperties(ScriptContext context, Player player)
: base(context, player) { }
: base(context, player) { }
[Desc("The player's name.")]
public string Name { get { return Player.PlayerName; } }

View File

@@ -87,7 +87,7 @@ namespace OpenRA.Mods.RA.Traits
{
if (!a.Owner.IsAlliedWith(Self.Owner))
return false;
var um = a.TraitOrDefault<UpgradeManager>();
return um != null && info.Upgrades.Any(u => um.AcceptsUpgrade(a, u));
});

View File

@@ -111,7 +111,7 @@ namespace OpenRA.Mods.RA.Traits
Info.BeaconPoster,
Info.BeaconPosterPalette,
() => missile.FractionComplete);
Action removeBeacon = () => self.World.AddFrameEndTask(w =>
{
w.Remove(beacon);

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA.Traits
public readonly string[] ShorePieces = { "br1", "br2" };
public readonly int[] NorthOffset = null;
public readonly int[] SouthOffset = null;
[Desc("The name of the weapon to use when demolishing the bridge")]
public readonly string DemolishWeapon = "Demolish";

View File

@@ -1,12 +1,12 @@
#region Copyright & License Information
/*
#region Copyright & License Information
/*
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
#endregion
using System;
using System.Linq;

View File

@@ -18,6 +18,6 @@ namespace OpenRA.Mods.RA.Traits
class Fake : ITags
{
public IEnumerable<TagType> GetTags() { yield return TagType.Fake; }
public IEnumerable<TagType> GetTags() { yield return TagType.Fake; }
}
}

View File

@@ -52,7 +52,7 @@ namespace OpenRA.Mods.RA.Traits
if (!IsTraitDisabled && self.AppearsFriendlyTo(player.PlayerActor))
{
// If the player won't affect the repair, we won't add him
if (!Repairers.Remove(player) && Repairers.Count < Info.RepairBonuses.Length)
if (!Repairers.Remove(player) && Repairers.Count < Info.RepairBonuses.Length)
{
Repairers.Add(player);
Sound.PlayNotification(self.World.Map.Rules, player, "Speech", "Repairing", player.Country.Race);
@@ -106,7 +106,7 @@ namespace OpenRA.Mods.RA.Traits
}
// Bonus is applied after finding players who can pay
// activePlayers won't cause IndexOutOfRange because we capped the max amount of players
// to the length of the array
self.InflictDamage(self, -(hpToRepair * Info.RepairBonuses[activePlayers - 1] / 100), null);

View File

@@ -74,7 +74,8 @@ namespace OpenRA.Mods.RA.Traits
{
s.First.Activate(crusher);
return;
} else
}
else
n -= s.Second;
}
}

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA.Traits
[Desc("The earliest time (in ticks) that this crate action can occur on.")]
public readonly int TimeDelay = 0;
[Desc("Only allow this crate action when the collector has these prerequisites")]
public readonly string[] Prerequisites = { };

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.RA.Traits
readonly GrantUpgradeCrateActionInfo info;
public GrantUpgradeCrateAction(Actor self, GrantUpgradeCrateActionInfo info)
: base(self, info)
: base(self, info)
{
this.self = self;
this.info = info;

View File

@@ -286,7 +286,7 @@ namespace OpenRA.Mods.RA.Traits
idleSmart = true;
self.CancelActivity();
var mobile = self.Trait<Mobile>();
if (order.TargetLocation != CPos.Zero)
{

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA.Traits
public readonly int Percentage = 50;
public readonly int Minimum = 500;
public readonly string SoundToVictim = "credit1.aud";
public object Create(ActorInitializer init) { return new InfiltrateForCash(this); }
}
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA.Traits
var toTake = (targetResources.Cash + targetResources.Resources) * info.Percentage / 100;
var toGive = Math.Max(toTake, info.Minimum);
targetResources.TakeCash(toTake);
spyResources.GiveCash(toGive);

View File

@@ -75,17 +75,17 @@ namespace OpenRA.Mods.RA.Traits
using (var se = sourceTiles.GetEnumerator())
using (var de = destTiles.GetEnumerator())
while (se.MoveNext() && de.MoveNext())
{
var a = se.Current;
var b = de.Current;
while (se.MoveNext() && de.MoveNext())
{
var a = se.Current;
var b = de.Current;
if (!Self.Owner.Shroud.IsExplored(a) || !Self.Owner.Shroud.IsExplored(b))
return false;
if (!Self.Owner.Shroud.IsExplored(a) || !Self.Owner.Shroud.IsExplored(b))
return false;
if (Self.World.Map.GetTerrainIndex(a) != Self.World.Map.GetTerrainIndex(b))
return false;
}
if (Self.World.Map.GetTerrainIndex(a) != Self.World.Map.GetTerrainIndex(b))
return false;
}
return true;
}
@@ -242,7 +242,7 @@ namespace OpenRA.Mods.RA.Traits
{
var targetCell = unit.Location + (xy - sourceLocation);
var canEnter = manager.Self.Owner.Shroud.IsExplored(targetCell) &&
unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit, targetCell);
unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit, targetCell);
var tile = canEnter ? validTile : invalidTile;
yield return new SpriteRenderable(tile, wr.World.Map.CenterOfCell(targetCell), WVec.Zero, -511, pal, 1f, true);
}

View File

@@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA.Traits
public void RefreshGps(Actor atek)
{
RefreshGranted();
foreach (var i in atek.World.ActorsWithTrait<GpsWatcher>())
i.Trait.RefreshGranted();
@@ -92,7 +92,8 @@ namespace OpenRA.Mods.RA.Traits
{
GpsWatcher owner;
public GpsPower(Actor self, GpsPowerInfo info) : base(self, info)
public GpsPower(Actor self, GpsPowerInfo info)
: base(self, info)
{
owner = self.Owner.PlayerActor.Trait<GpsWatcher>();
owner.GpsAdd(self);

View File

@@ -32,8 +32,10 @@ namespace OpenRA.Mods.RA.Traits
public override string[] TargetTypes
{
get { return cloak.Cloaked ? info.CloakedTargetTypes
: info.TargetTypes; }
get
{
return cloak.Cloaked ? info.CloakedTargetTypes : info.TargetTypes;
}
}
}
}

View File

@@ -93,7 +93,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
abortButton.OnClick = () => { Ui.CloseWindow(); onAbort(); };
retryButton.Visible = onRetry != null;
retryButton.OnClick = () =>
retryButton.OnClick = () =>
{
var password = passwordField != null && passwordField.IsVisible() ? passwordField.Text : orderManager.Password;

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public class CreditsLogic
{
[ObjectCreator.UseCtor]
public CreditsLogic(Widget widget, Action onExit)
public CreditsLogic(Widget widget, Action onExit)
{
var panel = widget.Get("CREDITS_PANEL");

View File

@@ -76,7 +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;

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (timer != null)
{
timer.GetText = () =>
timer.GetText = () =>
{
if (status == null && shouldShowStatus())
return statusText();

View File

@@ -71,7 +71,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
ConfirmationDialogs.PromptConfirmAction("Abort Mission", "Leave this game and return to the menu?", onQuit, showMenu);
};
Action onSurrender = () =>
Action onSurrender = () =>
{
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
closeMenu();

View File

@@ -155,7 +155,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var mapButton = lobby.GetOrNull<ButtonWidget>("CHANGEMAP_BUTTON");
if (mapButton != null)
{
mapButton.IsDisabled = configurationDisabled;
mapButton.IsDisabled = configurationDisabled;
mapButton.OnClick = () =>
{
var onSelect = new Action<string>(uid =>
@@ -322,7 +322,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
allowCheats.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllowCheats;
allowCheats.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.Cheats.HasValue || configurationDisabled();
allowCheats.OnClick = () => orderManager.IssueOrder(Order.Command(
allowCheats.OnClick = () => orderManager.IssueOrder(Order.Command(
"allowcheats {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowCheats)));
}
@@ -629,7 +629,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (Map.Status == MapStatus.Available)
{
// Maps need to be validated and pre-loaded before they can be accessed
new Thread(_ =>
new Thread(_ =>
{
var map = Map;
map.CacheRules();
@@ -820,7 +820,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public Action OnClick;
}
}
public class LobbyCountry
{
public string Name;

View File

@@ -107,20 +107,20 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var statusSearching = progress.GetOrNull("MAP_STATUS_SEARCHING");
if (statusSearching != null)
statusSearching.IsVisible = () => lobby.Map.Status == MapStatus.Searching;
statusSearching.IsVisible = () => lobby.Map.Status == MapStatus.Searching;
var statusUnavailable = progress.GetOrNull("MAP_STATUS_UNAVAILABLE");
if (statusUnavailable != null)
statusUnavailable.IsVisible = () => lobby.Map.Status == MapStatus.Unavailable;
statusUnavailable.IsVisible = () => lobby.Map.Status == MapStatus.Unavailable;
var statusError = progress.GetOrNull("MAP_STATUS_ERROR");
if (statusError != null)
statusError.IsVisible = () => lobby.Map.Status == MapStatus.DownloadError;
statusError.IsVisible = () => lobby.Map.Status == MapStatus.DownloadError;
var statusDownloading = progress.GetOrNull<LabelWidget>("MAP_STATUS_DOWNLOADING");
if (statusDownloading != null)
{
statusDownloading.IsVisible = () => lobby.Map.Status == MapStatus.Downloading;
statusDownloading.IsVisible = () => lobby.Map.Status == MapStatus.Downloading;
statusDownloading.GetText = () =>
{
if (lobby.Map.DownloadBytes == 0)

View File

@@ -345,7 +345,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
checkBox.IsVisible = () => orderManager.LocalClient.IsAdmin && !skirmishMode;
checkBox.IsDisabled = () => false;
Action okPressed = () =>
Action okPressed = () =>
{
orderManager.IssueOrder(Order.Command("allow_spectators {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowSpectators)));
orderManager.IssueOrders(

View File

@@ -78,7 +78,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
mapfilterInput.TakeKeyboardFocus();
mapfilterInput.OnEscKey = () =>
{
{
if (mapfilterInput.Text.Length == 0)
canceling();
else
@@ -87,7 +87,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
EnumerateMaps(onSelect, filter);
}
return true;
return true;
};
mapfilterInput.OnEnterKey = () => { approving(); return true; };
mapfilterInput.OnTextEdited = () =>

View File

@@ -217,14 +217,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (title != null)
{
title.GetText = () => game.Name;
title.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : title.TextColor;
title.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : title.TextColor;
}
var maptitle = item.GetOrNull<LabelWidget>("MAP");
if (title != null)
{
maptitle.GetText = () => map.Title;
maptitle.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : maptitle.TextColor;
maptitle.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : maptitle.TextColor;
}
var players = item.GetOrNull<LabelWidget>("PLAYERS");
@@ -232,7 +232,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
players.GetText = () => "{0} / {1}".F(game.Players, game.MaxPlayers)
+ (game.Spectators > 0 ? " ({0} Spectator{1})".F(game.Spectators, game.Spectators > 1 ? "s" : "") : "");
players.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : players.TextColor;
players.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : players.TextColor;
}
var state = item.GetOrNull<LabelWidget>("STATE");
@@ -254,7 +254,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
var cachedServerLocation = LobbyUtils.LookupCountry(game.Address.Split(':')[0]);
location.GetText = () => cachedServerLocation;
location.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : location.TextColor;
location.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : location.TextColor;
}
rows.Add(item);

View File

@@ -51,24 +51,24 @@ namespace OpenRA.Mods.RA.Widgets.Logic
labelText = "Unexplored Terrain";
break;
case WorldTooltipType.Actor:
{
o = viewport.ActorTooltip.Owner;
showOwner = !o.NonCombatant && viewport.ActorTooltip.TooltipInfo.IsOwnerRowVisible;
{
o = viewport.ActorTooltip.Owner;
showOwner = !o.NonCombatant && viewport.ActorTooltip.TooltipInfo.IsOwnerRowVisible;
var stance = o == null || world.RenderPlayer == null ? Stance.None : o.Stances[world.RenderPlayer];
labelText = viewport.ActorTooltip.TooltipInfo.TooltipForPlayerStance(stance);
break;
}
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;
{
o = viewport.FrozenActorTooltip.TooltipOwner;
showOwner = !o.NonCombatant && viewport.FrozenActorTooltip.TooltipInfo.IsOwnerRowVisible;
var stance = o == null || world.RenderPlayer == null ? Stance.None : o.Stances[world.RenderPlayer];
labelText = viewport.FrozenActorTooltip.TooltipInfo.TooltipForPlayerStance(stance);
break;
}
var stance = o == null || world.RenderPlayer == null ? Stance.None : o.Stances[world.RenderPlayer];
labelText = viewport.FrozenActorTooltip.TooltipInfo.TooltipForPlayerStance(stance);
break;
}
}
var textWidth = font.Measure(labelText).X;

View File

@@ -295,7 +295,7 @@ namespace OpenRA.Mods.RA.Widgets
if (ReadyTextStyle == ReadyTextStyleOptions.Solid || orderManager.LocalFrameNumber / 9 % 2 == 0)
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

@@ -74,7 +74,7 @@ namespace OpenRA.Mods.RA.Widgets
var oldIconCount = IconCount;
IconCount = 0;
var rb = RenderBounds;
foreach (var p in powers)
{

View File

@@ -63,7 +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;