diff --git a/Source/StudyFrameworkPlugin/Private/SFGameInstance.cpp b/Source/StudyFrameworkPlugin/Private/SFGameInstance.cpp index dd5dc3cbe413139ca5fafce5b1fc578267ace5c5..456bcfab09727350357e3b5d3659ce91c63064b3 100644 --- a/Source/StudyFrameworkPlugin/Private/SFGameInstance.cpp +++ b/Source/StudyFrameworkPlugin/Private/SFGameInstance.cpp @@ -246,29 +246,42 @@ void USFGameInstance::PrepareWithStudySetup(ASFStudySetup* Setup) "Next Participant", "Restart Study" }; - int Answer = FSFUtils::OpenCustomDialog(MessageTitle, MessageText, Buttons); - switch (Answer) - { - case 2: - FSFLoggingUtils::Log("[USFGameInstance::PrepareWithStudySetup]: Restart entire study"); - ParticipantSequenceNumber = 0; - Conditions = StudySetup->GetAllConditionsForRun(ParticipantSequenceNumber); - //clear data - USFParticipant::ClearLogData(Setup); - break; - case 0: - FSFLoggingUtils::Log("[USFGameInstance::PrepareWithStudySetup]: Continue last participant"); - Conditions = USFParticipant::GetLastParticipantsConditions(); - StartCondition = Conditions[USFParticipant::GetLastParticipantLastConditionStarted()]; - bRecoverParticipantData = true; - break; - case 1: - FSFLoggingUtils::Log("[USFGameInstance::PrepareWithStudySetup]: Continue with the next participant"); - ParticipantSequenceNumber++; - Conditions = StudySetup->GetAllConditionsForRun(ParticipantSequenceNumber); - break; - default:; + + bool bValidDecision = false; + while (!bValidDecision) { + int Answer = FSFUtils::OpenCustomDialog(MessageTitle, MessageText, Buttons); + + if (Answer < 0) { + FSFLoggingUtils::Log("[USFGameInstance::PrepareWithStudySetup] The window for deciding on how to recover from an unfinished run was closed without giving an answer, repeat question!", false); + continue; + } + + switch (Answer) + { + case 2: + FSFLoggingUtils::Log("[USFGameInstance::PrepareWithStudySetup]: Restart entire study"); + ParticipantSequenceNumber = 0; + Conditions = StudySetup->GetAllConditionsForRun(ParticipantSequenceNumber); + //clear data + USFParticipant::ClearLogData(Setup); + bValidDecision = true; + break; + case 0: + FSFLoggingUtils::Log("[USFGameInstance::PrepareWithStudySetup]: Continue last participant"); + Conditions = USFParticipant::GetLastParticipantsConditions(); + StartCondition = Conditions[USFParticipant::GetLastParticipantLastConditionStarted()]; + bRecoverParticipantData = true; + bValidDecision = true; + break; + case 1: + FSFLoggingUtils::Log("[USFGameInstance::PrepareWithStudySetup]: Continue with the next participant"); + ParticipantSequenceNumber++; + Conditions = StudySetup->GetAllConditionsForRun(ParticipantSequenceNumber); + bValidDecision = true; + break; + default:; + } } }