I believe we now have a semi-working graphics profiles and the ability to switch between them!
This commit is contained in:
parent
b8f67c33dc
commit
d4ac87e36d
3 changed files with 100 additions and 20 deletions
|
@ -13,17 +13,20 @@ TMap<FName, TMap<FName, FHLConfigValue>> UHarmonyLinkGraphics::DefaultSettings =
|
||||||
{ "Battery", {
|
{ "Battery", {
|
||||||
{ TEXT("r.ReflectionMethod"), FHLConfigValue(0) },
|
{ TEXT("r.ReflectionMethod"), FHLConfigValue(0) },
|
||||||
{ TEXT("r.DynamicGlobalIlluminationMethod"), FHLConfigValue(2) },
|
{ TEXT("r.DynamicGlobalIlluminationMethod"), FHLConfigValue(2) },
|
||||||
{ TEXT("r.Shadow.Virtual.Enable"), FHLConfigValue(0) }
|
{ TEXT("r.Shadow.Virtual.Enable"), FHLConfigValue(0) },
|
||||||
|
{ TEXT("r.ScreenPercentage"), FHLConfigValue(50) },
|
||||||
}},
|
}},
|
||||||
{ "Charging", {
|
{ "Charging", {
|
||||||
{ TEXT("r.ReflectionMethod"), FHLConfigValue(2) },
|
{ TEXT("r.ReflectionMethod"), FHLConfigValue(2) },
|
||||||
{ TEXT("r.DynamicGlobalIlluminationMethod"), FHLConfigValue(2) },
|
{ TEXT("r.DynamicGlobalIlluminationMethod"), FHLConfigValue(2) },
|
||||||
{ TEXT("r.Shadow.Virtual.Enable"), FHLConfigValue(1) }
|
{ TEXT("r.Shadow.Virtual.Enable"), FHLConfigValue(1) },
|
||||||
|
{ TEXT("r.ScreenPercentage"), FHLConfigValue(100) },
|
||||||
}},
|
}},
|
||||||
{ "Docked", {
|
{ "Docked", {
|
||||||
{ TEXT("r.ReflectionMethod"), FHLConfigValue(2) },
|
{ TEXT("r.ReflectionMethod"), FHLConfigValue(2) },
|
||||||
{ TEXT("r.DynamicGlobalIlluminationMethod"), FHLConfigValue(2) },
|
{ TEXT("r.DynamicGlobalIlluminationMethod"), FHLConfigValue(2) },
|
||||||
{ TEXT("r.Shadow.Virtual.Enable"), FHLConfigValue(1) }
|
{ TEXT("r.Shadow.Virtual.Enable"), FHLConfigValue(1) },
|
||||||
|
{ TEXT("r.ScreenPercentage"), FHLConfigValue(100) },
|
||||||
}}
|
}}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -144,15 +147,6 @@ void UHarmonyLinkGraphics::SaveConfig() const
|
||||||
GConfig->Flush(false, Filename);
|
GConfig->Flush(false, Filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UHarmonyLinkGraphics::ApplySettings(const bool bCheckForCommandLineOverrides)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
FGlobalComponentRecreateRenderStateContext Context;
|
|
||||||
//ApplyResolutionSettings(bCheckForCommandLineOverrides);
|
|
||||||
//ApplyNonResolutionSettings();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
UHarmonyLinkGraphics* UHarmonyLinkGraphics::GetSettings()
|
UHarmonyLinkGraphics* UHarmonyLinkGraphics::GetSettings()
|
||||||
|
@ -170,7 +164,10 @@ UHarmonyLinkGraphics* UHarmonyLinkGraphics::GetSettings()
|
||||||
|
|
||||||
const FBattery BatteryStatus = UHarmonyLinkLibrary::GetBatteryStatus();
|
const FBattery BatteryStatus = UHarmonyLinkLibrary::GetBatteryStatus();
|
||||||
|
|
||||||
if (BatteryStatus.HasBattery)
|
// Enabled for development testing
|
||||||
|
// At some point I need to implement the ability to fake and emulate these settings to make it easier to test
|
||||||
|
// BUG: Remove this before release!
|
||||||
|
if (!BatteryStatus.HasBattery)
|
||||||
{
|
{
|
||||||
Instance->ApplyProfile(EProfile::BATTERY);
|
Instance->ApplyProfile(EProfile::BATTERY);
|
||||||
}
|
}
|
||||||
|
@ -262,9 +259,76 @@ void UHarmonyLinkGraphics::LoadDefaults()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UHarmonyLinkGraphics::ApplyProfile(EProfile Profile)
|
bool UHarmonyLinkGraphics::ApplyProfile(const EProfile Profile)
|
||||||
{
|
{
|
||||||
|
// Find the profile name associated with the given EProfile
|
||||||
|
const FName* ProfileName = ProfileNames.Find(Profile);
|
||||||
|
|
||||||
|
if (!ProfileName)
|
||||||
|
{
|
||||||
|
UE_LOG(LogHarmonyLink, Warning, TEXT("Profile not found."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
UE_LOG(LogHarmonyLink, Log, TEXT("Applying profile %s."), *ProfileName->ToString());
|
||||||
|
|
||||||
|
// Find the settings associated with the profile
|
||||||
|
FSettingsProfile* SettingsProfile = Profiles.Find(Profile);
|
||||||
|
|
||||||
|
if (!SettingsProfile)
|
||||||
|
{
|
||||||
|
UE_LOG(LogHarmonyLink, Warning, TEXT("No settings found for profile %s."), *ProfileName->ToString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
FGlobalComponentRecreateRenderStateContext Context;
|
||||||
|
|
||||||
|
// Example of applying settings (actual application depends on your implementation)
|
||||||
|
for (const TPair<FName, FHLConfigValue>& Setting : SettingsProfile->Settings)
|
||||||
|
{
|
||||||
|
// Example of logging each setting being applied
|
||||||
|
UE_LOG(LogHarmonyLink, Log, TEXT("Applying setting: %s = %s"),
|
||||||
|
*Setting.Key.ToString(), *Setting.Value.ToString());
|
||||||
|
|
||||||
|
ApplySetting(Setting);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UHarmonyLinkGraphics::ApplySetting(const TPair<FName, FHLConfigValue>& Setting)
|
||||||
|
{
|
||||||
|
// Apply the setting based on the key (CVar)
|
||||||
|
IConsoleManager& ConsoleManager = IConsoleManager::Get();
|
||||||
|
IConsoleVariable* CVar = ConsoleManager.FindConsoleVariable(*Setting.Key.ToString());
|
||||||
|
|
||||||
|
if (CVar)
|
||||||
|
{
|
||||||
|
switch (Setting.Value.GetType())
|
||||||
|
{
|
||||||
|
case EConfigValueType::Bool:
|
||||||
|
CVar->Set(Setting.Value.GetValue<bool>(), ECVF_SetByGameSetting);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EConfigValueType::Float:
|
||||||
|
CVar->Set(Setting.Value.GetValue<float>(), ECVF_SetByGameSetting);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EConfigValueType::Int:
|
||||||
|
CVar->Set(Setting.Value.GetValue<int32>(), ECVF_SetByGameSetting);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
UE_LOG(LogHarmonyLink, Warning, TEXT("Unsupported value type for setting: %s"), *Setting.Key.ToString());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UE_LOG(LogHarmonyLink, Warning, TEXT("Console variable not found: %s"), *Setting.Key.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UHarmonyLinkGraphics::DebugPrintProfiles() const
|
void UHarmonyLinkGraphics::DebugPrintProfiles() const
|
||||||
|
|
|
@ -26,9 +26,6 @@ public:
|
||||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink Settings")
|
UFUNCTION(BlueprintCallable, Category="HarmonyLink Settings")
|
||||||
void SaveConfig() const;
|
void SaveConfig() const;
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink Settings", meta=(bCheckForCommandLineOverrides=true))
|
|
||||||
void ApplySettings(bool bCheckForCommandLineOverrides = true);
|
|
||||||
|
|
||||||
/** Returns the game local machine settings (resolution, windowing mode, scalability settings, etc...) */
|
/** Returns the game local machine settings (resolution, windowing mode, scalability settings, etc...) */
|
||||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink Settings")
|
UFUNCTION(BlueprintCallable, Category="HarmonyLink Settings")
|
||||||
static UHarmonyLinkGraphics* GetSettings();
|
static UHarmonyLinkGraphics* GetSettings();
|
||||||
|
@ -41,10 +38,12 @@ private:
|
||||||
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);
|
bool ApplyProfile(EProfile Profile);
|
||||||
|
|
||||||
static void ResetInstance();
|
static void ResetInstance();
|
||||||
|
|
||||||
|
static void ApplySetting(const TPair<FName, FHLConfigValue>& Setting);
|
||||||
|
|
||||||
// Debugging
|
// Debugging
|
||||||
void DebugPrintProfiles() const;
|
void DebugPrintProfiles() const;
|
||||||
static void PrintDebugSection(FSettingsProfile& SettingsProfile);
|
static void PrintDebugSection(FSettingsProfile& SettingsProfile);
|
||||||
|
|
|
@ -46,6 +46,23 @@ public:
|
||||||
|
|
||||||
FHLConfigValue(const FString& Value) : Type(EConfigValueType::String), IntValue(0), FloatValue(0.0f), BoolValue(false), StringValue(Value) {}
|
FHLConfigValue(const FString& Value) : Type(EConfigValueType::String), IntValue(0), FloatValue(0.0f), BoolValue(false), StringValue(Value) {}
|
||||||
|
|
||||||
|
FString ToString() const
|
||||||
|
{
|
||||||
|
switch (Type)
|
||||||
|
{
|
||||||
|
case EConfigValueType::Int:
|
||||||
|
return FString::Printf(TEXT("Int: %d"), IntValue);
|
||||||
|
case EConfigValueType::Float:
|
||||||
|
return FString::Printf(TEXT("Float: %f"), FloatValue);
|
||||||
|
case EConfigValueType::Bool:
|
||||||
|
return BoolValue ? TEXT("Bool: true") : TEXT("Bool: false");
|
||||||
|
case EConfigValueType::String:
|
||||||
|
return FString::Printf(TEXT("String: %s"), *StringValue);
|
||||||
|
default:
|
||||||
|
return TEXT("Unknown Type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EConfigValueType GetType() const
|
EConfigValueType GetType() const
|
||||||
{
|
{
|
||||||
return Type;
|
return Type;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue