diff --git a/OpenRA.Game/GameInformation.cs b/OpenRA.Game/GameInformation.cs
index a4d191d599..9776fd688b 100644
--- a/OpenRA.Game/GameInformation.cs
+++ b/OpenRA.Game/GameInformation.cs
@@ -16,62 +16,30 @@ using OpenRA.Network;
namespace OpenRA
{
- ///
- /// Contains information about a finished game
- ///
public class GameInformation
{
- /// The map identifier.
public string MapUid;
- /// The map title.
public string MapTitle;
- /// Game start timestamp.
public DateTime StartTimeUtc;
- /// Game end timestamp (when the recoding stopped).
+ // Game end timestamp (when the recoding stopped).
public DateTime EndTimeUtc;
- ///
- /// Gets the game's duration, from the time the game started until the
- /// replay recording stopped.
- ///
- /// The game's duration.
+ // Gets the game's duration, from the time the game started until the
+ // replay recording stopped.
public TimeSpan Duration { get { return EndTimeUtc > StartTimeUtc ? EndTimeUtc - StartTimeUtc : TimeSpan.Zero; } }
- ///
- /// Gets the list of players.
- ///
- /// The players.
public IList Players { get; private set; }
- ///
- /// Gets the map preview, using and the .
- ///
- /// The map preview.
public MapPreview MapPreview { get { return Game.modData.MapCache[MapUid]; } }
- ///
- /// Gets the human players.
- ///
- /// The human players.
public IEnumerable HumanPlayers { get { return Players.Where(p => p.IsHuman); } }
- ///
- /// Gets a value indicating whether this instance has just one human player.
- ///
- /// true if this instance has just one human player; otherwise, false.
public bool IsSinglePlayer { get { return HumanPlayers.Count() == 1; } }
Dictionary playersByRuntime;
- ///
- /// Initializes a new instance of the class.
- ///
public GameInformation()
{
Players = new List();
playersByRuntime = new Dictionary();
}
- ///
- /// Deserialize the specified data into a new instance.
- ///
- /// Data.
public static GameInformation Deserialize(string data)
{
try
@@ -104,9 +72,6 @@ namespace OpenRA
}
}
- ///
- /// Serialize this instance.
- ///
public string Serialize()
{
var nodes = new List();
@@ -119,11 +84,7 @@ namespace OpenRA
return nodes.WriteToString();
}
- ///
- /// Adds the start-up player information.
- ///
- /// Runtime player.
- /// Lobby info.
+ // Adds the player information at start-up.
public void AddPlayer(OpenRA.Player runtimePlayer, Session lobbyInfo)
{
if (runtimePlayer == null)
@@ -160,11 +121,7 @@ namespace OpenRA
Players.Add(player);
}
- ///
- /// Gets the player information for the specified runtime player instance.
- ///
- /// The player, or null.
- /// Runtime player.
+ // Gets the player information for the specified runtime player instance.
public Player GetPlayer(OpenRA.Player runtimePlayer)
{
Player player;
@@ -174,56 +131,37 @@ namespace OpenRA
return player;
}
- /// Specifies whether the player was defeated, victorious, or there was no outcome defined.
- public enum GameOutcome
- {
- /// Unknown outcome.
- Undefined,
- /// The player was defeated
- Defeat,
- /// The player was victorious
- Victory
- }
-
- ///
- /// Information about a player
- ///
public class Player
{
//
// Start-up information
//
- /// The client index.
public int ClientIndex;
- /// The player name, not guaranteed to be unique.
+ // The player name, not guaranteed to be unique.
public string Name;
- /// true if the player is a human player; otherwise, false.
public bool IsHuman;
- /// true if the player is a bot; otherwise, false.
public bool IsBot;
- /// The faction name (aka Country).
+ // The faction name (aka Country)
public string FactionName;
- /// The faction id (aka Country, aka Race).
+ // The faction id (aka Country, aka Race)
public string FactionId;
- /// The color used by the player in the game.
public HSLColor Color;
- /// The team id on start-up, or 0 if the player is not part of the team.
+ // The team id on start-up, or 0 if the player is not part of the team.
public int Team;
- /// The index of the spawn point on the map, or 0 if the player is not part of the team.
public int SpawnPoint;
- /// true if the faction was chosen at random; otherwise, false.
+ // True if the faction was chosen at random; otherwise, false
public bool IsRandomFaction;
- /// true if the spawn point was chosen at random; otherwise, false.
+ // True if the spawn point was chosen at random; otherwise, false.
public bool IsRandomSpawnPoint;
//
// Information gathered at a later stage
//
- /// The game outcome for this player.
- public GameOutcome Outcome;
- /// The time when this player won or lost the game.
+ // The game outcome for this player
+ public WinState Outcome;
+ // The time when this player won or lost the game
public DateTime OutcomeTimestampUtc;
}
}
diff --git a/OpenRA.Game/Player.cs b/OpenRA.Game/Player.cs
index ff5d5a8a2f..fcea4dc616 100644
--- a/OpenRA.Game/Player.cs
+++ b/OpenRA.Game/Player.cs
@@ -23,7 +23,7 @@ using OpenRA.Traits;
namespace OpenRA
{
public enum PowerState { Normal, Low, Critical };
- public enum WinState { Won, Lost, Undefined };
+ public enum WinState { Undefined, Won, Lost };
public class Player : IScriptBindable, IScriptNotifyBind, ILuaTableBinding, ILuaEqualityBinding, ILuaToStringBinding
{
diff --git a/OpenRA.Game/Widgets/LabelWidget.cs b/OpenRA.Game/Widgets/LabelWidget.cs
index e5110b1176..42b913c166 100644
--- a/OpenRA.Game/Widgets/LabelWidget.cs
+++ b/OpenRA.Game/Widgets/LabelWidget.cs
@@ -58,7 +58,7 @@ namespace OpenRA.Widgets
{
SpriteFont font;
if (!Game.Renderer.Fonts.TryGetValue(Font, out font))
- throw new ArgumentException("Request font '{0}' was not found.".F(Font));
+ throw new ArgumentException("Requested font '{0}' was not found.".F(Font));
var text = GetText();
if (text == null)
diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs
index df94effcd2..c7cf404a55 100644
--- a/OpenRA.Game/World.cs
+++ b/OpenRA.Game/World.cs
@@ -308,9 +308,7 @@ namespace OpenRA
var pi = gameInfo.GetPlayer(player);
if (pi != null)
{
- pi.Outcome = player.WinState == WinState.Lost ? GameInformation.GameOutcome.Defeat
- : player.WinState == WinState.Won ? GameInformation.GameOutcome.Victory
- : GameInformation.GameOutcome.Undefined;
+ pi.Outcome = player.WinState;
pi.OutcomeTimestampUtc = DateTime.UtcNow;
}
}
diff --git a/OpenRA.Mods.RA/MPStartLocations.cs b/OpenRA.Mods.RA/MPStartLocations.cs
index 0ae43f4d16..6569df50d9 100755
--- a/OpenRA.Mods.RA/MPStartLocations.cs
+++ b/OpenRA.Mods.RA/MPStartLocations.cs
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA
var client = world.LobbyInfo.ClientInSlot(kv.Key);
var spid = (client == null || client.SpawnPoint == 0)
? ChooseSpawnPoint(world, available, taken)
- : spawns[client.SpawnPoint-1];
+ : spawns[client.SpawnPoint-1];
Start.Add(player, spid);
diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyMapPreviewLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyMapPreviewLogic.cs
index 67a551b9a6..46e27c493c 100644
--- a/OpenRA.Mods.RA/Widgets/Logic/LobbyMapPreviewLogic.cs
+++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyMapPreviewLogic.cs
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var preview = available.Get("MAP_PREVIEW");
preview.Preview = () => lobby.Map;
preview.OnMouseDown = mi => LobbyUtils.SelectSpawnPoint(orderManager, preview, lobby.Map, mi);
- preview.SpawnOccupants = () => LobbyUtils.GetSpawnClients(orderManager.LobbyInfo, lobby.Map);
+ preview.SpawnOccupants = () => LobbyUtils.GetSpawnOccupants(orderManager.LobbyInfo, lobby.Map);
var title = available.GetOrNull("MAP_TITLE");
if (title != null)
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var preview = invalid.Get("MAP_PREVIEW");
preview.Preview = () => lobby.Map;
preview.OnMouseDown = mi => LobbyUtils.SelectSpawnPoint(orderManager, preview, lobby.Map, mi);
- preview.SpawnClients = () => LobbyUtils.GetSpawnClients(orderManager.LobbyInfo, lobby.Map);
+ preview.SpawnOccupants = () => LobbyUtils.GetSpawnOccupants(orderManager.LobbyInfo, lobby.Map);
var title = invalid.GetOrNull("MAP_TITLE");
if (title != null)
@@ -73,7 +73,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var preview = download.Get("MAP_PREVIEW");
preview.Preview = () => lobby.Map;
preview.OnMouseDown = mi => LobbyUtils.SelectSpawnPoint(orderManager, preview, lobby.Map, mi);
- preview.SpawnOccupants = () => LobbyUtils.GetSpawnClients(orderManager.LobbyInfo, lobby.Map);
+ preview.SpawnOccupants = () => LobbyUtils.GetSpawnOccupants(orderManager.LobbyInfo, lobby.Map);
var title = download.GetOrNull("MAP_TITLE");
if (title != null)
@@ -100,7 +100,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var preview = progress.Get("MAP_PREVIEW");
preview.Preview = () => lobby.Map;
preview.OnMouseDown = mi => LobbyUtils.SelectSpawnPoint(orderManager, preview, lobby.Map, mi);
- preview.SpawnOccupants = () => LobbyUtils.GetSpawnClients(orderManager.LobbyInfo, lobby.Map);
+ preview.SpawnOccupants = () => LobbyUtils.GetSpawnOccupants(orderManager.LobbyInfo, lobby.Map);
var title = progress.GetOrNull("MAP_TITLE");
if (title != null)
diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs
index ad7608ccfc..90663983e6 100644
--- a/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs
+++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs
@@ -149,14 +149,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
color.AttachPanel(colorChooser, onExit);
}
- public static Dictionary GetSpawnClients(Session lobbyInfo, MapPreview preview)
+ public static Dictionary GetSpawnOccupants(Session lobbyInfo, MapPreview preview)
{
var spawns = preview.SpawnPoints;
return lobbyInfo.Clients
.Where(c => c.SpawnPoint != 0)
.ToDictionary(c => spawns[c.SpawnPoint - 1], c => new SpawnOccupant(c));
}
- public static Dictionary GetSpawnClients(IEnumerable players, MapPreview preview)
+ public static Dictionary GetSpawnOccupants(IEnumerable players, MapPreview preview)
{
var spawns = preview.SpawnPoints;
return players
diff --git a/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs
index cb8fa0cbd7..3eb6068382 100644
--- a/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs
+++ b/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs
@@ -104,25 +104,25 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (ddb != null)
{
// Using list to maintain the order
- var options = new List>
+ var options = new List>
{
- new KeyValuePair(GameType.Any, ddb.GetText()),
- new KeyValuePair(GameType.Singleplayer, "Singleplayer"),
- new KeyValuePair(GameType.Multiplayer, "Multiplayer")
+ Pair.New(GameType.Any, ddb.GetText()),
+ Pair.New(GameType.Singleplayer, "Singleplayer"),
+ Pair.New(GameType.Multiplayer, "Multiplayer")
};
- var lookup = options.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
+ var lookup = options.ToDictionary(kvp => kvp.First, kvp => kvp.Second);
ddb.GetText = () => lookup[filter.Type];
ddb.OnMouseDown = _ =>
{
- Func, ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
+ Func, ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
{
var item = ScrollItemWidget.Setup(
tpl,
- () => filter.Type == option.Key,
- () => { filter.Type = option.Key; ApplyFilter(); }
+ () => filter.Type == option.First,
+ () => { filter.Type = option.First; ApplyFilter(); }
);
- item.Get("LABEL").GetText = () => option.Value;
+ item.Get("LABEL").GetText = () => option.Second;
return item;
};
@@ -139,27 +139,27 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (ddb != null)
{
// Using list to maintain the order
- var options = new List>
+ var options = new List>
{
- new KeyValuePair(DateType.Any, ddb.GetText()),
- new KeyValuePair(DateType.Today, "Today"),
- new KeyValuePair(DateType.LastWeek, "Last 7 days"),
- new KeyValuePair(DateType.LastFortnight, "Last 14 days"),
- new KeyValuePair(DateType.LastMonth, "Last 30 days")
+ Pair.New(DateType.Any, ddb.GetText()),
+ Pair.New(DateType.Today, "Today"),
+ Pair.New(DateType.LastWeek, "Last 7 days"),
+ Pair.New(DateType.LastFortnight, "Last 14 days"),
+ Pair.New(DateType.LastMonth, "Last 30 days")
};
- var lookup = options.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
+ var lookup = options.ToDictionary(kvp => kvp.First, kvp => kvp.Second);
ddb.GetText = () => lookup[filter.Date];
ddb.OnMouseDown = _ =>
{
- Func, ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
+ Func, ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
{
var item = ScrollItemWidget.Setup(
tpl,
- () => filter.Date == option.Key,
- () => { filter.Date = option.Key; ApplyFilter(); }
+ () => filter.Date == option.First,
+ () => { filter.Date = option.First; ApplyFilter(); }
);
- item.Get("LABEL").GetText = () => option.Value;
+ item.Get("LABEL").GetText = () => option.Second;
return item;
};
@@ -176,27 +176,27 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (ddb != null)
{
// Using list to maintain the order
- var options = new List>
+ var options = new List>
{
- new KeyValuePair(DurationType.Any, ddb.GetText()),
- new KeyValuePair(DurationType.VeryShort, "Under 5 min"),
- new KeyValuePair(DurationType.Short, "Short (10 min)"),
- new KeyValuePair(DurationType.Medium, "Medium (30 min)"),
- new KeyValuePair(DurationType.Long, "Long (60+ min)")
+ Pair.New(DurationType.Any, ddb.GetText()),
+ Pair.New(DurationType.VeryShort, "Under 5 min"),
+ Pair.New(DurationType.Short, "Short (10 min)"),
+ Pair.New(DurationType.Medium, "Medium (30 min)"),
+ Pair.New(DurationType.Long, "Long (60+ min)")
};
- var lookup = options.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
+ var lookup = options.ToDictionary(kvp => kvp.First, kvp => kvp.Second);
ddb.GetText = () => lookup[filter.Duration];
ddb.OnMouseDown = _ =>
{
- Func, ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
+ Func, ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
{
var item = ScrollItemWidget.Setup(
tpl,
- () => filter.Duration == option.Key,
- () => { filter.Duration = option.Key; ApplyFilter(); }
+ () => filter.Duration == option.First,
+ () => { filter.Duration = option.First; ApplyFilter(); }
);
- item.Get("LABEL").GetText = () => option.Value;
+ item.Get("LABEL").GetText = () => option.Second;
return item;
};
@@ -277,25 +277,25 @@ namespace OpenRA.Mods.RA.Widgets.Logic
ddb.IsDisabled = () => string.IsNullOrEmpty(filter.PlayerName);
// Using list to maintain the order
- var options = new List>
+ var options = new List>
{
- new KeyValuePair(GameInformation.GameOutcome.Undefined, ddb.GetText()),
- new KeyValuePair(GameInformation.GameOutcome.Defeat, "Defeat"),
- new KeyValuePair(GameInformation.GameOutcome.Victory, "Victory")
+ Pair.New(WinState.Undefined, ddb.GetText()),
+ Pair.New(WinState.Lost, "Defeat"),
+ Pair.New(WinState.Won, "Victory")
};
- var lookup = options.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
+ var lookup = options.ToDictionary(kvp => kvp.First, kvp => kvp.Second);
ddb.GetText = () => lookup[filter.Outcome];
ddb.OnMouseDown = _ =>
{
- Func, ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
+ Func, ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
{
var item = ScrollItemWidget.Setup(
tpl,
- () => filter.Outcome == option.Key,
- () => { filter.Outcome = option.Key; ApplyFilter(); }
+ () => filter.Outcome == option.First,
+ () => { filter.Outcome = option.First; ApplyFilter(); }
);
- item.Get("LABEL").GetText = () => option.Value;
+ item.Get("LABEL").GetText = () => option.Second;
return item;
};
@@ -409,7 +409,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic
button.IsDisabled = () => selectedReplay == null;
button.OnClick = () =>
{
- onDeleteReplay(selectedReplay, () => { if (selectedReplay == null) SelectFirstVisibleReplay(); });
+ onDeleteReplay(selectedReplay, () =>
+ {
+ if (selectedReplay == null)
+ SelectFirstVisibleReplay();
+ });
};
}
@@ -514,7 +518,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
// Duration
if (filter.Duration != DurationType.Any)
{
- double minutes = replay.GameInfo.Duration.TotalMinutes;
+ var minutes = replay.GameInfo.Duration.TotalMinutes;
switch (filter.Duration)
{
case DurationType.VeryShort:
@@ -551,7 +555,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
return false;
// Outcome
- if (filter.Outcome != GameInformation.GameOutcome.Undefined && filter.Outcome != player.Outcome)
+ if (filter.Outcome != WinState.Undefined && filter.Outcome != player.Outcome)
return false;
// Faction
@@ -582,7 +586,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
selectedReplay = replay;
selectedSpawns = (selectedReplay != null)
- ? LobbyUtils.GetSpawnClients(selectedReplay.GameInfo.Players, selectedReplay.GameInfo.MapPreview)
+ ? LobbyUtils.GetSpawnOccupants(selectedReplay.GameInfo.Players, selectedReplay.GameInfo.MapPreview)
: new Dictionary();
if (replay == null)
@@ -680,7 +684,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public GameType Type;
public DateType Date;
public DurationType Duration;
- public GameInformation.GameOutcome Outcome;
+ public WinState Outcome;
public string PlayerName;
public string MapName;
public string Faction;
@@ -692,7 +696,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
return Type == default(GameType)
&& Date == default(DateType)
&& Duration == default(DurationType)
- && Outcome == default(GameInformation.GameOutcome)
+ && Outcome == default(WinState)
&& string.IsNullOrEmpty(PlayerName)
&& string.IsNullOrEmpty(MapName)
&& string.IsNullOrEmpty(Faction);