Files
UnrealEngineUWP/Engine/Source/Developer/SourceControl/Public/SourceControlInitSettings.h
paul chipchase 623ba6cc9e The source control settings for the VA source control connection are no longer saved to a local ini file.
#rb Per.Larsson
#jira UE-163834
#rnx
#preflight 632d98e4b4515b7e221654ec

### Virtualization
- At the moment there is no way in the editor UX to change the source control settings for the source control backend, so what ever settings are found in the global environment would be applied when the editor is first run and then saved to a config file under the <saved> directory. From this point onwards those settings would always be used when setting up the source control backend. If the settings were wrong, the first time that the editor was started, then we'd continue to use the incorrect settings even if the global enviroment was fixed. Making the backend work at that point would require that the user know about the local ini file and change the settings there.
- We cannot fix this by just ignoring the ini file as it has been requested that users can add their settings there in case they want to customize things, so we just need to avoid saving to it.
- Added documentation to the source control backends header file on how to set up the ini file if needed.

### Perforce
- FSourceControlInitSettings now accepts EConfigBehavior which describes how we want the source control provider to deal with its settings with regards to the ini file.
- Note that EConfigBehavior is not a bitfield as we do not wish to support only writing to the ini file, there is no point if it cannot be read from.
- When the source control provider is creatred we pass on the into from EConfigBehavior to the FPerforceSourceControlSettings to enable/disable saving and loading.

[CL 22163769 by paul chipchase in ue5-main branch]
2022-09-23 20:05:59 -04:00

53 lines
1.5 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Containers/Map.h"
#include "Containers/StringFwd.h"
#include "Containers/UnrealString.h"
class FString;
class SOURCECONTROL_API FSourceControlInitSettings
{
public:
enum class EBehavior
{
/** All existing settings will be overridden via the contents of FSourceControlInitSettings. Settings that are not found will be reset to default states */
OverrideAll,
/** Only the settings found in FSourceControlInitSettings will be overridden. Settings not found will be left with their current values. */
OverrideExisting,
};
enum class EConfigBehavior
{
/** Can both read from, and save to the ini file*/
ReadWrite,
/** Will only read settings from the ini file, settings determined at runtime will not be saved to the ini file */
ReadOnly,
/** The settings will not be saved to the ini file, nor will they be read from the ini file */
None
};
FSourceControlInitSettings(EBehavior Behavior);
~FSourceControlInitSettings() = default;
void SetConfigBehavior(EConfigBehavior Behavior);
bool CanWriteToConfigFile() const;
bool CanReadFromConfigFile() const;
void AddSetting(FStringView SettingName, FStringView SettingValue);
void OverrideSetting(FStringView SettingName, FString& InOutSettingValue);
bool HasOverrides() const;
bool IsOverridden(FStringView SettingName) const;
private:
EBehavior OverrideBehavior = EBehavior::OverrideAll;
EConfigBehavior ConfigBehavior = EConfigBehavior::ReadWrite;
TMap<FString, FString> Settings;
};