Skip to content

Commit

Permalink
Merge branch 'sub-path'
Browse files Browse the repository at this point in the history
  • Loading branch information
getnamo committed Dec 14, 2021
2 parents 0053606 + daa22ea commit a956c23
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 31 deletions.
2 changes: 1 addition & 1 deletion BLUI.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"FileVersion": 3,
"FriendlyName": "BLUI",
"Version": 3,
"VersionName": "4.3.0",
"VersionName": "4.3.1",
"Description": "Chromium Embedded Framework (CEF) powered HTML UI and HUD for Unreal Engine 4",
"Category": "UI",
"CreatedBy": "Aaron M. Shea, Getnamo, & Contributors",
Expand Down
Binary file modified Content/BluiWidget.uasset
Binary file not shown.
Binary file modified Content/BluiWorldWidgetActorExample.uasset
Binary file not shown.
1 change: 1 addition & 0 deletions Source/Blu/Blu.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public Blu(ReadOnlyTargetRules Target) : base(Target)
"Core",
"CoreUObject",
"Engine",
"Projects",
"InputCore",
"RenderCore",
"RHI",
Expand Down
3 changes: 2 additions & 1 deletion Source/Blu/Private/Blu.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "IBlu.h"
#include "Interfaces/IPluginManager.h"
#include "BluManager.h"

class FBlu : public IBlu
Expand All @@ -8,7 +9,7 @@ class FBlu : public IBlu
virtual void StartupModule() override
{
CefString GameDirCef = *FPaths::ConvertRelativePathToFull(FPaths::ProjectDir() + "BluCache");
FString ExecutablePath = FPaths::ConvertRelativePathToFull(FPaths::ProjectDir() + "Plugins/BLUI/ThirdParty/cef/");
FString ExecutablePath = FPaths::ConvertRelativePathToFull(IPluginManager::Get().FindPlugin("BLUI")->GetBaseDir() + "/ThirdParty/cef/");

// Setup the default settings for BluManager
BluManager::Settings.windowless_rendering_enabled = true;
Expand Down
44 changes: 24 additions & 20 deletions Source/Blu/Private/BluEye.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ FBluEyeSettings::FBluEyeSettings()
{
FrameRate = 60.f;

Width = 1280;
Height = 720;
ViewSize.X = 1280;
ViewSize.Y = 720;

bIsTransparent = false;
bEnableWebGL = true;
bAudioMuted = false;
bAutoPlayEnabled = true;
bDebugLogTick = false;
}

UBluEye::UBluEye(const class FObjectInitializer& PCIP)
Expand All @@ -41,7 +42,7 @@ void UBluEye::Init()
}
}

if (Settings.Width <= 0 || Settings.Height <= 0)
if (Settings.ViewSize.X <= 0 || Settings.ViewSize.Y <= 0)
{
UE_LOG(LogBlu, Log, TEXT("Can't initialize when Width or Height are <= 0"));
return;
Expand All @@ -53,8 +54,8 @@ void UBluEye::Init()
//BrowserSettings.web_security = STATE_DISABLED;
//BrowserSettings.fullscreen_enabled = true;

Info.width = Settings.Width;
Info.height = Settings.Height;
Info.width = (int32)Settings.ViewSize.X;
Info.height = (int32)Settings.ViewSize.Y;

// Set transparant option
Info.SetAsWindowless(0); //bIsTransparent
Expand All @@ -72,7 +73,7 @@ void UBluEye::Init()
//NB: this setting will change it globally for all new instances
BluManager::AutoPlay = Settings.bAutoPlayEnabled;

Renderer = new RenderHandler(Settings.Width, Settings.Height, this);
Renderer = new RenderHandler(Settings.ViewSize.X, Settings.ViewSize.Y, this);
ClientHandler = new BrowserClient(Renderer);
Browser = CefBrowserHost::CreateBrowserSync(
Info,
Expand Down Expand Up @@ -112,7 +113,7 @@ void UBluEye::ResetTexture()


// init the new Texture2D
Texture = UTexture2D::CreateTransient(Settings.Width, Settings.Height, PF_B8G8R8A8);
Texture = UTexture2D::CreateTransient(Settings.ViewSize.X, Settings.ViewSize.Y, PF_B8G8R8A8);
Texture->AddToRoot();
Texture->UpdateResource();

Expand Down Expand Up @@ -163,11 +164,11 @@ void UBluEye::TextureUpdate(const void *buffer, FUpdateTextureRegion2D *updateRe
RegionData->Texture2DResource = (FTextureResource*)Texture->Resource;
RegionData->NumRegions = regionCount;
RegionData->SrcBpp = 4;
RegionData->SrcPitch = Settings.Width * 4;
RegionData->SrcPitch = int32(Settings.ViewSize.X) * 4;
RegionData->Regions = updateRegions;

//We need to copy this memory or it might get uninitialized
RegionData->SrcData.SetNumUninitialized(RegionData->SrcPitch * Settings.Height);
RegionData->SrcData.SetNumUninitialized(RegionData->SrcPitch * int32(Settings.ViewSize.Y));
FPlatformMemory::Memcpy(RegionData->SrcData.GetData(), buffer, RegionData->SrcData.Num());

ENQUEUE_RENDER_COMMAND(UpdateBLUICommand)(
Expand Down Expand Up @@ -329,16 +330,16 @@ UTexture2D* UBluEye::ResizeBrowser(const int32 NewWidth, const int32 NewHeight)
bEnabled = false;

// Set our new Width and Height
Settings.Width = NewWidth;
Settings.Height = NewHeight;
Settings.ViewSize.X = NewWidth;
Settings.ViewSize.Y = NewHeight;

// Update our render handler
Renderer->Width = NewWidth;
Renderer->Height = NewHeight;

bValidTexture = false;

Texture = UTexture2D::CreateTransient(Settings.Width, Settings.Height, PF_B8G8R8A8);
Texture = UTexture2D::CreateTransient(Settings.ViewSize.X, Settings.ViewSize.Y, PF_B8G8R8A8);
Texture->AddToRoot();
Texture->UpdateResource();

Expand All @@ -363,16 +364,16 @@ UTexture2D* UBluEye::CropWindow(const int32 Y, const int32 X, const int32 NewWid


// Set our new Width and Height
Settings.Width = NewWidth;
Settings.Height = NewHeight;
Settings.ViewSize.X = NewWidth;
Settings.ViewSize.Y = NewHeight;

// Update our render handler
Renderer->Width = NewWidth;
Renderer->Height = NewHeight;

bValidTexture = false;

Texture = UTexture2D::CreateTransient(Settings.Width, Settings.Height, PF_B8G8R8A8);
Texture = UTexture2D::CreateTransient(Settings.ViewSize.X, Settings.ViewSize.Y, PF_B8G8R8A8);
Texture->AddToRoot();
Texture->UpdateResource();

Expand All @@ -395,8 +396,8 @@ UBluEye* UBluEye::SetProperties(const int32 SetWidth,
const FName& SetTextureParameterName,
UMaterialInterface* SetBaseMaterial)
{
Settings.Width = SetWidth;
Settings.Height = SetHeight;
Settings.ViewSize.X = SetWidth;
Settings.ViewSize.Y = SetHeight;

bEnabled = SetEnabled;

Expand Down Expand Up @@ -626,11 +627,14 @@ void UBluEye::SpawnTickEventLoopIfNeeded()
{
if (!EventLoopData.DelegateHandle.IsValid())
{
EventLoopData.DelegateHandle = FTicker::GetCoreTicker().AddTicker(FTickerDelegate::CreateLambda([](float DeltaTime)
EventLoopData.DelegateHandle = FTicker::GetCoreTicker().AddTicker(FTickerDelegate::CreateLambda([&](float DeltaTime)
{
if (EventLoopData.bShouldTickEventLoop)
{
//UE_LOG(LogTemp, Log, TEXT("Delta: %1.2f"), DeltaTime);
if (Settings.bDebugLogTick)
{
UE_LOG(LogTemp, Log, TEXT("Delta: %1.2f"), DeltaTime);
}
BluManager::DoBluMessageLoop();
}

Expand All @@ -645,7 +649,7 @@ UTexture2D* UBluEye::GetTexture() const
{
if (!Texture)
{
return UTexture2D::CreateTransient(Settings.Width, Settings.Height, PF_B8G8R8A8);
return UTexture2D::CreateTransient(Settings.ViewSize.X, Settings.ViewSize.Y, PF_B8G8R8A8);
}

return Texture;
Expand Down
3 changes: 2 additions & 1 deletion Source/Blu/Private/RenderHandler.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "RenderHandler.h"
#include "Interfaces/IPluginManager.h"
#include "BluEye.h"

RenderHandler::RenderHandler(int32 Width, int32 Height, UBluEye* UI)
Expand Down Expand Up @@ -115,7 +116,7 @@ FString ReversePathSlashes(FString ForwardPath)
}
FString UtilityBLUIDownloadsFolder()
{
return ReversePathSlashes(FPaths::ConvertRelativePathToFull(FPaths::ProjectDir() + "Plugins/BLUI/Downloads/"));
return ReversePathSlashes(FPaths::ConvertRelativePathToFull(IPluginManager::Get().FindPlugin("BLUI")->GetBaseDir() + "/Downloads/"));
}


Expand Down
11 changes: 5 additions & 6 deletions Source/Blu/Public/BluTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,9 @@ struct FBluEyeSettings
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Blu")
bool bIsTransparent;

/** Width of the view resolution */
/** Width(X) and Height(Y) of the view resolution */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Blu")
int32 Width;

/** Height of the view resolution */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Blu")
int32 Height;
FVector2D ViewSize;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Blu")
bool bEnableWebGL;
Expand All @@ -86,6 +82,9 @@ struct FBluEyeSettings
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Blu")
bool bAutoPlayEnabled;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Blu")
bool bDebugLogTick;

FBluEyeSettings();
};

Expand Down
3 changes: 2 additions & 1 deletion Source/BluLoader/BluLoader.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public BluLoader(ReadOnlyTargetRules Target) : base(Target)
{
"Core",
"CoreUObject",
"Engine"
"Engine",
"Projects"
});
}
}
3 changes: 2 additions & 1 deletion Source/BluLoader/Private/BluLoader.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "IBluLoader.h"
#include "Interfaces/IPluginManager.h"
#include "CoreMinimal.h"
#include "Misc/Paths.h"
#include <string>
Expand All @@ -13,7 +14,7 @@ class FBluLoader : public IBluLoader
/** IModuleInterface implementation */
virtual void StartupModule() override
{
FString LibPath = FPaths::ConvertRelativePathToFull(FPaths::ProjectDir() + "Plugins/BLUI/ThirdParty/cef/");
FString LibPath = FPaths::ConvertRelativePathToFull(IPluginManager::Get().FindPlugin("BLUI")->GetBaseDir() + "/ThirdParty/cef/");

// If we're on Windows we need to load DLLs from our custom path
#if PLATFORM_WINDOWS
Expand Down

0 comments on commit a956c23

Please sign in to comment.