From 0176cc90dec48a6cdad9b60fca71ed1ee747196b Mon Sep 17 00:00:00 2001 From: Oleg Petruny Date: Sun, 12 Jan 2025 23:49:42 +0100 Subject: [PATCH] graphics settings --- .../Config/DefaultGameUserSettings.ini | 15 +- .../Content/UI/BP_MainWidgetManager.uasset | 4 +- .../UICC_MainMenu_PageButtonParticle.uasset | 2 +- .../UIC_MainMenu_OptionsButton.uasset | 4 +- .../UIC_MainMenu_OptionsComboBox.uasset | 4 +- .../UIC_MainMenu_OptionsSlider.uasset | 4 +- .../Components/UIC_MainMenu_PageButton.uasset | 4 +- .../E_MainMenuOptionsButtonName.uasset | 4 +- .../UI_MainMenu_Page_Options_Graphics.uasset | 4 +- .../MainMenu/UI_MainMenuCredits.uasset | 3 - .../Blueprints/Overlays/UI_Crosshair.uasset | 4 +- .../Overlays/UI_DevelopBuildWarning.uasset | 4 +- .../Blueprints/Overlays/UI_FpsCounter.uasset | 3 + .../Content/UI/Blueprints/UI_Journal.uasset | 2 +- .../Content/UI/Components/UIC_ComboBox.uasset | 4 +- .../Content/UI/Components/UIC_Slider.uasset | 4 +- .../Lost_Edge/Private/CommonFunctions.cpp | 57 ++++++- .../Lost_Edge/Private/CommonFunctions.h | 16 ++ .../Lost_Edge/Private/CommonInspectors.cpp | 63 +++++++ .../Lost_Edge/Private/CommonInspectors.h | 34 ++++ .../Lost_Edge/Private/CustomGameSettings.cpp | 21 +++ .../Lost_Edge/Private/CustomGameSettings.h | 9 +- .../Private/GraphicsSettingsHelper.cpp | 158 +++++++++++++----- .../Private/GraphicsSettingsHelper.h | 33 +++- .../Private/Widgets/ComboBoxText.cpp | 48 +++++- .../Lost_Edge/Private/Widgets/ComboBoxText.h | 15 +- .../Widgets/ResolutionResponsiveWidget.cpp | 1 + .../Private/Widgets/WidgetsManager.cpp | 28 ++++ .../Private/Widgets/WidgetsManager.h | 7 + 29 files changed, 469 insertions(+), 90 deletions(-) delete mode 100644 UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/UI_MainMenuCredits.uasset create mode 100644 UnrealProject/Lost_Edge/Content/UI/Blueprints/Overlays/UI_FpsCounter.uasset create mode 100644 UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CommonInspectors.cpp create mode 100644 UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CommonInspectors.h diff --git a/UnrealProject/Lost_Edge/Config/DefaultGameUserSettings.ini b/UnrealProject/Lost_Edge/Config/DefaultGameUserSettings.ini index d9bc256..4ac5f7e 100644 --- a/UnrealProject/Lost_Edge/Config/DefaultGameUserSettings.ini +++ b/UnrealProject/Lost_Edge/Config/DefaultGameUserSettings.ini @@ -1,5 +1,4 @@ [/Script/Lost_Edge.CustomGameSettings] -bUseMotionBlur=False bShowFps=False bMouseInverted=False fMouseSensetivity=1.000000 @@ -9,13 +8,13 @@ fEffectsVolume=1.000000 fVoicesVolume=1.000000 fMenuVolume=1.000000 bUseVSync=False -bUseDynamicResolution=False +bUseDynamicResolution=True ResolutionSizeX=1920 ResolutionSizeY=1080 LastUserConfirmedResolutionSizeX=1920 LastUserConfirmedResolutionSizeY=1080 -WindowPosX=-1 -WindowPosY=-1 +WindowPosX=0 +WindowPosY=0 FullscreenMode=1 LastConfirmedFullscreenMode=1 PreferredFullscreenMode=1 @@ -23,10 +22,10 @@ Version=5 AudioQualityLevel=0 LastConfirmedAudioQualityLevel=0 FrameRateLimit=0.000000 -DesiredScreenWidth=1280 -DesiredScreenHeight=720 -LastUserConfirmedDesiredScreenWidth=1280 -LastUserConfirmedDesiredScreenHeight=720 +DesiredScreenWidth=1920 +DesiredScreenHeight=1080 +LastUserConfirmedDesiredScreenWidth=1920 +LastUserConfirmedDesiredScreenHeight=1080 LastRecommendedScreenWidth=-1.000000 LastRecommendedScreenHeight=-1.000000 LastCPUBenchmarkResult=-1.000000 diff --git a/UnrealProject/Lost_Edge/Content/UI/BP_MainWidgetManager.uasset b/UnrealProject/Lost_Edge/Content/UI/BP_MainWidgetManager.uasset index d4d2dca..3c91fa7 100644 --- a/UnrealProject/Lost_Edge/Content/UI/BP_MainWidgetManager.uasset +++ b/UnrealProject/Lost_Edge/Content/UI/BP_MainWidgetManager.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e95c10c69373b3a62ba6d80f00db0455308691cf9c0e2afc92c52aa9f3054ab6 -size 7924 +oid sha256:3d91fb19b4df3c5e5975e5e69d7c03e0fccb04ebd5597110665fd221cbe29121 +size 8472 diff --git a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Components/Classes/UICC_MainMenu_PageButtonParticle.uasset b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Components/Classes/UICC_MainMenu_PageButtonParticle.uasset index 0344799..3db4853 100644 --- a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Components/Classes/UICC_MainMenu_PageButtonParticle.uasset +++ b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Components/Classes/UICC_MainMenu_PageButtonParticle.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6fe6c4fd42365952789dab56c8e6f45a8a19b5461f0e126b0bb394c6edb63821 +oid sha256:3c29909dc91b1fb532f4076a7ff9aeb6eed6d0115b23eaba3ea0f732533526bd size 6986 diff --git a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Components/UIC_MainMenu_OptionsButton.uasset b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Components/UIC_MainMenu_OptionsButton.uasset index 54b7f48..98e15ba 100644 --- a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Components/UIC_MainMenu_OptionsButton.uasset +++ b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Components/UIC_MainMenu_OptionsButton.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ad7f08dfb64fd3f4ac0fbc6bd9ec81a4c113bfd3e2dde318325d131c746b8e49 -size 341283 +oid sha256:8b50db41b6db7ea0c2c6cade170d9adc711c65dfca29117895514508b3d0e45e +size 354685 diff --git a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Components/UIC_MainMenu_OptionsComboBox.uasset b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Components/UIC_MainMenu_OptionsComboBox.uasset index 1c20e64..3fefab2 100644 --- a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Components/UIC_MainMenu_OptionsComboBox.uasset +++ b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Components/UIC_MainMenu_OptionsComboBox.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ffbd972689ca6f97ab7b3d368e3e7cdbe26858359e0015a0ce77f685049fd10a -size 61581 +oid sha256:6cd52ec0367ede055718e6aed1eb8bf8108cdafb870bcab4cd4009293aff10cb +size 95169 diff --git a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Components/UIC_MainMenu_OptionsSlider.uasset b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Components/UIC_MainMenu_OptionsSlider.uasset index 557ab85..d9fce59 100644 --- a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Components/UIC_MainMenu_OptionsSlider.uasset +++ b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Components/UIC_MainMenu_OptionsSlider.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e8f62b2d0a9d81fd3585f9477b38acf9b8504847cf03df5a9441a19c22a61c10 -size 77333 +oid sha256:f10680b166aefad84bdc0235fcab111156c5cbec2fc51c6bac679d50d53b474b +size 87000 diff --git a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Components/UIC_MainMenu_PageButton.uasset b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Components/UIC_MainMenu_PageButton.uasset index 15b3d50..f3b7f39 100644 --- a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Components/UIC_MainMenu_PageButton.uasset +++ b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Components/UIC_MainMenu_PageButton.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f848f6e7ae72d8d0c99fe4ff5f8295b539e3ad15b0150801a6aa63c2ec72ed53 -size 367684 +oid sha256:3fb8b1d96e0a8a789365ba92a9ceb08af0b0172337d4661d3b37e23124e6aa39 +size 367737 diff --git a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/E_MainMenuOptionsButtonName.uasset b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/E_MainMenuOptionsButtonName.uasset index c36d271..7c953fd 100644 --- a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/E_MainMenuOptionsButtonName.uasset +++ b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/E_MainMenuOptionsButtonName.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:804ce49b67d36ed546a85af9413fd7a243ca8953562359a9ad1b4f00b156a5c9 -size 2910 +oid sha256:fb3b5ea4fd4300a59fa4ece35698d4f2c02f8c912272ab0d2d13f69325799c06 +size 3746 diff --git a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Pages/UI_MainMenu_Page_Options_Graphics.uasset b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Pages/UI_MainMenu_Page_Options_Graphics.uasset index 0e6aafd..0217c0d 100644 --- a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Pages/UI_MainMenu_Page_Options_Graphics.uasset +++ b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Pages/UI_MainMenu_Page_Options_Graphics.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6eeeec30266e2e9460df51d739cd18b360dbe381fde52167e1af15b6fb939153 -size 117065 +oid sha256:f327d2922e24e1831ae8e42a44b3cd262aa5981e10b0e47a30552b0de66b2f6c +size 482797 diff --git a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/UI_MainMenuCredits.uasset b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/UI_MainMenuCredits.uasset deleted file mode 100644 index e039ee0..0000000 --- a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/UI_MainMenuCredits.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4c7e26391465b6d60a05d8fbd44b1108b13758332251eeb4b323011bf3272969 -size 929530 diff --git a/UnrealProject/Lost_Edge/Content/UI/Blueprints/Overlays/UI_Crosshair.uasset b/UnrealProject/Lost_Edge/Content/UI/Blueprints/Overlays/UI_Crosshair.uasset index d535f98..1e9e34e 100644 --- a/UnrealProject/Lost_Edge/Content/UI/Blueprints/Overlays/UI_Crosshair.uasset +++ b/UnrealProject/Lost_Edge/Content/UI/Blueprints/Overlays/UI_Crosshair.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:be449754436e25a553da784db487d590b5990b9ab0edc3c04ea757d5acf218c7 -size 15255 +oid sha256:b76ba0b71b0575036ef253825438018704801044c797a3126457c0a460f0774f +size 19560 diff --git a/UnrealProject/Lost_Edge/Content/UI/Blueprints/Overlays/UI_DevelopBuildWarning.uasset b/UnrealProject/Lost_Edge/Content/UI/Blueprints/Overlays/UI_DevelopBuildWarning.uasset index 06b2d4d..967b645 100644 --- a/UnrealProject/Lost_Edge/Content/UI/Blueprints/Overlays/UI_DevelopBuildWarning.uasset +++ b/UnrealProject/Lost_Edge/Content/UI/Blueprints/Overlays/UI_DevelopBuildWarning.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7932c329679ea3c7d0ae5d5764dc839240321f676cad7bbebc55622326fd9b0f -size 13635 +oid sha256:bb43473e4b2e7f8ff988adb692cb781f3792a33b6145043ef058bb40094c90ac +size 14440 diff --git a/UnrealProject/Lost_Edge/Content/UI/Blueprints/Overlays/UI_FpsCounter.uasset b/UnrealProject/Lost_Edge/Content/UI/Blueprints/Overlays/UI_FpsCounter.uasset new file mode 100644 index 0000000..9e1cd04 --- /dev/null +++ b/UnrealProject/Lost_Edge/Content/UI/Blueprints/Overlays/UI_FpsCounter.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d63974d7101d71ebfd1708d3eff1414ef24e7dc96b0688f8ae35c74381e8e444 +size 67990 diff --git a/UnrealProject/Lost_Edge/Content/UI/Blueprints/UI_Journal.uasset b/UnrealProject/Lost_Edge/Content/UI/Blueprints/UI_Journal.uasset index 2aa8060..56bb12f 100644 --- a/UnrealProject/Lost_Edge/Content/UI/Blueprints/UI_Journal.uasset +++ b/UnrealProject/Lost_Edge/Content/UI/Blueprints/UI_Journal.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a5314ffaa13ed3a358ecd36f530f404cc1fe5500354e71fdb8cac1b15d00920e +oid sha256:4bedff5c2d811ec644c7d2012d6e7fb9ce2c168f6bd77116e9d0fbc18283540c size 28747 diff --git a/UnrealProject/Lost_Edge/Content/UI/Components/UIC_ComboBox.uasset b/UnrealProject/Lost_Edge/Content/UI/Components/UIC_ComboBox.uasset index bd8c7d1..f4c14b0 100644 --- a/UnrealProject/Lost_Edge/Content/UI/Components/UIC_ComboBox.uasset +++ b/UnrealProject/Lost_Edge/Content/UI/Components/UIC_ComboBox.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:070138fc6cfd92dd686cf311d8895f074c53de94a648cdcb33e0c5956caba9c3 -size 121172 +oid sha256:0f131eb29362f2988881dc0723020d749a94da87994c6a13fbc0bc502a610f39 +size 184831 diff --git a/UnrealProject/Lost_Edge/Content/UI/Components/UIC_Slider.uasset b/UnrealProject/Lost_Edge/Content/UI/Components/UIC_Slider.uasset index 2d1795a..a6de394 100644 --- a/UnrealProject/Lost_Edge/Content/UI/Components/UIC_Slider.uasset +++ b/UnrealProject/Lost_Edge/Content/UI/Components/UIC_Slider.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:680dbf5d16e01d2ccc7ade57130e4668601dc605370b0f4362dbb8db7855102f -size 147470 +oid sha256:3d365a0de4ee355bfa57cf82ae8cb297e7e5713363ea2fc28abd72c18fec6354 +size 147896 diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CommonFunctions.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CommonFunctions.cpp index c859f95..11e9d00 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CommonFunctions.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CommonFunctions.cpp @@ -105,15 +105,33 @@ FWorldDilationChangedDelegate& UCommonFunctions::GetWorldDilationChangedDelegate return SlowMotion::worldDilationChangedDelegate; } +TArray UCommonFunctions::IntArrayToStringArray(const TArray& in) +{ + TArray result; + result.Reserve(in.Num()); + for(int32 i : in) + result.Add(FString::FromInt(i)); + return MoveTemp(result); +} + +TArray UCommonFunctions::StringArrayToIntArray(const TArray& in) +{ + TArray result; + result.Reserve(in.Num()); + for(auto& i : in) + result.Add(FCString::Atoi(*i)); + return MoveTemp(result); +} + FString UCommonFunctions::IntPointToString(const FIntPoint& in) { - FString result = FString::Printf(TEXT("%sx%s"), *FString::FromInt(in.X), *FString::FromInt(in.Y)); + FString result = FString::Printf(TEXT("%dx%d"), in.X, in.Y); return MoveTemp(result); } FIntPoint UCommonFunctions::StringToIntPoint(const FString& in) { - FIntPoint result; + FIntPoint result{}; const FRegexPattern rgxP(FRegexPattern(TEXT("[0-9]+"))); FRegexMatcher rgx = FRegexMatcher(rgxP, in); @@ -125,6 +143,41 @@ FIntPoint UCommonFunctions::StringToIntPoint(const FString& in) return MoveTemp(result); } +TArray UCommonFunctions::IntPointArrayToStringArray(const TArray& in) +{ + TArray result; + result.Reserve(in.Num()); + for(auto& i : in) + result.Add(IntPointToString(i)); + return MoveTemp(result); +} + +TArray UCommonFunctions::StringArrayToIntPointArray(const TArray& in) +{ + TArray result; + result.Reserve(in.Num()); + for(auto& i : in) + result.Add(StringToIntPoint(i)); + return MoveTemp(result); +} + +int32 UCommonFunctions::GetLongestCharCount(TArray& in) +{ + int32 result = 0; + for(auto& i : in) + if(i.Len() > result) + result = i.Len(); + return result; +} + +void UCommonFunctions::SortIntPointArray(TArray& in) +{ + in.Sort([](const FIntPoint& a, const FIntPoint& b) + { + return a.X < b.X || a.Y < b.Y; + }); +} + int32 UCommonFunctions::GreatestCommonDivisor(int32 a, int32 b) { int32 temp; diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CommonFunctions.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CommonFunctions.h index d8539c8..29f2903 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CommonFunctions.h +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CommonFunctions.h @@ -44,10 +44,26 @@ public: + UFUNCTION(BlueprintPure, Category = TypeCasts) + static TArray IntArrayToStringArray(const TArray& in); + UFUNCTION(BlueprintPure, Category = TypeCasts) + static TArray StringArrayToIntArray(const TArray& in); + UFUNCTION(BlueprintPure, Category = TypeCasts) static FString IntPointToString(const FIntPoint& in); UFUNCTION(BlueprintPure, Category = TypeCasts) static FIntPoint StringToIntPoint(const FString& in); + UFUNCTION(BlueprintPure, Category = TypeCasts) + static TArray IntPointArrayToStringArray(const TArray& in); + UFUNCTION(BlueprintPure, Category = TypeCasts) + static TArray StringArrayToIntPointArray(const TArray& in); + UFUNCTION(BlueprintPure, Category = TypeCasts) + static void SortIntPointArray(UPARAM(ref) TArray& in); + + + + UFUNCTION(BlueprintPure, Category = String) + static int32 GetLongestCharCount(UPARAM(ref) TArray& in); diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CommonInspectors.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CommonInspectors.cpp new file mode 100644 index 0000000..73d800a --- /dev/null +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CommonInspectors.cpp @@ -0,0 +1,63 @@ +// Oleg Petruny proprietary. + +#include "CommonInspectors.h" + +UEnum* UEnumInspector::GetEnumByName(const FString& name) +{ + static TMap map; + if(map.Contains(name)) + return map[name]; + + UEnum* enumPtr = FindObject((UPackage*)-1, *name, true); + map.Add(name, enumPtr); + return enumPtr; +} + +TArray UEnumInspector::GetEnumDisplayNames(const UEnum* enumPtr) +{ + if(!enumPtr) + return {}; + + auto enumPtrProxy = static_cast(enumPtr); + TArray result; + for(int32 i = 0; i < enumPtrProxy->Names.Num() - 1; ++i) // last UEnum value is Num counter + result.Add(enumPtr->GetDisplayNameTextByIndex(enumPtrProxy->Names[i].Value)); + return MoveTemp(result); +} + +TArray UEnumInspector::GetEnumValues(const UEnum* enumPtr) +{ + if(!enumPtr) + return {}; + + auto enumPtrProxy = static_cast(enumPtr); + TArray result; + for(int32 i = 0; i < enumPtrProxy->Names.Num() - 1; ++i) // last UEnum value is Num counter + result.Add(enumPtrProxy->Names[i].Value); + return MoveTemp(result); +} + +int32 UEnumInspector::GetEnumValueByValueId(const UEnum* enumPtr, const int32 id) +{ + if(!enumPtr) + return 0; + + auto enumPtrProxy = static_cast(enumPtr); + if(id < enumPtrProxy->Names.Num()) + return enumPtrProxy->Names[id].Value; + + return -1; +} + +int32 UEnumInspector::GetEnumValueIdByValue(const UEnum* enumPtr, const int32 value) +{ + if(!enumPtr) + return 0; + + auto enumPtrProxy = static_cast(enumPtr); + for(int32 i = 0; i < enumPtrProxy->Names.Num(); ++i) + if(enumPtrProxy->Names[i].Value == value) + return i; + + return int32(); +} diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CommonInspectors.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CommonInspectors.h new file mode 100644 index 0000000..04a7441 --- /dev/null +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CommonInspectors.h @@ -0,0 +1,34 @@ +// Oleg Petruny proprietary. + +#pragma once + +#include "CoreMinimal.h" + +#include "CommonInspectors.generated.h" + + +UCLASS(Deprecated) +class UDEPRECATED_EnumInspectorProxy : public UEnum +{ + GENERATED_BODY() + + friend class UEnumInspector; +}; + +UCLASS() +class UEnumInspector : public UBlueprintFunctionLibrary +{ + GENERATED_BODY() + +public: + UFUNCTION(BlueprintPure, Category = Enum) + static UEnum* GetEnumByName(const FString& name); + UFUNCTION(BlueprintPure, Category = Enum) + static TArray GetEnumDisplayNames(UPARAM(meta = (DisplayName = "enum")) const UEnum* enumPtr); + UFUNCTION(BlueprintPure, Category = Enum) + static TArray GetEnumValues(UPARAM(meta = (DisplayName = "enum")) const UEnum* enumPtr); + UFUNCTION(BlueprintPure, Category = Enum) + static int32 GetEnumValueByValueId(UPARAM(meta = (DisplayName = "enum")) const UEnum* enumPtr, const int32 id); + UFUNCTION(BlueprintPure, Category = Enum) + static int32 GetEnumValueIdByValue(UPARAM(meta = (DisplayName = "enum")) const UEnum* enumPtr, const int32 value); +}; \ No newline at end of file diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameSettings.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameSettings.cpp index 7692feb..e7d4a08 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameSettings.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameSettings.cpp @@ -5,6 +5,8 @@ #include "Kismet/GameplayStatics.h" #include "GraphicsSettingsHelper.h" +#include "MainGameModeBase.h" +#include "Widgets/WidgetsManager.h" namespace { @@ -46,6 +48,25 @@ UCustomGameSettings* UCustomGameSettings::Get() return Cast(UGameUserSettings::GetGameUserSettings()); } +void UCustomGameSettings::LoadSettings(bool bForceReload) +{ + Super::LoadSettings(bForceReload); + UpdateResolutionQuality(); +} + +void UCustomGameSettings::ApplySettings(bool bCheckForCommandLineOverrides) +{ + Super::ApplySettings(bCheckForCommandLineOverrides); + UGraphicsSettingsHelper::ApplySettings(this); + if(auto WM = AMainGameModeBase::GetWidgetsManager()) + { + if(bShowFps) + WM->ShowFpsCount(); + else + WM->HideFpsCount(); + } +} + LOST_EDGE_API bool UCustomGameSettings::GetDefaultShowFps() const { return bDefaultShowFps; diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameSettings.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameSettings.h index c02f5c6..5fc098b 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameSettings.h +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameSettings.h @@ -24,6 +24,9 @@ public: UFUNCTION(BlueprintPure, Category = "Settings", meta = (DisplayName = "Get Custom Game Settings")) static UCustomGameSettings* Get(); + virtual void LoadSettings(bool bForceReload = false) override; + virtual void ApplySettings(bool bCheckForCommandLineOverrides) override; + /** Graphics */ @@ -92,8 +95,9 @@ public: protected: + /** Graphics */ UPROPERTY(Config) - float fMouseSensetivity; + int32 eAntiAliasingMethod; /** Audio */ UPROPERTY(Config) @@ -107,4 +111,7 @@ protected: UPROPERTY(Config) float fMenuVolume; + /** Game */ + UPROPERTY(Config) + float fMouseSensetivity; }; diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/GraphicsSettingsHelper.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/GraphicsSettingsHelper.cpp index 76b2352..b580e86 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/GraphicsSettingsHelper.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/GraphicsSettingsHelper.cpp @@ -17,10 +17,12 @@ namespace constexpr int32 iDefaultMonitorId = 0; const FIntPoint ipDefaultResolution = { 1920, 1080 }; std::optional ipPreviousResolution; - constexpr float fDefaultResolutionScale = 1.0f; + constexpr float fDefaultResolutionScale = 100.0f; constexpr int32 iDefaultFrameRateLimit = 120; constexpr EDisplayMode eDefaultDisplayMode = EDisplayMode::Fullscreen; std::optional ePreviousDisplayMode; + constexpr bool bDefaultVSyncEnabled = false; + constexpr int32 eDefaultAntiAliasingMethod = static_cast(ELostEdgeAntiAliasingMethod::FXAA); } bool UGraphicsSettingsHelper::AreSettingsRestorable(UCustomGameSettings* settings) @@ -30,6 +32,16 @@ bool UGraphicsSettingsHelper::AreSettingsRestorable(UCustomGameSettings* setting || ePreviousDisplayMode.has_value(); } +void UGraphicsSettingsHelper::RestoreGraphicsSettings(UCustomGameSettings* settings) +{ + if(ipPreviousWindowPosition.has_value()) + SetWindowPosition(settings, ipPreviousWindowPosition.value()); + if(ipPreviousResolution.has_value()) + SetResolution(settings, ipPreviousResolution.value()); + if(ePreviousDisplayMode.has_value()) + SetDisplayMode(settings, ePreviousDisplayMode.value()); +} + void UGraphicsSettingsHelper::SetDefaults(UCustomGameSettings* settings) { { @@ -42,7 +54,23 @@ void UGraphicsSettingsHelper::SetDefaults(UCustomGameSettings* settings) settings->ResolutionSizeX = res.X; settings->ResolutionSizeY = res.Y; } + settings->bUseDynamicResolution = true; + settings->FrameRateLimit = GetDefaultFrameRateLimit(settings); + settings->SetResolutionScaleValueEx(fDefaultResolutionScale); settings->FullscreenMode = DisplayToWindowMode(GetDefaultDisplayMode(settings)); + settings->eAntiAliasingMethod = eDefaultAntiAliasingMethod; +} + +void UGraphicsSettingsHelper::ApplySettings(UCustomGameSettings* settings) +{ + if(!settings) + return; + + if(GEngine && GEngine->GameViewport) + if(auto window = GEngine->GameViewport->GetWindow()) + window->MoveWindowTo(settings->GetWindowPosition()); + + GEngine->Exec(UCustomGameSettings::Get()->GetWorld(), *FString::Printf(TEXT("r.AntiAliasingMethod %d"), settings->eAntiAliasingMethod)); } FIntPoint UGraphicsSettingsHelper::GetDefaultWindowPosition([[maybe_unused]] UCustomGameSettings* settings) @@ -66,18 +94,14 @@ FIntPoint UGraphicsSettingsHelper::GetWindowPosition([[maybe_unused]] UCustomGam void UGraphicsSettingsHelper::SetWindowPosition(UCustomGameSettings* settings, const FIntPoint& pos) { - if(settings && GEngine && GEngine->GameViewport) + if(settings) { - if(auto window = GEngine->GameViewport->GetWindow()) - { - if(ipPreviousWindowPosition == pos) - ipPreviousWindowPosition.reset(); - else - ipPreviousWindowPosition = GetWindowPosition(settings); + if(ipPreviousWindowPosition == pos) + ipPreviousWindowPosition.reset(); + else + ipPreviousWindowPosition = GetWindowPosition(settings); - window->MoveWindowTo(pos); - settings->SetWindowPosition(pos.X, pos.Y); - } + settings->SetWindowPosition(pos.X, pos.Y); } } @@ -126,10 +150,11 @@ int32 UGraphicsSettingsHelper::GetPrimaryMonitorId() TArray UGraphicsSettingsHelper::GetAvailableMonitorsNames() { - TArray names; auto monitors = GetAvailableMonitors(); - for(auto& m : monitors) - names.Add(m.ID); + TArray names; + names.Reserve(monitors.Num()); + for(int32 i = 0; i < monitors.Num(); ++i) + names.Add(FString::Printf(TEXT("%d - %s"), i + 1, *monitors[i].Name)); return MoveTemp(names); } @@ -195,11 +220,16 @@ TArray UGraphicsSettingsHelper::GetAllAvailableResol if(!RHIGetAvailableResolutions(buffer, false) || buffer.Num() == 0) return { {GetResolution(nullptr), {GetDefaultFrameRateLimit(nullptr)}} }; - TArray result = {}; + TArray result; int32 lastWidth = 0; int32 lastHeight = 0; + FIntPoint currentResolution = GetResolution(nullptr); + bool currentInfoPresent = false; for(auto& i : buffer) { + if(currentResolution.X == i.Width && currentResolution.Y == i.Height) + currentInfoPresent = true; + if(lastWidth != i.Width || lastHeight != i.Height) { result.Add({ {static_cast(i.Width), static_cast(i.Height)}, {static_cast(i.RefreshRate)} }); @@ -212,6 +242,10 @@ TArray UGraphicsSettingsHelper::GetAllAvailableResol } } + if(!currentInfoPresent) + if(auto settings = UCustomGameSettings::Get()) + result.Add({ currentResolution, { static_cast(settings->GetFrameRateLimit()) } }); + return MoveTemp(result); } @@ -222,6 +256,7 @@ TArray UGraphicsSettingsHelper::GetAllAvailableResolutions() return { {GetResolution(nullptr), {GetDefaultFrameRateLimit(nullptr)}} }; TArray result; + result.Reserve(buffer.Num() + 1); int32 lastWidth = 0; int32 lastHeight = 0; for(auto& i : buffer) @@ -233,20 +268,32 @@ TArray UGraphicsSettingsHelper::GetAllAvailableResolutions() lastWidth = i.Width; } } + + FIntPoint currentResolution = GetResolution(nullptr); + if(!result.Contains(currentResolution)) + result.Add(currentResolution); + return MoveTemp(result); } TArray UGraphicsSettingsHelper::GetAvailableResolutionsByMonitorId(const int32 id) { - TArray result; - + auto resolutions = GetAllAvailableResolutions(); FIntPoint nativeRes = GetNativeResolutionByMonitorId(id); - for(auto& i : GetAllAvailableResolutions()) + TArray result; + result.Reserve(resolutions.Num() + 1); + for(auto& i : resolutions) { if(i.X > nativeRes.X && i.Y > nativeRes.Y) continue; result.Add(i); } + if(id == GetMonitorId(nullptr)) + { + FIntPoint currentResolution = GetResolution(nullptr); + if(!result.Contains(currentResolution)) + result.Add(currentResolution); + } return MoveTemp(result); } @@ -267,8 +314,6 @@ void UGraphicsSettingsHelper::SetResolution(UCustomGameSettings* settings, const if(!settings) return; - settings->bUseDynamicResolution = true; - if(ipPreviousResolution.has_value() && ipPreviousResolution == resolution) ipPreviousResolution.reset(); else @@ -285,27 +330,11 @@ void UGraphicsSettingsHelper::RestoreResolution(UCustomGameSettings* settings) SetResolution(settings, ipPreviousResolution.value()); } -float UGraphicsSettingsHelper::GetDefaultResolutionScale([[maybe_unused]] UCustomGameSettings* settings) +float UGraphicsSettingsHelper::GetDefaultResolutionScaleFast(UCustomGameSettings* settings) { return fDefaultResolutionScale; } -float UGraphicsSettingsHelper::GetResolutionScale([[maybe_unused]] UCustomGameSettings* settings) -{ - if(auto settings = UCustomGameSettings::Get()) - return settings->GetResolutionScaleNormalized(); - - return 1.0f; -} - -void UGraphicsSettingsHelper::SetResolutionScale(UCustomGameSettings* settings, const float resolutionScale) -{ - if(!settings) - return; - - settings->SetResolutionScaleNormalized(resolutionScale); -} - int32 UGraphicsSettingsHelper::GetDefaultFrameRateLimit([[maybe_unused]] UCustomGameSettings* settings) { return iDefaultFrameRateLimit; @@ -315,8 +344,24 @@ TArray UGraphicsSettingsHelper::GetAvailableFrameRateLimitsForResolution( { auto resAndRates = GetAllAvailableResolutionsAndRefreshRates(); for(auto& i : resAndRates) + { if(i.resolution == resolution) + { + if(resolution == GetResolution(nullptr)) + if(auto settings = UCustomGameSettings::Get()) + if(!i.refreshRates.Contains(settings->GetFrameRateLimit())) + i.refreshRates.Add(settings->GetFrameRateLimit()); + + if(!i.refreshRates.Contains(GetDefaultFrameRateLimit(nullptr))) + i.refreshRates.Add(GetDefaultFrameRateLimit(nullptr)); + + if(!i.refreshRates.Contains(0)) + i.refreshRates.Add(0); + + i.refreshRates.Sort(); return MoveTemp(i.refreshRates); + } + } return { GetDefaultFrameRateLimit(nullptr) }; } @@ -350,8 +395,15 @@ TArray UGraphicsSettingsHelper::GetAvailableAspectRatiousOfMonitor(co TSet aspects; for(auto& i : resolutions) + { aspects.Add(GetAspectRatioFromResolution(i)); - return aspects.Array(); + UE_LOG(LogTemp, Log, TEXT("%dx%d = %dx%d"), i.X, i.Y, GetAspectRatioFromResolution(i).X, GetAspectRatioFromResolution(i).Y); + } + aspects.Add(GetAspectRatioFromResolution(GetResolution(nullptr))); + + TArray result = aspects.Array(); + UCommonFunctions::SortIntPointArray(result); + return MoveTemp(result); } EDisplayMode UGraphicsSettingsHelper::GetDefaultDisplayMode([[maybe_unused]] UCustomGameSettings* settings) @@ -406,6 +458,33 @@ void UGraphicsSettingsHelper::RestoreDisplayMode(UCustomGameSettings* settings) SetDisplayMode(settings, ePreviousDisplayMode.value()); } +bool UGraphicsSettingsHelper::GetDefaultVSyncEnabled(UCustomGameSettings* settings) +{ + return bDefaultVSyncEnabled; +} + +int32 UGraphicsSettingsHelper::GetDefaultAntiAliasingMethod(UCustomGameSettings* settings) +{ + return eDefaultAntiAliasingMethod; +} + +int32 UGraphicsSettingsHelper::GetAntiAliasingMethod(UCustomGameSettings* settings) +{ + static const auto cvar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.AntiAliasingMethod")); + if(cvar) + return cvar->GetInt(); + + return -1; +} + +void UGraphicsSettingsHelper::SetAntiAliasingMethod(UCustomGameSettings* settings, int32 method) +{ + if(!settings) + return; + + settings->eAntiAliasingMethod = FMath::Clamp(method, static_cast(ELostEdgeAntiAliasingMethod::None), static_cast(ELostEdgeAntiAliasingMethod::MSAA)); +} + inline constexpr EDisplayMode UGraphicsSettingsHelper::WindowToDisplayMode(const EWindowMode::Type mode) { switch(mode) @@ -433,6 +512,3 @@ inline constexpr EWindowMode::Type UGraphicsSettingsHelper::DisplayToWindowMode( return EWindowMode::Type::Fullscreen; } } - - - diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/GraphicsSettingsHelper.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/GraphicsSettingsHelper.h index 5d5f1d6..6cae13e 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/GraphicsSettingsHelper.h +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/GraphicsSettingsHelper.h @@ -27,6 +27,15 @@ enum class EDisplayMode : uint8 Windowed = 2 UMETA(DisplayName = "Windowed") }; +UENUM(BlueprintType) +enum class ELostEdgeAntiAliasingMethod : uint8 +{ + None = AAM_None UMETA(DisplayName = "None"), + FXAA = AAM_FXAA UMETA(DisplayName = "FXAA"), + TAA = AAM_TemporalAA UMETA(DisplayName = "TAA"), + MSAA = AAM_MSAA UMETA(DisplayName = "MSAA") +}; + /** * Helper for trivial and complex graphic settings. * Most of functions work without settings pointer. It is there just for Blueprint call convinience. @@ -39,10 +48,14 @@ class UGraphicsSettingsHelper : public UBlueprintFunctionLibrary GENERATED_BODY() public: - UFUNCTION(BlueprintPure, Category = "Settings|Graphics", meta = (DisplayName = "AreGraphicsSettingsRestorable")) + UFUNCTION(BlueprintPure, Category = "Settings|Graphics", meta = (DisplayName = "Are Graphics Settings Restorable")) static bool AreSettingsRestorable(class UCustomGameSettings* settings); - UFUNCTION(BlueprintCallable, Category = "Settings|Graphics", meta = (DisplayName = "SetGraphicsDefaults")) + UFUNCTION(BlueprintCallable, Category = "Settings|Graphics") + static void RestoreGraphicsSettings(class UCustomGameSettings* settings); + UFUNCTION(BlueprintCallable, Category = "Settings|Graphics", meta = (DisplayName = "Set Graphics Defaults")) static void SetDefaults(class UCustomGameSettings* settings); + UFUNCTION(BlueprintCallable, Category = "Settings|Graphics", meta = (DisplayName = "Apply Graphics Settings")) + static void ApplySettings(class UCustomGameSettings* settings); protected: // Window position setting is on the thin edge of user safeness, therefore protected. Please use SetMonitor(). UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Window") @@ -89,11 +102,7 @@ public: static void RestoreResolution(class UCustomGameSettings* settings); UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Resolution Scale") - static float GetDefaultResolutionScale(class UCustomGameSettings* settings); - UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Resolution Scale") - static float GetResolutionScale(class UCustomGameSettings* settings); - UFUNCTION(BlueprintCallable, Category = "Settings|Graphics|Resolution Scale") - static void SetResolutionScale(class UCustomGameSettings* settings, const float resolutionScale); + static float GetDefaultResolutionScaleFast(class UCustomGameSettings* settings); UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Frame Rate Limit") static int32 GetDefaultFrameRateLimit(class UCustomGameSettings* settings); @@ -124,6 +133,16 @@ public: UFUNCTION(BlueprintCallable, Category = "Settings|Graphics|Display Mode") static void RestoreDisplayMode(class UCustomGameSettings* settings); + UFUNCTION(BlueprintPure, Category = "Settings|Graphics|VSync") + static bool GetDefaultVSyncEnabled(class UCustomGameSettings* settings); + + UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Anti Aliasing") + static int32 GetDefaultAntiAliasingMethod(class UCustomGameSettings* settings); + UFUNCTION(BlueprintPure, Category = "Settings|Graphics|Anti Aliasing") + static int32 GetAntiAliasingMethod(class UCustomGameSettings* settings); + UFUNCTION(BlueprintCallable, Category = "Settings|Graphics|Anti Aliasing") + static void SetAntiAliasingMethod(class UCustomGameSettings* settings, int32 method); + private: inline constexpr static EDisplayMode WindowToDisplayMode(const EWindowMode::Type mode); inline constexpr static EWindowMode::Type DisplayToWindowMode(const EDisplayMode mode); diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/ComboBoxText.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/ComboBoxText.cpp index dbd1fc0..8d0fd6f 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/ComboBoxText.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/ComboBoxText.cpp @@ -6,15 +6,57 @@ void UComboBoxText::PostInitProperties() { Super::PostInitProperties(); - SetOptions(_DefaultOptions); + SetOptionsAsText(_DefaultOptions); _DefaultOptions.Empty(); + OnSelectionChanged.AddDynamic(this, &UComboBoxText::UpdateButtonPadding); + auto& style = GetWidgetStyle(); + buttonNormalLeftPadding = style.ComboButtonStyle.ButtonStyle.NormalPadding.Left; + buttonPressedLeftPadding = style.ComboButtonStyle.ButtonStyle.PressedPadding.Left; } -void UComboBoxText::SetOptions(const TArray& options) +void UComboBoxText::SetOptionsAsText(const TArray& options) { ClearSelection(); - Options.Empty(); + Options.Empty(options.Num()); for(auto& o : options) Options.Add(MakeShareable(new FString(o.ToString()))); RefreshOptions(); + PostOptionsSet(); +} + +void UComboBoxText::SetOptionsAsString(const TArray& options) +{ + ClearSelection(); + Options.Empty(options.Num()); + for(auto& o : options) + Options.Add(MakeShareable(new FString(o))); + RefreshOptions(); + PostOptionsSet(); +} + +TArray UComboBoxText::GetOptions() +{ + TArray result; + result.Reserve(Options.Num()); + for(auto& o : Options) + result.Add(*o); + return MoveTemp(result); +} + +void UComboBoxText::PostOptionsSet() +{ + longestCharCount = 0; + for(auto& o : Options) + if(o->Len() > longestCharCount) + longestCharCount = o->Len(); +} + +void UComboBoxText::UpdateButtonPadding(FString SelectedItem, ESelectInfo::Type SelectionType) +{ + const int32 len = longestCharCount - SelectedItem.Len(); + auto style = GetWidgetStyle(); + float padding = GetFont().Size * (static_cast(len)); + style.ComboButtonStyle.ButtonStyle.NormalPadding.Left = padding + buttonNormalLeftPadding; + style.ComboButtonStyle.ButtonStyle.PressedPadding.Left = padding + buttonPressedLeftPadding; + SetWidgetStyle(style); } diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/ComboBoxText.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/ComboBoxText.h index 82321b7..930cb7e 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/ComboBoxText.h +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/ComboBoxText.h @@ -15,9 +15,22 @@ public: virtual void PostInitProperties() override; UFUNCTION(BlueprintCallable) - void SetOptions(const TArray& options); + void SetOptionsAsText(const TArray& options); + + UFUNCTION(BlueprintCallable) + void SetOptionsAsString(const TArray& options); + + UFUNCTION(BlueprintPure) + TArray GetOptions(); protected: + void PostOptionsSet(); + UFUNCTION() + void UpdateButtonPadding(FString SelectedItem, ESelectInfo::Type SelectionType); + UPROPERTY(EditAnywhere, Category = ComboBoxTextDefault) TArray _DefaultOptions; + + int32 longestCharCount; + float buttonNormalLeftPadding, buttonPressedLeftPadding; }; diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/ResolutionResponsiveWidget.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/ResolutionResponsiveWidget.cpp index 2c4298a..ab29312 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/ResolutionResponsiveWidget.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/ResolutionResponsiveWidget.cpp @@ -3,6 +3,7 @@ #include "ResolutionResponsiveWidget.h" #include "Components/PanelSlot.h" +#include "GraphicsSettingsHelper.h" #include "UnrealClient.h" bool UResolutionResponsiveWidget::Initialize() diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/WidgetsManager.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/WidgetsManager.cpp index 1bf8772..95b6a16 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/WidgetsManager.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/WidgetsManager.cpp @@ -10,6 +10,7 @@ #include "UObject/ScriptInterface.h" #include "CustomGameInstance.h" +#include "CustomGameSettings.h" #include "Interactable/Interactable.h" #include "Interactable/Modificators/InteractableModificator.h" #include "Interactable/Modificators/InventoryInteractableModificator.h" @@ -98,6 +99,12 @@ void UWidgetsManager::Init() journalWidget->SetVisibility(ESlateVisibility::Hidden); journalWidget->AddToViewport(); } + + if(auto settings = UCustomGameSettings::Get()) + { + if(settings->bShowFps) + ShowFpsCount(); + } } } @@ -156,6 +163,27 @@ void UWidgetsManager::HideMainMenu() +void UWidgetsManager::ShowFpsCount() +{ + if(fpsCountWidget) + return; + + if(auto PC = UGameplayStatics::GetPlayerController(GetWorld(), 0)) + fpsCountWidget = CreateWidget(PC, fpsCountWidgetClass); + fpsCountWidget->AddToViewport(); +} + +void UWidgetsManager::HideFpsCount() +{ + if(!fpsCountWidget) + return; + + fpsCountWidget->RemoveFromViewport(); + fpsCountWidget = nullptr; +} + + + void UWidgetsManager::ShowInteractionHints(const UInteractableModificator* modificator) { if(interactableHintWidgetManager) diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/WidgetsManager.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/WidgetsManager.h index d421895..058de50 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/WidgetsManager.h +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/WidgetsManager.h @@ -30,6 +30,9 @@ public: void ShowMainMenu(bool pause = true); void HideMainMenu(); + void ShowFpsCount(); + void HideFpsCount(); + UFUNCTION(BlueprintCallable, Category = WidgetsManager) void ShowInteractionHints(const class UInteractableModificator* modificator = nullptr); UFUNCTION(BlueprintCallable, Category = WidgetsManager) @@ -70,6 +73,10 @@ protected: TSubclassOf mainMenuWidgetClass; class UMainMenuWidget* mainMenuWidget = nullptr; + UPROPERTY(EditDefaultsOnly) + TSubclassOf fpsCountWidgetClass; + class UUserWidget* fpsCountWidget = nullptr; + UPROPERTY(EditDefaultsOnly) TSubclassOf interactableHintWidgetManagerClass; // hidden in cutscene class UInteractableHintWidgetManager* interactableHintWidgetManager = nullptr;