本文整理汇总了C++中FTimespan类的典型用法代码示例。如果您正苦于以下问题:C++ FTimespan类的具体用法?C++ FTimespan怎么用?C++ FTimespan使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FTimespan类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTimeStamp
double FFileManagerGeneric::GetFileAgeSeconds( const TCHAR* Filename )
{
// make sure it exists
if (!GetLowLevel().FileExists(Filename))
{
return -1.0;
}
// get difference in time between now (UTC) and the filetime
FTimespan Age = FDateTime::UtcNow() - GetTimeStamp(Filename);
return Age.GetTotalSeconds();
}
示例2: timeUntilRespawn
float AFPSGPlayerController::timeUntilRespawn()
{
float timeToRespawn = 0.0f;
if (!isAlive)
{
if (timeOfDeath != FDateTime::MinValue())
{
FTimespan timeSinceDeath = FDateTime::Now() - timeOfDeath;
timeToRespawn = respawnTime - static_cast<float>(timeSinceDeath.GetTotalSeconds());
}
}
return timeToRespawn;
}
示例3: Parse
bool FTimespan::Parse( const FString& TimespanString, FTimespan& OutTimespan )
{
// @todo gmp: implement stricter FTimespan parsing; this implementation is too forgiving.
FString TokenString = TimespanString.Replace(TEXT("."), TEXT(":"));
bool Negative = TokenString.StartsWith(TEXT("-"));
TokenString.ReplaceInline(TEXT("-"), TEXT(":"), ESearchCase::CaseSensitive);
TArray<FString> Tokens;
TokenString.ParseIntoArray(Tokens, TEXT(":"), true);
if (Tokens.Num() == 4)
{
Tokens.Insert(TEXT("0"), 0);
}
if (Tokens.Num() == 5)
{
OutTimespan.Assign(FCString::Atoi(*Tokens[0]), FCString::Atoi(*Tokens[1]), FCString::Atoi(*Tokens[2]), FCString::Atoi(*Tokens[3]), FCString::Atoi(*Tokens[4]));
if (Negative)
{
OutTimespan.Ticks *= -1;
}
return true;
}
return false;
}
示例4: Seek
bool FAndroidMediaPlayer::Seek(const FTimespan& Time)
{
if (MediaState == EMediaState::Prepared || MediaState == EMediaState::Started ||
MediaState == EMediaState::Paused || MediaState == EMediaState::PlaybackCompleted)
{
JavaMediaPlayer->SeekTo(Time.GetMilliseconds());
return true;
}
else
{
return false;
}
}
示例5: select
EIPv6SocketInternalState::Return FSocketBSDIPv6::HasState(EIPv6SocketInternalState::Param State, FTimespan WaitTime)
{
#if PLATFORM_HAS_BSD_SOCKET_FEATURE_SELECT
// convert WaitTime to a timeval
timeval Time;
Time.tv_sec = (int32)WaitTime.GetTotalSeconds();
Time.tv_usec = WaitTime.GetMilliseconds() * 1000;
fd_set SocketSet;
// Set up the socket sets we are interested in (just this one)
FD_ZERO(&SocketSet);
FD_SET(Socket, &SocketSet);
// Check the status of the state
int32 SelectStatus = 0;
switch (State)
{
case EIPv6SocketInternalState::CanRead:
SelectStatus = select(Socket + 1, &SocketSet, NULL, NULL, &Time);
break;
case EIPv6SocketInternalState::CanWrite:
SelectStatus = select(Socket + 1, NULL, &SocketSet, NULL, &Time);
break;
case EIPv6SocketInternalState::HasError:
SelectStatus = select(Socket + 1, NULL, NULL, &SocketSet, &Time);
break;
}
// if the select returns a positive number, the socket had the state, 0 means didn't have it, and negative is API error condition (not socket's error state)
return SelectStatus > 0 ? EIPv6SocketInternalState::Yes :
SelectStatus == 0 ? EIPv6SocketInternalState::No :
EIPv6SocketInternalState::EncounteredError;
#else
UE_LOG(LogSockets, Fatal, TEXT("This platform doesn't support select(), but FSocketBSD::HasState was not overridden"));
return EIPv6SocketInternalState::EncounteredError;
#endif
}
示例6: FTimespan
void AEscapeBallGameMode::Tick(float DeltaSeconds)
{
// Add time to the total Time
totalGameTime += DeltaSeconds;
FTimespan timeFormatter = FTimespan(0, 0, 0, FMath::Floor(totalGameTime), FMath::Floor(FMath::Fmod(totalGameTime, 1.0f)*1000.0f));
totalGameTimeString = timeFormatter.ToString();
// Check if player has touched the goal.
UWorld* worldRef = GetWorld();
//ADestinationGoal* goalRef = Cast<ADestinationGoal>(goal);
if (goal && goal->isTriggered())
{
//GEngine->AddOnScreenDebugMessage(-1, 0.1f, FColor::Yellow, TEXT("Reached Goal"));
UGameplayStatics::OpenLevel(GWorld, "LevelEditorQuickStartGuide", false, "");
}
}
示例7: GetViewPixelCoordinatesFromActorLocation
void AUISurfaceActor::HandleVirtualTouchInput(FVector ActionHandPalmLocation, FVector ActionHandFingerLocation) {
FVector ActorSpaceActionFingerLocation = this->GetTransform().InverseTransformPosition(ActionHandFingerLocation);
FVector ActorSpaceActionPalmLocation = this->GetTransform().InverseTransformPosition(ActionHandPalmLocation);
FVector ActorSpaceActionFingerPreviousLocation = this->GetTransform().InverseTransformPosition(ActionHandPreviousFingerLocation);
FVector ActorSpaceActionPalmPreviousLocation = this->GetTransform().InverseTransformPosition(ActionHandPreviousPalmLocation);
FVector ActorSpaceActionFingerLocationXY = ActorSpaceActionFingerLocation;
ActorSpaceActionFingerLocationXY.Z = 0.0;
FVector ActorSpacePointerFingerLocationXYWorld = this->GetTransform().TransformPosition(ActorSpaceActionFingerLocationXY);
FVector PointerFingerPixelCoordinates = GetViewPixelCoordinatesFromActorLocation(ActorSpaceActionFingerLocationXY);
if (ActorSpaceActionFingerLocation.Z <= 0) { // finger is across plane
if (!PointerFingerAcrossPlane) { // finger was not previously across plane, so handle as mouse click and set across flag to true
HandleMouseDownEventAtCoordinates(PointerFingerPixelCoordinates);
DrawDebugSphere(GetWorld(), ActorSpacePointerFingerLocationXYWorld, 0.6, 12, FColor::Cyan, true, 0.1);
PointerFingerAcrossPlane = true;
}
else { // was already across plane
}
// handle scrolling
FVector CurrentPalmPixelCoordinates = GetViewPixelCoordinatesFromActorLocation(ActorSpaceActionPalmLocation);
FVector PreviousPalmPixelCoordinates = GetViewPixelCoordinatesFromActorLocation(ActorSpaceActionPalmPreviousLocation);
float NumPixelsMovedY = CurrentPalmPixelCoordinates.Y - PreviousPalmPixelCoordinates.Y; // if negative means palm is moving up so should scroll down
if (abs(NumPixelsMovedY) >= ScrollNumPixelsThreshold) {
float WheelTicksY = NumPixelsMovedY / PixelToWheelTickScalingFactor;
HandleYScrollIncrementEvent(WheelTicksY);
}
// Handle left/right swipe
// NOTE: was a simple left swipe to go Back before, but since there were too many false positives have more complicated gesture linking left and right swipes to go Back
float NumPixelsMovedX = CurrentPalmPixelCoordinates.X - PreviousPalmPixelCoordinates.X;
if (abs(NumPixelsMovedX) >= SwipeLengthPixelsThreshold) {
FDateTime CurrentTime = FDateTime::Now();
if (NumPixelsMovedX < 0) { // is left swipe
FTimespan TimeBetweenLeftSwipes = CurrentTime - LastLeftSwipeTime;
if (TimeBetweenLeftSwipes.GetTotalMilliseconds() >= MinMillisecondsBetweenSwipes) { // check if there has been enough elapsed time since last swipe
LastLeftSwipeTime = CurrentTime;
}
}
else { // is right swipe
FTimespan TimeBetweenRightSwipes = CurrentTime - LastRightSwipeTime;
if (TimeBetweenRightSwipes.GetTotalMilliseconds() >= MinMillisecondsBetweenSwipes) { // check if there has been enough elapsed time since last swipe
LastRightSwipeTime = CurrentTime;
FTimespan TimeBetweenLeftAndRightSwipes = LastRightSwipeTime - LastLeftSwipeTime;
if (TimeBetweenLeftAndRightSwipes.GetTotalMilliseconds() <= MaxMillisecondsLinkingSwipes) { // check right swipe is linked to the previous left swipe
HandleBackEvent();
}
}
}
}
}
else { // finger is not across plane
if (PointerFingerAcrossPlane) { // set across flag to false if it was set to true
PointerFingerAcrossPlane = false ;
HandleMouseUpEventAtCoordinates(PointerFingerPixelCoordinates);
}
// check for hover state
if (ActorSpaceActionFingerLocation.Z <= this->HoverDistance) { // check for hovering
PointerFingerIsHovering = true;
DrawDebugSphere(GetWorld(), ActorSpacePointerFingerLocationXYWorld, 0.5, 12, FColor::Magenta);
HandleMouseoverEventPixelCoordinates(PointerFingerPixelCoordinates);
}
else {
if (PointerFingerIsHovering) {
PointerFingerIsHovering = false;
}
}
}
// Now that we are done with Leap processing let's set the previous hand locations to the current hand locations
ActionHandPreviousPalmLocation = ActionHandPalmLocation;
ActionHandPreviousFingerLocation = ActionHandFingerLocation;
}
示例8: AsTimespan
FText FText::AsTimespan( const FTimespan& Timespan, const FCulturePtr& TargetCulture)
{
checkf(FInternationalization::Get().IsInitialized() == true, TEXT("FInternationalization is not initialized. An FText formatting method was likely used in static object initialization - this is not supported."));
FDateTime DateTime(Timespan.GetTicks());
return FText::FromString( DateTime.ToString( TEXT("%H.%M.%S") ) );
}
示例9: SCOPE_CYCLE_COUNTER
//.........这里部分代码省略.........
const FIntPoint atlasSampleTL(sliceCenterPixelX + FMath::Clamp(slicePixelX , -StripWidth/2, StripWidth/2), sliceCenterPixelY + FMath::Clamp(slicePixelY , -StripHeight/2, StripHeight/2));
const FIntPoint atlasSampleTR(sliceCenterPixelX + FMath::Clamp(slicePixelX + 1, -StripWidth/2, StripWidth/2), sliceCenterPixelY + FMath::Clamp(slicePixelY , -StripHeight/2, StripHeight/2));
const FIntPoint atlasSampleBL(sliceCenterPixelX + FMath::Clamp(slicePixelX , -StripWidth/2, StripWidth/2), sliceCenterPixelY + FMath::Clamp(slicePixelY + 1, -StripHeight/2, StripHeight/2));
const FIntPoint atlasSampleBR(sliceCenterPixelX + FMath::Clamp(slicePixelX + 1, -StripWidth/2, StripWidth/2), sliceCenterPixelY + FMath::Clamp(slicePixelY + 1, -StripHeight/2, StripHeight/2));
const FColor pixelColorTL = SurfaceData[atlasSampleTL.Y * UnprojectedAtlasWidth + atlasSampleTL.X];
const FColor pixelColorTR = SurfaceData[atlasSampleTR.Y * UnprojectedAtlasWidth + atlasSampleTR.X];
const FColor pixelColorBL = SurfaceData[atlasSampleBL.Y * UnprojectedAtlasWidth + atlasSampleBL.X];
const FColor pixelColorBR = SurfaceData[atlasSampleBR.Y * UnprojectedAtlasWidth + atlasSampleBR.X];
const float fracX = FMath::Frac(dbgMatchCaptureSliceFovToAtlasSliceFov ? sliceU * StripWidth : sliceU * CaptureWidth);
const float fracY = FMath::Frac(dbgMatchCaptureSliceFovToAtlasSliceFov ? sliceV * StripHeight : sliceV * CaptureHeight);
//Reinterpret as linear (a.k.a dont apply srgb inversion)
slicePixelSample = FMath::BiLerp(
pixelColorTL.ReinterpretAsLinear(), pixelColorTR.ReinterpretAsLinear(),
pixelColorBL.ReinterpretAsLinear(), pixelColorBR.ReinterpretAsLinear(),
fracX, fracY);
}
else
{
const int32 sliceCenterPixelX = (sliceXIndex + 0.5f) * StripWidth;
const int32 sliceCenterPixelY = (sliceYIndex + 0.5f) * StripHeight;
const int32 atlasSampleX = sliceCenterPixelX + slicePixelX;
const int32 atlasSampleY = sliceCenterPixelY + slicePixelY;
slicePixelSample = SurfaceData[atlasSampleY * UnprojectedAtlasWidth + atlasSampleX].ReinterpretAsLinear();
}
samplePixelAccum += slicePixelSample;
////Output color map of projections
//const FColor debugEquiColors[12] = {
// FColor(205, 180, 76),
// FColor(190, 88, 202),
// FColor(127, 185, 194),
// FColor(90, 54, 47),
// FColor(197, 88, 53),
// FColor(197, 75, 124),
// FColor(130, 208, 72),
// FColor(136, 211, 153),
// FColor(126, 130, 207),
// FColor(83, 107, 59),
// FColor(200, 160, 157),
// FColor(80, 66, 106)
//};
//samplePixelAccum = ssPattern.numSamples * debugEquiColors[sliceYIndex * 4 + sliceXIndex];
}
SphericalAtlas[y * SphericalAtlasWidth + x] = (samplePixelAccum / ssPattern.numSamples).Quantize();
// Force alpha value
if (bForceAlpha)
{
SphericalAtlas[y * SphericalAtlasWidth + x].A = 255;
}
}
}
//Blit the first column into the last column to make the stereo image seamless at theta=360
for (int32 y = 0; y < SphericalAtlasHeight; y++)
{
SphericalAtlas[y * SphericalAtlasWidth + (SphericalAtlasWidth - 1)] = SphericalAtlas[y * SphericalAtlasWidth + 0];
}
const FTimespan SamplingDuration = FDateTime::UtcNow() - SamplingStartTime;
UE_LOG(LogStereoPanorama, Log, TEXT("...done! Duration: %g seconds"), SamplingDuration.GetTotalSeconds());
}
// Generate name
FString FrameString = FString::Printf( TEXT( "%s_%05d.png" ), *Folder, CurrentFrameCount );
FString AtlasName = OutputDir / Timestamp / FrameString;
UE_LOG( LogStereoPanorama, Log, TEXT( "Writing atlas: %s" ), *AtlasName );
// Write out PNG
//TODO: ikrimae: Use threads to write out the images for performance
IImageWrapperPtr ImageWrapper = ImageWrapperModule.CreateImageWrapper( EImageFormat::PNG );
ImageWrapper->SetRaw(SphericalAtlas.GetData(), SphericalAtlas.GetAllocatedSize(), SphericalAtlasWidth, SphericalAtlasHeight, ERGBFormat::BGRA, 8);
const TArray<uint8>& PNGData = ImageWrapper->GetCompressed(100);
FFileHelper::SaveArrayToFile( PNGData, *AtlasName );
if (FStereoPanoramaManager::GenerateDebugImages->GetInt() != 0)
{
FString FrameStringUnprojected = FString::Printf(TEXT("%s_%05d_Unprojected.png"), *Folder, CurrentFrameCount);
FString AtlasNameUnprojected = OutputDir / Timestamp / FrameStringUnprojected;
ImageWrapper->SetRaw(SurfaceData.GetData(), SurfaceData.GetAllocatedSize(), UnprojectedAtlasWidth, UnprojectedAtlasHeight, ERGBFormat::BGRA, 8);
const TArray<uint8>& PNGDataUnprojected = ImageWrapper->GetCompressed(100);
FFileHelper::SaveArrayToFile(PNGData, *AtlasNameUnprojected);
}
ImageWrapper.Reset();
UE_LOG( LogStereoPanorama, Log, TEXT( " ... done!" ), *AtlasName );
return SphericalAtlas;
}
示例10: GetTotalSeconds
float UKismetMathLibrary::GetTotalSeconds( FTimespan A )
{
return A.GetTotalSeconds();
}
示例11: GetTotalMinutes
float UKismetMathLibrary::GetTotalMinutes( FTimespan A )
{
return A.GetTotalMinutes();
}
示例12: GetSeconds
int32 UKismetMathLibrary::GetSeconds( FTimespan A )
{
return A.GetSeconds();
}
示例13: GetMinutes
int32 UKismetMathLibrary::GetMinutes( FTimespan A )
{
return A.GetMinutes();
}
示例14: GetHours
int32 UKismetMathLibrary::GetHours( FTimespan A )
{
return A.GetHours();
}
示例15: GetDuration
FTimespan UKismetMathLibrary::GetDuration( FTimespan A )
{
return A.GetDuration();
}