Skip to content

Commit 41d7995

Browse files
Getting CICD Online (#154)
* 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
1 parent 62ac863 commit 41d7995

File tree

7 files changed

+242
-59
lines changed

7 files changed

+242
-59
lines changed

Immutable.uplugin

Lines changed: 43 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,45 @@
11
{
2-
"FileVersion": 3,
3-
"Version": 1,
4-
"VersionName": "1.3.0.alpha",
5-
"FriendlyName": "Immutable",
6-
"Description": "",
7-
"Category": "Other",
8-
"CreatedBy": "",
9-
"CreatedByURL": "",
10-
"DocsURL": "",
11-
"MarketplaceURL": "",
12-
"SupportURL": "",
13-
"CanContainContent": true,
14-
"IsBetaVersion": true,
15-
"IsExperimentalVersion": true,
16-
"Installed": true,
17-
"EnabledByDefault": true,
18-
"Modules": [
19-
{
20-
"Name": "Immutable",
21-
"Type": "Runtime",
22-
"LoadingPhase": "Default"
23-
},
24-
{
25-
"Name": "ImmutableEditor",
26-
"Type": "Editor",
27-
"LoadingPhase": "Default"
28-
},
29-
{
30-
"Name": "ImmutableOrderbook",
31-
"Type": "Runtime",
32-
"LoadingPhase": "Default"
33-
},
34-
{
35-
"Name": "ImmutablezkEVMAPI",
36-
"Type": "Runtime",
37-
"LoadingPhase": "Default"
38-
}
39-
],
40-
"Plugins": [
41-
{
42-
"Name": "WebBrowserWidget",
43-
"Enabled": true
44-
},
45-
{
46-
"Name": "BLUI",
47-
"Enabled": true,
48-
"Optional": true
49-
}
50-
]
2+
"FileVersion": 3,
3+
"Version": 1,
4+
"VersionName": "1.3.0.alpha",
5+
"FriendlyName": "Immutable",
6+
"Description": "",
7+
"Category": "Other",
8+
"CreatedBy": "",
9+
"CreatedByURL": "",
10+
"DocsURL": "",
11+
"MarketplaceURL": "",
12+
"SupportURL": "",
13+
"EnabledByDefault": true,
14+
"CanContainContent": true,
15+
"IsBetaVersion": true,
16+
"IsExperimentalVersion": true,
17+
"Installed": true,
18+
"Modules": [
19+
{
20+
"Name": "Immutable",
21+
"Type": "Runtime",
22+
"LoadingPhase": "Default"
23+
},
24+
{
25+
"Name": "ImmutableEditor",
26+
"Type": "Editor",
27+
"LoadingPhase": "Default"
28+
},
29+
{
30+
"Name": "ImmutablePluginManager",
31+
"Type": "Runtime",
32+
"LoadingPhase": "EarliestPossible"
33+
},
34+
{
35+
"Name": "ImmutableOrderbook",
36+
"Type": "Runtime",
37+
"LoadingPhase": "Default"
38+
},
39+
{
40+
"Name": "ImmutablezkEVMAPI",
41+
"Type": "Runtime",
42+
"LoadingPhase": "Default"
43+
}
44+
]
5145
}

Source/Immutable/Immutable.Build.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,21 @@ public Immutable(ReadOnlyTargetRules Target) : base(Target)
3838
);
3939

4040
#if UE_5_0_OR_LATER
41-
PublicDependencyModuleNames.Add("WebBrowserWidget");
41+
PublicDependencyModuleNames.Add("WebBrowserWidget");
42+
#else
43+
if (Target.Platform == UnrealTargetPlatform.Win64)
44+
{
45+
PublicDependencyModuleNames.Add("Blu");
46+
}
47+
#endif
48+
49+
#if UE_5_0_OR_LATER
4250
PrivateDependencyModuleNames.Add("WebBrowser");
4351
PublicDefinitions.Add("USING_BUNDLED_CEF=1");
4452
PublicDefinitions.Add("USING_BLUI_CEF=0");
4553
#else
4654
if (Target.Platform == UnrealTargetPlatform.Win64)
4755
{
48-
PrivateDependencyModuleNames.Add("Blu");
4956
PublicDefinitions.Add("USING_BLUI_CEF=1");
5057
}
5158
else

Source/Immutable/Private/Immutable/ImtblBlui.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,18 @@ void UImtblBlui::OnLogEvent(const FString& LogText)
3535
void UImtblBlui::WorldTickStart(UWorld* World, ELevelTick LevelTick, float X)
3636
{
3737
#if USING_BLUI_CEF
38-
if (!GetBluEye()->IsBrowserLoading() && !bLoadedIndexJS)
38+
if (UBluEye* BluEye = GetBluEye())
3939
{
40-
FString JavaScript;
41-
42-
IMTBL_LOG("BLUI CEF Browser loaded");
43-
bLoadedIndexJS = true;
44-
if (FImmutableUtilities::LoadGameBridge(JavaScript))
40+
if (!BluEye->IsBrowserLoading() && !bLoadedIndexJS)
4541
{
46-
GetBluEye()->ExecuteJS(JavaScript);
42+
FString JavaScript;
43+
44+
IMTBL_LOG("BLUI CEF Browser loaded");
45+
bLoadedIndexJS = true;
46+
if (FImmutableUtilities::LoadGameBridge(JavaScript))
47+
{
48+
BluEye->ExecuteJS(JavaScript);
49+
}
4750
}
4851
}
4952
#endif

Source/Immutable/Private/Immutable/Tests/ImtblMessagesTest.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include "Containers/UnrealString.h"
44
#include "CoreTypes.h"
5+
#include "Runtime/Launch/Resources/Version.h"
6+
57
#include "Immutable/ImmutablePassport.h"
68

79
#include "Misc/AutomationTest.h"
@@ -15,7 +17,11 @@
1517

1618
#if WITH_DEV_AUTOMATION_TESTS
1719

18-
IMPLEMENT_SIMPLE_AUTOMATION_TEST(FImtblMessagesTest, "Immutable.JSMessages", EAutomationTestFlags::ApplicationContextMask | EAutomationTestFlags::ServerContext | EAutomationTestFlags::ProductFilter)
20+
#if ((ENGINE_MAJOR_VERSION <= 4) || (ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION <= 4))
21+
IMPLEMENT_SIMPLE_AUTOMATION_TEST(FImtblMessagesTest, "Immutable.JSMessages", EAutomationTestFlags::ApplicationContextMask | EAutomationTestFlags::EngineFilter)
22+
#else
23+
IMPLEMENT_SIMPLE_AUTOMATION_TEST(FImtblMessagesTest, "Immutable.JSMessages", EAutomationTestFlags_ApplicationContextMask | EAutomationTestFlags::EngineFilter)
24+
#endif
1925

2026
// EAutomationTestFlags::SmokeFilter -- note that SmokeFilter will run
2127
// automatically during cooking
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using UnrealBuildTool;
2+
3+
/**
4+
* ImmutablePluginManager establishes the rules for this module.
5+
*/
6+
public class ImmutablePluginManager : ModuleRules
7+
{
8+
public ImmutablePluginManager(ReadOnlyTargetRules Target) : base(Target)
9+
{
10+
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
11+
12+
PublicDependencyModuleNames.AddRange(new string[]
13+
{
14+
"Core",
15+
"CoreUObject",
16+
"Projects"
17+
});
18+
}
19+
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#include "ImmutablePluginManager.h"
2+
3+
#include "Interfaces/IPluginManager.h"
4+
#include "Misc/CoreDelegates.h"
5+
#include "Misc/MessageDialog.h"
6+
#include "Runtime/Launch/Resources/Version.h"
7+
8+
#include "Runtime/Projects/Private/PluginManager.h"
9+
10+
DEFINE_LOG_CATEGORY(LogImtblPluginManager);
11+
12+
#define LOCTEXT_NAMESPACE "FImmutablePluginManagerModule"
13+
14+
/**
15+
* ImmutablePluginManagerInternal manages the enabling/disabling of BLUI and WebBrowserWidget.
16+
*/
17+
class FImmutablePluginManagerInternal
18+
{
19+
public:
20+
FImmutablePluginManagerInternal()
21+
{
22+
#if ENGINE_MAJOR_VERSION <= 4
23+
FImmutablePluginManagerModule::EnablePlugin(TEXT("BLUI"));
24+
FImmutablePluginManagerModule::DisablePlugin(TEXT("WebBrowserWidget"));
25+
#else
26+
FImmutablePluginManagerModule::DisablePlugin(TEXT("BLUI"));
27+
FImmutablePluginManagerModule::EnablePlugin(TEXT("WebBrowserWidget"));
28+
#endif
29+
}
30+
};
31+
32+
TOptional<FImmutablePluginManagerInternal> GImmutablePluginManagerInternal(InPlace);
33+
34+
void FImmutablePluginManagerModule::EnablePlugin(const FString& PluginName)
35+
{
36+
TogglePlugin(PluginName, true);
37+
}
38+
39+
void FImmutablePluginManagerModule::DisablePlugin(const FString& PluginName)
40+
{
41+
TogglePlugin(PluginName, false);
42+
}
43+
44+
void FImmutablePluginManagerModule::TogglePlugin(const FString& PluginName, bool bEnabled)
45+
{
46+
UpdateImmutablePluginDescriptor_PluginDependency(PluginName, bEnabled);
47+
48+
UpdatePluginManager(PluginName, bEnabled);
49+
}
50+
51+
bool FImmutablePluginManagerModule::UpdateImmutablePluginDescriptor_PluginDependency(const FString& PluginName, bool bEnabled)
52+
{
53+
bool bUpdateImmutablePluginDescriptor = false;
54+
55+
IPluginManager& PluginManager = IPluginManager::Get();
56+
57+
TSharedPtr<IPlugin> ImmutablePlugin = PluginManager.FindPlugin("Immutable");
58+
ensureAlways(ImmutablePlugin.IsValid());
59+
60+
FPluginDescriptor& ImmutablePluginDescriptor = const_cast<FPluginDescriptor&>(ImmutablePlugin->GetDescriptor());
61+
62+
FPluginReferenceDescriptor* PluginDependencyReferenceDescriptor = ImmutablePluginDescriptor.Plugins.FindByPredicate([PluginName](const FPluginReferenceDescriptor& Descriptor)
63+
{
64+
return Descriptor.Name == PluginName;
65+
});
66+
67+
if (PluginDependencyReferenceDescriptor)
68+
{
69+
if (PluginDependencyReferenceDescriptor->bEnabled != bEnabled)
70+
{
71+
PluginDependencyReferenceDescriptor->bEnabled = bEnabled;
72+
73+
bUpdateImmutablePluginDescriptor = true;
74+
}
75+
}
76+
else
77+
{
78+
TSharedPtr<IPlugin> Plugin = IPluginManager::Get().FindPlugin(PluginName);
79+
80+
if (ensureAlways(Plugin.IsValid()))
81+
{
82+
ImmutablePluginDescriptor.Plugins.Add(FPluginReferenceDescriptor(Plugin->GetName(), bEnabled));
83+
84+
bUpdateImmutablePluginDescriptor = true;
85+
}
86+
}
87+
88+
if (bUpdateImmutablePluginDescriptor)
89+
{
90+
FText FailReason;
91+
const bool bUpdateDescriptor = ImmutablePlugin->UpdateDescriptor(ImmutablePluginDescriptor, FailReason);
92+
93+
ensureAlways(bUpdateDescriptor);
94+
ensureAlways(FailReason.IsEmpty());
95+
}
96+
97+
return bUpdateImmutablePluginDescriptor;
98+
}
99+
100+
void FImmutablePluginManagerModule::UpdatePluginManager(const FString& PluginName, bool bEnabled)
101+
{
102+
IPluginManager& PluginManager = IPluginManager::Get();
103+
TSharedPtr<IPlugin> PluginInterface = PluginManager.FindPlugin(PluginName);
104+
105+
if (ensureAlways(PluginInterface.IsValid()))
106+
{
107+
FPlugin* Plugin = reinterpret_cast<FPlugin*>(PluginInterface.Get());
108+
109+
if (ensureAlways(Plugin))
110+
{
111+
if (Plugin->bEnabled != bEnabled)
112+
{
113+
Plugin->bEnabled = bEnabled;
114+
}
115+
}
116+
}
117+
}
118+
119+
void FImmutablePluginManagerModule::StartupModule()
120+
{
121+
}
122+
123+
void FImmutablePluginManagerModule::ShutdownModule()
124+
{
125+
}
126+
127+
#undef LOCTEXT_NAMESPACE
128+
129+
IMPLEMENT_MODULE(FImmutablePluginManagerModule, ImmutablePluginManager)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#pragma once
2+
3+
#include "Modules/ModuleInterface.h"
4+
5+
IMMUTABLEPLUGINMANAGER_API DECLARE_LOG_CATEGORY_EXTERN(LogImtblPluginManager, Log, All);
6+
7+
/**
8+
* Plugin manager module that automatically switches between the BLUI and Epic's WebBrowserWidget plugins at build time.
9+
* This eliminates the need for developers to manually disable either plugin by editing the .uplugin file, streamlining the installation process.
10+
*/
11+
class FImmutablePluginManagerModule : public IModuleInterface
12+
{
13+
public:
14+
static void EnablePlugin(const FString& PluginName);
15+
static void DisablePlugin(const FString& PluginName);
16+
17+
static void TogglePlugin(const FString& PluginName, bool bEnabled);
18+
19+
static bool UpdateImmutablePluginDescriptor_PluginDependency(const FString& PluginName, bool bEnabled);
20+
static void UpdatePluginManager(const FString& PluginName, bool bEnabled);
21+
22+
public:
23+
virtual void StartupModule() override;
24+
virtual void ShutdownModule() override;
25+
};

0 commit comments

Comments
 (0)