Skip to content
Snippets Groups Projects
Commit c3fa988a authored by Sebastian Pape's avatar Sebastian Pape
Browse files

Adding the DemoConfig and rewriting the utility "chapter" within the README

parent c6e5f561
No related branches found
No related tags found
1 merge request!1Adding the DemoConfig and rewriting the utility "chapter" within the README
......@@ -53,4 +53,10 @@ PawnMovement->SetCameraComponent(CameraComponent);
```
## :open_file_folder: Utility
This folder contains the VirtualRealityUtilities.h, which is a collection of static functions which can be helpful in every application
This folder contains a collection of functions/classes which can be helpful in every application
### :diamond_shape_with_a_dot_inside: VirtualRealityUtilities
The VirtualRealityUtilities.h is a collection of static functions which are specifically useful for all nDisplay related applications
### :diamond_shape_with_a_dot_inside: DemoConfig
The DemoConfig is an extension to the normally used `UDeveloperSettings`, which enable the storing and altering of ini file as usual within the project, but extends this functionality to generate these ini file in the shipped project on startup, if they are not there.
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/DeveloperSettings.h"
#include "DemoConfig.generated.h"
/**
* This DeveloperSettings derivative has the following behavior:
* 1. Creates a DefaultDemo.ini in your projects config folder (Name can be changed via "config =" parameter in UCLASS)
* 2. Creates a settings page in the project settings (ProjectSettings|Game|Demo) for all UPROPERTY-s and stores all UPROPERTY-s with a "Config" flag into (1.), that are altered
* 3. When packaged, creates a Demo.ini (without "Default") in the config directory of the game and dumps the contents of the DefaultDemo.ini into it
* 4. When packaged, loads the config file from (3.) into this class
* 5. Settings can be accessed from everywhere via `GetDefault<UYourSubClass>()->PropertyName`
*/
UCLASS(Abstract, config = Demo, defaultconfig)
class DISPLAYCLUSTEREXTENSIONS_API UDemoConfig : public UDeveloperSettings
{
GENERATED_BODY()
virtual FName GetCategoryName() const override {return "Game";};
#if WITH_EDITOR
virtual FText GetSectionText() const override {return FText::FromString("Demo");};
#endif
virtual void PostInitProperties() override
{
Super::PostInitProperties();
// Do not create/load this config file in the editor. We have the DefaultDemo.ini already
if(FApp::GetBuildTargetType() == EBuildTargetType::Editor) return;
// Load config file (does nothing if not exist)
const FString ConfigFile = FPaths::Combine(FPaths::ProjectConfigDir(), FPaths::GetCleanFilename(GetClass()->GetConfigName()));
FConfigCacheIni Config(EConfigCacheType::DiskBacked);
Config.LoadFile(ConfigFile);
// Check existence of correct section (fails if file does not exist)
if(Config.DoesSectionExist(*GetClass()->GetPathName(), ConfigFile))
{
LoadConfig(GetClass(), *ConfigFile);
}
else
{
SaveConfig(CPF_Config, *ConfigFile, &Config);
Config.Flush(false);
}
};
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment