restart the game instead of unmounting on the fly
avoid more redundancy between the load screens
This commit is contained in:
@@ -361,13 +361,13 @@ namespace OpenRA
|
||||
foreach (var mod in ModMetadata.AllMods)
|
||||
Console.WriteLine("\t{0}: {1} ({2})", mod.Key, mod.Value.Title, mod.Value.Version);
|
||||
|
||||
InitializeWithMod(Settings.Game.Mod, args.GetValue("Launch.Replay", null));
|
||||
InitializeMod(Settings.Game.Mod, args);
|
||||
|
||||
if (Settings.Server.DiscoverNatDevices)
|
||||
RunAfterDelay(Settings.Server.NatDiscoveryTimeout, UPnP.StoppingNatDiscovery);
|
||||
}
|
||||
|
||||
public static void InitializeWithMod(string mod, string replay)
|
||||
public static void InitializeMod(string mod, Arguments args)
|
||||
{
|
||||
// Clear static state if we have switched mods
|
||||
LobbyInfoChanged = () => { };
|
||||
@@ -439,13 +439,45 @@ namespace OpenRA
|
||||
}
|
||||
else
|
||||
{
|
||||
modData.LoadScreen.StartGame();
|
||||
Settings.Save();
|
||||
if (!string.IsNullOrEmpty(replay))
|
||||
Game.JoinReplay(replay);
|
||||
var window = args != null ? args.GetValue("Launch.Window", null) : null;
|
||||
if (!string.IsNullOrEmpty(window))
|
||||
{
|
||||
var installData = modData.Manifest.ContentInstaller;
|
||||
if (installData.ContainsKey("InstallerBackgroundWidget"))
|
||||
Ui.LoadWidget(installData["InstallerBackgroundWidget"], Ui.Root, new WidgetArgs());
|
||||
|
||||
Widgets.Ui.OpenWindow(window, new WidgetArgs());
|
||||
}
|
||||
else
|
||||
{
|
||||
modData.LoadScreen.StartGame();
|
||||
Settings.Save();
|
||||
var replay = args != null ? args.GetValue("Launch.Replay", null) : null;
|
||||
if (!string.IsNullOrEmpty(replay))
|
||||
Game.JoinReplay(replay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void TestAndContinue()
|
||||
{
|
||||
Ui.ResetAll();
|
||||
var installData = modData.Manifest.ContentInstaller;
|
||||
if (!installData["TestFiles"].Split(',').All(f => GlobalFileSystem.Exists(f.Trim())))
|
||||
{
|
||||
var args = new WidgetArgs()
|
||||
{
|
||||
{ "continueLoading", () => TestAndContinue() },
|
||||
{ "installData", installData }
|
||||
};
|
||||
if (installData.ContainsKey("InstallerBackgroundWidget"))
|
||||
Ui.LoadWidget(installData["InstallerBackgroundWidget"], Ui.Root, args);
|
||||
Ui.OpenWindow(installData["InstallerMenuWidget"], args);
|
||||
}
|
||||
else
|
||||
LoadShellMap();
|
||||
}
|
||||
|
||||
public static void LoadShellMap()
|
||||
{
|
||||
var shellmap = ChooseShellmap();
|
||||
@@ -471,7 +503,7 @@ namespace OpenRA
|
||||
|
||||
static double idealFrameTime;
|
||||
public static void SetIdealFrameTime(int fps)
|
||||
{
|
||||
{
|
||||
idealFrameTime = 1.0 / fps;
|
||||
}
|
||||
|
||||
|
||||
@@ -121,25 +121,7 @@ namespace OpenRA.Mods.Cnc
|
||||
|
||||
public void StartGame()
|
||||
{
|
||||
TestAndContinue();
|
||||
}
|
||||
|
||||
void TestAndContinue()
|
||||
{
|
||||
Ui.ResetAll();
|
||||
var installData = Game.modData.Manifest.ContentInstaller;
|
||||
if (!installData["TestFiles"].Split(',').All(f => GlobalFileSystem.Exists(f.Trim())))
|
||||
{
|
||||
var args = new WidgetArgs()
|
||||
{
|
||||
{ "continueLoading", () => TestAndContinue() },
|
||||
{ "installData", installData }
|
||||
};
|
||||
Ui.LoadWidget(installData["InstallerBackgroundWidget"], Ui.Root, args);
|
||||
Ui.OpenWindow(installData["InstallerMenuWidget"], args);
|
||||
}
|
||||
else
|
||||
Game.LoadShellMap();
|
||||
Game.TestAndContinue();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,24 +69,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public void StartGame()
|
||||
{
|
||||
TestAndContinue();
|
||||
}
|
||||
|
||||
void TestAndContinue()
|
||||
{
|
||||
Ui.ResetAll();
|
||||
var installData = Game.modData.Manifest.ContentInstaller;
|
||||
if (!installData["TestFiles"].Split(',').All(f => GlobalFileSystem.Exists(f.Trim())))
|
||||
{
|
||||
var args = new WidgetArgs()
|
||||
{
|
||||
{ "continueLoading", () => TestAndContinue() },
|
||||
{ "installData", installData }
|
||||
};
|
||||
Ui.OpenWindow(installData["InstallerMenuWidget"], args);
|
||||
}
|
||||
else
|
||||
Game.LoadShellMap();
|
||||
Game.TestAndContinue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.RA
|
||||
public void StartGame()
|
||||
{
|
||||
Ui.ResetAll();
|
||||
Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Ui.Root, "INIT_SETUP" );
|
||||
Game.modData.WidgetLoader.LoadWidget(new WidgetArgs(), Ui.Root, "INIT_SETUP");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
public InstallLogic(Widget widget, IReadOnlyDictionary<string, string> installData, Action continueLoading)
|
||||
{
|
||||
var panel = widget.Get("INSTALL_PANEL");
|
||||
var args = new WidgetArgs()
|
||||
var widgetArgs = new WidgetArgs()
|
||||
{
|
||||
{ "afterInstall", () => { Ui.CloseWindow(); continueLoading(); } },
|
||||
{ "installData", installData },
|
||||
@@ -28,15 +28,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
};
|
||||
|
||||
panel.Get<ButtonWidget>("DOWNLOAD_BUTTON").OnClick = () =>
|
||||
Ui.OpenWindow("INSTALL_DOWNLOAD_PANEL", args);
|
||||
Ui.OpenWindow("INSTALL_DOWNLOAD_PANEL", widgetArgs);
|
||||
|
||||
panel.Get<ButtonWidget>("INSTALL_BUTTON").OnClick = () =>
|
||||
Ui.OpenWindow("INSTALL_FROMCD_PANEL", args);
|
||||
Ui.OpenWindow("INSTALL_FROMCD_PANEL", widgetArgs);
|
||||
|
||||
panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = () =>
|
||||
{
|
||||
Game.Settings.Game.PreviousMod = Game.modData.Manifest.Mod.Id;
|
||||
Game.InitializeWithMod("modchooser", null);
|
||||
Game.InitializeMod("modchooser", null);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,56 +19,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
{
|
||||
public class InstallMusicLogic
|
||||
{
|
||||
ButtonWidget installButton;
|
||||
Ruleset modRules;
|
||||
IReadOnlyDictionary<string, string> installData;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public InstallMusicLogic(Widget widget, Ruleset modRules)
|
||||
public InstallMusicLogic(Widget widget)
|
||||
{
|
||||
this.modRules = modRules;
|
||||
|
||||
installData = Game.modData.Manifest.ContentInstaller;
|
||||
|
||||
installButton = widget.GetOrNull<ButtonWidget>("INSTALL_BUTTON");
|
||||
if (installButton != null)
|
||||
{
|
||||
installButton.OnClick = () => LoadInstallMusicContainer();
|
||||
installButton.IsVisible = () =>
|
||||
modRules.InstalledMusic.ToArray().Length <= Exts.ParseIntegerInvariant(installData["ShippedSoundtracks"]);
|
||||
}
|
||||
}
|
||||
|
||||
bool previousShowShellSetting;
|
||||
void LoadInstallMusicContainer()
|
||||
{
|
||||
var installMusicContainer = Ui.OpenWindow("INSTALL_MUSIC_PANEL", new WidgetArgs());
|
||||
|
||||
Action after = () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
GlobalFileSystem.LoadFromManifest(Game.modData.Manifest);
|
||||
modRules.Music.Do(m => m.Value.Reload());
|
||||
var musicPlayerLogic = (MusicPlayerLogic)installButton.Parent.LogicObject;
|
||||
musicPlayerLogic.BuildMusicTable();
|
||||
Ui.CloseWindow();
|
||||
Game.Settings.Game.ShowShellmap = previousShowShellSetting;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Write("debug", "Mounting the new MIX file and rebuild of scores list failed:\n{0}", e);
|
||||
}
|
||||
};
|
||||
var installMusicContainer = widget.Get("INSTALL_MUSIC_PANEL");
|
||||
|
||||
var cancelButton = installMusicContainer.GetOrNull<ButtonWidget>("CANCEL_BUTTON");
|
||||
if (cancelButton != null)
|
||||
{
|
||||
cancelButton.OnClick = () =>
|
||||
{
|
||||
Game.Settings.Game.ShowShellmap = previousShowShellSetting;
|
||||
Ui.CloseWindow();
|
||||
};
|
||||
cancelButton.OnClick = () => Game.InitializeMod(Game.Settings.Game.Mod, null);
|
||||
}
|
||||
|
||||
var copyFromDiscButton = installMusicContainer.GetOrNull<ButtonWidget>("COPY_FROM_CD_BUTTON");
|
||||
@@ -76,11 +35,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
{
|
||||
copyFromDiscButton.OnClick = () =>
|
||||
{
|
||||
previousShowShellSetting = Game.Settings.Game.ShowShellmap;
|
||||
Game.Settings.Game.ShowShellmap = false;
|
||||
GlobalFileSystem.UnmountAll();
|
||||
Ui.OpenWindow("INSTALL_FROMCD_PANEL", new WidgetArgs() {
|
||||
{ "continueLoading", after },
|
||||
{ "continueLoading", () => Game.InitializeMod(Game.Settings.Game.Mod, null) },
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -88,17 +44,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
var downloadButton = installMusicContainer.GetOrNull<ButtonWidget>("DOWNLOAD_BUTTON");
|
||||
if (downloadButton != null)
|
||||
{
|
||||
var installData = Game.modData.Manifest.ContentInstaller;
|
||||
downloadButton.IsVisible = () => !string.IsNullOrEmpty(installData["MusicPackageMirrorList"]);
|
||||
var musicInstallData = new Dictionary<string, string> { };
|
||||
musicInstallData["PackageMirrorList"] = installData["MusicPackageMirrorList"];
|
||||
|
||||
downloadButton.OnClick = () =>
|
||||
{
|
||||
previousShowShellSetting = Game.Settings.Game.ShowShellmap;
|
||||
Game.Settings.Game.ShowShellmap = false;
|
||||
GlobalFileSystem.UnmountAll();
|
||||
Ui.OpenWindow("INSTALL_DOWNLOAD_PANEL", new WidgetArgs() {
|
||||
{ "afterInstall", after },
|
||||
{ "afterInstall", () => Game.InitializeMod(Game.Settings.Game.Mod, null) },
|
||||
{ "installData", new ReadOnlyDictionary<string, string>(musicInstallData) },
|
||||
});
|
||||
};
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
mainMenu.Get<ButtonWidget>("MODS_BUTTON").OnClick = () =>
|
||||
{
|
||||
Game.Settings.Game.PreviousMod = Game.modData.Manifest.Mod.Id;
|
||||
Game.InitializeWithMod("modchooser", null);
|
||||
Game.InitializeMod("modchooser", null);
|
||||
};
|
||||
|
||||
mainMenu.Get<ButtonWidget>("SETTINGS_BUTTON").OnClick = () =>
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
Game.RunAfterTick(() =>
|
||||
{
|
||||
Ui.CloseWindow();
|
||||
Game.InitializeWithMod(mod.Id, null);
|
||||
Game.InitializeMod(mod.Id, null);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +81,16 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
musicSlider.OnChange += x => Sound.MusicVolume = x;
|
||||
musicSlider.Value = Sound.MusicVolume;
|
||||
|
||||
var installButton = widget.GetOrNull<ButtonWidget>("INSTALL_BUTTON");
|
||||
if (installButton != null)
|
||||
{
|
||||
var args = new string[] { "Launch.Window=INSTALL_MUSIC_PANEL" };
|
||||
installButton.OnClick = () => Game.InitializeMod(Game.Settings.Game.Mod, new Arguments(args));
|
||||
var installData = Game.modData.Manifest.ContentInstaller;
|
||||
installButton.IsVisible = () =>
|
||||
modRules.InstalledMusic.ToArray().Length <= Exts.ParseIntegerInvariant(installData["ShippedSoundtracks"]);
|
||||
}
|
||||
|
||||
panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => { Game.Settings.Save(); Ui.CloseWindow(); onExit(); };
|
||||
}
|
||||
|
||||
|
||||
@@ -170,7 +170,6 @@ Container@MUSIC_PANEL:
|
||||
Height: 35
|
||||
Text: Back
|
||||
Button@INSTALL_BUTTON:
|
||||
Logic: InstallMusicLogic
|
||||
X: 220
|
||||
Y: 399
|
||||
Width: 140
|
||||
|
||||
@@ -150,7 +150,6 @@ Background@MUSIC_PANEL:
|
||||
Visible: false
|
||||
Text: No Music Installed
|
||||
Button@INSTALL_BUTTON:
|
||||
Logic: InstallMusicLogic
|
||||
X: 20
|
||||
Y: PARENT_BOTTOM - 45
|
||||
Width: 120
|
||||
|
||||
Reference in New Issue
Block a user