Missed a couple of static bits.

This commit is contained in:
Paul Chote
2011-05-06 23:36:01 +12:00
parent 6cb0cb7d0e
commit b73575f37b

View File

@@ -32,10 +32,9 @@ namespace OpenRA.Mods.Cnc.Widgets
// Must be set only once on game start // Must be set only once on game start
// TODO: This is stupid // TODO: This is stupid
static bool staticSetup; static bool staticSetup;
enum StaticCrap { LobbyInfo, BeforeGameStart, AddChatLine }
static void StaticCrapChanged(StaticCrap type, Color a, string b, string c)
public static void GameStartingStub()
{ {
var panel = Widget.RootWidget.GetWidget("SERVER_LOBBY"); var panel = Widget.RootWidget.GetWidget("SERVER_LOBBY");
@@ -47,22 +46,19 @@ namespace OpenRA.Mods.Cnc.Widgets
if (lobbyLogic == null) if (lobbyLogic == null)
return; return;
lobbyLogic.onGameStart(); switch (type)
} {
case StaticCrap.LobbyInfo:
public static void UpdateCurrentMapStub() lobbyLogic.UpdateCurrentMap();
{ lobbyLogic.UpdatePlayerList();
var panel = Widget.RootWidget.GetWidget("SERVER_LOBBY"); break;
case StaticCrap.BeforeGameStart:
// The panel may not be open anymore lobbyLogic.onGameStart();
if (panel == null) break;
return; case StaticCrap.AddChatLine:
panel.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").AddLine(a,b,c);
var lobbyLogic = panel.DelegateObject as CncLobbyLogic; break;
if (lobbyLogic == null) }
return;
lobbyLogic.UpdateCurrentMap();
} }
readonly Action onGameStart; readonly Action onGameStart;
@@ -82,12 +78,12 @@ namespace OpenRA.Mods.Cnc.Widgets
if (!staticSetup) if (!staticSetup)
{ {
staticSetup = true; staticSetup = true;
Game.LobbyInfoChanged += UpdateCurrentMapStub; Game.LobbyInfoChanged += () => StaticCrapChanged(StaticCrap.LobbyInfo, Color.Beige, null, null);
Game.BeforeGameStart += GameStartingStub; Game.BeforeGameStart += () => StaticCrapChanged(StaticCrap.BeforeGameStart, Color.PapayaWhip, null, null);
Game.AddChatLine += (a,b,c) => StaticCrapChanged(StaticCrap.AddChatLine, a, b, c);
} }
UpdateCurrentMap(); UpdateCurrentMap();
CurrentColorPreview = Game.Settings.Player.ColorRamp; CurrentColorPreview = Game.Settings.Player.ColorRamp;
Players = lobby.GetWidget<ScrollPanelWidget>("PLAYERS"); Players = lobby.GetWidget<ScrollPanelWidget>("PLAYERS");
@@ -182,9 +178,6 @@ namespace OpenRA.Mods.Cnc.Widgets
// Todo: Only show if the map requirements are met for player slots // Todo: Only show if the map requirements are met for player slots
startGameButton.IsVisible = () => Game.IsHost; startGameButton.IsVisible = () => Game.IsHost;
Game.LobbyInfoChanged += UpdatePlayerList;
Game.AddChatLine += lobby.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").AddLine;
bool teamChat = false; bool teamChat = false;
var chatLabel = lobby.GetWidget<LabelWidget>("LABEL_CHATTYPE"); var chatLabel = lobby.GetWidget<LabelWidget>("LABEL_CHATTYPE");