Unify ra and cnc main menu logic and clean up the main menus.

Move a bunch of buttons into an Extras submenu and the server browser.
Move CncMenuPaletteEffect to ra so it can be used elsewhere and rename it to MenuPaletteEffect.
This commit is contained in:
ScottNZ
2014-01-31 23:29:59 +13:00
parent 81ec978a61
commit 1a3ec26a1e
25 changed files with 577 additions and 601 deletions

View File

@@ -75,7 +75,6 @@ namespace OpenRA.GameRules
public bool SanityCheckUnsyncedCode = false;
public int Samples = 25;
public bool IgnoreVersionMismatch = false;
public bool DeveloperMenu = false;
public bool ShowFatalErrorDialog = true;
public string FatalErrorDialogFaq = "http://github.com/OpenRA/OpenRA/wiki/FAQ";

View File

@@ -74,7 +74,6 @@
<ItemGroup>
<Compile Include="Activities\HarvesterDockSequence.cs" />
<Compile Include="CncLoadScreen.cs" />
<Compile Include="CncMenuPaletteEffect.cs" />
<Compile Include="Effects\IonCannon.cs" />
<Compile Include="IonCannonPower.cs" />
<Compile Include="PoisonedByTiberium.cs" />
@@ -90,7 +89,7 @@
<Compile Include="Widgets\Logic\CncIngameChromeLogic.cs" />
<Compile Include="Widgets\Logic\CncIngameMenuLogic.cs" />
<Compile Include="Widgets\Logic\CncInstallFromCDLogic.cs" />
<Compile Include="Widgets\Logic\CncMenuLogic.cs" />
<Compile Include="Widgets\Logic\CncMainMenuLogic.cs" />
<Compile Include="Widgets\Logic\ProductionTooltipLogic.cs" />
<Compile Include="Widgets\Logic\SupportPowerTooltipLogic.cs" />
<Compile Include="Widgets\ProductionPaletteWidget.cs" />

View File

@@ -39,8 +39,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
public CncIngameChromeLogic(Widget widget, World world)
{
this.world = world;
world.WorldActor.Trait<CncMenuPaletteEffect>()
.Fade(CncMenuPaletteEffect.EffectType.None);
world.WorldActor.Trait<MenuPaletteEffect>()
.Fade(MenuPaletteEffect.EffectType.None);
ingameRoot = widget.Get("INGAME_ROOT");
var playerRoot = ingameRoot.Get("PLAYER_ROOT");

View File

@@ -11,6 +11,7 @@
using System;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Mods.RA;
using OpenRA.Traits;
using OpenRA.Widgets;
@@ -27,8 +28,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{
var resumeDisabled = false;
menu = widget.Get("INGAME_MENU");
var mpe = world.WorldActor.Trait<CncMenuPaletteEffect>();
mpe.Fade(CncMenuPaletteEffect.EffectType.Desaturated);
var mpe = world.WorldActor.Trait<MenuPaletteEffect>();
mpe.Fade(MenuPaletteEffect.EffectType.Desaturated);
menu.Get<LabelWidget>("VERSION_LABEL").Text = Game.modData.Manifest.Mod.Version;
@@ -40,7 +41,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{
Sound.PlayNotification(null, "Speech", "Leave", null);
resumeDisabled = true;
Game.RunAfterDelay(1200, () => mpe.Fade(CncMenuPaletteEffect.EffectType.Black));
Game.RunAfterDelay(1200, () => mpe.Fade(MenuPaletteEffect.EffectType.Black));
Game.RunAfterDelay(1200 + 40 * mpe.Info.FadeLength, () =>
{
Game.Disconnect();
@@ -86,7 +87,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{
Ui.CloseWindow();
Ui.Root.RemoveChild(menu);
world.WorldActor.Trait<CncMenuPaletteEffect>().Fade(CncMenuPaletteEffect.EffectType.None);
world.WorldActor.Trait<MenuPaletteEffect>().Fade(MenuPaletteEffect.EffectType.None);
onExit();
};

View File

@@ -0,0 +1,30 @@
#region Copyright & License Information
/*
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using OpenRA.Mods.RA.Widgets.Logic;
using OpenRA.Widgets;
namespace OpenRA.Mods.Cnc.Widgets.Logic
{
public class CncMainMenuLogic : MainMenuLogic
{
[ObjectCreator.UseCtor]
public CncMainMenuLogic(Widget widget, World world)
: base(widget, world)
{
var shellmapDecorations = widget.Get("SHELLMAP_DECORATIONS");
shellmapDecorations.IsVisible = () => menuType != MenuType.None && Game.Settings.Game.ShowShellmap;
shellmapDecorations.Get<ImageWidget>("RECBLOCK").IsVisible = () => world.FrameNumber / 25 % 2 == 0;
var shellmapDisabledDecorations = widget.Get("SHELLMAP_DISABLED_DECORATIONS");
shellmapDisabledDecorations.IsVisible = () => !Game.Settings.Game.ShowShellmap;
}
}
}

View File

@@ -1,152 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Net;
using OpenRA.Mods.RA.Widgets.Logic;
using OpenRA.Widgets;
namespace OpenRA.Mods.Cnc.Widgets.Logic
{
public class CncMenuLogic
{
enum MenuType { Main, Multiplayer, Settings, None }
MenuType menuType = MenuType.Main;
Widget rootMenu;
[ObjectCreator.UseCtor]
public CncMenuLogic(Widget widget, World world)
{
world.WorldActor.Trait<CncMenuPaletteEffect>()
.Fade(CncMenuPaletteEffect.EffectType.Desaturated);
rootMenu = widget.Get("MENU_BACKGROUND");
rootMenu.Get<LabelWidget>("VERSION_LABEL").Text = Game.modData.Manifest.Mod.Version;
// Menu buttons
var mainMenu = widget.Get("MAIN_MENU");
mainMenu.IsVisible = () => menuType == MenuType.Main;
mainMenu.Get<ButtonWidget>("SOLO_BUTTON").OnClick = StartSkirmishGame;
mainMenu.Get<ButtonWidget>("MULTIPLAYER_BUTTON").OnClick = () => menuType = MenuType.Multiplayer;
mainMenu.Get<ButtonWidget>("MODS_BUTTON").OnClick = () =>
{
menuType = MenuType.None;
Ui.OpenWindow("MODS_PANEL", new WidgetArgs()
{
{ "onExit", () => menuType = MenuType.Main },
{ "onSwitch", RemoveShellmapUI }
});
};
mainMenu.Get<ButtonWidget>("SETTINGS_BUTTON").OnClick = () => menuType = MenuType.Settings;
mainMenu.Get<ButtonWidget>("QUIT_BUTTON").OnClick = Game.Exit;
// Multiplayer menu
var multiplayerMenu = widget.Get("MULTIPLAYER_MENU");
multiplayerMenu.IsVisible = () => menuType == MenuType.Multiplayer;
multiplayerMenu.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => menuType = MenuType.Main;
multiplayerMenu.Get<ButtonWidget>("JOIN_BUTTON").OnClick = () => OpenGamePanel("SERVERBROWSER_PANEL");
multiplayerMenu.Get<ButtonWidget>("CREATE_BUTTON").OnClick = () => OpenGamePanel("CREATESERVER_PANEL");
multiplayerMenu.Get<ButtonWidget>("DIRECTCONNECT_BUTTON").OnClick = () => OpenGamePanel("DIRECTCONNECT_PANEL");
// Settings menu
var settingsMenu = widget.Get("SETTINGS_MENU");
settingsMenu.IsVisible = () => menuType == MenuType.Settings;
settingsMenu.Get<ButtonWidget>("REPLAYS_BUTTON").OnClick = () =>
{
menuType = MenuType.None;
Ui.OpenWindow("REPLAYBROWSER_PANEL", new WidgetArgs()
{
{ "onExit", () => menuType = MenuType.Settings },
{ "onStart", RemoveShellmapUI }
});
};
settingsMenu.Get<ButtonWidget>("MUSIC_BUTTON").OnClick = () =>
{
menuType = MenuType.None;
Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs()
{
{ "onExit", () => menuType = MenuType.Settings },
});
};
settingsMenu.Get<ButtonWidget>("CREDITS_BUTTON").OnClick = () =>
{
menuType = MenuType.None;
Ui.OpenWindow("CREDITS_PANEL", new WidgetArgs()
{
{ "onExit", () => menuType = MenuType.Settings },
});
};
settingsMenu.Get<ButtonWidget>("SETTINGS_BUTTON").OnClick = () =>
{
menuType = MenuType.None;
Game.OpenWindow("SETTINGS_PANEL", new WidgetArgs()
{
{ "onExit", () => menuType = MenuType.Settings },
});
};
settingsMenu.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => menuType = MenuType.Main;
var shellmapDecorations = widget.Get("SHELLMAP_DECORATIONS");
shellmapDecorations.IsVisible = () => menuType != MenuType.None && Game.Settings.Game.ShowShellmap;
shellmapDecorations.Get<ImageWidget>("RECBLOCK").IsVisible = () => world.FrameNumber / 25 % 2 == 0;
var shellmapDisabledDecorations = widget.Get("SHELLMAP_DISABLED_DECORATIONS");
shellmapDisabledDecorations.IsVisible = () => !Game.Settings.Game.ShowShellmap;
}
void OpenGamePanel(string id)
{
menuType = MenuType.None;
Ui.OpenWindow(id, new WidgetArgs()
{
{ "onExit", () => menuType = MenuType.Multiplayer },
{ "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer, false) }
});
}
void RemoveShellmapUI()
{
rootMenu.Parent.RemoveChild(rootMenu);
}
void OpenLobbyPanel(MenuType menu, bool addBots)
{
menuType = MenuType.None;
Game.OpenWindow("SERVER_LOBBY", new WidgetArgs()
{
{ "onExit", () => { Game.Disconnect(); menuType = menu; } },
{ "onStart", RemoveShellmapUI },
{ "addBots", addBots }
});
}
void StartSkirmishGame()
{
var map = WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map);
Game.Settings.Server.Map = map;
Game.Settings.Save();
ConnectionLogic.Connect(IPAddress.Loopback.ToString(),
Game.CreateLocalServer(map),
"",
() => OpenLobbyPanel(MenuType.Main, true),
() => { Game.CloseServer(); menuType = MenuType.Main; });
}
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
@@ -14,25 +14,25 @@ using OpenRA.FileFormats;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc
namespace OpenRA.Mods.RA
{
public class CncMenuPaletteEffectInfo : ITraitInfo
public class MenuPaletteEffectInfo : ITraitInfo
{
public readonly int FadeLength = 10;
public object Create(ActorInitializer init) { return new CncMenuPaletteEffect(this); }
public object Create(ActorInitializer init) { return new MenuPaletteEffect(this); }
}
public class CncMenuPaletteEffect : IPaletteModifier, ITickRender
public class MenuPaletteEffect : IPaletteModifier, ITickRender
{
public enum EffectType { None, Black, Desaturated }
public readonly CncMenuPaletteEffectInfo Info;
public readonly MenuPaletteEffectInfo Info;
int remainingFrames;
EffectType from = EffectType.Black;
EffectType to = EffectType.Black;
public CncMenuPaletteEffect(CncMenuPaletteEffectInfo info) { Info = info; }
public MenuPaletteEffect(MenuPaletteEffectInfo info) { Info = info; }
public void Fade(EffectType type)
{

View File

@@ -123,6 +123,7 @@
<Compile Include="Air\Aircraft.cs" />
<Compile Include="Air\AttackHeli.cs" />
<Compile Include="Air\AttackPlane.cs" />
<Compile Include="MenuPaletteEffect.cs" />
<Compile Include="Crates\UnitUpgradeCrateAction.cs" />
<Compile Include="EjectOnDeath.cs" />
<Compile Include="Air\FallsToEarth.cs" />
@@ -401,7 +402,7 @@
<Compile Include="Widgets\Logic\IngameChromeLogic.cs" />
<Compile Include="Widgets\Logic\LobbyLogic.cs" />
<Compile Include="Widgets\Logic\LobbyUtils.cs" />
<Compile Include="Widgets\Logic\MainMenuButtonsLogic.cs" />
<Compile Include="Widgets\Logic\MainMenuLogic.cs" />
<Compile Include="Widgets\Logic\MapChooserLogic.cs" />
<Compile Include="Widgets\Logic\MissionObjectivesLogic.cs" />
<Compile Include="Widgets\Logic\MusicPlayerLogic.cs" />
@@ -412,6 +413,7 @@
<Compile Include="Widgets\Logic\ReplayBrowserLogic.cs" />
<Compile Include="Widgets\Logic\ServerBrowserLogic.cs" />
<Compile Include="Widgets\Logic\ServerCreationLogic.cs" />
<Compile Include="Widgets\Logic\ShellmapDesaturationLogic.cs" />
<Compile Include="Widgets\MoneyBinWidget.cs" />
<Compile Include="Widgets\ObserverProductionIconsWidget.cs" />
<Compile Include="Widgets\ObserverSupportPowerIconsWidget.cs" />

View File

@@ -1,133 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using OpenRA.Widgets;
namespace OpenRA.Mods.RA.Widgets.Logic
{
public class MainMenuButtonsLogic
{
enum MenuType { Main, None }
MenuType Menu = MenuType.Main;
Widget rootMenu;
[ObjectCreator.UseCtor]
public MainMenuButtonsLogic(Widget widget)
{
rootMenu = widget;
rootMenu.IsVisible = () => Menu == MenuType.Main;
var versionLabel = Ui.Root.GetOrNull<LabelWidget>("VERSION_LABEL");
if (versionLabel != null)
versionLabel.Text = Game.modData.Manifest.Mod.Version;
widget.Get<ButtonWidget>("MAINMENU_BUTTON_JOIN").OnClick = () => OpenGamePanel("JOINSERVER_BG");
widget.Get<ButtonWidget>("MAINMENU_BUTTON_CREATE").OnClick = () => OpenGamePanel("CREATESERVER_BG");
widget.Get<ButtonWidget>("MAINMENU_BUTTON_DIRECTCONNECT").OnClick = () => OpenGamePanel("DIRECTCONNECT_BG");
widget.Get<ButtonWidget>("MAINMENU_BUTTON_SETTINGS").OnClick = () =>
{
Menu = MenuType.None;
Game.OpenWindow("SETTINGS_PANEL", new WidgetArgs()
{
{ "onExit", () => Menu = MenuType.Main }
});
};
widget.Get<ButtonWidget>("MAINMENU_BUTTON_MUSIC").OnClick = () =>
{
Menu = MenuType.None;
Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs()
{
{ "onExit", () => Menu = MenuType.Main }
});
};
widget.Get<ButtonWidget>("MAINMENU_BUTTON_MODS").OnClick = () =>
{
Menu = MenuType.None;
Ui.OpenWindow("MODS_PANEL", new WidgetArgs()
{
{ "onExit", () => Menu = MenuType.Main },
{ "onSwitch", RemoveShellmapUI }
});
};
widget.Get<ButtonWidget>("MAINMENU_BUTTON_CREDITS").OnClick = () =>
{
Menu = MenuType.None;
Ui.OpenWindow("CREDITS_PANEL", new WidgetArgs()
{
{ "onExit", () => Menu = MenuType.Main },
});
};
widget.Get<ButtonWidget>("MAINMENU_BUTTON_REPLAY_VIEWER").OnClick = () =>
{
Menu = MenuType.None;
Ui.OpenWindow("REPLAYBROWSER_BG", new WidgetArgs()
{
{ "onExit", () => Menu = MenuType.Main },
{ "onStart", RemoveShellmapUI }
});
};
var assetBrowserButton = widget.Get<ButtonWidget>("MAINMENU_BUTTON_ASSET_BROWSER");
assetBrowserButton.OnClick = () =>
{
Menu = MenuType.None;
Game.OpenWindow("ASSETBROWSER_BG", new WidgetArgs()
{
{ "onExit", () => Menu = MenuType.Main }
});
};
var quitButton = widget.Get<ButtonWidget>("MAINMENU_BUTTON_QUIT");
quitButton.OnClick = () => Game.Exit();
// Hide developer-specific buttons
if (Game.Settings.Debug.DeveloperMenu == false)
{
assetBrowserButton.IsVisible = () => false;
var offset = assetBrowserButton.Bounds.Y - quitButton.Bounds.Y;
quitButton.Bounds.Y += offset;
rootMenu.Bounds.Height += offset;
rootMenu.Bounds.Y -= offset/2;
}
}
void RemoveShellmapUI()
{
rootMenu.Parent.RemoveChild(rootMenu);
}
void OpenGamePanel(string id)
{
Menu = MenuType.None;
Ui.OpenWindow(id, new WidgetArgs()
{
{ "onExit", () => Menu = MenuType.Main },
{ "openLobby", () => OpenLobbyPanel() }
});
}
void OpenLobbyPanel()
{
Menu = MenuType.None;
Game.OpenWindow("SERVER_LOBBY", new WidgetArgs()
{
{ "onExit", () => { Game.Disconnect(); Menu = MenuType.Main; } },
{ "onStart", RemoveShellmapUI },
{ "addBots", false }
});
}
}
}

View File

@@ -0,0 +1,143 @@
#region Copyright & License Information
/*
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Net;
using OpenRA.Widgets;
namespace OpenRA.Mods.RA.Widgets.Logic
{
public class MainMenuLogic
{
protected enum MenuType { Main, Extras, None }
protected MenuType menuType = MenuType.Main;
Widget rootMenu;
[ObjectCreator.UseCtor]
public MainMenuLogic(Widget widget, World world)
{
rootMenu = widget;
rootMenu.Get<LabelWidget>("VERSION_LABEL").Text = Game.modData.Manifest.Mod.Version;
// Menu buttons
var mainMenu = widget.Get("MAIN_MENU");
mainMenu.IsVisible = () => menuType == MenuType.Main;
mainMenu.Get<ButtonWidget>("SINGLEPLAYER_BUTTON").OnClick = StartSkirmishGame;
mainMenu.Get<ButtonWidget>("MULTIPLAYER_BUTTON").OnClick = () =>
{
menuType = MenuType.None;
Ui.OpenWindow("SERVERBROWSER_PANEL", new WidgetArgs
{
{ "onStart", RemoveShellmapUI },
{ "onExit", () => menuType = MenuType.Main }
});
};
mainMenu.Get<ButtonWidget>("MODS_BUTTON").OnClick = () =>
{
menuType = MenuType.None;
Ui.OpenWindow("MODS_PANEL", new WidgetArgs
{
{ "onExit", () => menuType = MenuType.Main },
{ "onSwitch", RemoveShellmapUI }
});
};
mainMenu.Get<ButtonWidget>("SETTINGS_BUTTON").OnClick = () =>
{
menuType = MenuType.None;
Game.OpenWindow("SETTINGS_PANEL", new WidgetArgs
{
{ "onExit", () => menuType = MenuType.Main }
});
};
mainMenu.Get<ButtonWidget>("EXTRAS_BUTTON").OnClick = () => menuType = MenuType.Extras;
mainMenu.Get<ButtonWidget>("QUIT_BUTTON").OnClick = Game.Exit;
// Extras menu
var extrasMenu = widget.Get("EXTRAS_MENU");
extrasMenu.IsVisible = () => menuType == MenuType.Extras;
extrasMenu.Get<ButtonWidget>("REPLAYS_BUTTON").OnClick = () =>
{
menuType = MenuType.None;
Ui.OpenWindow("REPLAYBROWSER_PANEL", new WidgetArgs
{
{ "onExit", () => menuType = MenuType.Extras },
{ "onStart", RemoveShellmapUI }
});
};
extrasMenu.Get<ButtonWidget>("MUSIC_BUTTON").OnClick = () =>
{
menuType = MenuType.None;
Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs
{
{ "onExit", () => menuType = MenuType.Extras },
});
};
var assetBrowserButton = extrasMenu.GetOrNull<ButtonWidget>("ASSETBROWSER_BUTTON");
if (assetBrowserButton != null)
assetBrowserButton.OnClick = () =>
{
menuType = MenuType.None;
Game.OpenWindow("ASSETBROWSER_PANEL", new WidgetArgs
{
{ "onExit", () => menuType = MenuType.Extras },
});
};
extrasMenu.Get<ButtonWidget>("CREDITS_BUTTON").OnClick = () =>
{
menuType = MenuType.None;
Ui.OpenWindow("CREDITS_PANEL", new WidgetArgs
{
{ "onExit", () => menuType = MenuType.Extras },
});
};
extrasMenu.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => menuType = MenuType.Main;
}
void RemoveShellmapUI()
{
rootMenu.Parent.RemoveChild(rootMenu);
}
void OpenSkirmishLobbyPanel()
{
menuType = MenuType.None;
Game.OpenWindow("SERVER_LOBBY", new WidgetArgs
{
{ "onExit", () => { Game.Disconnect(); menuType = MenuType.Main; } },
{ "onStart", RemoveShellmapUI },
{ "addBots", true }
});
}
void StartSkirmishGame()
{
var map = WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map);
Game.Settings.Server.Map = map;
Game.Settings.Save();
ConnectionLogic.Connect(IPAddress.Loopback.ToString(),
Game.CreateLocalServer(map),
"",
OpenSkirmishLobbyPanel,
() => { Game.CloseServer(); menuType = MenuType.Main; });
}
}
}

View File

@@ -23,8 +23,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
GameServer currentServer;
ScrollItemWidget serverTemplate;
Action OpenLobby;
Action OnExit;
Action onStart;
Action onExit;
enum SearchStatus { Fetching, Failed, NoGames, Hidden }
SearchStatus searchStatus = SearchStatus.Fetching;
@@ -38,19 +39,20 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
switch (searchStatus)
{
case SearchStatus.Fetching: return "Fetching game list...";
case SearchStatus.Failed: return "Failed to contact master server.";
case SearchStatus.NoGames: return "No games found.";
default: return "";
case SearchStatus.Fetching: return "Fetching game list...";
case SearchStatus.Failed: return "Failed to contact master server.";
case SearchStatus.NoGames: return "No games found.";
default: return "";
}
}
[ObjectCreator.UseCtor]
public ServerBrowserLogic(Widget widget, Action openLobby, Action onExit)
public ServerBrowserLogic(Widget widget, Action onStart, Action onExit)
{
var panel = widget;
OpenLobby = openLobby;
OnExit = onExit;
this.onStart = onStart;
this.onExit = onExit;
var sl = panel.Get<ScrollPanelWidget>("SERVER_LIST");
// Menu buttons
@@ -58,6 +60,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
refreshButton.IsDisabled = () => searchStatus == SearchStatus.Fetching;
refreshButton.OnClick = () => ServerList.Query(games => RefreshServerList(panel, games));
panel.Get<ButtonWidget>("DIRECTCONNECT_BUTTON").OnClick = OpenDirectConnectPanel;
panel.Get<ButtonWidget>("CREATE_BUTTON").OnClick = OpenCreateServerPanel;
var join = panel.Get<ButtonWidget>("JOIN_BUTTON");
join.IsDisabled = () => currentServer == null || !currentServer.CanJoin();
join.OnClick = () => Join(currentServer);
@@ -106,6 +111,34 @@ namespace OpenRA.Mods.RA.Widgets.Logic
ServerList.Query(games => RefreshServerList(panel, games));
}
void OpenLobby()
{
Game.OpenWindow("SERVER_LOBBY", new WidgetArgs
{
{ "onExit", Game.Disconnect },
{ "onStart", onStart },
{ "addBots", false }
});
}
void OpenDirectConnectPanel()
{
Ui.OpenWindow("DIRECTCONNECT_PANEL", new WidgetArgs
{
{ "openLobby", OpenLobby },
{ "onExit", () => { } }
});
}
void OpenCreateServerPanel()
{
Ui.OpenWindow("CREATESERVER_PANEL", new WidgetArgs
{
{ "openLobby", OpenLobby },
{ "onExit", () => { } }
});
}
void Join(GameServer server)
{
if (server == null || !server.CanJoin())
@@ -114,8 +147,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var host = server.Address.Split(':')[0];
var port = int.Parse(server.Address.Split(':')[1]);
Ui.CloseWindow();
ConnectionLogic.Connect(host, port, "", OpenLobby, OnExit);
ConnectionLogic.Connect(host, port, "", OpenLobby, onExit);
}
string GetPlayersLabel(GameServer game)

View File

@@ -356,7 +356,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic
BindCheckboxPref(panel, "PERFGRAPH_CHECKBOX", ds, "PerfGraph");
BindCheckboxPref(panel, "CHECKUNSYNCED_CHECKBOX", ds, "SanityCheckUnsyncedCode");
BindCheckboxPref(panel, "BOTDEBUG_CHECKBOX", ds, "BotDebug");
BindCheckboxPref(panel, "DEVELOPER_MENU_CHECKBOX", ds, "DeveloperMenu");
BindCheckboxPref(panel, "CRASH_DIALOG_CHECKBOX", ds, "ShowFatalErrorDialog");
return () => { };
@@ -377,7 +376,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic
ds.PerfGraph = dds.PerfGraph;
ds.SanityCheckUnsyncedCode = dds.SanityCheckUnsyncedCode;
ds.BotDebug = dds.BotDebug;
ds.DeveloperMenu = dds.DeveloperMenu;
ds.ShowFatalErrorDialog = dds.ShowFatalErrorDialog;
};
}

View File

@@ -0,0 +1,23 @@
#region Copyright & License Information
/*
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
namespace OpenRA.Mods.RA.Widgets.Logic
{
public class ShellmapDesaturationLogic
{
[ObjectCreator.UseCtor]
public ShellmapDesaturationLogic(World world)
{
var paletteEffect = world.WorldActor.TraitOrDefault<MenuPaletteEffect>();
if (paletteEffect != null)
paletteEffect.Fade(MenuPaletteEffect.EffectType.Desaturated);
}
}
}

View File

@@ -1,8 +1,10 @@
Container@MENU_BACKGROUND:
Width:WINDOW_RIGHT
Height:WINDOW_BOTTOM
Logic:CncMenuLogic
Logic:CncMainMenuLogic
Children:
Container@SHELLMAP_DESATURATION:
Logic:ShellmapDesaturationLogic
Container@SHELLMAP_DECORATIONS:
Children:
Image@RETICLE:
@@ -57,7 +59,7 @@ Container@MENU_BACKGROUND:
Container@MENUS:
X:(WINDOW_RIGHT-WIDTH)/2
Y:WINDOW_BOTTOM-33-HEIGHT-10
Width:740
Width:890
Height:35
Children:
Container@MAIN_MENU:
@@ -72,7 +74,7 @@ Container@MENU_BACKGROUND:
Align:Center
Font:Bold
Contrast:True
Button@SOLO_BUTTON:
Button@SINGLEPLAYER_BUTTON:
X:0
Y:0
Width:140
@@ -84,72 +86,40 @@ Container@MENU_BACKGROUND:
Width:140
Height:35
Text:Multiplayer
Button@SETTINGS_BUTTON:
X:300
Y:0
Width:140
Height:35
Text:Options
Button@MODS_BUTTON:
X:450
X:300
Y:0
Width:140
Height:35
Text:Mods
Button@QUIT_BUTTON:
Button@SETTINGS_BUTTON:
X:450
Y:0
Width:140
Height:35
Text:Settings
Button@EXTRAS_BUTTON:
X:600
Y:0
Width:140
Height:35
Text:Extras
Button@QUIT_BUTTON:
X:750
Y:0
Width:140
Height:35
Text:Quit
Container@MULTIPLAYER_MENU:
Width:PARENT_RIGHT
Visible:false
Children:
Label@MULTIPLAYER_MENU_TITLE:
X:0
Y:0-30
Width:PARENT_RIGHT
Height:20
Text:Multiplayer
Align:Center
Font:Bold
Contrast:True
Button@CREATE_BUTTON:
X:0
Y:0
Width:140
Height:35
Text:Create Server
Button@JOIN_BUTTON:
X:150
Y:0
Width:140
Height:35
Text:Find Server
Button@DIRECTCONNECT_BUTTON:
X:300
Y:0
Width:140
Height:35
Text:Direct Connect
Button@BACK_BUTTON:
Key:escape
X:600
Y:0
Width:140
Height:35
Text:Back
Container@SETTINGS_MENU:
Container@EXTRAS_MENU:
Width:PARENT_RIGHT
Visible:False
Children:
Label@OPTIONS_MENU_TITLE:
Label@EXTRAS_MENU_TITLE:
X:0
Y:0-30
Width:PARENT_RIGHT
Height:20
Text:Options
Text:Extras
Align:Center
Font:Bold
Contrast:True
@@ -165,21 +135,15 @@ Container@MENU_BACKGROUND:
Width:140
Height:35
Text:Music
Button@SETTINGS_BUTTON:
X:300
Y:0
Width:140
Height:35
Text:Settings
Button@CREDITS_BUTTON:
X:450
X:300
Y:0
Width:140
Height:35
Text:Credits
Button@BACK_BUTTON:
Key:escape
X:600
X:750
Y:0
Width:140
Height:35

View File

@@ -6,7 +6,7 @@ Container@SERVERBROWSER_PANEL:
Height:535
Children:
Label@TITLE:
Text:Find Server
Text:Multiplayer
Width:740
Y:0-25
Font:BigBold
@@ -19,38 +19,44 @@ Container@SERVERBROWSER_PANEL:
Children:
Label@SHOW_LABEL_TITLE:
X:20
Y:10
Y:465
Width:20
Height:25
Text:Show:
Font:Bold
Checkbox@WAITING_FOR_PLAYERS:
X:80
Y:13
Y:468
Width:100
Height:20
Text:Waiting
Checkbox@EMPTY:
X:180
Y:13
Y:468
Width:100
Height:20
Text:Empty
Checkbox@ALREADY_STARTED:
X:280
Y:13
Y:468
Width:100
Height:20
Text:Started
Checkbox@INCOMPATIBLE_VERSION:
X:380
Y:13
Y:468
Width:100
Height:20
Text:Incompatible
Button@REFRESH_BUTTON:
X:PARENT_RIGHT - WIDTH - 20
Y:465
Width:100
Height:25
Text:Refresh
ScrollPanel@SERVER_LIST:
X:15
Y:45
Y:15
Width:700
Height:440
Children:
@@ -120,12 +126,18 @@ Container@SERVERBROWSER_PANEL:
Width:140
Height:35
Text:Back
Button@REFRESH_BUTTON:
Button@CREATE_BUTTON:
X:PARENT_RIGHT - 140 - 10 - 140 - 10 - 140
Y:499
Width:140
Height:35
Text:Create
Button@DIRECTCONNECT_BUTTON:
X:PARENT_RIGHT - 140 - 10 - 140
Y:499
Width:140
Height:35
Text:Refresh
Text:Direct IP
Button@JOIN_BUTTON:
Key:return
X:PARENT_RIGHT - 140

View File

@@ -427,13 +427,6 @@ Container@SETTINGS_PANEL:
Height:20
Font:Regular
Text:Show Performance Graph
Checkbox@DEVELOPER_MENU_CHECKBOX:
X:15
Y:100
Width:300
Height:20
Font:Regular
Text:Enable Asset Browser (requires restart)
Label@HOTKEY_TITLE:
Y:140
Width:PARENT_RIGHT

View File

@@ -3,7 +3,7 @@ World:
ActorMap:
LoadWidgetAtGameStart:
Widget: INGAME_ROOT
CncMenuPaletteEffect:
MenuPaletteEffect:
CloakPaletteEffect:
ScreenShaker:
NukePaletteEffect:

View File

@@ -1,105 +1,139 @@
Background@MAINMENU:
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:250
Height:500
Visible:true
Logic:MainMenuButtonsLogic
Container@MAINMENU:
Logic:MainMenuLogic
Children:
Label@MAINMENU_LABEL_TITLE:
X:0
Y:20
Width:250
Height:25
Text:OpenD2k Main Menu
Align:Center
Font:Bold
Button@MAINMENU_BUTTON_JOIN:
X:45
Y:70
Width:160
Height:25
Text:Join Game
Font:Bold
Button@MAINMENU_BUTTON_CREATE:
X:45
Y:110
Width:160
Height:25
Text:Create Game
Font:Bold
Button@MAINMENU_BUTTON_DIRECTCONNECT:
X:45
Y:150
Width:160
Height:25
Text:Direct Connect
Font:Bold
Button@MAINMENU_BUTTON_SETTINGS:
X:45
Y:190
Width:160
Height:25
Text:Settings
Font:Bold
Button@MAINMENU_BUTTON_MODS:
X:45
Y:230
Width:160
Height:25
Text:Mods
Font:Bold
Button@MAINMENU_BUTTON_MUSIC:
X:45
Y:270
Width:160
Height:25
Text:Music
Font:Bold
Button@MAINMENU_BUTTON_REPLAY_VIEWER:
X:45
Y:310
Width:160
Height:25
Text:Replay Viewer
Font:Bold
Button@MAINMENU_BUTTON_CREDITS:
X:45
Y:350
Width:160
Height:25
Text:Credits
Font:Bold
Button@MAINMENU_BUTTON_ASSET_BROWSER:
X:45
Y:390
Width:160
Height:25
Text:Asset Browser
Font:Bold
Button@MAINMENU_BUTTON_QUIT:
X:45
Y:430
Width:160
Height:25
Text:Quit
Font:Bold
Background@PERF_BG:
ClickThrough:true
Background:dialog4
Logic:PerfDebugLogic
X:10
Y:WINDOW_BOTTOM - 250
Width: 210
Height: 250
Children:
PerfGraph@GRAPH:
X:5
Y:5
Label@VERSION_LABEL:
X:WINDOW_RIGHT - 10
Y:WINDOW_BOTTOM - 20
Align:Right
Font:Regular
Contrast:True
Container@MENUS:
X:100
Y:WINDOW_BOTTOM/2-HEIGHT/2
Width:200
Height:200
Label@TEXT:
X:20
Y:205
Width:170
Height:40
Height:320
Children:
Background@MAIN_MENU:
Width:PARENT_RIGHT
Height:PARENT_BOTTOM
Children:
Label@MAINMENU_LABEL_TITLE:
X:0
Y:20
Width:200
Height:30
Text:OpenRA
Align:Center
Font:Bold
Button@SINGLEPLAYER_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Y:60
Width:140
Height:30
Text:Singleplayer
Font:Bold
Button@MULTIPLAYER_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Y:100
Width:140
Height:30
Text:Multiplayer
Font:Bold
Button@MODS_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Y:140
Width:140
Height:30
Text:Mods
Font:Bold
Button@SETTINGS_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Y:180
Width:140
Height:30
Text:Settings
Font:Bold
Button@EXTRAS_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Y:220
Width:140
Height:30
Text:Extras
Font:Bold
Button@QUIT_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Y:260
Width:140
Height:30
Text:Quit
Font:Bold
Background@EXTRAS_MENU:
Width:PARENT_RIGHT
Height:PARENT_BOTTOM
Children:
Label@EXTRAS_MENU_TITLE:
X:0
Y:20
Width:200
Height:30
Text:Extras
Align:Center
Font:Bold
Button@REPLAYS_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Y:60
Width:140
Height:30
Text:Replays
Font:Bold
Button@MUSIC_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Y:100
Width:140
Height:30
Text:Music
Font:Bold
Button@ASSETBROWSER_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Y:140
Width:140
Height:30
Text:Asset Browser
Font:Bold
Button@CREDITS_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Y:180
Width:140
Height:30
Text:Credits
Font:Bold
Button@BACK_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Key:escape
Y:260
Width:140
Height:30
Text:Back
Font:Bold
Container@PERFORMANCE_INFO:
Logic:PerfDebugLogic
Children:
Label@PERF_TEXT:
X:30
Y:WINDOW_BOTTOM - 70
Width:170
Height:40
Contrast:true
Background@GRAPH_BG:
ClickThrough:true
Background:dialog4
X:WINDOW_RIGHT - 240
Y:WINDOW_BOTTOM - 240
Width:210
Height:210
Children:
PerfGraph@GRAPH:
X:5
Y:5
Width:200
Height:200

View File

@@ -1,4 +1,4 @@
Background@ASSETBROWSER_BG:
Background@ASSETBROWSER_PANEL:
Logic:AssetBrowserLogic
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2

View File

@@ -1,4 +1,4 @@
Background@CREATESERVER_BG:
Background@CREATESERVER_PANEL:
Logic:ServerCreationLogic
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2

View File

@@ -1,4 +1,4 @@
Background@DIRECTCONNECT_BG:
Background@DIRECTCONNECT_PANEL:
Logic:DirectConnectLogic
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
@@ -10,7 +10,7 @@ Background@DIRECTCONNECT_BG:
Y:20
Width:400
Height:25
Text:Direct Connect
Text:Connect to Server
Align:Center
Font:Bold
Label@ADDRESS_LABEL:

View File

@@ -1,4 +1,5 @@
Container@MAINMENU:
Logic:MainMenuLogic
Children:
Background@BORDER:
Background:mainmenu-border
@@ -19,91 +20,114 @@ Container@MAINMENU:
Align:Center
Font:Regular
Contrast:True
Background@MAINMENU_BG:
X:(WINDOW_RIGHT - WIDTH)/8
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:250
Height:605
Logic:MainMenuButtonsLogic
Container@MENUS:
X:100
Y:WINDOW_BOTTOM/2-HEIGHT/2
Width:200
Height:320
Children:
Label@MAINMENU_LABEL_TITLE:
X:0
Y:20
Width:250
Height:35
Text:OpenRA
Align:Center
Font:Title
Button@MAINMENU_BUTTON_JOIN:
X:45
Y:80
Width:160
Height:35
Text:Join Game
Font:Bold
Button@MAINMENU_BUTTON_CREATE:
X:45
Y:130
Width:160
Height:35
Text:Create Game
Font:Bold
Button@MAINMENU_BUTTON_DIRECTCONNECT:
X:45
Y:180
Width:160
Height:35
Text:Direct Connect
Font:Bold
Button@MAINMENU_BUTTON_SETTINGS:
X:45
Y:230
Width:160
Height:35
Text:Settings
Font:Bold
Button@MAINMENU_BUTTON_MODS:
X:45
Y:280
Width:160
Height:35
Text:Mods
Font:Bold
Button@MAINMENU_BUTTON_MUSIC:
X:45
Y:330
Width:160
Height:35
Text:Music
Font:Bold
Button@MAINMENU_BUTTON_REPLAY_VIEWER:
X:45
Y:380
Width:160
Height:35
Text:Replay Viewer
Font:Bold
Button@MAINMENU_BUTTON_CREDITS:
X:45
Y:430
Width:160
Height:35
Text:Credits
Font:Bold
Button@MAINMENU_BUTTON_ASSET_BROWSER:
X:45
Y:480
Width:160
Height:35
Text:Asset Browser
Font:Bold
Button@MAINMENU_BUTTON_QUIT:
X:45
Y:530
Width:160
Height:35
Text:Quit
Font:Bold
Background@MAIN_MENU:
Width:PARENT_RIGHT
Height:PARENT_BOTTOM
Children:
Label@MAINMENU_LABEL_TITLE:
X:0
Y:20
Width:200
Height:30
Text:OpenRA
Align:Center
Font:Bold
Button@SINGLEPLAYER_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Y:60
Width:140
Height:30
Text:Singleplayer
Font:Bold
Button@MULTIPLAYER_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Y:100
Width:140
Height:30
Text:Multiplayer
Font:Bold
Button@MODS_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Y:140
Width:140
Height:30
Text:Mods
Font:Bold
Button@SETTINGS_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Y:180
Width:140
Height:30
Text:Settings
Font:Bold
Button@EXTRAS_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Y:220
Width:140
Height:30
Text:Extras
Font:Bold
Button@QUIT_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Y:260
Width:140
Height:30
Text:Quit
Font:Bold
Background@EXTRAS_MENU:
Width:PARENT_RIGHT
Height:PARENT_BOTTOM
Children:
Label@EXTRAS_MENU_TITLE:
X:0
Y:20
Width:200
Height:30
Text:Extras
Align:Center
Font:Bold
Button@REPLAYS_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Y:60
Width:140
Height:30
Text:Replays
Font:Bold
Button@MUSIC_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Y:100
Width:140
Height:30
Text:Music
Font:Bold
Button@ASSETBROWSER_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Y:140
Width:140
Height:30
Text:Asset Browser
Font:Bold
Button@CREDITS_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Y:180
Width:140
Height:30
Text:Credits
Font:Bold
Button@BACK_BUTTON:
X:PARENT_RIGHT/2-WIDTH/2
Key:escape
Y:260
Width:140
Height:30
Text:Back
Font:Bold
Container@PERFORMANCE_INFO:
Logic:PerfDebugLogic
Children:

View File

@@ -1,4 +1,4 @@
Background@REPLAYBROWSER_BG:
Background@REPLAYBROWSER_PANEL:
Logic:ReplayBrowserLogic
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2

View File

@@ -1,16 +1,16 @@
Background@JOINSERVER_BG:
Background@SERVERBROWSER_PANEL:
Logic:ServerBrowserLogic
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:740
Height:505
Height:500
Children:
Label@JOINSERVER_LABEL_TITLE:
Label@MULTIPLAYER_LABEL_TITLE:
X:0
Y:15
Width:PARENT_RIGHT
Height:25
Text:Join Server
Text:Multiplayer
Align:Center
Font:Bold
Label@SHOW_LABEL_TITLE:
@@ -48,7 +48,7 @@ Background@JOINSERVER_BG:
X:20
Y:80
Width:700
Height:355
Height:360
Children:
ScrollItem@SERVER_TEMPLATE:
Width:PARENT_RIGHT-27
@@ -115,6 +115,20 @@ Background@JOINSERVER_BG:
Height:25
Text:Refresh
Font:Bold
Button@CREATE_BUTTON:
X:PARENT_RIGHT - 120 - 120 - 120 - 120
Y:PARENT_BOTTOM - 45
Width:100
Height:25
Text:Create
Font:Bold
Button@DIRECTCONNECT_BUTTON:
X:PARENT_RIGHT - 120 - 120 - 120
Y:PARENT_BOTTOM - 45
Width:100
Height:25
Text:Direct IP
Font:Bold
Button@JOIN_BUTTON:
X:PARENT_RIGHT - 120 - 120
Y:PARENT_BOTTOM - 45

View File

@@ -415,13 +415,6 @@ Background@SETTINGS_PANEL:
Height:20
Font:Regular
Text:Show Performance Graph
Checkbox@DEVELOPER_MENU_CHECKBOX:
X:15
Y:100
Width:300
Height:20
Font:Regular
Text:Enable Asset Browser (requires restart)
Label@HOTKEY_TITLE:
Y:140
Width:PARENT_RIGHT