Merge pull request #7121 from pchote/switchmods
Add Launch.Connect command and on-connect mod switching.
This commit is contained in:
91
OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs
Normal file
91
OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
#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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.FileSystem;
|
||||
using OpenRA.Widgets;
|
||||
using OpenRA.Mods.Common.Widgets.Logic;
|
||||
|
||||
namespace OpenRA.Mods.Common.LoadScreens
|
||||
{
|
||||
public class BlankLoadScreen : ILoadScreen
|
||||
{
|
||||
public virtual void Init(Manifest m, Dictionary<string, string> info) { }
|
||||
|
||||
public virtual void Display()
|
||||
{
|
||||
if (Game.Renderer == null)
|
||||
return;
|
||||
|
||||
// Draw a black screen
|
||||
Game.Renderer.BeginFrame(int2.Zero, 1f);
|
||||
Game.Renderer.EndFrame(new NullInputHandler());
|
||||
}
|
||||
|
||||
public void StartGame(Arguments args)
|
||||
{
|
||||
Ui.ResetAll();
|
||||
Game.Settings.Save();
|
||||
|
||||
// Check whether the mod content is installed
|
||||
// TODO: The installation code has finally been beaten into shape, so we can
|
||||
// finally move it all into the planned "Manage Content" panel in the modchooser mod.
|
||||
var installData = Game.modData.Manifest.ContentInstaller;
|
||||
var installModContent = !installData.TestFiles.All(f => GlobalFileSystem.Exists(f));
|
||||
var installModMusic = args != null && args.Contains("Install.Music");
|
||||
|
||||
if (installModContent || installModMusic)
|
||||
{
|
||||
var widgetArgs = new WidgetArgs()
|
||||
{
|
||||
{ "continueLoading", () => Game.InitializeMod(Game.Settings.Game.Mod, args) },
|
||||
};
|
||||
|
||||
if (installData.BackgroundWidget != null)
|
||||
Ui.LoadWidget(installData.BackgroundWidget, Ui.Root, widgetArgs);
|
||||
|
||||
var menu = installModContent ? installData.MenuWidget : installData.MusicMenuWidget;
|
||||
Ui.OpenWindow(menu, widgetArgs);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Join a server directly
|
||||
var connect = args != null ? args.GetValue("Launch.Connect", null) : null;
|
||||
if (!string.IsNullOrEmpty(connect))
|
||||
{
|
||||
var parts = connect.Split(':');
|
||||
|
||||
if (parts.Length == 2)
|
||||
{
|
||||
var host = parts[0];
|
||||
var port = Exts.ParseIntegerInvariant(parts[1]);
|
||||
Game.LoadShellMap();
|
||||
Game.RemoteDirectConnect(host, port);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Load a replay directly
|
||||
var replay = args != null ? args.GetValue("Launch.Replay", null) : null;
|
||||
if (!string.IsNullOrEmpty(replay))
|
||||
{
|
||||
Game.JoinReplay(replay);
|
||||
return;
|
||||
}
|
||||
|
||||
Game.LoadShellMap();
|
||||
Game.Settings.Save();
|
||||
}
|
||||
|
||||
public virtual void Dispose() { }
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.LoadScreens
|
||||
{
|
||||
public sealed class DefaultLoadScreen : ILoadScreen
|
||||
public sealed class LogoStripeLoadScreen : BlankLoadScreen
|
||||
{
|
||||
Stopwatch lastUpdate = Stopwatch.StartNew();
|
||||
Renderer r;
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.LoadScreens
|
||||
Sprite stripe, logo;
|
||||
string[] messages;
|
||||
|
||||
public void Init(Manifest m, Dictionary<string, string> info)
|
||||
public override void Init(Manifest m, Dictionary<string, string> info)
|
||||
{
|
||||
// Avoid standard loading mechanisms so we
|
||||
// can display the loadscreen as early as possible
|
||||
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.LoadScreens
|
||||
logoPos = new float2(r.Resolution.Width / 2 - 128, r.Resolution.Height / 2 - 128);
|
||||
}
|
||||
|
||||
public void Display()
|
||||
public override void Display()
|
||||
{
|
||||
if (r == null)
|
||||
return;
|
||||
@@ -66,12 +66,7 @@ namespace OpenRA.Mods.Common.LoadScreens
|
||||
r.EndFrame(new NullInputHandler());
|
||||
}
|
||||
|
||||
public void StartGame()
|
||||
{
|
||||
Game.TestAndContinue();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
public override void Dispose()
|
||||
{
|
||||
if (sheet != null)
|
||||
sheet.Dispose();
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.LoadScreens
|
||||
r.EndFrame(new NullInputHandler());
|
||||
}
|
||||
|
||||
public void StartGame()
|
||||
public void StartGame(Arguments args)
|
||||
{
|
||||
Ui.LoadWidget("MODCHOOSER", Ui.Root, new WidgetArgs());
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
#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.Collections.Generic;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.LoadScreens
|
||||
{
|
||||
public sealed class NullLoadScreen : ILoadScreen
|
||||
{
|
||||
public void Init(Manifest m, Dictionary<string, string> info) { }
|
||||
|
||||
public void Display()
|
||||
{
|
||||
if (Game.Renderer == null)
|
||||
return;
|
||||
|
||||
// Draw a black screen
|
||||
Game.Renderer.BeginFrame(int2.Zero, 1f);
|
||||
Game.Renderer.EndFrame(new NullInputHandler());
|
||||
}
|
||||
|
||||
public void StartGame()
|
||||
{
|
||||
Ui.ResetAll();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,9 +80,7 @@
|
||||
<Compile Include="Graphics\TextRenderable.cs" />
|
||||
<Compile Include="Graphics\VoxelActorPreview.cs" />
|
||||
<Compile Include="Graphics\VoxelRenderable.cs" />
|
||||
<Compile Include="LoadScreens\DefaultLoadScreen.cs" />
|
||||
<Compile Include="LoadScreens\ModChooserLoadScreen.cs" />
|
||||
<Compile Include="LoadScreens\NullLoadScreen.cs" />
|
||||
<Compile Include="Orders\DeployOrderTargeter.cs" />
|
||||
<Compile Include="Orders\EnterAlliedActorTargeter.cs" />
|
||||
<Compile Include="Orders\UnitOrderTargeter.cs" />
|
||||
@@ -243,6 +241,8 @@
|
||||
<Compile Include="SpriteLoaders\ShpD2Loader.cs" />
|
||||
<Compile Include="Widgets\Logic\SettingsLogic.cs" />
|
||||
<Compile Include="Widgets\TerrainTemplatePreviewWidget.cs" />
|
||||
<Compile Include="LoadScreens\LogoStripeLoadScreen.cs" />
|
||||
<Compile Include="LoadScreens\BlankLoadScreen.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
|
||||
Reference in New Issue
Block a user