diff --git a/.DS_Store b/.DS_Store index 695c426..89f4bc6 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Config/FilterPlugin.ini b/Config/FilterPlugin.ini new file mode 100644 index 0000000..d552da1 --- /dev/null +++ b/Config/FilterPlugin.ini @@ -0,0 +1,8 @@ +[FilterPlugin] +; This section lists additional files which will be packaged along with your plugin. Paths should be listed relative to the root plugin directory, and +; may include "...", "*", and "?" wildcards to match directories, files, and individual characters respectively. +; +; Examples: +; /README.txt +; /Extras/... +; /Binaries/ThirdParty/*.dll diff --git a/Content/.DS_Store b/Content/.DS_Store index 89033ac..5f22342 100644 Binary files a/Content/.DS_Store and b/Content/.DS_Store differ diff --git a/Openfort.uplugin b/Openfort.uplugin index 3c95e86..9aea0d5 100644 --- a/Openfort.uplugin +++ b/Openfort.uplugin @@ -15,16 +15,19 @@ "IsExperimentalVersion": true, "Installed": true, "EnabledByDefault": true, + "EngineVersion" : "5.4.0", "Modules": [ { "Name": "Openfort", "Type": "Runtime", - "LoadingPhase": "Default" + "LoadingPhase": "Default", + "WhitelistPlatforms": [ "Win64", "Mac", "IOS", "Android" ] }, { "Name": "OpenfortEditor", "Type": "Editor", - "LoadingPhase": "Default" + "LoadingPhase": "Default", + "WhitelistPlatforms": [ "Win64", "Mac", "IOS", "Android" ] } ], "Plugins": [ @@ -33,9 +36,8 @@ "Enabled": true }, { - "Name": "BLUI", - "Enabled": true, - "Optional": true + "Name": "OnlineSubsystem", + "Enabled": true } ] } \ No newline at end of file diff --git a/Source/.DS_Store b/Source/.DS_Store index a72f211..5db89c0 100644 Binary files a/Source/.DS_Store and b/Source/.DS_Store differ diff --git a/Source/Openfort/.DS_Store b/Source/Openfort/.DS_Store index a70f94b..5b269ab 100644 Binary files a/Source/Openfort/.DS_Store and b/Source/Openfort/.DS_Store differ diff --git a/Source/Openfort/.idea/.idea.Openfort.dir/.idea/.gitignore b/Source/Openfort/.idea/.idea.Openfort.dir/.idea/.gitignore new file mode 100644 index 0000000..4a556dc --- /dev/null +++ b/Source/Openfort/.idea/.idea.Openfort.dir/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/projectSettingsUpdater.xml +/modules.xml +/contentModel.xml +/.idea.Openfort.iml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/Source/Openfort/.idea/.idea.Openfort.dir/.idea/encodings.xml b/Source/Openfort/.idea/.idea.Openfort.dir/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/Source/Openfort/.idea/.idea.Openfort.dir/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Source/Openfort/.idea/.idea.Openfort.dir/.idea/indexLayout.xml b/Source/Openfort/.idea/.idea.Openfort.dir/.idea/indexLayout.xml new file mode 100644 index 0000000..f5a863a --- /dev/null +++ b/Source/Openfort/.idea/.idea.Openfort.dir/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Source/Openfort/Openfort.Build.cs b/Source/Openfort/Openfort.Build.cs index 5cea0e6..ec53325 100644 --- a/Source/Openfort/Openfort.Build.cs +++ b/Source/Openfort/Openfort.Build.cs @@ -10,10 +10,8 @@ public Openfort(ReadOnlyTargetRules Target) : base(Target) { PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; -#if UE_5_1_OR_LATER - IncludeOrderVersion = EngineIncludeOrderVersion.Latest; -#endif - + IncludeOrderVersion = EngineIncludeOrderVersion.Latest; + PublicIncludePaths.AddRange( new string[] { @@ -28,50 +26,35 @@ public Openfort(ReadOnlyTargetRules Target) : base(Target) // ... add other private include paths required here ... } ); - - + PublicDependencyModuleNames.AddRange( new string[] { "Core", + "CoreUObject", + "Engine", + "Slate", + "SlateCore", "JsonUtilities", - "HTTP" + "HTTP", + "UMG", + "OnlineSubsystem", + "WebBrowser", + "WebBrowserWidget" } ); - - + PrivateDependencyModuleNames.AddRange( new string[] { - "CoreUObject", - "Engine", - "Slate", - "SlateCore", + "EngineSettings", "Json", - "UMG", - "Projects", + "Projects" // ... add private dependencies that you statically link with here ... } ); -#if UE_5_0_OR_LATER - PublicDependencyModuleNames.Add("WebBrowserWidget"); - PrivateDependencyModuleNames.Add("WebBrowser"); - PublicDefinitions.Add("USING_BUNDLED_CEF=1"); - PublicDefinitions.Add("USING_BLUI_CEF=0"); -#else - if (Target.Platform == UnrealTargetPlatform.Win64) - { - PrivateDependencyModuleNames.Add("Blu"); - PublicDefinitions.Add("USING_BLUI_CEF=1"); - } - else - { - PublicDefinitions.Add("USING_BLUI_CEF=0"); - } - - PublicDefinitions.Add("USING_BUNDLED_CEF=0"); -#endif + PublicDefinitions.Add("USING_BUNDLED_CEF=1"); DynamicallyLoadedModuleNames.AddRange( new string[] diff --git a/Source/Openfort/Private/Openfort/Actions/OpenfortBlueprintAsyncAction.cpp b/Source/Openfort/Private/Openfort/Actions/OpenfortBlueprintAsyncAction.cpp index b7d47d9..68865c7 100644 --- a/Source/Openfort/Private/Openfort/Actions/OpenfortBlueprintAsyncAction.cpp +++ b/Source/Openfort/Private/Openfort/Actions/OpenfortBlueprintAsyncAction.cpp @@ -1,6 +1,9 @@ // Fill out your copyright notice in the Description page of Project Settings. #include "Openfort/Actions/OpenfortBlueprintAsyncAction.h" +#include "Engine/World.h" +#include "Engine/GameInstance.h" +#include "Openfort/OpenfortSubsystem.h" UOpenfortSubsystem *UOpenfortBlueprintAsyncAction::GetSubsystem() const { diff --git a/Source/Openfort/Private/Openfort/Actions/OpenfortOpenfortSDKAuthenticateAsyncAction.cpp b/Source/Openfort/Private/Openfort/Actions/OpenfortOpenfortSDKAuthenticateAsyncAction.cpp index 5077f55..f6ef77b 100644 --- a/Source/Openfort/Private/Openfort/Actions/OpenfortOpenfortSDKAuthenticateAsyncAction.cpp +++ b/Source/Openfort/Private/Openfort/Actions/OpenfortOpenfortSDKAuthenticateAsyncAction.cpp @@ -1,7 +1,6 @@ // Fill out your copyright notice in the Description page of Project Settings. #include "Openfort/Actions/OpenfortOpenfortSDKAuthenticateAsyncAction.h" - #include "Openfort/OpenfortOpenfortSDK.h" #include "Openfort/OpenfortSubsystem.h" #include "Openfort/Misc/OpenfortLogging.h" diff --git a/Source/Openfort/Private/Openfort/Actions/OpenfortOpenfortSDKExecuteTransactionAsyncAction.cpp b/Source/Openfort/Private/Openfort/Actions/OpenfortOpenfortSDKExecuteTransactionAsyncAction.cpp index d898575..8c245e9 100644 --- a/Source/Openfort/Private/Openfort/Actions/OpenfortOpenfortSDKExecuteTransactionAsyncAction.cpp +++ b/Source/Openfort/Private/Openfort/Actions/OpenfortOpenfortSDKExecuteTransactionAsyncAction.cpp @@ -58,8 +58,8 @@ void UOpenfortOpenfortSDKExecuteTransactionAsyncAction::OnHttpRequestComplete(FH if (FJsonSerializer::Deserialize(Reader, JsonObject) && JsonObject.IsValid()) { FString UserOperationHash, TransactionIntentId; - JsonObject->TryGetStringField("userOperationHash", UserOperationHash); - JsonObject->TryGetStringField("transactionIntentId", TransactionIntentId); + JsonObject->TryGetStringField(TEXT("userOperationHash"), UserOperationHash); + JsonObject->TryGetStringField(TEXT("transactionIntentId"), TransactionIntentId); TransactionSent.Broadcast(TEXT(""), TransactionIntentId, UserOperationHash); } diff --git a/Source/Openfort/Private/Openfort/OpenfortBlui.cpp b/Source/Openfort/Private/Openfort/OpenfortBlui.cpp deleted file mode 100644 index bfe9865..0000000 --- a/Source/Openfort/Private/Openfort/OpenfortBlui.cpp +++ /dev/null @@ -1,180 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#include "OpenfortBlui.h" -#include "Openfort/Assets/OpenfortSDKResource.h" -#include "Openfort/Misc/OpenfortLogging.h" -#include "Openfort/OpenfortJSConnector.h" -#include - -#if USING_BLUI_CEF -#include "BluEye.h" -#endif - -UOpenfortBlui::UOpenfortBlui() -{ - OPENFORT_LOG_FUNCSIG -#if USING_BLUI_CEF - if (!BluEyePtr) - { - OPENFORT_LOG("Creating BluEye") - BluEyePtr = NewObject(this, "BluEye"); - } -#endif - - JSConnector = NewObject(this, "JSConnector"); - JSConnector->ExecuteJs = UOpenfortJSConnector::FOnExecuteJsDelegate::CreateUObject(this, &UOpenfortBlui::ExecuteJS); -} - -#if USING_BLUI_CEF -UBluEye *UOpenfortBlui::GetBluEye() const { return Cast(BluEyePtr); } -#endif - -void UOpenfortBlui::OnLogEvent(const FString &LogText) -{ - OPENFORT_LOG_FUNC("LogEvent: %s", *LogText); -} - -void UOpenfortBlui::WorldTickStart(UWorld *World, ELevelTick LevelTick, float X) -{ -#if USING_BLUI_CEF - if (!GetBluEye()->IsBrowserLoading() && !bLoadedIndexJS) - { - const FSoftObjectPath AssetRef( - TEXT("/Script/Openfort.OpenfortSDKResource'/Openfort/PackagedResources/" - "index.index'")); - - OPENFORT_LOG("Browser loaded"); - bLoadedIndexJS = true; - if (UObject *LoadedAsset = AssetRef.TryLoad()) - { - if (const auto Resource = Cast(LoadedAsset)) - { - GetBluEye()->ExecuteJS(Resource->Js); - OPENFORT_VERBOSE("Loaded index.js") - } - else - { - OPENFORT_ERR("Error in loading index.js") - } - } - else - { - OPENFORT_ERR("Error in loading index.js") - } - } -#endif -} - -void UOpenfortBlui::BeginDestroy() -{ - OPENFORT_LOG_FUNCSIG -#if USING_BLUI_CEF - if (GetBluEye()) - { - GetBluEye()->CloseBrowser(); - } - BluEyePtr = nullptr; -#endif - Super::BeginDestroy(); -} - -void UOpenfortBlui::OnScriptEvent(const FString &EventName, const FString &EventMessage) -{ - OPENFORT_LOG_FUNC("EventName: %s, EventMessage: %s", *EventName, *EventMessage); - JSConnector->SendToGame(EventMessage); -} - -TWeakObjectPtr UOpenfortBlui::GetJSConnector() const -{ - return JSConnector; -} - -void UOpenfortBlui::ExecuteJS(const FString &ScriptText) const -{ -#if USING_BLUI_CEF - if (GetBluEye()) - { - GetBluEye()->ExecuteJS(ScriptText); - } -#endif -} - -void UOpenfortBlui::Init() -{ - OPENFORT_LOG_FUNCSIG - -#if USING_BLUI_CEF - // Todo: Add comment here why GetBluEye - UBluEye *BluEye = GetBluEye(); - - BluEye->LogEventEmitter.AddUniqueDynamic(this, &UOpenfortBlui::OnLogEvent); - BluEye->ScriptEventEmitter.AddUniqueDynamic(this, &UOpenfortBlui::OnScriptEvent); - - BluEye->bEnabled = true; - OPENFORT_LOG("Events subscribed") - - BluEye->Init(); - OPENFORT_LOG("BluEye Initialised") - - FSoftObjectPath AssetRef(TEXT("/Script/Openfort.OpenfortSDKResource'/Openfort/" - "PackagedResources/index.index'")); - if (UObject *LoadedAsset = AssetRef.TryLoad()) - { - if (auto Resource = Cast(LoadedAsset)) - { - // We're attempting to replicate the process that Unreal's WebBrowser - // widget uses to load a page from a string. Unfortunately this doesn't - // work correctly, but it still solves our issue. LocalStorage can't be - // accessed from about:blank or data URIs, so we still need to load a - // page. Despite this failing to load our custom html, this approach - // still allows us to access LocalStorage and use the game bridge. If - // there was more time in the future it would probably be worth - // investigating the issues here. - - // PostData - CefRefPtr PostData = CefPostData::Create(); - CefRefPtr Element = CefPostDataElement::Create(); - FTCHARToUTF8 UTF8String(TEXT( - "GameSDK " - "Bridge

Bridge Running

")); - Element->SetToBytes(UTF8String.Length(), UTF8String.Get()); - PostData->AddElement(Element); - - CefRequest::HeaderMap HeaderMap; - HeaderMap.insert(std::pair( - TCHAR_TO_WCHAR(TEXT("Content-Type")), "html")); - - const FString CustomContentMethod(TEXT("X-GET-CUSTOM-CONTENT")); - - const auto Request = CefRequest::Create(); - Request->Set("file:///Openfort/index.html", *CustomContentMethod, - PostData, HeaderMap); - - GetBluEye()->Browser->GetMainFrame()->LoadRequest(Request); - OPENFORT_VERBOSE("LoadRequest'ed for Index.html") - - WorldTickHandle = FWorldDelegates::OnWorldTickStart.AddUObject( - this, &UOpenfortBlui::WorldTickStart); - OPENFORT_LOG("Waiting for Browser to load..."); - } - } - else - { - OPENFORT_ERR("Failed to load Openfort bridge asset.") - } - - // Do this after the the page is given to the browser and being loaded... - JSConnector->Init(!BluEye->IsBrowserLoading()); -#endif -} - -#if USING_BLUI_CEF -void UOpenfortBlui::StopBluiEventLoop() -{ - if (UBluEye *BluEye = GetBluEye()) - { - BluEye->SetShouldTickEventLoop(false); - } -} -#endif diff --git a/Source/Openfort/Private/Openfort/OpenfortBlui.h b/Source/Openfort/Private/Openfort/OpenfortBlui.h deleted file mode 100644 index 697288e..0000000 --- a/Source/Openfort/Private/Openfort/OpenfortBlui.h +++ /dev/null @@ -1,52 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#pragma once - -#include "CoreMinimal.h" -#include "UObject/Object.h" -// clang-format off -#include "OpenfortBlui.generated.h" -// clang-format on - -/** - * - */ -UCLASS() -class OPENFORT_API UOpenfortBlui : public UObject -{ - GENERATED_BODY() - -public: - UOpenfortBlui(); - - UFUNCTION() - void OnScriptEvent(const FString &EventName, const FString &EventMessage); - TWeakObjectPtr GetJSConnector() const; - - UFUNCTION() - void OnLogEvent(const FString &LogText); - - virtual void BeginDestroy() override; - void Init(); - -#if USING_BLUI_CEF - void StopBluiEventLoop(); -#endif - -private: - UPROPERTY() - UObject *BluEyePtr = nullptr; - - bool bLoadedIndexJS = false; - void WorldTickStart(UWorld *World, ELevelTick LevelTick, float X); - - UPROPERTY() - class UOpenfortJSConnector *JSConnector = nullptr; - FDelegateHandle WorldTickHandle; - - void ExecuteJS(const FString &ScriptText) const; - -#if USING_BLUI_CEF - class UBluEye *GetBluEye() const; -#endif -}; diff --git a/Source/Openfort/Private/Openfort/OpenfortBrowserUserWidget.cpp b/Source/Openfort/Private/Openfort/OpenfortBrowserUserWidget.cpp index bbebd12..2abe62c 100644 --- a/Source/Openfort/Private/Openfort/OpenfortBrowserUserWidget.cpp +++ b/Source/Openfort/Private/Openfort/OpenfortBrowserUserWidget.cpp @@ -85,7 +85,7 @@ void UOpenfortBrowserUserWidget::OnWidgetRebuilt() Super::OnWidgetRebuilt(); } -TWeakObjectPtr UOpenfortBrowserUserWidget::GetJSConnector() const +TWeakObjectPtr UOpenfortBrowserUserWidget::GetJSConnector() const { if (!Browser) { diff --git a/Source/Openfort/Private/Openfort/OpenfortBrowserUserWidget.h b/Source/Openfort/Private/Openfort/OpenfortBrowserUserWidget.h index d09c211..c173903 100644 --- a/Source/Openfort/Private/Openfort/OpenfortBrowserUserWidget.h +++ b/Source/Openfort/Private/Openfort/OpenfortBrowserUserWidget.h @@ -6,6 +6,8 @@ #include "CoreMinimal.h" #include "OpenfortBrowserUserWidget.generated.h" +class UOpenfortJSConnector; + UCLASS() class OPENFORT_API UOpenfortBrowserUserWidget : public UUserWidget { @@ -17,7 +19,7 @@ class OPENFORT_API UOpenfortBrowserUserWidget : public UUserWidget virtual void RemoveFromParent() override; virtual void OnWidgetRebuilt() override; - TWeakObjectPtr GetJSConnector() const; + TWeakObjectPtr GetJSConnector() const; private: UPROPERTY() diff --git a/Source/Openfort/Private/Openfort/OpenfortBrowserWidget.cpp b/Source/Openfort/Private/Openfort/OpenfortBrowserWidget.cpp index e30d4f8..1a783c1 100644 --- a/Source/Openfort/Private/Openfort/OpenfortBrowserWidget.cpp +++ b/Source/Openfort/Private/Openfort/OpenfortBrowserWidget.cpp @@ -1,9 +1,10 @@ // Fill out your copyright notice in the Description page of Project Settings. #include "OpenfortBrowserWidget.h" - #include "Openfort/Misc/OpenfortLogging.h" #include "Openfort/OpenfortJSConnector.h" +#include "Widgets/Layout/SBox.h" +#include "Widgets/Text/STextBlock.h" #if USING_BUNDLED_CEF #include "SWebBrowser.h" #endif @@ -60,8 +61,9 @@ bool UOpenfortBrowserWidget::IsPageLoaded() const { #if USING_BUNDLED_CEF return WebBrowserWidget.IsValid() && WebBrowserWidget->IsLoaded(); -#endif +#else return false; +#endif } void UOpenfortBrowserWidget::ExecuteJS(const FString &ScriptText) const diff --git a/Source/Openfort/Private/Openfort/OpenfortBrowserWidget.h b/Source/Openfort/Private/Openfort/OpenfortBrowserWidget.h index a44fa6f..a59524a 100644 --- a/Source/Openfort/Private/Openfort/OpenfortBrowserWidget.h +++ b/Source/Openfort/Private/Openfort/OpenfortBrowserWidget.h @@ -7,21 +7,22 @@ #include "IWebBrowserWindow.h" #endif #include "Components/Widget.h" +#include "Widgets/SWidget.h" +#include "Runtime/Launch/Resources/Version.h" #include "OpenfortBrowserWidget.generated.h" +class UOpenfortJSConnector; + UCLASS() class OPENFORT_API UOpenfortBrowserWidget : public UWidget { GENERATED_BODY() - - friend class UOpenfortJSConnector; - public: // Sets default values for this actor's properties UOpenfortBrowserWidget(); // Get a pointer to the JSConnector - TWeakObjectPtr GetJSConnector() const; + TWeakObjectPtr GetJSConnector() const; bool IsPageLoaded() const; @@ -44,7 +45,7 @@ class OPENFORT_API UOpenfortBrowserWidget : public UWidget bool bShowInitialThrobber = false; UPROPERTY() - class UOpenfortJSConnector *JSConnector = nullptr; + UOpenfortJSConnector *JSConnector = nullptr; void SetBrowserContent(); diff --git a/Source/Openfort/Private/Openfort/OpenfortOpenfortSDK.cpp b/Source/Openfort/Private/Openfort/OpenfortOpenfortSDK.cpp index 89b2436..33c25b2 100644 --- a/Source/Openfort/Private/Openfort/OpenfortOpenfortSDK.cpp +++ b/Source/Openfort/Private/Openfort/OpenfortOpenfortSDK.cpp @@ -391,7 +391,8 @@ void UOpenfortOpenfortSDK::OnAuthenticateWithOAuthResponse(FOpenfortJSResponse R return; } FPoolOAuthRequest Data{InitOAuthFlowData->key}; - PoolOAuth(Data, ResponseDelegate); + + PoolOAuth(Data, ResponseDelegate.GetValue()); #endif } } diff --git a/Source/Openfort/Private/Openfort/OpenfortSubsystem.cpp b/Source/Openfort/Private/Openfort/OpenfortSubsystem.cpp index 6db7556..9e9bf18 100644 --- a/Source/Openfort/Private/Openfort/OpenfortSubsystem.cpp +++ b/Source/Openfort/Private/Openfort/OpenfortSubsystem.cpp @@ -1,23 +1,23 @@ // Fill out your copyright notice in the Description page of Project Settings. #include "Openfort/OpenfortSubsystem.h" - -#include "Engine/GameInstance.h" -#include "Blueprint/UserWidget.h" -#include "Openfort/OpenfortOpenfortSDK.h" -#include "Openfort/Misc/OpenfortLogging.h" -#include "OpenfortBlui.h" +#include +#include +#include +#include +#include #include "OpenfortBrowserUserWidget.h" +#include "Blueprint/UserWidget.h" +#include "Engine/GameInstance.h" +#include "Engine/GameViewportClient.h" #include "Openfort/OpenfortJSConnector.h" +#include "Openfort/OpenfortOpenfortSDK.h" #include "Openfort/Actions/OpenfortOpenfortSDKAuthenticateAsyncAction.h" +#include "Openfort/Actions/OpenfortOpenfortSDKAuthenticateWithThirdPartyProviderAsyncAction.h" #include "Openfort/Actions/OpenfortOpenfortSDKConfigureEmbeddedSignerAsyncAction.h" #include "Openfort/Actions/OpenfortOpenfortSDKExecuteTransactionAsyncAction.h" #include "Openfort/Actions/OpenfortOpenfortSDKGetAccessTokenAsyncAction.h" -#include -#include -#include -#include -#include +#include "Openfort/Misc/OpenfortLogging.h" UOpenfortSubsystem::UOpenfortSubsystem() { OPENFORT_LOG_FUNCSIG } @@ -48,12 +48,6 @@ void UOpenfortSubsystem::Deinitialize() OPENFORT_LOG_FUNCSIG BrowserWidget = nullptr; - -#if USING_BLUI_CEF - OpenfortBlui->ConditionalBeginDestroy(); - OpenfortBlui = nullptr; -#endif - OpenfortSDK = nullptr; #if PLATFORM_ANDROID | PLATFORM_IOS @@ -66,13 +60,14 @@ void UOpenfortSubsystem::Deinitialize() Super::Deinitialize(); } +TWeakObjectPtr UOpenfortSubsystem::GetOpenfortSDK() const +{ + return MakeWeakObjectPtr(OpenfortSDK); +} + // Template function should typically be in the header file, but if you keep it here: template -#if (ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1) void UOpenfortSubsystem::WhenReady(UserClass *Object, typename FOpenfortSubsystemReadyDelegate::FDelegate::TMethodPtr Func) -#else -void UOpenfortSubsystem::WhenReady(UserClass *Object, typename FOpenfortSubsystemReadyDelegate::FDelegate::TUObjectMethodDelegate::FMethodPtr Func) -#endif { OnReady.AddUObject(Object, Func); } @@ -125,11 +120,7 @@ void UOpenfortSubsystem::ManageBridgeDelegateQueue() { if (bIsReady) { -#if USING_BLUI_CEF - OnReady.Broadcast(OpenfortBlui->GetJSConnector()); -#else OnReady.Broadcast(BrowserWidget->GetJSConnector()); -#endif OnReady.Clear(); } } @@ -141,42 +132,7 @@ void UOpenfortSubsystem::SetupGameBridge() return; } bHasSetupGameBridge = true; - -#if USING_BLUI_CEF - // Create the Blui - if (!OpenfortBlui) - { - OpenfortBlui = NewObject(); - OpenfortBlui->Init(); - } - - if (!OpenfortBlui) - { - OPENFORT_ERR("Failed to create UOpenfortBlui") - return; - } - if (!OpenfortBlui->GetJSConnector().IsValid()) - { - OPENFORT_ERR("JSConnector not available, can't set up subsystem-ready event chain") - return; - } - - // Set up ready event chain - if (!IsReady()) - { - OpenfortBlui->GetJSConnector()->AddCallbackWhenBridgeReady( - UOpenfortJSConnector::FOnBridgeReadyDelegate::FDelegate::CreateUObject(this, &UOpenfortSubsystem::OnBridgeReady)); - } - - // Prepare OpenfortSDK - if (!OpenfortSDK) - { - OpenfortSDK = NewObject(this); - if (OpenfortSDK) - OpenfortSDK->Setup(OpenfortBlui->GetJSConnector()); - } - -#else + // Create the browser widget if (!BrowserWidget) { @@ -215,7 +171,6 @@ void UOpenfortSubsystem::SetupGameBridge() OpenfortSDK->Setup(BrowserWidget->GetJSConnector()); } } -#endif } void UOpenfortSubsystem::OnViewportCreated() diff --git a/Source/Openfort/Private/OpenfortModule.cpp b/Source/Openfort/Private/OpenfortModule.cpp index 4a181a2..fd5b707 100644 --- a/Source/Openfort/Private/OpenfortModule.cpp +++ b/Source/Openfort/Private/OpenfortModule.cpp @@ -17,17 +17,7 @@ void FOpenfortModule::StartupModule() { // This code will execute after your module is loaded into memory; the exact // timing is specified in the .uplugin file per-module - -#if USING_BLUI_CEF - if (IPluginManager::Get().FindPlugin("WebBrowserWidget") != nullptr && - IPluginManager::Get().FindPlugin("WebBrowserWidget")->IsEnabled()) - { - OPENFORT_ERR("Cannot enable both BLUI and WebBrowserWidget plugin at the same " - "time as it crashes. In Openfort.uplugin file, " - "'Plugins->WebBrowserWidget->Enabled' to 'false' and ensure the " - "WebBrowserWidget is disabled in your project to use BLUI.") - } -#endif + } void FOpenfortModule::ShutdownModule() diff --git a/Source/Openfort/Public/Openfort/OpenfortDataTypes.h b/Source/Openfort/Public/Openfort/OpenfortDataTypes.h index 442a55b..c3dd76b 100644 --- a/Source/Openfort/Public/Openfort/OpenfortDataTypes.h +++ b/Source/Openfort/Public/Openfort/OpenfortDataTypes.h @@ -2,8 +2,8 @@ #include "JsonObjectConverter.h" #include "Openfort/OpenfortJSMessages.h" +#include "Misc/EngineVersion.h" #include "Openfort/OpenfortNames.h" - #include "OpenfortDataTypes.generated.h" // This is the version of the Unreal Openfort SDK that is being used. This is not the version of the engine. @@ -83,7 +83,7 @@ struct OPENFORT_API FOpenfortOpenfortSDKInitData FString shieldUrl; UPROPERTY() - bool bShieldDebug; + bool bShieldDebug = false; UPROPERTY() FString backendUrl; @@ -167,7 +167,7 @@ struct OPENFORT_API FEvmTransactionReceipt UPROPERTY() FString gasUsed; - UPROPERTY(BlueprintReadOnly) + UPROPERTY(BlueprintReadOnly, Category="EvmTransactionReceiptLog") TArray logs; UPROPERTY() @@ -198,6 +198,6 @@ struct OPENFORT_API FTransactionIntentResponse UPROPERTY() FString id; - UPROPERTY(BlueprintReadOnly) + UPROPERTY(BlueprintReadOnly, Category="TransactionIntentResponse") FEvmTransactionReceipt response; }; diff --git a/Source/Openfort/Public/Openfort/OpenfortJSConnector.h b/Source/Openfort/Public/Openfort/OpenfortJSConnector.h index 5d2876f..c8c9cf3 100644 --- a/Source/Openfort/Public/Openfort/OpenfortJSConnector.h +++ b/Source/Openfort/Public/Openfort/OpenfortJSConnector.h @@ -50,7 +50,6 @@ class OPENFORT_API UOpenfortJSConnector : public UObject void SendToGame(FString Message); // Bind the func to be called for executing JS. Typically by the BrowserWidget - // (UE5) or Blui for UE4 FOnExecuteJsDelegate ExecuteJs; #if PLATFORM_ANDROID | PLATFORM_IOS diff --git a/Source/Openfort/Public/Openfort/OpenfortJSMessages.h b/Source/Openfort/Public/Openfort/OpenfortJSMessages.h index c382d31..7da65e6 100644 --- a/Source/Openfort/Public/Openfort/OpenfortJSMessages.h +++ b/Source/Openfort/Public/Openfort/OpenfortJSMessages.h @@ -106,8 +106,8 @@ struct OPENFORT_API FOpenfortJSResponse FString Error; if (JSResponse.JsonObject.IsValid()) { - JSResponse.JsonObject->TryGetNumberField("errorType", ErrType); - JSResponse.JsonObject->TryGetStringField("error", Error); + JSResponse.JsonObject->TryGetNumberField(TEXT("errorType"), ErrType); + JSResponse.JsonObject->TryGetStringField(TEXT("error"), Error); } JSResponse.Error = FOpenfortResponseError{static_cast(ErrType), Error}; } diff --git a/Source/Openfort/Public/Openfort/OpenfortOpenfortSDK.h b/Source/Openfort/Public/Openfort/OpenfortOpenfortSDK.h index 6f35f82..b71f81e 100644 --- a/Source/Openfort/Public/Openfort/OpenfortOpenfortSDK.h +++ b/Source/Openfort/Public/Openfort/OpenfortOpenfortSDK.h @@ -3,12 +3,12 @@ #include "CoreMinimal.h" #include "JsonObjectConverter.h" #include "Misc/EngineVersion.h" +#include "Engine/TimerHandle.h" #include "Runtime/Core/Public/HAL/Platform.h" #include "UObject/Object.h" #include "Openfort/OpenfortJSConnector.h" #include "Openfort/OpenfortDataTypes.h" #include "Openfort/OpenfortRequests.h" - #include "OpenfortOpenfortSDK.generated.h" template diff --git a/Source/Openfort/Public/Openfort/OpenfortRequests.h b/Source/Openfort/Public/Openfort/OpenfortRequests.h index c4eaf44..9c82f4b 100644 --- a/Source/Openfort/Public/Openfort/OpenfortRequests.h +++ b/Source/Openfort/Public/Openfort/OpenfortRequests.h @@ -1,6 +1,9 @@ #pragma once #include "CoreMinimal.h" #include "UObject/NoExportTypes.h" +#include "Serialization/JsonWriter.h" +#include "Serialization/JsonSerializer.h" +#include "Dom/JsonObject.h" #include "OpenfortRequests.generated.h" USTRUCT(BlueprintType) @@ -196,7 +199,8 @@ struct OPENFORT_API FInitLinkOAuthRequest UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Openfort") FOAuthInitRequestOptions Options; - FInitLinkOAuthRequest() {} + FInitLinkOAuthRequest(): Provider(){} + FInitLinkOAuthRequest(EOAuthProvider InProvider, const FString &InAuthToken, const FOAuthInitRequestOptions &InOptions) : Provider(InProvider), AuthToken(InAuthToken), Options(InOptions) {} }; @@ -464,7 +468,8 @@ struct OPENFORT_API FThirdPartyProviderRequest UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Openfort") ETokenType TokenType; - FThirdPartyProviderRequest() {} + FThirdPartyProviderRequest(): Provider(), TokenType(){} + FThirdPartyProviderRequest(EThirdPartyOAuthProvider InProvider, const FString &InToken, ETokenType InTokenType) : Provider(InProvider), Token(InToken), TokenType(InTokenType) {} }; @@ -608,7 +613,8 @@ struct OPENFORT_API FUnlinkOAuthRequest UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Openfort") FString AuthToken; - FUnlinkOAuthRequest() {} + FUnlinkOAuthRequest(): Provider(){} + FUnlinkOAuthRequest(EOAuthProvider InProvider, const FString &InAuthToken) : Provider(InProvider), AuthToken(InAuthToken) {} }; @@ -627,7 +633,8 @@ struct OPENFORT_API FOAuthInitRequest UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Openfort") bool bUsePooling; - FOAuthInitRequest() : bUsePooling(false) {} + FOAuthInitRequest() : Provider(), bUsePooling(false){} + FOAuthInitRequest(EOAuthProvider InProvider, const FOAuthInitRequestOptions &InOptions = FOAuthInitRequestOptions(), bool InUsePooling = false) : Provider(InProvider), Options(InOptions), bUsePooling(InUsePooling) {} }; @@ -683,7 +690,7 @@ struct OPENFORT_API FShieldAuthentication UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Openfort") FString TokenType; - FShieldAuthentication() {} + FShieldAuthentication(): Auth() {} FShieldAuthentication(EShieldAuthType InAuth, const FString &InToken, const FString &InAuthProvider = TEXT(""), const FString &InTokenType = TEXT("")) : Auth(InAuth), Token(InToken), AuthProvider(InAuthProvider), TokenType(InTokenType) {} @@ -703,7 +710,7 @@ struct OPENFORT_API FEmbeddedSignerRequest UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Openfort") FString RecoveryPassword; - FEmbeddedSignerRequest() {} + FEmbeddedSignerRequest(): ChainId(0){} FEmbeddedSignerRequest(int32 InChainId, const FShieldAuthentication &InShieldAuthentication, const FString &InRecoveryPassword = TEXT("")) : ChainId(InChainId), ShieldAuthentication(InShieldAuthentication), RecoveryPassword(InRecoveryPassword) {} diff --git a/Source/Openfort/Public/Openfort/OpenfortSubsystem.h b/Source/Openfort/Public/Openfort/OpenfortSubsystem.h index a2b55cc..1940633 100644 --- a/Source/Openfort/Public/Openfort/OpenfortSubsystem.h +++ b/Source/Openfort/Public/Openfort/OpenfortSubsystem.h @@ -4,11 +4,16 @@ #include "CoreMinimal.h" #include "Subsystems/GameInstanceSubsystem.h" +#include "Engine/EngineBaseTypes.h" +#include "Runtime/Launch/Resources/Version.h" // clang-format off #include "OpenfortSubsystem.generated.h" // clang-format on -DECLARE_MULTICAST_DELEGATE_OneParam(FOpenfortSubsystemReadyDelegate, TWeakObjectPtr); +class UOpenfortJSConnector; +class UOpenfortOpenfortSDK; + +DECLARE_MULTICAST_DELEGATE_OneParam(FOpenfortSubsystemReadyDelegate, TWeakObjectPtr); /** * @@ -24,10 +29,7 @@ class OPENFORT_API UOpenfortSubsystem : public UGameInstanceSubsystem virtual void Initialize(FSubsystemCollectionBase &Collection) override; virtual void Deinitialize() override; - TWeakObjectPtr GetOpenfortSDK() const - { - return MakeWeakObjectPtr(OpenfortSDK); - } + TWeakObjectPtr GetOpenfortSDK() const; bool IsReady() const { return bIsReady; } @@ -47,10 +49,7 @@ class OPENFORT_API UOpenfortSubsystem : public UGameInstanceSubsystem class UOpenfortBrowserUserWidget *BrowserWidget = nullptr; UPROPERTY() - class UOpenfortBlui *OpenfortBlui = nullptr; - - UPROPERTY() - class UOpenfortOpenfortSDK *OpenfortSDK = nullptr; + UOpenfortOpenfortSDK *OpenfortSDK = nullptr; bool bHasSetupGameBridge = false; bool bIsReady = false; diff --git a/Source/OpenfortEditor/.DS_Store b/Source/OpenfortEditor/.DS_Store index 2b8c8e9..a359204 100644 Binary files a/Source/OpenfortEditor/.DS_Store and b/Source/OpenfortEditor/.DS_Store differ diff --git a/Source/OpenfortEditor/.idea/.idea.OpenfortEditor.dir/.idea/.gitignore b/Source/OpenfortEditor/.idea/.idea.OpenfortEditor.dir/.idea/.gitignore new file mode 100644 index 0000000..3673b23 --- /dev/null +++ b/Source/OpenfortEditor/.idea/.idea.OpenfortEditor.dir/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/modules.xml +/projectSettingsUpdater.xml +/contentModel.xml +/.idea.OpenfortEditor.iml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/Source/OpenfortEditor/.idea/.idea.OpenfortEditor.dir/.idea/encodings.xml b/Source/OpenfortEditor/.idea/.idea.OpenfortEditor.dir/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/Source/OpenfortEditor/.idea/.idea.OpenfortEditor.dir/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Source/OpenfortEditor/.idea/.idea.OpenfortEditor.dir/.idea/indexLayout.xml b/Source/OpenfortEditor/.idea/.idea.OpenfortEditor.dir/.idea/indexLayout.xml new file mode 100644 index 0000000..f5a863a --- /dev/null +++ b/Source/OpenfortEditor/.idea/.idea.OpenfortEditor.dir/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Source/OpenfortEditor/OpenfortEditor.Build.cs b/Source/OpenfortEditor/OpenfortEditor.Build.cs index b8dd270..48192c5 100644 --- a/Source/OpenfortEditor/OpenfortEditor.Build.cs +++ b/Source/OpenfortEditor/OpenfortEditor.Build.cs @@ -8,9 +8,7 @@ public OpenfortEditor(ReadOnlyTargetRules Target) : base(Target) { PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; -#if UE_5_1_OR_LATER - IncludeOrderVersion = EngineIncludeOrderVersion.Latest; -#endif + IncludeOrderVersion = EngineIncludeOrderVersion.Latest; PublicIncludePaths.AddRange( new string[]