removed unused methods(BeginPlay, Tick) and added rider plugin

This commit is contained in:
Caleb Buhungiro
2025-07-05 15:04:21 +08:00
parent a98fd4b2a7
commit 58a7fc2f55
416 changed files with 64917 additions and 16 deletions

View File

@@ -0,0 +1,83 @@
#include "BlueprintProvider.hpp"
#include "Async/Async.h"
#include "AssetEditorMessages.h"
#include "BlueprintEditor.h"
#include "MessageEndpointBuilder.h"
#include "MessageEndpoint.h"
#include "Kismet2/KismetEditorUtilities.h"
#include "Runtime/Launch/Resources/Version.h"
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION <= 23
#include "Toolkits/AssetEditorManager.h"
#endif
#include "Kismet2/BlueprintEditorUtils.h"
#include "Model/RdEditorProtocol/RdEditorModel/RdEditorModel.Pregenerated.h"
#if ENGINE_MAJOR_VERSION < 5
#include "AssetData.h"
#else
#include "AssetRegistry/AssetData.h"
#endif
void BluePrintProvider::AddAsset(FAssetData const& AssetData) {
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION <= 23
UObject* cls = AssetData.GetAsset();
#else
UObject* cls = AssetData.FastGetAsset();
#endif
if (cls) {
UBlueprint* Blueprint = Cast<UBlueprint>(cls);
if (Blueprint && Blueprint->IsValidLowLevel()) {
}
}
}
bool BluePrintProvider::IsBlueprint(FString const& pathName) {
return FPackageName::IsValidObjectPath(pathName);
}
void BluePrintProvider::OpenBlueprint(JetBrains::EditorPlugin::BlueprintReference const& BlueprintReference, TSharedPtr<FMessageEndpoint, ESPMode::ThreadSafe> const& messageEndpoint) {
// Just to create asset manager if it wasn't created already
const FString AssetPathName = BlueprintReference.get_pathName();
FGuid AssetGuid;
bool bIsValidGuid = FGuid::Parse(BlueprintReference.get_guid(), AssetGuid);
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION <= 23
FAssetEditorManager::Get();
messageEndpoint->Publish(new FAssetEditorRequestOpenAsset(AssetPathName), EMessageScope::Process);
#else
AsyncTask(ENamedThreads::GameThread, [AssetPathName, AssetGuid, bIsValidGuid]()
{
// An asset needs loading
UPackage* Package = LoadPackage(nullptr, *AssetPathName, LOAD_NoRedirects);
if (Package)
{
Package->FullyLoad();
const FString AssetName = FPaths::GetBaseFilename(AssetPathName);
UObject* Object = FindObject<UObject>(Package, *AssetName);
const UBlueprint* Blueprint = Cast<UBlueprint>(Object);
if(bIsValidGuid && Blueprint != nullptr)
{
UEdGraphNode* EdGraphNode = FBlueprintEditorUtils::GetNodeByGUID(Blueprint, AssetGuid);
if(EdGraphNode != nullptr)
{
FKismetEditorUtilities::BringKismetToFocusAttentionOnObject(EdGraphNode);
}
else
{
FKismetEditorUtilities::BringKismetToFocusAttentionOnObject(Blueprint);
}
}
else if(Object != nullptr)
{
GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->OpenEditorForAsset(Object);
}
}
});
#endif
}

View File

@@ -0,0 +1,108 @@
#include "RiderBlueprint.hpp"
#include "BlueprintProvider.hpp"
#include "IRiderLink.hpp"
#include "Model/RdEditorProtocol/RdEditorModel/RdEditorModel.Pregenerated.h"
#include "Engine/Blueprint.h"
#include "Framework/Docking/TabManager.h"
#include "HAL/PlatformProcess.h"
#include "MessageEndpoint.h"
#include "MessageEndpointBuilder.h"
#include "Modules/ModuleManager.h"
#include "Runtime/Launch/Resources/Version.h"
#if ENGINE_MAJOR_VERSION < 5
#include "AssetRegistryModule.h"
#else
#include "AssetRegistry/AssetRegistryModule.h"
#endif
#define LOCTEXT_NAMESPACE "RiderBlueprint"
DEFINE_LOG_CATEGORY(FLogRiderBlueprintModule);
IMPLEMENT_MODULE(FRiderBlueprintModule, RiderBlueprint);
static void AllowSetForeGroundForEditor(JetBrains::EditorPlugin::RdEditorModel const & unrealToBackendModel) {
static const int32 CurrentProcessId = FPlatformProcess::GetCurrentProcessId();
try {
const rd::WiredRdTask<bool> Task = unrealToBackendModel.get_allowSetForegroundWindow().sync(CurrentProcessId);
if (Task.is_faulted()) {
UE_LOG(FLogRiderBlueprintModule, Error, TEXT("AllowSetForeGroundForEditor failed: %hs "), rd::to_string(Task.value_or_throw()).c_str());
}
else if (Task.is_succeeded()) {
if (!(Task.value_or_throw().unwrap())) {
UE_LOG(FLogRiderBlueprintModule, Error, TEXT("AllowSetForeGroundForEditor failed: %hs "), rd::to_string(Task.value_or_throw()).c_str());
}
}
}
catch (std::exception const &e) {
UE_LOG(FLogRiderBlueprintModule, Error, TEXT("AllowSetForeGroundForEditor failed: %hs "), rd::to_string(e).c_str());
}
}
void FRiderBlueprintModule::StartupModule()
{
UE_LOG(FLogRiderBlueprintModule, Verbose, TEXT("STARTUP START"));
IRiderLinkModule& RiderLinkModule = IRiderLinkModule::Get();
ModuleLifetimeDef = RiderLinkModule.CreateNestedLifetimeDefinition();
const FAssetRegistryModule* AssetRegistryModule = &FModuleManager::LoadModuleChecked<FAssetRegistryModule>
(AssetRegistryConstants::ModuleName);
MessageEndpoint = FMessageEndpoint::Builder(FName("FAssetEditorManager")).Build();
AssetRegistryModule->Get().OnAssetAdded().AddLambda([](const FAssetData& AssetData) {
// TO-DO: Fix loading uasset's on 4.23-
// BluePrintProvider::AddAsset(AssetData);
});
RiderLinkModule.ViewModel(ModuleLifetimeDef.lifetime, [this] (rd::Lifetime ModelLifetime, JetBrains::EditorPlugin::RdEditorModel const& UnrealToBackendModel)
{
UnrealToBackendModel.get_openBlueprint().advise(
ModelLifetime,
[this, &UnrealToBackendModel](
JetBrains::EditorPlugin::BlueprintReference const& s)
{
try
{
AllowSetForeGroundForEditor(UnrealToBackendModel);
auto Window = FGlobalTabmanager::Get()->GetRootWindow();
if (!Window.IsValid()) return;
if (Window->IsWindowMinimized())
{
Window->Restore();
}
else
{
Window->HACK_ForceToFront();
}
BluePrintProvider::OpenBlueprint(s, MessageEndpoint);
}
catch (std::exception const& e)
{
std::cerr << rd::to_string(e);
}
}
);
UnrealToBackendModel.get_isBlueprintPathName().set([](FString const& pathName) -> bool
{
return BluePrintProvider::IsBlueprint(pathName);
});
});
UE_LOG(FLogRiderBlueprintModule, Verbose, TEXT("STARTUP FINISH"));
}
void FRiderBlueprintModule::ShutdownModule()
{
UE_LOG(FLogRiderBlueprintModule, Verbose, TEXT("SHUTDOWN START"));
ModuleLifetimeDef.terminate();
UE_LOG(FLogRiderBlueprintModule, Verbose, TEXT("SHUTDOWN FINISH"));
}
#undef LOCTEXT_NAMESPACE

View File

@@ -0,0 +1,25 @@
#pragma once
#include "Delegates/Delegate.h"
namespace JetBrains
{
namespace EditorPlugin
{
class BlueprintReference;
}
}
struct FAssetData;
class FMessageEndpoint;
class UBlueprint;
class RIDERBLUEPRINT_API BluePrintProvider {
public:
static void AddAsset(FAssetData const& AssetData);
static bool IsBlueprint(FString const& pathName);
static void OpenBlueprint(JetBrains::EditorPlugin::BlueprintReference const& path, TSharedPtr<FMessageEndpoint, ESPMode::ThreadSafe> const& messageEndpoint);
};

View File

@@ -0,0 +1,26 @@
#pragma once
#include "lifetime/LifetimeDefinition.h"
#include "Logging/LogMacros.h"
#include "Logging/LogVerbosity.h"
#include "MessageEndpoint.h"
#include "Modules/ModuleInterface.h"
#include "Templates/SharedPointer.h"
DECLARE_LOG_CATEGORY_EXTERN(FLogRiderBlueprintModule, Log, All);
class FRiderBlueprintModule : public IModuleInterface
{
public:
FRiderBlueprintModule() = default;
virtual ~FRiderBlueprintModule() override = default;
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
virtual bool SupportsDynamicReloading() override { return true; };
private:
TSharedPtr<FMessageEndpoint, ESPMode::ThreadSafe> MessageEndpoint;
rd::LifetimeDefinition ModuleLifetimeDef;
};

View File

@@ -0,0 +1,35 @@
using UnrealBuildTool;
public class RiderBlueprint : ModuleRules
{
public RiderBlueprint(ReadOnlyTargetRules Target) : base(Target)
{
#if UE_4_22_OR_LATER
PCHUsage = PCHUsageMode.NoPCHs;
#else
PCHUsage = PCHUsageMode.NoSharedPCHs;
#endif
bUseRTTI = true;
#if UE_5_2_OR_LATER
bDisableStaticAnalysis = true;
#endif
PublicDependencyModuleNames.Add("RD");
PrivateDependencyModuleNames.AddRange(new []
{
"Core",
"SlateCore",
"RiderLink",
"Slate",
"AssetRegistry",
"MessagingCommon",
"UnrealEd",
"UnrealEdMessages",
"Engine",
"CoreUObject"
});
}
}