graphics settings code
This commit is contained in:
parent
07f34a7c6b
commit
509d2e9c98
@ -27,14 +27,6 @@ void ACameraModeBase::BeginPlay()
|
|||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
|
||||||
auto world = GetWorld();
|
auto world = GetWorld();
|
||||||
|
|
||||||
if(auto gameSettings = UCustomGameSettings::Get())
|
|
||||||
{
|
|
||||||
if(auto camera = FindComponentByClass<UCameraComponent>())
|
|
||||||
{
|
|
||||||
camera->PostProcessSettings.MotionBlurAmount = gameSettings->bUseMotionBlur ? 1.0f : 0.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACameraModeBase::Tick(float DeltaTime)
|
void ACameraModeBase::Tick(float DeltaTime)
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
// Oleg Petruny proprietary.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
|
||||||
|
namespace CommonTexts
|
||||||
|
{
|
||||||
|
const FText Default = NSLOCTEXT("CommonTexts", "Default", "Default");
|
||||||
|
}
|
@ -4,11 +4,12 @@
|
|||||||
|
|
||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
|
||||||
|
#include "GraphicsSettingsHelper.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
/** Game */
|
/** Graphics */
|
||||||
constexpr float fDefaultMouseSensetivity = 0.5f;
|
constexpr bool bDefaultShowFps = false;
|
||||||
constexpr bool bDefaultMouseInverted = false;
|
|
||||||
|
|
||||||
/** Audio */
|
/** Audio */
|
||||||
constexpr float fDefaultMasterVolume = 0.4f;
|
constexpr float fDefaultMasterVolume = 0.4f;
|
||||||
@ -16,12 +17,17 @@ namespace
|
|||||||
constexpr float fDefaultEffectsVolume = 1.0f;
|
constexpr float fDefaultEffectsVolume = 1.0f;
|
||||||
constexpr float fDefaultVoicesVolume = 1.0f;
|
constexpr float fDefaultVoicesVolume = 1.0f;
|
||||||
constexpr float fDefaultMenuVolume = 1.0f;
|
constexpr float fDefaultMenuVolume = 1.0f;
|
||||||
|
|
||||||
|
/** Game */
|
||||||
|
constexpr float fDefaultMouseSensetivity = 0.5f;
|
||||||
|
constexpr bool bDefaultMouseInverted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
UCustomGameSettings::UCustomGameSettings(const FObjectInitializer& ObjectInitializer) :Super(ObjectInitializer)
|
UCustomGameSettings::UCustomGameSettings(const FObjectInitializer& ObjectInitializer) :Super(ObjectInitializer)
|
||||||
{
|
{
|
||||||
bUseMotionBlur = false;
|
/** Graphics */
|
||||||
bShowFps = false;
|
bShowFps = GetDefaultShowFps();
|
||||||
|
UGraphicsSettingsHelper::SetDefaults(this);
|
||||||
|
|
||||||
/** Audio */
|
/** Audio */
|
||||||
fMasterVolume = GetDefaultMasterVolume();
|
fMasterVolume = GetDefaultMasterVolume();
|
||||||
@ -40,6 +46,11 @@ UCustomGameSettings* UCustomGameSettings::Get()
|
|||||||
return Cast<UCustomGameSettings>(UGameUserSettings::GetGameUserSettings());
|
return Cast<UCustomGameSettings>(UGameUserSettings::GetGameUserSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOST_EDGE_API bool UCustomGameSettings::GetDefaultShowFps() const
|
||||||
|
{
|
||||||
|
return bDefaultShowFps;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Audio */
|
/** Audio */
|
||||||
|
@ -15,78 +15,78 @@ class UCustomGameSettings : public UGameUserSettings
|
|||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
friend class UGraphicsSettingsHelper;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Is auto defined by UE but implementation is in cpp
|
// Is auto defined by UE but implementation is in cpp
|
||||||
UCustomGameSettings(const FObjectInitializer& ObjectInitializer);
|
UCustomGameSettings(const FObjectInitializer& ObjectInitializer);
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure, Category = Settings, meta = (DisplayName = "Get Custom Game Settings"))
|
UFUNCTION(BlueprintPure, Category = "Settings", meta = (DisplayName = "Get Custom Game Settings"))
|
||||||
static UCustomGameSettings* Get();
|
static UCustomGameSettings* Get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Graphics */
|
/** Graphics */
|
||||||
UPROPERTY(Config, BlueprintReadWrite)
|
UFUNCTION(BlueprintPure, Category = "Settings|Graphics")
|
||||||
bool bUseMotionBlur;
|
LOST_EDGE_API inline bool GetDefaultShowFps() const;
|
||||||
|
UPROPERTY(Config, BlueprintReadWrite, Category = "Settings|Graphics")
|
||||||
UPROPERTY(Config, BlueprintReadWrite)
|
|
||||||
bool bShowFps;
|
bool bShowFps;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Audio
|
* Audio
|
||||||
* All values are clamped in [0.0 - 1.0]
|
* All values are clamped in [0.0 - 1.0]
|
||||||
*/
|
*/
|
||||||
UFUNCTION(BlueprintPure, Category = Settings)
|
UFUNCTION(BlueprintPure, Category = "Settings|Audio")
|
||||||
LOST_EDGE_API inline float GetDefaultMasterVolume() const; // UFUNCTION doesn't support constexpr functions
|
LOST_EDGE_API inline float GetDefaultMasterVolume() const; // UFUNCTION doesn't support constexpr functions
|
||||||
UFUNCTION(BlueprintPure, Category = Settings)
|
UFUNCTION(BlueprintPure, Category = "Settings|Audio")
|
||||||
LOST_EDGE_API inline float GetDefaultMusicVolume() const; // UFUNCTION doesn't support constexpr functions
|
LOST_EDGE_API inline float GetDefaultMusicVolume() const; // UFUNCTION doesn't support constexpr functions
|
||||||
UFUNCTION(BlueprintPure, Category = Settings)
|
UFUNCTION(BlueprintPure, Category = "Settings|Audio")
|
||||||
LOST_EDGE_API inline float GetDefaultEffectsVolume() const; // UFUNCTION doesn't support constexpr functions
|
LOST_EDGE_API inline float GetDefaultEffectsVolume() const; // UFUNCTION doesn't support constexpr functions
|
||||||
UFUNCTION(BlueprintPure, Category = Settings)
|
UFUNCTION(BlueprintPure, Category = "Settings|Audio")
|
||||||
LOST_EDGE_API inline float GetDefaultVoicesVolume() const; // UFUNCTION doesn't support constexpr functions
|
LOST_EDGE_API inline float GetDefaultVoicesVolume() const; // UFUNCTION doesn't support constexpr functions
|
||||||
UFUNCTION(BlueprintPure, Category = Settings)
|
UFUNCTION(BlueprintPure, Category = "Settings|Audio")
|
||||||
LOST_EDGE_API inline float GetDefaultMenuVolume() const; // UFUNCTION doesn't support constexpr functions
|
LOST_EDGE_API inline float GetDefaultMenuVolume() const; // UFUNCTION doesn't support constexpr functions
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure, Category = Settings)
|
UFUNCTION(BlueprintPure, Category = "Settings|Audio")
|
||||||
float GetMasterVolume() const;
|
float GetMasterVolume() const;
|
||||||
UFUNCTION(BlueprintPure, Category = Settings)
|
UFUNCTION(BlueprintPure, Category = "Settings|Audio")
|
||||||
float GetMusicVolume() const;
|
float GetMusicVolume() const;
|
||||||
UFUNCTION(BlueprintPure, Category = Settings)
|
UFUNCTION(BlueprintPure, Category = "Settings|Audio")
|
||||||
float GetEffectsVolume() const;
|
float GetEffectsVolume() const;
|
||||||
UFUNCTION(BlueprintPure, Category = Settings)
|
UFUNCTION(BlueprintPure, Category = "Settings|Audio")
|
||||||
float GetVoicesVolume() const;
|
float GetVoicesVolume() const;
|
||||||
UFUNCTION(BlueprintPure, Category = Settings)
|
UFUNCTION(BlueprintPure, Category = "Settings|Audio")
|
||||||
float GetMenuVolume() const;
|
float GetMenuVolume() const;
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = Settings)
|
UFUNCTION(BlueprintCallable, Category = "Settings|Audio")
|
||||||
void SetMasterVolume(float value);
|
void SetMasterVolume(float value);
|
||||||
UFUNCTION(BlueprintCallable, Category = Settings)
|
UFUNCTION(BlueprintCallable, Category = "Settings|Audio")
|
||||||
void SetMusicVolume(float value);
|
void SetMusicVolume(float value);
|
||||||
UFUNCTION(BlueprintCallable, Category = Settings)
|
UFUNCTION(BlueprintCallable, Category = "Settings|Audio")
|
||||||
void SetEffectsVolume(float value);
|
void SetEffectsVolume(float value);
|
||||||
UFUNCTION(BlueprintCallable, Category = Settings)
|
UFUNCTION(BlueprintCallable, Category = "Settings|Audio")
|
||||||
void SetVoicesVolume(float value);
|
void SetVoicesVolume(float value);
|
||||||
UFUNCTION(BlueprintCallable, Category = Settings)
|
UFUNCTION(BlueprintCallable, Category = "Settings|Audio")
|
||||||
void SetMenuVolume(float value);
|
void SetMenuVolume(float value);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Game */
|
/** Game */
|
||||||
UFUNCTION(BlueprintPure, Category = Settings)
|
UFUNCTION(BlueprintPure, Category = "Settings|Game")
|
||||||
LOST_EDGE_API inline float GetDefaultMouseSensetivity() const;
|
LOST_EDGE_API inline float GetDefaultMouseSensetivity() const;
|
||||||
/** Returns mouse sensetivity multiplier in [0.1 - 2.0] */
|
/** Returns mouse sensetivity multiplier in [0.1 - 2.0] */
|
||||||
UFUNCTION(BlueprintPure, Category = Settings)
|
UFUNCTION(BlueprintPure, Category = "Settings|Game")
|
||||||
float GetMouseSensetivity() const;
|
float GetMouseSensetivity() const;
|
||||||
/**
|
/**
|
||||||
* Sets mouse sensetivity multiplier
|
* Sets mouse sensetivity multiplier
|
||||||
* @param value [0.1 - 2.0]
|
* @param value [0.1 - 2.0]
|
||||||
*/
|
*/
|
||||||
UFUNCTION(BlueprintCallable, Category = Settings)
|
UFUNCTION(BlueprintCallable, Category = "Settings|Game")
|
||||||
void SetMouseSensetivity(float value);
|
void SetMouseSensetivity(float value);
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure, Category = Settings)
|
UFUNCTION(BlueprintPure, Category = "Settings|Game")
|
||||||
LOST_EDGE_API inline bool GetDefaultMouseInverted() const;
|
LOST_EDGE_API inline bool GetDefaultMouseInverted() const;
|
||||||
UPROPERTY(Config, BlueprintReadWrite)
|
UPROPERTY(Config, BlueprintReadWrite, Category = "Settings|Game")
|
||||||
bool bMouseInverted;
|
bool bMouseInverted;
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,15 +5,44 @@
|
|||||||
#include "GenericPlatform/GenericApplication.h"
|
#include "GenericPlatform/GenericApplication.h"
|
||||||
|
|
||||||
#include "CommonFunctions.h"
|
#include "CommonFunctions.h"
|
||||||
|
#include "CommonTexts.h"
|
||||||
#include "CustomGameSettings.h"
|
#include "CustomGameSettings.h"
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const FIntPoint ipDefaultWindowPosition = { 0, 0 };
|
const FIntPoint ipDefaultWindowPosition = { 0, 0 };
|
||||||
|
std::optional<FIntPoint> ipPreviousWindowPosition;
|
||||||
constexpr int32 iDefaultMonitorId = 0;
|
constexpr int32 iDefaultMonitorId = 0;
|
||||||
const FIntPoint ipDefaultResolution = { 1920, 1080 };
|
const FIntPoint ipDefaultResolution = { 1920, 1080 };
|
||||||
|
std::optional<FIntPoint> ipPreviousResolution;
|
||||||
constexpr float fDefaultResolutionScale = 1.0f;
|
constexpr float fDefaultResolutionScale = 1.0f;
|
||||||
constexpr int32 iDefaultFrameRateLimit = 120;
|
constexpr int32 iDefaultFrameRateLimit = 120;
|
||||||
|
constexpr EDisplayMode eDefaultDisplayMode = EDisplayMode::Fullscreen;
|
||||||
|
std::optional<EDisplayMode> ePreviousDisplayMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UGraphicsSettingsHelper::AreSettingsRestorable(UCustomGameSettings* settings)
|
||||||
|
{
|
||||||
|
return ipPreviousWindowPosition.has_value()
|
||||||
|
|| ipPreviousResolution.has_value()
|
||||||
|
|| ePreviousDisplayMode.has_value();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UGraphicsSettingsHelper::SetDefaults(UCustomGameSettings* settings)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
FIntPoint pos = GetDefaultWindowPosition(settings);
|
||||||
|
settings->WindowPosX = pos.X;
|
||||||
|
settings->WindowPosY = pos.Y;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
FIntPoint res = GetDefaultResolution(settings);
|
||||||
|
settings->ResolutionSizeX = res.X;
|
||||||
|
settings->ResolutionSizeY = res.Y;
|
||||||
|
}
|
||||||
|
settings->FullscreenMode = DisplayToWindowMode(GetDefaultDisplayMode(settings));
|
||||||
}
|
}
|
||||||
|
|
||||||
FIntPoint UGraphicsSettingsHelper::GetDefaultWindowPosition([[maybe_unused]] UCustomGameSettings* settings)
|
FIntPoint UGraphicsSettingsHelper::GetDefaultWindowPosition([[maybe_unused]] UCustomGameSettings* settings)
|
||||||
@ -35,18 +64,29 @@ FIntPoint UGraphicsSettingsHelper::GetWindowPosition([[maybe_unused]] UCustomGam
|
|||||||
return GetDefaultWindowPosition(settings);
|
return GetDefaultWindowPosition(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UGraphicsSettingsHelper::SetWindowPosition([[maybe_unused]] UCustomGameSettings* settings, const FIntPoint& pos)
|
void UGraphicsSettingsHelper::SetWindowPosition(UCustomGameSettings* settings, const FIntPoint& pos)
|
||||||
{
|
{
|
||||||
if(settings && GEngine && GEngine->GameViewport)
|
if(settings && GEngine && GEngine->GameViewport)
|
||||||
{
|
{
|
||||||
if(auto window = GEngine->GameViewport->GetWindow())
|
if(auto window = GEngine->GameViewport->GetWindow())
|
||||||
{
|
{
|
||||||
|
if(ipPreviousWindowPosition == pos)
|
||||||
|
ipPreviousWindowPosition.reset();
|
||||||
|
else
|
||||||
|
ipPreviousWindowPosition = GetWindowPosition(settings);
|
||||||
|
|
||||||
window->MoveWindowTo(pos);
|
window->MoveWindowTo(pos);
|
||||||
settings->SetWindowPosition(pos.X, pos.Y);
|
settings->SetWindowPosition(pos.X, pos.Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UGraphicsSettingsHelper::RestoreWindowPosition(UCustomGameSettings* settings)
|
||||||
|
{
|
||||||
|
if(!ipPreviousWindowPosition.has_value())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
SetWindowPosition(settings, ipPreviousWindowPosition.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 UGraphicsSettingsHelper::GetDefaultMonitorId([[maybe_unused]] UCustomGameSettings* settings)
|
int32 UGraphicsSettingsHelper::GetDefaultMonitorId([[maybe_unused]] UCustomGameSettings* settings)
|
||||||
@ -120,6 +160,11 @@ void UGraphicsSettingsHelper::SetMonitor(UCustomGameSettings* settings, const in
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UGraphicsSettingsHelper::RestoreMonitor(UCustomGameSettings* settings)
|
||||||
|
{
|
||||||
|
RestoreWindowPosition(settings);
|
||||||
|
}
|
||||||
|
|
||||||
FIntPoint UGraphicsSettingsHelper::GetDefaultResolution([[maybe_unused]] UCustomGameSettings* settings)
|
FIntPoint UGraphicsSettingsHelper::GetDefaultResolution([[maybe_unused]] UCustomGameSettings* settings)
|
||||||
{
|
{
|
||||||
return ipDefaultResolution;
|
return ipDefaultResolution;
|
||||||
@ -223,9 +268,23 @@ void UGraphicsSettingsHelper::SetResolution(UCustomGameSettings* settings, const
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
settings->bUseDynamicResolution = true;
|
settings->bUseDynamicResolution = true;
|
||||||
|
|
||||||
|
if(ipPreviousResolution.has_value() && ipPreviousResolution == resolution)
|
||||||
|
ipPreviousResolution.reset();
|
||||||
|
else
|
||||||
|
ipPreviousResolution = resolution;
|
||||||
|
|
||||||
settings->SetScreenResolution(resolution);
|
settings->SetScreenResolution(resolution);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UGraphicsSettingsHelper::RestoreResolution(UCustomGameSettings* settings)
|
||||||
|
{
|
||||||
|
if(!ipPreviousResolution.has_value())
|
||||||
|
return;
|
||||||
|
|
||||||
|
SetResolution(settings, ipPreviousResolution.value());
|
||||||
|
}
|
||||||
|
|
||||||
float UGraphicsSettingsHelper::GetDefaultResolutionScale([[maybe_unused]] UCustomGameSettings* settings)
|
float UGraphicsSettingsHelper::GetDefaultResolutionScale([[maybe_unused]] UCustomGameSettings* settings)
|
||||||
{
|
{
|
||||||
return fDefaultResolutionScale;
|
return fDefaultResolutionScale;
|
||||||
@ -295,3 +354,85 @@ TArray<FIntPoint> UGraphicsSettingsHelper::GetAvailableAspectRatiousOfMonitor(co
|
|||||||
return aspects.Array();
|
return aspects.Array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EDisplayMode UGraphicsSettingsHelper::GetDefaultDisplayMode([[maybe_unused]] UCustomGameSettings* settings)
|
||||||
|
{
|
||||||
|
return eDefaultDisplayMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
EDisplayMode UGraphicsSettingsHelper::GetDisplayMode(UCustomGameSettings* settings)
|
||||||
|
{
|
||||||
|
if(!settings)
|
||||||
|
return GetDefaultDisplayMode(settings);
|
||||||
|
|
||||||
|
return WindowToDisplayMode(settings->GetFullscreenMode());
|
||||||
|
}
|
||||||
|
|
||||||
|
EDisplayMode UGraphicsSettingsHelper::TextToDisplayMode(const FText& in)
|
||||||
|
{
|
||||||
|
static const UEnum* enumPtr = FindObject<UEnum>(ANY_PACKAGE, TEXT("EDisplayMode"), true);
|
||||||
|
if(!enumPtr)
|
||||||
|
return GetDefaultDisplayMode(nullptr);
|
||||||
|
|
||||||
|
return static_cast<EDisplayMode>(enumPtr->GetValueByName(FName{ *FTextInspector::GetSourceString(in) }));
|
||||||
|
}
|
||||||
|
|
||||||
|
FText UGraphicsSettingsHelper::DisplayModeToText(const EDisplayMode mode)
|
||||||
|
{
|
||||||
|
static const UEnum* enumPtr = FindObject<UEnum>(ANY_PACKAGE, TEXT("EDisplayMode"), true);
|
||||||
|
if(!enumPtr)
|
||||||
|
return CommonTexts::Default;
|
||||||
|
|
||||||
|
return enumPtr->GetDisplayNameTextByIndex(static_cast<int32>(mode));
|
||||||
|
}
|
||||||
|
|
||||||
|
void UGraphicsSettingsHelper::SetDisplayMode(UCustomGameSettings* settings, const EDisplayMode mode)
|
||||||
|
{
|
||||||
|
if(!settings)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(ePreviousDisplayMode.has_value() && ePreviousDisplayMode == mode)
|
||||||
|
ePreviousDisplayMode.reset();
|
||||||
|
else
|
||||||
|
ePreviousDisplayMode = mode;
|
||||||
|
|
||||||
|
settings->SetFullscreenMode(DisplayToWindowMode(mode));
|
||||||
|
}
|
||||||
|
|
||||||
|
void UGraphicsSettingsHelper::RestoreDisplayMode(UCustomGameSettings* settings)
|
||||||
|
{
|
||||||
|
if(!ePreviousDisplayMode.has_value())
|
||||||
|
return;
|
||||||
|
|
||||||
|
SetDisplayMode(settings, ePreviousDisplayMode.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr EDisplayMode UGraphicsSettingsHelper::WindowToDisplayMode(const EWindowMode::Type mode)
|
||||||
|
{
|
||||||
|
switch(mode)
|
||||||
|
{
|
||||||
|
case EWindowMode::Type::WindowedFullscreen:
|
||||||
|
return EDisplayMode::Borderless;
|
||||||
|
case EWindowMode::Type::Windowed:
|
||||||
|
return EDisplayMode::Windowed;
|
||||||
|
case EWindowMode::Type::Fullscreen:
|
||||||
|
default:
|
||||||
|
return EDisplayMode::Fullscreen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr EWindowMode::Type UGraphicsSettingsHelper::DisplayToWindowMode(const EDisplayMode mode)
|
||||||
|
{
|
||||||
|
switch(mode)
|
||||||
|
{
|
||||||
|
case EDisplayMode::Borderless:
|
||||||
|
return EWindowMode::Type::WindowedFullscreen;
|
||||||
|
case EDisplayMode::Windowed:
|
||||||
|
return EWindowMode::Type::Windowed;
|
||||||
|
case EDisplayMode::Fullscreen:
|
||||||
|
default:
|
||||||
|
return EWindowMode::Type::Fullscreen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,19 +18,20 @@ public:
|
|||||||
TArray<int32> refreshRates;
|
TArray<int32> refreshRates;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Redefine of EWindowType, because it has duplicate without blueprint macro */
|
||||||
UENUM(BlueprintType, Category = "Settings|Graphics|Enums")
|
UENUM(BlueprintType, Category = "Settings|Graphics|Enums")
|
||||||
enum class EDisplayMode : uint8
|
enum class EDisplayMode : uint8
|
||||||
{
|
{
|
||||||
Fullscreen = 0,
|
Fullscreen = 0 UMETA(DisplayName = "Fullscreen"),
|
||||||
Borderless = 1,
|
Borderless = 1 UMETA(DisplayName = "Borderless"),
|
||||||
Windowed = 2
|
Windowed = 2 UMETA(DisplayName = "Windowed")
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper for trivial and complex graphic settings.
|
* Helper for trivial and complex graphic settings.
|
||||||
* Most of functions work without settings pointer. It is there just for Blueprint call convinience.
|
* Most of functions work without settings pointer. It is there just for Blueprint call convinience.
|
||||||
* Helps with window position, monitor selection, resolution, resolution scale, frame rate limit, aspect ratio,
|
* Helps with window position, monitor selection, resolution, resolution scale, frame rate limit, aspect ratio, display mode.
|
||||||
* display mode and gamma.
|
*
|
||||||
*/
|
*/
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class UGraphicsSettingsHelper : public UBlueprintFunctionLibrary
|
class UGraphicsSettingsHelper : public UBlueprintFunctionLibrary
|
||||||
@ -38,13 +39,22 @@ class UGraphicsSettingsHelper : public UBlueprintFunctionLibrary
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
UFUNCTION(BlueprintPure, Category = "Settings|Graphics", meta = (DisplayName = "AreGraphicsSettingsRestorable"))
|
||||||
|
static bool AreSettingsRestorable(class UCustomGameSettings* settings);
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Settings|Graphics", meta = (DisplayName = "SetGraphicsDefaults"))
|
||||||
|
static void SetDefaults(class UCustomGameSettings* settings);
|
||||||
|
|
||||||
|
protected: // Window position setting is on the thin edge of user safeness, therefore protected. Please use SetMonitor().
|
||||||
UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Window")
|
UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Window")
|
||||||
static FIntPoint GetDefaultWindowPosition(class UCustomGameSettings* settings); // inline functions need API macro, but API macro with static inline function results in "no definition"
|
static FIntPoint GetDefaultWindowPosition(class UCustomGameSettings* settings); // inline functions need API macro, but API macro with static inline function results in "no definition"
|
||||||
UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Window")
|
UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Window")
|
||||||
static FIntPoint GetWindowPosition(class UCustomGameSettings* settings);
|
static FIntPoint GetWindowPosition(class UCustomGameSettings* settings);
|
||||||
UFUNCTION(BlueprintCallable, Category = "Settings|Graphics|Window")
|
UFUNCTION(BlueprintCallable, Category = "Settings|Graphics|Window")
|
||||||
static void SetWindowPosition(class UCustomGameSettings* settings, const FIntPoint& pos);
|
static void SetWindowPosition(class UCustomGameSettings* settings, const FIntPoint& pos);
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Settings|Graphics|Window")
|
||||||
|
static void RestoreWindowPosition(class UCustomGameSettings* settings);
|
||||||
|
|
||||||
|
public:
|
||||||
UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Monitor")
|
UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Monitor")
|
||||||
static int32 GetDefaultMonitorId(class UCustomGameSettings* settings);
|
static int32 GetDefaultMonitorId(class UCustomGameSettings* settings);
|
||||||
UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Monitor")
|
UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Monitor")
|
||||||
@ -56,6 +66,8 @@ public:
|
|||||||
static TArray<FMonitorInfo> GetAvailableMonitors();
|
static TArray<FMonitorInfo> GetAvailableMonitors();
|
||||||
UFUNCTION(BlueprintCallable, Category = "Settings|Graphics|Monitor")
|
UFUNCTION(BlueprintCallable, Category = "Settings|Graphics|Monitor")
|
||||||
static void SetMonitor(class UCustomGameSettings* settings, const int32 id);
|
static void SetMonitor(class UCustomGameSettings* settings, const int32 id);
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Settings|Graphics|Monitor")
|
||||||
|
static void RestoreMonitor(class UCustomGameSettings* settings);
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Resolution")
|
UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Resolution")
|
||||||
static FIntPoint GetDefaultResolution(class UCustomGameSettings* settings);
|
static FIntPoint GetDefaultResolution(class UCustomGameSettings* settings);
|
||||||
@ -73,6 +85,8 @@ public:
|
|||||||
static TArray<FIntPoint> FilterResolutionsViaAspectRatio(const TArray<FIntPoint>& resolutions, const FIntPoint& aspectRatio);
|
static TArray<FIntPoint> FilterResolutionsViaAspectRatio(const TArray<FIntPoint>& resolutions, const FIntPoint& aspectRatio);
|
||||||
UFUNCTION(BlueprintCallable, Category = "Settings|Graphics|Resolution")
|
UFUNCTION(BlueprintCallable, Category = "Settings|Graphics|Resolution")
|
||||||
static void SetResolution(class UCustomGameSettings* settings, const FIntPoint& resolution);
|
static void SetResolution(class UCustomGameSettings* settings, const FIntPoint& resolution);
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Settings|Graphics|Resolution")
|
||||||
|
static void RestoreResolution(class UCustomGameSettings* settings);
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Resolution Scale")
|
UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Resolution Scale")
|
||||||
static float GetDefaultResolutionScale(class UCustomGameSettings* settings);
|
static float GetDefaultResolutionScale(class UCustomGameSettings* settings);
|
||||||
@ -97,17 +111,20 @@ public:
|
|||||||
UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Aspect Ratio")
|
UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Aspect Ratio")
|
||||||
static TArray<FIntPoint> GetAvailableAspectRatiousOfMonitor(const int32 monitor);
|
static TArray<FIntPoint> GetAvailableAspectRatiousOfMonitor(const int32 monitor);
|
||||||
|
|
||||||
//UFUNCTION(BlueprintPure, Category = "Settings Video|Display Mode")
|
UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Display Mode")
|
||||||
//static EDisplayMode StringToDisplayMode(FString in);
|
static EDisplayMode GetDefaultDisplayMode(class UCustomGameSettings* settings);
|
||||||
//UFUNCTION(BlueprintPure, Category = "Settings Video|Display Mode")
|
UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Display Mode")
|
||||||
//static FString DisplayModeToString(EDisplayMode mode);
|
static EDisplayMode GetDisplayMode(class UCustomGameSettings* settings);
|
||||||
//UFUNCTION(BlueprintPure, Category = "Settings Video|Display Mode")
|
UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Display Mode")
|
||||||
//static void IntToDisplayMode(int in, EDisplayMode& mode);
|
static EDisplayMode TextToDisplayMode(const FText& in);
|
||||||
//UFUNCTION(BlueprintPure, Category = "Settings Video|Display Mode")
|
UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Display Mode")
|
||||||
//static void DisplayModeToInt(EDisplayMode mode, int& out);
|
static FText DisplayModeToText(const EDisplayMode mode);
|
||||||
//UFUNCTION(BlueprintPure, Category = "Settings Video|Display Mode")
|
UFUNCTION(BlueprintCallable, Category = "Settings|Graphics|Display Mode")
|
||||||
//static void GetCurrentDisplayMode(EDisplayMode& mode);
|
static void SetDisplayMode(class UCustomGameSettings* settings, const EDisplayMode mode);
|
||||||
//UFUNCTION(BlueprintCallable, Category = "Settings Video|Display Mode")
|
UFUNCTION(BlueprintCallable, Category = "Settings|Graphics|Display Mode")
|
||||||
//static void SetDisplayMode(EDisplayMode mode);
|
static void RestoreDisplayMode(class UCustomGameSettings* settings);
|
||||||
|
|
||||||
|
private:
|
||||||
|
inline constexpr static EDisplayMode WindowToDisplayMode(const EWindowMode::Type mode);
|
||||||
|
inline constexpr static EWindowMode::Type DisplayToWindowMode(const EDisplayMode mode);
|
||||||
};
|
};
|
||||||
|
@ -85,12 +85,6 @@ void APlayerBase::BeginPlay()
|
|||||||
cameraManager->ViewPitchMax = maxPitch;
|
cameraManager->ViewPitchMax = maxPitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto gameSettings = UCustomGameSettings::Get();
|
|
||||||
if(gameSettings && camera)
|
|
||||||
{
|
|
||||||
camera->PostProcessSettings.MotionBlurAmount = gameSettings->bUseMotionBlur ? 1.0f : 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadInteractablesActivators();
|
LoadInteractablesActivators();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user