Files
UnrealEngineUWP/Engine/Source/Runtime/TimeManagement/Public/CommonFrameRates.h
matt johnson 4c040cf127 TimeManagement: add FCommonFrameRates::Find() overload to allow frame rate lookup by FPS
This new Find() overload allows finding a common frame rate given its value as a decimal number of
frames per second.

#rb max.chen, alejandro.arango, jason.walter
#preflight 61aff20e643ecfe8b06472ff

#ROBOMERGE-AUTHOR: matt.johnson
#ROBOMERGE-SOURCE: CL 18407690 in //UE5/Release-5.0/... via CL 18407710
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v897-18405271)

[CL 18407716 by matt johnson in ue5-release-engine-test branch]
2021-12-08 12:33:32 -05:00

74 lines
2.9 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Misc/FrameRate.h"
#include "Containers/ArrayView.h"
enum class ECommonFrameRate : uint8
{
FPS_12,
FPS_15,
FPS_24,
FPS_25,
FPS_30,
FPS_48,
FPS_50,
FPS_60,
FPS_100,
FPS_120,
FPS_240,
NTSC_24,
NTSC_30,
NTSC_60,
Private_Num
};
struct FCommonFrameRateInfo
{
FFrameRate FrameRate;
FText DisplayName;
FText Description;
};
struct TIMEMANAGEMENT_API FCommonFrameRates
{
typedef __underlying_type(ECommonFrameRate) NumericType;
FORCEINLINE static FFrameRate FPS_12() { return AllFrameRates[(NumericType)ECommonFrameRate::FPS_12].FrameRate; }
FORCEINLINE static FFrameRate FPS_15() { return AllFrameRates[(NumericType)ECommonFrameRate::FPS_15].FrameRate; }
FORCEINLINE static FFrameRate FPS_24() { return AllFrameRates[(NumericType)ECommonFrameRate::FPS_24].FrameRate; }
FORCEINLINE static FFrameRate FPS_25() { return AllFrameRates[(NumericType)ECommonFrameRate::FPS_25].FrameRate; }
FORCEINLINE static FFrameRate FPS_30() { return AllFrameRates[(NumericType)ECommonFrameRate::FPS_30].FrameRate; }
FORCEINLINE static FFrameRate FPS_48() { return AllFrameRates[(NumericType)ECommonFrameRate::FPS_48].FrameRate; }
FORCEINLINE static FFrameRate FPS_50() { return AllFrameRates[(NumericType)ECommonFrameRate::FPS_50].FrameRate; }
FORCEINLINE static FFrameRate FPS_60() { return AllFrameRates[(NumericType)ECommonFrameRate::FPS_60].FrameRate; }
FORCEINLINE static FFrameRate FPS_100() { return AllFrameRates[(NumericType)ECommonFrameRate::FPS_100].FrameRate; }
FORCEINLINE static FFrameRate FPS_120() { return AllFrameRates[(NumericType)ECommonFrameRate::FPS_120].FrameRate; }
FORCEINLINE static FFrameRate FPS_240() { return AllFrameRates[(NumericType)ECommonFrameRate::FPS_240].FrameRate; }
FORCEINLINE static FFrameRate NTSC_24() { return AllFrameRates[(NumericType)ECommonFrameRate::NTSC_24].FrameRate; }
FORCEINLINE static FFrameRate NTSC_30() { return AllFrameRates[(NumericType)ECommonFrameRate::NTSC_30].FrameRate; }
FORCEINLINE static FFrameRate NTSC_60() { return AllFrameRates[(NumericType)ECommonFrameRate::NTSC_60].FrameRate; }
static TArrayView<const FCommonFrameRateInfo> GetAll();
static bool Contains(FFrameRate FrameRateToCheck)
{
return Find(FrameRateToCheck) != nullptr;
}
static const FCommonFrameRateInfo* Find(FFrameRate InFrameRate);
/** Find a common frame rate that matches the given frame rate as a decimal number of frames per second.
*
* @param InFrameRateAsDecimal: Frame rate (in frames per second) to search for.
* @param Tolerance: Numerical tolerance to use when searching for a frame rate match.
* @return: a pointer to the matching common frame rate if a match was found, or nullptr otherwise.
*/
static const FCommonFrameRateInfo* Find(const double InFrameRateAsDecimal, const double Tolerance = DOUBLE_KINDA_SMALL_NUMBER);
private:
static const FCommonFrameRateInfo AllFrameRates[(int32)ECommonFrameRate::Private_Num];
};