Space Plunder
Loading...
Searching...
No Matches
AReplaySpectatorController Class Reference

#include <ReplaySpectatorController.h>

Inheritance diagram for AReplaySpectatorController:

Public Member Functions

 AReplaySpectatorController (const FObjectInitializer &ObjectInitializer)
 
bool SetCurrentReplayPausedState (const bool bPause)
 
void RestartReplay ()
 
void RewindReplay ()
 
int32 GetCurrentReplayTotalTimeInSeconds () const
 ** Gets the Max Number of Seconds that were recorded in the current Replay *‍/
 
int32 GetCurrentReplayCurrentTimeInSeconds () const
 ** Gets the Second we are currently watching in the Replay *‍/
 
void SetCurrentReplayTimeToSeconds (const int32 Seconds) const
 ** Jumps to the specified Second in the Replay we are watching *‍/
 
void SetCurrentReplayPlayRate (const float PlayRate=1.f) const
 ** Changes the PlayRate of the Replay we are watching, enabling FastForward or SlowMotion *‍/
 
void SetReplayCheckpoint () const
 
void OpenReplayMenu ()
 

Protected Member Functions

virtual void BeginPlay () override
 

Protected Attributes

int32 PreviousAASetting = 0
 
int32 PreviousMBSetting = 0
 
class UReplayViewerReplayViewerWidget
 
TSubclassOf< class UReplayViewerReplayViewerWidgetClass
 

Private Attributes

bool bReplayMenuOpen = false
 

Constructor & Destructor Documentation

◆ AReplaySpectatorController()

AReplaySpectatorController::AReplaySpectatorController ( const FObjectInitializer & ObjectInitializer)
13 : APlayerController(ObjectInitializer)
14{
15 bShowMouseCursor = true;
16 PrimaryActorTick.bTickEvenWhenPaused = true;
17 bShouldPerformFullTickWhenPaused = true;
18 ReplayViewerWidget = nullptr;
19
20 const ConstructorHelpers::FClassFinder<UReplayViewer> ReplayViewerWidgetBP(TEXT("/MenuSystem/Widgets/Replays/WBP_ReplayViewer"));
21 if (!ensure(ReplayViewerWidgetBP.Class != nullptr)) return;
22 ReplayViewerWidgetClass = ReplayViewerWidgetBP.Class;
23
24}
class UReplayViewer * ReplayViewerWidget
Definition ReplaySpectatorController.h:31
TSubclassOf< class UReplayViewer > ReplayViewerWidgetClass
Definition ReplaySpectatorController.h:34

Member Function Documentation

◆ BeginPlay()

void AReplaySpectatorController::BeginPlay ( )
overrideprotectedvirtual
27{
28 Super::BeginPlay();
29 //- Only create if is local controller, otherwise will try and create while creating clip //
30 if(IsLocalController())
31 {
32 ReplayViewerWidget = CreateWidget<UReplayViewer>(this, ReplayViewerWidgetClass);
33 if(ReplayViewerWidget == nullptr){UE_LOG(LogMenuSystem, Error, TEXT("Replay Viewer Failed to Create in Replay Spectator"));}
34 if(ReplayViewerWidget != nullptr)
35 {
37 ReplayViewerWidget->AddToViewport();
38 }
39 }
40}
void SetReplayController(AReplaySpectatorController *Controller)
Definition ReplayViewer.h:59

◆ GetCurrentReplayCurrentTimeInSeconds()

int32 AReplaySpectatorController::GetCurrentReplayCurrentTimeInSeconds ( ) const

** Gets the Second we are currently watching in the Replay *‍/

107{
108 if(GetWorld() != nullptr && GetWorld()->GetDemoNetDriver() != nullptr)
109 {
110 return GetWorld()->GetDemoNetDriver()->GetDemoCurrentTime();
111 }
112 return 0;
113}

◆ GetCurrentReplayTotalTimeInSeconds()

int32 AReplaySpectatorController::GetCurrentReplayTotalTimeInSeconds ( ) const

** Gets the Max Number of Seconds that were recorded in the current Replay *‍/

98{
99 if(GetWorld() != nullptr && GetWorld()->GetDemoNetDriver() != nullptr)
100 {
101 return GetWorld()->GetDemoNetDriver()->GetDemoTotalTime();
102 }
103 return 0;
104}

◆ OpenReplayMenu()

void AReplaySpectatorController::OpenReplayMenu ( )
141{
142 if(GetGameInstance() != nullptr)
143 {
144 IReplayClipInterface* ReplayClipInterface = Cast<IReplayClipInterface>(GetGameInstance());
145 if(ReplayClipInterface != nullptr)
146 {
147 bReplayMenuOpen = ReplayClipInterface->OpenReplayMenu(this, true);
148 }
149 }
150}
bool bReplayMenuOpen
Definition ReplaySpectatorController.h:71
Definition ReplayClipInterface.h:20
virtual bool OpenReplayMenu(APlayerController *Player, const bool bOpen=true)=0

◆ RestartReplay()

void AReplaySpectatorController::RestartReplay ( )
81{
82 if(GetWorld() != nullptr && GetWorld()->GetDemoNetDriver() != nullptr)
83 {
84 GetWorld()->GetDemoNetDriver()->GotoTimeInSeconds(0);
85 }
86}

◆ RewindReplay()

void AReplaySpectatorController::RewindReplay ( )
89{
90 if(GetWorld() != nullptr && GetWorld()->GetWorldSettings() != nullptr)
91 {
92 GetWorld()->GetWorldSettings()->RewindForReplay();
93 // GetWorld()->GetWorldSettings()->DemoPlayTimeDilation *= -1.0;
94 }
95}

◆ SetCurrentReplayPausedState()

bool AReplaySpectatorController::SetCurrentReplayPausedState ( const bool bPause)
43{
44 AWorldSettings* WorldSettings = GetWorldSettings();
45 if (!WorldSettings)
46 {
47 UE_LOG(LogMenuSystem, Error, TEXT("World Setting Invalid"));
48 // Handle the null case, possibly log an error or return early
49 return false;
50 }
51 // Set MotionBlur off and Anti Aliasing to FXAA in order to bypass the pause-bug of both
52 // static const auto CVarAA = IConsoleManager::Get().FindConsoleVariable(TEXT("r.DefaultFeature.AntiAliasing"));
53 // static const auto CVarMB = IConsoleManager::Get().FindConsoleVariable(TEXT("r.DefaultFeature.MotionBlur"));
54 // if (!CVarAA || !CVarMB)
55 // {
56 // UE_LOG(LogMenuSystem, Error, TEXT("Console Vars Invalid"));
57 // // Handle the null case, possibly log an error or return early
58 // return false;
59 // }
60 if(bPause)
61 {
62 // PreviousAASetting = CVarAA->GetInt();
63 // PreviousMBSetting = CVarMB->GetInt();
64
65 // Set MotionBlur to OFF, Anti-Aliasing to FXAA
66 // CVarAA->Set(1);
67 // CVarMB->Set(0);
68
69 WorldSettings->SetPauserPlayerState(PlayerState);
70 return true;
71 }
72 // Rest MotionBlur and AA
73 // CVarAA->Set(PreviousAASetting);
74 // CVarMB->Set(PreviousMBSetting);
75
76 WorldSettings->SetPauserPlayerState(nullptr);
77 return false;
78}

◆ SetCurrentReplayPlayRate()

void AReplaySpectatorController::SetCurrentReplayPlayRate ( const float PlayRate = 1.f) const

** Changes the PlayRate of the Replay we are watching, enabling FastForward or SlowMotion *‍/

124{
125 if(GetWorld() != nullptr && GetWorld()->GetWorldSettings() != nullptr)
126 {
127 GetWorld()->GetWorldSettings()->DemoPlayTimeDilation = PlayRate;
128 }
129
130}

◆ SetCurrentReplayTimeToSeconds()

void AReplaySpectatorController::SetCurrentReplayTimeToSeconds ( const int32 Seconds) const

** Jumps to the specified Second in the Replay we are watching *‍/

116{
117 if(GetWorld() != nullptr && GetWorld()->GetDemoNetDriver() != nullptr)
118 {
119 GetWorld()->GetDemoNetDriver()->GotoTimeInSeconds(Seconds);
120 }
121}

◆ SetReplayCheckpoint()

void AReplaySpectatorController::SetReplayCheckpoint ( ) const
133{
134 if(GetWorld() != nullptr && GetWorld()->GetDemoNetDriver() != nullptr)
135 {
136 GetWorld()->GetDemoNetDriver()->RequestCheckpoint();
137 }
138}

Member Data Documentation

◆ bReplayMenuOpen

bool AReplaySpectatorController::bReplayMenuOpen = false
private

◆ PreviousAASetting

int32 AReplaySpectatorController::PreviousAASetting = 0
protected

◆ PreviousMBSetting

int32 AReplaySpectatorController::PreviousMBSetting = 0
protected

◆ ReplayViewerWidget

class UReplayViewer* AReplaySpectatorController::ReplayViewerWidget
protected

◆ ReplayViewerWidgetClass

TSubclassOf<class UReplayViewer> AReplaySpectatorController::ReplayViewerWidgetClass
protected

The documentation for this class was generated from the following files: