Remove references to chrome.currentMap from LobbyDelegate

This commit is contained in:
Paul Chote
2010-07-11 14:42:12 +12:00
parent 7591434987
commit 74383fee47

View File

@@ -31,8 +31,14 @@ namespace OpenRA.Widgets.Delegates
Widget Players, LocalPlayerTemplate, RemotePlayerTemplate;
Dictionary<string,string> CountryNames;
string MapUid;
MapStub Map;
public LobbyDelegate()
{
Game.LobbyInfoChanged += UpdateCurrentMap;
UpdateCurrentMap();
var r = Chrome.rootWidget;
var lobby = r.GetWidget("SERVER_LOBBY");
Players = Chrome.rootWidget.GetWidget("SERVER_LOBBY").GetWidget("PLAYERS");
@@ -41,7 +47,7 @@ namespace OpenRA.Widgets.Delegates
var map = lobby.GetWidget<MapPreviewWidget>("LOBBY_MAP_PREVIEW");
map.Map = () => {return Game.chrome.currentMap;};
map.Map = () => {return Map;};
map.OnSpawnClick = sp =>
{
var owned = Game.LobbyInfo.Clients.Any(c => c.SpawnPoint == sp);
@@ -51,7 +57,7 @@ namespace OpenRA.Widgets.Delegates
map.SpawnColors = () =>
{
var spawns = Game.chrome.currentMap.SpawnPoints;
var spawns = Map.SpawnPoints;
var playerColors = Game.world.PlayerColors();
var sc = new Dictionary<int2,Color>();
@@ -94,6 +100,7 @@ namespace OpenRA.Widgets.Delegates
};
Game.LobbyInfoChanged += UpdatePlayerList;
Chrome.chatWidget = lobby.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY");
@@ -120,6 +127,13 @@ namespace OpenRA.Widgets.Delegates
}
void UpdateCurrentMap()
{
if (MapUid == Game.LobbyInfo.GlobalSettings.Map) return;
MapUid = Game.LobbyInfo.GlobalSettings.Map;
Map = Game.AvailableMaps[ MapUid ];
}
void UpdatePlayerList()
{
// This causes problems for people who are in the process of editing their names (the widgets vanish from beneath them)