Extract loading of game rows into LoadGameRows method.
This commit is contained in:
@@ -392,13 +392,50 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
void RefreshServerListInner(List<GameServer> games)
|
||||
{
|
||||
ScrollItemWidget nextServerRow = null;
|
||||
var rows = new List<Widget>();
|
||||
List<Widget> rows = null;
|
||||
|
||||
if (games != null)
|
||||
rows = LoadGameRows(games, out nextServerRow);
|
||||
|
||||
Game.RunAfterTick(() =>
|
||||
{
|
||||
serverList.RemoveChildren();
|
||||
SelectServer(null);
|
||||
|
||||
if (games == null)
|
||||
{
|
||||
searchStatus = SearchStatus.Failed;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!rows.Any())
|
||||
{
|
||||
searchStatus = SearchStatus.NoGames;
|
||||
return;
|
||||
}
|
||||
|
||||
searchStatus = SearchStatus.Hidden;
|
||||
|
||||
// Search for any unknown maps
|
||||
if (Game.Settings.Game.AllowDownloading)
|
||||
modData.MapCache.QueryRemoteMapDetails(services.MapRepository, games.Where(g => !Filtered(g)).Select(g => g.Map));
|
||||
|
||||
foreach (var row in rows)
|
||||
serverList.AddChild(row);
|
||||
|
||||
if (nextServerRow != null)
|
||||
nextServerRow.OnClick();
|
||||
});
|
||||
}
|
||||
|
||||
List<Widget> LoadGameRows(List<GameServer> games, out ScrollItemWidget nextServerRow)
|
||||
{
|
||||
nextServerRow = null;
|
||||
var rows = new List<Widget>();
|
||||
var mods = games.GroupBy(g => g.Mods)
|
||||
.OrderByDescending(g => GroupSortOrder(g.First()))
|
||||
.ThenByDescending(g => g.Count());
|
||||
|
||||
foreach (var modGames in mods)
|
||||
{
|
||||
if (modGames.All(Filtered))
|
||||
@@ -492,37 +529,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Game.RunAfterTick(() =>
|
||||
{
|
||||
serverList.RemoveChildren();
|
||||
SelectServer(null);
|
||||
|
||||
if (games == null)
|
||||
{
|
||||
searchStatus = SearchStatus.Failed;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!rows.Any())
|
||||
{
|
||||
searchStatus = SearchStatus.NoGames;
|
||||
return;
|
||||
}
|
||||
|
||||
searchStatus = SearchStatus.Hidden;
|
||||
|
||||
// Search for any unknown maps
|
||||
if (Game.Settings.Game.AllowDownloading)
|
||||
modData.MapCache.QueryRemoteMapDetails(services.MapRepository, games.Where(g => !Filtered(g)).Select(g => g.Map));
|
||||
|
||||
foreach (var row in rows)
|
||||
serverList.AddChild(row);
|
||||
|
||||
if (nextServerRow != null)
|
||||
nextServerRow.OnClick();
|
||||
});
|
||||
return rows;
|
||||
}
|
||||
|
||||
void OpenLobby()
|
||||
|
||||
Reference in New Issue
Block a user