Move lobby event unbinding to Dispose.
This commit is contained in:
@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (om.Connection.ConnectionState == ConnectionState.NotConnected)
|
if (om.Connection.ConnectionState == ConnectionState.NotConnected)
|
||||||
{
|
{
|
||||||
// Show connection failed dialog
|
// Show connection failed dialog
|
||||||
CloseWindow();
|
Ui.CloseWindow();
|
||||||
|
|
||||||
Action onConnect = () =>
|
Action onConnect = () =>
|
||||||
{
|
{
|
||||||
@@ -100,17 +100,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloseWindow()
|
|
||||||
{
|
|
||||||
orderManager.AddChatLine -= AddChatLine;
|
|
||||||
Game.LobbyInfoChanged -= UpdateCurrentMap;
|
|
||||||
Game.LobbyInfoChanged -= UpdatePlayerList;
|
|
||||||
Game.BeforeGameStart -= OnGameStart;
|
|
||||||
Game.ConnectionStateChanged -= ConnectionStateChanged;
|
|
||||||
|
|
||||||
Ui.CloseWindow();
|
|
||||||
}
|
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
internal LobbyLogic(Widget widget, ModData modData, WorldRenderer worldRenderer, OrderManager orderManager,
|
internal LobbyLogic(Widget widget, ModData modData, WorldRenderer worldRenderer, OrderManager orderManager,
|
||||||
Action onExit, Action onStart, bool skirmishMode)
|
Action onExit, Action onStart, bool skirmishMode)
|
||||||
@@ -618,7 +607,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
|
|
||||||
var disconnectButton = lobby.Get<ButtonWidget>("DISCONNECT_BUTTON");
|
var disconnectButton = lobby.Get<ButtonWidget>("DISCONNECT_BUTTON");
|
||||||
disconnectButton.OnClick = () => { CloseWindow(); onExit(); };
|
disconnectButton.OnClick = () => { Ui.CloseWindow(); onExit(); };
|
||||||
|
|
||||||
if (skirmishMode)
|
if (skirmishMode)
|
||||||
disconnectButton.Text = "Back";
|
disconnectButton.Text = "Back";
|
||||||
@@ -716,6 +705,22 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
addBotOnMapLoad = true;
|
addBotOnMapLoad = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool disposed;
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && !disposed)
|
||||||
|
{
|
||||||
|
disposed = true;
|
||||||
|
orderManager.AddChatLine -= AddChatLine;
|
||||||
|
Game.LobbyInfoChanged -= UpdateCurrentMap;
|
||||||
|
Game.LobbyInfoChanged -= UpdatePlayerList;
|
||||||
|
Game.BeforeGameStart -= OnGameStart;
|
||||||
|
Game.ConnectionStateChanged -= ConnectionStateChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
public override void Tick()
|
public override void Tick()
|
||||||
{
|
{
|
||||||
var newMessages = Game.GlobalChat.History.Count(m => m.Type == ChatMessageType.Message);
|
var newMessages = Game.GlobalChat.History.Count(m => m.Type == ChatMessageType.Message);
|
||||||
@@ -985,7 +990,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
void OnGameStart()
|
void OnGameStart()
|
||||||
{
|
{
|
||||||
CloseWindow();
|
Ui.CloseWindow();
|
||||||
onStart();
|
onStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user