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