Move content mod switching to IFileSystemExternalContent interface.
This commit is contained in:
committed by
Gustas Kažukauskas
parent
8b8651dcf7
commit
79567f3f8a
@@ -65,5 +65,12 @@ namespace OpenRA.Mods.Common.FileSystem
|
||||
|
||||
return !isContentAvailable;
|
||||
}
|
||||
|
||||
void IFileSystemExternalContent.ManageContent(ModData modData)
|
||||
{
|
||||
// Switching mods changes the world state (by disposing it),
|
||||
// so we can't do this inside the input handler.
|
||||
Game.RunAfterTick(() => Game.InitializeMod(ContentInstallerMod, new Arguments()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace OpenRA.Mods.Common.FileSystem
|
||||
public interface IFileSystemExternalContent
|
||||
{
|
||||
bool InstallContentIfRequired(ModData modData);
|
||||
void ManageContent(ModData modData);
|
||||
}
|
||||
|
||||
public class DefaultFileSystemLoader : IFileSystemLoader
|
||||
|
||||
@@ -83,18 +83,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var contentButton = mainMenu.GetOrNull<ButtonWidget>("CONTENT_BUTTON");
|
||||
if (contentButton != null)
|
||||
{
|
||||
var contentInstaller = modData.FileSystemLoader as ContentInstallerFileSystemLoader;
|
||||
var contentInstaller = modData.FileSystemLoader as IFileSystemExternalContent;
|
||||
contentButton.Disabled = contentInstaller == null;
|
||||
contentButton.OnClick = () =>
|
||||
{
|
||||
// Switching mods changes the world state (by disposing it),
|
||||
// so we can't do this inside the input handler.
|
||||
Game.RunAfterTick(() =>
|
||||
{
|
||||
if (contentInstaller != null)
|
||||
Game.InitializeMod(contentInstaller.ContentInstallerMod, new Arguments());
|
||||
});
|
||||
};
|
||||
contentButton.OnClick = () => contentInstaller?.ManageContent(modData);
|
||||
}
|
||||
|
||||
mainMenu.Get<ButtonWidget>("SETTINGS_BUTTON").OnClick = () =>
|
||||
|
||||
Reference in New Issue
Block a user