本文整理汇总了C++中TOptional::GetValue方法的典型用法代码示例。如果您正苦于以下问题:C++ TOptional::GetValue方法的具体用法?C++ TOptional::GetValue怎么用?C++ TOptional::GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TOptional
的用法示例。
在下文中一共展示了TOptional::GetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetViewRange
void FSequencerTimeSliderController::SetViewRange( float NewRangeMin, float NewRangeMax, EViewRangeInterpolation Interpolation )
{
TOptional<float> LocalClampMin = TimeSliderArgs.ClampMin.Get();
TOptional<float> LocalClampMax = TimeSliderArgs.ClampMax.Get();
// Clamp the range if clamp values are set
if ( LocalClampMin.IsSet() && NewRangeMin < LocalClampMin.GetValue() )
{
NewRangeMin = LocalClampMin.GetValue();
}
if ( LocalClampMax.IsSet() && NewRangeMax > LocalClampMax.GetValue() )
{
NewRangeMax = LocalClampMax.GetValue();
}
const TRange<float> NewRange(NewRangeMin, NewRangeMax);
TimeSliderArgs.OnViewRangeChanged.ExecuteIfBound( NewRange, Interpolation );
if( !TimeSliderArgs.ViewRange.IsBound() )
{
// The output is not bound to a delegate so we'll manage the value ourselves (no animation)
TimeSliderArgs.ViewRange.Set( NewRange );
}
}
示例2: HorizontalScrollBar_OnUserScrolled
void FVisualLoggerTimeSliderController::HorizontalScrollBar_OnUserScrolled(float ScrollOffset)
{
if (!TimeSliderArgs.ViewRange.IsBound())
{
TRange<float> LocalViewRange = TimeSliderArgs.ViewRange.Get();
float LocalViewRangeMin = LocalViewRange.GetLowerBoundValue();
float LocalViewRangeMax = LocalViewRange.GetUpperBoundValue();
TOptional<float> LocalClampMin = TimeSliderArgs.ClampMin.Get();
TOptional<float> LocalClampMax = TimeSliderArgs.ClampMax.Get();
float InThumbSizeFraction = (LocalViewRangeMax - LocalViewRangeMin) / (LocalClampMax.GetValue() - LocalClampMin.GetValue());
float NewViewOutputMin = LocalClampMin.GetValue() + ScrollOffset * (LocalClampMax.GetValue() - LocalClampMin.GetValue());
// The output is not bound to a delegate so we'll manage the value ourselves
float NewViewOutputMax = FMath::Min<float>(NewViewOutputMin + (LocalViewRangeMax - LocalViewRangeMin), LocalClampMax.GetValue());
NewViewOutputMin = NewViewOutputMax - (LocalViewRangeMax - LocalViewRangeMin);
float InOffsetFraction = (NewViewOutputMin - LocalClampMin.GetValue()) / (LocalClampMax.GetValue() - LocalClampMin.GetValue());
//if (InOffsetFraction + InThumbSizeFraction <= 1)
{
TimeSliderArgs.ViewRange.Set(TRange<float>(NewViewOutputMin, NewViewOutputMax));
Scrollbar->SetState(InOffsetFraction, InThumbSizeFraction);
}
}
}
示例3: if
/** Parse anything until we find an unescaped { */
TOptional<FExpressionError> ParseLiteral(FExpressionTokenConsumer& Consumer, bool bEmitErrors)
{
// Include a leading { character - if it was a valid argument token it would have been picked up by a previous token definition
bool bFirstChar = true;
TOptional<FStringToken> Token = Consumer.GetStream().ParseToken([&](TCHAR C){
if (C == '{' && !bFirstChar)
{
return EParseState::StopBefore;
}
else if (C == EscapeChar)
{
return EParseState::StopBefore;
}
else
{
bFirstChar = false;
// Keep consuming
return EParseState::Continue;
}
});
if (Token.IsSet())
{
// Add the token to the consumer. This moves the read position in the stream to the end of the token.
Consumer.Add(Token.GetValue(), FStringLiteral(Token.GetValue()));
}
return TOptional<FExpressionError>();
}
示例4: IsValidAdditiveInternal
bool UBlendSpaceBase::IsValidAdditiveInternal(EAdditiveAnimationType AdditiveType) const
{
TOptional<bool> bIsAdditive;
for (int32 I=0; I<SampleData.Num(); ++I)
{
const UAnimSequence* Animation = SampleData[I].Animation;
// test animation to see if it matched additive type
bool bAdditiveAnim = ( Animation && Animation->IsValidAdditive() && Animation->AdditiveAnimType == AdditiveType );
// if already has value, but it does not match
if ( bIsAdditive.IsSet() )
{
// it's inconsistent, we ignore this
if (bIsAdditive.GetValue() != bAdditiveAnim)
{
return false;
}
}
else
{
bIsAdditive = TOptional<bool>(bAdditiveAnim);
}
}
return (bIsAdditive.IsSet() && bIsAdditive.GetValue());
}
示例5: SetNav
void FWidgetNavigationCustomization::SetNav(UWidget* Widget, EUINavigation Nav, TOptional<EUINavigationRule> Rule, TOptional<FName> WidgetToFocus)
{
Widget->Modify();
UWidgetNavigation* WidgetNavigation = Widget->Navigation;
if (!Widget->Navigation)
{
WidgetNavigation = NewObject<UWidgetNavigation>(Widget);
}
FWidgetNavigationData* DirectionNavigation = nullptr;
switch ( Nav )
{
case EUINavigation::Left:
DirectionNavigation = &WidgetNavigation->Left;
break;
case EUINavigation::Right:
DirectionNavigation = &WidgetNavigation->Right;
break;
case EUINavigation::Up:
DirectionNavigation = &WidgetNavigation->Up;
break;
case EUINavigation::Down:
DirectionNavigation = &WidgetNavigation->Down;
break;
case EUINavigation::Next:
DirectionNavigation = &WidgetNavigation->Next;
break;
case EUINavigation::Previous:
DirectionNavigation = &WidgetNavigation->Previous;
break;
default:
// Should not be possible.
check(false);
return;
}
if ( Rule.IsSet() )
{
DirectionNavigation->Rule = Rule.GetValue();
}
if ( WidgetToFocus.IsSet() )
{
DirectionNavigation->WidgetToFocus = WidgetToFocus.GetValue();
}
if ( WidgetNavigation->IsDefault() )
{
// If the navigation rules are all set to the defaults, remove the navigation
// information from the widget.
Widget->Navigation = nullptr;
}
else
{
Widget->Navigation = WidgetNavigation;
}
}
示例6: SetTimeRange
void FVisualLoggerTimeSliderController::SetTimeRange(float NewViewOutputMin, float NewViewOutputMax)
{
TimeSliderArgs.ViewRange.Set(TRange<float>(NewViewOutputMin, NewViewOutputMax));
TOptional<float> LocalClampMin = TimeSliderArgs.ClampMin.Get();
TOptional<float> LocalClampMax = TimeSliderArgs.ClampMax.Get();
const float InOffsetFraction = (NewViewOutputMin - LocalClampMin.GetValue()) / (LocalClampMax.GetValue() - LocalClampMin.GetValue());
const float InThumbSizeFraction = (NewViewOutputMax - NewViewOutputMin) / (LocalClampMax.GetValue() - LocalClampMin.GetValue());
Scrollbar->SetState(InOffsetFraction, InThumbSizeFraction);
}
示例7: ConsumeNumber
/** Consume a number from the specified consumer's stream, if one exists at the current read position */
TOptional<FExpressionError> ConsumeNumber(FExpressionTokenConsumer& Consumer)
{
auto& Stream = Consumer.GetStream();
TOptional<FStringToken> NumberToken = ExpressionParser::ParseNumber(Stream);
if (NumberToken.IsSet())
{
Consumer.Add(NumberToken.GetValue(), FExpressionNode(FTextToken(NumberToken.GetValue().GetString(), ETextFilterTextComparisonMode::Partial, FTextToken::EInvertResult::No)));
}
return TOptional<FExpressionError>();
}
示例8: UpdateAspectTextFromProperty
void FCameraDetails::UpdateAspectTextFromProperty()
{
// Called whenever the actual aspect ratio property changes - clears the text box if the value no longer matches the current text
TOptional<float> Value = GetAspectRatio();
if (!Value.IsSet() || Value.GetValue() < LastParsedAspectRatioValue - DELTA || Value.GetValue() > LastParsedAspectRatioValue + DELTA)
{
LastParsedAspectRatioValue = -1.0f;
if (!AspectTextBox->GetText().IsEmpty())
{
AspectTextBox->SetText(FText::GetEmpty());
}
}
}
示例9: ImportTextForTargets
bool LocalizationCommandletTasks::ImportTextForTargets(const TSharedRef<SWindow>& ParentWindow, const TArray<ULocalizationTarget*>& Targets, const TOptional<FString> DirectoryPath)
{
TArray<LocalizationCommandletExecution::FTask> Tasks;
for (ULocalizationTarget* Target : Targets)
{
const bool ShouldUseProjectFile = !Target->IsMemberOfEngineTargetSet();
FFormatNamedArguments Arguments;
Arguments.Add(TEXT("TargetName"), FText::FromString(Target->Settings.Name));
const FText ImportTaskName = FText::Format(LOCTEXT("ImportTaskNameFormat", "Import Translations for {TargetName}"), Arguments);
const FString ImportScriptPath = LocalizationConfigurationScript::GetImportTextConfigPath(Target, TOptional<FString>());
const TOptional<FString> DirectoryPathForTarget = DirectoryPath.IsSet() ? DirectoryPath.GetValue() / Target->Settings.Name : TOptional<FString>();
LocalizationConfigurationScript::GenerateImportTextConfigFile(Target, TOptional<FString>(), DirectoryPathForTarget).Write(ImportScriptPath);
Tasks.Add(LocalizationCommandletExecution::FTask(ImportTaskName, ImportScriptPath, ShouldUseProjectFile));
const FText ReportTaskName = FText::Format(LOCTEXT("ReportTaskNameFormat", "Generate Reports for {TargetName}"), Arguments);
const FString ReportScriptPath = LocalizationConfigurationScript::GetWordCountReportConfigPath(Target);
LocalizationConfigurationScript::GenerateWordCountReportConfigFile(Target).Write(ReportScriptPath);
Tasks.Add(LocalizationCommandletExecution::FTask(ReportTaskName, ReportScriptPath, ShouldUseProjectFile));
}
return LocalizationCommandletExecution::Execute(ParentWindow, LOCTEXT("ImportForAllTargetsWindowTitle", "Import Translations for All Targets"), Tasks);
}
示例10: OnCursorQuery
FCursorReply SWidget::OnCursorQuery( const FGeometry& MyGeometry, const FPointerEvent& CursorEvent ) const
{
TOptional<EMouseCursor::Type> TheCursor = Cursor.Get();
return ( TheCursor.IsSet() )
? FCursorReply::Cursor( TheCursor.GetValue() )
: FCursorReply::Unhandled();
}
示例11: ParseEscapedChar
TOptional<FExpressionError> ParseEscapedChar(FExpressionTokenConsumer& Consumer)
{
FTokenStream& Stream = Consumer.GetStream();
TOptional<FStringToken> Token = Stream.ParseSymbol(EscapeChar);
if (!Token.IsSet())
{
return TOptional<FExpressionError>();
}
FStringToken& TokenValue = Token.GetValue();
// Accumulate the next character into the token
TOptional<FStringToken> EscapedChar = Consumer.GetStream().ParseSymbol(&TokenValue);
if (!EscapedChar.IsSet())
{
return TOptional<FExpressionError>();
}
// Check for a valid escape character
const TCHAR Character = *EscapedChar->GetTokenStartPos();
if (IsValidEscapeChar(Character))
{
// Add the token to the consumer - this moves the read position in the stream to the end of the token.
Consumer.Add(TokenValue, FEscapedCharacter(Character));
}
return TOptional<FExpressionError>();
}
示例12: if
TOptional<FExpressionError> ParseLiteral(FExpressionTokenConsumer& Consumer)
{
FTokenStream& Stream = Consumer.GetStream();
TOptional<FStringToken> Token;
{
bool bFirstChar = true;
Token = Stream.ParseToken([&](TCHAR C)
{
// Always include the first character, since if it was the start of a valid token then it would have been picked up by a higher priority token parser
if (bFirstChar)
{
bFirstChar = false;
return EParseState::Continue;
}
else if (!IsLiteralBreakChar(C))
{
return EParseState::Continue;
}
else
{
return EParseState::StopBefore;
}
});
}
if (Token.IsSet())
{
// Add the token to the consumer - this moves the read position in the stream to the end of the token
FStringToken& TokenValue = Token.GetValue();
Consumer.Add(TokenValue, FStringLiteral(TokenValue));
}
return TOptional<FExpressionError>();
}
示例13: OnMouseWheel
FReply FSequencerTimeSliderController::OnMouseWheel( TSharedRef<SWidget> WidgetOwner, const FGeometry& MyGeometry, const FPointerEvent& MouseEvent )
{
if ( TimeSliderArgs.AllowZoom )
{
const float ZoomDelta = -0.1f * MouseEvent.GetWheelDelta();
{
TRange<float> LocalViewRange = TimeSliderArgs.ViewRange.Get();
float LocalViewRangeMax = LocalViewRange.GetUpperBoundValue();
float LocalViewRangeMin = LocalViewRange.GetLowerBoundValue();
const float OutputViewSize = LocalViewRangeMax - LocalViewRangeMin;
const float OutputChange = OutputViewSize * ZoomDelta;
float NewViewOutputMin = LocalViewRangeMin - (OutputChange * 0.5f);
float NewViewOutputMax = LocalViewRangeMax + (OutputChange * 0.5f);
if( FMath::Abs( OutputChange ) > 0.01f && NewViewOutputMin < NewViewOutputMax )
{
TOptional<float> LocalClampMin = TimeSliderArgs.ClampMin.Get();
TOptional<float> LocalClampMax = TimeSliderArgs.ClampMax.Get();
// Clamp the range if clamp values are set
if ( LocalClampMin.IsSet() && NewViewOutputMin < LocalClampMin.GetValue() )
{
NewViewOutputMin = LocalClampMin.GetValue();
}
if ( LocalClampMax.IsSet() && NewViewOutputMax > LocalClampMax.GetValue() )
{
NewViewOutputMax = LocalClampMax.GetValue();
}
TimeSliderArgs.OnViewRangeChanged.ExecuteIfBound(TRange<float>(NewViewOutputMin, NewViewOutputMax));
if( !TimeSliderArgs.ViewRange.IsBound() )
{
// The output is not bound to a delegate so we'll manage the value ourselves
TimeSliderArgs.ViewRange.Set( TRange<float>( NewViewOutputMin, NewViewOutputMax ) );
}
}
}
return FReply::Handled();
}
return FReply::Unhandled();
}
示例14: if
TOptional<FVector4> FVectorPropertySection::GetPropertyValueAsVector4() const
{
if (ChannelsUsed == 2)
{
TOptional<FVector2D> Vector = GetPropertyValue<FVector2D>();
return Vector.IsSet() ? TOptional<FVector4>(FVector4(Vector.GetValue().X, Vector.GetValue().Y, 0, 0)) : TOptional<FVector4>();
}
else if (ChannelsUsed == 3)
{
TOptional<FVector> Vector = GetPropertyValue<FVector>();
return Vector.IsSet() ? TOptional<FVector4>(FVector4(Vector.GetValue().X, Vector.GetValue().Y, Vector.GetValue().Z, 0)) : TOptional<FVector4>();
}
else // ChannelsUsed == 4
{
return GetPropertyValue<FVector4>();
}
}
示例15:
TOptional<FGuid> FActorReferencePropertySection::GetActorGuid() const
{
TOptional<AActor*> CurrentActor = GetPropertyValue<AActor*>();
if (CurrentActor.IsSet() && CurrentActor.GetValue() != nullptr)
{
return TOptional<FGuid>(GetSequencer()->GetFocusedMovieSceneSequenceInstance()->FindObjectId(*CurrentActor.GetValue()));
}
return TOptional<FGuid>(FGuid());
}