Added detection of battery and proceeds to load battery profile
This commit is contained in:
parent
5c9a3256d6
commit
1a1b445302
2 changed files with 26 additions and 10 deletions
|
@ -4,6 +4,7 @@
|
||||||
#include "Objects/HarmonyLinkGraphics.h"
|
#include "Objects/HarmonyLinkGraphics.h"
|
||||||
#include "ComponentRecreateRenderStateContext.h"
|
#include "ComponentRecreateRenderStateContext.h"
|
||||||
#include "HarmonyLink.h"
|
#include "HarmonyLink.h"
|
||||||
|
#include "HarmonyLinkLibrary.h"
|
||||||
|
|
||||||
UHarmonyLinkGraphics* UHarmonyLinkGraphics::Instance = nullptr;
|
UHarmonyLinkGraphics* UHarmonyLinkGraphics::Instance = nullptr;
|
||||||
FString UHarmonyLinkGraphics::IniLocation = "HarmonyLink";
|
FString UHarmonyLinkGraphics::IniLocation = "HarmonyLink";
|
||||||
|
@ -156,11 +157,22 @@ void UHarmonyLinkGraphics::ApplySettings(const bool bCheckForCommandLineOverride
|
||||||
|
|
||||||
UHarmonyLinkGraphics* UHarmonyLinkGraphics::GetSettings()
|
UHarmonyLinkGraphics* UHarmonyLinkGraphics::GetSettings()
|
||||||
{
|
{
|
||||||
if (!Instance)
|
// Check if we already initialised
|
||||||
|
if (Instance)
|
||||||
{
|
{
|
||||||
Instance = NewObject<UHarmonyLinkGraphics>();
|
return Instance;
|
||||||
Instance->AddToRoot();
|
}
|
||||||
Instance->LoadConfig();
|
|
||||||
|
// Proceed to create a new singleton instance
|
||||||
|
Instance = NewObject<UHarmonyLinkGraphics>();
|
||||||
|
Instance->AddToRoot();
|
||||||
|
Instance->LoadConfig();
|
||||||
|
|
||||||
|
const FBattery BatteryStatus = UHarmonyLinkLibrary::GetBatteryStatus();
|
||||||
|
|
||||||
|
if (BatteryStatus.HasBattery)
|
||||||
|
{
|
||||||
|
Instance->ApplyProfile(EProfile::BATTERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Instance;
|
return Instance;
|
||||||
|
@ -250,6 +262,11 @@ void UHarmonyLinkGraphics::LoadDefaults()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UHarmonyLinkGraphics::ApplyProfile(EProfile Profile)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void UHarmonyLinkGraphics::DebugPrintProfiles() const
|
void UHarmonyLinkGraphics::DebugPrintProfiles() const
|
||||||
{
|
{
|
||||||
UE_LOG(LogHarmonyLink, Log, TEXT("DebugPrintProfiles started."));
|
UE_LOG(LogHarmonyLink, Log, TEXT("DebugPrintProfiles started."));
|
||||||
|
|
|
@ -38,18 +38,17 @@ public:
|
||||||
private:
|
private:
|
||||||
void CreateDefaultConfigFile();
|
void CreateDefaultConfigFile();
|
||||||
bool LoadSettingsFromConfig();
|
bool LoadSettingsFromConfig();
|
||||||
|
|
||||||
bool LoadSection(const FConfigFile& ConfigFile, const TPair<EProfile, FName> Profile);
|
bool LoadSection(const FConfigFile& ConfigFile, const TPair<EProfile, FName> Profile);
|
||||||
|
|
||||||
void SaveSection(FSettingsProfile& SettingsProfile, const bool bFlush = false) const;
|
void SaveSection(FSettingsProfile& SettingsProfile, const bool bFlush = false) const;
|
||||||
|
|
||||||
void LoadDefaults();
|
void LoadDefaults();
|
||||||
|
void ApplyProfile(EProfile Profile);
|
||||||
void DebugPrintProfiles() const;
|
|
||||||
static void PrintDebugSection(FSettingsProfile& SettingsProfile);
|
|
||||||
|
|
||||||
static void ResetInstance();
|
static void ResetInstance();
|
||||||
|
|
||||||
|
// Debugging
|
||||||
|
void DebugPrintProfiles() const;
|
||||||
|
static void PrintDebugSection(FSettingsProfile& SettingsProfile);
|
||||||
|
|
||||||
static FString IniLocation;
|
static FString IniLocation;
|
||||||
|
|
||||||
TMap<EProfile, FName> ProfileNames = {
|
TMap<EProfile, FName> ProfileNames = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue