diff --git a/BLUI.uplugin b/BLUI.uplugin index e0bc49b..262b9d3 100644 --- a/BLUI.uplugin +++ b/BLUI.uplugin @@ -1,28 +1,28 @@ { - "FileVersion": 3, - "FriendlyName": "BLUI", - "Version": 3, - "VersionName": "3.2.4", - "Description": "Chromium Embedded Framework (CEF) powered HTML UI and HUD for Unreal Engine 4", - "Category": "UI", - "CreatedBy": "Aaron M. Shea", - "CreatedByURL": "http://aaronshea.me", - "DocsURL": "https://github.com/getnamo/BLUI", - "EnabledByDefault" : true, - "CanContainContent": "true", - "Modules": - [ - { - "Name" : "BluLoader", - "Type" : "Runtime", - "LoadingPhase" : "PreDefault", - "BlacklistPlatforms" : [ "HTML5", "Android", "iOS"] - }, - { - "Name": "Blu", - "Type": "Runtime", - "LoadingPhase": "PreDefault", - "BlacklistPlatforms": [ "HTML5", "Android", "iOS" ] - } - ] + "FileVersion": 3, + "FriendlyName": "BLUI", + "Version": 3, + "VersionName": "4.2.0", + "Description": "Chromium Embedded Framework (CEF) powered HTML UI and HUD for Unreal Engine 4", + "Category": "UI", + "CreatedBy": "Aaron M. Shea, Getnamo, & Contributors", + "CreatedByURL": "github.com/aaronShea", + "DocsURL": "https://github.com/getnamo/BLUI", + "EnabledByDefault" : true, + "CanContainContent": "true", + "Modules": + [ + { + "Name" : "BluLoader", + "Type" : "Runtime", + "LoadingPhase" : "PreDefault", + "BlacklistPlatforms" : ["Android", "iOS"] + }, + { + "Name": "Blu", + "Type": "Runtime", + "LoadingPhase": "PreDefault", + "BlacklistPlatforms": ["Android", "iOS" ] + } + ] } diff --git a/Content/BluTickActor.uasset b/Content/BluTickActor.uasset deleted file mode 100644 index f620cff..0000000 Binary files a/Content/BluTickActor.uasset and /dev/null differ diff --git a/Content/BluiWidget.uasset b/Content/BluiWidget.uasset index 4fb109c..a5470bf 100644 Binary files a/Content/BluiWidget.uasset and b/Content/BluiWidget.uasset differ diff --git a/Content/BluiWorldWidgetActorExample.uasset b/Content/BluiWorldWidgetActorExample.uasset index 01f1043..0c4765a 100644 Binary files a/Content/BluiWorldWidgetActorExample.uasset and b/Content/BluiWorldWidgetActorExample.uasset differ diff --git a/Content/InteractableBluiWidgetActor.uasset b/Content/InteractableBluiWidgetActor.uasset new file mode 100644 index 0000000..8b4e052 Binary files /dev/null and b/Content/InteractableBluiWidgetActor.uasset differ diff --git a/LICENSE b/LICENSE index 64e9bae..6a308b6 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ The MIT License (MIT) Copyright (c) 2014 Aaron M. Shea (AaronShea) +Copyright (c) 2016-present, Jan Kaniewski (Getnamo) & Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,4 +19,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +THE SOFTWARE. diff --git a/README.md b/README.md index af3872f..1d67f2d 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,16 @@ [![release](https://img.shields.io/github/release/getnamo/BLUI.svg?style=flat-square)](https://github.com/getnamo/BLUI/releases) ![BLUI-logo](https://cloud.githubusercontent.com/assets/1334174/5969395/201a1202-a7f1-11e4-98a4-12bc6793f830.png) +[![Github All Releases](https://img.shields.io/github/downloads/getnamo/BLUI/total.svg)](https://github.com/getnamo/BLUI/releases) ## Getnamo Fork Notes -Fork made to support small additions and changes for certain use cases. +A fork of BLUI that is kept relatively up to date. -To install check out the latest releases https://github.com/getnamo/BLUI/releases and drag and drop *Plugins* folder into your project root folder - -### Download and Fullscreen Support +Latest release is updated to [CEF 80.0.3987.132](https://github.com/chromiumembedded/cef/tree/3987). -Contains changes to allow downloading of files via the inbuilt browser. +To install check out the latest releases https://github.com/getnamo/BLUI/releases and drag and drop *Plugins* folder into your project root folder -Updated CEF build to 3.2556 to support fullscreen videos. +Unreal thread: https://forums.unrealengine.com/community/released-projects/29036-blui-open-source-html5-js-css-hud-ui ### Convenience Blueprints @@ -63,16 +62,21 @@ By default the actor has a BLUI resolution of 1000x1000, you can change this by ### BluTickActor +Since 4.0.0 - This actor is no longer needed. Ticking happens internally. + +Older verions: Instead of ticking in your level bp, I prefer to use a simple actor to do the ticking. Other convenience blueprints may spawn this as necessary so if you use those, you don't ever need to use this directly. -## //End Fork Notes +## Demo Project + +Thanks to @oivio we have the Demo project updated to the latest release. See https://github.com/getnamo/BLUI/releases/tag/3.4.0 for the 4.22 Demo project release ([BLUI-v3.4.0-UE4.22-DemoExamples.7z](https://github.com/getnamo/BLUI/releases/download/3.4.0/BLUI-v3.4.0-UE4.22-DemoExamples.7z)) -## HTML powered UI and HUD for Unreal Engine 4 -(Hit up the wiki for a quick start guide!) +### Video of Demo project -Do you use BLUI in your project? I'd really love it if you credit me and it! You can even use the [logo right here!](https://res.cloudinary.com/aaronshea/image/upload/v1423576170/BLUI-Transparent_eu582n.png) +[![Demo Project](https://img.youtube.com/vi/PRxO0yCO3Kk/0.jpg)](https://youtu.be/PRxO0yCO3Kk) + +Click on image to take you to video. -License: MIT What is it? --------------------------------------- @@ -97,21 +101,14 @@ Re-generate your project's Visual Studio file and load up the editor. Then check Updating the CEF event loop --------------------------------------- -~~You must call the `BluManager::doBluMessageLoop();` method every tick in order for the CEF process to update properly. To do this, override the default GameMode's Tick function and include the `Blu/Public/BluManager.h` header file. You can then call the appropriate method.~~ - -As of now, you no longer need to do this. You can simply call a blueprint node to Tick the CEF loop every tick of the level blueprint. +Some actor or level blueprint needs to call [RunBluEventLoop](https://github.com/getnamo/BLUI/blob/master/Source/Blu/Public/BluBlueprintFunctionLibrary.h#L18). Loading Local Files --------------------------------------- -Set your default URL or use the "Load URL" node/method to load a URL that starts with `blui://` this will point to the directory root of the project or the game (if packaged). So if you wanted to load an HTML file from `YourProject/UI/file.html`, set the URL to `blui://UI/file.html` +Set your default URL or use the "Load URL" node/method to load a URL that starts with `blui://` (or `local://`) this will point to the directory root of the project or the game (if packaged). So if you wanted to load an HTML file from `YourProject/UI/file.html`, set the URL to `blui://UI/file.html` HUD Example Blueprint --------------------------------------- Within the release, you'll find an ExampleHUD blueprint file, place this into your project's blueprints directory to try it out! (It's a simple UMG widget pre-configures to accept keyboard and mouse input, with a BluEye instance hooked up to a canvas) - - -Shipping Your Game (Linux) ---------------------------------------- -Copy all contents of the Linux shipping files into your packaged game's `GameName/Binaries/{Linux}`, these are the required files for the Chromium process. diff --git a/Source/Blu/Blu.Build.cs b/Source/Blu/Blu.Build.cs index b8d9112..d2fa044 100644 --- a/Source/Blu/Blu.Build.cs +++ b/Source/Blu/Blu.Build.cs @@ -11,35 +11,33 @@ private string ThirdPartyPath get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "../../ThirdParty/")); } } - private void stageFiles(String[] filesToStage) + private void stageFiles(String[] FilesToStage) { - foreach (var f in filesToStage) + foreach (var File in FilesToStage) { - RuntimeDependencies.Add(new RuntimeDependency(f)); + RuntimeDependencies.Add(File); } } public Blu(ReadOnlyTargetRules Target) : base(Target) { - - PublicDependencyModuleNames.AddRange( - new string[] - { - "Core", - "CoreUObject", - "Engine", - "InputCore", - "RenderCore", - "RHI", - "Slate", - "SlateCore", - "UMG", - "Json" - }); + PublicDependencyModuleNames.AddRange( + new string[] { + "Core", + "CoreUObject", + "Engine", + "InputCore", + "RenderCore", + "RHI", + "Slate", + "SlateCore", + "UMG", + "Json" + }); PrivateIncludePaths.AddRange( new string[] { - "Blu/Private", + Path.Combine(ModuleDirectory, "Private"), }); if(Target.Platform == UnrealTargetPlatform.Win64) @@ -61,8 +59,8 @@ public Blu(ReadOnlyTargetRules Target) : base(Target) }); // Add our runtime dependencies - var filesToStage = Directory.GetFiles(Path.Combine(ThirdPartyPath, "cef/Win/shipping"), "*", SearchOption.AllDirectories); - stageFiles(filesToStage); + var FilesToStage = Directory.GetFiles(Path.Combine(ThirdPartyPath, "cef/Win/shipping"), "*", SearchOption.AllDirectories); + stageFiles(FilesToStage); } else if(Target.Platform == UnrealTargetPlatform.Linux) { @@ -78,9 +76,9 @@ public Blu(ReadOnlyTargetRules Target) : base(Target) } else if(Target.Platform == UnrealTargetPlatform.Mac) { - var frameworkPath = Path.Combine(ThirdPartyPath, "cef/Mac/lib", "Chromium Embedded Framework.framework"); + var FrameworkPath = Path.Combine(ThirdPartyPath, "cef/Mac/lib", "Chromium Embedded Framework.framework"); - PublicFrameworks.Add(frameworkPath); + PublicFrameworks.Add(FrameworkPath); PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "cef/Mac/lib", "libcef_dll_wrapper.a")); PublicIncludePaths.AddRange( @@ -88,17 +86,16 @@ public Blu(ReadOnlyTargetRules Target) : base(Target) Path.Combine(ThirdPartyPath, "cef", "Mac") }); - var filesToStage = Directory.GetFiles(Path.Combine(ThirdPartyPath, "cef/Mac/shipping"), "*", SearchOption.AllDirectories); - stageFiles(filesToStage); + var FilesToStage = Directory.GetFiles(Path.Combine(ThirdPartyPath, "cef/Mac/shipping"), "*", SearchOption.AllDirectories); + stageFiles(FilesToStage); - filesToStage = Directory.GetFiles(Path.Combine(ThirdPartyPath, "cef/Mac/lib"), "*", SearchOption.AllDirectories); - stageFiles(filesToStage); + FilesToStage = Directory.GetFiles(Path.Combine(ThirdPartyPath, "cef/Mac/lib"), "*", SearchOption.AllDirectories); + stageFiles(FilesToStage); if(!Target.bBuildEditor) { - AdditionalBundleResources.Add(new UEBuildBundleResource(Path.Combine(frameworkPath, "Chromium Embedded Framework"), "MacOS", false)); + AdditionalBundleResources.Add(new BundleResource(Path.Combine(FrameworkPath, "Chromium Embedded Framework"), "MacOS", false)); } - } else { diff --git a/Source/Blu/Private/Blu.cpp b/Source/Blu/Private/Blu.cpp index 17d8839..7e3c9cb 100644 --- a/Source/Blu/Private/Blu.cpp +++ b/Source/Blu/Private/Blu.cpp @@ -1,4 +1,5 @@ -#include "BluPrivatePCH.h" +#include "IBlu.h" +#include "BluManager.h" class FBlu : public IBlu { @@ -10,9 +11,10 @@ class FBlu : public IBlu FString ExecutablePath = FPaths::ConvertRelativePathToFull(FPaths::ProjectDir() + "Plugins/BLUI/ThirdParty/cef/"); // Setup the default settings for BluManager - BluManager::settings.windowless_rendering_enabled = true; - BluManager::settings.no_sandbox = true; - BluManager::settings.remote_debugging_port = 7777; + BluManager::Settings.windowless_rendering_enabled = true; + BluManager::Settings.no_sandbox = true; + BluManager::Settings.remote_debugging_port = 7777; + BluManager::Settings.uncaught_exception_stack_size = 5; #if PLATFORM_LINUX ExecutablePath = "./blu_ue4_process"; @@ -27,16 +29,16 @@ class FBlu : public IBlu CefString realExePath = *ExecutablePath; // Set the sub-process path - CefString(&BluManager::settings.browser_subprocess_path).FromString(realExePath); + CefString(&BluManager::Settings.browser_subprocess_path).FromString(realExePath); // Set the cache path - CefString(&BluManager::settings.cache_path).FromString(GameDirCef); + CefString(&BluManager::Settings.cache_path).FromString(GameDirCef); // Make a new manager instance CefRefPtr BluApp = new BluManager(); //CefExecuteProcess(BluManager::main_args, BluApp, NULL); - CefInitialize(BluManager::main_args, BluManager::settings, BluApp, NULL); + CefInitialize(BluManager::MainArgs, BluManager::Settings, BluApp, NULL); UE_LOG(LogBlu, Log, TEXT(" STATUS: Loaded")); } @@ -44,7 +46,7 @@ class FBlu : public IBlu virtual void ShutdownModule() override { UE_LOG(LogBlu, Log, TEXT(" STATUS: Shutdown")); - CefShutdown(); + //CefShutdown(); } }; diff --git a/Source/Blu/Private/BluBluprintFunctionLibrary.cpp b/Source/Blu/Private/BluBluprintFunctionLibrary.cpp index 7b9a433..a358af0 100644 --- a/Source/Blu/Private/BluBluprintFunctionLibrary.cpp +++ b/Source/Blu/Private/BluBluprintFunctionLibrary.cpp @@ -1,6 +1,6 @@ -#include "BluPrivatePCH.h" -#include "BluManager.h" -#include "Json.h" +#include "BluBlueprintFunctionLibrary.h" +#include "BluJsonObj.h" + UBluBlueprintFunctionLibrary::UBluBlueprintFunctionLibrary(const class FObjectInitializer& PCIP) : Super(PCIP) @@ -12,34 +12,34 @@ UBluEye* UBluBlueprintFunctionLibrary::NewBluEye(UObject* WorldContextObject) { UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); - UBluEye* tempObject = Cast(StaticConstructObject_Internal(UBluEye::StaticClass())); + UBluEye* Eye = NewObject(WorldContextObject); - return tempObject; + return Eye; } UBluJsonObj* UBluBlueprintFunctionLibrary::NewBluJSONObj(UObject* WorldContextObject) { - UBluJsonObj* tempObj = NewObject(GetTransientPackage(), UBluJsonObj::StaticClass()); - tempObj->init("{}"); + UBluJsonObj* JsonObj = NewObject(GetTransientPackage(), UBluJsonObj::StaticClass()); + JsonObj->Init("{}"); - return tempObj; + return JsonObj; } void UBluBlueprintFunctionLibrary::RunBluEventLoop() { - BluManager::doBluMessageLoop(); + BluManager::DoBluMessageLoop(); } UBluJsonObj* UBluBlueprintFunctionLibrary::ParseJSON(const FString& JSONString) { - UBluJsonObj* tempObj = NewObject(GetTransientPackage(), UBluJsonObj::StaticClass()); - tempObj->init(JSONString); + UBluJsonObj* JsonObj = NewObject(GetTransientPackage(), UBluJsonObj::StaticClass()); + JsonObj->Init(JSONString); - return tempObj; + return JsonObj; } @@ -47,16 +47,26 @@ FString UBluBlueprintFunctionLibrary::JSONToString(UBluJsonObj *ObjectToParse) { // Create the JSON reader - FString returnString; - TSharedRef> writer = TJsonWriterFactory::Create(&returnString); + FString ReturnString; + TSharedRef> writer = TJsonWriterFactory::Create(&ReturnString); // Convert the JSON object to an FString - FJsonSerializer::Serialize(ObjectToParse->getJsonObj().ToSharedRef(), writer); + FJsonSerializer::Serialize(ObjectToParse->GetJsonObj().ToSharedRef(), writer); - return returnString; + return ReturnString; } +FCharacterEvent UBluBlueprintFunctionLibrary::ToKeyEvent(FKey Key) +{ + FModifierKeysState KeyState; + + FCharacterEvent CharEvent = FCharacterEvent(Key.GetFName().ToString().ToUpper().GetCharArray()[0], KeyState, 0, 0); + + return CharEvent; +} + + FString UBluBlueprintFunctionLibrary::GameRootDirectory() { diff --git a/Source/Blu/Private/BluEye.cpp b/Source/Blu/Private/BluEye.cpp index 8085120..2adcd0f 100644 --- a/Source/Blu/Private/BluEye.cpp +++ b/Source/Blu/Private/BluEye.cpp @@ -1,27 +1,36 @@ -#include "BluPrivatePCH.h" + +#include "BluEye.h" #include "RenderHandler.h" -UBluEye::UBluEye(const class FObjectInitializer& PCIP) - : Super(PCIP) +FTickEventLoopData UBluEye::EventLoopData = FTickEventLoopData(); + +FBluEyeSettings::FBluEyeSettings() { - Texture = nullptr; + FrameRate = 60.f; - Width = 800; - Height = 600; + Width = 1280; + Height = 720; bIsTransparent = false; - bEnableWebGL = false; + bEnableWebGL = true; + bAudioMuted = false; + bAutoPlayEnabled = true; +} +UBluEye::UBluEye(const class FObjectInitializer& PCIP) + : Super(PCIP) +{ + Texture = nullptr; + bValidTexture = false; } -void UBluEye::init() +void UBluEye::Init() { /** * We don't want this running in editor unless it's PIE - * If we don't check this, CEF will spawn infinit processes with widget components + * If we don't check this, CEF will spawn infinite processes with widget components **/ - Texture = nullptr; if (GEngine) { @@ -32,46 +41,64 @@ void UBluEye::init() } } - if (Width <= 0 || Height <= 0) + if (Settings.Width <= 0 || Settings.Height <= 0) { UE_LOG(LogBlu, Log, TEXT("Can't initialize when Width or Height are <= 0")); return; } - browserSettings.universal_access_from_file_urls = STATE_ENABLED; - browserSettings.file_access_from_file_urls = STATE_ENABLED; + BrowserSettings.universal_access_from_file_urls = STATE_ENABLED; + BrowserSettings.file_access_from_file_urls = STATE_ENABLED; - info.width = Width; - info.height = Height; + //BrowserSettings.web_security = STATE_DISABLED; + //BrowserSettings.fullscreen_enabled = true; + + Info.width = Settings.Width; + Info.height = Settings.Height; // Set transparant option - info.SetAsWindowless(0, bIsTransparent); + Info.SetAsWindowless(0); //bIsTransparent // Figure out if we want to turn on WebGL support - if (bEnableWebGL) + if (Settings.bEnableWebGL) { if (BluManager::CPURenderSettings) { UE_LOG(LogBlu, Error, TEXT("You have enabled WebGL for this browser, but CPU Saver is enabled in BluManager.cpp - WebGL will not work!")); } - browserSettings.webgl = STATE_ENABLED; + BrowserSettings.webgl = STATE_ENABLED; } - renderer = new RenderHandler(Width, Height, this); - g_handler = new BrowserClient(renderer); - browser = CefBrowserHost::CreateBrowserSync(info, g_handler.get(), "about:blank", browserSettings, NULL); + //NB: this setting will change it globally for all new instances + BluManager::AutoPlay = Settings.bAutoPlayEnabled; + + Renderer = new RenderHandler(Settings.Width, Settings.Height, this); + ClientHandler = new BrowserClient(Renderer); + Browser = CefBrowserHost::CreateBrowserSync( + Info, + ClientHandler.get(), + "about:blank", + BrowserSettings, + NULL, + NULL); + + + Browser->GetHost()->SetWindowlessFrameRate(Settings.FrameRate); + Browser->GetHost()->SetAudioMuted(Settings.bAudioMuted); // Setup JS event emitter - g_handler->SetEventEmitter(&ScriptEventEmitter); + ClientHandler->SetEventEmitter(&ScriptEventEmitter); + ClientHandler->SetLogEmitter(&LogEventEmitter); UE_LOG(LogBlu, Log, TEXT("Component Initialized")); - CefString str = *DefaultURL; UE_LOG(LogBlu, Log, TEXT("Loading URL: %s"), *DefaultURL); // Load the default URL LoadURL(DefaultURL); ResetTexture(); + //Instead of manually ticking, we now tick whenever one blu eye is created + SpawnTickEventLoopIfNeeded(); } void UBluEye::ResetTexture() @@ -80,10 +107,12 @@ void UBluEye::ResetTexture() // Here we init the texture to its initial state DestroyTexture(); + bValidTexture = false; Texture = nullptr; + // init the new Texture2D - Texture = UTexture2D::CreateTransient(Width, Height, PF_B8G8R8A8); + Texture = UTexture2D::CreateTransient(Settings.Width, Settings.Height, PF_B8G8R8A8); Texture->AddToRoot(); Texture->UpdateResource(); @@ -91,11 +120,12 @@ void UBluEye::ResetTexture() ResetMatInstance(); + bValidTexture = true; } void UBluEye::DestroyTexture() { - // Here we destory the texture and its resource + // Here we destroy the texture and its resource if (Texture) { Texture->RemoveFromRoot(); @@ -108,44 +138,44 @@ void UBluEye::DestroyTexture() Texture->MarkPendingKill(); Texture = nullptr; + bValidTexture = false; } } void UBluEye::TextureUpdate(const void *buffer, FUpdateTextureRegion2D *updateRegions, uint32 regionCount) { - if (!browser || !bEnabled) + if (!Browser || !bEnabled) { UE_LOG(LogBlu, Warning, TEXT("NO BROWSER ACCESS OR NOT ENABLED")) return; } - //todo: remove debug address hack - if (Texture && (int64)Texture != 0xdddddddddddddddd && Texture->IsValidLowLevel() && Texture->Resource) + if (bValidTexture && Texture->IsValidLowLevelFast()) { if (buffer == nullptr) { UE_LOG(LogBlu, Warning, TEXT("NO TEXTDATA")) return; - } + } - FUpdateTextureRegionsData * RegionData = new FUpdateTextureRegionsData; - RegionData->Texture2DResource = (FTexture2DResource*)Texture->Resource; + FUpdateTextureRegionsData* RegionData = new FUpdateTextureRegionsData; + RegionData->Texture2DResource = (FTextureResource*)Texture->Resource; RegionData->NumRegions = regionCount; RegionData->SrcBpp = 4; - RegionData->SrcPitch = Width * 4; - RegionData->SrcData = (uint8*)buffer; + RegionData->SrcPitch = Settings.Width * 4; RegionData->Regions = updateRegions; + //We need to copy this memory or it might get uninitialized + RegionData->SrcData.SetNumUninitialized(RegionData->SrcPitch * Settings.Height); + FPlatformMemory::Memcpy(RegionData->SrcData.GetData(), buffer, RegionData->SrcData.Num()); - ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER( - void, - FUpdateTextureRegionsData*, RegionData, RegionData, + ENQUEUE_RENDER_COMMAND(UpdateBLUICommand)( + [RegionData](FRHICommandList& CommandList) { for (uint32 RegionIndex = 0; RegionIndex < RegionData->NumRegions; RegionIndex++) { - - RHIUpdateTexture2D(RegionData->Texture2DResource->GetTexture2DRHI(), 0, RegionData->Regions[RegionIndex], RegionData->SrcPitch, RegionData->SrcData + RHIUpdateTexture2D(RegionData->Texture2DResource->TextureRHI->GetTexture2D(), 0, RegionData->Regions[RegionIndex], RegionData->SrcPitch, RegionData->SrcData.GetData() + RegionData->Regions[RegionIndex].SrcY * RegionData->SrcPitch + RegionData->Regions[RegionIndex].SrcX * RegionData->SrcBpp); } @@ -161,39 +191,46 @@ void UBluEye::TextureUpdate(const void *buffer, FUpdateTextureRegion2D *updateRe } -void UBluEye::ExecuteJS(const FString& code) +void UBluEye::ExecuteJS(const FString& Code) { - CefString codeStr = *code; - browser->GetMainFrame()->ExecuteJavaScript(codeStr, "", 0); + CefString CodeStr = *Code; + Browser->GetMainFrame()->ExecuteJavaScript(CodeStr, "", 0); } void UBluEye::ExecuteJSMethodWithParams(const FString& methodName, const TArray params) { // Empty param string - FString paramString = "("; + FString ParamString = "("; // Build the param string for (FString param : params) { - paramString += param; - paramString += ","; + ParamString += param; + ParamString += ","; } // Remove the last , it's not needed - paramString.RemoveFromEnd(","); - paramString += ");"; + ParamString.RemoveFromEnd(","); + ParamString += ");"; // time to call the function - ExecuteJS(methodName + paramString); - + ExecuteJS(methodName + ParamString); } void UBluEye::LoadURL(const FString& newURL) { + FString FinalUrl = newURL; - // Check if we want to load a local file + //Detect chrome-devtools, and re-target them to regular devtools + if (newURL.Contains(TEXT("chrome-devtools://devtools"))) + { + //devtools://devtools/inspector.html?v8only=true&ws=localhost:9229 + //browser->GetHost()->ShowDevTools(info, g_handler, browserSettings, CefPoint()); + FinalUrl = FinalUrl.Replace(TEXT("chrome-devtools://devtools/bundled/inspector.html"), TEXT("devtools://devtools/inspector.html")); + } + // Check if we want to load a local file if (newURL.Contains(TEXT("blui://"), ESearchCase::IgnoreCase, ESearchDir::FromStart)) { @@ -209,49 +246,41 @@ void UBluEye::LoadURL(const FString& newURL) UE_LOG(LogBlu, Log, TEXT("Load Local File: %s"), *LocalFile) // Load it up - browser->GetMainFrame()->LoadURL(*LocalFile); + Browser->GetMainFrame()->LoadURL(*LocalFile); return; } // Load as usual - browser->GetMainFrame()->LoadURL(*newURL); + Browser->GetMainFrame()->LoadURL(*FinalUrl); } FString UBluEye::GetCurrentURL() { - return FString(browser->GetMainFrame()->GetURL().c_str()); + return FString(Browser->GetMainFrame()->GetURL().c_str()); } -void UBluEye::SetZoom(const float scale /*= 1*/) +void UBluEye::SetZoom(const float Scale /*= 1*/) { - browser->GetHost()->SetZoomLevel(scale); + Browser->GetHost()->SetZoomLevel(Scale); } float UBluEye::GetZoom() { - return browser->GetHost()->GetZoomLevel(); + return Browser->GetHost()->GetZoomLevel(); } -void UBluEye::Test() +void UBluEye::DownloadFile(const FString& FileUrl) { - /*CefRefPtr visitor; - browser->GetHost->GetNavigationEntries(visitor, false);*/ - - //for (auto in visitor) -} - -void UBluEye::DownloadFile(const FString& fileUrl) -{ - browser->GetHost()->StartDownload(*fileUrl); + Browser->GetHost()->StartDownload(*FileUrl); //Todo: ensure downloading works in some way, shape or form? } bool UBluEye::IsBrowserLoading() { - return browser->IsLoading(); + return Browser->IsLoading(); } void UBluEye::ReloadBrowser(bool IgnoreCache) @@ -259,19 +288,19 @@ void UBluEye::ReloadBrowser(bool IgnoreCache) if (IgnoreCache) { - return browser->ReloadIgnoreCache(); + return Browser->ReloadIgnoreCache(); } - browser->Reload(); + Browser->Reload(); } void UBluEye::NavBack() { - if (browser->CanGoBack()) + if (Browser->CanGoBack()) { - browser->GoBack(); + Browser->GoBack(); } } @@ -279,9 +308,9 @@ void UBluEye::NavBack() void UBluEye::NavForward() { - if (browser->CanGoForward()) + if (Browser->CanGoForward()) { - browser->GoForward(); + Browser->GoForward(); } } @@ -300,19 +329,23 @@ UTexture2D* UBluEye::ResizeBrowser(const int32 NewWidth, const int32 NewHeight) bEnabled = false; // Set our new Width and Height - Width = NewWidth; - Height = NewHeight; + Settings.Width = NewWidth; + Settings.Height = NewHeight; // Update our render handler - renderer->Width = NewWidth; - renderer->Height = NewHeight; + Renderer->Width = NewWidth; + Renderer->Height = NewHeight; + + bValidTexture = false; - Texture = UTexture2D::CreateTransient(Width, Height, PF_B8G8R8A8); + Texture = UTexture2D::CreateTransient(Settings.Width, Settings.Height, PF_B8G8R8A8); Texture->AddToRoot(); Texture->UpdateResource(); + bValidTexture = true; + // Let the browser's host know we resized it - browser->GetHost()->WasResized(); + Browser->GetHost()->WasResized(); // Now we can keep going bEnabled = true; @@ -330,17 +363,21 @@ UTexture2D* UBluEye::CropWindow(const int32 Y, const int32 X, const int32 NewWid // Set our new Width and Height - Width = NewWidth; - Height = NewHeight; + Settings.Width = NewWidth; + Settings.Height = NewHeight; // Update our render handler - renderer->Width = NewWidth; - renderer->Height = NewHeight; + Renderer->Width = NewWidth; + Renderer->Height = NewHeight; - Texture = UTexture2D::CreateTransient(Width, Height, PF_B8G8R8A8); + bValidTexture = false; + + Texture = UTexture2D::CreateTransient(Settings.Width, Settings.Height, PF_B8G8R8A8); Texture->AddToRoot(); Texture->UpdateResource(); + bValidTexture = true; + // Now we can keep going bEnabled = true; @@ -358,13 +395,13 @@ UBluEye* UBluEye::SetProperties(const int32 SetWidth, const FName& SetTextureParameterName, UMaterialInterface* SetBaseMaterial) { - Width = SetWidth; - Height = SetHeight; + Settings.Width = SetWidth; + Settings.Height = SetHeight; bEnabled = SetEnabled; - bIsTransparent = SetIsTransparent; - bEnableWebGL = SetWebGL; + Settings.bIsTransparent = SetIsTransparent; + Settings.bEnableWebGL = SetWebGL; BaseMaterial = SetBaseMaterial; DefaultURL = SetDefaultURL; @@ -373,88 +410,88 @@ UBluEye* UBluEye::SetProperties(const int32 SetWidth, return this; } -void UBluEye::TriggerMouseMove(const FVector2D& pos, const float scale) +void UBluEye::TriggerMouseMove(const FVector2D& Pos, const float Scale) { - mouse_event.x = pos.X / scale; - mouse_event.y = pos.Y / scale; + MouseEvent.x = Pos.X / Scale; + MouseEvent.y = Pos.Y / Scale; - browser->GetHost()->SendFocusEvent(true); - browser->GetHost()->SendMouseMoveEvent(mouse_event, false); + Browser->GetHost()->SendFocusEvent(true); + Browser->GetHost()->SendMouseMoveEvent(MouseEvent, false); } -void UBluEye::TriggerLeftClick(const FVector2D& pos, const float scale) +void UBluEye::TriggerLeftClick(const FVector2D& Pos, const float Scale) { - TriggerLeftMouseDown(pos, scale); - TriggerLeftMouseUp(pos, scale); + TriggerLeftMouseDown(Pos, Scale); + TriggerLeftMouseUp(Pos, Scale); } -void UBluEye::TriggerRightClick(const FVector2D& pos, const float scale) +void UBluEye::TriggerRightClick(const FVector2D& Pos, const float Scale) { - TriggerRightMouseDown(pos, scale); - TriggerRightMouseUp(pos, scale); + TriggerRightMouseDown(Pos, Scale); + TriggerRightMouseUp(Pos, Scale); } -void UBluEye::TriggerLeftMouseDown(const FVector2D& pos, const float scale) +void UBluEye::TriggerLeftMouseDown(const FVector2D& Pos, const float Scale) { - mouse_event.x = pos.X / scale; - mouse_event.y = pos.Y / scale; + MouseEvent.x = Pos.X / Scale; + MouseEvent.y = Pos.Y / Scale; - browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, false, 1); + Browser->GetHost()->SendMouseClickEvent(MouseEvent, MBT_LEFT, false, 1); } -void UBluEye::TriggerRightMouseDown(const FVector2D& pos, const float scale) +void UBluEye::TriggerRightMouseDown(const FVector2D& Pos, const float Scale) { - mouse_event.x = pos.X / scale; - mouse_event.y = pos.Y / scale; + MouseEvent.x = Pos.X / Scale; + MouseEvent.y = Pos.Y / Scale; - browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_RIGHT, false, 1); + Browser->GetHost()->SendMouseClickEvent(MouseEvent, MBT_RIGHT, false, 1); } -void UBluEye::TriggerLeftMouseUp(const FVector2D& pos, const float scale) +void UBluEye::TriggerLeftMouseUp(const FVector2D& Pos, const float Scale) { - mouse_event.x = pos.X / scale; - mouse_event.y = pos.Y / scale; + MouseEvent.x = Pos.X / Scale; + MouseEvent.y = Pos.Y / Scale; - browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, true, 1); + Browser->GetHost()->SendMouseClickEvent(MouseEvent, MBT_LEFT, true, 1); } -void UBluEye::TriggerRightMouseUp(const FVector2D& pos, const float scale) +void UBluEye::TriggerRightMouseUp(const FVector2D& Pos, const float Scale) { - mouse_event.x = pos.X / scale; - mouse_event.y = pos.Y / scale; + MouseEvent.x = Pos.X / Scale; + MouseEvent.y = Pos.Y / Scale; - browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_RIGHT, true, 1); + Browser->GetHost()->SendMouseClickEvent(MouseEvent, MBT_RIGHT, true, 1); } -void UBluEye::TriggerMouseWheel(const float MouseWheelDelta, const FVector2D& pos, const float scale) +void UBluEye::TriggerMouseWheel(const float MouseWheelDelta, const FVector2D& Pos, const float Scale) { - mouse_event.x = pos.X / scale; - mouse_event.y = pos.Y / scale; + MouseEvent.x = Pos.X / Scale; + MouseEvent.y = Pos.Y / Scale; - browser->GetHost()->SendMouseWheelEvent(mouse_event, MouseWheelDelta * 10, MouseWheelDelta * 10); + Browser->GetHost()->SendMouseWheelEvent(MouseEvent, MouseWheelDelta * 10, MouseWheelDelta * 10); } void UBluEye::KeyDown(FKeyEvent InKey) { - processKeyMods(InKey); - processKeyCode(InKey); + ProcessKeyMods(InKey); + ProcessKeyCode(InKey); - key_event.type = KEYEVENT_KEYDOWN; - browser->GetHost()->SendKeyEvent(key_event); + KeyEvent.type = KEYEVENT_KEYDOWN; + Browser->GetHost()->SendKeyEvent(KeyEvent); } void UBluEye::KeyUp(FKeyEvent InKey) { - processKeyMods(InKey); - processKeyCode(InKey); + ProcessKeyMods(InKey); + ProcessKeyCode(InKey); - key_event.type = KEYEVENT_KEYUP; - browser->GetHost()->SendKeyEvent(key_event); + KeyEvent.type = KEYEVENT_KEYUP; + Browser->GetHost()->SendKeyEvent(KeyEvent); } @@ -467,31 +504,51 @@ void UBluEye::KeyPress(FKeyEvent InKey) } -void UBluEye::processKeyCode(FKeyEvent InKey) +void UBluEye::ProcessKeyCode(FKeyEvent InKey) { - key_event.native_key_code = InKey.GetKeyCode(); - key_event.windows_key_code = InKey.GetKeyCode(); + KeyEvent.native_key_code = InKey.GetKeyCode(); + KeyEvent.windows_key_code = InKey.GetKeyCode(); } -void UBluEye::CharKeyPress(FCharacterEvent CharEvent) +void UBluEye::CharKeyInput(FCharacterEvent CharEvent) { // Process keymods like usual - processKeyMods(CharEvent); + ProcessKeyMods(CharEvent); + + // Below char input needs some special treatment, se we can't use the normal key down/up methods + +#if PLATFORM_MAC + KeyEvent.character = CharEvent.GetCharacter(); +#else + KeyEvent.windows_key_code = CharEvent.GetCharacter(); + KeyEvent.native_key_code = CharEvent.GetCharacter(); +#endif + KeyEvent.type = KEYEVENT_CHAR; + Browser->GetHost()->SendKeyEvent(KeyEvent); +} + +void UBluEye::CharKeyDownUp(FCharacterEvent CharEvent) +{ + // Process keymods like usual + ProcessKeyMods(CharEvent); // Below char input needs some special treatment, se we can't use the normal key down/up methods #if PLATFORM_MAC - key_event.character = CharEvent.GetCharacter(); + KeyEvent.character = CharEvent.GetCharacter(); #else - key_event.windows_key_code = CharEvent.GetCharacter(); - key_event.native_key_code = CharEvent.GetCharacter(); + KeyEvent.windows_key_code = CharEvent.GetCharacter(); + KeyEvent.native_key_code = CharEvent.GetCharacter(); #endif - key_event.type = KEYEVENT_CHAR; - browser->GetHost()->SendKeyEvent(key_event); + KeyEvent.type = KEYEVENT_KEYDOWN; + Browser->GetHost()->SendKeyEvent(KeyEvent); + + KeyEvent.type = KEYEVENT_KEYUP; + Browser->GetHost()->SendKeyEvent(KeyEvent); } -void UBluEye::RawCharKeyPress(const FString charToPress, bool isRepeat, +void UBluEye::RawCharKeyPress(const FString CharToPress, bool isRepeat, bool LeftShiftDown, bool RightShiftDown, bool LeftControlDown, @@ -506,13 +563,13 @@ void UBluEye::RawCharKeyPress(const FString charToPress, bool isRepeat, FModifierKeysState* KeyState = new FModifierKeysState(LeftShiftDown, RightShiftDown, LeftControlDown, RightControlDown, LeftAltDown, RightAltDown, LeftCommandDown, RightCommandDown, CapsLocksOn); - FCharacterEvent* CharEvent = new FCharacterEvent(charToPress.GetCharArray()[0], *KeyState, 0, isRepeat); + FCharacterEvent* CharEvent = new FCharacterEvent(CharToPress.GetCharArray()[0], *KeyState, 0, isRepeat); - CharKeyPress(*CharEvent); + CharKeyInput(*CharEvent); } -void UBluEye::SpecialKeyPress(EBluSpecialKeys key, bool LeftShiftDown, +void UBluEye::SpecialKeyPress(EBluSpecialKeys Key, bool LeftShiftDown, bool RightShiftDown, bool LeftControlDown, bool RightControlDown, @@ -523,53 +580,72 @@ void UBluEye::SpecialKeyPress(EBluSpecialKeys key, bool LeftShiftDown, bool CapsLocksOn) { - int32 keyValue = key; + int32 KeyValue = Key; - key_event.windows_key_code = keyValue; - key_event.native_key_code = keyValue; - key_event.type = KEYEVENT_KEYDOWN; - browser->GetHost()->SendKeyEvent(key_event); + KeyEvent.windows_key_code = KeyValue; + KeyEvent.native_key_code = KeyValue; + KeyEvent.type = KEYEVENT_KEYDOWN; + Browser->GetHost()->SendKeyEvent(KeyEvent); - key_event.windows_key_code = keyValue; - key_event.native_key_code = keyValue; + KeyEvent.windows_key_code = KeyValue; + KeyEvent.native_key_code = KeyValue; // bits 30 and 31 should be always 1 for WM_KEYUP - key_event.type = KEYEVENT_KEYUP; - browser->GetHost()->SendKeyEvent(key_event); + KeyEvent.type = KEYEVENT_KEYUP; + Browser->GetHost()->SendKeyEvent(KeyEvent); } -void UBluEye::processKeyMods(FInputEvent InKey) +void UBluEye::ProcessKeyMods(FInputEvent InKey) { - int mods = 0; + int Mods = 0; // Test alt if (InKey.IsAltDown()) { - mods |= cef_event_flags_t::EVENTFLAG_ALT_DOWN; + Mods |= cef_event_flags_t::EVENTFLAG_ALT_DOWN; } else // Test control if (InKey.IsControlDown()) { - mods |= cef_event_flags_t::EVENTFLAG_CONTROL_DOWN; + Mods |= cef_event_flags_t::EVENTFLAG_CONTROL_DOWN; } else // Test shift if (InKey.IsShiftDown()) { - mods |= cef_event_flags_t::EVENTFLAG_SHIFT_DOWN; + Mods |= cef_event_flags_t::EVENTFLAG_SHIFT_DOWN; } - key_event.modifiers = mods; + KeyEvent.modifiers = Mods; + +} + +void UBluEye::SpawnTickEventLoopIfNeeded() +{ + if (!EventLoopData.DelegateHandle.IsValid()) + { + EventLoopData.DelegateHandle = FTicker::GetCoreTicker().AddTicker(FTickerDelegate::CreateLambda([](float DeltaTime) + { + if (EventLoopData.bShouldTickEventLoop) + { + //UE_LOG(LogTemp, Log, TEXT("Delta: %1.2f"), DeltaTime); + BluManager::DoBluMessageLoop(); + } + + return true; + })); + } + EventLoopData.EyeCount++; } UTexture2D* UBluEye::GetTexture() const { if (!Texture) { - return UTexture2D::CreateTransient(Width, Height); + return UTexture2D::CreateTransient(Settings.Width, Settings.Height, PF_B8G8R8A8); } return Texture; @@ -608,7 +684,7 @@ void UBluEye::ResetMatInstance() return; } - MaterialInstance->SetTextureParameterValue(TextureParameterName, GetTexture()); + MaterialInstance->SetTextureParameterValue(TextureParameterName, Texture); } void UBluEye::CloseBrowser() @@ -618,16 +694,34 @@ void UBluEye::CloseBrowser() void UBluEye::BeginDestroy() { - if (browser) + if (Browser) { // Close up the browser - browser->GetHost()->CloseDevTools(); - browser->GetHost()->CloseBrowser(true); + Browser->GetHost()->SetAudioMuted(true); + Browser->GetMainFrame()->LoadURL("about:blank"); + //browser->GetMainFrame()->Delete(); + Browser->GetHost()->CloseDevTools(); + Browser->GetHost()->CloseBrowser(true); + Browser = nullptr; + UE_LOG(LogBlu, Warning, TEXT("Browser Closing")); } DestroyTexture(); SetFlags(RF_BeginDestroyed); + + //Remove our auto-ticking setup + EventLoopData.EyeCount--; + if (EventLoopData.EyeCount <= 0) + { + FTicker::GetCoreTicker().RemoveTicker(EventLoopData.DelegateHandle); + EventLoopData.DelegateHandle = FDelegateHandle(); + } Super::BeginDestroy(); } + +void UBluEye::SetShouldTickEventLoop(bool ShouldTick /*= true*/) +{ + EventLoopData.bShouldTickEventLoop = ShouldTick; +} diff --git a/Source/Blu/Private/BluJsonObj.cpp b/Source/Blu/Private/BluJsonObj.cpp index dc56735..6dd88af 100644 --- a/Source/Blu/Private/BluJsonObj.cpp +++ b/Source/Blu/Private/BluJsonObj.cpp @@ -1,4 +1,4 @@ -#include "BluPrivatePCH.h" +#include "BluJsonObj.h" #include "Json.h" UBluJsonObj::UBluJsonObj(const class FObjectInitializer& PCIP) @@ -7,207 +7,177 @@ UBluJsonObj::UBluJsonObj(const class FObjectInitializer& PCIP) } -void UBluJsonObj::init(const FString &StringData) +void UBluJsonObj::Init(const FString &StringData) { - StrData = *StringData; TSharedRef> JsonReader = TJsonReaderFactory::Create(StringData); - doParseJson(JsonReader); - + DoParseJson(JsonReader); } -FString UBluJsonObj::getStringValue(const FString &index) +FString UBluJsonObj::GetStringValue(const FString& Index) { - - return JsonParsed->GetStringField(index); - + return JsonParsed->GetStringField(Index); } -bool UBluJsonObj::getBooleanValue(const FString &index) +bool UBluJsonObj::GetBooleanValue(const FString &Index) { - - return JsonParsed->GetBoolField(index); - + return JsonParsed->GetBoolField(Index); } -float UBluJsonObj::getNumValue(const FString &index) +float UBluJsonObj::GetNumValue(const FString &Index) { - - return JsonParsed->GetNumberField(index); - + return JsonParsed->GetNumberField(Index); } -UBluJsonObj* UBluJsonObj::getNestedObject(const FString &index) +UBluJsonObj* UBluJsonObj::GetNestedObject(const FString &Index) { + TSharedPtr NewJson = JsonParsed->GetObjectField(Index); - TSharedPtr newJson = JsonParsed->GetObjectField(index); - - if (!newJson.IsValid()) + if (!NewJson.IsValid()) { return nullptr; } - // Make our new temp obj - UBluJsonObj* tempObj = NewObject(GetTransientPackage(), UBluJsonObj::StaticClass()); - tempObj->setJsonObj(newJson); + // Make our new Temp obj + UBluJsonObj* TempObj = NewObject(GetTransientPackage(), UBluJsonObj::StaticClass()); + TempObj->SetJsonObj(NewJson); // return it - return tempObj; - + return TempObj; } -TArray UBluJsonObj::getNumArray(const FString &index) +TArray UBluJsonObj::GetNumArray(const FString &Index) { + TArray Temp; - TArray temp; - - for (TSharedPtr val : JsonParsed->GetArrayField(index)) + for (TSharedPtr Val : JsonParsed->GetArrayField(Index)) { - temp.Add(val->AsNumber()); + Temp.Add(Val->AsNumber()); } - return temp; - + return Temp; } -TArray UBluJsonObj::getBooleanArray(const FString &index) +TArray UBluJsonObj::GetBooleanArray(const FString &Index) { + TArray Temp; - TArray temp; - - for (TSharedPtr val : JsonParsed->GetArrayField(index)) + for (TSharedPtr Val : JsonParsed->GetArrayField(Index)) { - temp.Add(val->AsBool()); + Temp.Add(Val->AsBool()); } - return temp; - + return Temp; } -TArray UBluJsonObj::getStringArray(const FString &index) +TArray UBluJsonObj::GetStringArray(const FString &Index) { + TArray Temp; - TArray temp; - - for (TSharedPtr val : JsonParsed->GetArrayField(index)) + for (TSharedPtr Val : JsonParsed->GetArrayField(Index)) { - temp.Add(val->AsString()); + Temp.Add(Val->AsString()); } - return temp; - + return Temp; } -void UBluJsonObj::setStringValue(const FString &value, const FString &index) +void UBluJsonObj::SetStringValue(const FString &Value, const FString &Index) { - - JsonParsed->SetStringField(index, value); - + JsonParsed->SetStringField(Index, Value); } -void UBluJsonObj::setNumValue(const float value, const FString &index) +void UBluJsonObj::SetNumValue(const float Value, const FString &Index) { - - JsonParsed->SetNumberField(index, value); - + JsonParsed->SetNumberField(Index, Value); } -void UBluJsonObj::setBooleanValue(const bool value, const FString &index) +void UBluJsonObj::SetBooleanValue(const bool Value, const FString &Index) { - - JsonParsed->SetBoolField(index, value); - + JsonParsed->SetBoolField(Index, Value); } -void UBluJsonObj::setNestedObject(UBluJsonObj *value, const FString &index) +void UBluJsonObj::SetNestedObject(UBluJsonObj *Value, const FString &Index) { - - JsonParsed->SetObjectField(index, value->getJsonObj()); - + JsonParsed->SetObjectField(Index, Value->GetJsonObj()); } -void UBluJsonObj::setJsonObj(TSharedPtr NewJson) +void UBluJsonObj::SetJsonObj(TSharedPtr NewJson) { - // Set our new stored JSON object JsonParsed = NewJson; - } -TSharedPtr UBluJsonObj::getJsonObj() +TSharedPtr UBluJsonObj::GetJsonObj() { - return JsonParsed; - } -void UBluJsonObj::doParseJson(TSharedRef> JsonReader) +void UBluJsonObj::DoParseJson(TSharedRef> JsonReader) { - if (!FJsonSerializer::Deserialize(JsonReader, JsonParsed)) { UE_LOG(LogBlu, Warning, TEXT("JSON STRING FAILED TO PARSE! WILL DEFAULT TO EMPTY OBJECT {}")); // Make an empty json object to prevent crashing - doParseJson(TJsonReaderFactory::Create("{}")); + DoParseJson(TJsonReaderFactory::Create("{}")); } - } // CUSTOM ADDED START -void UBluJsonObj::setStringArray(const TArray &value, const FString &index) +void UBluJsonObj::SetStringArray(const TArray &Value, const FString &Index) { - TArray> valueArray; + TArray> ValueArray; - for (FString val : value) + for (FString Val : Value) { - valueArray.Add(MakeShareable(new FJsonValueString(val))); + ValueArray.Add(MakeShareable(new FJsonValueString(Val))); } - JsonParsed->SetArrayField(index, valueArray); + JsonParsed->SetArrayField(Index, ValueArray); } -void UBluJsonObj::setBooleanArray(const TArray &value, const FString &index) +void UBluJsonObj::SetBooleanArray(const TArray &Value, const FString &Index) { - TArray> valueArray; + TArray> ValueArray; - for (bool val : value) + for (bool Val : Value) { - valueArray.Add(MakeShareable(new FJsonValueBoolean(val))); + ValueArray.Add(MakeShareable(new FJsonValueBoolean(Val))); } - JsonParsed->SetArrayField(index, valueArray); + JsonParsed->SetArrayField(Index, ValueArray); } -void UBluJsonObj::setNumArray(const TArray &value, const FString &index) +void UBluJsonObj::SetNumArray(const TArray &Value, const FString &Index) { - TArray> valueArray; + TArray> ValueArray; - for (float val : value) + for (float Val : Value) { - valueArray.Add(MakeShareable(new FJsonValueNumber(val))); + ValueArray.Add(MakeShareable(new FJsonValueNumber(Val))); } - JsonParsed->SetArrayField(index, valueArray); + JsonParsed->SetArrayField(Index, ValueArray); } -void UBluJsonObj::setObjectArray(const TArray &value, const FString &index) +void UBluJsonObj::SetObjectArray(const TArray &Value, const FString &Index) { - TArray> valueArray; + TArray> ValueArray; - for (UBluJsonObj* val : value) + for (UBluJsonObj* Val : Value) { - valueArray.Add(MakeShareable(new FJsonValueObject(val->getJsonObj()))); + ValueArray.Add(MakeShareable(new FJsonValueObject(Val->GetJsonObj()))); } - JsonParsed->SetArrayField(index, valueArray); + JsonParsed->SetArrayField(Index, ValueArray); } // CUSTOM ADDED END diff --git a/Source/Blu/Private/BluManager.cpp b/Source/Blu/Private/BluManager.cpp index 78ac561..e7b03d5 100644 --- a/Source/Blu/Private/BluManager.cpp +++ b/Source/Blu/Private/BluManager.cpp @@ -1,12 +1,11 @@ -#include "BluPrivatePCH.h" +#include "BluManager.h" BluManager::BluManager() { - } void BluManager::OnBeforeCommandLineProcessing(const CefString& process_type, - CefRefPtr< CefCommandLine > command_line) + CefRefPtr< CefCommandLine > CommandLine) { ///////////////// @@ -18,37 +17,44 @@ void BluManager::OnBeforeCommandLineProcessing(const CefString& process_type, BluManager::CPURenderSettings = false; ///////////////// - command_line->AppendSwitch("off-screen-rendering-enabled"); - command_line->AppendSwitchWithValue("off-screen-frame-rate", "60"); - command_line->AppendSwitch("enable-font-antialiasing"); - command_line->AppendSwitch("enable-media-stream"); + CommandLine->AppendSwitch("off-screen-rendering-enabled"); + CommandLine->AppendSwitchWithValue("off-screen-frame-rate", "60"); + CommandLine->AppendSwitch("enable-font-antialiasing"); + CommandLine->AppendSwitch("enable-media-stream"); // Should we use the render settings that use less CPU? if (CPURenderSettings) { - command_line->AppendSwitch("disable-gpu"); - command_line->AppendSwitch("disable-gpu-compositing"); - command_line->AppendSwitch("enable-begin-frame-scheduling"); + CommandLine->AppendSwitch("disable-gpu"); + CommandLine->AppendSwitch("disable-gpu-compositing"); + CommandLine->AppendSwitch("enable-begin-frame-scheduling"); } else { // Enables things like CSS3 and WebGL - command_line->AppendSwitch("enable-gpu-rasterization"); - command_line->AppendSwitch("enable-webgl"); - command_line->AppendSwitch("disable-web-security"); + CommandLine->AppendSwitch("enable-gpu-rasterization"); + CommandLine->AppendSwitch("enable-webgl"); + CommandLine->AppendSwitch("disable-web-security"); } + CommandLine->AppendSwitchWithValue("enable-blink-features", "HTMLImports"); + if (AutoPlay) + { + CommandLine->AppendSwitchWithValue("autoplay-policy", "no-user-gesture-required"); + } + // Append more command line options here if you want // Visit Peter Beverloo's site: http://peter.sh/experiments/chromium-command-line-switches/ for more info on the switches } -void BluManager::doBluMessageLoop() +void BluManager::DoBluMessageLoop() { CefDoMessageLoopWork(); } -CefSettings BluManager::settings; -CefMainArgs BluManager::main_args; -bool BluManager::CPURenderSettings = true; \ No newline at end of file +CefSettings BluManager::Settings; +CefMainArgs BluManager::MainArgs; +bool BluManager::CPURenderSettings = false; +bool BluManager::AutoPlay = true; \ No newline at end of file diff --git a/Source/Blu/Private/BluPrivatePCH.h b/Source/Blu/Private/BluPrivatePCH.h deleted file mode 100644 index e0d387c..0000000 --- a/Source/Blu/Private/BluPrivatePCH.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include "CoreUObject.h" -#include "Engine.h" -#include "Engine/Console.h" -#include "Runtime/UMG/Public/UMG.h" -#include "Runtime/UMG/Public/UMGStyle.h" -#include "Runtime/UMG/Public/Slate/SObjectWidget.h" -#include "Runtime/UMG/Public/IUMGModule.h" -#include "Runtime/UMG/Public/Blueprint/UserWidget.h" - -// You should place include statements to your module's private header files here. You only need to -// add includes for headers that are used in most of your module's source files though. -#include "ModuleManager.h" -#include "IBlu.h" - -DECLARE_LOG_CATEGORY_EXTERN(LogBlu, Log, All); - -// Blu Classes -#include "BluManager.h" -#include "BluEye.h" -#include "RenderHandler.h" -#include "BluJsonObj.h" -#include "BluBlueprintFunctionLibrary.h" \ No newline at end of file diff --git a/Source/Blu/Private/RenderHandler.cpp b/Source/Blu/Private/RenderHandler.cpp index 1041417..94aeeee 100644 --- a/Source/Blu/Private/RenderHandler.cpp +++ b/Source/Blu/Private/RenderHandler.cpp @@ -1,135 +1,166 @@ -#include "BluPrivatePCH.h" +#include "RenderHandler.h" +#include "BluEye.h" -RenderHandler::RenderHandler(int32 width, int32 height, UBluEye* ui) +RenderHandler::RenderHandler(int32 Width, int32 Height, UBluEye* UI) { - this->Width = width; - this->Height = height; - this->parentUI = ui; + this->Width = Width; + this->Height = Height; + this->ParentUI = UI; } -bool RenderHandler::GetViewRect(CefRefPtr browser, CefRect &rect) +void RenderHandler::GetViewRect(CefRefPtr Browser, CefRect &Rect) { - rect = CefRect(0, 0, Width, Height); - return true; + Rect = CefRect(0, 0, Width, Height); } -void RenderHandler::OnPaint(CefRefPtr browser, PaintElementType type, const RectList &dirtyRects, const void *buffer, int width, int height) +void RenderHandler::OnPaint(CefRefPtr Browser, PaintElementType Type, const RectList &DirtyRects, const void *Buffer, int InWidth, int InHeight) { - FUpdateTextureRegion2D *updateRegions = static_cast(FMemory::Malloc(sizeof(FUpdateTextureRegion2D) * dirtyRects.size())); + FUpdateTextureRegion2D *UpdateRegions = static_cast(FMemory::Malloc(sizeof(FUpdateTextureRegion2D) * DirtyRects.size())); - int current = 0; - for (auto dirtyRect : dirtyRects) + int Current = 0; + for (auto DirtyRect : DirtyRects) { - updateRegions[current].DestX = updateRegions[current].SrcX = dirtyRect.x; - updateRegions[current].DestY = updateRegions[current].SrcY = dirtyRect.y; - updateRegions[current].Height = dirtyRect.height; - updateRegions[current].Width = dirtyRect.width; + UpdateRegions[Current].DestX = UpdateRegions[Current].SrcX = DirtyRect.x; + UpdateRegions[Current].DestY = UpdateRegions[Current].SrcY = DirtyRect.y; + UpdateRegions[Current].Height = DirtyRect.height; + UpdateRegions[Current].Width = DirtyRect.width; - current++; + Current++; } // Trigger our parent UIs Texture to update - parentUI->TextureUpdate(buffer, updateRegions, dirtyRects.size()); + ParentUI->TextureUpdate(Buffer, UpdateRegions, DirtyRects.size()); } -void BrowserClient::OnAfterCreated(CefRefPtr browser) +void BrowserClient::OnAfterCreated(CefRefPtr Browser) { //CEF_REQUIRE_UI_THREAD(); - if (!m_Browser.get()) + if (!BrowserRef.get()) { // Keep a reference to the main browser. - m_Browser = browser; - m_BrowserId = browser->GetIdentifier(); + BrowserRef = Browser; + BrowserId = Browser->GetIdentifier(); } } -void BrowserClient::OnBeforeClose(CefRefPtr browser) +void BrowserClient::OnBeforeClose(CefRefPtr Browser) { //CEF_REQUIRE_UI_THREAD(); - if (m_BrowserId == browser->GetIdentifier()) + if (BrowserId == Browser->GetIdentifier()) { - m_Browser = NULL; + BrowserRef = NULL; } } -bool BrowserClient::OnProcessMessageReceived(CefRefPtr browser, CefProcessId source_process, CefRefPtr message) +bool BrowserClient::OnConsoleMessage(CefRefPtr Browser, cef_log_severity_t Level, const CefString& Message, const CefString& source, int line) { - - FString data; - FString name = FString(UTF8_TO_TCHAR(message->GetArgumentList()->GetString(0).ToString().c_str())); - FString type = FString(UTF8_TO_TCHAR(message->GetArgumentList()->GetString(2).ToString().c_str())); - FString data_type = FString(UTF8_TO_TCHAR(message->GetArgumentList()->GetString(3).ToString().c_str())); - - if (type == "js_event") + FString LogMessage = FString(Message.c_str()); + LogEmitter->Broadcast(LogMessage); + return true; +} + +void BrowserClient::OnFullscreenModeChange(CefRefPtr< CefBrowser > Browser, bool Fullscreen) +{ + UE_LOG(LogTemp, Log, TEXT("Changed to Fullscreen: %d"), Fullscreen); +} + +void BrowserClient::OnTitleChange(CefRefPtr< CefBrowser > Browser, const CefString& Title) +{ + FString TitleMessage = FString(Title.c_str()); + LogEmitter->Broadcast(TitleMessage); +} + +CefRefPtr BrowserClient::GetCEFBrowser() +{ + return BrowserRef; +} + +bool BrowserClient::OnProcessMessageReceived(CefRefPtr Browser, CefRefPtr Frame, CefProcessId SourceProcess, CefRefPtr Message) +{ + FString Data; + FString Name = FString(UTF8_TO_TCHAR(Message->GetArgumentList()->GetString(0).ToString().c_str())); + FString Type = FString(UTF8_TO_TCHAR(Message->GetArgumentList()->GetString(2).ToString().c_str())); + FString DataType = FString(UTF8_TO_TCHAR(Message->GetArgumentList()->GetString(3).ToString().c_str())); + + if (Type == "js_event") { - + // Check the datatype - - if (data_type == "bool") - data = message->GetArgumentList()->GetBool(1) ? TEXT("true") : TEXT("false"); - else if (data_type == "int") - data = FString::FromInt(message->GetArgumentList()->GetInt(1)); - else if (data_type == "string") - data = FString(UTF8_TO_TCHAR(message->GetArgumentList()->GetString(1).ToString().c_str())); - else if (data_type == "double") - data = FString::SanitizeFloat(message->GetArgumentList()->GetDouble(1)); - - event_emitter->Broadcast(name, data); + + if (DataType == "bool") + Data = Message->GetArgumentList()->GetBool(1) ? TEXT("true") : TEXT("false"); + else if (DataType == "int") + Data = FString::FromInt(Message->GetArgumentList()->GetInt(1)); + else if (DataType == "string") + Data = FString(UTF8_TO_TCHAR(Message->GetArgumentList()->GetString(1).ToString().c_str())); + else if (DataType == "double") + Data = FString::SanitizeFloat(Message->GetArgumentList()->GetDouble(1)); + + EventEmitter->Broadcast(Name, Data); } - + return true; - } +void BrowserClient::OnUncaughtException(CefRefPtr Browser, CefRefPtr Frame, CefRefPtr Context, CefRefPtr Exception, CefRefPtr StackTrace) +{ + FString ErrorMessage = FString(Exception->GetMessage().c_str()); + UE_LOG(LogClass, Warning, TEXT("%s"), *ErrorMessage); +} //The path slashes have to be reversed to work with CEF -FString ReversePathSlashes(FString forwardPath) +FString ReversePathSlashes(FString ForwardPath) { - return forwardPath.Replace(TEXT("/"), TEXT("\\")); + return ForwardPath.Replace(TEXT("/"), TEXT("\\")); } FString UtilityBLUIDownloadsFolder() { - return ReversePathSlashes(FPaths::ConvertRelativePathToFull(FPaths::GameDir() + "Plugins/BLUI/Downloads/")); + return ReversePathSlashes(FPaths::ConvertRelativePathToFull(FPaths::ProjectDir() + "Plugins/BLUI/Downloads/")); } -void BrowserClient::SetEventEmitter(FScriptEvent* emitter) +void BrowserClient::SetEventEmitter(FScriptEvent* Emitter) +{ + this->EventEmitter = Emitter; +} + +void BrowserClient::SetLogEmitter(FLogEvent* Emitter) { - this->event_emitter = emitter; + this->LogEmitter = Emitter; } void BrowserClient::OnBeforeDownload( - CefRefPtr browser, - CefRefPtr download_item, - const CefString & suggested_name, - CefRefPtr callback) + CefRefPtr Browser, + CefRefPtr DownloadItem, + const CefString & SuggestedName, + CefRefPtr Callback) { - UNREFERENCED_PARAMETER(browser); - UNREFERENCED_PARAMETER(download_item); + UNREFERENCED_PARAMETER(Browser); + UNREFERENCED_PARAMETER(DownloadItem); //We use this concatenation method to mix c_str with regular FString and then convert the result back to c_str - FString downloadPath = UtilityBLUIDownloadsFolder() + FString(suggested_name.c_str()); + FString DownloadPath = UtilityBLUIDownloadsFolder() + FString(SuggestedName.c_str()); - callback->Continue(*downloadPath, false); //don't show the download dialog, just go for it + Callback->Continue(*DownloadPath, false); //don't show the download dialog, just go for it - UE_LOG(LogClass, Log, TEXT("Downloading file for path %s"), *downloadPath); + UE_LOG(LogClass, Log, TEXT("Downloading file for path %s"), *DownloadPath); } void BrowserClient::OnDownloadUpdated( - CefRefPtr browser, - CefRefPtr download_item, - CefRefPtr callback) + CefRefPtr ForBrowser, + CefRefPtr DownloadItem, + CefRefPtr Callback) { - int percentage = download_item->GetPercentComplete(); - FString url = FString(download_item->GetFullPath().c_str()); + int Percentage = DownloadItem->GetPercentComplete(); + FString Url = FString(DownloadItem->GetFullPath().c_str()); - UE_LOG(LogClass, Log, TEXT("Download %s Updated: %d"), *url , percentage); + UE_LOG(LogClass, Log, TEXT("Download %s Updated: %d"), *Url , Percentage); - m_renderHandler->parentUI->DownloadUpdated.Broadcast(url, percentage); + RenderHandlerRef->ParentUI->DownloadUpdated.Broadcast(Url, Percentage); - if (percentage == 100 && download_item->IsComplete()) { - UE_LOG(LogClass, Log, TEXT("Download %s Complete"), *url); - m_renderHandler->parentUI->DownloadComplete.Broadcast(url); + if (Percentage == 100 && DownloadItem->IsComplete()) { + UE_LOG(LogClass, Log, TEXT("Download %s Complete"), *Url); + RenderHandlerRef->ParentUI->DownloadComplete.Broadcast(Url); } //Example download cancel/pause etc, we just have to hijack this diff --git a/Source/Blu/Public/BluBlueprintFunctionLibrary.h b/Source/Blu/Public/BluBlueprintFunctionLibrary.h index b111e83..e639164 100644 --- a/Source/Blu/Public/BluBlueprintFunctionLibrary.h +++ b/Source/Blu/Public/BluBlueprintFunctionLibrary.h @@ -1,5 +1,9 @@ #pragma once +#include "Kismet/BlueprintFunctionLibrary.h" +#include "Input/Events.h" +#include "BluEye.h" + #include "BluBlueprintFunctionLibrary.generated.h" UCLASS(ClassGroup = Blu, Blueprintable) @@ -23,6 +27,10 @@ class BLU_API UBluBlueprintFunctionLibrary : public UBlueprintFunctionLibrary UFUNCTION(BlueprintCallable, meta = (DisplayName = "JSON To String", Keywords = "blui blu eye json parse string"), Category = Blu) static FString JSONToString(UBluJsonObj *ObjectToParse); + /** convert regular key events into char event which you can use char press*/ + UFUNCTION(BlueprintPure, meta = (DisplayName = "To CharacterEvent (Key)", BlueprintAutocast), Category = Blu) + static FCharacterEvent ToKeyEvent(FKey Key); + //Utility functions taken from Victory Plugin UFUNCTION(BlueprintPure, Category = "Blu Utility") static FString GameRootDirectory(); diff --git a/Source/Blu/Public/BluEye.h b/Source/Blu/Public/BluEye.h index 9d1222f..9976cc9 100644 --- a/Source/Blu/Public/BluEye.h +++ b/Source/Blu/Public/BluEye.h @@ -1,54 +1,10 @@ #pragma once -#include "BluEye.generated.h" - -class BrowserClient; -class RenderHandler; - -DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FScriptEvent, const FString&, EventName, const FString&, EventMessage); - -struct FBluTextureParams -{ - - // Pointer to our Texture's resource - FTexture2DResource* Texture2DResource; - -}; -struct FUpdateTextureRegionsData -{ - FTexture2DResource * Texture2DResource; - uint32 NumRegions; - FUpdateTextureRegion2D * Regions; - uint32 SrcPitch; - uint32 SrcBpp; - uint8 * SrcData; -}; - -UENUM(BlueprintType) -enum EBluSpecialKeys -{ - backspacekey = 8 UMETA(DisplayName = "Backspace"), - tabkey = 9 UMETA(DisplayName = "Tab"), - enterkey = 13 UMETA(DisplayName = "Enter"), - pausekey = 19 UMETA(DisplayName = "Pause"), - escapekey = 27 UMETA(DisplayName = "Escape"), - pageupkey = 33 UMETA(DisplayName = "Page Up"), - pagedownkey = 34 UMETA(DisplayName = "Page Down"), - endkey = 35 UMETA(DisplayName = "End"), - homekey = 36 UMETA(DisplayName = "Home"), - leftarrowkey = 37 UMETA(DisplayName = "Left Arrow"), - rightarrowkey = 38 UMETA(DisplayName = "Right Arrow"), - downarrowkey = 39 UMETA(DisplayName = "Down Arrow"), - uparrowkey = 40 UMETA(DisplayName = "Up Arrow"), - insertkey = 45 UMETA(DisplayName = "Insert"), - deletekey = 46 UMETA(DisplayName = "Delete"), - numlockkey = 144 UMETA(DisplayName = "Num Lock"), - scrolllockkey = 145 UMETA(DisplayName = "Scroll Lock") -}; - -DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDownloadCompleteSignature, FString, url); -DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FDownloadUpdatedSignature, FString, url, float, percentage); -//DECLARE_DYNAMIC_MULTICAST_DELEGATE(FDownloadComplete); +#include "RenderHandler.h" +#include "BluTypes.h" +#include "BluManager.h" +#include "UObject/Object.h" +#include "BluEye.generated.h" UCLASS(ClassGroup = Blu, Blueprintable) class BLU_API UBluEye : public UObject @@ -61,50 +17,38 @@ class BLU_API UBluEye : public UObject //Event delegates UPROPERTY(BlueprintAssignable, Category = "Blu Browser Events") - FDownloadCompleteSignature DownloadComplete; + FDownloadCompleteSignature DownloadComplete; UPROPERTY(BlueprintAssignable, Category = "Blu Browser Events") - FDownloadUpdatedSignature DownloadUpdated; + FDownloadUpdatedSignature DownloadUpdated; //GENERATED_UCLASS_BODY() /** Initialize function, should be called after properties are set */ UFUNCTION(BlueprintCallable, Category = "Blu") - void init(); + void Init(); /** The default URL this UI component will load */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Blu") - FString DefaultURL; + FString DefaultURL; /** Is this UI component current active? */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Blu") - bool bEnabled; + bool bEnabled; - /** Should this be rendered in game to be transparent? */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Blu") - bool bIsTransparent; - - /** Width of the view resolution */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Blu") - int32 Width; - - /** Height of the view resolution */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Blu") - int32 Height; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Blu") - bool bEnableWebGL; + FBluEyeSettings Settings; /** Material that will be instanced to load UI texture into it */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Blu") - UMaterialInterface* BaseMaterial; + UMaterialInterface* BaseMaterial; /** Name of parameter to load UI texture into material */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Blu") - FName TextureParameterName = "BluTexture"; + FName TextureParameterName = "BluTexture"; UFUNCTION(BlueprintCallable, Category = "Blu") - UBluEye* SetProperties(const int32 SetWidth, + UBluEye* SetProperties(const int32 SetWidth, const int32 SetHeight, const bool SetIsTransparent, const bool SetEnabled, @@ -115,11 +59,11 @@ class BLU_API UBluEye : public UObject /** Get the texture data from our UI component */ UFUNCTION(BlueprintCallable, Category = "Blu") - UTexture2D* GetTexture() const; + UTexture2D* GetTexture() const; /** Execute JS code inside the browser */ UFUNCTION(BlueprintCallable, Category = "Blu") - void ExecuteJS(const FString& code); + void ExecuteJS(const FString& code); /** * Execute a JS function/method by name with FString Array as params. @@ -129,87 +73,90 @@ class BLU_API UBluEye : public UObject * To pass as a string, place quotes around the param when adding to the array: "10.5" and "hello" are strings */ UFUNCTION(BlueprintCallable, Category = "Blu", meta = (DisplayName = "Execute Javascript With Params", Keywords = "js javascript parameters")) - void ExecuteJSMethodWithParams(const FString& methodName, const TArray params); + void ExecuteJSMethodWithParams(const FString& methodName, const TArray params); /** Load a new URL into the browser */ UFUNCTION(BlueprintCallable, Category = "Blu") - void LoadURL(const FString& newURL); + void LoadURL(const FString& newURL); /** Get the currently loaded URL */ UFUNCTION(BlueprintPure, Category = "Blu") - FString GetCurrentURL(); + FString GetCurrentURL(); /** Trigger Zoom */ UFUNCTION(BlueprintCallable, Category = "Blu") - void SetZoom(const float scale = 1); + void SetZoom(const float scale = 1); /** Get our zoom level */ UFUNCTION(BlueprintPure, Category = "Blu") - float GetZoom(); - - //Not ready yet - //UFUNCTION(BlueprintCallable, Category = "Blu Test") - void Test(); + float GetZoom(); /** Download a file */ UFUNCTION(BlueprintCallable, Category = "Blu") - void DownloadFile(const FString& fileUrl); + void DownloadFile(const FString& fileUrl); /** Trigger a LEFT click in the browser via a Vector2D */ UFUNCTION(BlueprintCallable, Category = "Blu") - void TriggerLeftClick(const FVector2D& pos, const float scale = 1); + void TriggerLeftClick(const FVector2D& pos, const float scale = 1); /** Trigger a RIGHT click in the browser via a Vector2D */ UFUNCTION(BlueprintCallable, Category = "Blu") - void TriggerRightClick(const FVector2D& pos, const float scale = 1); + void TriggerRightClick(const FVector2D& pos, const float scale = 1); /** Trigger a LEFT MOUSE DOWN in the browser via a Vector2D */ UFUNCTION(BlueprintCallable, Category = "Blu") - void TriggerLeftMouseDown(const FVector2D& pos, const float scale = 1); + void TriggerLeftMouseDown(const FVector2D& pos, const float scale = 1); /** Trigger a RIGHT MOUSE DOWN in the browser via a Vector2D */ UFUNCTION(BlueprintCallable, Category = "Blu") - void TriggerRightMouseDown(const FVector2D& pos, const float scale = 1); + void TriggerRightMouseDown(const FVector2D& pos, const float scale = 1); /** Trigger a LEFT MOUSE UP in the browser via a Vector2D */ UFUNCTION(BlueprintCallable, Category = "Blu") - void TriggerLeftMouseUp(const FVector2D& pos, const float scale = 1); + void TriggerLeftMouseUp(const FVector2D& pos, const float scale = 1); /* Trigger a RIGHT MOUSE UP in the browser via a Vector2D */ UFUNCTION(BlueprintCallable, Category = "Blu") - void TriggerRightMouseUp(const FVector2D& pos, const float scale = 1); + void TriggerRightMouseUp(const FVector2D& pos, const float scale = 1); /** Move the mouse in the browser */ UFUNCTION(BlueprintCallable, Category = "Blu") - void TriggerMouseMove(const FVector2D& pos, const float scale = 1); + void TriggerMouseMove(const FVector2D& pos, const float scale = 1); /** Move the mouse in the browser */ UFUNCTION(BlueprintCallable, Category = "Blu") - void TriggerMouseWheel(const float MouseWheelDelta, const FVector2D& pos, const float scale = 1); + void TriggerMouseWheel(const float MouseWheelDelta, const FVector2D& pos, const float scale = 1); /** Javascript event emitter */ UPROPERTY(BlueprintAssignable) - FScriptEvent ScriptEventEmitter; + FScriptEvent ScriptEventEmitter; + + UPROPERTY(BlueprintAssignable) + FLogEvent LogEventEmitter; /** Trigger a key down event */ UFUNCTION(BlueprintCallable, Category = "Blu") - void KeyDown(FKeyEvent InKey); + void KeyDown(FKeyEvent InKey); /** Trigger a key up event */ UFUNCTION(BlueprintCallable, Category = "Blu") - void KeyUp(FKeyEvent InKey); + void KeyUp(FKeyEvent InKey); /** Trigger a key press event */ UFUNCTION(BlueprintCallable, Category = "Blu") - void KeyPress(FKeyEvent InKey); + void KeyPress(FKeyEvent InKey); + + /** Trigger a character key event as if typing input */ + UFUNCTION(BlueprintCallable, Category = "Blu") + void CharKeyInput(FCharacterEvent CharEvent); - /** Trigger a character key event */ + /** Trigger a character key event as if pressing like a keyboard shortcut */ UFUNCTION(BlueprintCallable, Category = "Blu") - void CharKeyPress(FCharacterEvent CharEvent); + void CharKeyDownUp(FCharacterEvent CharEvent); /** Trigger a raw keypress via a character */ UFUNCTION(BlueprintCallable, Category = "Blu", meta = (AdvancedDisplay = "2")) - void RawCharKeyPress(const FString charToPress, bool isRepeat, + void RawCharKeyPress(const FString charToPress, bool isRepeat, bool LeftShiftDown, bool RightShiftDown, bool LeftControlDown, @@ -221,7 +168,7 @@ class BLU_API UBluEye : public UObject bool CapsLocksOn); UFUNCTION(BlueprintCallable, Category = "Blu", meta = (AdvancedDisplay = "2")) - void SpecialKeyPress(EBluSpecialKeys key, + void SpecialKeyPress(EBluSpecialKeys key, bool LeftShiftDown, bool RightShiftDown, bool LeftControlDown, @@ -234,65 +181,73 @@ class BLU_API UBluEye : public UObject /** Close the browser */ UFUNCTION(BlueprintCallable, Category = "Blu") - void CloseBrowser(); + void CloseBrowser(); /** Check if the browser is still loading */ UFUNCTION(BlueprintCallable, Category = "Blu") - bool IsBrowserLoading(); + bool IsBrowserLoading(); /** Reloads the browser's current page */ UFUNCTION(BlueprintCallable, Category = "Blu") - void ReloadBrowser(bool IgnoreCache); + void ReloadBrowser(bool IgnoreCache); /** Navigate back in this web view's history */ UFUNCTION(BlueprintCallable, Category = "Blu") - void NavBack(); + void NavBack(); /** Navigate forward in this web view's history */ UFUNCTION(BlueprintCallable, Category = "Blu") - void NavForward(); + void NavForward(); /** Resize the browser's viewport */ UFUNCTION(BlueprintCallable, Category = "Blu") - UTexture2D* ResizeBrowser(const int32 NewWidth, const int32 NewHeight); + UTexture2D* ResizeBrowser(const int32 NewWidth, const int32 NewHeight); //This cropping function doesn't work atm //UFUNCTION(BlueprintCallable, Category = "Blu") - UTexture2D* CropWindow(const int32 Y, const int32 X, const int32 NewWidth, const int32 NewHeight); - - CefRefPtr browser; + UTexture2D* CropWindow(const int32 Y, const int32 X, const int32 NewWidth, const int32 NewHeight); void TextureUpdate(const void* buffer, FUpdateTextureRegion2D * updateRegions, uint32 regionCount); void BeginDestroy() override; - protected: - CefWindowInfo info; - CefRefPtr g_handler; - CefBrowserSettings browserSettings; - RenderHandler* renderer; + /** Use this to pause the tick loop in the new system */ + UFUNCTION(BlueprintCallable, Category = "Blu") + static void SetShouldTickEventLoop(bool ShouldTick = true); + +protected: + + CefWindowInfo Info; + CefRefPtr ClientHandler; + CefBrowserSettings BrowserSettings; + RenderHandler* Renderer; + CefRefPtr Browser; + + CefMouseEvent MouseEvent; + CefKeyEvent KeyEvent; - void ResetTexture(); - void DestroyTexture(); - void ResetMatInstance(); + void ResetTexture(); + void DestroyTexture(); + void ResetMatInstance(); - // Parse UE4 key events, helper - void processKeyCode(FKeyEvent InKey); + // Parse UE4 key events, helper + void ProcessKeyCode(FKeyEvent InKey); - // Helper for processing key modifiers - void processKeyMods(FInputEvent InKey); + // Helper for processing key modifiers + void ProcessKeyMods(FInputEvent InKey); - // Store UI state in this UTexture2D - UPROPERTY() - UTexture2D* Texture; + void SpawnTickEventLoopIfNeeded(); - UMaterialInstanceDynamic* MaterialInstance; + static FTickEventLoopData EventLoopData; - CefMouseEvent mouse_event; - CefKeyEvent key_event; + // Store UI state in this UTexture2D + UPROPERTY() + UTexture2D* Texture; - private: + UMaterialInstanceDynamic* MaterialInstance; - FBluTextureParams RenderParams; +private: + FBluTextureParams RenderParams; + FThreadSafeBool bValidTexture; }; diff --git a/Source/Blu/Public/BluJsonObj.h b/Source/Blu/Public/BluJsonObj.h index 15737cf..a18a9d3 100644 --- a/Source/Blu/Public/BluJsonObj.h +++ b/Source/Blu/Public/BluJsonObj.h @@ -12,71 +12,71 @@ class BLU_API UBluJsonObj : public UObject //// Get Values //// - /* Gets a String value for the key given */ + /* Gets a String Value for the key given */ UFUNCTION(BlueprintCallable, Category = "Blu") - FString getStringValue(const FString &index); + FString GetStringValue(const FString &Index); - /* Gets a Numerical value for the key given */ + /* Gets a Numerical Value for the key given */ UFUNCTION(BlueprintCallable, Category = "Blu") - float getNumValue(const FString &index); + float GetNumValue(const FString &Index); - /* Gets a Boolean value for the key given */ + /* Gets a Boolean Value for the key given */ UFUNCTION(BlueprintCallable, Category = "Blu") - bool getBooleanValue(const FString &index); + bool GetBooleanValue(const FString &Index); - /* Gets a Nested JSON Object value for the key given */ + /* Gets a Nested JSON Object Value for the key given */ UFUNCTION(BlueprintCallable, Category = "Blu") - UBluJsonObj* getNestedObject(const FString &index); + UBluJsonObj* GetNestedObject(const FString &Index); //// Get Array Values //// /* Gets an Array of floats or numbers for the key given */ UFUNCTION(BlueprintCallable, Category = "Blu") - TArray getNumArray(const FString &index); + TArray GetNumArray(const FString &Index); /* Gets an Array of booleans for the key given */ UFUNCTION(BlueprintCallable, Category = "Blu") - TArray getBooleanArray(const FString &index); + TArray GetBooleanArray(const FString &Index); /* Gets an Array of strings for the key given */ UFUNCTION(BlueprintCallable, Category = "Blu") - TArray getStringArray(const FString &index); + TArray GetStringArray(const FString &Index); //// Set Values //// - /* Sets or Adds a String value to this JSON object */ + /* Sets or Adds a String Value to this JSON object */ UFUNCTION(BlueprintCallable, Category = "Blu") - void setStringValue(const FString &value, const FString &index); + void SetStringValue(const FString &Value, const FString &Index); - /* Sets or Adds a Numerical value to this JSON object */ + /* Sets or Adds a Numerical Value to this JSON object */ UFUNCTION(BlueprintCallable, Category = "Blu") - void setNumValue(const float value, const FString &index); + void SetNumValue(const float Value, const FString &Index); - /* Sets or Adds a Boolean value to this JSON object */ + /* Sets or Adds a Boolean Value to this JSON object */ UFUNCTION(BlueprintCallable, Category = "Blu") - void setBooleanValue(const bool value, const FString &index); + void SetBooleanValue(const bool Value, const FString &Index); - /* Sets or Adds a Nested JSON Object value to this JSON object */ + /* Sets or Adds a Nested JSON Object Value to this JSON object */ UFUNCTION(BlueprintCallable, Category = "Blu") - void setNestedObject(UBluJsonObj *value, const FString &index); + void SetNestedObject(UBluJsonObj *Value, const FString &Index); - void init(const FString &dataString); - void setJsonObj(TSharedPtr NewJson); + void Init(const FString &dataString); + void SetJsonObj(TSharedPtr NewJson); - TSharedPtr getJsonObj(); + TSharedPtr GetJsonObj(); // CUSTOM ADDED START UFUNCTION(BlueprintCallable, Category = "Blu") - void setStringArray(const TArray &value, const FString &index); + void SetStringArray(const TArray &Value, const FString &Index); UFUNCTION(BlueprintCallable, Category = "Blu") - void setBooleanArray(const TArray &value, const FString &index); + void SetBooleanArray(const TArray &Value, const FString &Index); UFUNCTION(BlueprintCallable, Category = "Blu") - void setNumArray(const TArray &value, const FString &index); + void SetNumArray(const TArray &Value, const FString &Index); UFUNCTION(BlueprintCallable, Category = "Blu") - void setObjectArray(const TArray &value, const FString &index); + void SetObjectArray(const TArray &Value, const FString &Index); // CUSTOM ADDED END private: @@ -84,7 +84,5 @@ class BLU_API UBluJsonObj : public UObject FString StrData; TSharedPtr JsonParsed; - void doParseJson(TSharedRef> JsonReader); - - + void DoParseJson(TSharedRef> JsonReader); }; \ No newline at end of file diff --git a/Source/Blu/Public/BluManager.h b/Source/Blu/Public/BluManager.h index 72f85f2..d2c1488 100644 --- a/Source/Blu/Public/BluManager.h +++ b/Source/Blu/Public/BluManager.h @@ -1,36 +1,22 @@ #pragma once -#if PLATFORM_WINDOWS -#include "WindowsHWrapper.h" -#include "AllowWindowsPlatformTypes.h" -#include "AllowWindowsPlatformAtomics.h" -#endif -#pragma push_macro("OVERRIDE") -#undef OVERRIDE // cef headers provide their own OVERRIDE macro -THIRD_PARTY_INCLUDES_START -#include "include/cef_app.h" -THIRD_PARTY_INCLUDES_END -#pragma pop_macro("OVERRIDE") -#if PLATFORM_WINDOWS -#include "HideWindowsPlatformAtomics.h" -#include "HideWindowsPlatformTypes.h" -#endif +#include "CEFInclude.h" class BLU_API BluManager : public CefApp { +public: - public: + BluManager(); - BluManager(); + static void DoBluMessageLoop(); + static CefSettings Settings; + static CefMainArgs MainArgs; + static bool CPURenderSettings; + static bool AutoPlay; - static void doBluMessageLoop(); - static CefSettings settings; - static CefMainArgs main_args; - static bool CPURenderSettings; + virtual void OnBeforeCommandLineProcessing(const CefString& ProcessType, + CefRefPtr< CefCommandLine > CommandLine) override; - virtual void OnBeforeCommandLineProcessing(const CefString& process_type, - CefRefPtr< CefCommandLine > command_line) override; + IMPLEMENT_REFCOUNTING(BluManager); +}; - IMPLEMENT_REFCOUNTING(BluManager) - -}; \ No newline at end of file diff --git a/Source/Blu/Public/BluTypes.h b/Source/Blu/Public/BluTypes.h new file mode 100644 index 0000000..99662c0 --- /dev/null +++ b/Source/Blu/Public/BluTypes.h @@ -0,0 +1,96 @@ +#pragma once + +#include "CoreMinimal.h" +#include "BluTypes.generated.h" + +struct FTickEventLoopData +{ + FDelegateHandle DelegateHandle; + int32 EyeCount; + bool bShouldTickEventLoop; + + FTickEventLoopData() + { + DelegateHandle = FDelegateHandle(); + EyeCount = 0; + bShouldTickEventLoop = true; + } +}; + +struct FBluTextureParams +{ + // Pointer to our Texture's resource + FTexture2DResource* Texture2DResource; +}; + +struct FUpdateTextureRegionsData +{ + FTextureResource* Texture2DResource; + uint32 NumRegions; + FUpdateTextureRegion2D* Regions; + uint32 SrcPitch; + uint32 SrcBpp; + TArray SrcData; +}; + +UENUM(BlueprintType) +enum EBluSpecialKeys +{ + backspacekey = 8 UMETA(DisplayName = "Backspace"), + tabkey = 9 UMETA(DisplayName = "Tab"), + enterkey = 13 UMETA(DisplayName = "Enter"), + pausekey = 19 UMETA(DisplayName = "Pause"), + escapekey = 27 UMETA(DisplayName = "Escape"), + pageupkey = 33 UMETA(DisplayName = "Page Up"), + pagedownkey = 34 UMETA(DisplayName = "Page Down"), + endkey = 35 UMETA(DisplayName = "End"), + homekey = 36 UMETA(DisplayName = "Home"), + leftarrowkey = 37 UMETA(DisplayName = "Left Arrow"), + rightarrowkey = 39 UMETA(DisplayName = "Right Arrow"), + downarrowkey = 40 UMETA(DisplayName = "Down Arrow"), + uparrowkey = 38 UMETA(DisplayName = "Up Arrow"), + insertkey = 45 UMETA(DisplayName = "Insert"), + deletekey = 46 UMETA(DisplayName = "Delete"), + numlockkey = 144 UMETA(DisplayName = "Num Lock"), + scrolllockkey = 145 UMETA(DisplayName = "Scroll Lock"), + unknownkey = 0, +}; + + +USTRUCT(BlueprintType) +struct FBluEyeSettings +{ + GENERATED_USTRUCT_BODY() + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "BluSettings") + float FrameRate; + + /** Should this be rendered in game to be transparent? */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Blu") + bool bIsTransparent; + + /** Width of the view resolution */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Blu") + int32 Width; + + /** Height of the view resolution */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Blu") + int32 Height; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Blu") + bool bEnableWebGL; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Blu") + bool bAudioMuted; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Blu") + bool bAutoPlayEnabled; + + FBluEyeSettings(); +}; + +DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FScriptEvent, const FString&, EventName, const FString&, EventMessage); +DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FLogEvent, const FString&, LogText); +DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDownloadCompleteSignature, FString, url); +DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FDownloadUpdatedSignature, FString, url, float, percentage); +//DECLARE_DYNAMIC_MULTICAST_DELEGATE(FDownloadComplete); \ No newline at end of file diff --git a/Source/Blu/Public/CEFInclude.h b/Source/Blu/Public/CEFInclude.h new file mode 100644 index 0000000..2f1a8ab --- /dev/null +++ b/Source/Blu/Public/CEFInclude.h @@ -0,0 +1,19 @@ +#pragma once + +#if PLATFORM_WINDOWS +#include "Windows/WindowsHWrapper.h" +#include "Windows/AllowWindowsPlatformTypes.h" +#include "Windows/AllowWindowsPlatformAtomics.h" +#endif +//#pragma push_macro("OVERRIDE") +//#undef OVERRIDE // cef headers provide their own OVERRIDE macro +THIRD_PARTY_INCLUDES_START +#include "include/cef_client.h" +#include "include/cef_browser.h" +#include "include/cef_app.h" +THIRD_PARTY_INCLUDES_END +//#pragma pop_macro("OVERRIDE") +#if PLATFORM_WINDOWS +#include "Windows/HideWindowsPlatformAtomics.h" +#include "Windows/HideWindowsPlatformTypes.h" +#endif \ No newline at end of file diff --git a/Source/Blu/Public/IBlu.h b/Source/Blu/Public/IBlu.h index a22403e..b4551ed 100644 --- a/Source/Blu/Public/IBlu.h +++ b/Source/Blu/Public/IBlu.h @@ -2,7 +2,9 @@ * (c) Aaron M. Shea 2014 */ #pragma once -#include "ModuleManager.h" +#include "Modules/ModuleManager.h" + +DECLARE_LOG_CATEGORY_EXTERN(LogBlu, Log, All); class IBlu : public IModuleInterface { @@ -28,5 +30,4 @@ class IBlu : public IModuleInterface { return FModuleManager::Get().IsModuleLoaded("Blu"); } - }; diff --git a/Source/Blu/Public/RenderHandler.h b/Source/Blu/Public/RenderHandler.h index 85009bf..d7e8494 100644 --- a/Source/Blu/Public/RenderHandler.h +++ b/Source/Blu/Public/RenderHandler.h @@ -1,44 +1,30 @@ #pragma once -#if PLATFORM_WINDOWS -#include "WindowsHWrapper.h" -#include "AllowWindowsPlatformTypes.h" -#include "AllowWindowsPlatformAtomics.h" -#endif -#pragma push_macro("OVERRIDE") -#undef OVERRIDE // cef headers provide their own OVERRIDE macro -THIRD_PARTY_INCLUDES_START -#include "include/cef_client.h" -#include "include/cef_app.h" -THIRD_PARTY_INCLUDES_END -#pragma pop_macro("OVERRIDE") -#if PLATFORM_WINDOWS -#include "HideWindowsPlatformAtomics.h" -#include "HideWindowsPlatformTypes.h" -#endif - -#include "../Public/BluEye.h" +#include "CEFInclude.h" +#include "BluTypes.h" + +class UBluEye; class RenderHandler : public CefRenderHandler { public: - UBluEye* parentUI; + UBluEye* ParentUI; int32 Width; int32 Height; // CefRenderHandler interface - bool GetViewRect(CefRefPtr browser, CefRect &rect) override; + virtual void GetViewRect(CefRefPtr Browser, CefRect &Rect) override; - void OnPaint(CefRefPtr browser, PaintElementType type, const RectList &dirtyRects, const void *buffer, int width, int height) override; + void OnPaint(CefRefPtr Browser, PaintElementType Type, const RectList &DirtyRects, const void *Buffer, int Width, int Height) override; - RenderHandler(int32 width, int32 height, UBluEye* ui); + RenderHandler(int32 Width, int32 Height, UBluEye* UI); // CefBase interface // NOTE: Must be at bottom public: - IMPLEMENT_REFCOUNTING(RenderHandler) + IMPLEMENT_REFCOUNTING(RenderHandler); }; // for manual render handler @@ -46,29 +32,30 @@ class BrowserClient : public CefClient, public CefLifeSpanHandler, public CefDow { private: - FScriptEvent* event_emitter; - CefRefPtr m_renderHandler; + FScriptEvent* EventEmitter; + FLogEvent* LogEmitter; + CefRefPtr RenderHandlerRef; // For lifespan - CefRefPtr m_Browser; - int m_BrowserId; - bool m_bIsClosing; + CefRefPtr BrowserRef; + int BrowserId; + bool bIsClosing; public: - BrowserClient(RenderHandler* renderHandler) : m_renderHandler(renderHandler) + BrowserClient(RenderHandler* InRenderHandler) : RenderHandlerRef(InRenderHandler) { }; virtual CefRefPtr GetRenderHandler() { - return m_renderHandler; + return RenderHandlerRef; }; // Getter for renderer virtual CefRefPtr GetRenderHandlerCustom() { - return m_renderHandler; + return RenderHandlerRef; }; // Getter for lifespan @@ -76,43 +63,73 @@ class BrowserClient : public CefClient, public CefLifeSpanHandler, public CefDow { return this; } + //required or pdf download won't work + virtual CefRefPtr GetDownloadHandler() override + { + return this; + } + + virtual bool OnProcessMessageReceived(CefRefPtr Browser, + CefRefPtr Frame, + CefProcessId SourceProcess, + CefRefPtr Message) override; - virtual bool OnProcessMessageReceived(CefRefPtr browser, CefProcessId source_process, CefRefPtr message) override; - void SetEventEmitter(FScriptEvent* emitter); + virtual void OnUncaughtException(CefRefPtr Browser, + CefRefPtr Frame, + CefRefPtr Context, + CefRefPtr Exception, + CefRefPtr StackTrace); + + void SetEventEmitter(FScriptEvent* Emitter); + void SetLogEmitter(FLogEvent* Emitter); //CefDownloadHandler virtual void OnBeforeDownload( - CefRefPtr browser, - CefRefPtr download_item, - const CefString& suggested_name, - CefRefPtr callback) override; + CefRefPtr Browser, + CefRefPtr DownloadItem, + const CefString& SuggestedName, + CefRefPtr Callback) override; virtual void OnDownloadUpdated( - CefRefPtr browser, - CefRefPtr download_item, - CefRefPtr callback) override; + CefRefPtr Browser, + CefRefPtr DownloadItem, + CefRefPtr Callback) override; //CefLifeSpanHandler - virtual bool OnBeforePopup(CefRefPtr browser, - CefRefPtr frame, - const CefString& target_url, - const CefString& target_frame_name, - WindowOpenDisposition target_disposition, - bool user_gesture, - const CefPopupFeatures& popupFeatures, - CefWindowInfo& windowInfo, - CefRefPtr& client, - CefBrowserSettings& settings, - bool* no_javascript_access) override - { + virtual bool OnBeforePopup(CefRefPtr Browser, + CefRefPtr Frame, + const CefString& TargetUrl, + const CefString& TargetFrameName, + WindowOpenDisposition TargetDisposition, + bool UserGesture, + const CefPopupFeatures& PopupFeatures, + CefWindowInfo& WindowInfo, + CefRefPtr& Client, + CefBrowserSettings& Settings, + CefRefPtr& ExtraInfo, + bool* NoJavascriptAccess) { return false; } // Lifespan methods - void OnAfterCreated(CefRefPtr browser) override; - void OnBeforeClose(CefRefPtr browser) override; + void OnAfterCreated(CefRefPtr Browser) override; + void OnBeforeClose(CefRefPtr Browser) override; + + virtual bool OnConsoleMessage(CefRefPtr Browser, + cef_log_severity_t Level, + const CefString& Message, + const CefString& Source, + int Line) override; + + virtual void OnFullscreenModeChange(CefRefPtr< CefBrowser > Browser, bool Fullscreen) override; + + virtual void OnTitleChange(CefRefPtr< CefBrowser > Browser, const CefString& Title); + + CefRefPtr GetCEFBrowser(); // NOTE: Must be at bottom public: - IMPLEMENT_REFCOUNTING(BrowserClient) -}; \ No newline at end of file + IMPLEMENT_REFCOUNTING(BrowserClient); +}; + + diff --git a/Source/BluLoader/BluLoader.Build.cs b/Source/BluLoader/BluLoader.Build.cs index f7df2b2..f6b2e3f 100644 --- a/Source/BluLoader/BluLoader.Build.cs +++ b/Source/BluLoader/BluLoader.Build.cs @@ -6,7 +6,7 @@ public class BluLoader : ModuleRules { public BluLoader(ReadOnlyTargetRules Target) : base(Target) { - PublicDependencyModuleNames.AddRange( + PublicDependencyModuleNames.AddRange( new string[] { "Core", diff --git a/Source/BluLoader/Private/BluLoader.cpp b/Source/BluLoader/Private/BluLoader.cpp index d4850d0..2d9304c 100644 --- a/Source/BluLoader/Private/BluLoader.cpp +++ b/Source/BluLoader/Private/BluLoader.cpp @@ -1,6 +1,12 @@ -#include "BluLoaderPrivatePCH.h" +#include "IBluLoader.h" +#include "CoreMinimal.h" +#include "Misc/Paths.h" #include +#if PLATFORM_WINDOWS +#include "Windows/WindowsPlatformProcess.h" +#endif + class FBluLoader : public IBluLoader { diff --git a/Source/BluLoader/Private/BluLoaderPrivatePCH.h b/Source/BluLoader/Private/BluLoaderPrivatePCH.h deleted file mode 100644 index d51e888..0000000 --- a/Source/BluLoader/Private/BluLoaderPrivatePCH.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -#include "CoreUObject.h" -#include "Engine.h" -#include "Engine/Console.h" - -#include "ModuleManager.h" -#include "IBluLoader.h" - -DECLARE_LOG_CATEGORY_EXTERN(LogBluLoader, Log, All); diff --git a/Source/BluLoader/Public/IBluLoader.h b/Source/BluLoader/Public/IBluLoader.h index e8137ca..a96f81b 100644 --- a/Source/BluLoader/Public/IBluLoader.h +++ b/Source/BluLoader/Public/IBluLoader.h @@ -2,7 +2,9 @@ * (c) Aaron M. Shea 2014 */ #pragma once -#include "ModuleManager.h" +#include "Modules/ModuleManager.h" + +DECLARE_LOG_CATEGORY_EXTERN(LogBluLoader, Log, All); class IBluLoader : public IModuleInterface { diff --git a/builder/README.md b/builder/README.md index e88d9b1..8763130 100644 --- a/builder/README.md +++ b/builder/README.md @@ -1,6 +1,8 @@ -### BLUI Build Script +### BLUI CEF Chromium Build Script -#### Windows Steps +Current CEF building instructions: https://github.com/getnamo/blubrowser + +#### Archived - Windows Steps Requirements: ``` diff --git a/builder/builder.py b/builder/archived_builder.py similarity index 100% rename from builder/builder.py rename to builder/archived_builder.py