File size: 14,156 Bytes
7fd553e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 | // Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "GameFramework/GameUserSettings.h"
#include "InputCoreTypes.h"
#include "LyraSettingsLocal.generated.h"
enum class ECommonInputType : uint8;
enum class ELyraDisplayablePerformanceStat : uint8;
enum class ELyraStatDisplayMode : uint8;
class ULyraLocalPlayer;
class UObject;
class USoundControlBus;
class USoundControlBusMix;
struct FFrame;
USTRUCT()
struct FLyraScalabilitySnapshot
{
GENERATED_BODY()
FLyraScalabilitySnapshot();
Scalability::FQualityLevels Qualities;
bool bActive = false;
bool bHasOverrides = false;
};
/**
* ULyraSettingsLocal
*/
UCLASS()
class ULyraSettingsLocal : public UGameUserSettings
{
GENERATED_BODY()
public:
ULyraSettingsLocal();
static ULyraSettingsLocal* Get();
//~UObject interface
virtual void BeginDestroy() override;
//~End of UObject interface
//~UGameUserSettings interface
virtual void SetToDefaults() override;
virtual void LoadSettings(bool bForceReload) override;
virtual void ConfirmVideoMode() override;
virtual float GetEffectiveFrameRateLimit() override;
virtual void ResetToCurrentSettings() override;
virtual void ApplyNonResolutionSettings() override;
virtual int32 GetOverallScalabilityLevel() const override;
virtual void SetOverallScalabilityLevel(int32 Value) override;
//~End of UGameUserSettings interface
void OnExperienceLoaded();
void OnHotfixDeviceProfileApplied();
//////////////////////////////////////////////////////////////////
// Frontend state
public:
void SetShouldUseFrontendPerformanceSettings(bool bInFrontEnd);
protected:
bool ShouldUseFrontendPerformanceSettings() const;
private:
bool bInFrontEndForPerformancePurposes = false;
//////////////////////////////////////////////////////////////////
// Performance stats
public:
/** Returns the display mode for the specified performance stat */
ELyraStatDisplayMode GetPerfStatDisplayState(ELyraDisplayablePerformanceStat Stat) const;
/** Sets the display mode for the specified performance stat */
void SetPerfStatDisplayState(ELyraDisplayablePerformanceStat Stat, ELyraStatDisplayMode DisplayMode);
/** Fired when the display state for a performance stat has changed, or the settings are applied */
DECLARE_EVENT(ULyraSettingsLocal, FPerfStatSettingsChanged);
FPerfStatSettingsChanged& OnPerfStatDisplayStateChanged() { return PerfStatSettingsChangedEvent; }
// Latency flash indicators
static bool DoesPlatformSupportLatencyMarkers();
DECLARE_EVENT(ULyraSettingsLocal, FLatencyFlashInidicatorSettingChanged);
UFUNCTION()
void SetEnableLatencyFlashIndicators(const bool bNewVal);
UFUNCTION()
bool GetEnableLatencyFlashIndicators() const { return bEnableLatencyFlashIndicators; }
FLatencyFlashInidicatorSettingChanged& OnLatencyFlashInidicatorSettingsChangedEvent() { return LatencyFlashInidicatorSettingsChangedEvent; }
// Latency tracking stats
static bool DoesPlatformSupportLatencyTrackingStats();
DECLARE_EVENT(ULyraSettingsLocal, FLatencyStatEnabledSettingChanged);
FLatencyStatEnabledSettingChanged& OnLatencyStatIndicatorSettingsChangedEvent() { return LatencyStatIndicatorSettingsChangedEvent; }
UFUNCTION()
void SetEnableLatencyTrackingStats(const bool bNewVal);
UFUNCTION()
bool GetEnableLatencyTrackingStats() const { return bEnableLatencyTrackingStats; }
private:
void ApplyLatencyTrackingStatSetting();
// List of stats to display in the HUD
UPROPERTY(Config)
TMap<ELyraDisplayablePerformanceStat, ELyraStatDisplayMode> DisplayStatList;
// Event for display stat widget containers to bind to
FPerfStatSettingsChanged PerfStatSettingsChangedEvent;
// If true, enable latency flash markers which can be used to measure input latency.
UPROPERTY(Config)
bool bEnableLatencyFlashIndicators = false;
// Event for when the latency flash indicator setting had changed for player input to bind to.
FLatencyFlashInidicatorSettingChanged LatencyFlashInidicatorSettingsChangedEvent;
// Event for when the latency stats being toggled on or off has changed
FLatencyStatEnabledSettingChanged LatencyStatIndicatorSettingsChangedEvent;
// If true, then the game will track latency stats via ILatencyMarkerModule modules.
// This enables you to view some more latency oriented performance stats.
// The default value is set to true if the platform supports it, false otherwise.
UPROPERTY(Config)
bool bEnableLatencyTrackingStats;
//////////////////////////////////////////////////////////////////
// Brightness/Gamma
public:
UFUNCTION()
float GetDisplayGamma() const;
UFUNCTION()
void SetDisplayGamma(float InGamma);
private:
void ApplyDisplayGamma();
UPROPERTY(Config)
float DisplayGamma = 2.2;
//////////////////////////////////////////////////////////////////
// Display
public:
UFUNCTION()
float GetFrameRateLimit_OnBattery() const;
UFUNCTION()
void SetFrameRateLimit_OnBattery(float NewLimitFPS);
UFUNCTION()
float GetFrameRateLimit_InMenu() const;
UFUNCTION()
void SetFrameRateLimit_InMenu(float NewLimitFPS);
UFUNCTION()
float GetFrameRateLimit_WhenBackgrounded() const;
UFUNCTION()
void SetFrameRateLimit_WhenBackgrounded(float NewLimitFPS);
UFUNCTION()
float GetFrameRateLimit_Always() const;
UFUNCTION()
void SetFrameRateLimit_Always(float NewLimitFPS);
protected:
void UpdateEffectiveFrameRateLimit();
private:
UPROPERTY(Config)
float FrameRateLimit_OnBattery;
UPROPERTY(Config)
float FrameRateLimit_InMenu;
UPROPERTY(Config)
float FrameRateLimit_WhenBackgrounded;
//////////////////////////////////////////////////////////////////
// Display - Mobile quality settings
public:
static int32 GetDefaultMobileFrameRate();
static int32 GetMaxMobileFrameRate();
static bool IsSupportedMobileFramePace(int32 TestFPS);
// Returns the first frame rate at which overall quality is restricted/limited by the current device profile
int32 GetFirstFrameRateWithQualityLimit() const;
// Returns the lowest quality at which there's a limit on the overall frame rate (or -1 if there is no limit)
int32 GetLowestQualityWithFrameRateLimit() const;
void ResetToMobileDeviceDefaults();
int32 GetMaxSupportedOverallQualityLevel() const;
private:
void SetMobileFPSMode(int32 NewLimitFPS);
void ClampMobileResolutionQuality(int32 TargetFPS);
void RemapMobileResolutionQuality(int32 FromFPS, int32 ToFPS);
void ClampMobileFPSQualityLevels(bool bWriteBack);
void ClampMobileQuality();
int32 GetHighestLevelOfAnyScalabilityChannel() const;
/* Modifies the input levels based on the active mode's overrides */
void OverrideQualityLevelsToScalabilityMode(const FLyraScalabilitySnapshot& InMode, Scalability::FQualityLevels& InOutLevels);
/* Clamps the input levels based on the active device profile's default allowed levels */
void ClampQualityLevelsToDeviceProfile(const Scalability::FQualityLevels& ClampLevels, Scalability::FQualityLevels& InOutLevels);
public:
int32 GetDesiredMobileFrameRateLimit() const { return DesiredMobileFrameRateLimit; }
void SetDesiredMobileFrameRateLimit(int32 NewLimitFPS);
private:
UPROPERTY(Config)
int32 MobileFrameRateLimit = 30;
FLyraScalabilitySnapshot DeviceDefaultScalabilitySettings;
bool bSettingOverallQualityGuard = false;
int32 DesiredMobileFrameRateLimit = 0;
private:
//////////////////////////////////////////////////////////////////
// Display - Console quality presets
public:
UFUNCTION()
FString GetDesiredDeviceProfileQualitySuffix() const;
UFUNCTION()
void SetDesiredDeviceProfileQualitySuffix(const FString& InDesiredSuffix);
protected:
/** Updates device profiles, FPS mode etc for the current game mode */
void UpdateGameModeDeviceProfileAndFps();
void UpdateConsoleFramePacing();
void UpdateDesktopFramePacing();
void UpdateMobileFramePacing();
void UpdateDynamicResFrameTime(float TargetFPS);
private:
UPROPERTY(Transient)
FString DesiredUserChosenDeviceProfileSuffix;
UPROPERTY(Transient)
FString CurrentAppliedDeviceProfileOverrideSuffix;
UPROPERTY(config)
FString UserChosenDeviceProfileSuffix;
//////////////////////////////////////////////////////////////////
// Audio - Volume
public:
DECLARE_EVENT_OneParam(ULyraSettingsLocal, FAudioDeviceChanged, const FString& /*DeviceId*/);
FAudioDeviceChanged OnAudioOutputDeviceChanged;
public:
/** Returns if we're using headphone mode (HRTF) **/
UFUNCTION()
bool IsHeadphoneModeEnabled() const;
/** Enables or disables headphone mode (HRTF) - NOTE this setting will be overruled if au.DisableBinauralSpatialization is set */
UFUNCTION()
void SetHeadphoneModeEnabled(bool bEnabled);
/** Returns if we can enable/disable headphone mode (i.e., if it's not forced on or off by the platform) */
UFUNCTION()
bool CanModifyHeadphoneModeEnabled() const;
public:
/** Whether we *want* to use headphone mode (HRTF); may or may not actually be applied **/
UPROPERTY(Transient)
bool bDesiredHeadphoneMode;
private:
/** Whether to use headphone mode (HRTF) **/
UPROPERTY(config)
bool bUseHeadphoneMode;
public:
/** Returns if we're using High Dynamic Range Audio mode (HDR Audio) **/
UFUNCTION()
bool IsHDRAudioModeEnabled() const;
/** Enables or disables High Dynamic Range Audio mode (HDR Audio) */
UFUNCTION()
void SetHDRAudioModeEnabled(bool bEnabled);
/** Whether to use High Dynamic Range Audio mode (HDR Audio) **/
UPROPERTY(config)
bool bUseHDRAudioMode;
public:
/** Returns true if this platform can run the auto benchmark */
UFUNCTION(BlueprintCallable, Category = Settings)
bool CanRunAutoBenchmark() const;
/** Returns true if this user should run the auto benchmark as it has never been run */
UFUNCTION(BlueprintCallable, Category = Settings)
bool ShouldRunAutoBenchmarkAtStartup() const;
/** Run the auto benchmark, optionally saving right away */
UFUNCTION(BlueprintCallable, Category = Settings)
void RunAutoBenchmark(bool bSaveImmediately);
/** Apply just the quality scalability settings */
void ApplyScalabilitySettings();
UFUNCTION()
float GetOverallVolume() const;
UFUNCTION()
void SetOverallVolume(float InVolume);
UFUNCTION()
float GetMusicVolume() const;
UFUNCTION()
void SetMusicVolume(float InVolume);
UFUNCTION()
float GetSoundFXVolume() const;
UFUNCTION()
void SetSoundFXVolume(float InVolume);
UFUNCTION()
float GetDialogueVolume() const;
UFUNCTION()
void SetDialogueVolume(float InVolume);
UFUNCTION()
float GetVoiceChatVolume() const;
UFUNCTION()
void SetVoiceChatVolume(float InVolume);
//////////////////////////////////////////////////////////////////
// Audio - Sound
public:
/** Returns the user's audio device id */
UFUNCTION()
FString GetAudioOutputDeviceId() const { return AudioOutputDeviceId; }
/** Sets the user's audio device by id */
UFUNCTION()
void SetAudioOutputDeviceId(const FString& InAudioOutputDeviceId);
private:
UPROPERTY(Config)
FString AudioOutputDeviceId;
void SetVolumeForSoundClass(FName ChannelName, float InVolume);
//////////////////////////////////////////////////////////////////
// Safezone
public:
UFUNCTION()
bool IsSafeZoneSet() const { return SafeZoneScale != -1; }
UFUNCTION()
float GetSafeZone() const { return SafeZoneScale >= 0 ? SafeZoneScale : 0; }
UFUNCTION()
void SetSafeZone(float Value) { SafeZoneScale = Value; ApplySafeZoneScale(); }
void ApplySafeZoneScale();
private:
void SetVolumeForControlBus(USoundControlBus* InSoundControlBus, float InVolume);
//////////////////////////////////////////////////////////////////
// Keybindings
public:
// Sets the controller representation to use, a single platform might support multiple kinds of controllers. For
// example, Win64 games could be played with both an XBox or Playstation controller.
UFUNCTION()
void SetControllerPlatform(const FName InControllerPlatform);
UFUNCTION()
FName GetControllerPlatform() const;
private:
void LoadUserControlBusMix();
UPROPERTY(Config)
float OverallVolume = 1.0f;
UPROPERTY(Config)
float MusicVolume = 1.0f;
UPROPERTY(Config)
float SoundFXVolume = 1.0f;
UPROPERTY(Config)
float DialogueVolume = 1.0f;
UPROPERTY(Config)
float VoiceChatVolume = 1.0f;
UPROPERTY(Transient)
TMap<FName/*SoundClassName*/, TObjectPtr<USoundControlBus>> ControlBusMap;
UPROPERTY(Transient)
TObjectPtr<USoundControlBusMix> ControlBusMix = nullptr;
UPROPERTY(Transient)
bool bSoundControlBusMixLoaded;
UPROPERTY(Config)
float SafeZoneScale = -1;
/**
* The name of the controller the player is using. This is maps to the name of a UCommonInputBaseControllerData
* that is available on this current platform. The gamepad data are registered per platform, you'll find them
* in <Platform>Game.ini files listed under +ControllerData=...
*/
UPROPERTY(Config)
FName ControllerPlatform;
UPROPERTY(Config)
FName ControllerPreset = TEXT("Default");
/** The name of the current input config that the user has selected. */
UPROPERTY(Config)
FName InputConfigName = TEXT("Default");
// Replays
public:
UFUNCTION()
bool ShouldAutoRecordReplays() const { return bShouldAutoRecordReplays; }
UFUNCTION()
void SetShouldAutoRecordReplays(bool bEnabled) { bShouldAutoRecordReplays = bEnabled;}
UFUNCTION()
int32 GetNumberOfReplaysToKeep() const { return NumberOfReplaysToKeep; }
UFUNCTION()
void SetNumberOfReplaysToKeep(int32 InNumberOfReplays) { NumberOfReplaysToKeep = InNumberOfReplays; }
private:
UPROPERTY(Config)
bool bShouldAutoRecordReplays = false;
UPROPERTY(Config)
int32 NumberOfReplaysToKeep = 5;
private:
void OnAppActivationStateChanged(bool bIsActive);
void ReapplyThingsDueToPossibleDeviceProfileChange();
private:
FDelegateHandle OnApplicationActivationStateChangedHandle;
};
|