Added delegates and automatic switching
This commit is contained in:
parent
d4ac87e36d
commit
16061e077b
5 changed files with 263 additions and 44 deletions
|
@ -9,6 +9,8 @@
|
|||
#include "UObject/Object.h"
|
||||
#include "HarmonyLinkGraphics.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnProfileChanged, EProfile, Profile);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -19,6 +21,10 @@ class HARMONYLINK_API UHarmonyLinkGraphics : public UObject
|
|||
|
||||
public:
|
||||
UHarmonyLinkGraphics();
|
||||
virtual ~UHarmonyLinkGraphics() override;
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FOnProfileChanged OnProfileChanged;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink Settings")
|
||||
void LoadConfig(const bool bForceReload = false);
|
||||
|
@ -26,19 +32,37 @@ public:
|
|||
UFUNCTION(BlueprintCallable, Category="HarmonyLink Settings")
|
||||
void SaveConfig() const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink Settings")
|
||||
void SetSetting(EProfile Profile, FName Setting, FHLConfigValue Value);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink Settings")
|
||||
bool ApplyProfile(EProfile Profile);
|
||||
|
||||
/** Returns the game local machine settings (resolution, windowing mode, scalability settings, etc...) */
|
||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink Settings")
|
||||
static UHarmonyLinkGraphics* GetSettings();
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink Settings")
|
||||
FSettingsProfile GetSettingProfile(const EProfile Profile);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink Settings")
|
||||
EProfile GetActiveProfile() const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink Settings")
|
||||
void SetAutomaticSwitching(const bool bAutomaticSwitch);
|
||||
|
||||
static void DestroySettings();
|
||||
|
||||
private:
|
||||
void Init();
|
||||
void Tick();
|
||||
void CreateDefaultConfigFile();
|
||||
bool LoadSettingsFromConfig();
|
||||
bool LoadSection(const FConfigFile& ConfigFile, const TPair<EProfile, FName> Profile);
|
||||
void SaveSection(FSettingsProfile& SettingsProfile, const bool bFlush = false) const;
|
||||
void LoadDefaults();
|
||||
bool ApplyProfile(EProfile Profile);
|
||||
|
||||
void OnPostWorldInitialization(UWorld* World, UWorld::InitializationValues IVS);
|
||||
|
||||
static void ResetInstance();
|
||||
|
||||
|
@ -48,17 +72,26 @@ private:
|
|||
void DebugPrintProfiles() const;
|
||||
static void PrintDebugSection(FSettingsProfile& SettingsProfile);
|
||||
|
||||
static FString IniLocation;
|
||||
static FString _IniLocation;
|
||||
|
||||
TMap<EProfile, FName> ProfileNames = {
|
||||
uint8 _bAutomaticSwitch :1;
|
||||
|
||||
// How many times to query HarmonyLinkLib for hardware info
|
||||
static int32 _TickRate;
|
||||
|
||||
FTimerHandle _TickTimerHandle;
|
||||
|
||||
EProfile _ActiveProfile = EProfile::NONE;
|
||||
|
||||
TMap<EProfile, FName> _ProfileNames = {
|
||||
{EProfile::BATTERY, "Battery"},
|
||||
{EProfile::CHARGING, "Charging"},
|
||||
{EProfile::DOCKED, "Docked"},
|
||||
};
|
||||
|
||||
TMap<EProfile, FSettingsProfile> Profiles;
|
||||
TMap<EProfile, FSettingsProfile> _Profiles;
|
||||
|
||||
static TMap<FName, TMap<FName, FHLConfigValue>> DefaultSettings;
|
||||
static TMap<FName, TMap<FName, FHLConfigValue>> _DefaultSettings;
|
||||
|
||||
static UHarmonyLinkGraphics* Instance;
|
||||
static UHarmonyLinkGraphics* _INSTANCE;
|
||||
};
|
||||
|
|
|
@ -14,25 +14,29 @@ enum class EConfigValueType : uint8
|
|||
String
|
||||
};
|
||||
|
||||
/**
|
||||
* Note: In Blueprints, all values will be visible, but only the value corresponding to the 'Type' will be used.
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct FHLConfigValue
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
private:
|
||||
UPROPERTY(EditAnywhere, Category="ConfigValue")
|
||||
// Allow Blueprint access to these private variables
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "ConfigValue", meta = (AllowPrivateAccess = "true"))
|
||||
EConfigValueType Type;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="ConfigValue")
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "ConfigValue", meta = (AllowPrivateAccess = "true", EditCondition = "Type == EConfigValueType::Int", EditConditionHides))
|
||||
int32 IntValue;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="ConfigValue")
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "ConfigValue", meta = (AllowPrivateAccess = "true", EditCondition = "Type == EConfigValueType::Float", EditConditionHides))
|
||||
float FloatValue;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="ConfigValue")
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "ConfigValue", meta = (AllowPrivateAccess = "true", EditCondition = "Type == EConfigValueType::Bool", EditConditionHides))
|
||||
bool BoolValue;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="ConfigValue")
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "ConfigValue", meta = (AllowPrivateAccess = "true", EditCondition = "Type == EConfigValueType::String", EditConditionHides))
|
||||
FString StringValue;
|
||||
|
||||
public:
|
||||
|
|
|
@ -12,10 +12,10 @@ struct FSettingsProfile
|
|||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY()
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Settings")
|
||||
FName SectionName;
|
||||
|
||||
UPROPERTY()
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Settings")
|
||||
TMap<FName, FHLConfigValue> Settings;
|
||||
|
||||
// Equality operators
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue