Skip to content
Snippets Groups Projects
Commit 7017fabf authored by Jonathan Ehret's avatar Jonathan Ehret
Browse files

Merge remote-tracking branch 'origin/feature/clusterized_popup_104' into dev/5.3

parents 0a5d33ad 4c431ac6
No related branches found
No related tags found
No related merge requests found
......@@ -226,14 +226,11 @@ void USFGameInstance::PrepareWithStudySetup(ASFStudySetup* Setup)
int ParticipantSequenceNumber = USFParticipant::GetLastParticipantSequenceNumber();
FString LastParticipantID = USFParticipant::GetLastParticipantID();
TArray<USFCondition*> Conditions;
bool bRecoverParticipantData = false;
if (USFParticipant::GetLastParticipantFinished())
{
ParticipantSequenceNumber++;
Conditions = StudySetup->GetAllConditionsForRun(ParticipantSequenceNumber);
PrepareForStartMode("Last Participant Finished");
}
else
else if (FSFUtils::IsPrimary())
{
const FString MessageText = FString("The last participant did not finish the study run. Would you like to:") +
......@@ -248,30 +245,61 @@ void USFGameInstance::PrepareWithStudySetup(ASFStudySetup* Setup)
"Next Participant",
"Restart Study"
};
int Answer = FSFUtils::OpenCustomDialog(MessageTitle, MessageText, Buttons);
const FString ModeSelection = Buttons[Answer];
// Primary Node in cluster mode: Continue preparation by event for synchronization purposes
if (IDisplayCluster::Get().GetOperationMode() == EDisplayClusterOperationMode::Cluster)
{
IDisplayClusterClusterManager* const Manager = IDisplayCluster::Get().GetClusterMgr();
FDisplayClusterClusterEventJson Event;
TMap<FString, FString> Params;
Params.Add("Selection", ModeSelection);
Event.Type = "SFGameInstanceEvent";
Event.Name = "SelectStudyStartMode";
Event.Parameters = Params;
Manager->EmitClusterEventJson(Event, true);
}
// Not in cluster mode: Directly call prep
else
{
PrepareForStartMode(ModeSelection);
}
}
}
//Continue / Next Participant / Restart Study
void USFGameInstance::PrepareForStartMode(FString StartMode)
{
int ParticipantSequenceNumber = USFParticipant::GetLastParticipantSequenceNumber();
FString LastParticipantID = USFParticipant::GetLastParticipantID();
TArray<USFCondition*> Conditions;
bool bRecoverParticipantData = false;
switch (Answer)
if (StartMode == "Last Participant Finished")
{
ParticipantSequenceNumber++;
Conditions = StudySetup->GetAllConditionsForRun(ParticipantSequenceNumber);
}
else if (StartMode == "Restart Study")
{
case 2:
FSFLoggingUtils::Log("[USFGameInstance::PrepareWithStudySetup]: Restart entire study");
ParticipantSequenceNumber = 0;
Conditions = StudySetup->GetAllConditionsForRun(ParticipantSequenceNumber);
//clear data
USFParticipant::ClearLogData(Setup);
break;
case 0:
USFParticipant::ClearLogData();
}
else if (StartMode == "Continue Participant")
{
FSFLoggingUtils::Log("[USFGameInstance::PrepareWithStudySetup]: Continue last participant");
Conditions = USFParticipant::GetLastParticipantsConditions();
StartCondition = Conditions[USFParticipant::GetLastParticipantLastConditionStarted()];
bRecoverParticipantData = true;
break;
case 1:
}
else if (StartMode == "Next Participant") {
FSFLoggingUtils::Log("[USFGameInstance::PrepareWithStudySetup]: Continue with the next participant");
ParticipantSequenceNumber++;
Conditions = StudySetup->GetAllConditionsForRun(ParticipantSequenceNumber);
break;
default: ;
}
}
if (StudySetup->bPreloadAllMapsOnStart)
......@@ -282,7 +310,7 @@ void USFGameInstance::PrepareWithStudySetup(ASFStudySetup* Setup)
// Participant
FString ParticipantID = "";
if(Setup->bUseCustomParticipantIDs)
if (StudySetup->bUseCustomParticipantIDs)
{
//ask for it:
bool bValidIDEntered = false;
......@@ -318,7 +346,7 @@ void USFGameInstance::PrepareWithStudySetup(ASFStudySetup* Setup)
Participant->LoadLastParticipantsIndependentVariables();
}
else {
Participant->SetIndependentVariablesFromStudySetup(Setup);
Participant->SetIndependentVariablesFromStudySetup(StudySetup);
Participant->StoreInIndependentVarLongTable();
}
Participant->SetStudyConditions(Conditions);
......@@ -341,7 +369,7 @@ void USFGameInstance::PrepareWithStudySetup(ASFStudySetup* Setup)
if (IsInitialized())
{
InitFadeHandler(Setup->FadeConfig);
InitFadeHandler(StudySetup->FadeConfig);
}
UpdateHUD("Wait for Start");
}
......@@ -505,6 +533,10 @@ void USFGameInstance::GoToConditionSynced(FString ConditionName, bool bForced, E
void USFGameInstance::HandleClusterEvent(const FDisplayClusterClusterEventJson& Event) {
if (Event.Type == "SFGameInstanceEvent") {
if(Event.Name == "SelectStudyStartMode")
{
PrepareForStartMode(Event.Parameters["Selection"]);
}
//now we actually react on all cluster nodes:
if(Event.Name == "GoToConditionSynced")
{
......
......@@ -740,7 +740,7 @@ void USFParticipant::CreateLongTableBackUp(const FString PathToSrcFile) const
}
void USFParticipant::ClearLogData(ASFStudySetup* StudySetup)
void USFParticipant::ClearLogData()
{
const FString LongTableFolder = FPaths::ProjectDir() + "StudyFramework/StudyLogs/";
const FString StudyRunsFolder = FPaths::ProjectDir() + "StudyFramework/StudyRuns";
......
......@@ -201,6 +201,7 @@ protected:
void InitFadeHandler(FFadeConfig FadeConfig);
void PrepareWithStudySetup(ASFStudySetup* Setup);
void PrepareForStartMode(FString StartMode);
void PreloadAllMaps(const TArray<USFCondition*> &Conditions);
......
......@@ -79,7 +79,7 @@ public:
// for the data to be ready to use in statistics software. This methods clears all
// of that data (e.g. if study is entirely restarted).
// The data can be recovered from /StudyLogs/RecyclingBin
static void ClearLogData(ASFStudySetup* StudySetup);
static void ClearLogData();
// Whenever we delete data in a file (e.g. with by restarting a condition),
// we want to create a backup, to enable data recovery
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment