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

add the possibility to force fading

parent 27cbc708
Branches
Tags
No related merge requests found
......@@ -93,7 +93,7 @@ void USFFadeHandler::Tick()
}
}
void USFFadeHandler::FadeToLevel(const FString& NextLevelName, const bool bStartFadeFadedOut)
void USFFadeHandler::FadeToLevel(const FString& NextLevelName, bool bForceFade, const bool bStartFadeFadedOut)
{
if (GetCameraManager() == nullptr)
{
......@@ -124,7 +124,8 @@ void USFFadeHandler::FadeToLevel(const FString& NextLevelName, const bool bStart
FadeState = EFadeState::FadingOut;
}
else if (USFGameInstance::Get()->GetStudySetup()->bNoFadingOnSameMap
&& CurrentLevelName == FPackageName::GetShortName(NextLevelName))
&& CurrentLevelName == FPackageName::GetShortName(NextLevelName)
&& !bForceFade)
{
//bNoFadingOnSameMap and fade to same map, so no fading, but pretend we "faded in"
FadeState = EFadeState::FadingIn;
......@@ -157,7 +158,7 @@ void USFFadeHandler::FadeIn()
void USFFadeHandler::FadeOut()
{
FadeToLevel("");
FadeToLevel("", true);
}
......
......@@ -412,7 +412,7 @@ void USFGameInstance::EndStudy()
}
bool USFGameInstance::NextCondition(bool bForced /*=false*/)
bool USFGameInstance::NextCondition(bool bForced /*=false*/, bool bForceFade /*= false*/)
{
// Check if is already fading
if (FadeHandler->GetIsFading() && !FadeHandler->GetIsFadedOutWaitingForLevel())
......@@ -428,10 +428,10 @@ bool USFGameInstance::NextCondition(bool bForced /*=false*/)
EndStudy();
return false;
}
return GoToCondition(NextCondition, bForced);
return GoToCondition(NextCondition, bForced, bForceFade);
}
bool USFGameInstance::GoToCondition(const USFCondition* Condition, bool bForced /*=false*/)
bool USFGameInstance::GoToCondition(const USFCondition* Condition, bool bForced /*=false*/, bool bForceFade /*= false*/)
{
// Check if is already fading
if (FadeHandler->GetIsFading() && !FadeHandler->GetIsFadedOutWaitingForLevel())
......@@ -445,16 +445,16 @@ bool USFGameInstance::GoToCondition(const USFCondition* Condition, bool bForced
FSFLoggingUtils::Log("[USFGameInstance::GoToCondition()]: Could not load next condition.", true);
return false;
}
GoToConditionSynced(Condition->UniqueName, bForced);
GoToConditionSynced(Condition->UniqueName, bForced, bForceFade);
return true;
}
void USFGameInstance::GoToConditionSynced(FString ConditionName, bool bForced)
void USFGameInstance::GoToConditionSynced(FString ConditionName, bool bForced, bool bForceFade)
{
const EDisplayClusterOperationMode OperationMode = IDisplayCluster::Get().GetOperationMode();
if (OperationMode != EDisplayClusterOperationMode::Cluster)
{
HandleGoToConditionSynced(ConditionName, bForced);
HandleGoToConditionSynced(ConditionName, bForced, bForceFade);
}
else
{
......@@ -467,6 +467,7 @@ void USFGameInstance::GoToConditionSynced(FString ConditionName, bool bForced)
TMap<FString, FString> Params;
Params.Add("ConditionName", ConditionName);
Params.Add("bForced", bForced ?"true":"false");
Params.Add("bForceFade", bForceFade ? "true" : "false");
ClusterEvent.Parameters = Params;
ClusterEvent.bShouldDiscardOnRepeat = true;
......@@ -479,13 +480,13 @@ void USFGameInstance::HandleClusterEvent(const FDisplayClusterClusterEventJson&
//now we actually react on all cluster nodes:
if(Event.Name == "GoToConditionSynced")
{
HandleGoToConditionSynced(Event.Parameters["ConditionName"], Event.Parameters["bForced"] == "true");
HandleGoToConditionSynced(Event.Parameters["ConditionName"], Event.Parameters["bForced"] == "true", Event.Parameters["bForceFade"] == "true");
}
}
}
void USFGameInstance::HandleGoToConditionSynced(FString ConditionName, bool bForced)
void USFGameInstance::HandleGoToConditionSynced(FString ConditionName, bool bForced, bool bForceFade)
{
USFCondition* NextCondition = nullptr;
for (USFCondition* Condition : Participant->GetAllConditions())
......@@ -556,7 +557,7 @@ void USFGameInstance::HandleGoToConditionSynced(FString ConditionName, bool bFor
}
else
{
FadeHandler->FadeToLevel(NextCondition->Map);
FadeHandler->FadeToLevel(NextCondition->Map, bForceFade);
}
UpdateHUD("Fading out");
}
......
......@@ -45,7 +45,7 @@ class STUDYFRAMEWORKPLUGIN_API USFFadeHandler : public UObject
public:
void Tick();
void FadeToLevel(const FString& LevelName, bool bStartFadedOut = false);
void FadeToLevel(const FString& LevelName, bool bForceFade, bool bStartFadedOut = false);
void FadeIn();
void FadeOut();
float FadeTimeRemaining() const;
......
......@@ -51,13 +51,17 @@ public:
//Fade to the next condition (use this to proceed in the study once condition is done)
//bForce also goes to the next condition if the current condition was not finished (not all required dependent variables gathered)
//bForceFade: unless specified differently in the StudySetup it is faded between every two conditions, if bNoFadingOnSameMap is set to false,
// bForceFade forces to fade anyways between two conditions on the same map and has not effect otherwise
UFUNCTION(BlueprintCallable)
bool NextCondition(bool bForce = false);
bool NextCondition(bool bForce = false, bool bForceFade = false);
//This method can be used to jump to a specific condition (DO NOT USE during normal study run)
//bForce also goes to the next condition if the current condition was not finished (not all required dependent variables gathered)
//bForceFade: unless specified differently in the StudySetup it is faded between every two conditions, if bNoFadingOnSameMap is set to false,
// bForceFade forces to fade anyways between two conditions on the same map and has not effect otherwise
UFUNCTION(BlueprintCallable)
bool GoToCondition(const USFCondition* Condition, bool bForce = false);
bool GoToCondition(const USFCondition* Condition, bool bForce = false, bool bForceFade = false);
//Whether the study was started already
UFUNCTION(BlueprintCallable)
......@@ -173,8 +177,8 @@ protected:
void EndStudy();
//we use cluster events so GoToConditionSynced can not run out of sync when using nDisplay in cluster mode
void GoToConditionSynced(FString ConditionName, bool bForced); //send the cluster event
void HandleGoToConditionSynced(FString ConditionName, bool bForced); //process the cluter event
void GoToConditionSynced(FString ConditionName, bool bForced, bool bForceFade); //send the cluster event
void HandleGoToConditionSynced(FString ConditionName, bool bForced, bool bForceFade); //process the cluter event
FOnClusterEventJsonListener ClusterEventListenerDelegate;
void HandleClusterEvent(const FDisplayClusterClusterEventJson& Event);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment