From 094578984aee9c7fdba617f21e673d10f1950bdf Mon Sep 17 00:00:00 2001 From: jehret <ehret@vr.rwth-aachen.de> Date: Fri, 19 Jan 2024 13:22:03 +0100 Subject: [PATCH] do not allow closing the "how to proceed after unfinished run detected" dialog without giving an answer by just reopening it! closes #108 --- .../Private/SFGameInstance.cpp | 57 ++++++++++++------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/Source/StudyFrameworkPlugin/Private/SFGameInstance.cpp b/Source/StudyFrameworkPlugin/Private/SFGameInstance.cpp index dd5dc3c..456bcfa 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:; + } } } -- GitLab