Add Graphics settings
This commit is contained in:
parent
f079124c18
commit
96d5f5c762
6 changed files with 342 additions and 0 deletions
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(LogHarmonyLink, Log, All);
|
||||
|
||||
class FHarmonyLinkModule : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
|
|
70
Source/HarmonyLink/Public/Objects/HarmonyLinkGraphics.h
Normal file
70
Source/HarmonyLink/Public/Objects/HarmonyLinkGraphics.h
Normal file
|
@ -0,0 +1,70 @@
|
|||
// Copyright (C) 2024 Jordon Brooks
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Structs/HLConfigValue.h"
|
||||
|
||||
#include "UObject/Object.h"
|
||||
#include "HarmonyLinkGraphics.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(Blueprintable, config="HarmonyLink")
|
||||
class HARMONYLINK_API UHarmonyLinkGraphics : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UHarmonyLinkGraphics();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink Settings")
|
||||
void LoadProfile(const FName& ProfileName, const bool bForceReload = false);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink Settings")
|
||||
void SaveProfile(const FName& ProfileName);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink Settings", meta=(bCheckForCommandLineOverrides=true))
|
||||
void ApplySettings(bool bCheckForCommandLineOverrides = true);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink Settings")
|
||||
void ApplyNonResolutionSettings();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink Settings")
|
||||
void ApplyResolutionSettings(bool bCheckForCommandLineOverrides);
|
||||
|
||||
/** Returns the game local machine settings (resolution, windowing mode, scalability settings, etc...) */
|
||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink Settings")
|
||||
static UHarmonyLinkGraphics* GetSettings();
|
||||
|
||||
static void DestroySettings();
|
||||
|
||||
private:
|
||||
void CreateDefaultConfigFile();
|
||||
bool LoadSettingsFromConfig(const FString& SectionName);
|
||||
|
||||
void SaveSection(const FName& SectionName, const TMap<FName, FHLConfigValue>& Settings) const;
|
||||
|
||||
static void ResetInstance();
|
||||
|
||||
UPROPERTY(Config)
|
||||
FName _ProfileName = NAME_None;
|
||||
|
||||
static FString IniLocation;
|
||||
|
||||
static FName BatteryProfile;
|
||||
static FName ChargingProfile;
|
||||
static FName DockedProfile;
|
||||
|
||||
TMap<FName, int32> SettingsMap;
|
||||
|
||||
// Maps to store configuration settings for each profile
|
||||
TMap<FName, FHLConfigValue> BatterySettings;
|
||||
TMap<FName, FHLConfigValue> ChargingSettings;
|
||||
TMap<FName, FHLConfigValue> DockedSettings;
|
||||
|
||||
static TMap<FName, int32> DefaultSettingsMap;
|
||||
|
||||
static UHarmonyLinkGraphics* Instance;
|
||||
};
|
85
Source/HarmonyLink/Public/Structs/HLConfigValue.h
Normal file
85
Source/HarmonyLink/Public/Structs/HLConfigValue.h
Normal file
|
@ -0,0 +1,85 @@
|
|||
// Copyright (C) 2024 Jordon Brooks
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "HLConfigValue.generated.h"
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EConfigValueType : uint8
|
||||
{
|
||||
Int,
|
||||
Float,
|
||||
Bool,
|
||||
String
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FHLConfigValue
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
private:
|
||||
UPROPERTY(EditAnywhere, Category="ConfigValue")
|
||||
EConfigValueType Type;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="ConfigValue")
|
||||
int32 IntValue;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="ConfigValue")
|
||||
float FloatValue;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="ConfigValue")
|
||||
bool BoolValue;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="ConfigValue")
|
||||
FString StringValue;
|
||||
|
||||
public:
|
||||
FHLConfigValue() : Type(EConfigValueType::String), IntValue(0), FloatValue(0.0f), BoolValue(false), StringValue(TEXT("")) {}
|
||||
|
||||
FHLConfigValue(int32 Value) : Type(EConfigValueType::Int), IntValue(Value), FloatValue(0.0f), BoolValue(false), StringValue(TEXT("")) {}
|
||||
|
||||
FHLConfigValue(float Value) : Type(EConfigValueType::Float), IntValue(0), FloatValue(Value), BoolValue(false), StringValue(TEXT("")) {}
|
||||
|
||||
FHLConfigValue(bool Value) : Type(EConfigValueType::Bool), IntValue(0), FloatValue(0.0f), BoolValue(Value), StringValue(TEXT("")) {}
|
||||
|
||||
FHLConfigValue(const FString& Value) : Type(EConfigValueType::String), IntValue(0), FloatValue(0.0f), BoolValue(false), StringValue(Value) {}
|
||||
|
||||
EConfigValueType GetType() const
|
||||
{
|
||||
return Type;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T GetValue() const;
|
||||
};
|
||||
|
||||
// Specializations of the templated getter
|
||||
template<>
|
||||
inline int32 FHLConfigValue::GetValue<int32>() const
|
||||
{
|
||||
ensure(Type == EConfigValueType::Int);
|
||||
return IntValue;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline float FHLConfigValue::GetValue<float>() const
|
||||
{
|
||||
ensure(Type == EConfigValueType::Float);
|
||||
return FloatValue;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool FHLConfigValue::GetValue<bool>() const
|
||||
{
|
||||
ensure(Type == EConfigValueType::Bool);
|
||||
return BoolValue;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline FString FHLConfigValue::GetValue<FString>() const
|
||||
{
|
||||
ensure(Type == EConfigValueType::String);
|
||||
return StringValue;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue