Merge pull request #7121 from pchote/switchmods

Add Launch.Connect command and on-connect mod switching.
This commit is contained in:
Oliver Brakmann
2014-12-24 16:06:00 +01:00
19 changed files with 193 additions and 116 deletions

View File

@@ -48,7 +48,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Ui.OpenWindow("SERVERBROWSER_PANEL", new WidgetArgs
{
{ "onStart", RemoveShellmapUI },
{ "onExit", () => menuType = MenuType.Main }
{ "onExit", () => menuType = MenuType.Main },
{ "directConnectHost", null },
{ "directConnectPort", 0 },
});
};
@@ -173,6 +175,18 @@ namespace OpenRA.Mods.RA.Widgets.Logic
newsButton.IsHighlighted = () => newsHighlighted && Game.LocalTick % 50 < 25;
}
Game.OnRemoteDirectConnect += (host, port) =>
{
menuType = MenuType.None;
Ui.OpenWindow("SERVERBROWSER_PANEL", new WidgetArgs
{
{ "onStart", RemoveShellmapUI },
{ "onExit", () => menuType = MenuType.Main },
{ "directConnectHost", host },
{ "directConnectPort", port },
});
};
}
void SetNewsStatus(string message)

View File

@@ -85,7 +85,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (installButton != null)
{
installButton.IsDisabled = () => world == null || !world.IsShellmap;
var args = new string[] { "Launch.Window=INSTALL_MUSIC_PANEL" };
var args = new string[] { "Install.Music=true" };
installButton.OnClick = () =>
{
Game.modData.LoadScreen.Display(); // HACK: prevent a flicker when transitioning to the installation dialog

View File

@@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
}
[ObjectCreator.UseCtor]
public ServerBrowserLogic(Widget widget, Action onStart, Action onExit)
public ServerBrowserLogic(Widget widget, Action onStart, Action onExit, string directConnectHost, int directConnectPort)
{
panel = widget;
this.onStart = onStart;
@@ -116,6 +116,18 @@ namespace OpenRA.Mods.RA.Widgets.Logic
}
RefreshServerList();
if (directConnectHost != null)
{
// The connection window must be opened at the end of the tick for the widget hierarchy to
// work out, but we also want to prevent the server browser from flashing visible for one tick.
widget.Visible = false;
Game.RunAfterTick(() =>
{
ConnectionLogic.Connect(directConnectHost, directConnectPort, "", OpenLobby, DoNothing);
widget.Visible = true;
});
}
}
void RefreshServerList()