Remove engine references to MAINMENU_BG. Don't push the menu background onto the window list. Crashes whenever a delegate tries to open MAINMENU_BG.
This commit is contained in:
@@ -329,9 +329,6 @@ namespace OpenRA
|
||||
var shellmap = ChooseShellmap();
|
||||
JoinLocal();
|
||||
StartGame(shellmap);
|
||||
|
||||
Widget.CloseWindow();
|
||||
Widget.OpenWindow("MAINMENU_BG");
|
||||
}
|
||||
|
||||
public static T CreateObject<T>( string name )
|
||||
|
||||
@@ -313,7 +313,8 @@ namespace OpenRA.Widgets
|
||||
|
||||
public static void CloseWindow()
|
||||
{
|
||||
RootWidget.Children.Remove(WindowList.Pop());
|
||||
if (WindowList.Count > 0)
|
||||
RootWidget.Children.Remove(WindowList.Pop());
|
||||
if (WindowList.Count > 0)
|
||||
rootWidget.Children.Add(WindowList.Peek());
|
||||
}
|
||||
@@ -331,6 +332,11 @@ namespace OpenRA.Widgets
|
||||
WindowList.Push(window);
|
||||
return window;
|
||||
}
|
||||
|
||||
public static Widget LoadWidget(string id)
|
||||
{
|
||||
return Game.modData.WidgetLoader.LoadWidget(new Dictionary<string, object>(), rootWidget, id);
|
||||
}
|
||||
|
||||
public static void DoTick()
|
||||
{
|
||||
|
||||
@@ -59,6 +59,8 @@ namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
Sound.StopMusic();
|
||||
Game.Disconnect();
|
||||
Widget.CloseWindow();
|
||||
Widget.LoadWidget("MENU_BACKGROUND");
|
||||
})));
|
||||
}
|
||||
|
||||
@@ -75,6 +77,8 @@ namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
Sound.StopMusic();
|
||||
Game.Disconnect();
|
||||
Widget.CloseWindow();
|
||||
Widget.LoadWidget("MENU_BACKGROUND");
|
||||
})));
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
widget.GetWidget("CONNECTION_BUTTON_ABORT").OnMouseUp = mi => {
|
||||
widget.GetWidget("CONNECTION_BUTTON_ABORT").Parent.Visible = false;
|
||||
Game.Disconnect();
|
||||
Widget.CloseWindow();
|
||||
Widget.OpenWindow("MAINMENU_BG");
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -42,6 +44,8 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
widget.GetWidget("CONNECTION_BUTTON_CANCEL").OnMouseUp = mi => {
|
||||
widget.GetWidget("CONNECTION_BUTTON_CANCEL").Parent.Visible = false;
|
||||
Game.Disconnect();
|
||||
Widget.CloseWindow();
|
||||
Widget.OpenWindow("MAINMENU_BG");
|
||||
return true;
|
||||
};
|
||||
widget.GetWidget("CONNECTION_BUTTON_RETRY").OnMouseUp = mi => {
|
||||
|
||||
@@ -34,33 +34,64 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
|
||||
public void Init()
|
||||
{
|
||||
Game.ConnectionStateChanged += orderManager =>
|
||||
{
|
||||
Widget.CloseWindow();
|
||||
switch (orderManager.Connection.ConnectionState)
|
||||
{
|
||||
case ConnectionState.PreConnecting:
|
||||
Widget.OpenWindow("MAINMENU_BG");
|
||||
break;
|
||||
case ConnectionState.Connecting:
|
||||
Widget.OpenWindow("CONNECTING_BG",
|
||||
new Dictionary<string, object> { { "host", orderManager.Host }, { "port", orderManager.Port } });
|
||||
break;
|
||||
case ConnectionState.NotConnected:
|
||||
Widget.OpenWindow("CONNECTION_FAILED_BG",
|
||||
new Dictionary<string, object> { { "orderManager", orderManager } });
|
||||
break;
|
||||
case ConnectionState.Connected:
|
||||
var lobby = Game.OpenWindow(orderManager.world, "SERVER_LOBBY");
|
||||
lobby.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").ClearChat();
|
||||
lobby.GetWidget("CHANGEMAP_BUTTON").Visible = true;
|
||||
lobby.GetWidget("LOCKTEAMS_CHECKBOX").Visible = true;
|
||||
lobby.GetWidget("ALLOWCHEATS_CHECKBOX").Visible = true;
|
||||
lobby.GetWidget("DISCONNECT_BUTTON").Visible = true;
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
if (Info.InstallMode == "cnc")
|
||||
{
|
||||
Game.ConnectionStateChanged += orderManager =>
|
||||
{
|
||||
Widget.CloseWindow();
|
||||
switch (orderManager.Connection.ConnectionState)
|
||||
{
|
||||
case ConnectionState.PreConnecting:
|
||||
Widget.OpenWindow("MENU_BACKGROUND");
|
||||
break;
|
||||
case ConnectionState.Connecting:
|
||||
Widget.OpenWindow("CONNECTING_BG",
|
||||
new Dictionary<string, object> { { "host", orderManager.Host }, { "port", orderManager.Port } });
|
||||
break;
|
||||
case ConnectionState.NotConnected:
|
||||
Widget.OpenWindow("CONNECTION_FAILED_BG",
|
||||
new Dictionary<string, object> { { "orderManager", orderManager } });
|
||||
break;
|
||||
case ConnectionState.Connected:
|
||||
var lobby = Game.OpenWindow(orderManager.world, "SERVER_LOBBY");
|
||||
lobby.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").ClearChat();
|
||||
lobby.GetWidget("CHANGEMAP_BUTTON").Visible = true;
|
||||
lobby.GetWidget("LOCKTEAMS_CHECKBOX").Visible = true;
|
||||
lobby.GetWidget("ALLOWCHEATS_CHECKBOX").Visible = true;
|
||||
lobby.GetWidget("DISCONNECT_BUTTON").Visible = true;
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
Game.ConnectionStateChanged += orderManager =>
|
||||
{
|
||||
Widget.CloseWindow();
|
||||
switch (orderManager.Connection.ConnectionState)
|
||||
{
|
||||
case ConnectionState.PreConnecting:
|
||||
Widget.LoadWidget("MAINMENU_BG");
|
||||
break;
|
||||
case ConnectionState.Connecting:
|
||||
Widget.OpenWindow("CONNECTING_BG",
|
||||
new Dictionary<string, object> { { "host", orderManager.Host }, { "port", orderManager.Port } });
|
||||
break;
|
||||
case ConnectionState.NotConnected:
|
||||
Widget.OpenWindow("CONNECTION_FAILED_BG",
|
||||
new Dictionary<string, object> { { "orderManager", orderManager } });
|
||||
break;
|
||||
case ConnectionState.Connected:
|
||||
var lobby = Game.OpenWindow(orderManager.world, "SERVER_LOBBY");
|
||||
lobby.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").ClearChat();
|
||||
lobby.GetWidget("CHANGEMAP_BUTTON").Visible = true;
|
||||
lobby.GetWidget("LOCKTEAMS_CHECKBOX").Visible = true;
|
||||
lobby.GetWidget("ALLOWCHEATS_CHECKBOX").Visible = true;
|
||||
lobby.GetWidget("DISCONNECT_BUTTON").Visible = true;
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
TestAndContinue();
|
||||
}
|
||||
|
||||
@@ -70,7 +101,10 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
{
|
||||
Game.LoadShellMap();
|
||||
Widget.RootWidget.RemoveChildren();
|
||||
Widget.OpenWindow("MAINMENU_BG");
|
||||
if (Info.InstallMode == "cnc")
|
||||
Widget.LoadWidget("MENU_BACKGROUND");
|
||||
else
|
||||
Widget.OpenWindow("MAINMENU_BG");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -30,6 +30,8 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
optionsBG.GetWidget("DISCONNECT").OnMouseUp = mi => {
|
||||
optionsBG.Visible = false;
|
||||
Game.Disconnect();
|
||||
Widget.CloseWindow();
|
||||
Widget.OpenWindow("MAINMENU_BG");
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
optionsBG.GetWidget("DISCONNECT").OnMouseUp = mi => {
|
||||
optionsBG.Visible = false;
|
||||
Game.Disconnect();
|
||||
Widget.CloseWindow();
|
||||
Widget.OpenWindow("MAINMENU_BG");
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
@@ -102,6 +102,8 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
disconnectButton.OnMouseUp = mi =>
|
||||
{
|
||||
Game.Disconnect();
|
||||
Widget.CloseWindow();
|
||||
Widget.OpenWindow("MAINMENU_BG");
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Container@MAINMENU_BG:
|
||||
Id:MAINMENU_BG
|
||||
Container@MENU_BACKGROUND:
|
||||
Id:MENU_BACKGROUND
|
||||
X:0
|
||||
Y:0
|
||||
Width:WINDOW_RIGHT
|
||||
|
||||
Reference in New Issue
Block a user