-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: the need to config immutable.uplugin to toggle on/off blui/webbrowserwidget when switching between 4.26+/5.1+ respectively (#3459) * fix: crash that happens when running with automated tests (#3331) * fix: ue 5.5 compile error
- Loading branch information
1 parent
62ac863
commit 41d7995
Showing
7 changed files
with
242 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,45 @@ | ||
{ | ||
"FileVersion": 3, | ||
"Version": 1, | ||
"VersionName": "1.3.0.alpha", | ||
"FriendlyName": "Immutable", | ||
"Description": "", | ||
"Category": "Other", | ||
"CreatedBy": "", | ||
"CreatedByURL": "", | ||
"DocsURL": "", | ||
"MarketplaceURL": "", | ||
"SupportURL": "", | ||
"CanContainContent": true, | ||
"IsBetaVersion": true, | ||
"IsExperimentalVersion": true, | ||
"Installed": true, | ||
"EnabledByDefault": true, | ||
"Modules": [ | ||
{ | ||
"Name": "Immutable", | ||
"Type": "Runtime", | ||
"LoadingPhase": "Default" | ||
}, | ||
{ | ||
"Name": "ImmutableEditor", | ||
"Type": "Editor", | ||
"LoadingPhase": "Default" | ||
}, | ||
{ | ||
"Name": "ImmutableOrderbook", | ||
"Type": "Runtime", | ||
"LoadingPhase": "Default" | ||
}, | ||
{ | ||
"Name": "ImmutablezkEVMAPI", | ||
"Type": "Runtime", | ||
"LoadingPhase": "Default" | ||
} | ||
], | ||
"Plugins": [ | ||
{ | ||
"Name": "WebBrowserWidget", | ||
"Enabled": true | ||
}, | ||
{ | ||
"Name": "BLUI", | ||
"Enabled": true, | ||
"Optional": true | ||
} | ||
] | ||
"FileVersion": 3, | ||
"Version": 1, | ||
"VersionName": "1.3.0.alpha", | ||
"FriendlyName": "Immutable", | ||
"Description": "", | ||
"Category": "Other", | ||
"CreatedBy": "", | ||
"CreatedByURL": "", | ||
"DocsURL": "", | ||
"MarketplaceURL": "", | ||
"SupportURL": "", | ||
"EnabledByDefault": true, | ||
"CanContainContent": true, | ||
"IsBetaVersion": true, | ||
"IsExperimentalVersion": true, | ||
"Installed": true, | ||
"Modules": [ | ||
{ | ||
"Name": "Immutable", | ||
"Type": "Runtime", | ||
"LoadingPhase": "Default" | ||
}, | ||
{ | ||
"Name": "ImmutableEditor", | ||
"Type": "Editor", | ||
"LoadingPhase": "Default" | ||
}, | ||
{ | ||
"Name": "ImmutablePluginManager", | ||
"Type": "Runtime", | ||
"LoadingPhase": "EarliestPossible" | ||
}, | ||
{ | ||
"Name": "ImmutableOrderbook", | ||
"Type": "Runtime", | ||
"LoadingPhase": "Default" | ||
}, | ||
{ | ||
"Name": "ImmutablezkEVMAPI", | ||
"Type": "Runtime", | ||
"LoadingPhase": "Default" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
Source/ImmutablePluginManager/ImmutablePluginManager.Build.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using UnrealBuildTool; | ||
|
||
/** | ||
* ImmutablePluginManager establishes the rules for this module. | ||
*/ | ||
public class ImmutablePluginManager : ModuleRules | ||
{ | ||
public ImmutablePluginManager(ReadOnlyTargetRules Target) : base(Target) | ||
{ | ||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; | ||
|
||
PublicDependencyModuleNames.AddRange(new string[] | ||
{ | ||
"Core", | ||
"CoreUObject", | ||
"Projects" | ||
}); | ||
} | ||
} |
129 changes: 129 additions & 0 deletions
129
Source/ImmutablePluginManager/Private/ImmutablePluginManager.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
#include "ImmutablePluginManager.h" | ||
|
||
#include "Interfaces/IPluginManager.h" | ||
#include "Misc/CoreDelegates.h" | ||
#include "Misc/MessageDialog.h" | ||
#include "Runtime/Launch/Resources/Version.h" | ||
|
||
#include "Runtime/Projects/Private/PluginManager.h" | ||
|
||
DEFINE_LOG_CATEGORY(LogImtblPluginManager); | ||
|
||
#define LOCTEXT_NAMESPACE "FImmutablePluginManagerModule" | ||
|
||
/** | ||
* ImmutablePluginManagerInternal manages the enabling/disabling of BLUI and WebBrowserWidget. | ||
*/ | ||
class FImmutablePluginManagerInternal | ||
{ | ||
public: | ||
FImmutablePluginManagerInternal() | ||
{ | ||
#if ENGINE_MAJOR_VERSION <= 4 | ||
FImmutablePluginManagerModule::EnablePlugin(TEXT("BLUI")); | ||
FImmutablePluginManagerModule::DisablePlugin(TEXT("WebBrowserWidget")); | ||
#else | ||
FImmutablePluginManagerModule::DisablePlugin(TEXT("BLUI")); | ||
FImmutablePluginManagerModule::EnablePlugin(TEXT("WebBrowserWidget")); | ||
#endif | ||
} | ||
}; | ||
|
||
TOptional<FImmutablePluginManagerInternal> GImmutablePluginManagerInternal(InPlace); | ||
|
||
void FImmutablePluginManagerModule::EnablePlugin(const FString& PluginName) | ||
{ | ||
TogglePlugin(PluginName, true); | ||
} | ||
|
||
void FImmutablePluginManagerModule::DisablePlugin(const FString& PluginName) | ||
{ | ||
TogglePlugin(PluginName, false); | ||
} | ||
|
||
void FImmutablePluginManagerModule::TogglePlugin(const FString& PluginName, bool bEnabled) | ||
{ | ||
UpdateImmutablePluginDescriptor_PluginDependency(PluginName, bEnabled); | ||
|
||
UpdatePluginManager(PluginName, bEnabled); | ||
} | ||
|
||
bool FImmutablePluginManagerModule::UpdateImmutablePluginDescriptor_PluginDependency(const FString& PluginName, bool bEnabled) | ||
{ | ||
bool bUpdateImmutablePluginDescriptor = false; | ||
|
||
IPluginManager& PluginManager = IPluginManager::Get(); | ||
|
||
TSharedPtr<IPlugin> ImmutablePlugin = PluginManager.FindPlugin("Immutable"); | ||
ensureAlways(ImmutablePlugin.IsValid()); | ||
|
||
FPluginDescriptor& ImmutablePluginDescriptor = const_cast<FPluginDescriptor&>(ImmutablePlugin->GetDescriptor()); | ||
|
||
FPluginReferenceDescriptor* PluginDependencyReferenceDescriptor = ImmutablePluginDescriptor.Plugins.FindByPredicate([PluginName](const FPluginReferenceDescriptor& Descriptor) | ||
{ | ||
return Descriptor.Name == PluginName; | ||
}); | ||
|
||
if (PluginDependencyReferenceDescriptor) | ||
{ | ||
if (PluginDependencyReferenceDescriptor->bEnabled != bEnabled) | ||
{ | ||
PluginDependencyReferenceDescriptor->bEnabled = bEnabled; | ||
|
||
bUpdateImmutablePluginDescriptor = true; | ||
} | ||
} | ||
else | ||
{ | ||
TSharedPtr<IPlugin> Plugin = IPluginManager::Get().FindPlugin(PluginName); | ||
|
||
if (ensureAlways(Plugin.IsValid())) | ||
{ | ||
ImmutablePluginDescriptor.Plugins.Add(FPluginReferenceDescriptor(Plugin->GetName(), bEnabled)); | ||
|
||
bUpdateImmutablePluginDescriptor = true; | ||
} | ||
} | ||
|
||
if (bUpdateImmutablePluginDescriptor) | ||
{ | ||
FText FailReason; | ||
const bool bUpdateDescriptor = ImmutablePlugin->UpdateDescriptor(ImmutablePluginDescriptor, FailReason); | ||
|
||
ensureAlways(bUpdateDescriptor); | ||
ensureAlways(FailReason.IsEmpty()); | ||
} | ||
|
||
return bUpdateImmutablePluginDescriptor; | ||
} | ||
|
||
void FImmutablePluginManagerModule::UpdatePluginManager(const FString& PluginName, bool bEnabled) | ||
{ | ||
IPluginManager& PluginManager = IPluginManager::Get(); | ||
TSharedPtr<IPlugin> PluginInterface = PluginManager.FindPlugin(PluginName); | ||
|
||
if (ensureAlways(PluginInterface.IsValid())) | ||
{ | ||
FPlugin* Plugin = reinterpret_cast<FPlugin*>(PluginInterface.Get()); | ||
|
||
if (ensureAlways(Plugin)) | ||
{ | ||
if (Plugin->bEnabled != bEnabled) | ||
{ | ||
Plugin->bEnabled = bEnabled; | ||
} | ||
} | ||
} | ||
} | ||
|
||
void FImmutablePluginManagerModule::StartupModule() | ||
{ | ||
} | ||
|
||
void FImmutablePluginManagerModule::ShutdownModule() | ||
{ | ||
} | ||
|
||
#undef LOCTEXT_NAMESPACE | ||
|
||
IMPLEMENT_MODULE(FImmutablePluginManagerModule, ImmutablePluginManager) |
25 changes: 25 additions & 0 deletions
25
Source/ImmutablePluginManager/Public/ImmutablePluginManager.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include "Modules/ModuleInterface.h" | ||
|
||
IMMUTABLEPLUGINMANAGER_API DECLARE_LOG_CATEGORY_EXTERN(LogImtblPluginManager, Log, All); | ||
|
||
/** | ||
* Plugin manager module that automatically switches between the BLUI and Epic's WebBrowserWidget plugins at build time. | ||
* This eliminates the need for developers to manually disable either plugin by editing the .uplugin file, streamlining the installation process. | ||
*/ | ||
class FImmutablePluginManagerModule : public IModuleInterface | ||
{ | ||
public: | ||
static void EnablePlugin(const FString& PluginName); | ||
static void DisablePlugin(const FString& PluginName); | ||
|
||
static void TogglePlugin(const FString& PluginName, bool bEnabled); | ||
|
||
static bool UpdateImmutablePluginDescriptor_PluginDependency(const FString& PluginName, bool bEnabled); | ||
static void UpdatePluginManager(const FString& PluginName, bool bEnabled); | ||
|
||
public: | ||
virtual void StartupModule() override; | ||
virtual void ShutdownModule() override; | ||
}; |