removed unused methods(BeginPlay, Tick) and added rider plugin
This commit is contained in:
119
Plugins/Developer/RiderLink/Source/RiderLC/Private/RiderLC.cpp
Normal file
119
Plugins/Developer/RiderLink/Source/RiderLC/Private/RiderLC.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
#include "RiderLC.hpp"
|
||||
|
||||
#include "IRiderLink.hpp"
|
||||
#include "RdEditorModel/RdEditorModel.Pregenerated.h"
|
||||
|
||||
#include "Async/Async.h"
|
||||
#if WITH_LIVE_CODING
|
||||
#include "ILiveCodingModule.h"
|
||||
#endif
|
||||
#include "Misc/HotReloadInterface.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FRiderLCModule"
|
||||
|
||||
DEFINE_LOG_CATEGORY(FLogRiderLCModule);
|
||||
|
||||
IMPLEMENT_MODULE(FRiderLCModule, RiderLC)
|
||||
|
||||
const FName HotReloadModule("HotReload");
|
||||
|
||||
void FRiderLCModule::SetupLiveCodingBinds()
|
||||
{
|
||||
IRiderLinkModule& RiderLinkModule = IRiderLinkModule::Get();
|
||||
RiderLinkModule.ViewModel(ModuleLifetimeDef.lifetime, [](const rd::Lifetime& Lifetime, JetBrains::EditorPlugin::RdEditorModel const& RdEditorModel)
|
||||
{
|
||||
RdEditorModel.get_triggerHotReload().advise(Lifetime, []
|
||||
{
|
||||
AsyncTask(ENamedThreads::GameThread, []
|
||||
{
|
||||
#if WITH_LIVE_CODING
|
||||
ILiveCodingModule* LiveCoding = FModuleManager::GetModulePtr<ILiveCodingModule>(LIVE_CODING_MODULE_NAME);
|
||||
if (LiveCoding != nullptr && LiveCoding->IsEnabledByDefault())
|
||||
{
|
||||
LiveCoding->EnableForSession(true);
|
||||
if (LiveCoding->IsEnabledForSession())
|
||||
{
|
||||
LiveCoding->Compile();
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#if WITH_HOT_RELOAD
|
||||
IHotReloadInterface* HotReload = FModuleManager::GetModulePtr<IHotReloadInterface>(HotReloadModule);
|
||||
if (HotReload != nullptr && !HotReload->IsCurrentlyCompiling())
|
||||
{
|
||||
HotReload->DoHotReloadFromEditor(EHotReloadFlags::None);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
bool FRiderLCModule::Tick(float DeltaTime)
|
||||
{
|
||||
bool bIsAvailable = false;
|
||||
bool bIsCompiling = false;
|
||||
#if WITH_LIVE_CODING
|
||||
const ILiveCodingModule* LiveCoding = FModuleManager::GetModulePtr<ILiveCodingModule>(LIVE_CODING_MODULE_NAME);
|
||||
if (LiveCoding != nullptr && LiveCoding->IsEnabledByDefault())
|
||||
{
|
||||
bIsAvailable = true;
|
||||
bIsCompiling = LiveCoding->IsCompiling();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#if WITH_HOT_RELOAD
|
||||
const IHotReloadInterface* HotReload = FModuleManager::GetModulePtr<IHotReloadInterface>(HotReloadModule);
|
||||
if (HotReload != nullptr)
|
||||
{
|
||||
bIsAvailable = true;
|
||||
bIsCompiling = HotReload->IsCurrentlyCompiling();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
IRiderLinkModule& RiderLinkModule = IRiderLinkModule::Get();
|
||||
RiderLinkModule.QueueModelAction([bIsAvailable, bIsCompiling](JetBrains::EditorPlugin::RdEditorModel const& RdEditorModel)
|
||||
{
|
||||
RdEditorModel.get_isHotReloadAvailable().set(bIsAvailable);
|
||||
RdEditorModel.get_isHotReloadCompiling().set(bIsCompiling);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FRiderLCModule::StartupModule()
|
||||
{
|
||||
UE_LOG(FLogRiderLCModule, Verbose, TEXT("RiderLC STARTUP START"));
|
||||
|
||||
const IRiderLinkModule& RiderLinkModule = IRiderLinkModule::Get();
|
||||
ModuleLifetimeDef = RiderLinkModule.CreateNestedLifetimeDefinition();
|
||||
SetupLiveCodingBinds();
|
||||
TickDelegate = FTickerDelegate::CreateRaw(this, &FRiderLCModule::Tick);
|
||||
#if ENGINE_MAJOR_VERSION < 5
|
||||
TickDelegateHandle = FTicker::GetCoreTicker().AddTicker(TickDelegate);
|
||||
#else
|
||||
TickDelegateHandle = FTSTicker::GetCoreTicker().AddTicker(TickDelegate);
|
||||
#endif
|
||||
|
||||
UE_LOG(FLogRiderLCModule, Verbose, TEXT("RiderLC STARTUP FINISH"));
|
||||
}
|
||||
|
||||
void FRiderLCModule::ShutdownModule()
|
||||
{
|
||||
UE_LOG(FLogRiderLCModule, Verbose, TEXT("RiderLC SHUTDOWN START"));
|
||||
|
||||
#if ENGINE_MAJOR_VERSION < 5
|
||||
FTicker::GetCoreTicker().RemoveTicker(TickDelegateHandle);
|
||||
#else
|
||||
FTSTicker::GetCoreTicker().RemoveTicker(TickDelegateHandle);
|
||||
#endif
|
||||
ModuleLifetimeDef.terminate();
|
||||
|
||||
UE_LOG(FLogRiderLCModule, Verbose, TEXT("RiderLC SHUTDOWN FINISH"));
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Containers/Ticker.h"
|
||||
#include "lifetime/LifetimeDefinition.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
#include "Runtime/Launch/Resources/Version.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(FLogRiderLCModule, Log, All);
|
||||
|
||||
class FRiderLCModule : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
virtual bool SupportsDynamicReloading() override { return true; }
|
||||
void SetupLiveCodingBinds();
|
||||
|
||||
private:
|
||||
bool Tick(float DeltaTime);
|
||||
|
||||
rd::LifetimeDefinition ModuleLifetimeDef;
|
||||
FTickerDelegate TickDelegate;
|
||||
#if ENGINE_MAJOR_VERSION < 5
|
||||
FDelegateHandle TickDelegateHandle;
|
||||
#else
|
||||
FTSTicker::FDelegateHandle TickDelegateHandle;
|
||||
#endif
|
||||
};
|
||||
36
Plugins/Developer/RiderLink/Source/RiderLC/RiderLC.Build.cs
Normal file
36
Plugins/Developer/RiderLink/Source/RiderLC/RiderLC.Build.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class RiderLC : ModuleRules
|
||||
{
|
||||
public RiderLC(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
|
||||
|
||||
PrivateDefinitions.Add("_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING");
|
||||
PrivateDefinitions.Add("_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS");
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
"Engine",
|
||||
"RiderLink",
|
||||
"RD"
|
||||
}
|
||||
);
|
||||
|
||||
if (Target.bWithLiveCoding)
|
||||
{
|
||||
PrivateIncludePathModuleNames.Add("LiveCoding");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user