Skip to content
Snippets Groups Projects
Commit f4e715ff authored by Lab1's avatar Lab1
Browse files

actually quit the game if "End Study" is clicked, once faded out

parent 27040239
No related branches found
No related tags found
No related merge requests found
...@@ -56,6 +56,11 @@ void USFFadeHandler::Tick() ...@@ -56,6 +56,11 @@ void USFFadeHandler::Tick()
SetTimerForNextTick(); SetTimerForNextTick();
FadeState = EFadeState::WaitForLevelLoaded; FadeState = EFadeState::WaitForLevelLoaded;
} }
else if(USFGameInstance::Get()->HasEnded())
{
//we quit the game
UKismetSystemLibrary::QuitGame(USFGameInstance::Get()->GetWorld(), nullptr, EQuitPreference::Quit, false);
}
//else just do nothing so we stay faded out NewLevelName=="" is the case for a simple FadeOut() //else just do nothing so we stay faded out NewLevelName=="" is the case for a simple FadeOut()
break; break;
......
...@@ -45,6 +45,9 @@ void USFGameInstance::Init() ...@@ -45,6 +45,9 @@ void USFGameInstance::Init()
// Register delegate for ticker callback // Register delegate for ticker callback
TickDelegateHandle = FTicker::GetCoreTicker().AddTicker(FTickerDelegate::CreateUObject(this, &USFGameInstance::LogTick)); TickDelegateHandle = FTicker::GetCoreTicker().AddTicker(FTickerDelegate::CreateUObject(this, &USFGameInstance::LogTick));
LogObject->Initialize(); LogObject->Initialize();
bStudyStarted = false;
bStudyEnded = false;
} }
void USFGameInstance::Shutdown() void USFGameInstance::Shutdown()
...@@ -358,6 +361,7 @@ void USFGameInstance::EndStudy() ...@@ -358,6 +361,7 @@ void USFGameInstance::EndStudy()
GetHUD()->SetNextConditionButtonVisibility(ESlateVisibility::Collapsed); GetHUD()->SetNextConditionButtonVisibility(ESlateVisibility::Collapsed);
} }
bStudyEnded = true;
FadeHandler->FadeOut(); FadeHandler->FadeOut();
} }
...@@ -460,6 +464,11 @@ bool USFGameInstance::IsStarted() const ...@@ -460,6 +464,11 @@ bool USFGameInstance::IsStarted() const
return bStudyStarted; return bStudyStarted;
} }
bool USFGameInstance::HasEnded() const
{
return bStudyEnded;
}
float USFGameInstance::GetCurrentTime() const float USFGameInstance::GetCurrentTime() const
{ {
if(GetParticipant() && IsStarted()) if(GetParticipant() && IsStarted())
......
...@@ -62,6 +62,12 @@ public: ...@@ -62,6 +62,12 @@ public:
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
bool IsStarted() const; bool IsStarted() const;
//Whether the study is done (this is actually only true for a short duration), as once faded out Unreal is quit
UFUNCTION(BlueprintCallable)
bool HasEnded() const;
//the time that passed since the start of the study in seconds //the time that passed since the start of the study in seconds
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
float GetCurrentTime() const; float GetCurrentTime() const;
...@@ -190,9 +196,12 @@ protected: ...@@ -190,9 +196,12 @@ protected:
USFCondition* StartCondition; USFCondition* StartCondition;
// State of Study / GameInstance // State of Study / GameInstance
UPROPERTY() UPROPERTY(BlueprintReadOnly)
bool bStudyStarted = false; bool bStudyStarted = false;
UPROPERTY(BlueprintReadOnly)
bool bStudyEnded = false;
//singleton object of this class, to easier access it //singleton object of this class, to easier access it
static USFGameInstance* Instance; static USFGameInstance* Instance;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment