add IEnum<T>.JoinWith, use it to clean up a bunch of things
This commit is contained in:
@@ -184,7 +184,7 @@ namespace OpenRA.Mods.RA.Server
|
||||
|
||||
var slot = server.lobbyInfo.Slots[parts[0]];
|
||||
var bot = server.lobbyInfo.ClientInSlot(parts[0]);
|
||||
var botType = string.Join(" ", parts.Skip(1).ToArray() );
|
||||
var botType = parts.Skip(1).JoinWith(" ");
|
||||
|
||||
// Invalid slot
|
||||
if (bot != null && bot.Bot == null)
|
||||
@@ -419,7 +419,7 @@ namespace OpenRA.Mods.RA.Server
|
||||
};
|
||||
|
||||
var cmdName = cmd.Split(' ').First();
|
||||
var cmdValue = string.Join(" ", cmd.Split(' ').Skip(1).ToArray());
|
||||
var cmdValue = cmd.Split(' ').Skip(1).JoinWith(" ");
|
||||
|
||||
Func<string,bool> a;
|
||||
if (!dict.TryGetValue(cmdName, out a))
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA.Server
|
||||
server.Settings.ExternalPort, Uri.EscapeUriString(server.Settings.Name),
|
||||
server.GameStarted ? 2 : 1, // todo: post-game states, etc.
|
||||
server.lobbyInfo.Clients.Count,
|
||||
string.Join(",", Game.CurrentMods.Select(f => "{0}@{1}".F(f.Key, f.Value.Version)).ToArray()),
|
||||
Game.CurrentMods.Select(f => "{0}@{1}".F(f.Key, f.Value.Version)).JoinWith(","),
|
||||
server.lobbyInfo.GlobalSettings.Map,
|
||||
server.Map.PlayerCount));
|
||||
|
||||
|
||||
@@ -480,7 +480,7 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
var bi = info.Traits.GetOrDefault<BuildingInfo>();
|
||||
if (bi != null)
|
||||
DrawRightAligned("{1}{0}".F(bi.Power, bi.Power > 0 ? "+" : ""), pos + new int2(-5, 20),
|
||||
((power.PowerProvided - power.PowerDrained) >= -bi.Power || bi.Power > 0)? Color.White: Color.Red);
|
||||
((power.PowerProvided - power.PowerDrained) >= -bi.Power || bi.Power > 0)? Color.White: Color.Red);
|
||||
|
||||
p += new int2(5, 35);
|
||||
if (!canBuildThis)
|
||||
@@ -488,7 +488,7 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
var prereqs = buildable.Prerequisites
|
||||
.Select( a => Description( a ) );
|
||||
Game.Renderer.Fonts["Regular"].DrawText(
|
||||
"Requires {0}".F(string.Join(", ", prereqs.ToArray())),
|
||||
"Requires {0}".F(prereqs.JoinWith(", ")),
|
||||
p.ToInt2(),
|
||||
Color.White);
|
||||
|
||||
|
||||
@@ -84,12 +84,17 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
return (currentServer == null) ? null : Game.modData.FindMapByUid(currentServer.Map);
|
||||
}
|
||||
|
||||
static string GenerateModLabel(KeyValuePair<string,string> mod)
|
||||
{
|
||||
if (Mod.AllMods.ContainsKey(mod.Key))
|
||||
return "{0} ({1})".F(Mod.AllMods[mod.Key].Title, mod.Value);
|
||||
|
||||
return "Unknown Mod: {0}".F(mod.Key);
|
||||
}
|
||||
|
||||
public static string GenerateModsLabel(GameServer s)
|
||||
{
|
||||
return string.Join("\n", s.UsefulMods
|
||||
.Select(m =>
|
||||
Mod.AllMods.ContainsKey(m.Key) ? string.Format("{0} ({1})", Mod.AllMods[m.Key].Title, m.Value)
|
||||
: string.Format("Unknown Mod: {0}",m.Key)).ToArray());
|
||||
return s.UsefulMods.Select(m => GenerateModLabel(m)).JoinWith("\n");
|
||||
}
|
||||
|
||||
void RefreshServerList(IEnumerable<GameServer> games)
|
||||
|
||||
Reference in New Issue
Block a user