Remove EditorSettingsOriginTracker (moved to prototype branch)

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>
This commit is contained in:
Danilo Aimini
2021-08-10 17:32:39 -07:00
parent f3fe8439a7
commit 6db547302e
3 changed files with 0 additions and 146 deletions
@@ -1,103 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <AzToolsFramework/Editor/Settings/EditorSettingsOriginTracker.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Utils/Utils.h>
namespace AzToolsFramework
{
EditorSettingsOriginTracker::SettingsNotificationHandler::SettingsNotificationHandler(
AZ::SettingsRegistryInterface& registry)
: m_settingsRegistry(registry)
{
AZ::JsonApplyPatchSettings applyPatchSettings;
m_settingsRegistry.GetApplyPatchSettings(applyPatchSettings);
// Wrap any existing callbacks into the reporting callback, so that both this struct
// reporting callbacks and the existing callbacks can be invoked
m_prevReportingCallback = applyPatchSettings.m_reporting;
applyPatchSettings.m_reporting = [this](
AZStd::string_view message, AZ::JsonSerializationResult::ResultCode result,
AZStd::string_view path) -> AZ::JsonSerializationResult::ResultCode
{
m_prevReportingCallback(message, result, path);
(*this)(message, result, path);
return result;
};
m_settingsRegistry.SetApplyPatchSettings(applyPatchSettings);
}
EditorSettingsOriginTracker::SettingsNotificationHandler::~SettingsNotificationHandler()
{
// Restore previous reporting callback
AZ::JsonApplyPatchSettings applyPatchSettings;
m_settingsRegistry.GetApplyPatchSettings(applyPatchSettings);
applyPatchSettings.m_reporting = m_prevReportingCallback;
m_settingsRegistry.SetApplyPatchSettings(applyPatchSettings);
}
// Use the Json Serialization Issue Callback system
// to determine when a merge option modifies a value
AZ::JsonSerializationResult::ResultCode EditorSettingsOriginTracker::SettingsNotificationHandler::operator()(
AZStd::string_view /*message*/, AZ::JsonSerializationResult::ResultCode result, AZStd::string_view path)
{
using FixedValueString = AZ::SettingsRegistryInterface::FixedValueString;
AZ::IO::PathView preferencesRootKey{ "/Amazon/Preferences", AZ::IO::PosixPathSeparator };
AZ::IO::PathView inputKey{ path, AZ::IO::PosixPathSeparator };
// Delegate to the Notifier Handler callable below
if (result.GetTask() == AZ::JsonSerializationResult::Tasks::Merge &&
result.GetProcessing() == AZ::JsonSerializationResult::Processing::Completed && inputKey.IsRelativeTo(preferencesRootKey))
{
if (auto type = m_settingsRegistry.GetType(path); type != AZ::SettingsRegistryInterface::Type::NoType)
{
operator()(path, type);
}
}
return result;
}
void EditorSettingsOriginTracker::SettingsNotificationHandler::operator()(
AZStd::string_view path, AZ::SettingsRegistryInterface::Type /*type*/)
{
constexpr AZ::IO::PathView preferencesRootKey{ "/Amazon/Preferences", AZ::IO::PosixPathSeparator };
AZ::IO::PathView inputKey{ path, AZ::IO::PosixPathSeparator };
if (inputKey.IsRelativeTo(preferencesRootKey))
{
// Do stuff with key
}
}
EditorSettingsOriginTracker::EditorSettingsOriginTracker(AZ::SettingsRegistryInterface& registry)
: m_settingsRegistry(registry)
{
auto PreMergeEvent = [this](AZStd::string_view filePath, AZStd::string_view /*rootKey*/)
{
AZ::IO::FixedMaxPath editorPreferencesPath = AZ::Utils::GetProjectPath();
editorPreferencesPath = editorPreferencesPath / "user" / "Registry" / "editorpreferences.setreg";
if (AZ::IO::PathView(filePath) == editorPreferencesPath)
{
m_notifyHandler = m_settingsRegistry.RegisterNotifier(SettingsNotificationHandler(m_settingsRegistry));
}
};
auto PostMergeEvent = [this](AZStd::string_view /*filePath*/, AZStd::string_view /*rootKey*/)
{
// Clear the notification handler so that it goes out of scope
// and this tracker instance no handles settings updates
m_notifyHandler = {};
};
m_preMergeEventHandler = m_settingsRegistry.RegisterPreMergeEvent(PreMergeEvent);
m_postMergeEventHandler = m_settingsRegistry.RegisterPostMergeEvent(PostMergeEvent);
}
}
@@ -1,41 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzCore/Serialization/Json/JsonSerializationSettings.h>
#include <AzCore/Settings/SettingsRegistry.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
namespace AzToolsFramework
{
struct EditorSettingsOriginTracker
{
explicit EditorSettingsOriginTracker(AZ::SettingsRegistryInterface& registry);
struct SettingsNotificationHandler
{
SettingsNotificationHandler(AZ::SettingsRegistryInterface& registry);
~SettingsNotificationHandler();
AZ::JsonSerializationResult::ResultCode operator()(
AZStd::string_view message, AZ::JsonSerializationResult::ResultCode result, AZStd::string_view path);
void operator()(AZStd::string_view path, AZ::SettingsRegistryInterface::Type type);
private:
AZ::SettingsRegistryInterface& m_settingsRegistry;
AZ::JsonSerializationResult::JsonIssueCallback m_prevReportingCallback;
};
private:
AZ::SettingsRegistryInterface& m_settingsRegistry;
AZ::SettingsRegistryInterface::PreMergeEventHandler m_preMergeEventHandler;
AZ::SettingsRegistryInterface::PostMergeEventHandler m_postMergeEventHandler;
AZ::SettingsRegistryInterface::NotifyEventHandler m_notifyHandler;
};
} // namespace AZ
@@ -113,8 +113,6 @@ set(FILES
Component/EditorLevelComponentAPIComponent.h
Editor/EditorContextMenuBus.h
Editor/EditorSettingsAPIBus.h
Editor/Settings/EditorSettingsOriginTracker.cpp
Editor/Settings/EditorSettingsOriginTracker.h
Entity/EditorEntityStartStatus.h
Entity/EditorEntityAPIBus.h
Entity/EditorEntityContextComponent.cpp