Pipe mod music installation through the ModChooser
This commit is contained in:
@@ -41,8 +41,17 @@ namespace OpenRA.Mods.Common.LoadScreens
|
|||||||
|
|
||||||
public void StartGame(Arguments args)
|
public void StartGame(Arguments args)
|
||||||
{
|
{
|
||||||
Ui.LoadWidget("MODCHOOSER_BACKGROUND", Ui.Root, new WidgetArgs());
|
var widgetArgs = new WidgetArgs();
|
||||||
Ui.OpenWindow("MODCHOOSER_DIALOG");
|
|
||||||
|
Ui.LoadWidget("MODCHOOSER_BACKGROUND", Ui.Root, widgetArgs);
|
||||||
|
|
||||||
|
if (args != null && args.Contains("installMusic"))
|
||||||
|
{
|
||||||
|
widgetArgs.Add("modId", args.GetValue("installMusic", ""));
|
||||||
|
Ui.OpenWindow("INSTALL_MUSIC_PANEL", widgetArgs);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Ui.OpenWindow("MODCHOOSER_DIALOG", widgetArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|||||||
@@ -9,10 +9,6 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using OpenRA.FileSystem;
|
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||||
@@ -20,38 +16,42 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
public class InstallMusicLogic
|
public class InstallMusicLogic
|
||||||
{
|
{
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public InstallMusicLogic(Widget widget)
|
public InstallMusicLogic(Widget widget, string modId)
|
||||||
{
|
{
|
||||||
var installMusicContainer = widget.Get("INSTALL_MUSIC_PANEL");
|
var installMusicContainer = widget.Get("INSTALL_MUSIC_PANEL");
|
||||||
|
|
||||||
Action loadDefaultMod = () => Game.RunAfterTick(() =>
|
Action loadDefaultMod = () =>
|
||||||
Game.InitializeMod(Game.Settings.Game.Mod, null));
|
Game.RunAfterTick(() => Game.InitializeMod(modId, null));
|
||||||
|
|
||||||
var cancelButton = installMusicContainer.GetOrNull<ButtonWidget>("CANCEL_BUTTON");
|
var cancelButton = installMusicContainer.GetOrNull<ButtonWidget>("BACK_BUTTON");
|
||||||
if (cancelButton != null)
|
if (cancelButton != null)
|
||||||
cancelButton.OnClick = loadDefaultMod;
|
cancelButton.OnClick = loadDefaultMod;
|
||||||
|
|
||||||
var copyFromDiscButton = installMusicContainer.GetOrNull<ButtonWidget>("COPY_FROM_CD_BUTTON");
|
var copyFromDiscButton = installMusicContainer.GetOrNull<ButtonWidget>("INSTALL_MUSIC_BUTTON");
|
||||||
if (copyFromDiscButton != null)
|
if (copyFromDiscButton != null)
|
||||||
{
|
{
|
||||||
copyFromDiscButton.OnClick = () =>
|
copyFromDiscButton.OnClick = () =>
|
||||||
{
|
{
|
||||||
Ui.OpenWindow("INSTALL_FROMCD_PANEL", new WidgetArgs() {
|
Ui.OpenWindow("INSTALL_FROMCD_PANEL", new WidgetArgs
|
||||||
|
{
|
||||||
{ "continueLoading", loadDefaultMod },
|
{ "continueLoading", loadDefaultMod },
|
||||||
|
{ "modId", modId }
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var downloadButton = installMusicContainer.GetOrNull<ButtonWidget>("DOWNLOAD_BUTTON");
|
var downloadButton = installMusicContainer.GetOrNull<ButtonWidget>("DOWNLOAD_MUSIC_BUTTON");
|
||||||
if (downloadButton != null)
|
if (downloadButton != null)
|
||||||
{
|
{
|
||||||
var installData = Game.ModData.Manifest.Get<ContentInstaller>();
|
var installData = ModMetadata.AllMods[modId].Content;
|
||||||
downloadButton.IsVisible = () => !string.IsNullOrEmpty(installData.MusicPackageMirrorList);
|
downloadButton.IsDisabled = () => string.IsNullOrEmpty(installData.MusicPackageMirrorList);
|
||||||
downloadButton.OnClick = () =>
|
downloadButton.OnClick = () =>
|
||||||
{
|
{
|
||||||
Ui.OpenWindow("INSTALL_DOWNLOAD_PANEL", new WidgetArgs() {
|
Ui.OpenWindow("INSTALL_DOWNLOAD_PANEL", new WidgetArgs
|
||||||
|
{
|
||||||
{ "afterInstall", loadDefaultMod },
|
{ "afterInstall", loadDefaultMod },
|
||||||
{ "mirrorListUrl", installData.MusicPackageMirrorList },
|
{ "mirrorListUrl", installData.MusicPackageMirrorList },
|
||||||
|
{ "modId", modId }
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ using System.Collections.Generic;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.FileSystem;
|
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
@@ -96,7 +95,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
modInstallStatus = new Cache<ModMetadata, bool>(IsModInstalled);
|
modInstallStatus = new Cache<ModMetadata, bool>(IsModInstalled);
|
||||||
|
|
||||||
ModMetadata initialMod = null;
|
ModMetadata initialMod;
|
||||||
ModMetadata.AllMods.TryGetValue(Game.Settings.Game.PreviousMod, out initialMod);
|
ModMetadata.AllMods.TryGetValue(Game.Settings.Game.PreviousMod, out initialMod);
|
||||||
SelectMod(initialMod != null && initialMod.Id != "modchooser" ? initialMod : ModMetadata.AllMods["ra"]);
|
SelectMod(initialMod != null && initialMod.Id != "modchooser" ? initialMod : ModMetadata.AllMods["ra"]);
|
||||||
|
|
||||||
|
|||||||
@@ -90,11 +90,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var installButton = widget.GetOrNull<ButtonWidget>("INSTALL_BUTTON");
|
var installButton = widget.GetOrNull<ButtonWidget>("INSTALL_BUTTON");
|
||||||
if (installButton != null)
|
if (installButton != null)
|
||||||
{
|
{
|
||||||
installButton.IsDisabled = () => world == null || world.Type != WorldType.Shellmap;
|
installButton.IsDisabled = () => world.Type != WorldType.Shellmap;
|
||||||
var args = new string[] { "Install.Music=true" };
|
var args = new[] { "installMusic={0}".F(Game.ModData.Manifest.Mod.Id) };
|
||||||
installButton.OnClick = () =>
|
installButton.OnClick = () =>
|
||||||
Game.RunAfterTick(() =>
|
Game.RunAfterTick(() => Game.InitializeMod("modchooser", new Arguments(args)));
|
||||||
Game.InitializeMod(Game.Settings.Game.Mod, new Arguments(args)));
|
|
||||||
|
|
||||||
var installData = Game.ModData.Manifest.Get<ContentInstaller>();
|
var installData = Game.ModData.Manifest.Get<ContentInstaller>();
|
||||||
installButton.IsVisible = () => modRules.InstalledMusic.ToArray().Length <= installData.ShippedSoundtracks;
|
installButton.IsVisible = () => modRules.InstalledMusic.ToArray().Length <= installData.ShippedSoundtracks;
|
||||||
|
|||||||
@@ -140,7 +140,6 @@ LoadScreen: CncLoadScreen
|
|||||||
|
|
||||||
ContentInstaller:
|
ContentInstaller:
|
||||||
TestFiles: ^Content/cnc/conquer.mix, ^Content/cnc/desert.mix, ^Content/cnc/sounds.mix, ^Content/cnc/speech.mix, ^Content/cnc/temperat.mix, ^Content/cnc/tempicnh.mix, ^Content/cnc/winter.mix
|
TestFiles: ^Content/cnc/conquer.mix, ^Content/cnc/desert.mix, ^Content/cnc/sounds.mix, ^Content/cnc/speech.mix, ^Content/cnc/temperat.mix, ^Content/cnc/tempicnh.mix, ^Content/cnc/winter.mix
|
||||||
MusicMenuWidget: INSTALL_MUSIC_PANEL
|
|
||||||
FilesToCopy: CONQUER.MIX, DESERT.MIX, SCORES.MIX, SOUNDS.MIX, TEMPERAT.MIX, WINTER.MIX
|
FilesToCopy: CONQUER.MIX, DESERT.MIX, SCORES.MIX, SOUNDS.MIX, TEMPERAT.MIX, WINTER.MIX
|
||||||
FilesToExtract: speech.mix, tempicnh.mix, transit.mix
|
FilesToExtract: speech.mix, tempicnh.mix, transit.mix
|
||||||
PackageMirrorList: http://www.openra.net/packages/cnc-mirrors.txt
|
PackageMirrorList: http://www.openra.net/packages/cnc-mirrors.txt
|
||||||
|
|||||||
@@ -123,7 +123,6 @@ LoadScreen: LogoStripeLoadScreen
|
|||||||
Text: Filling Crates..., Breeding Sandworms..., Fuelling carryalls..., Deploying harvesters..., Preparing 'thopters..., Summoning mentats...
|
Text: Filling Crates..., Breeding Sandworms..., Fuelling carryalls..., Deploying harvesters..., Preparing 'thopters..., Summoning mentats...
|
||||||
|
|
||||||
ContentInstaller:
|
ContentInstaller:
|
||||||
MusicMenuWidget: INSTALL_MUSIC_PANEL
|
|
||||||
# TODO: check if DATA.R8 is at 1.03 patch level with 4840 frames
|
# TODO: check if DATA.R8 is at 1.03 patch level with 4840 frames
|
||||||
TestFiles: ^Content/d2k/BLOXBASE.R8, ^Content/d2k/BLOXBAT.R8, ^Content/d2k/BLOXBGBS.R8, ^Content/d2k/BLOXICE.R8, ^Content/d2k/BLOXTREE.R8, ^Content/d2k/BLOXWAST.R8, ^Content/d2k/DATA.R8, ^Content/d2k/SOUND.RS
|
TestFiles: ^Content/d2k/BLOXBASE.R8, ^Content/d2k/BLOXBAT.R8, ^Content/d2k/BLOXBGBS.R8, ^Content/d2k/BLOXICE.R8, ^Content/d2k/BLOXTREE.R8, ^Content/d2k/BLOXWAST.R8, ^Content/d2k/DATA.R8, ^Content/d2k/SOUND.RS
|
||||||
PackageMirrorList: http://www.openra.net/packages/d2k-103-mirrors.txt
|
PackageMirrorList: http://www.openra.net/packages/d2k-103-mirrors.txt
|
||||||
|
|||||||
@@ -195,3 +195,68 @@ Container@INSTALL_FROMCD_PANEL:
|
|||||||
Font: Bold
|
Font: Bold
|
||||||
Key: escape
|
Key: escape
|
||||||
|
|
||||||
|
|
||||||
|
Container@INSTALL_MUSIC_PANEL:
|
||||||
|
Logic: InstallMusicLogic
|
||||||
|
X: (WINDOW_RIGHT - WIDTH)/2
|
||||||
|
Y: (WINDOW_BOTTOM - HEIGHT)/2
|
||||||
|
Width: 500
|
||||||
|
Height: 177
|
||||||
|
Children:
|
||||||
|
Background:
|
||||||
|
Width: PARENT_RIGHT
|
||||||
|
Height: PARENT_BOTTOM
|
||||||
|
Background: panel-bg
|
||||||
|
Background@RULE:
|
||||||
|
X: 30
|
||||||
|
Y: 50
|
||||||
|
Width: 440
|
||||||
|
Height:150
|
||||||
|
Background:panel-rule
|
||||||
|
Label@TITLE:
|
||||||
|
X: 0
|
||||||
|
Y: 12
|
||||||
|
Width: PARENT_RIGHT
|
||||||
|
Height: 25
|
||||||
|
Text: Install Music
|
||||||
|
Align: Center
|
||||||
|
Font: MediumBold
|
||||||
|
Label@DESC1:
|
||||||
|
X: 0
|
||||||
|
Y: 65
|
||||||
|
Width: PARENT_RIGHT
|
||||||
|
Height: 25
|
||||||
|
Text: OpenRA can download the music files from the internet (if available),
|
||||||
|
Align: Center
|
||||||
|
Label@DESC2:
|
||||||
|
X: 0
|
||||||
|
Y: 85
|
||||||
|
Width: PARENT_RIGHT
|
||||||
|
Height: 25
|
||||||
|
Text: or you can install them from an original CD.
|
||||||
|
Align: Center
|
||||||
|
Button@DOWNLOAD_MUSIC_BUTTON:
|
||||||
|
X: 20
|
||||||
|
Y: PARENT_BOTTOM - 52
|
||||||
|
Background:button-highlighted
|
||||||
|
Width: 110
|
||||||
|
Height: 32
|
||||||
|
Text: Download
|
||||||
|
Font: Bold
|
||||||
|
Button@INSTALL_MUSIC_BUTTON:
|
||||||
|
X: 140
|
||||||
|
Y: PARENT_BOTTOM - 52
|
||||||
|
Background:button-highlighted
|
||||||
|
Width: 110
|
||||||
|
Height: 32
|
||||||
|
Text: Use CD
|
||||||
|
Font: Bold
|
||||||
|
Button@BACK_BUTTON:
|
||||||
|
X: PARENT_RIGHT - 130
|
||||||
|
Y: PARENT_BOTTOM - 52
|
||||||
|
Background:button-highlighted
|
||||||
|
Width: 110
|
||||||
|
Height: 32
|
||||||
|
Text: Back
|
||||||
|
Font: Bold
|
||||||
|
Key: escape
|
||||||
|
|||||||
@@ -141,7 +141,6 @@ LoadScreen: LogoStripeLoadScreen
|
|||||||
Text: Filling Crates..., Charging Capacitors..., Reticulating Splines..., Planting Trees..., Building Bridges..., Aging Empires..., Compiling EVA..., Constructing Pylons..., Activating Skynet..., Splitting Atoms...
|
Text: Filling Crates..., Charging Capacitors..., Reticulating Splines..., Planting Trees..., Building Bridges..., Aging Empires..., Compiling EVA..., Constructing Pylons..., Activating Skynet..., Splitting Atoms...
|
||||||
|
|
||||||
ContentInstaller:
|
ContentInstaller:
|
||||||
MusicMenuWidget: INSTALL_MUSIC_PANEL
|
|
||||||
TestFiles: ^Content/ra/allies.mix, ^Content/ra/conquer.mix, ^Content/ra/interior.mix, ^Content/ra/redalert.mix, ^Content/ra/russian.mix, ^Content/ra/snow.mix, ^Content/ra/sounds.mix, ^Content/ra/temperat.mix
|
TestFiles: ^Content/ra/allies.mix, ^Content/ra/conquer.mix, ^Content/ra/interior.mix, ^Content/ra/redalert.mix, ^Content/ra/russian.mix, ^Content/ra/snow.mix, ^Content/ra/sounds.mix, ^Content/ra/temperat.mix
|
||||||
PackageMirrorList: http://www.openra.net/packages/ra-mirrors.txt
|
PackageMirrorList: http://www.openra.net/packages/ra-mirrors.txt
|
||||||
DiskTestFiles: MAIN.MIX, INSTALL/REDALERT.MIX
|
DiskTestFiles: MAIN.MIX, INSTALL/REDALERT.MIX
|
||||||
|
|||||||
@@ -189,7 +189,6 @@ LoadScreen: LogoStripeLoadScreen
|
|||||||
Text: Updating EVA installation..., Changing perspective...
|
Text: Updating EVA installation..., Changing perspective...
|
||||||
|
|
||||||
ContentInstaller:
|
ContentInstaller:
|
||||||
MusicMenuWidget: INSTALL_MUSIC_PANEL
|
|
||||||
TestFiles: ^Content/ts/cache.mix, ^Content/ts/conquer.mix, ^Content/ts/isosnow.mix, ^Content/ts/isotemp.mix, ^Content/ts/local.mix, ^Content/ts/sidec01.mix, ^Content/ts/sidec02.mix, ^Content/ts/sno.mix, ^Content/ts/snow.mix, ^Content/ts/sounds.mix, ^Content/ts/speech01.mix, ^Content/ts/tem.mix, ^Content/ts/temperat.mix
|
TestFiles: ^Content/ts/cache.mix, ^Content/ts/conquer.mix, ^Content/ts/isosnow.mix, ^Content/ts/isotemp.mix, ^Content/ts/local.mix, ^Content/ts/sidec01.mix, ^Content/ts/sidec02.mix, ^Content/ts/sno.mix, ^Content/ts/snow.mix, ^Content/ts/sounds.mix, ^Content/ts/speech01.mix, ^Content/ts/tem.mix, ^Content/ts/temperat.mix
|
||||||
PackageMirrorList: http://www.openra.net/packages/ts-mirrors.txt
|
PackageMirrorList: http://www.openra.net/packages/ts-mirrors.txt
|
||||||
DiskTestFiles: MULTI.MIX, INSTALL/TIBSUN.MIX
|
DiskTestFiles: MULTI.MIX, INSTALL/TIBSUN.MIX
|
||||||
|
|||||||
Reference in New Issue
Block a user