October3d55/M/PICOOpen7991a2a23d57V5/Source/PICOOpenXRRuntimeSettings/Private/PICOOpenXRRuntimeSettings.cpp

111 lines
3.8 KiB
C++

// Copyright 2023 PICO Inc. All Rights Reserved.
#include "PICOOpenXRRuntimeSettings.h"
#include "Modules/ModuleInterface.h"
#include "Modules/ModuleManager.h"
#include "Misc/ConfigCacheIni.h"
#include "HAL/FileManager.h"
#include "Engine/RendererSettings.h"
#include "Misc/ConfigUtilities.h"
DEFINE_LOG_CATEGORY(LogPICOOpenXRSettings);
IMPLEMENT_MODULE(FDefaultModuleImpl, PICOOpenXRRuntimeSettings);
UPICOOpenXRRuntimeSettings::UPICOOpenXRRuntimeSettings(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
void UPICOOpenXRRuntimeSettings::PostInitProperties()
{
Super::PostInitProperties();
}
bool UPICOOpenXRRuntimeSettings::GetBoolConfigByKey(const FString& InKeyName)
{
if(const FConfigSection* Section = GConfig->GetSection(TEXT("/Script/PICOOpenXRRuntimeSettings.PICOOpenXRRuntimeSettings"), false, GEngineIni))
{
for(FConfigSectionMap::TConstIterator It(*Section); It; ++It)
{
const FString& KeyString = It.Key().GetPlainNameString();
const FString& ValueString = It.Value().GetValue();
if (KeyString==InKeyName)
{
const FString& NewValueString = UE::ConfigUtilities::ConvertValueFromHumanFriendlyValue(*ValueString);
if (NewValueString == TEXT("1"))
{
return true;
}
}
}
}
return false;
}
#if WITH_EDITOR
void UPICOOpenXRRuntimeSettings::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);
GConfig->Flush(false);
FString Dst = FPaths::ProjectDir() / TEXT("pico_splash.png");
if (!(bUsingOSSplash && IFileManager::Get().Copy(*Dst, *OSSplashScreen.FilePath, true) == COPY_OK))
{
IFileManager::Get().Delete(*Dst, true);
}
HandlesRGBHWSupport();
static const FName EnableVSTName = GET_MEMBER_NAME_CHECKED(UPICOOpenXRRuntimeSettings, bEnableVST);
if (PropertyChangedEvent.Property->GetFName() == EnableVSTName)
{
bEnablePassthroughEXT = bEnableVST;
UpdateSinglePropertyInConfigFile(GetClass()->FindPropertyByName(GET_MEMBER_NAME_CHECKED(UPICOOpenXRRuntimeSettings, bEnablePassthroughEXT)), GetDefaultConfigFilename());
}
static const FName EnableSemanticsAlignWithVertex = GET_MEMBER_NAME_CHECKED(UPICOOpenXRRuntimeSettings, bSemanticsAlignWithVertex);
if (PropertyChangedEvent.Property && PropertyChangedEvent.Property->GetFName() == EnableSemanticsAlignWithVertex)
{
if (bSemanticsAlignWithVertex == true)
{
bSemanticsAlignWithTriangle = false;
UpdateSinglePropertyInConfigFile(GetClass()->FindPropertyByName(GET_MEMBER_NAME_CHECKED(UPICOOpenXRRuntimeSettings, bSemanticsAlignWithTriangle)), GetDefaultConfigFilename());
}
}
static const FName EnableSemanticsAlignWithTriangle = GET_MEMBER_NAME_CHECKED(UPICOOpenXRRuntimeSettings, bSemanticsAlignWithTriangle);
if (PropertyChangedEvent.Property && PropertyChangedEvent.Property->GetFName() == EnableSemanticsAlignWithTriangle)
{
if (bSemanticsAlignWithTriangle == true)
{
bSemanticsAlignWithVertex = false;
UpdateSinglePropertyInConfigFile(GetClass()->FindPropertyByName(GET_MEMBER_NAME_CHECKED(UPICOOpenXRRuntimeSettings, bSemanticsAlignWithVertex)), GetDefaultConfigFilename());
}
}
}
void UPICOOpenXRRuntimeSettings::HandlesRGBHWSupport()
{
const bool SupportssRGB = true;
URendererSettings* const Settings = GetMutableDefault<URendererSettings>();
static auto* MobileUseHWsRGBEncodingCVAR = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Mobile.UseHWsRGBEncoding"));
if (SupportssRGB != Settings->bMobileUseHWsRGBEncoding)
{
Settings->bMobileUseHWsRGBEncoding = SupportssRGB;
Settings->UpdateSinglePropertyInConfigFile(Settings->GetClass()->FindPropertyByName(GET_MEMBER_NAME_CHECKED(URendererSettings, bMobileUseHWsRGBEncoding)), GetDefaultConfigFilename());
}
if (MobileUseHWsRGBEncodingCVAR && MobileUseHWsRGBEncodingCVAR->GetInt() != (int)SupportssRGB)
{
MobileUseHWsRGBEncodingCVAR->Set((int)SupportssRGB);
}
}
#endif