Skip to content
Snippets Groups Projects
Commit 1c37cd09 authored by Malte Christian Kögel's avatar Malte Christian Kögel
Browse files

revert changes in GameInstance (regarding "Restart" and "Custom ID" windows)...

revert changes in GameInstance (regarding "Restart" and "Custom ID" windows) focus on indep var's for now
parent fdaa784c
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,6 @@
#include "HUD/SFGlobalFadeGameViewportClient.h"
#include "Help/SFUtils.h"
#include "Kismet/KismetStringLibrary.h"
#include "Logging/SFLoggingBPLibrary.h"
#include "Logging/SFLoggingUtils.h"
......@@ -51,7 +50,7 @@ void USFGameInstance::Init()
}
// Register delegate for ticker callback
TickDelegateHandle = FTSTicker::GetCoreTicker().AddTicker(FTickerDelegate::CreateUObject(this, &USFGameInstance::LogTick));
TickDelegateHandle = FTicker::GetCoreTicker().AddTicker(FTickerDelegate::CreateUObject(this, &USFGameInstance::LogTick));
LogObject->Initialize();
bStudyStarted = false;
......@@ -74,9 +73,7 @@ void USFGameInstance::Shutdown()
}
Instance = nullptr;
// Unregister ticker delegate
FTSTicker::GetCoreTicker().RemoveTicker(TickDelegateHandle);
Super::Shutdown();
FTicker::GetCoreTicker().RemoveTicker(TickDelegateHandle);
}
void USFGameInstance::OnWorldStart()
......@@ -249,34 +246,7 @@ void USFGameInstance::PrepareWithStudySetup(ASFStudySetup* Setup)
"Next Participant",
"Restart Study"
};
int Answer;
if(!FSFUtils::IsPrimary())
{
while (!bResultBufferSet)
{
//Wait for Dialog to be completed on primary node
};
Answer = ResultBuffer;
ResultBuffer = -1;
bResultBufferSet = false;
}
else
{
Answer = FSFUtils::OpenCustomDialog(MessageTitle, MessageText, Buttons);
// Broadcast result to secondary nodes
if (IDisplayCluster::Get().GetOperationMode() == EDisplayClusterOperationMode::Cluster)
{
IDisplayClusterClusterManager* const Manager = IDisplayCluster::Get().GetClusterMgr();
FDisplayClusterClusterEventJson Event;
TMap<FString, FString> Params;
Params.Add("Result", FString::FromInt(Answer));
Event.Type = "SFGameInstanceEvent";
Event.Name = "CustomDialogCompleted";
Event.Parameters = Params;
Manager->EmitClusterEventJson(Event, false);
}
}
int Answer = FSFUtils::OpenCustomDialog(MessageTitle, MessageText, Buttons);
switch (Answer)
{
......@@ -317,37 +287,7 @@ void USFGameInstance::PrepareWithStudySetup(ASFStudySetup* Setup)
while(!bValidIDEntered)
{
FString IDGiven;
int Result;
if (!FSFUtils::IsPrimary())
{
while (!bResultBufferSet)
{
//Wait for Dialog to be completed on primary node
};
Result = ResultBuffer;
ResultBuffer = -1;
bResultBufferSet = false;
IDGiven = TextBuffer;
TextBuffer = "";
bTextBufferSet = false;
}
else
{
Result = FSFUtils::OpenCustomDialogText("Participant ID", "Please type in your ID:", "", IDGiven);
// Broadcast result to secondary nodes
if (IDisplayCluster::Get().GetOperationMode() == EDisplayClusterOperationMode::Cluster)
{
IDisplayClusterClusterManager* const Manager = IDisplayCluster::Get().GetClusterMgr();
FDisplayClusterClusterEventJson Event;
TMap<FString, FString> Params;
Params.Add("Result", FString::FromInt(Result));
Params.Add("Text", IDGiven);
Event.Type = "SFGameInstanceEvent";
Event.Name = "CustomDialogTextCompleted";
Event.Parameters = Params;
Manager->EmitClusterEventJson(Event, false);
}
}
int Result = FSFUtils::OpenCustomDialogText("Participant ID", "Please type in your ID:", "", IDGiven);
if (Result < 0) {
FSFLoggingUtils::Log("[USFGameInstance::PrepareWithStudySetup] The window for entering the participant ID was closed without giving an answer, repeat question!", false);
continue;
......@@ -584,24 +524,6 @@ void USFGameInstance::HandleClusterEvent(const FDisplayClusterClusterEventJson&
}
HandleGoToConditionSynced(Event.Parameters["ConditionName"], Event.Parameters["bForced"] == "true", Fade);
}
else if (Event.Name == "CustomDialogCompleted")
{
if(!FSFUtils::IsPrimary())
{
ResultBuffer = UKismetStringLibrary::Conv_StringToInt(Event.Parameters["Result"]);
bResultBufferSet = true;
}
}
else if (Event.Name == "CustomDialogTextCompleted")
{
if (!FSFUtils::IsPrimary())
{
TextBuffer = Event.Parameters["Text"];
bTextBufferSet = true;
ResultBuffer = UKismetStringLibrary::Conv_StringToInt(Event.Parameters["Result"]);
bResultBufferSet = true;
}
}
}
}
......@@ -896,8 +818,12 @@ USFLogObject* USFGameInstance::GetLogObject()
void USFGameInstance::LogComment(const FString& Comment, bool bAlsoLogToHUD /*= true*/)
{
UniLog.Log("#" + GetParticipant()->GetCurrentTimeAsString() + ": " + Comment, "ParticipantLog");
FSFLoggingUtils::Log("Logged Comment: " + Comment);
if (!GetParticipant())
{
return;
}
UniLog.Log("#" + GetParticipant()->GetCurrentTimeAsString() + ": " + Comment, "ParticipantLog");
if (bAlsoLogToHUD)
{
LogToHUD(Comment);
......
......@@ -249,17 +249,5 @@ protected:
//Controls central logging functionality, stores logging parameters
UPROPERTY()
USFLogObject* LogObject;
private:
//Use this to write result from primary node
UPROPERTY()
FString TextBuffer = "";
UPROPERTY()
bool bTextBufferSet = false;
UPROPERTY()
int ResultBuffer = -1;
UPROPERTY()
bool bResultBufferSet = false;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment