Space Plunder
Loading...
Searching...
No Matches
FCommonUIStyleModule Class Reference

#include <CommonUIStyle.h>

Inheritance diagram for FCommonUIStyleModule:

Public Member Functions

virtual void StartupModule () override
 
virtual void ShutdownModule () override
 

Member Function Documentation

◆ ShutdownModule()

void FCommonUIStyleModule::ShutdownModule ( )
overridevirtual
74{
75 // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
76 // we call this function before unloading the module.
77}

◆ StartupModule()

void FCommonUIStyleModule::StartupModule ( )
overridevirtual

IModuleInterface implementation

13{
14 // // Copy relevant keys from the plugin’s config to PlatformInput.ini
15 const FString SourceSection = TEXT("CommonInputPlatformSettings_Windows CommonInputPlatformSettings");
16 const FString SourceIni = FPaths::Combine(IPluginManager::Get().FindPlugin("CommonUIStyle")->GetBaseDir(), TEXT("Config/DefaultCommonUIStyle.ini"));
17 TArray<FString> Keys = {
18 TEXT("DefaultInputType"),
19 TEXT("bSupportsMouseAndKeyboard"),
20 TEXT("bSupportsTouch"),
21 TEXT("bSupportsGamepad"),
22 TEXT("DefaultGamepadName"),
23 TEXT("bCanChangeGamepadType"),
24 TEXT("+ControllerData") // For +ControllerData
25 };
26 const FString SourceTargetIni = FPaths::Combine(FPaths::ProjectConfigDir(), TEXT("DefaultGame.ini"));
27 FString TargetIni = FConfigCacheIni::NormalizeConfigIniPath(SourceTargetIni);
28 for(const FString& Key : Keys)
29 {
30 TArray<FString> Values;
31 if (GConfig->GetArray(*SourceSection, *Key, Values, *SourceIni))
32 {
33 // Special handling for arrays that need '+' syntax
34 if(Key == TEXT("+ControllerData"))
35 {
36 GConfig->SetArray(*SourceSection, TEXT("+ControllerData"), Values, *TargetIni);
37 }
38 else
39 {
40 GConfig->SetArray(*SourceSection, *Key, Values, *TargetIni);
41 }
42 }
43 else
44 {
45 FString Value;
46 if (GConfig->GetString(*SourceSection, *Key, Value, *SourceIni))
47 {
48 GConfig->SetString(*SourceSection, *Key, *Value, *TargetIni);
49 }
50 }
51 }
52
53 const FString CustomSection = TEXT("CommonUIStyle");
54 const FString CustomKey = TEXT("InputData");
55 FString StyleInputData;
56 // Load the config value from the custom ini file
57 if(GConfig->GetString(*CustomSection, *CustomKey, StyleInputData, *SourceIni))
58 {
59 // Write it to the project's actual Game.ini (will persist)
60 const FString TargetSection = TEXT("/Script/CommonInput.CommonInputSettings");
61 const FString TargetKey = TEXT("InputData");
62 GConfig->SetString(*TargetSection, *TargetKey, *StyleInputData, *TargetIni);
63
64 UE_LOG(LogTemp, Log, TEXT("Set InputData to %s from DefaultCommonUIStyle.ini"), *StyleInputData);
65 }
66 else
67 {
68 UE_LOG(LogTemp, Warning, TEXT("Could not find InputData in %s"), *SourceIni);
69 }
70 GConfig->Flush(false, *TargetIni); // Make sure it gets saved
71}

The documentation for this class was generated from the following files: