helper for 'hide all children, then show THIS menu'
This commit is contained in:
@@ -112,15 +112,13 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
{
|
{
|
||||||
if (w.Id == "MAINMENU_BUTTON_SETTINGS")
|
if (w.Id == "MAINMENU_BUTTON_SETTINGS")
|
||||||
{
|
{
|
||||||
Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = false;
|
Game.chrome.rootWidget.ShowMenu("SETTINGS_BG");
|
||||||
Game.chrome.rootWidget.GetWidget("SETTINGS_BG").Visible = true;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w.Id == "SETTINGS_BUTTON_OK")
|
if (w.Id == "SETTINGS_BUTTON_OK")
|
||||||
{
|
{
|
||||||
Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = true;
|
Game.chrome.rootWidget.ShowMenu("MAINMENU_BG");
|
||||||
Game.chrome.rootWidget.GetWidget("SETTINGS_BG").Visible = false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,21 +153,19 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
{
|
{
|
||||||
if (w.Id == "MAINMENU_BUTTON_CREATE")
|
if (w.Id == "MAINMENU_BUTTON_CREATE")
|
||||||
{
|
{
|
||||||
Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = false;
|
Game.chrome.rootWidget.ShowMenu("CREATESERVER_BG");
|
||||||
Game.chrome.rootWidget.GetWidget("CREATESERVER_BG").Visible = true;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w.Id == "CREATESERVER_BUTTON_CANCEL")
|
if (w.Id == "CREATESERVER_BUTTON_CANCEL")
|
||||||
{
|
{
|
||||||
Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = true;
|
Game.chrome.rootWidget.ShowMenu("MAINMENU_BG");
|
||||||
Game.chrome.rootWidget.GetWidget("CREATESERVER_BG").Visible = false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w.Id == "CREATESERVER_BUTTON_START")
|
if (w.Id == "CREATESERVER_BUTTON_START")
|
||||||
{
|
{
|
||||||
Game.chrome.rootWidget.GetWidget("CREATESERVER_BG").Visible = false;
|
Game.chrome.rootWidget.ShowMenu(null);
|
||||||
Log.Write("Creating server");
|
Log.Write("Creating server");
|
||||||
|
|
||||||
Server.Server.ServerMain(AdvertiseServerOnline, Game.Settings.MasterServer,
|
Server.Server.ServerMain(AdvertiseServerOnline, Game.Settings.MasterServer,
|
||||||
@@ -195,9 +191,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
// Main Menu root
|
// Main Menu root
|
||||||
if (w.Id == "MAINMENU_BUTTON_JOIN")
|
if (w.Id == "MAINMENU_BUTTON_JOIN")
|
||||||
{
|
{
|
||||||
Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = false;
|
var bg = Game.chrome.rootWidget.ShowMenu("JOINSERVER_BG");
|
||||||
Widget bg = Game.chrome.rootWidget.GetWidget("JOINSERVER_BG");
|
|
||||||
bg.Visible = true;
|
|
||||||
|
|
||||||
int height = 50;
|
int height = 50;
|
||||||
int width = 300;
|
int width = 300;
|
||||||
@@ -242,8 +236,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
|
|
||||||
if (w.Id == "JOINSERVER_BUTTON_CANCEL")
|
if (w.Id == "JOINSERVER_BUTTON_CANCEL")
|
||||||
{
|
{
|
||||||
Game.chrome.rootWidget.GetWidget("JOINSERVER_BG").Visible = false;
|
Game.chrome.rootWidget.ShowMenu("MAINMENU_BG");
|
||||||
Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = true;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,15 +251,13 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
// Main Menu root
|
// Main Menu root
|
||||||
if (w.Id == "CONNECTION_BUTTON_ABORT")
|
if (w.Id == "CONNECTION_BUTTON_ABORT")
|
||||||
{
|
{
|
||||||
Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = true;
|
Game.chrome.rootWidget.ShowMenu("MAINMENU_BG");
|
||||||
Game.chrome.rootWidget.GetWidget("CONNECTING_BG").Visible = false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w.Id == "CONNECTION_BUTTON_CANCEL")
|
if (w.Id == "CONNECTION_BUTTON_CANCEL")
|
||||||
{
|
{
|
||||||
Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = true;
|
Game.chrome.rootWidget.ShowMenu("MAINMENU_BG");
|
||||||
Game.chrome.rootWidget.GetWidget("CONNECTION_FAILED_BG").Visible = false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -143,7 +143,19 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Widget GetCurrentMenu() { return Children.FirstOrDefault(c => c.Visible); }
|
||||||
|
|
||||||
|
public Widget ShowMenu(string menu)
|
||||||
|
{
|
||||||
|
GetCurrentMenu().Visible = false;
|
||||||
|
|
||||||
|
var widget = GetWidget(menu);
|
||||||
|
if (widget != null)
|
||||||
|
widget.Visible = true;
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ContainerWidget : Widget { }
|
class ContainerWidget : Widget { }
|
||||||
|
|||||||
Reference in New Issue
Block a user