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