@@ -192,11 +192,86 @@ namespace AZ
|
||||
};
|
||||
|
||||
|
||||
//! SettingsRegistry notifier handler which is responsible for loading
|
||||
//! the project.json file at the new project path
|
||||
//! if an update to '<BootstrapSettingsRootKey>/project_path' key occurs.
|
||||
struct ProjectPathChangedEventHandler
|
||||
{
|
||||
ProjectPathChangedEventHandler(AZ::SettingsRegistryInterface& registry)
|
||||
: m_registry{ registry }
|
||||
{
|
||||
}
|
||||
|
||||
void operator()(AZStd::string_view path, AZ::SettingsRegistryInterface::Type)
|
||||
{
|
||||
// Update the project settings when the project path is set
|
||||
using FixedValueString = AZ::SettingsRegistryInterface::FixedValueString;
|
||||
const auto projectPathKey = FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
|
||||
|
||||
AZ::IO::FixedMaxPath newProjectPath;
|
||||
if (SettingsRegistryMergeUtils::IsPathAncestorDescendantOrEqual(projectPathKey, path)
|
||||
&& m_registry.Get(newProjectPath.Native(), projectPathKey) && newProjectPath != m_oldProjectPath)
|
||||
{
|
||||
// Update old Project path before attempting to merge in new Settings Registry values in order to prevent recursive calls
|
||||
m_oldProjectPath = newProjectPath;
|
||||
|
||||
// Merge the project.json file into settings registry under ProjectSettingsRootKey path.
|
||||
AZ::IO::FixedMaxPath projectMetadataFile{ AZ::SettingsRegistryMergeUtils::FindEngineRoot(m_registry) / newProjectPath };
|
||||
projectMetadataFile /= "project.json";
|
||||
m_registry.MergeSettingsFile(projectMetadataFile.Native(),
|
||||
AZ::SettingsRegistryInterface::Format::JsonMergePatch, AZ::SettingsRegistryMergeUtils::ProjectSettingsRootKey);
|
||||
|
||||
// Update all the runtime file paths based on the new "project_path" value.
|
||||
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(m_registry);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
AZ::IO::FixedMaxPath m_oldProjectPath;
|
||||
AZ::SettingsRegistryInterface& m_registry;
|
||||
};
|
||||
|
||||
//! SettingsRegistry notifier handler which adds the project name as a specialization tag
|
||||
//! to the registry
|
||||
//! if an update to '<ProjectSettingsRootKey>/project_name' key occurs.
|
||||
struct ProjectNameChangedEventHandler
|
||||
{
|
||||
ProjectNameChangedEventHandler(AZ::SettingsRegistryInterface& registry)
|
||||
: m_registry{ registry }
|
||||
{
|
||||
}
|
||||
|
||||
void operator()(AZStd::string_view path, AZ::SettingsRegistryInterface::Type)
|
||||
{
|
||||
// Update the project specialization when the project name is set
|
||||
using FixedValueString = AZ::SettingsRegistryInterface::FixedValueString;
|
||||
const auto projectNameKey = FixedValueString(AZ::SettingsRegistryMergeUtils::ProjectSettingsRootKey) + "/project_name";
|
||||
|
||||
FixedValueString newProjectName;
|
||||
if (SettingsRegistryMergeUtils::IsPathAncestorDescendantOrEqual(projectNameKey, path)
|
||||
&& m_registry.Get(newProjectName, projectNameKey) && newProjectName != m_oldProjectName)
|
||||
{
|
||||
// Add the project_name as a specialization for loading the build system dependency .setreg files
|
||||
auto newProjectNameSpecialization = FixedValueString::format("%s/%.*s", AZ::SettingsRegistryMergeUtils::SpecializationsRootKey,
|
||||
aznumeric_cast<int>(newProjectName.size()), newProjectName.data());
|
||||
auto oldProjectNameSpecialization = FixedValueString::format("%s/%s", AZ::SettingsRegistryMergeUtils::SpecializationsRootKey,
|
||||
m_oldProjectName.c_str());
|
||||
m_registry.Remove(oldProjectNameSpecialization);
|
||||
m_oldProjectName = newProjectName;
|
||||
m_registry.Set(newProjectNameSpecialization, true);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
AZ::SettingsRegistryInterface::FixedValueString m_oldProjectName;
|
||||
AZ::SettingsRegistryInterface& m_registry;
|
||||
};
|
||||
|
||||
//! SettingsRegistry notifier handler which updates relevant registry settings based
|
||||
//! on an update to '/Amazon/AzCore/Bootstrap/project_path' key.
|
||||
struct UpdateProjectSettingsEventHandler
|
||||
struct UpdateCommandLineEventHandler
|
||||
{
|
||||
UpdateProjectSettingsEventHandler(AZ::SettingsRegistryInterface& registry, AZ::CommandLine& commandLine)
|
||||
UpdateCommandLineEventHandler(AZ::SettingsRegistryInterface& registry, AZ::CommandLine& commandLine)
|
||||
: m_registry{ registry }
|
||||
, m_commandLine{ commandLine }
|
||||
{
|
||||
@@ -204,70 +279,14 @@ namespace AZ
|
||||
|
||||
void operator()(AZStd::string_view path, AZ::SettingsRegistryInterface::Type)
|
||||
{
|
||||
using FixedValueString = AZ::SettingsRegistryInterface::FixedValueString;
|
||||
// #1 Update the project settings when the project path is set
|
||||
const auto projectPathKey = FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
|
||||
AZ::IO::FixedMaxPath newProjectPath;
|
||||
if (SettingsRegistryMergeUtils::IsPathAncestorDescendantOrEqual(projectPathKey, path)
|
||||
&& m_registry.Get(newProjectPath.Native(), projectPathKey) && newProjectPath != m_oldProjectPath)
|
||||
{
|
||||
UpdateProjectSettingsFromProjectPath(AZ::IO::PathView(newProjectPath));
|
||||
}
|
||||
|
||||
// #2 Update the project specialization when the project name is set
|
||||
const auto projectNameKey = FixedValueString(AZ::SettingsRegistryMergeUtils::ProjectSettingsRootKey) + "/project_name";
|
||||
FixedValueString newProjectName;
|
||||
if (SettingsRegistryMergeUtils::IsPathAncestorDescendantOrEqual(projectNameKey, path)
|
||||
&& m_registry.Get(newProjectName, projectNameKey) && newProjectName != m_oldProjectName)
|
||||
{
|
||||
UpdateProjectSpecializationFromProjectName(newProjectName);
|
||||
}
|
||||
|
||||
// #3 Update the ComponentApplication CommandLine instance when the command line settings are merged into the Settings Registry
|
||||
// Update the ComponentApplication CommandLine instance when the command line settings are merged into the Settings Registry
|
||||
if (path == AZ::SettingsRegistryMergeUtils::CommandLineValueChangedKey)
|
||||
{
|
||||
UpdateCommandLine();
|
||||
AZ::SettingsRegistryMergeUtils::GetCommandLineFromRegistry(m_registry, m_commandLine);
|
||||
}
|
||||
}
|
||||
|
||||
//! Add the project name as a specialization underneath the /Amazon/AzCore/Settings/Specializations path
|
||||
//! and remove the current project name specialization if one exists.
|
||||
void UpdateProjectSpecializationFromProjectName(AZStd::string_view newProjectName)
|
||||
{
|
||||
using FixedValueString = AZ::SettingsRegistryInterface::FixedValueString;
|
||||
// Add the project_name as a specialization for loading the build system dependency .setreg files
|
||||
auto newProjectNameSpecialization = FixedValueString::format("%s/%.*s", AZ::SettingsRegistryMergeUtils::SpecializationsRootKey,
|
||||
aznumeric_cast<int>(newProjectName.size()), newProjectName.data());
|
||||
auto oldProjectNameSpecialization = FixedValueString::format("%s/%s", AZ::SettingsRegistryMergeUtils::SpecializationsRootKey,
|
||||
m_oldProjectName.c_str());
|
||||
m_registry.Remove(oldProjectNameSpecialization);
|
||||
m_oldProjectName = newProjectName;
|
||||
m_registry.Set(newProjectNameSpecialization, true);
|
||||
}
|
||||
|
||||
void UpdateProjectSettingsFromProjectPath(AZ::IO::PathView newProjectPath)
|
||||
{
|
||||
// Update old Project path before attempting to merge in new Settings Registry values in order to prevent recursive calls
|
||||
m_oldProjectPath = newProjectPath;
|
||||
|
||||
// Merge the project.json file into settings registry under ProjectSettingsRootKey path.
|
||||
AZ::IO::FixedMaxPath projectMetadataFile{ AZ::SettingsRegistryMergeUtils::FindEngineRoot(m_registry) / newProjectPath };
|
||||
projectMetadataFile /= "project.json";
|
||||
m_registry.MergeSettingsFile(projectMetadataFile.Native(),
|
||||
AZ::SettingsRegistryInterface::Format::JsonMergePatch, AZ::SettingsRegistryMergeUtils::ProjectSettingsRootKey);
|
||||
|
||||
// Update all the runtime file paths based on the new "project_path" value.
|
||||
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(m_registry);
|
||||
}
|
||||
|
||||
void UpdateCommandLine()
|
||||
{
|
||||
AZ::SettingsRegistryMergeUtils::GetCommandLineFromRegistry(m_registry, m_commandLine);
|
||||
}
|
||||
|
||||
private:
|
||||
AZ::IO::FixedMaxPath m_oldProjectPath;
|
||||
AZ::SettingsRegistryInterface::FixedValueString m_oldProjectName;
|
||||
AZ::SettingsRegistryInterface& m_registry;
|
||||
AZ::CommandLine& m_commandLine;
|
||||
};
|
||||
@@ -462,7 +481,12 @@ namespace AZ
|
||||
// 1. The 'project_path' key changes
|
||||
// 2. The project specialization when the 'project-name' key changes
|
||||
// 3. The ComponentApplication command line when the command line is stored to the registry
|
||||
m_projectChangedHandler = m_settingsRegistry->RegisterNotifier(UpdateProjectSettingsEventHandler{ *m_settingsRegistry, m_commandLine });
|
||||
m_projectPathChangedHandler = m_settingsRegistry->RegisterNotifier(ProjectPathChangedEventHandler{
|
||||
*m_settingsRegistry });
|
||||
m_projectNameChangedHandler = m_settingsRegistry->RegisterNotifier(ProjectNameChangedEventHandler{
|
||||
*m_settingsRegistry });
|
||||
m_commandLineUpdatedHandler = m_settingsRegistry->RegisterNotifier(UpdateCommandLineEventHandler{
|
||||
*m_settingsRegistry, m_commandLine });
|
||||
|
||||
// Merge Command Line arguments
|
||||
constexpr bool executeRegDumpCommands = false;
|
||||
@@ -515,11 +539,12 @@ namespace AZ
|
||||
Destroy();
|
||||
}
|
||||
|
||||
// The m_projectChangedHandler stores an AZStd::function internally
|
||||
// which allocates using the AZ SystemAllocator
|
||||
// m_projectChangedHandler is being default value initialized
|
||||
// to clear out the AZStd::function
|
||||
m_projectChangedHandler = {};
|
||||
// The SettingsRegistry Notify handlers stores an AZStd::function internally
|
||||
// which may allocates using the AZ SystemAllocator(if the functor > 16 bytes)
|
||||
// The handlers are being default value initialized to clear out the AZStd::function
|
||||
m_commandLineUpdatedHandler = {};
|
||||
m_projectNameChangedHandler = {};
|
||||
m_projectPathChangedHandler = {};
|
||||
|
||||
// Delete the AZ::IConsole if it was created by this application instance
|
||||
if (m_ownsConsole)
|
||||
|
||||
@@ -390,7 +390,9 @@ namespace AZ
|
||||
AZ::IO::FixedMaxPath m_engineRoot;
|
||||
AZ::IO::FixedMaxPath m_appRoot;
|
||||
|
||||
AZ::SettingsRegistryInterface::NotifyEventHandler m_projectChangedHandler;
|
||||
AZ::SettingsRegistryInterface::NotifyEventHandler m_projectPathChangedHandler;
|
||||
AZ::SettingsRegistryInterface::NotifyEventHandler m_projectNameChangedHandler;
|
||||
AZ::SettingsRegistryInterface::NotifyEventHandler m_commandLineUpdatedHandler;
|
||||
|
||||
// ConsoleFunctorHandle is responsible for unregistering the Settings Registry Console
|
||||
// from the m_console member when it goes out of scope
|
||||
|
||||
@@ -225,8 +225,16 @@ namespace AZ
|
||||
|
||||
ConsoleCommandContainer commandSubset;
|
||||
|
||||
for (ConsoleFunctorBase* curr = m_head; curr != nullptr; curr = curr->m_next)
|
||||
for (const auto& functor : m_commands)
|
||||
{
|
||||
if (functor.second.empty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Filter functors registered with the same name
|
||||
const ConsoleFunctorBase* curr = functor.second.front();
|
||||
|
||||
if ((curr->GetFlags() & ConsoleFunctorFlags::IsInvisible) == ConsoleFunctorFlags::IsInvisible)
|
||||
{
|
||||
// Filter functors marked as invisible
|
||||
@@ -236,7 +244,12 @@ namespace AZ
|
||||
if (StringFunc::StartsWith(curr->m_name, command, false))
|
||||
{
|
||||
AZLOG_INFO("- %s : %s\n", curr->m_name, curr->m_desc);
|
||||
commandSubset.push_back(curr->m_name);
|
||||
|
||||
if (commandSubset.size() < MaxConsoleCommandPlusArgsLength)
|
||||
{
|
||||
commandSubset.push_back(curr->m_name);
|
||||
}
|
||||
|
||||
if (matches)
|
||||
{
|
||||
matches->push_back(curr->m_name);
|
||||
@@ -271,7 +284,10 @@ namespace AZ
|
||||
{
|
||||
for (auto& curr : m_commands)
|
||||
{
|
||||
visitor(curr.second.front());
|
||||
if (!curr.second.empty())
|
||||
{
|
||||
visitor(curr.second.front());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,6 +352,11 @@ namespace AZ
|
||||
{
|
||||
iter->second.erase(iter2);
|
||||
}
|
||||
|
||||
if (iter->second.empty())
|
||||
{
|
||||
m_commands.erase(iter);
|
||||
}
|
||||
}
|
||||
functor->Unlink(m_head);
|
||||
functor->m_console = nullptr;
|
||||
@@ -618,9 +639,10 @@ namespace AZ
|
||||
{
|
||||
// Make sure the there is a JSON object at the ConsoleRuntimeCommandKey or ConsoleAutoexecKey
|
||||
// So that JSON Patch is able to add values underneath that object (JSON Patch doesn't create intermediate objects)
|
||||
settingsRegistry.MergeSettings(R"({ "Amazon": { "AzCore": { "Runtime": { "ConsoleCommands": {} } } })"
|
||||
R"(,"O3DE": { "Autoexec": { "ConsoleCommands": {} } } })",
|
||||
SettingsRegistryInterface::Format::JsonMergePatch);
|
||||
settingsRegistry.MergeSettings(R"({})", SettingsRegistryInterface::Format::JsonMergePatch,
|
||||
IConsole::ConsoleRuntimeCommandKey);
|
||||
settingsRegistry.MergeSettings(R"({})", SettingsRegistryInterface::Format::JsonMergePatch,
|
||||
IConsole::ConsoleAutoexecCommandKey);
|
||||
m_consoleCommandKeyHandler = settingsRegistry.RegisterNotifier(ConsoleCommandKeyNotificationHandler{ settingsRegistry, *this });
|
||||
|
||||
JsonApplyPatchSettings applyPatchSettings;
|
||||
|
||||
@@ -40,6 +40,12 @@ namespace AZ
|
||||
static unsigned int Record(StackFrame* frames, unsigned int maxNumOfFrames, unsigned int suppressCount = 0, void* nativeThread = 0);
|
||||
};
|
||||
|
||||
class StackConverter
|
||||
{
|
||||
public:
|
||||
static unsigned int FromNative(StackFrame* frames, unsigned int maxNumOfFrames, void* nativeContext);
|
||||
};
|
||||
|
||||
class SymbolStorage
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -31,6 +31,8 @@ namespace AZ
|
||||
{
|
||||
namespace Debug
|
||||
{
|
||||
struct StackFrame;
|
||||
|
||||
namespace Platform
|
||||
{
|
||||
#if defined(AZ_ENABLE_DEBUG_TOOLS)
|
||||
@@ -551,17 +553,19 @@ namespace AZ
|
||||
{
|
||||
StackFrame frames[25];
|
||||
|
||||
// Without StackFrame explicit alignment frames array is aligned to 4 bytes
|
||||
// which causes the stack tracing to fail.
|
||||
//size_t bla = AZStd::alignment_of<StackFrame>::value;
|
||||
//printf("Alignment value %d address 0x%08x : 0x%08x\n",bla,frames);
|
||||
SymbolStorage::StackLine lines[AZ_ARRAY_SIZE(frames)];
|
||||
unsigned int numFrames = 0;
|
||||
|
||||
if (!nativeContext)
|
||||
{
|
||||
suppressCount += 1; /// If we don't provide a context we will capture in the RecordFunction, so skip us (Trace::PrinCallstack).
|
||||
suppressCount += 1; /// If we don't provide a context we will capture in the RecordFunction, so skip us (Trace::PrintCallstack).
|
||||
numFrames = StackRecorder::Record(frames, AZ_ARRAY_SIZE(frames), suppressCount);
|
||||
}
|
||||
unsigned int numFrames = StackRecorder::Record(frames, AZ_ARRAY_SIZE(frames), suppressCount, nativeContext);
|
||||
else
|
||||
{
|
||||
numFrames = StackConverter::FromNative(frames, AZ_ARRAY_SIZE(frames), nativeContext);
|
||||
}
|
||||
|
||||
if (numFrames)
|
||||
{
|
||||
SymbolStorage::DecodeFrames(frames, numFrames, lines);
|
||||
@@ -573,7 +577,9 @@ namespace AZ
|
||||
}
|
||||
|
||||
azstrcat(lines[i], AZ_ARRAY_SIZE(lines[i]), "\n");
|
||||
AZ_Printf(window, "%s", lines[i]); // feed back into the trace system so that listeners can get it.
|
||||
// Use Output instead of AZ_Printf to be consistent with the exception output code and avoid
|
||||
// this accidentally being suppressed as a normal message
|
||||
Output(window, lines[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,26 +192,34 @@ namespace AZ
|
||||
//! @param path An offset at which traversal should start.
|
||||
//! @return Whether or not entries could be visited.
|
||||
virtual bool Visit(const VisitorCallback& callback, AZStd::string_view path) const = 0;
|
||||
|
||||
//! Register a callback that will be called whenever an entry gets a new/updated value.
|
||||
//!
|
||||
//! @callback The function to call when an entry gets a new/updated value.
|
||||
[[nodiscard]] virtual NotifyEventHandler RegisterNotifier(const NotifyCallback& callback) = 0;
|
||||
//! Register a callback that will be called whenever an entry gets a new/updated value.
|
||||
//! @callback The function to call when an entry gets a new/updated value.
|
||||
[[nodiscard]] virtual NotifyEventHandler RegisterNotifier(NotifyCallback&& callback) = 0;
|
||||
//! @return NotifyEventHandler instance which must persist to receive event signal
|
||||
[[nodiscard]] virtual NotifyEventHandler RegisterNotifier(NotifyCallback callback) = 0;
|
||||
//! Register a notify event handler with the NotifyEvent.
|
||||
//! The handler will be called whenever an entry gets a new/updated value.
|
||||
//! @param handler The handler to register with the NotifyEvent.
|
||||
virtual void RegisterNotifier(NotifyEventHandler& handler) = 0;
|
||||
|
||||
//! Register a function that will be called before a file is merged.
|
||||
//! @callback The function to call before a file is merged.
|
||||
[[nodiscard]] virtual PreMergeEventHandler RegisterPreMergeEvent(const PreMergeEventCallback& callback) = 0;
|
||||
//! Register a function that will be called before a file is merged.
|
||||
//! @callback The function to call before a file is merged.
|
||||
[[nodiscard]] virtual PreMergeEventHandler RegisterPreMergeEvent(PreMergeEventCallback&& callback) = 0;
|
||||
//! @param callback The function to call before a file is merged.
|
||||
//! @return PreMergeEventHandler instance which must persist to receive event signal
|
||||
[[nodiscard]] virtual PreMergeEventHandler RegisterPreMergeEvent(PreMergeEventCallback callback) = 0;
|
||||
//! Register a pre-merge handler with the PreMergeEvent.
|
||||
//! The handler will be called before a file is merged.
|
||||
//! @param handler The hanlder to register with the PreMergeEvent.
|
||||
virtual void RegisterPreMergeEvent(PreMergeEventHandler& handler) = 0;
|
||||
|
||||
//! Register a function that will be called after a file is merged.
|
||||
//! @callback The function to call after a file is merged.
|
||||
[[nodiscard]] virtual PostMergeEventHandler RegisterPostMergeEvent(const PostMergeEventCallback& callback) = 0;
|
||||
//! Register a function that will be called after a file is merged.
|
||||
//! @callback The function to call after a file is merged.
|
||||
[[nodiscard]] virtual PostMergeEventHandler RegisterPostMergeEvent(PostMergeEventCallback&& callback) = 0;
|
||||
//! @param callback The function to call after a file is merged.
|
||||
//! @return PostMergeEventHandler instance which must persist to receive event signal
|
||||
[[nodiscard]] virtual PostMergeEventHandler RegisterPostMergeEvent(PostMergeEventCallback callback) = 0;
|
||||
//! Register a post-merge hahndler with the PostMergeEvent.
|
||||
//! The handler will be called after a file is merged.
|
||||
//! @param handler The handler to register with the PostmergeEVent.
|
||||
virtual void RegisterPostMergeEvent(PostMergeEventHandler& hanlder) = 0;
|
||||
|
||||
//! Gets the boolean value at the provided path.
|
||||
//! @param result The target to write the result to.
|
||||
@@ -326,23 +334,25 @@ namespace AZ
|
||||
//! - all digits and dot -> floating point number
|
||||
//! - Everything else is considered a string.
|
||||
//! @param argument The command line argument.
|
||||
//! @param structure which contains functors which determine what characters are delimiters
|
||||
//! @param anchorKey The key where the merged command line argument will be anchored under
|
||||
//! @param commandLineSettings structure which contains functors which determine what characters are delimiters
|
||||
//! @return True if the command line argument could be parsed, otherwise false.
|
||||
virtual bool MergeCommandLineArgument(AZStd::string_view argument, AZStd::string_view rootKey = "",
|
||||
virtual bool MergeCommandLineArgument(AZStd::string_view argument, AZStd::string_view anchorKey = "",
|
||||
const CommandLineArgumentSettings& commandLineSettings = {}) = 0;
|
||||
//! Merges the json data provided into the settings registry.
|
||||
//! @param data The json data stored in a string.
|
||||
//! @param format The format of the provided data.
|
||||
//! @param anchorKey The key where the merged json content will be anchored under.
|
||||
//! @return True if the data was successfully merged, otherwise false.
|
||||
virtual bool MergeSettings(AZStd::string_view data, Format format) = 0;
|
||||
virtual bool MergeSettings(AZStd::string_view data, Format format, AZStd::string_view anchorKey = "") = 0;
|
||||
//! Loads a settings file and merges it into the registry.
|
||||
//! @param path The path to the registry file.
|
||||
//! @param format The format of the text data in the file at the provided path.
|
||||
//! @param rootKey The key where the root of the settings file will be stored under.
|
||||
//! @param anchorKey The key where the content of the settings file will be anchored.
|
||||
//! @param scratchBuffer An optional buffer that's used to load the file into. Use this when loading multiple patches to
|
||||
//! reduce the number of intermediate memory allocations.
|
||||
//! @return True if the registry file was successfully merged, otherwise false.
|
||||
virtual bool MergeSettingsFile(AZStd::string_view path, Format format, AZStd::string_view rootKey = "",
|
||||
virtual bool MergeSettingsFile(AZStd::string_view path, Format format, AZStd::string_view anchorKey = "",
|
||||
AZStd::vector<char>* scratchBuffer = nullptr) = 0;
|
||||
//! Loads all settings files in a folder and merges them into the registry.
|
||||
//! With the specializations "a" and "b" and platform "c" the files would be loaded in the order:
|
||||
@@ -357,11 +367,12 @@ namespace AZ
|
||||
//! @param platform An optional name of a platform. Platform overloads are located at <path>/Platform/<platform>/
|
||||
//! Files in a platform are applied in the same order as for the main folder but always after the same file
|
||||
//! in the main folder.
|
||||
//! @param anchorKey The registry path location where the settings will be anchored
|
||||
//! @param scratchBuffer An optional buffer that's used to load the file into. Use this when loading multiple patches to
|
||||
//! reduce the number of intermediate memory allocations.
|
||||
//! @return True if the registry folder was successfully merged, otherwise false.
|
||||
virtual bool MergeSettingsFolder(AZStd::string_view path, const Specializations& specializations,
|
||||
AZStd::string_view platform = {}, AZStd::string_view rootKey = "", AZStd::vector<char>* scratchBuffer = nullptr) = 0;
|
||||
AZStd::string_view platform = {}, AZStd::string_view anchorKey = "", AZStd::vector<char>* scratchBuffer = nullptr) = 0;
|
||||
|
||||
//! Stores the settings structure which is used when merging settings to the Settings Registry
|
||||
//! using JSON Merge Patch or JSON Merge Patch.
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <AzCore/IO/FileReader.h>
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
#include <AzCore/JSON/error/en.h>
|
||||
#include <AzCore/NativeUI//NativeUIRequests.h>
|
||||
#include <AzCore/NativeUI/NativeUIRequests.h>
|
||||
#include <AzCore/Serialization/Json/JsonSerialization.h>
|
||||
#include <AzCore/Serialization/Json/StackedString.h>
|
||||
#include <AzCore/Settings/SettingsRegistryImpl.h>
|
||||
@@ -21,6 +21,34 @@
|
||||
#include <AzCore/std/sort.h>
|
||||
#include <AzCore/std/parallel/scoped_lock.h>
|
||||
|
||||
namespace AZ::SettingsRegistryImplInternal
|
||||
{
|
||||
AZ::SettingsRegistryInterface::Type RapidjsonToSettingsRegistryType(const rapidjson::Value& value)
|
||||
{
|
||||
using Type = AZ::SettingsRegistryInterface::Type;
|
||||
switch (value.GetType())
|
||||
{
|
||||
case rapidjson::Type::kNullType:
|
||||
return Type::Null;
|
||||
case rapidjson::Type::kFalseType:
|
||||
return Type::Boolean;
|
||||
case rapidjson::Type::kTrueType:
|
||||
return Type::Boolean;
|
||||
case rapidjson::Type::kObjectType:
|
||||
return Type::Object;
|
||||
case rapidjson::Type::kArrayType:
|
||||
return Type::Array;
|
||||
case rapidjson::Type::kStringType:
|
||||
return Type::String;
|
||||
case rapidjson::Type::kNumberType:
|
||||
return value.IsDouble() ? Type::FloatingPoint :
|
||||
Type::Integer;
|
||||
}
|
||||
|
||||
return Type::NoType;
|
||||
}
|
||||
}
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
template<typename T>
|
||||
@@ -28,7 +56,7 @@ namespace AZ
|
||||
{
|
||||
if (path.empty())
|
||||
{
|
||||
// rapidjson::Pointer assets that the supplied string
|
||||
// rapidjson::Pointer asserts that the supplied string
|
||||
// is not nullptr even if the supplied size is 0
|
||||
// Setting to empty string to prevent assert
|
||||
path = "";
|
||||
@@ -70,7 +98,7 @@ namespace AZ
|
||||
{
|
||||
if (path.empty())
|
||||
{
|
||||
// rapidjson::Pointer assets that the supplied string
|
||||
// rapidjson::Pointer asserts that the supplied string
|
||||
// is not nullptr even if the supplied size is 0
|
||||
// Setting to empty string to prevent assert
|
||||
path = "";
|
||||
@@ -161,7 +189,7 @@ namespace AZ
|
||||
{
|
||||
if (path.empty())
|
||||
{
|
||||
// rapidjson::Pointer assets that the supplied string
|
||||
// rapidjson::Pointer asserts that the supplied string
|
||||
// is not nullptr even if the supplied size is 0
|
||||
// Setting to empty string to prevent assert
|
||||
path = "";
|
||||
@@ -212,17 +240,7 @@ namespace AZ
|
||||
return Visit(visitor, path);
|
||||
}
|
||||
|
||||
auto SettingsRegistryImpl::RegisterNotifier(const NotifyCallback& callback) -> NotifyEventHandler
|
||||
{
|
||||
NotifyEventHandler notifyHandler{ callback };
|
||||
{
|
||||
AZStd::scoped_lock lock(m_notifierMutex);
|
||||
notifyHandler.Connect(m_notifiers);
|
||||
}
|
||||
return notifyHandler;
|
||||
}
|
||||
|
||||
auto SettingsRegistryImpl::RegisterNotifier(NotifyCallback&& callback) -> NotifyEventHandler
|
||||
auto SettingsRegistryImpl::RegisterNotifier(NotifyCallback callback) -> NotifyEventHandler
|
||||
{
|
||||
NotifyEventHandler notifyHandler{ AZStd::move(callback) };
|
||||
{
|
||||
@@ -232,23 +250,19 @@ namespace AZ
|
||||
return notifyHandler;
|
||||
}
|
||||
|
||||
auto SettingsRegistryImpl::RegisterNotifier(NotifyEventHandler& notifyHandler) -> void
|
||||
{
|
||||
AZStd::scoped_lock lock(m_notifierMutex);
|
||||
notifyHandler.Connect(m_notifiers);
|
||||
}
|
||||
|
||||
void SettingsRegistryImpl::ClearNotifiers()
|
||||
{
|
||||
AZStd::scoped_lock lock(m_notifierMutex);
|
||||
m_notifiers.DisconnectAllHandlers();
|
||||
}
|
||||
|
||||
auto SettingsRegistryImpl::RegisterPreMergeEvent(const PreMergeEventCallback& callback) -> PreMergeEventHandler
|
||||
{
|
||||
PreMergeEventHandler preMergeHandler{ callback };
|
||||
{
|
||||
AZStd::scoped_lock lock(m_settingMutex);
|
||||
preMergeHandler.Connect(m_preMergeEvent);
|
||||
}
|
||||
return preMergeHandler;
|
||||
}
|
||||
|
||||
auto SettingsRegistryImpl::RegisterPreMergeEvent(PreMergeEventCallback&& callback) -> PreMergeEventHandler
|
||||
auto SettingsRegistryImpl::RegisterPreMergeEvent(PreMergeEventCallback callback) -> PreMergeEventHandler
|
||||
{
|
||||
PreMergeEventHandler preMergeHandler{ AZStd::move(callback) };
|
||||
{
|
||||
@@ -258,17 +272,13 @@ namespace AZ
|
||||
return preMergeHandler;
|
||||
}
|
||||
|
||||
auto SettingsRegistryImpl::RegisterPostMergeEvent(const PostMergeEventCallback& callback) -> PostMergeEventHandler
|
||||
auto SettingsRegistryImpl::RegisterPreMergeEvent(PreMergeEventHandler& preMergeHandler) -> void
|
||||
{
|
||||
PostMergeEventHandler postMergeHandler{ callback };
|
||||
{
|
||||
AZStd::scoped_lock lock(m_settingMutex);
|
||||
postMergeHandler.Connect(m_postMergeEvent);
|
||||
}
|
||||
return postMergeHandler;
|
||||
AZStd::scoped_lock lock(m_settingMutex);
|
||||
preMergeHandler.Connect(m_preMergeEvent);
|
||||
}
|
||||
|
||||
auto SettingsRegistryImpl::RegisterPostMergeEvent(PostMergeEventCallback&& callback) -> PostMergeEventHandler
|
||||
auto SettingsRegistryImpl::RegisterPostMergeEvent(PostMergeEventCallback callback) -> PostMergeEventHandler
|
||||
{
|
||||
PostMergeEventHandler postMergeHandler{ AZStd::move(callback) };
|
||||
{
|
||||
@@ -278,6 +288,12 @@ namespace AZ
|
||||
return postMergeHandler;
|
||||
}
|
||||
|
||||
auto SettingsRegistryImpl::RegisterPostMergeEvent(PostMergeEventHandler& postMergeHandler) -> void
|
||||
{
|
||||
AZStd::scoped_lock lock(m_settingMutex);
|
||||
postMergeHandler.Connect(m_postMergeEvent);
|
||||
}
|
||||
|
||||
void SettingsRegistryImpl::ClearMergeEvents()
|
||||
{
|
||||
AZStd::scoped_lock lock(m_settingMutex);
|
||||
@@ -297,7 +313,36 @@ namespace AZ
|
||||
localNotifierEvent = AZStd::move(m_notifiers);
|
||||
}
|
||||
|
||||
localNotifierEvent.Signal(jsonPath, type);
|
||||
// Signal the NotifyEvent for each queued argument
|
||||
decltype(m_signalNotifierQueue) localNotifierQueue;
|
||||
{
|
||||
AZStd::scoped_lock signalLock(m_signalMutex);
|
||||
m_signalNotifierQueue.push_back({ FixedValueString{jsonPath}, type });
|
||||
// If the signal count was 0, then a dispatch is in progress
|
||||
if (m_signalCount++ == 0)
|
||||
{
|
||||
AZStd::swap(localNotifierQueue, m_signalNotifierQueue);
|
||||
}
|
||||
}
|
||||
|
||||
while (!localNotifierQueue.empty())
|
||||
{
|
||||
for (SignalNotifierArgs notifierArgs : localNotifierQueue)
|
||||
{
|
||||
localNotifierEvent.Signal(notifierArgs.m_jsonPath, notifierArgs.m_type);
|
||||
}
|
||||
// Clear the local notifier queue and check if more notifiers have been added
|
||||
localNotifierQueue = {};
|
||||
{
|
||||
AZStd::scoped_lock signalLock(m_signalMutex);
|
||||
AZStd::swap(localNotifierQueue, m_signalNotifierQueue);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
AZStd::scoped_lock signalLock(m_signalMutex);
|
||||
--m_signalCount;
|
||||
}
|
||||
|
||||
{
|
||||
// Swap the local handlers with the current m_notifiers which
|
||||
@@ -314,39 +359,19 @@ namespace AZ
|
||||
{
|
||||
if (path.empty())
|
||||
{
|
||||
//rapidjson::Pointer assets that the supplied string
|
||||
//rapidjson::Pointer asserts that the supplied string
|
||||
// is not nullptr even if the supplied size is 0
|
||||
// Setting to empty string to prevent assert
|
||||
path = "";
|
||||
}
|
||||
|
||||
|
||||
rapidjson::Pointer pointer(path.data(), path.length());
|
||||
if (pointer.IsValid())
|
||||
{
|
||||
AZStd::scoped_lock lock(m_settingMutex);
|
||||
const rapidjson::Value* value = pointer.Get(m_settings);
|
||||
if (value)
|
||||
if (const rapidjson::Value* value = pointer.Get(m_settings); value != nullptr)
|
||||
{
|
||||
switch (value->GetType())
|
||||
{
|
||||
case rapidjson::Type::kNullType:
|
||||
return Type::Null;
|
||||
case rapidjson::Type::kFalseType:
|
||||
return Type::Boolean;
|
||||
case rapidjson::Type::kTrueType:
|
||||
return Type::Boolean;
|
||||
case rapidjson::Type::kObjectType:
|
||||
return Type::Object;
|
||||
case rapidjson::Type::kArrayType:
|
||||
return Type::Array;
|
||||
case rapidjson::Type::kStringType:
|
||||
return Type::String;
|
||||
case rapidjson::Type::kNumberType:
|
||||
return
|
||||
value->IsDouble() ? Type::FloatingPoint :
|
||||
Type::Integer;
|
||||
}
|
||||
return SettingsRegistryImplInternal::RapidjsonToSettingsRegistryType(*value);
|
||||
}
|
||||
}
|
||||
return Type::NoType;
|
||||
@@ -392,7 +417,7 @@ namespace AZ
|
||||
{
|
||||
if (path.empty())
|
||||
{
|
||||
// rapidjson::Pointer assets that the supplied string
|
||||
// rapidjson::Pointer asserts that the supplied string
|
||||
// is not nullptr even if the supplied size is 0
|
||||
// Setting to empty string to prevent assert
|
||||
path = "";
|
||||
@@ -471,13 +496,12 @@ namespace AZ
|
||||
{
|
||||
if (path.empty())
|
||||
{
|
||||
//rapidjson::Pointer assets that the supplied string
|
||||
// rapidjson::Pointer asserts that the supplied string
|
||||
// is not nullptr even if the supplied size is 0
|
||||
// Setting to empty string to prevent assert
|
||||
path = "";
|
||||
}
|
||||
|
||||
|
||||
rapidjson::Pointer pointer(path.data(), path.length());
|
||||
if (pointer.IsValid())
|
||||
{
|
||||
@@ -486,10 +510,14 @@ namespace AZ
|
||||
value, nullptr, valueTypeID, m_serializationSettings);
|
||||
if (jsonResult.GetProcessing() != JsonSerializationResult::Processing::Halted)
|
||||
{
|
||||
AZStd::scoped_lock lock(m_settingMutex);
|
||||
rapidjson::Value& setting = pointer.Create(m_settings, m_settings.GetAllocator());
|
||||
setting = AZStd::move(store);
|
||||
SignalNotifier(path, Type::Object);
|
||||
auto anchorType = Type::NoType;
|
||||
{
|
||||
AZStd::scoped_lock lock(m_settingMutex);
|
||||
rapidjson::Value& setting = pointer.Create(m_settings, m_settings.GetAllocator());
|
||||
setting = AZStd::move(store);
|
||||
anchorType = SettingsRegistryImplInternal::RapidjsonToSettingsRegistryType(setting);
|
||||
}
|
||||
SignalNotifier(path, anchorType);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -500,7 +528,7 @@ namespace AZ
|
||||
{
|
||||
if (path.empty())
|
||||
{
|
||||
// rapidjson::Pointer assets that the supplied string
|
||||
// rapidjson::Pointer asserts that the supplied string
|
||||
// is not nullptr even if the supplied size is 0
|
||||
// Setting to empty string to prevent assert
|
||||
path = "";
|
||||
@@ -605,7 +633,7 @@ namespace AZ
|
||||
return Set(key, value);
|
||||
}
|
||||
|
||||
bool SettingsRegistryImpl::MergeSettings(AZStd::string_view data, Format format)
|
||||
bool SettingsRegistryImpl::MergeSettings(AZStd::string_view data, Format format, AZStd::string_view anchorKey)
|
||||
{
|
||||
rapidjson::Document jsonPatch;
|
||||
constexpr int flags = rapidjson::kParseStopWhenDoneFlag | rapidjson::kParseCommentsFlag | rapidjson::kParseTrailingCommasFlag;
|
||||
@@ -631,17 +659,43 @@ namespace AZ
|
||||
return false;
|
||||
}
|
||||
|
||||
AZStd::scoped_lock lock(m_settingMutex);
|
||||
|
||||
JsonSerializationResult::ResultCode mergeResult =
|
||||
JsonSerialization::ApplyPatch(m_settings, m_settings.GetAllocator(), jsonPatch, mergeApproach);
|
||||
if (mergeResult.GetProcessing() != JsonSerializationResult::Processing::Completed)
|
||||
rapidjson::Pointer anchorPath;
|
||||
if (!anchorKey.empty())
|
||||
{
|
||||
AZ_Error("Settings Registry", false, "Failed to fully merge data into registry.");
|
||||
return false;
|
||||
anchorPath = rapidjson::Pointer(anchorKey.data(), anchorKey.size());
|
||||
if (!anchorPath.IsValid())
|
||||
{
|
||||
rapidjson::Pointer pointer(AZ_SETTINGS_REGISTRY_HISTORY_KEY "/-");
|
||||
AZ_Error("Settings Registry", false, R"(Anchor path "%.*s" is invalid.)", AZ_STRING_ARG(anchorKey));
|
||||
AZStd::scoped_lock lock(m_settingMutex);
|
||||
pointer.Create(m_settings, m_settings.GetAllocator()).SetObject()
|
||||
.AddMember(rapidjson::StringRef("Error"), rapidjson::StringRef("Invalid anchor key."), m_settings.GetAllocator())
|
||||
.AddMember(rapidjson::StringRef("Path"),
|
||||
rapidjson::Value(anchorKey.data(), aznumeric_caster(anchorKey.size()), m_settings.GetAllocator()),
|
||||
m_settings.GetAllocator());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SignalNotifier("", Type::Object);
|
||||
auto anchorType = AZ::SettingsRegistryInterface::Type::NoType;
|
||||
{
|
||||
AZStd::scoped_lock lock(m_settingMutex);
|
||||
rapidjson::Value& anchorRoot = anchorPath.IsValid() ? anchorPath.Create(m_settings, m_settings.GetAllocator())
|
||||
: m_settings;
|
||||
|
||||
JsonSerializationResult::ResultCode mergeResult =
|
||||
JsonSerialization::ApplyPatch(anchorRoot, m_settings.GetAllocator(), jsonPatch, mergeApproach);
|
||||
if (mergeResult.GetProcessing() != JsonSerializationResult::Processing::Completed)
|
||||
{
|
||||
AZ_Error("Settings Registry", false, "Failed to fully merge data into registry.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// The settings have been successfully merged, query the type at the anchor key
|
||||
anchorType = SettingsRegistryImplInternal::RapidjsonToSettingsRegistryType(anchorRoot);
|
||||
}
|
||||
|
||||
SignalNotifier(anchorKey, anchorType);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1225,10 +1279,12 @@ namespace AZ
|
||||
ScopedMergeEvent scopedMergeEvent(m_preMergeEvent, m_postMergeEvent, path, rootKey);
|
||||
|
||||
JsonSerializationResult::ResultCode mergeResult(JsonSerializationResult::Tasks::Merge);
|
||||
auto anchorType = Type::NoType;
|
||||
if (rootKey.empty())
|
||||
{
|
||||
AZStd::scoped_lock lock(m_settingMutex);
|
||||
mergeResult = JsonSerialization::ApplyPatch(m_settings, m_settings.GetAllocator(), jsonPatch, mergeApproach, m_applyPatchSettings);
|
||||
anchorType = SettingsRegistryImplInternal::RapidjsonToSettingsRegistryType(m_settings);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1238,6 +1294,7 @@ namespace AZ
|
||||
AZStd::scoped_lock lock(m_settingMutex);
|
||||
Value& rootValue = root.Create(m_settings, m_settings.GetAllocator());
|
||||
mergeResult = JsonSerialization::ApplyPatch(rootValue, m_settings.GetAllocator(), jsonPatch, mergeApproach, m_applyPatchSettings);
|
||||
anchorType = SettingsRegistryImplInternal::RapidjsonToSettingsRegistryType(rootValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1265,7 +1322,7 @@ namespace AZ
|
||||
pointer.Create(m_settings, m_settings.GetAllocator()).SetString(path, m_settings.GetAllocator());
|
||||
}
|
||||
|
||||
SignalNotifier("", Type::Object);
|
||||
SignalNotifier(rootKey, anchorType);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -48,14 +48,14 @@ namespace AZ
|
||||
Type GetType(AZStd::string_view path) const override;
|
||||
bool Visit(Visitor& visitor, AZStd::string_view path) const override;
|
||||
bool Visit(const VisitorCallback& callback, AZStd::string_view path) const override;
|
||||
[[nodiscard]] NotifyEventHandler RegisterNotifier(const NotifyCallback& callback) override;
|
||||
[[nodiscard]] NotifyEventHandler RegisterNotifier(NotifyCallback&& callback) override;
|
||||
[[nodiscard]] NotifyEventHandler RegisterNotifier(NotifyCallback callback) override;
|
||||
void RegisterNotifier(NotifyEventHandler& hanlder) override;
|
||||
void ClearNotifiers();
|
||||
|
||||
[[nodiscard]] PreMergeEventHandler RegisterPreMergeEvent(const PreMergeEventCallback& callback) override;
|
||||
[[nodiscard]] PreMergeEventHandler RegisterPreMergeEvent(PreMergeEventCallback&& callback) override;
|
||||
[[nodiscard]] PostMergeEventHandler RegisterPostMergeEvent(const PostMergeEventCallback& callback) override;
|
||||
[[nodiscard]] PostMergeEventHandler RegisterPostMergeEvent(PostMergeEventCallback&& callback) override;
|
||||
[[nodiscard]] PreMergeEventHandler RegisterPreMergeEvent(PreMergeEventCallback callback) override;
|
||||
void RegisterPreMergeEvent(PreMergeEventHandler& handler) override;
|
||||
[[nodiscard]] PostMergeEventHandler RegisterPostMergeEvent(PostMergeEventCallback callback) override;
|
||||
void RegisterPostMergeEvent(PostMergeEventHandler& handler) override;
|
||||
void ClearMergeEvents();
|
||||
|
||||
bool Get(bool& result, AZStd::string_view path) const override;
|
||||
@@ -76,13 +76,13 @@ namespace AZ
|
||||
|
||||
bool Remove(AZStd::string_view path) override;
|
||||
|
||||
bool MergeCommandLineArgument(AZStd::string_view argument, AZStd::string_view rootKey,
|
||||
bool MergeCommandLineArgument(AZStd::string_view argument, AZStd::string_view anchorKey,
|
||||
const CommandLineArgumentSettings& commandLineSettings) override;
|
||||
bool MergeSettings(AZStd::string_view data, Format format) override;
|
||||
bool MergeSettingsFile(AZStd::string_view path, Format format, AZStd::string_view rootKey,
|
||||
bool MergeSettings(AZStd::string_view data, Format format, AZStd::string_view anchorKey = "") override;
|
||||
bool MergeSettingsFile(AZStd::string_view path, Format format, AZStd::string_view anchorKey = "",
|
||||
AZStd::vector<char>* scratchBuffer = nullptr) override;
|
||||
bool MergeSettingsFolder(AZStd::string_view path, const Specializations& specializations,
|
||||
AZStd::string_view platform, AZStd::string_view rootKey = "", AZStd::vector<char>* scratchBuffer = nullptr) override;
|
||||
AZStd::string_view platform, AZStd::string_view anchorKey = "", AZStd::vector<char>* scratchBuffer = nullptr) override;
|
||||
|
||||
void SetApplyPatchSettings(const AZ::JsonApplyPatchSettings& applyPatchSettings) override;
|
||||
void GetApplyPatchSettings(AZ::JsonApplyPatchSettings& applyPatchSettings) override;
|
||||
@@ -121,6 +121,19 @@ namespace AZ
|
||||
PreMergeEvent m_preMergeEvent;
|
||||
PostMergeEvent m_postMergeEvent;
|
||||
|
||||
//! NOTE: During SignalNotifier, the registered notify event handlers are moved to a local NotifyEvent
|
||||
//! Therefore setting a value within the registry during signaling will queue future SignalNotifer calls
|
||||
//! These calls will then be invoked after the current signaling has completex
|
||||
//! This is done to avoid deadlock if another thread attempts to access register a notifier or signal one
|
||||
mutable AZStd::mutex m_signalMutex;
|
||||
struct SignalNotifierArgs
|
||||
{
|
||||
FixedValueString m_jsonPath;
|
||||
Type m_type;
|
||||
};
|
||||
AZStd::deque<SignalNotifierArgs> m_signalNotifierQueue;
|
||||
AZStd::atomic_int m_signalCount{};
|
||||
|
||||
rapidjson::Document m_settings;
|
||||
JsonSerializerSettings m_serializationSettings;
|
||||
JsonDeserializerSettings m_deserializationSettings;
|
||||
|
||||
@@ -23,12 +23,12 @@ namespace AZ
|
||||
MOCK_CONST_METHOD1(GetType, Type(AZStd::string_view));
|
||||
MOCK_CONST_METHOD2(Visit, bool(Visitor&, AZStd::string_view));
|
||||
MOCK_CONST_METHOD2(Visit, bool(const VisitorCallback&, AZStd::string_view));
|
||||
MOCK_METHOD1(RegisterNotifier, NotifyEventHandler(const NotifyCallback&));
|
||||
MOCK_METHOD1(RegisterNotifier, NotifyEventHandler(NotifyCallback&&));
|
||||
MOCK_METHOD1(RegisterPreMergeEvent, PreMergeEventHandler(const PreMergeEventCallback&));
|
||||
MOCK_METHOD1(RegisterPreMergeEvent, PreMergeEventHandler(PreMergeEventCallback&&));
|
||||
MOCK_METHOD1(RegisterPostMergeEvent, PostMergeEventHandler(const PostMergeEventCallback&));
|
||||
MOCK_METHOD1(RegisterPostMergeEvent, PostMergeEventHandler(PostMergeEventCallback&&));
|
||||
MOCK_METHOD1(RegisterNotifier, NotifyEventHandler(NotifyCallback));
|
||||
MOCK_METHOD1(RegisterNotifier, void(NotifyEventHandler&));
|
||||
MOCK_METHOD1(RegisterPreMergeEvent, PreMergeEventHandler(PreMergeEventCallback));
|
||||
MOCK_METHOD1(RegisterPreMergeEvent, void(PreMergeEventHandler&));
|
||||
MOCK_METHOD1(RegisterPostMergeEvent, PostMergeEventHandler(PostMergeEventCallback));
|
||||
MOCK_METHOD1(RegisterPostMergeEvent, void(PostMergeEventHandler&));
|
||||
|
||||
MOCK_CONST_METHOD2(Get, bool(bool&, AZStd::string_view));
|
||||
MOCK_CONST_METHOD2(Get, bool(s64&, AZStd::string_view));
|
||||
@@ -49,7 +49,7 @@ namespace AZ
|
||||
MOCK_METHOD1(Remove, bool(AZStd::string_view));
|
||||
|
||||
MOCK_METHOD3(MergeCommandLineArgument, bool(AZStd::string_view, AZStd::string_view, const CommandLineArgumentSettings&));
|
||||
MOCK_METHOD2(MergeSettings, bool(AZStd::string_view, Format));
|
||||
MOCK_METHOD3(MergeSettings, bool(AZStd::string_view, Format, AZStd::string_view));
|
||||
MOCK_METHOD4(MergeSettingsFile, bool(AZStd::string_view, Format, AZStd::string_view, AZStd::vector<char>*));
|
||||
MOCK_METHOD5(
|
||||
MergeSettingsFolder,
|
||||
|
||||
+5
@@ -17,6 +17,11 @@ namespace AZ
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int StackConverter::FromNative(StackFrame*, unsigned int, void*)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SymbolStorage::LoadModuleData(const void*, unsigned int)
|
||||
{}
|
||||
|
||||
|
||||
@@ -78,6 +78,12 @@ StackRecorder::Record(StackFrame* frames, unsigned int maxNumOfFrames, unsigned
|
||||
return count;
|
||||
}
|
||||
|
||||
unsigned int StackConverter::FromNative([[maybe_unused]] StackFrame* frames, [[maybe_unused]] unsigned int maxNumOfFrames, [[maybe_unused]] void* nativeContext)
|
||||
{
|
||||
AZ_Assert(false, "StackConverter::FromNative() is not supported for UnixLike platform yet");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SymbolStorage::DecodeFrames(const StackFrame* frames, unsigned int numFrames, StackLine* textLines)
|
||||
{
|
||||
|
||||
@@ -1048,9 +1048,9 @@ cleanup:
|
||||
unsigned int
|
||||
StackRecorder::Record(StackFrame* frames, unsigned int maxNumOfFrames, unsigned int suppressCount, void* nativeThread)
|
||||
{
|
||||
#if defined(AZ_ENABLE_DEBUG_TOOLS)
|
||||
unsigned int numFrames = 0;
|
||||
|
||||
#if defined(AZ_ENABLE_DEBUG_TOOLS)
|
||||
if (nativeThread == NULL)
|
||||
{
|
||||
++suppressCount; // Skip current call
|
||||
@@ -1079,9 +1079,8 @@ cleanup:
|
||||
|
||||
STACKFRAME64 sf;
|
||||
memset(&sf, 0, sizeof(STACKFRAME64));
|
||||
DWORD imageType;
|
||||
DWORD imageType = IMAGE_FILE_MACHINE_AMD64;
|
||||
|
||||
imageType = IMAGE_FILE_MACHINE_AMD64;
|
||||
sf.AddrPC.Offset = context.Rip;
|
||||
sf.AddrPC.Mode = AddrModeFlat;
|
||||
sf.AddrFrame.Offset = context.Rsp;
|
||||
@@ -1090,8 +1089,7 @@ cleanup:
|
||||
sf.AddrStack.Mode = AddrModeFlat;
|
||||
|
||||
EnterCriticalSection(&g_csDbgHelpDll);
|
||||
s32 frame = -(s32)suppressCount;
|
||||
for (; frame < (s32)maxNumOfFrames; ++frame)
|
||||
for (s32 frame = -static_cast<s32>(suppressCount); frame < static_cast<s32>(maxNumOfFrames); ++frame)
|
||||
{
|
||||
if (!g_StackWalk64(imageType, g_currentProcess, hThread, &sf, &context, 0, g_SymFunctionTableAccess64, g_SymGetModuleBase64, 0))
|
||||
{
|
||||
@@ -1111,15 +1109,68 @@ cleanup:
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&g_csDbgHelpDll);
|
||||
}
|
||||
return numFrames;
|
||||
}
|
||||
#else
|
||||
(void)frames;
|
||||
(void)maxNumOfFrames;
|
||||
(void)suppressCount;
|
||||
(void)nativeThread;
|
||||
return 0;
|
||||
AZ_UNUSED(frames);
|
||||
AZ_UNUSED(maxNumOfFrames);
|
||||
AZ_UNUSED(suppressCount);
|
||||
AZ_UNUSED(nativeThread);
|
||||
#endif // AZ_ENABLE_DEBUG_TOOLS
|
||||
|
||||
return numFrames;
|
||||
}
|
||||
|
||||
unsigned int StackConverter::FromNative(StackFrame* frames, unsigned int maxNumOfFrames, void* nativeContext)
|
||||
{
|
||||
unsigned int numFrames = 0;
|
||||
|
||||
#if defined(AZ_ENABLE_DEBUG_TOOLS)
|
||||
if (!g_dbgHelpLoaded)
|
||||
{
|
||||
LoadDbgHelp();
|
||||
}
|
||||
|
||||
HANDLE hThread;
|
||||
DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hThread, 0, false, DUPLICATE_SAME_ACCESS);
|
||||
|
||||
PCONTEXT nativeContextType = reinterpret_cast<PCONTEXT>(nativeContext);
|
||||
STACKFRAME64 sf;
|
||||
memset(&sf, 0, sizeof(STACKFRAME64));
|
||||
|
||||
DWORD imageType = IMAGE_FILE_MACHINE_AMD64;
|
||||
|
||||
sf.AddrPC.Offset = nativeContextType->Rip;
|
||||
sf.AddrPC.Mode = AddrModeFlat;
|
||||
sf.AddrFrame.Offset = nativeContextType->Rsp;
|
||||
sf.AddrFrame.Mode = AddrModeFlat;
|
||||
sf.AddrStack.Offset = nativeContextType->Rsp;
|
||||
sf.AddrStack.Mode = AddrModeFlat;
|
||||
|
||||
EnterCriticalSection(&g_csDbgHelpDll);
|
||||
for (unsigned int frame = 0; frame < maxNumOfFrames; ++frame)
|
||||
{
|
||||
if (!g_StackWalk64(imageType, g_currentProcess, hThread, &sf, nativeContext, 0, g_SymFunctionTableAccess64, g_SymGetModuleBase64, 0))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (sf.AddrPC.Offset == sf.AddrReturn.Offset)
|
||||
{
|
||||
// "StackWalk64-Endless-Callstack!"
|
||||
break;
|
||||
}
|
||||
|
||||
frames[numFrames++].m_programCounter = sf.AddrPC.Offset;
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&g_csDbgHelpDll);
|
||||
#else
|
||||
AZ_UNUSED(frames);
|
||||
AZ_UNUSED(maxNumOfFrames);
|
||||
AZ_UNUSED(nativeContext);
|
||||
#endif
|
||||
|
||||
return numFrames;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1413,7 +1413,7 @@ namespace UnitTest
|
||||
>;
|
||||
TYPED_TEST_CASE(HashedSetDifferentAllocatorFixture, SetTemplateConfigs);
|
||||
|
||||
#if GTEST_OS_SUPPORTS_DEATH_TEST
|
||||
#if GTEST_HAS_DEATH_TEST
|
||||
TYPED_TEST(HashedSetDifferentAllocatorFixture, InsertNodeHandleWithDifferentAllocatorsLogsTraceMessages)
|
||||
{
|
||||
using ContainerType = typename TypeParam::ContainerType;
|
||||
@@ -1435,7 +1435,7 @@ namespace UnitTest
|
||||
}
|
||||
}, ".*");
|
||||
}
|
||||
#endif // GTEST_OS_SUPPORTS_DEATH_TEST
|
||||
#endif // GTEST_HAS_DEATH_TEST
|
||||
|
||||
template<typename ContainerType>
|
||||
class HashedMapContainers
|
||||
@@ -1811,7 +1811,7 @@ namespace UnitTest
|
||||
>;
|
||||
TYPED_TEST_CASE(HashedMapDifferentAllocatorFixture, MapTemplateConfigs);
|
||||
|
||||
#if GTEST_OS_SUPPORTS_DEATH_TEST
|
||||
#if GTEST_HAS_DEATH_TEST
|
||||
TYPED_TEST(HashedMapDifferentAllocatorFixture, InsertNodeHandleWithDifferentAllocatorsLogsTraceMessages)
|
||||
{
|
||||
using ContainerType = typename TypeParam::ContainerType;
|
||||
@@ -1833,7 +1833,7 @@ namespace UnitTest
|
||||
}
|
||||
} , ".*");
|
||||
}
|
||||
#endif // GTEST_OS_SUPPORTS_DEATH_TEST
|
||||
#endif // GTEST_HAS_DEATH_TEST
|
||||
|
||||
namespace HashedContainerTransparentTestInternal
|
||||
{
|
||||
|
||||
@@ -1095,7 +1095,7 @@ namespace UnitTest
|
||||
>;
|
||||
TYPED_TEST_CASE(TreeSetDifferentAllocatorFixture, SetTemplateConfigs);
|
||||
|
||||
#if GTEST_OS_SUPPORTS_DEATH_TEST
|
||||
#if GTEST_HAS_DEATH_TEST
|
||||
TYPED_TEST(TreeSetDifferentAllocatorFixture, InsertNodeHandleWithDifferentAllocatorsLogsTraceMessages)
|
||||
{
|
||||
using ContainerType = typename TypeParam::ContainerType;
|
||||
@@ -1117,7 +1117,7 @@ namespace UnitTest
|
||||
}
|
||||
}, ".*");
|
||||
}
|
||||
#endif // GTEST_OS_SUPPORTS_DEATH_TEST
|
||||
#endif // GTEST_HAS_DEATH_TEST
|
||||
|
||||
TYPED_TEST(TreeSetDifferentAllocatorFixture, SwapMovesElementsWhenAllocatorsDiffer)
|
||||
{
|
||||
@@ -1516,7 +1516,7 @@ namespace UnitTest
|
||||
>;
|
||||
TYPED_TEST_CASE(TreeMapDifferentAllocatorFixture, MapTemplateConfigs);
|
||||
|
||||
#if GTEST_OS_SUPPORTS_DEATH_TEST
|
||||
#if GTEST_HAS_DEATH_TEST
|
||||
TYPED_TEST(TreeMapDifferentAllocatorFixture, InsertNodeHandleWithDifferentAllocatorsLogsTraceMessages)
|
||||
{
|
||||
using ContainerType = typename TypeParam::ContainerType;
|
||||
@@ -1538,7 +1538,7 @@ namespace UnitTest
|
||||
}
|
||||
}, ".*");
|
||||
}
|
||||
#endif // GTEST_OS_SUPPORTS_DEATH_TEST
|
||||
#endif // GTEST_HAS_DEATH_TEST
|
||||
|
||||
TYPED_TEST(TreeMapDifferentAllocatorFixture, SwapMovesElementsWhenAllocatorsDiffer)
|
||||
{
|
||||
|
||||
@@ -1595,7 +1595,7 @@ namespace UnitTest
|
||||
}
|
||||
};
|
||||
|
||||
#if GTEST_OS_SUPPORTS_DEATH_TEST
|
||||
#if GTEST_HAS_DEATH_TEST
|
||||
TEST_F(ThreadEventsDeathTest, UsingClientBus_AvoidsDeadlock)
|
||||
{
|
||||
EXPECT_EXIT(
|
||||
@@ -1608,5 +1608,5 @@ namespace UnitTest
|
||||
, ::testing::ExitedWithCode(0),".*");
|
||||
|
||||
}
|
||||
#endif // GTEST_OS_SUPPORTS_DEATH_TEST
|
||||
#endif // GTEST_HAS_DEATH_TEST
|
||||
}
|
||||
|
||||
@@ -736,7 +736,10 @@ namespace UnitTest
|
||||
auto& assetManager = AssetManager::Instance();
|
||||
|
||||
AssetBusCallbacks callbacks{};
|
||||
AZ_PUSH_DISABLE_WARNING(5233, "-Wunknown-warning-option") // Older versions of MSVC toolchain require to pass constexpr in the
|
||||
// capture. Newer versions issue unused warning
|
||||
callbacks.SetOnAssetReadyCallback([&, AssetNoRefB](const Asset<AssetData>&, AssetBusCallbacks&)
|
||||
AZ_POP_DISABLE_WARNING
|
||||
{
|
||||
// This callback should run inside the "main thread" dispatch events loop
|
||||
auto loadAsset = assetManager.GetAsset<AssetWithSerializedData>(AZ::Uuid(AssetNoRefB), AssetLoadBehavior::Default);
|
||||
|
||||
@@ -288,6 +288,21 @@ namespace AZ
|
||||
AZStd::string completeCommand = console->AutoCompleteCommand("testVec3");
|
||||
AZ_TEST_ASSERT(completeCommand == "testVec3");
|
||||
}
|
||||
|
||||
// Duplicate names
|
||||
{
|
||||
// Register two cvars with the same name
|
||||
auto id = AZ::TypeId();
|
||||
auto flag = AZ::ConsoleFunctorFlags::Null;
|
||||
auto signature = AZ::ConsoleFunctor<void, false>::FunctorSignature();
|
||||
AZ::ConsoleFunctor<void, false> cvarOne(*console, "testAutoCompleteDuplication", "", flag, id, signature);
|
||||
AZ::ConsoleFunctor<void, false> cvarTwo(*console, "testAutoCompleteDuplication", "", flag, id, signature);
|
||||
|
||||
// Autocomplete given name expecting one match (not two)
|
||||
AZStd::vector<AZStd::string> matches;
|
||||
AZStd::string completeCommand = console->AutoCompleteCommand("testAutoCompleteD", &matches);
|
||||
AZ_TEST_ASSERT(matches.size() == 1 && completeCommand == "testAutoCompleteDuplication");
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ConsoleTests, ConsoleFunctor_FreeFunctorExecutionTest)
|
||||
|
||||
@@ -109,7 +109,10 @@ namespace AZ::Debug
|
||||
AZStd::thread threads[totalThreads];
|
||||
for (size_t threadIndex = 0; threadIndex < totalThreads; ++threadIndex)
|
||||
{
|
||||
AZ_PUSH_DISABLE_WARNING(5233, "-Wunknown-warning-option") // Older versions of MSVC toolchain require to pass constexpr in the
|
||||
// capture. Newer versions issue unused warning
|
||||
threads[threadIndex] = AZStd::thread([&startLogging, &messages]()
|
||||
AZ_POP_DISABLE_WARNING
|
||||
{
|
||||
while (!startLogging)
|
||||
{
|
||||
@@ -226,7 +229,10 @@ namespace AZ::Debug
|
||||
AZStd::thread threads[totalThreads];
|
||||
for (size_t threadIndex = 0; threadIndex < totalThreads; ++threadIndex)
|
||||
{
|
||||
AZ_PUSH_DISABLE_WARNING(5233, "-Wunknown-warning-option") // Older versions of MSVC toolchain require to pass constexpr in the
|
||||
// capture. Newer versions issue unused warning
|
||||
threads[threadIndex] = AZStd::thread([&startLogging, &message, &totalRecordsWritten]()
|
||||
AZ_POP_DISABLE_WARNING
|
||||
{
|
||||
AZ_UNUSED(message);
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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 <AzCore/UnitTest/TestTypes.h>
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
class UnhandledExceptions
|
||||
: public ScopedAllocatorSetupFixture
|
||||
{
|
||||
|
||||
public:
|
||||
void causeAccessViolation()
|
||||
{
|
||||
int* someVariable = reinterpret_cast<int*>(0);
|
||||
*someVariable = 0;
|
||||
}
|
||||
};
|
||||
|
||||
#if GTEST_HAS_DEATH_TEST
|
||||
TEST_F(UnhandledExceptions, Handle)
|
||||
{
|
||||
EXPECT_DEATH(causeAccessViolation(), "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -144,14 +144,13 @@ namespace UnitTest
|
||||
}
|
||||
};
|
||||
|
||||
#if GTEST_OS_SUPPORTS_DEATH_TEST
|
||||
// SPEC-2669: Disabled since it is causing hangs on Linux
|
||||
#if GTEST_HAS_DEATH_TEST
|
||||
TEST_F(AllocatorsTestFixtureLeakDetectionDeathTest_SKIPCODECOVERAGE, AllocatorLeak)
|
||||
{
|
||||
// testing that the TraceBusHook will fail on cause the test to die
|
||||
EXPECT_DEATH(TestAllocatorLeak(), "");
|
||||
}
|
||||
#endif // GTEST_OS_SUPPORTS_DEATH_TEST
|
||||
#endif // GTEST_HAS_DEATH_TEST
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Testing ScopedAllocatorSetupFixture. Testing that detects leaks
|
||||
|
||||
+18
@@ -597,7 +597,10 @@ namespace AZ::IO
|
||||
path.InitFromAbsolutePath(m_dummyFilepath);
|
||||
|
||||
request->CreateRead(nullptr, buffer.get(), fileSize, path, 0, fileSize);
|
||||
AZ_PUSH_DISABLE_WARNING(5233, "-Wunknown-warning-option") // Older versions of MSVC toolchain require to pass constexpr in the
|
||||
// capture. Newer versions issue unused warning
|
||||
auto callback = [&fileSize, this](const FileRequest& request)
|
||||
AZ_POP_DISABLE_WARNING
|
||||
{
|
||||
EXPECT_EQ(request.GetStatus(), AZ::IO::IStreamerTypes::RequestStatus::Completed);
|
||||
auto& readRequest = AZStd::get<AZ::IO::FileRequest::ReadData>(request.GetCommand());
|
||||
@@ -639,7 +642,10 @@ namespace AZ::IO
|
||||
path.InitFromAbsolutePath(m_dummyFilepath);
|
||||
|
||||
request->CreateRead(nullptr, buffer, unalignedSize + 4, path, unalignedOffset, unalignedSize);
|
||||
AZ_PUSH_DISABLE_WARNING(5233, "-Wunknown-warning-option") // Older versions of MSVC toolchain require to pass constexpr in the
|
||||
// capture. Newer versions issue unused warning
|
||||
auto callback = [unalignedOffset, unalignedSize, this](const FileRequest& request)
|
||||
AZ_POP_DISABLE_WARNING
|
||||
{
|
||||
EXPECT_EQ(request.GetStatus(), AZ::IO::IStreamerTypes::RequestStatus::Completed);
|
||||
auto& readRequest = AZStd::get<AZ::IO::FileRequest::ReadData>(request.GetCommand());
|
||||
@@ -784,7 +790,10 @@ namespace AZ::IO
|
||||
requests[i] = m_context->GetNewInternalRequest();
|
||||
|
||||
requests[i]->CreateRead(nullptr, buffers[i].get(), chunkSize, path, i * chunkSize, chunkSize);
|
||||
AZ_PUSH_DISABLE_WARNING(5233, "-Wunknown-warning-option") // Older versions of MSVC toolchain require to pass constexpr in the
|
||||
// capture. Newer versions issue unused warning
|
||||
auto callback = [chunkSize, i](const FileRequest& request)
|
||||
AZ_POP_DISABLE_WARNING
|
||||
{
|
||||
EXPECT_EQ(request.GetStatus(), AZ::IO::IStreamerTypes::RequestStatus::Completed);
|
||||
auto& readRequest = AZStd::get<AZ::IO::FileRequest::ReadData>(request.GetCommand());
|
||||
@@ -970,7 +979,10 @@ namespace AZ::IO
|
||||
i * chunkSize
|
||||
));
|
||||
|
||||
AZ_PUSH_DISABLE_WARNING(5233, "-Wunknown-warning-option") // Older versions of MSVC toolchain require to pass constexpr in the
|
||||
// capture. Newer versions issue unused warning
|
||||
auto callback = [numChunks, &numCallbacks, &waitForReads](FileRequestHandle request)
|
||||
AZ_POP_DISABLE_WARNING
|
||||
{
|
||||
IStreamer* streamer = Interface<IStreamer>::Get();
|
||||
if (streamer)
|
||||
@@ -1038,7 +1050,10 @@ namespace AZ::IO
|
||||
i * chunkSize
|
||||
));
|
||||
|
||||
AZ_PUSH_DISABLE_WARNING(5233, "-Wunknown-warning-option") // Older versions of MSVC toolchain require to pass constexpr in the
|
||||
// capture. Newer versions issue unused warning
|
||||
auto callback = [numChunks, &waitForReads, &waitForSingleRead, &numReadCallbacks]([[maybe_unused]] FileRequestHandle request)
|
||||
AZ_POP_DISABLE_WARNING
|
||||
{
|
||||
numReadCallbacks++;
|
||||
if (numReadCallbacks == 1)
|
||||
@@ -1059,7 +1074,10 @@ namespace AZ::IO
|
||||
for (size_t i = 0; i < numChunks; ++i)
|
||||
{
|
||||
cancels.push_back(m_streamer->Cancel(requests[numChunks - i - 1]));
|
||||
AZ_PUSH_DISABLE_WARNING(5233, "-Wunknown-warning-option") // Older versions of MSVC toolchain require to pass constexpr in the
|
||||
// capture. Newer versions issue unused warning
|
||||
auto callback = [&numCancelCallbacks, &waitForCancels, numChunks](FileRequestHandle request)
|
||||
AZ_POP_DISABLE_WARNING
|
||||
{
|
||||
auto result = Interface<IStreamer>::Get()->GetRequestStatus(request);
|
||||
EXPECT_EQ(result, IStreamerTypes::RequestStatus::Completed);
|
||||
|
||||
@@ -327,7 +327,7 @@ namespace JsonSerializationTests
|
||||
SerializerWithOneType::Unreflect(m_jsonRegistrationContext.get());
|
||||
}
|
||||
|
||||
#if GTEST_OS_SUPPORTS_DEATH_TEST
|
||||
#if GTEST_HAS_DEATH_TEST
|
||||
using JsonSerializationDeathTests = JsonRegistrationContextTests;
|
||||
TEST_F(JsonSerializationDeathTests, DoubleUnregisterSerializer_Asserts)
|
||||
{
|
||||
@@ -338,5 +338,6 @@ namespace JsonSerializationTests
|
||||
}, ".*"
|
||||
);
|
||||
}
|
||||
#endif // GTEST_OS_SUPPORTS_DEATH_TEST
|
||||
#endif // GTEST_HAS_DEATH_TEST
|
||||
|
||||
} //namespace JsonSerializationTests
|
||||
|
||||
@@ -1299,6 +1299,35 @@ namespace SettingsRegistryTests
|
||||
EXPECT_FALSE(m_registry->MergeCommandLineArgument(" ", {}, {}));
|
||||
}
|
||||
|
||||
//
|
||||
// MergeSettings
|
||||
//
|
||||
TEST_F(SettingsRegistryTest, MergeSettings_MergeJsonWithAnchorKey_StoresSettingsUnderneathKey)
|
||||
{
|
||||
constexpr AZStd::string_view anchorKey = "/Anchor/Root/0";
|
||||
constexpr auto mergeFormat = AZ::SettingsRegistryInterface::Format::JsonMergePatch;
|
||||
EXPECT_TRUE(m_registry->MergeSettings(R"({ "Test": "1" })", mergeFormat, anchorKey));
|
||||
EXPECT_EQ(AZ::SettingsRegistryInterface::Type::Array, m_registry->GetType("/Anchor/Root"));
|
||||
EXPECT_EQ(AZ::SettingsRegistryInterface::Type::Object, m_registry->GetType("/Anchor/Root/0"));
|
||||
EXPECT_EQ(AZ::SettingsRegistryInterface::Type::String, m_registry->GetType("/Anchor/Root/0/Test"));
|
||||
}
|
||||
|
||||
TEST_F(SettingsRegistryTest, MergeSettings_NotifierSignals_AtAnchorKeyAndStoresMergeType)
|
||||
{
|
||||
AZStd::string_view anchorKey = "/Anchor/Root";
|
||||
bool callbackInvoked{};
|
||||
auto callback = [anchorKey, &callbackInvoked](AZStd::string_view path, AZ::SettingsRegistryInterface::Type type)
|
||||
{
|
||||
EXPECT_EQ(anchorKey, path);
|
||||
EXPECT_EQ(AZ::SettingsRegistryInterface::Type::Array, type);
|
||||
callbackInvoked = true;
|
||||
};
|
||||
auto testNotifier1 = m_registry->RegisterNotifier(callback);
|
||||
constexpr auto mergeFormat = AZ::SettingsRegistryInterface::Format::JsonMergePatch;
|
||||
EXPECT_TRUE(m_registry->MergeSettings(R"([ "Test" ])", mergeFormat, anchorKey));
|
||||
EXPECT_TRUE(callbackInvoked);
|
||||
}
|
||||
|
||||
//
|
||||
// MergeSettingsFile
|
||||
//
|
||||
@@ -1331,7 +1360,7 @@ namespace SettingsRegistryTests
|
||||
|
||||
auto callback = [this](AZStd::string_view path, AZ::SettingsRegistryInterface::Type)
|
||||
{
|
||||
EXPECT_TRUE(path.empty());
|
||||
EXPECT_EQ("/Path", path);
|
||||
AZ::s64 value = -1;
|
||||
bool result = m_registry->Get(value, "/Path/Test");
|
||||
EXPECT_TRUE(result);
|
||||
|
||||
@@ -363,7 +363,10 @@ namespace AZ
|
||||
{
|
||||
constexpr AZStd::array visitTokens = { "Hello", "World", "", "More", "", "", "Tokens" };
|
||||
size_t visitIndex{};
|
||||
AZ_PUSH_DISABLE_WARNING(5233, "-Wunknown-warning-option") // Older versions of MSVC toolchain require to pass constexpr in the
|
||||
// capture. Newer versions issue unused warning
|
||||
auto visitor = [&visitIndex, &visitTokens](AZStd::string_view token)
|
||||
AZ_POP_DISABLE_WARNING
|
||||
{
|
||||
if (visitIndex > visitTokens.size())
|
||||
{
|
||||
@@ -389,7 +392,10 @@ namespace AZ
|
||||
{
|
||||
constexpr AZStd::array visitTokens = { "Hello", "World", "", "More", "", "", "Tokens" };
|
||||
size_t visitIndex = visitTokens.size() - 1;
|
||||
AZ_PUSH_DISABLE_WARNING(5233, "-Wunknown-warning-option") // Older versions of MSVC toolchain require to pass constexpr in the
|
||||
// capture. Newer versions issue unused warning
|
||||
auto visitor = [&visitIndex, &visitTokens](AZStd::string_view token)
|
||||
AZ_POP_DISABLE_WARNING
|
||||
{
|
||||
if (visitIndex > visitTokens.size())
|
||||
{
|
||||
|
||||
@@ -72,6 +72,7 @@ set(FILES
|
||||
Debug/AssetTracking.cpp
|
||||
Debug/LocalFileEventLoggerTests.cpp
|
||||
Debug/Trace.cpp
|
||||
Debug/UnhandledExceptions.cpp
|
||||
Name/NameJsonSerializerTests.cpp
|
||||
Name/NameTests.cpp
|
||||
RTTI/TypeSafeIntegralTests.cpp
|
||||
|
||||
@@ -1924,13 +1924,11 @@ namespace AZ::IO
|
||||
ArchiveLocationPriority Archive::GetPakPriority() const
|
||||
{
|
||||
int pakPriority = aznumeric_cast<int>(ArchiveVars{}.nPriority);
|
||||
#if defined(AZ_ENABLE_TRACING)
|
||||
if (auto console = AZ::Interface<AZ::IConsole>::Get(); console != nullptr)
|
||||
{
|
||||
AZ::GetValueResult getCvarResult = console->GetCvarValue("sys_PakPriority", pakPriority);
|
||||
[[maybe_unused]] AZ::GetValueResult getCvarResult = console->GetCvarValue("sys_PakPriority", pakPriority);
|
||||
AZ_Error("Archive", getCvarResult == AZ::GetValueResult::Success, "Lookup of 'sys_PakPriority console variable failed with error %s", AZ::GetEnumString(getCvarResult));
|
||||
}
|
||||
#endif
|
||||
return static_cast<ArchiveLocationPriority>(pakPriority);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,234 +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/Math/Matrix3x3.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#include <AzCore/Math/Aabb.h>
|
||||
|
||||
#include <AzFramework/Physics/WorldBody.h>
|
||||
#include <AzFramework/Physics/ShapeConfiguration.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
class ReflectContext;
|
||||
}
|
||||
|
||||
namespace Physics
|
||||
{
|
||||
class ShapeConfiguration;
|
||||
class World;
|
||||
class Shape;
|
||||
|
||||
/// Default values used for initializing RigidBodySettings.
|
||||
/// These can be modified by Physics Implementation gems. // O3DE_DEPRECATED(LY-114472) - DefaultRigidBodyConfiguration values are not shared across modules.
|
||||
// Use RigidBodyConfiguration default values.
|
||||
struct DefaultRigidBodyConfiguration
|
||||
{
|
||||
static float m_mass;
|
||||
static bool m_computeInertiaTensor;
|
||||
static float m_linearDamping;
|
||||
static float m_angularDamping;
|
||||
static float m_sleepMinEnergy;
|
||||
static float m_maxAngularVelocity;
|
||||
};
|
||||
|
||||
enum class MassComputeFlags : AZ::u8
|
||||
{
|
||||
NONE = 0,
|
||||
|
||||
//! Flags indicating whether a certain mass property should be auto-computed or not.
|
||||
COMPUTE_MASS = 1,
|
||||
COMPUTE_INERTIA = 1 << 1,
|
||||
COMPUTE_COM = 1 << 2,
|
||||
|
||||
//! If set, non-simulated shapes will also be included in the mass properties calculation.
|
||||
INCLUDE_ALL_SHAPES = 1 << 3,
|
||||
|
||||
DEFAULT = COMPUTE_COM | COMPUTE_INERTIA | COMPUTE_MASS
|
||||
};
|
||||
|
||||
class RigidBodyConfiguration
|
||||
: public WorldBodyConfiguration
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(RigidBodyConfiguration, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(RigidBodyConfiguration, "{ACFA8900-8530-4744-AF00-AA533C868A8E}", WorldBodyConfiguration);
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
enum PropertyVisibility : AZ::u16
|
||||
{
|
||||
InitialVelocities = 1 << 0, ///< Whether the initial linear and angular velocities are visible.
|
||||
InertiaProperties = 1 << 1, ///< Whether the whole category of inertia properties (mass, compute inertia,
|
||||
///< inertia tensor etc) is visible.
|
||||
Damping = 1 << 2, ///< Whether linear and angular damping are visible.
|
||||
SleepOptions = 1 << 3, ///< Whether the sleep threshold and start asleep options are visible.
|
||||
Interpolation = 1 << 4, ///< Whether the interpolation option is visible.
|
||||
Gravity = 1 << 5, ///< Whether the effected by gravity option is visible.
|
||||
Kinematic = 1 << 6, ///< Whether the option to make the body kinematic is visible.
|
||||
ContinuousCollisionDetection = 1 << 7, ///< Whether the option to enable continuous collision detection is visible.
|
||||
MaxVelocities = 1 << 8 ///< Whether upper limits on velocities are visible.
|
||||
};
|
||||
|
||||
RigidBodyConfiguration() = default;
|
||||
RigidBodyConfiguration(const RigidBodyConfiguration& settings) = default;
|
||||
|
||||
// Visibility functions.
|
||||
AZ::Crc32 GetPropertyVisibility(PropertyVisibility property) const;
|
||||
void SetPropertyVisibility(PropertyVisibility property, bool isVisible);
|
||||
|
||||
AZ::Crc32 GetInitialVelocitiesVisibility() const;
|
||||
/// Returns whether the whole category of inertia settings (mass, inertia, center of mass offset etc) is visible.
|
||||
AZ::Crc32 GetInertiaSettingsVisibility() const;
|
||||
/// Returns whether the individual inertia tensor field is visible or is hidden because the compute inertia option is selected.
|
||||
AZ::Crc32 GetInertiaVisibility() const;
|
||||
/// Returns whether the mass field is visible or is hidden because compute mass option is selected.
|
||||
AZ::Crc32 GetMassVisibility() const;
|
||||
/// Returns whether the individual centre of mass offset field is visible or is hidden because compute CoM option is selected.
|
||||
AZ::Crc32 GetCoMVisibility() const;
|
||||
AZ::Crc32 GetDampingVisibility() const;
|
||||
AZ::Crc32 GetSleepOptionsVisibility() const;
|
||||
AZ::Crc32 GetInterpolationVisibility() const;
|
||||
AZ::Crc32 GetGravityVisibility() const;
|
||||
AZ::Crc32 GetKinematicVisibility() const;
|
||||
AZ::Crc32 GetCCDVisibility() const;
|
||||
AZ::Crc32 GetMaxVelocitiesVisibility() const;
|
||||
MassComputeFlags GetMassComputeFlags() const;
|
||||
void SetMassComputeFlags(MassComputeFlags flags);
|
||||
|
||||
bool IsCCDEnabled() const;
|
||||
|
||||
// Basic initial settings.
|
||||
AZ::Vector3 m_initialLinearVelocity = AZ::Vector3::CreateZero();
|
||||
AZ::Vector3 m_initialAngularVelocity = AZ::Vector3::CreateZero();
|
||||
AZ::Vector3 m_centerOfMassOffset = AZ::Vector3::CreateZero();
|
||||
|
||||
// Simulation parameters.
|
||||
float m_mass = DefaultRigidBodyConfiguration::m_mass;
|
||||
AZ::Matrix3x3 m_inertiaTensor = AZ::Matrix3x3::CreateIdentity();
|
||||
float m_linearDamping = DefaultRigidBodyConfiguration::m_linearDamping;
|
||||
float m_angularDamping = DefaultRigidBodyConfiguration::m_angularDamping;
|
||||
float m_sleepMinEnergy = DefaultRigidBodyConfiguration::m_sleepMinEnergy;
|
||||
float m_maxAngularVelocity = DefaultRigidBodyConfiguration::m_maxAngularVelocity;
|
||||
|
||||
// Visibility settings.
|
||||
AZ::u16 m_propertyVisibilityFlags = (std::numeric_limits<AZ::u16>::max)();
|
||||
|
||||
bool m_startAsleep = false;
|
||||
bool m_interpolateMotion = false;
|
||||
bool m_gravityEnabled = true;
|
||||
bool m_simulated = true;
|
||||
bool m_kinematic = false;
|
||||
bool m_ccdEnabled = false; ///< Whether continuous collision detection is enabled.
|
||||
float m_ccdMinAdvanceCoefficient = 0.15f; ///< Coefficient affecting how granularly time is subdivided in CCD.
|
||||
bool m_ccdFrictionEnabled = false; ///< Whether friction is applied when resolving CCD collisions.
|
||||
|
||||
bool m_computeCenterOfMass = true;
|
||||
bool m_computeInertiaTensor = true;
|
||||
bool m_computeMass = true;
|
||||
|
||||
//! If set, non-simulated shapes will also be included in the mass properties calculation.
|
||||
bool m_includeAllShapesInMassCalculation = false;
|
||||
};
|
||||
|
||||
/// Dynamic rigid body.
|
||||
class RigidBody
|
||||
: public WorldBody
|
||||
{
|
||||
public:
|
||||
|
||||
AZ_CLASS_ALLOCATOR(RigidBody, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(RigidBody, "{156E459F-7BB7-4B4E-ADA0-2130D96B7E80}", WorldBody);
|
||||
|
||||
public:
|
||||
RigidBody() = default;
|
||||
explicit RigidBody(const RigidBodyConfiguration& settings);
|
||||
|
||||
|
||||
virtual void AddShape(AZStd::shared_ptr<Shape> shape) = 0;
|
||||
virtual void RemoveShape(AZStd::shared_ptr<Shape> shape) = 0;
|
||||
virtual AZ::u32 GetShapeCount() { return 0; }
|
||||
virtual AZStd::shared_ptr<Shape> GetShape(AZ::u32 /*index*/) { return nullptr; }
|
||||
|
||||
virtual AZ::Vector3 GetCenterOfMassWorld() const = 0;
|
||||
virtual AZ::Vector3 GetCenterOfMassLocal() const = 0;
|
||||
|
||||
virtual AZ::Matrix3x3 GetInverseInertiaWorld() const = 0;
|
||||
virtual AZ::Matrix3x3 GetInverseInertiaLocal() const = 0;
|
||||
|
||||
virtual float GetMass() const = 0;
|
||||
virtual float GetInverseMass() const = 0;
|
||||
virtual void SetMass(float mass) = 0;
|
||||
virtual void SetCenterOfMassOffset(const AZ::Vector3& comOffset) = 0;
|
||||
|
||||
/// Retrieves the velocity at center of mass; only linear velocity, no rotational velocity contribution.
|
||||
virtual AZ::Vector3 GetLinearVelocity() const = 0;
|
||||
virtual void SetLinearVelocity(const AZ::Vector3& velocity) = 0;
|
||||
virtual AZ::Vector3 GetAngularVelocity() const = 0;
|
||||
virtual void SetAngularVelocity(const AZ::Vector3& angularVelocity) = 0;
|
||||
virtual AZ::Vector3 GetLinearVelocityAtWorldPoint(const AZ::Vector3& worldPoint) = 0;
|
||||
virtual void ApplyLinearImpulse(const AZ::Vector3& impulse) = 0;
|
||||
virtual void ApplyLinearImpulseAtWorldPoint(const AZ::Vector3& impulse, const AZ::Vector3& worldPoint) = 0;
|
||||
virtual void ApplyAngularImpulse(const AZ::Vector3& angularImpulse) = 0;
|
||||
|
||||
virtual float GetLinearDamping() const = 0;
|
||||
virtual void SetLinearDamping(float damping) = 0;
|
||||
virtual float GetAngularDamping() const = 0;
|
||||
virtual void SetAngularDamping(float damping) = 0;
|
||||
|
||||
virtual bool IsAwake() const = 0;
|
||||
virtual void ForceAsleep() = 0;
|
||||
virtual void ForceAwake() = 0;
|
||||
virtual float GetSleepThreshold() const = 0;
|
||||
virtual void SetSleepThreshold(float threshold) = 0;
|
||||
|
||||
virtual bool IsKinematic() const = 0;
|
||||
virtual void SetKinematic(bool kinematic) = 0;
|
||||
virtual void SetKinematicTarget(const AZ::Transform& targetPosition) = 0;
|
||||
|
||||
virtual bool IsGravityEnabled() const = 0;
|
||||
virtual void SetGravityEnabled(bool enabled) = 0;
|
||||
virtual void SetSimulationEnabled(bool enabled) = 0;
|
||||
virtual void SetCCDEnabled(bool enabled) = 0;
|
||||
|
||||
//! Recalculates mass, inertia and center of mass based on the flags passed.
|
||||
//! @param flags MassComputeFlags specifying which properties should be recomputed.
|
||||
//! @param centerOfMassOffsetOverride Optional override of the center of mass. Note: This parameter will be ignored if COMPUTE_COM is passed in flags.
|
||||
//! @param inertiaTensorOverride Optional override of the inertia. Note: This parameter will be ignored if COMPUTE_INERTIA is passed in flags.
|
||||
//! @param massOverride Optional override of the mass. Note: This parameter will be ignored if COMPUTE_MASS is passed in flags.
|
||||
virtual void UpdateMassProperties(MassComputeFlags flags = MassComputeFlags::DEFAULT,
|
||||
const AZ::Vector3* centerOfMassOffsetOverride = nullptr,
|
||||
const AZ::Matrix3x3* inertiaTensorOverride = nullptr,
|
||||
const float* massOverride = nullptr) = 0;
|
||||
};
|
||||
|
||||
/// Bitwise operators for MassComputeFlags
|
||||
inline MassComputeFlags operator|(MassComputeFlags lhs, MassComputeFlags rhs)
|
||||
{
|
||||
return aznumeric_cast<MassComputeFlags>(aznumeric_cast<AZ::u8>(lhs) | aznumeric_cast<AZ::u8>(rhs));
|
||||
}
|
||||
|
||||
inline MassComputeFlags operator&(MassComputeFlags lhs, MassComputeFlags rhs)
|
||||
{
|
||||
return aznumeric_cast<MassComputeFlags>(aznumeric_cast<AZ::u8>(lhs) & aznumeric_cast<AZ::u8>(rhs));
|
||||
}
|
||||
|
||||
/// Static rigid body.
|
||||
class RigidBodyStatic
|
||||
: public WorldBody
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(RigidBodyStatic, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(RigidBodyStatic, "{13A677BB-7085-4EDB-BCC8-306548238692}", WorldBody);
|
||||
|
||||
virtual void AddShape(const AZStd::shared_ptr<Shape>& shape) = 0;
|
||||
virtual AZ::u32 GetShapeCount() { return 0; }
|
||||
virtual AZStd::shared_ptr<Shape> GetShape(AZ::u32 /*index*/) { return nullptr; }
|
||||
};
|
||||
} // namespace Physics
|
||||
@@ -89,9 +89,9 @@ namespace AzPhysics
|
||||
//! @param inertiaTensorOverride Optional override of the inertia. Note: This parameter will be ignored if COMPUTE_INERTIA is passed in flags.
|
||||
//! @param massOverride Optional override of the mass. Note: This parameter will be ignored if COMPUTE_MASS is passed in flags.
|
||||
virtual void UpdateMassProperties(MassComputeFlags flags = MassComputeFlags::DEFAULT,
|
||||
const AZ::Vector3* centerOfMassOffsetOverride = nullptr,
|
||||
const AZ::Matrix3x3* inertiaTensorOverride = nullptr,
|
||||
const float* massOverride = nullptr) = 0;
|
||||
const AZ::Vector3& centerOfMassOffsetOverride = AZ::Vector3::CreateZero(),
|
||||
const AZ::Matrix3x3& inertiaTensorOverride = AZ::Matrix3x3::CreateIdentity(),
|
||||
const float massOverride = 1.0f) = 0;
|
||||
};
|
||||
|
||||
} // namespace AzPhysics
|
||||
|
||||
@@ -30,22 +30,42 @@ namespace AzFramework
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// OnSessionHealthCheck is fired in health check process
|
||||
// @return The result of all OnSessionHealthCheck
|
||||
// Use this notification to perform any custom health check
|
||||
// @return True if OnSessionHealthCheck succeeds, false otherwise
|
||||
virtual bool OnSessionHealthCheck() = 0;
|
||||
|
||||
// OnCreateSessionBegin is fired at the beginning of session creation
|
||||
// OnCreateSessionBegin is fired at the beginning of session creation process
|
||||
// Use this notification to perform any necessary configuration or initialization before
|
||||
// creating session
|
||||
// @param sessionConfig The properties to describe a session
|
||||
// @return The result of all OnCreateSessionBegin notifications
|
||||
// @return True if OnCreateSessionBegin succeeds, false otherwise
|
||||
virtual bool OnCreateSessionBegin(const SessionConfig& sessionConfig) = 0;
|
||||
|
||||
// OnDestroySessionBegin is fired at the beginning of session termination
|
||||
// @return The result of all OnDestroySessionBegin notifications
|
||||
// OnCreateSessionEnd is fired at the end of session creation process
|
||||
// Use this notification to perform any follow-up operation after session is created and active
|
||||
virtual void OnCreateSessionEnd() = 0;
|
||||
|
||||
// OnDestroySessionBegin is fired at the beginning of session termination process
|
||||
// Use this notification to perform any cleanup operation before destroying session,
|
||||
// like gracefully disconnect players, cleanup data, etc.
|
||||
// @return True if OnDestroySessionBegin succeeds, false otherwise
|
||||
virtual bool OnDestroySessionBegin() = 0;
|
||||
|
||||
// OnUpdateSessionBegin is fired at the beginning of session update
|
||||
// OnDestroySessionEnd is fired at the end of session termination process
|
||||
// Use this notification to perform any follow-up operation after session is destroyed,
|
||||
// like shutdown application process, etc.
|
||||
virtual void OnDestroySessionEnd() = 0;
|
||||
|
||||
// OnUpdateSessionBegin is fired at the beginning of session update process
|
||||
// Use this notification to perform any configuration or initialization to handle
|
||||
// the session settings changing
|
||||
// @param sessionConfig The properties to describe a session
|
||||
// @param updateReason The reason for session update
|
||||
virtual void OnUpdateSessionBegin(const SessionConfig& sessionConfig, const AZStd::string& updateReason) = 0;
|
||||
|
||||
// OnUpdateSessionBegin is fired at the end of session update process
|
||||
// Use this notification to perform any follow-up operations after session is updated
|
||||
virtual void OnUpdateSessionEnd() = 0;
|
||||
};
|
||||
using SessionNotificationBus = AZ::EBus<SessionNotifications>;
|
||||
} // namespace AzFramework
|
||||
|
||||
@@ -23,10 +23,12 @@ namespace AzFramework
|
||||
virtual ~XcbEventHandler() = default;
|
||||
|
||||
virtual void HandleXcbEvent(xcb_generic_event_t* event) = 0;
|
||||
|
||||
// ATTN This is used as a workaround for RAW Input events when using the Editor.
|
||||
virtual void PollSpecialEvents(){};
|
||||
};
|
||||
|
||||
class XcbEventHandlerBusTraits
|
||||
: public AZ::EBusTraits
|
||||
class XcbEventHandlerBusTraits : public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -0,0 +1,652 @@
|
||||
/*
|
||||
* 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 <AzCore/std/typetraits/integral_constant.h>
|
||||
#include <AzFramework/API/ApplicationAPI_Linux.h>
|
||||
#include <AzFramework/XcbConnectionManager.h>
|
||||
#include <AzFramework/XcbInputDeviceMouse.h>
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
xcb_window_t GetSystemCursorFocusWindow()
|
||||
{
|
||||
void* systemCursorFocusWindow = nullptr;
|
||||
AzFramework::InputSystemCursorConstraintRequestBus::BroadcastResult(
|
||||
systemCursorFocusWindow, &AzFramework::InputSystemCursorConstraintRequests::GetSystemCursorConstraintWindow);
|
||||
|
||||
if (!systemCursorFocusWindow)
|
||||
{
|
||||
return XCB_NONE;
|
||||
}
|
||||
|
||||
// TODO Clang compile error because cast .... loses information. On GNU/Linux HWND is void* and on 64-bit
|
||||
// machines its obviously 64 bit but we receive the window id from m_renderOverlay.winId() which is xcb_window_t 32-bit.
|
||||
|
||||
return static_cast<xcb_window_t>(reinterpret_cast<uint64_t>(systemCursorFocusWindow));
|
||||
}
|
||||
|
||||
xcb_connection_t* XcbInputDeviceMouse::s_xcbConnection = nullptr;
|
||||
xcb_screen_t* XcbInputDeviceMouse::s_xcbScreen = nullptr;
|
||||
bool XcbInputDeviceMouse::m_xfixesInitialized = false;
|
||||
bool XcbInputDeviceMouse::m_xInputInitialized = false;
|
||||
|
||||
XcbInputDeviceMouse::XcbInputDeviceMouse(InputDeviceMouse& inputDevice)
|
||||
: InputDeviceMouse::Implementation(inputDevice)
|
||||
, m_systemCursorState(SystemCursorState::Unknown)
|
||||
, m_systemCursorPositionNormalized(0.5f, 0.5f)
|
||||
, m_prevConstraintWindow(XCB_NONE)
|
||||
, m_focusWindow(XCB_NONE)
|
||||
, m_cursorShown(true)
|
||||
{
|
||||
XcbEventHandlerBus::Handler::BusConnect();
|
||||
|
||||
SetSystemCursorState(SystemCursorState::Unknown);
|
||||
}
|
||||
|
||||
XcbInputDeviceMouse::~XcbInputDeviceMouse()
|
||||
{
|
||||
XcbEventHandlerBus::Handler::BusDisconnect();
|
||||
|
||||
SetSystemCursorState(SystemCursorState::Unknown);
|
||||
}
|
||||
|
||||
InputDeviceMouse::Implementation* XcbInputDeviceMouse::Create(InputDeviceMouse& inputDevice)
|
||||
{
|
||||
auto* interface = AzFramework::XcbConnectionManagerInterface::Get();
|
||||
if (!interface)
|
||||
{
|
||||
AZ_Warning("XcbInput", false, "XCB interface not available");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
s_xcbConnection = AzFramework::XcbConnectionManagerInterface::Get()->GetXcbConnection();
|
||||
if (!s_xcbConnection)
|
||||
{
|
||||
AZ_Warning("XcbInput", false, "XCB connection not available");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const xcb_setup_t* xcbSetup = xcb_get_setup(s_xcbConnection);
|
||||
s_xcbScreen = xcb_setup_roots_iterator(xcbSetup).data;
|
||||
if (!s_xcbScreen)
|
||||
{
|
||||
AZ_Warning("XcbInput", false, "XCB screen not available");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Initialize XFixes extension which we use to create pointer barriers.
|
||||
if (!InitializeXFixes())
|
||||
{
|
||||
AZ_Warning("XcbInput", false, "XCB XFixes initialization failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Initialize XInput extension which is used to get RAW Input events.
|
||||
if (!InitializeXInput())
|
||||
{
|
||||
AZ_Warning("XcbInput", false, "XCB XInput initialization failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return aznew XcbInputDeviceMouse(inputDevice);
|
||||
}
|
||||
|
||||
bool XcbInputDeviceMouse::IsConnected() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void XcbInputDeviceMouse::CreateBarriers(xcb_window_t window, bool create)
|
||||
{
|
||||
// Don't create any barriers if we are debugging. This will cause artifacts but better then
|
||||
// a confined cursor during debugging.
|
||||
if (AZ::Debug::Trace::IsDebuggerPresent())
|
||||
{
|
||||
AZ_Warning("XcbInput", false, "Debugger running. Barriers will not be created.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (create)
|
||||
{
|
||||
// Destroy barriers if they are active already.
|
||||
if (!m_activeBarriers.empty())
|
||||
{
|
||||
for (const auto& barrier : m_activeBarriers)
|
||||
{
|
||||
xcb_xfixes_delete_pointer_barrier_checked(s_xcbConnection, barrier.id);
|
||||
}
|
||||
|
||||
m_activeBarriers.clear();
|
||||
}
|
||||
|
||||
// Get window information.
|
||||
const XcbStdFreePtr<xcb_get_geometry_reply_t> xcbGeometryReply{ xcb_get_geometry_reply(
|
||||
s_xcbConnection, xcb_get_geometry(s_xcbConnection, window), NULL) };
|
||||
|
||||
if (!xcbGeometryReply)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const xcb_translate_coordinates_cookie_t translate_coord =
|
||||
xcb_translate_coordinates(s_xcbConnection, window, s_xcbScreen->root, 0, 0);
|
||||
|
||||
const XcbStdFreePtr<xcb_translate_coordinates_reply_t> xkbTranslateCoordReply{ xcb_translate_coordinates_reply(
|
||||
s_xcbConnection, translate_coord, NULL) };
|
||||
|
||||
if (!xkbTranslateCoordReply)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const int16_t x0 = xkbTranslateCoordReply->dst_x < 0 ? 0 : xkbTranslateCoordReply->dst_x;
|
||||
const int16_t y0 = xkbTranslateCoordReply->dst_y < 0 ? 0 : xkbTranslateCoordReply->dst_y;
|
||||
const int16_t x1 = xkbTranslateCoordReply->dst_x + xcbGeometryReply->width;
|
||||
const int16_t y1 = xkbTranslateCoordReply->dst_y + xcbGeometryReply->height;
|
||||
|
||||
// ATTN For whatever reason, when making an exact rectangle the pointer will escape the top right corner in some cases. Adding
|
||||
// an offset to the lines so that they cross each other prevents that.
|
||||
const int16_t offset = 30;
|
||||
|
||||
// Create the left barrier info.
|
||||
m_activeBarriers.push_back({ xcb_generate_id(s_xcbConnection), XCB_XFIXES_BARRIER_DIRECTIONS_POSITIVE_X, x0, Clamp(y0 - offset),
|
||||
x0, Clamp(y1 + offset) });
|
||||
|
||||
// Create the right barrier info.
|
||||
m_activeBarriers.push_back({ xcb_generate_id(s_xcbConnection), XCB_XFIXES_BARRIER_DIRECTIONS_NEGATIVE_X, x1, Clamp(y0 - offset),
|
||||
x1, Clamp(y1 + offset) });
|
||||
|
||||
// Create the top barrier info.
|
||||
m_activeBarriers.push_back({ xcb_generate_id(s_xcbConnection), XCB_XFIXES_BARRIER_DIRECTIONS_POSITIVE_Y, Clamp(x0 - offset), y0,
|
||||
Clamp(x1 + offset), y0 });
|
||||
|
||||
// Create the bottom barrier info.
|
||||
m_activeBarriers.push_back({ xcb_generate_id(s_xcbConnection), XCB_XFIXES_BARRIER_DIRECTIONS_NEGATIVE_Y, Clamp(x0 - offset), y1,
|
||||
Clamp(x1 + offset), y1 });
|
||||
|
||||
// Create the xfixes barriers.
|
||||
for (const auto& barrier : m_activeBarriers)
|
||||
{
|
||||
xcb_void_cookie_t cookie = xcb_xfixes_create_pointer_barrier_checked(
|
||||
s_xcbConnection, barrier.id, window, barrier.x0, barrier.y0, barrier.x1, barrier.y1, barrier.direction, 0, NULL);
|
||||
const XcbStdFreePtr<xcb_generic_error_t> xkbError{ xcb_request_check(s_xcbConnection, cookie) };
|
||||
|
||||
AZ_Warning(
|
||||
"XcbInput", !xkbError, "XFixes, failed to create barrier %d at (%d %d %d %d)", barrier.id, barrier.x0, barrier.y0,
|
||||
barrier.x1, barrier.y1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const auto& barrier : m_activeBarriers)
|
||||
{
|
||||
xcb_xfixes_delete_pointer_barrier_checked(s_xcbConnection, barrier.id);
|
||||
}
|
||||
|
||||
m_activeBarriers.clear();
|
||||
}
|
||||
|
||||
xcb_flush(s_xcbConnection);
|
||||
}
|
||||
|
||||
bool XcbInputDeviceMouse::InitializeXFixes()
|
||||
{
|
||||
m_xfixesInitialized = false;
|
||||
|
||||
// We don't have to free query_extension_reply according to xcb documentation.
|
||||
const xcb_query_extension_reply_t* query_extension_reply = xcb_get_extension_data(s_xcbConnection, &xcb_xfixes_id);
|
||||
if (!query_extension_reply || !query_extension_reply->present)
|
||||
{
|
||||
return m_xfixesInitialized;
|
||||
}
|
||||
|
||||
const xcb_xfixes_query_version_cookie_t query_cookie = xcb_xfixes_query_version(s_xcbConnection, 5, 0);
|
||||
|
||||
xcb_generic_error_t* error = NULL;
|
||||
const XcbStdFreePtr<xcb_xfixes_query_version_reply_t> xkbQueryRequestReply{ xcb_xfixes_query_version_reply(
|
||||
s_xcbConnection, query_cookie, &error) };
|
||||
|
||||
if (!xkbQueryRequestReply || error)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
AZ_Warning("XcbInput", false, "Retrieving XFixes version failed : Error code %d", error->error_code);
|
||||
free(error);
|
||||
}
|
||||
return m_xfixesInitialized;
|
||||
}
|
||||
else if (xkbQueryRequestReply->major_version < 5)
|
||||
{
|
||||
AZ_Warning("XcbInput", false, "XFixes version fails the minimum version check (%d<5)", xkbQueryRequestReply->major_version);
|
||||
return m_xfixesInitialized;
|
||||
}
|
||||
|
||||
m_xfixesInitialized = true;
|
||||
|
||||
return m_xfixesInitialized;
|
||||
}
|
||||
|
||||
bool XcbInputDeviceMouse::InitializeXInput()
|
||||
{
|
||||
m_xInputInitialized = false;
|
||||
|
||||
// We don't have to free query_extension_reply according to xcb documentation.
|
||||
const xcb_query_extension_reply_t* query_extension_reply = xcb_get_extension_data(s_xcbConnection, &xcb_input_id);
|
||||
if (!query_extension_reply || !query_extension_reply->present)
|
||||
{
|
||||
return m_xInputInitialized;
|
||||
}
|
||||
|
||||
const xcb_input_xi_query_version_cookie_t query_version_cookie = xcb_input_xi_query_version(s_xcbConnection, 2, 2);
|
||||
|
||||
xcb_generic_error_t* error = NULL;
|
||||
const XcbStdFreePtr<xcb_input_xi_query_version_reply_t> xkbQueryRequestReply{ xcb_input_xi_query_version_reply(
|
||||
s_xcbConnection, query_version_cookie, &error) };
|
||||
|
||||
if (!xkbQueryRequestReply || error)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
AZ_Warning("XcbInput", false, "Retrieving XInput version failed : Error code %d", error->error_code);
|
||||
free(error);
|
||||
}
|
||||
return m_xInputInitialized;
|
||||
}
|
||||
else if (xkbQueryRequestReply->major_version < 2)
|
||||
{
|
||||
AZ_Warning("XcbInput", false, "XInput version fails the minimum version check (%d<5)", xkbQueryRequestReply->major_version);
|
||||
return m_xInputInitialized;
|
||||
}
|
||||
|
||||
m_xInputInitialized = true;
|
||||
|
||||
return m_xInputInitialized;
|
||||
}
|
||||
|
||||
void XcbInputDeviceMouse::SetEnableXInput(bool enable)
|
||||
{
|
||||
struct
|
||||
{
|
||||
xcb_input_event_mask_t head;
|
||||
int mask;
|
||||
} mask;
|
||||
|
||||
mask.head.deviceid = XCB_INPUT_DEVICE_ALL;
|
||||
mask.head.mask_len = 1;
|
||||
|
||||
if (enable)
|
||||
{
|
||||
mask.mask = XCB_INPUT_XI_EVENT_MASK_RAW_MOTION | XCB_INPUT_XI_EVENT_MASK_RAW_BUTTON_PRESS |
|
||||
XCB_INPUT_XI_EVENT_MASK_RAW_BUTTON_RELEASE | XCB_INPUT_XI_EVENT_MASK_MOTION | XCB_INPUT_XI_EVENT_MASK_BUTTON_PRESS |
|
||||
XCB_INPUT_XI_EVENT_MASK_BUTTON_RELEASE;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask.mask = XCB_NONE;
|
||||
}
|
||||
|
||||
xcb_input_xi_select_events(s_xcbConnection, s_xcbScreen->root, 1, &mask.head);
|
||||
|
||||
xcb_flush(s_xcbConnection);
|
||||
}
|
||||
|
||||
void XcbInputDeviceMouse::SetSystemCursorState(SystemCursorState systemCursorState)
|
||||
{
|
||||
if (systemCursorState != m_systemCursorState)
|
||||
{
|
||||
m_systemCursorState = systemCursorState;
|
||||
|
||||
m_focusWindow = GetSystemCursorFocusWindow();
|
||||
|
||||
HandleCursorState(m_focusWindow, systemCursorState);
|
||||
}
|
||||
}
|
||||
|
||||
void XcbInputDeviceMouse::HandleCursorState(xcb_window_t window, SystemCursorState systemCursorState)
|
||||
{
|
||||
bool confined = false, cursorShown = true;
|
||||
switch (systemCursorState)
|
||||
{
|
||||
case SystemCursorState::ConstrainedAndHidden:
|
||||
{
|
||||
//!< Constrained to the application's main window and hidden
|
||||
confined = true;
|
||||
cursorShown = false;
|
||||
}
|
||||
break;
|
||||
case SystemCursorState::ConstrainedAndVisible:
|
||||
{
|
||||
//!< Constrained to the application's main window and visible
|
||||
confined = true;
|
||||
}
|
||||
break;
|
||||
case SystemCursorState::UnconstrainedAndHidden:
|
||||
{
|
||||
//!< Free to move outside the main window but hidden while inside
|
||||
cursorShown = false;
|
||||
}
|
||||
break;
|
||||
case SystemCursorState::UnconstrainedAndVisible:
|
||||
{
|
||||
//!< Free to move outside the application's main window and visible
|
||||
}
|
||||
case SystemCursorState::Unknown:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// ATTN GetSystemCursorFocusWindow when getting out of the play in editor will return XCB_NONE
|
||||
// We need however the window id to reset the cursor.
|
||||
if (XCB_NONE == window && (confined || cursorShown))
|
||||
{
|
||||
// Reuse the previous window to reset states.
|
||||
window = m_prevConstraintWindow;
|
||||
m_prevConstraintWindow = XCB_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remember the window we used to modify cursor and barrier states.
|
||||
m_prevConstraintWindow = window;
|
||||
}
|
||||
|
||||
SetEnableXInput(!cursorShown);
|
||||
|
||||
CreateBarriers(window, confined);
|
||||
ShowCursor(window, cursorShown);
|
||||
}
|
||||
|
||||
SystemCursorState XcbInputDeviceMouse::GetSystemCursorState() const
|
||||
{
|
||||
return m_systemCursorState;
|
||||
}
|
||||
|
||||
void XcbInputDeviceMouse::SetSystemCursorPositionNormalizedInternal(xcb_window_t window, AZ::Vector2 positionNormalized)
|
||||
{
|
||||
// TODO Basically not done at all. Added only the basic functions needed.
|
||||
const XcbStdFreePtr<xcb_get_geometry_reply_t> xkbGeometryReply{ xcb_get_geometry_reply(
|
||||
s_xcbConnection, xcb_get_geometry(s_xcbConnection, window), NULL) };
|
||||
|
||||
if (!xkbGeometryReply)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const int16_t x = static_cast<int16_t>(positionNormalized.GetX() * xkbGeometryReply->width);
|
||||
const int16_t y = static_cast<int16_t>(positionNormalized.GetY() * xkbGeometryReply->height);
|
||||
|
||||
xcb_warp_pointer(s_xcbConnection, XCB_NONE, window, 0, 0, 0, 0, x, y);
|
||||
|
||||
xcb_flush(s_xcbConnection);
|
||||
}
|
||||
|
||||
void XcbInputDeviceMouse::SetSystemCursorPositionNormalized(AZ::Vector2 positionNormalized)
|
||||
{
|
||||
const xcb_window_t window = GetSystemCursorFocusWindow();
|
||||
if (XCB_NONE == window)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SetSystemCursorPositionNormalizedInternal(window, positionNormalized);
|
||||
}
|
||||
|
||||
AZ::Vector2 XcbInputDeviceMouse::GetSystemCursorPositionNormalizedInternal(xcb_window_t window) const
|
||||
{
|
||||
AZ::Vector2 position = AZ::Vector2::CreateZero();
|
||||
|
||||
const xcb_query_pointer_cookie_t pointer = xcb_query_pointer(s_xcbConnection, window);
|
||||
|
||||
const XcbStdFreePtr<xcb_query_pointer_reply_t> xkbQueryPointerReply{ xcb_query_pointer_reply(s_xcbConnection, pointer, NULL) };
|
||||
|
||||
if (!xkbQueryPointerReply)
|
||||
{
|
||||
return position;
|
||||
}
|
||||
|
||||
const XcbStdFreePtr<xcb_get_geometry_reply_t> xkbGeometryReply{ xcb_get_geometry_reply(
|
||||
s_xcbConnection, xcb_get_geometry(s_xcbConnection, window), NULL) };
|
||||
|
||||
if (!xkbGeometryReply)
|
||||
{
|
||||
return position;
|
||||
}
|
||||
|
||||
AZ_Assert(xkbGeometryReply->width != 0, "xkbGeometry response width must be non-zero. (%d)", xkbGeometryReply->width);
|
||||
const float normalizedCursorPostionX = static_cast<float>(xkbQueryPointerReply->win_x) / xkbGeometryReply->width;
|
||||
|
||||
AZ_Assert(xkbGeometryReply->height != 0, "xkbGeometry response height must be non-zero. (%d)", xkbGeometryReply->height);
|
||||
const float normalizedCursorPostionY = static_cast<float>(xkbQueryPointerReply->win_y) / xkbGeometryReply->height;
|
||||
|
||||
position = AZ::Vector2(normalizedCursorPostionX, normalizedCursorPostionY);
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
AZ::Vector2 XcbInputDeviceMouse::GetSystemCursorPositionNormalized() const
|
||||
{
|
||||
const xcb_window_t window = GetSystemCursorFocusWindow();
|
||||
if (XCB_NONE == window)
|
||||
{
|
||||
return AZ::Vector2::CreateZero();
|
||||
}
|
||||
|
||||
return GetSystemCursorPositionNormalizedInternal(window);
|
||||
}
|
||||
|
||||
void XcbInputDeviceMouse::TickInputDevice()
|
||||
{
|
||||
ProcessRawEventQueues();
|
||||
}
|
||||
|
||||
void XcbInputDeviceMouse::ShowCursor(xcb_window_t window, bool show)
|
||||
{
|
||||
xcb_void_cookie_t cookie;
|
||||
if (show)
|
||||
{
|
||||
cookie = xcb_xfixes_show_cursor_checked(s_xcbConnection, window);
|
||||
}
|
||||
else
|
||||
{
|
||||
cookie = xcb_xfixes_hide_cursor_checked(s_xcbConnection, window);
|
||||
}
|
||||
|
||||
const XcbStdFreePtr<xcb_generic_error_t> xkbError{ xcb_request_check(s_xcbConnection, cookie) };
|
||||
|
||||
if (xkbError)
|
||||
{
|
||||
AZ_Warning("XcbInput", false, "ShowCursor failed: %d", xkbError->error_code);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// ATTN In the following part we will when cursor gets hidden store the position of the cursor in screen space
|
||||
// not window space. We use that to re-position when showing the cursor again. Is this the correct
|
||||
// behavior?
|
||||
|
||||
const bool cursorWasHidden = !m_cursorShown;
|
||||
m_cursorShown = show;
|
||||
if (!m_cursorShown)
|
||||
{
|
||||
m_cursorHiddenPosition = GetSystemCursorPositionNormalizedInternal(s_xcbScreen->root);
|
||||
|
||||
SetSystemCursorPositionNormalized(AZ::Vector2(0.5f, 0.5f));
|
||||
}
|
||||
else if (cursorWasHidden)
|
||||
{
|
||||
SetSystemCursorPositionNormalizedInternal(s_xcbScreen->root, m_cursorHiddenPosition);
|
||||
}
|
||||
|
||||
xcb_flush(s_xcbConnection);
|
||||
}
|
||||
|
||||
void XcbInputDeviceMouse::HandleButtonPressEvents(uint32_t detail, bool pressed)
|
||||
{
|
||||
bool isWheel;
|
||||
float wheelDirection;
|
||||
const auto* button = InputChannelFromMouseEvent(detail, isWheel, wheelDirection);
|
||||
if (button)
|
||||
{
|
||||
QueueRawButtonEvent(*button, pressed);
|
||||
}
|
||||
if (isWheel)
|
||||
{
|
||||
float axisValue = MAX_XI_WHEEL_SENSITIVITY * wheelDirection;
|
||||
QueueRawMovementEvent(InputDeviceMouse::Movement::Z, axisValue);
|
||||
}
|
||||
}
|
||||
|
||||
void XcbInputDeviceMouse::HandlePointerMotionEvents(const xcb_generic_event_t* event)
|
||||
{
|
||||
const xcb_input_motion_event_t* mouseMotionEvent = reinterpret_cast<const xcb_input_motion_event_t*>(event);
|
||||
|
||||
m_systemCursorPosition[0] = mouseMotionEvent->event_x;
|
||||
m_systemCursorPosition[1] = mouseMotionEvent->event_y;
|
||||
}
|
||||
|
||||
void XcbInputDeviceMouse::HandleRawInputEvents(const xcb_ge_generic_event_t* event)
|
||||
{
|
||||
const xcb_ge_generic_event_t* genericEvent = reinterpret_cast<const xcb_ge_generic_event_t*>(event);
|
||||
switch (genericEvent->event_type)
|
||||
{
|
||||
case XCB_INPUT_RAW_BUTTON_PRESS:
|
||||
{
|
||||
const xcb_input_raw_button_press_event_t* mouseButtonEvent =
|
||||
reinterpret_cast<const xcb_input_raw_button_press_event_t*>(event);
|
||||
HandleButtonPressEvents(mouseButtonEvent->detail, true);
|
||||
}
|
||||
break;
|
||||
case XCB_INPUT_RAW_BUTTON_RELEASE:
|
||||
{
|
||||
const xcb_input_raw_button_release_event_t* mouseButtonEvent =
|
||||
reinterpret_cast<const xcb_input_raw_button_release_event_t*>(event);
|
||||
HandleButtonPressEvents(mouseButtonEvent->detail, false);
|
||||
}
|
||||
break;
|
||||
case XCB_INPUT_RAW_MOTION:
|
||||
{
|
||||
const xcb_input_raw_motion_event_t* mouseMotionEvent = reinterpret_cast<const xcb_input_raw_motion_event_t*>(event);
|
||||
|
||||
int axisLen = xcb_input_raw_button_press_axisvalues_length(mouseMotionEvent);
|
||||
const xcb_input_fp3232_t* axisvalues = xcb_input_raw_button_press_axisvalues_raw(mouseMotionEvent);
|
||||
for (int i = 0; i < axisLen; ++i)
|
||||
{
|
||||
const float axisValue = fp3232ToFloat(axisvalues[i]);
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
QueueRawMovementEvent(InputDeviceMouse::Movement::X, axisValue);
|
||||
break;
|
||||
case 1:
|
||||
QueueRawMovementEvent(InputDeviceMouse::Movement::Y, axisValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void XcbInputDeviceMouse::PollSpecialEvents()
|
||||
{
|
||||
while (xcb_generic_event_t* genericEvent = xcb_poll_for_queued_event(s_xcbConnection))
|
||||
{
|
||||
// TODO Is the following correct? If we are showing the cursor, don't poll RAW Input events.
|
||||
switch (genericEvent->response_type & ~0x80)
|
||||
{
|
||||
case XCB_GE_GENERIC:
|
||||
{
|
||||
const xcb_ge_generic_event_t* geGenericEvent = reinterpret_cast<const xcb_ge_generic_event_t*>(genericEvent);
|
||||
|
||||
// Only handle raw inputs if we have focus.
|
||||
// Handle Raw Input events first.
|
||||
if ((geGenericEvent->event_type == XCB_INPUT_RAW_BUTTON_PRESS) ||
|
||||
(geGenericEvent->event_type == XCB_INPUT_RAW_BUTTON_RELEASE) ||
|
||||
(geGenericEvent->event_type == XCB_INPUT_RAW_MOTION))
|
||||
{
|
||||
HandleRawInputEvents(geGenericEvent);
|
||||
|
||||
free(genericEvent);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void XcbInputDeviceMouse::HandleXcbEvent(xcb_generic_event_t* event)
|
||||
{
|
||||
switch (event->response_type & ~0x80)
|
||||
{
|
||||
// QT5 is using by default XInput which means we do need to check for XCB_GE_GENERIC event to parse all mouse related events.
|
||||
case XCB_GE_GENERIC:
|
||||
{
|
||||
const xcb_ge_generic_event_t* genericEvent = reinterpret_cast<const xcb_ge_generic_event_t*>(event);
|
||||
|
||||
// Handling RAW Inputs here works in GameMode but not in Editor mode because QT is
|
||||
// not handling RAW input events and passing to.
|
||||
if (!m_cursorShown)
|
||||
{
|
||||
// Handle Raw Input events first.
|
||||
if ((genericEvent->event_type == XCB_INPUT_RAW_BUTTON_PRESS) ||
|
||||
(genericEvent->event_type == XCB_INPUT_RAW_BUTTON_RELEASE) || (genericEvent->event_type == XCB_INPUT_RAW_MOTION))
|
||||
{
|
||||
HandleRawInputEvents(genericEvent);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (genericEvent->event_type)
|
||||
{
|
||||
case XCB_INPUT_BUTTON_PRESS:
|
||||
{
|
||||
const xcb_input_button_press_event_t* mouseButtonEvent =
|
||||
reinterpret_cast<const xcb_input_button_press_event_t*>(genericEvent);
|
||||
HandleButtonPressEvents(mouseButtonEvent->detail, true);
|
||||
}
|
||||
break;
|
||||
case XCB_INPUT_BUTTON_RELEASE:
|
||||
{
|
||||
const xcb_input_button_release_event_t* mouseButtonEvent =
|
||||
reinterpret_cast<const xcb_input_button_release_event_t*>(genericEvent);
|
||||
HandleButtonPressEvents(mouseButtonEvent->detail, false);
|
||||
}
|
||||
break;
|
||||
case XCB_INPUT_MOTION:
|
||||
{
|
||||
HandlePointerMotionEvents(event);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XCB_FOCUS_IN:
|
||||
{
|
||||
const xcb_focus_in_event_t* focusInEvent = reinterpret_cast<const xcb_focus_in_event_t*>(event);
|
||||
if (m_focusWindow != focusInEvent->event)
|
||||
{
|
||||
m_focusWindow = focusInEvent->event;
|
||||
HandleCursorState(m_focusWindow, m_systemCursorState);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XCB_FOCUS_OUT:
|
||||
{
|
||||
const xcb_focus_out_event_t* focusOutEvent = reinterpret_cast<const xcb_focus_out_event_t*>(event);
|
||||
HandleCursorState(focusOutEvent->event, SystemCursorState::UnconstrainedAndVisible);
|
||||
|
||||
ProcessRawEventQueues();
|
||||
ResetInputChannelStates();
|
||||
|
||||
m_focusWindow = XCB_NONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // namespace AzFramework
|
||||
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* 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 <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h>
|
||||
#include <AzFramework/XcbConnectionManager.h>
|
||||
#include <AzFramework/XcbEventHandler.h>
|
||||
#include <AzFramework/XcbInterface.h>
|
||||
|
||||
#include <xcb/xfixes.h>
|
||||
#include <xcb/xinput.h>
|
||||
|
||||
// The maximum number of raw input axis this mouse device supports.
|
||||
constexpr uint32_t MAX_XI_RAW_AXIS = 2;
|
||||
|
||||
// The sensitivity of the wheel.
|
||||
constexpr float MAX_XI_WHEEL_SENSITIVITY = 140.0f;
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
class XcbInputDeviceMouse
|
||||
: public InputDeviceMouse::Implementation
|
||||
, public XcbEventHandlerBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(XcbInputDeviceMouse, AZ::SystemAllocator, 0);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//! Constructor
|
||||
//! \param[in] inputDevice Reference to the input device being implemented
|
||||
XcbInputDeviceMouse(InputDeviceMouse& inputDevice);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//! Destructor
|
||||
virtual ~XcbInputDeviceMouse();
|
||||
|
||||
static XcbInputDeviceMouse::Implementation* Create(InputDeviceMouse& inputDevice);
|
||||
|
||||
protected:
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//! \ref AzFramework::InputDeviceMouse::Implementation::IsConnected
|
||||
bool IsConnected() const override;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//! \ref AzFramework::InputDeviceMouse::Implementation::SetSystemCursorState
|
||||
void SetSystemCursorState(SystemCursorState systemCursorState) override;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//! \ref AzFramework::InputDeviceMouse::Implementation::GetSystemCursorState
|
||||
SystemCursorState GetSystemCursorState() const override;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//! \ref AzFramework::InputDeviceMouse::Implementation::SetSystemCursorPositionNormalized
|
||||
void SetSystemCursorPositionNormalized(AZ::Vector2 positionNormalized) override;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//! \ref AzFramework::InputDeviceMouse::Implementation::GetSystemCursorPositionNormalized
|
||||
AZ::Vector2 GetSystemCursorPositionNormalized() const override;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//! \ref AzFramework::InputDeviceMouse::Implementation::TickInputDevice
|
||||
void TickInputDevice() override;
|
||||
|
||||
//! This method is called by the Editor to accommodate some events with the Editor. Never called in Game mode.
|
||||
void PollSpecialEvents() override;
|
||||
|
||||
//! Handle X11 events.
|
||||
void HandleXcbEvent(xcb_generic_event_t* event) override;
|
||||
|
||||
//! Initialize XFixes extension. Used for barriers.
|
||||
static bool InitializeXFixes();
|
||||
|
||||
//! Initialize XInput extension. Used for raw input during confinement and showing/hiding the cursor.
|
||||
static bool InitializeXInput();
|
||||
|
||||
//! Enables/Disables XInput Raw Input events.
|
||||
void SetEnableXInput(bool enable);
|
||||
|
||||
//! Create barriers.
|
||||
void CreateBarriers(xcb_window_t window, bool create);
|
||||
|
||||
//! Helper function.
|
||||
void SystemCursorStateToLogic(SystemCursorState systemCursorState, bool& confined, bool& cursorShown);
|
||||
|
||||
//! Shows/Hides the cursor.
|
||||
void ShowCursor(xcb_window_t window, bool show);
|
||||
|
||||
//! Get the normalized cursor position. The coordinates returned are relative to the specified window.
|
||||
AZ::Vector2 GetSystemCursorPositionNormalizedInternal(xcb_window_t window) const;
|
||||
|
||||
//! Set the normalized cursor position. The normalized position will be relative to the specified window.
|
||||
void SetSystemCursorPositionNormalizedInternal(xcb_window_t window, AZ::Vector2 positionNormalized);
|
||||
|
||||
//! Handle button press/release events.
|
||||
void HandleButtonPressEvents(uint32_t detail, bool pressed);
|
||||
|
||||
//! Handle motion notify events.
|
||||
void HandlePointerMotionEvents(const xcb_generic_event_t* event);
|
||||
|
||||
//! Will set cursor states and confinement modes.
|
||||
void HandleCursorState(xcb_window_t window, SystemCursorState systemCursorState);
|
||||
|
||||
//! Will handle all raw input events.
|
||||
void HandleRawInputEvents(const xcb_ge_generic_event_t* event);
|
||||
|
||||
//! Convert XInput fp1616 to float.
|
||||
inline float fp1616ToFloat(xcb_input_fp1616_t value) const
|
||||
{
|
||||
return static_cast<float>((value >> 16) + (value & 0xffff) / 0xffff);
|
||||
}
|
||||
|
||||
//! Convert XInput fp3232 to float.
|
||||
inline float fp3232ToFloat(xcb_input_fp3232_t value) const
|
||||
{
|
||||
return static_cast<float>(value.integral) + static_cast<float>(value.frac / (float)(1ull << 32));
|
||||
}
|
||||
|
||||
const InputChannelId* InputChannelFromMouseEvent(xcb_button_t button, bool& isWheel, float& direction) const
|
||||
{
|
||||
isWheel = false;
|
||||
direction = 1.0f;
|
||||
switch (button)
|
||||
{
|
||||
case XCB_BUTTON_INDEX_1:
|
||||
return &InputDeviceMouse::Button::Left;
|
||||
case XCB_BUTTON_INDEX_2:
|
||||
return &InputDeviceMouse::Button::Right;
|
||||
case XCB_BUTTON_INDEX_3:
|
||||
return &InputDeviceMouse::Button::Middle;
|
||||
case XCB_BUTTON_INDEX_4:
|
||||
isWheel = true;
|
||||
direction = 1.0f;
|
||||
break;
|
||||
case XCB_BUTTON_INDEX_5:
|
||||
isWheel = true;
|
||||
direction = -1.0f;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Barriers work only with positive values. We clamp here to zero.
|
||||
inline int16_t Clamp(int16_t value) const
|
||||
{
|
||||
return value < 0 ? 0 : value;
|
||||
}
|
||||
|
||||
private:
|
||||
//! The current system cursor state
|
||||
SystemCursorState m_systemCursorState;
|
||||
|
||||
//! The cursor position before it got hidden.
|
||||
AZ::Vector2 m_cursorHiddenPosition;
|
||||
|
||||
AZ::Vector2 m_systemCursorPositionNormalized;
|
||||
uint32_t m_systemCursorPosition[MAX_XI_RAW_AXIS];
|
||||
|
||||
static xcb_connection_t* s_xcbConnection;
|
||||
static xcb_screen_t* s_xcbScreen;
|
||||
|
||||
//! Will be true if the xfixes extension could be initialized.
|
||||
static bool m_xfixesInitialized;
|
||||
|
||||
//! Will be true if the xinput2 extension could be initialized.
|
||||
static bool m_xInputInitialized;
|
||||
|
||||
//! The window that had focus
|
||||
xcb_window_t m_prevConstraintWindow;
|
||||
|
||||
//! The current window that has focus
|
||||
xcb_window_t m_focusWindow;
|
||||
|
||||
//! Will be true if the cursor is shown else false.
|
||||
bool m_cursorShown;
|
||||
|
||||
struct XFixesBarrierProperty
|
||||
{
|
||||
xcb_xfixes_barrier_t id;
|
||||
uint32_t direction;
|
||||
int16_t x0, y0, x1, y1;
|
||||
};
|
||||
|
||||
//! Array that holds barrier information used to confine the cursor.
|
||||
std::vector<XFixesBarrierProperty> m_activeBarriers;
|
||||
};
|
||||
} // namespace AzFramework
|
||||
@@ -8,25 +8,31 @@
|
||||
|
||||
#include <AzFramework/Application/Application.h>
|
||||
#include <AzFramework/Windowing/NativeWindow.h>
|
||||
#include <AzFramework/XcbNativeWindow.h>
|
||||
#include <AzFramework/XcbConnectionManager.h>
|
||||
#include <AzFramework/XcbInterface.h>
|
||||
#include <AzFramework/XcbNativeWindow.h>
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
[[maybe_unused]] const char XcbErrorWindow[] = "XcbNativeWindow";
|
||||
static constexpr uint8_t s_XcbFormatDataSize = 32; // Format indicator for xcb for client messages
|
||||
static constexpr uint16_t s_DefaultXcbWindowBorderWidth = 4; // The default border with in pixels if a border was specified
|
||||
static constexpr uint8_t s_XcbResponseTypeMask = 0x7f; // Mask to extract the specific event type from an xcb event
|
||||
static constexpr uint8_t s_XcbFormatDataSize = 32; // Format indicator for xcb for client messages
|
||||
static constexpr uint16_t s_DefaultXcbWindowBorderWidth = 4; // The default border with in pixels if a border was specified
|
||||
static constexpr uint8_t s_XcbResponseTypeMask = 0x7f; // Mask to extract the specific event type from an xcb event
|
||||
|
||||
#define _NET_WM_STATE_REMOVE 0l
|
||||
#define _NET_WM_STATE_ADD 1l
|
||||
#define _NET_WM_STATE_TOGGLE 2l
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
XcbNativeWindow::XcbNativeWindow()
|
||||
XcbNativeWindow::XcbNativeWindow()
|
||||
: NativeWindow::Implementation()
|
||||
, m_xcbConnection(nullptr)
|
||||
, m_xcbRootScreen(nullptr)
|
||||
, m_xcbWindow(XCB_NONE)
|
||||
{
|
||||
if (auto xcbConnectionManager = AzFramework::XcbConnectionManagerInterface::Get();
|
||||
xcbConnectionManager != nullptr)
|
||||
if (auto xcbConnectionManager = AzFramework::XcbConnectionManagerInterface::Get(); xcbConnectionManager != nullptr)
|
||||
{
|
||||
m_xcbConnection = xcbConnectionManager->GetXcbConnection();
|
||||
}
|
||||
@@ -34,89 +40,184 @@ namespace AzFramework
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
XcbNativeWindow::~XcbNativeWindow() = default;
|
||||
XcbNativeWindow::~XcbNativeWindow()
|
||||
{
|
||||
if (XCB_NONE != m_xcbWindow)
|
||||
{
|
||||
xcb_destroy_window(m_xcbConnection, m_xcbWindow);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void XcbNativeWindow::InitWindow(const AZStd::string& title,
|
||||
const WindowGeometry& geometry,
|
||||
const WindowStyleMasks& styleMasks)
|
||||
void XcbNativeWindow::InitWindow(const AZStd::string& title, const WindowGeometry& geometry, const WindowStyleMasks& styleMasks)
|
||||
{
|
||||
// Get the parent window
|
||||
// Get the parent window
|
||||
const xcb_setup_t* xcbSetup = xcb_get_setup(m_xcbConnection);
|
||||
xcb_screen_t* xcbRootScreen = xcb_setup_roots_iterator(xcbSetup).data;
|
||||
xcb_window_t xcbParentWindow = xcbRootScreen->root;
|
||||
m_xcbRootScreen = xcb_setup_roots_iterator(xcbSetup).data;
|
||||
xcb_window_t xcbParentWindow = m_xcbRootScreen->root;
|
||||
|
||||
// Create an XCB window from the connection
|
||||
m_xcbWindow = xcb_generate_id(m_xcbConnection);
|
||||
|
||||
uint16_t borderWidth = 0;
|
||||
const uint32_t mask = styleMasks.m_platformAgnosticStyleMask;
|
||||
if ((mask & WindowStyleMasks::WINDOW_STYLE_BORDERED) ||
|
||||
(mask & WindowStyleMasks::WINDOW_STYLE_RESIZEABLE))
|
||||
if ((mask & WindowStyleMasks::WINDOW_STYLE_BORDERED) || (mask & WindowStyleMasks::WINDOW_STYLE_RESIZEABLE))
|
||||
{
|
||||
borderWidth = s_DefaultXcbWindowBorderWidth;
|
||||
}
|
||||
|
||||
uint32_t eventMask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
|
||||
|
||||
const uint32_t interestedEvents =
|
||||
XCB_EVENT_MASK_STRUCTURE_NOTIFY
|
||||
| XCB_EVENT_MASK_BUTTON_PRESS
|
||||
| XCB_EVENT_MASK_BUTTON_RELEASE
|
||||
| XCB_EVENT_MASK_KEY_PRESS
|
||||
| XCB_EVENT_MASK_KEY_RELEASE
|
||||
| XCB_EVENT_MASK_POINTER_MOTION
|
||||
;
|
||||
uint32_t valueList[] = { xcbRootScreen->black_pixel,
|
||||
interestedEvents };
|
||||
|
||||
const uint32_t interestedEvents = XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
|
||||
XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE;
|
||||
uint32_t valueList[] = { m_xcbRootScreen->black_pixel, interestedEvents };
|
||||
|
||||
xcb_void_cookie_t xcbCheckResult;
|
||||
|
||||
xcbCheckResult = xcb_create_window_checked(m_xcbConnection,
|
||||
XCB_COPY_FROM_PARENT,
|
||||
m_xcbWindow,
|
||||
xcbParentWindow,
|
||||
aznumeric_cast<int16_t>(geometry.m_posX),
|
||||
aznumeric_cast<int16_t>(geometry.m_posY),
|
||||
aznumeric_cast<int16_t>(geometry.m_width),
|
||||
aznumeric_cast<int16_t>(geometry.m_height),
|
||||
borderWidth,
|
||||
XCB_WINDOW_CLASS_INPUT_OUTPUT,
|
||||
xcbRootScreen->root_visual,
|
||||
eventMask,
|
||||
valueList);
|
||||
xcbCheckResult = xcb_create_window_checked(
|
||||
m_xcbConnection, XCB_COPY_FROM_PARENT, m_xcbWindow, xcbParentWindow, aznumeric_cast<int16_t>(geometry.m_posX),
|
||||
aznumeric_cast<int16_t>(geometry.m_posY), aznumeric_cast<int16_t>(geometry.m_width), aznumeric_cast<int16_t>(geometry.m_height),
|
||||
borderWidth, XCB_WINDOW_CLASS_INPUT_OUTPUT, m_xcbRootScreen->root_visual, eventMask, valueList);
|
||||
|
||||
AZ_Assert(ValidateXcbResult(xcbCheckResult), "Failed to create xcb window.");
|
||||
|
||||
SetWindowTitle(title);
|
||||
|
||||
// Setup the window close event
|
||||
const static char* wmProtocolString = "WM_PROTOCOLS";
|
||||
|
||||
xcb_intern_atom_cookie_t cookieProtocol = xcb_intern_atom(m_xcbConnection, 1, strlen(wmProtocolString), wmProtocolString);
|
||||
xcb_intern_atom_reply_t* replyProtocol = xcb_intern_atom_reply(m_xcbConnection, cookieProtocol, nullptr);
|
||||
AZ_Error(XcbErrorWindow, replyProtocol != nullptr, "Unable to query xcb '%s' atom", wmProtocolString);
|
||||
m_xcbAtomProtocols = replyProtocol->atom;
|
||||
|
||||
const static char* wmDeleteWindowString = "WM_DELETE_WINDOW";
|
||||
xcb_intern_atom_cookie_t cookieDeleteWindow = xcb_intern_atom(m_xcbConnection, 0, strlen(wmDeleteWindowString), wmDeleteWindowString);
|
||||
xcb_intern_atom_reply_t* replyDeleteWindow = xcb_intern_atom_reply(m_xcbConnection, cookieDeleteWindow, nullptr);
|
||||
AZ_Error(XcbErrorWindow, replyDeleteWindow != nullptr, "Unable to query xcb '%s' atom", wmDeleteWindowString);
|
||||
m_xcbAtomDeleteWindow = replyDeleteWindow->atom;
|
||||
|
||||
xcbCheckResult = xcb_change_property_checked(m_xcbConnection,
|
||||
XCB_PROP_MODE_REPLACE,
|
||||
m_xcbWindow,
|
||||
m_xcbAtomProtocols,
|
||||
XCB_ATOM_ATOM,
|
||||
s_XcbFormatDataSize,
|
||||
1,
|
||||
&m_xcbAtomDeleteWindow);
|
||||
|
||||
AZ_Assert(ValidateXcbResult(xcbCheckResult), "Failed to change the xcb atom property for WM_CLOSE event");
|
||||
|
||||
m_posX = geometry.m_posX;
|
||||
m_posY = geometry.m_posY;
|
||||
m_width = geometry.m_width;
|
||||
m_height = geometry.m_height;
|
||||
|
||||
InitializeAtoms();
|
||||
|
||||
xcb_client_message_event_t event;
|
||||
event.response_type = XCB_CLIENT_MESSAGE;
|
||||
event.type = _NET_REQUEST_FRAME_EXTENTS;
|
||||
event.window = m_xcbWindow;
|
||||
event.format = 32;
|
||||
event.sequence = 0;
|
||||
event.data.data32[0] = 0l;
|
||||
event.data.data32[1] = 0l;
|
||||
event.data.data32[2] = 0l;
|
||||
event.data.data32[3] = 0l;
|
||||
event.data.data32[4] = 0l;
|
||||
xcbCheckResult = xcb_send_event(
|
||||
m_xcbConnection, 1, m_xcbRootScreen->root, XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT,
|
||||
(const char*)&event);
|
||||
AZ_Assert(ValidateXcbResult(xcbCheckResult), "Failed to set _NET_REQUEST_FRAME_EXTENTS");
|
||||
|
||||
// The WM will be able to kill the application if it gets unresponsive.
|
||||
int32_t pid = getpid();
|
||||
xcb_change_property(m_xcbConnection, XCB_PROP_MODE_REPLACE, m_xcbWindow, _NET_WM_PID, XCB_ATOM_CARDINAL, 32, 1, &pid);
|
||||
|
||||
xcb_flush(m_xcbConnection);
|
||||
}
|
||||
|
||||
xcb_atom_t XcbNativeWindow::GetAtom(const char* atomName)
|
||||
{
|
||||
xcb_intern_atom_cookie_t intern_atom_cookie = xcb_intern_atom(m_xcbConnection, 0, strlen(atomName), atomName);
|
||||
XcbStdFreePtr<xcb_intern_atom_reply_t> xkbinternAtom{ xcb_intern_atom_reply(m_xcbConnection, intern_atom_cookie, NULL) };
|
||||
|
||||
if (!xkbinternAtom)
|
||||
{
|
||||
AZ_Error(XcbErrorWindow, xkbinternAtom != nullptr, "Unable to query xcb '%s' atom", atomName);
|
||||
return XCB_NONE;
|
||||
}
|
||||
|
||||
return xkbinternAtom->atom;
|
||||
}
|
||||
|
||||
int XcbNativeWindow::SetAtom(xcb_window_t window, xcb_atom_t atom, xcb_atom_t type, size_t len, void* data)
|
||||
{
|
||||
xcb_void_cookie_t cookie = xcb_change_property_checked(m_xcbConnection, XCB_PROP_MODE_REPLACE, window, atom, type, 32, len, data);
|
||||
XcbStdFreePtr<xcb_generic_error_t> xkbError{ xcb_request_check(m_xcbConnection, cookie) };
|
||||
|
||||
if (!xkbError)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return xkbError->error_code;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void XcbNativeWindow::InitializeAtoms()
|
||||
{
|
||||
AZStd::vector<xcb_atom_t> Atoms;
|
||||
|
||||
_NET_ACTIVE_WINDOW = GetAtom("_NET_ACTIVE_WINDOW");
|
||||
_NET_WM_BYPASS_COMPOSITOR = GetAtom("_NET_WM_BYPASS_COMPOSITOR");
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Handle all WM Protocols atoms.
|
||||
//
|
||||
|
||||
WM_PROTOCOLS = GetAtom("WM_PROTOCOLS");
|
||||
|
||||
// This atom is used to close a window. Emitted when user clicks the close button.
|
||||
WM_DELETE_WINDOW = GetAtom("WM_DELETE_WINDOW");
|
||||
|
||||
Atoms.push_back(WM_DELETE_WINDOW);
|
||||
|
||||
xcb_change_property(
|
||||
m_xcbConnection, XCB_PROP_MODE_REPLACE, m_xcbWindow, WM_PROTOCOLS, XCB_ATOM_ATOM, 32, Atoms.size(), Atoms.data());
|
||||
|
||||
xcb_flush(m_xcbConnection);
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Handle all WM State atoms.
|
||||
//
|
||||
|
||||
_NET_WM_STATE = GetAtom("_NET_WM_STATE");
|
||||
_NET_WM_STATE_FULLSCREEN = GetAtom("_NET_WM_STATE_FULLSCREEN");
|
||||
_NET_WM_STATE_MAXIMIZED_VERT = GetAtom("_NET_WM_STATE_MAXIMIZED_VERT");
|
||||
_NET_WM_STATE_MAXIMIZED_HORZ = GetAtom("_NET_WM_STATE_MAXIMIZED_HORZ");
|
||||
_NET_MOVERESIZE_WINDOW = GetAtom("_NET_MOVERESIZE_WINDOW");
|
||||
_NET_REQUEST_FRAME_EXTENTS = GetAtom("_NET_REQUEST_FRAME_EXTENTS");
|
||||
_NET_FRAME_EXTENTS = GetAtom("_NET_FRAME_EXTENTS");
|
||||
_NET_WM_PID = GetAtom("_NET_WM_PID");
|
||||
}
|
||||
|
||||
void XcbNativeWindow::GetWMStates()
|
||||
{
|
||||
xcb_get_property_cookie_t cookie = xcb_get_property(m_xcbConnection, 0, m_xcbWindow, _NET_WM_STATE, XCB_ATOM_ATOM, 0, 1024);
|
||||
|
||||
xcb_generic_error_t* error = nullptr;
|
||||
XcbStdFreePtr<xcb_get_property_reply_t> xkbGetPropertyReply{ xcb_get_property_reply(m_xcbConnection, cookie, &error) };
|
||||
|
||||
if (!xkbGetPropertyReply || error || !((xkbGetPropertyReply->format == 32) && (xkbGetPropertyReply->type == XCB_ATOM_ATOM)))
|
||||
{
|
||||
AZ_Warning("ApplicationLinux", false, "Acquiring _NET_WM_STATE information from the WM failed.");
|
||||
|
||||
if (error)
|
||||
{
|
||||
AZ_TracePrintf("Error", "Error code %d", error->error_code);
|
||||
free(error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
m_fullscreenState = false;
|
||||
m_horizontalyMaximized = false;
|
||||
m_verticallyMaximized = false;
|
||||
|
||||
const xcb_atom_t* states = static_cast<const xcb_atom_t*>(xcb_get_property_value(xkbGetPropertyReply.get()));
|
||||
for (int i = 0; i < xkbGetPropertyReply->length; i++)
|
||||
{
|
||||
if (states[i] == _NET_WM_STATE_FULLSCREEN)
|
||||
{
|
||||
m_fullscreenState = true;
|
||||
}
|
||||
else if (states[i] == _NET_WM_STATE_MAXIMIZED_HORZ)
|
||||
{
|
||||
m_horizontalyMaximized = true;
|
||||
}
|
||||
else if (states[i] == _NET_WM_STATE_MAXIMIZED_VERT)
|
||||
{
|
||||
m_verticallyMaximized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -146,7 +247,7 @@ namespace AzFramework
|
||||
xcb_flush(m_xcbConnection);
|
||||
}
|
||||
XcbEventHandlerBus::Handler::BusDisconnect();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
NativeWindowHandle XcbNativeWindow::GetWindowHandle() const
|
||||
@@ -158,14 +259,9 @@ namespace AzFramework
|
||||
void XcbNativeWindow::SetWindowTitle(const AZStd::string& title)
|
||||
{
|
||||
xcb_void_cookie_t xcbCheckResult;
|
||||
xcbCheckResult = xcb_change_property(m_xcbConnection,
|
||||
XCB_PROP_MODE_REPLACE,
|
||||
m_xcbWindow,
|
||||
XCB_ATOM_WM_NAME,
|
||||
XCB_ATOM_STRING,
|
||||
8,
|
||||
static_cast<uint32_t>(title.size()),
|
||||
title.c_str());
|
||||
xcbCheckResult = xcb_change_property(
|
||||
m_xcbConnection, XCB_PROP_MODE_REPLACE, m_xcbWindow, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, static_cast<uint32_t>(title.size()),
|
||||
title.c_str());
|
||||
AZ_Assert(ValidateXcbResult(xcbCheckResult), "Failed to set window title.");
|
||||
}
|
||||
|
||||
@@ -175,7 +271,7 @@ namespace AzFramework
|
||||
const uint32_t values[] = { clientAreaSize.m_width, clientAreaSize.m_height };
|
||||
|
||||
xcb_configure_window(m_xcbConnection, m_xcbWindow, XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values);
|
||||
|
||||
|
||||
m_width = clientAreaSize.m_width;
|
||||
m_height = clientAreaSize.m_height;
|
||||
}
|
||||
@@ -185,16 +281,77 @@ namespace AzFramework
|
||||
{
|
||||
// [GFX TODO][GHI - 2678]
|
||||
// Using 60 for now until proper support is added
|
||||
|
||||
return 60;
|
||||
}
|
||||
|
||||
bool XcbNativeWindow::GetFullScreenState() const
|
||||
{
|
||||
return m_fullscreenState;
|
||||
}
|
||||
|
||||
void XcbNativeWindow::SetFullScreenState(bool fullScreenState)
|
||||
{
|
||||
// TODO This is a pretty basic full-screen implementation using WM's _NET_WM_STATE_FULLSCREEN state.
|
||||
// Do we have to provide also the old way?
|
||||
|
||||
GetWMStates();
|
||||
|
||||
xcb_client_message_event_t event;
|
||||
event.response_type = XCB_CLIENT_MESSAGE;
|
||||
event.type = _NET_WM_STATE;
|
||||
event.window = m_xcbWindow;
|
||||
event.format = 32;
|
||||
event.sequence = 0;
|
||||
event.data.data32[0] = fullScreenState ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
|
||||
event.data.data32[1] = _NET_WM_STATE_FULLSCREEN;
|
||||
event.data.data32[2] = 0;
|
||||
event.data.data32[3] = 1;
|
||||
event.data.data32[4] = 0;
|
||||
xcb_void_cookie_t xcbCheckResult = xcb_send_event(
|
||||
m_xcbConnection, 1, m_xcbRootScreen->root, XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT,
|
||||
(const char*)&event);
|
||||
AZ_Assert(ValidateXcbResult(xcbCheckResult), "Failed to set _NET_WM_STATE_FULLSCREEN");
|
||||
|
||||
// Also try to disable/enable the compositor if possible. Might help in some cases.
|
||||
const long _NET_WM_BYPASS_COMPOSITOR_HINT_ON = m_fullscreenState ? 1 : 0;
|
||||
SetAtom(m_xcbWindow, _NET_WM_BYPASS_COMPOSITOR, XCB_ATOM_CARDINAL, 32, (char*)&_NET_WM_BYPASS_COMPOSITOR_HINT_ON);
|
||||
|
||||
if (!fullScreenState)
|
||||
{
|
||||
if (m_horizontalyMaximized || m_verticallyMaximized)
|
||||
{
|
||||
printf("Remove maximized state.\n");
|
||||
xcb_client_message_event_t event;
|
||||
event.response_type = XCB_CLIENT_MESSAGE;
|
||||
event.type = _NET_WM_STATE;
|
||||
event.window = m_xcbWindow;
|
||||
event.format = 32;
|
||||
event.sequence = 0;
|
||||
event.data.data32[0] = _NET_WM_STATE_MAXIMIZED_VERT;
|
||||
event.data.data32[1] = _NET_WM_STATE_MAXIMIZED_HORZ;
|
||||
event.data.data32[2] = 0;
|
||||
event.data.data32[3] = 0;
|
||||
event.data.data32[4] = 0;
|
||||
xcb_void_cookie_t xcbCheckResult = xcb_send_event(
|
||||
m_xcbConnection, 1, m_xcbRootScreen->root, XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT,
|
||||
(const char*)&event);
|
||||
AZ_Assert(
|
||||
ValidateXcbResult(xcbCheckResult), "Failed to remove _NET_WM_STATE_MAXIMIZED_VERT | _NET_WM_STATE_MAXIMIZED_HORZ");
|
||||
}
|
||||
}
|
||||
|
||||
xcb_flush(m_xcbConnection);
|
||||
m_fullscreenState = fullScreenState;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool XcbNativeWindow::ValidateXcbResult(xcb_void_cookie_t cookie)
|
||||
{
|
||||
bool result = true;
|
||||
if (xcb_generic_error_t* error = xcb_request_check(m_xcbConnection, cookie))
|
||||
{
|
||||
AZ_TracePrintf("Error","Error code %d", error->error_code);
|
||||
AZ_TracePrintf("Error", "Error code %d", error->error_code);
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
@@ -205,20 +362,20 @@ namespace AzFramework
|
||||
{
|
||||
switch (event->response_type & s_XcbResponseTypeMask)
|
||||
{
|
||||
case XCB_CONFIGURE_NOTIFY:
|
||||
case XCB_CONFIGURE_NOTIFY:
|
||||
{
|
||||
xcb_configure_notify_event_t* cne = reinterpret_cast<xcb_configure_notify_event_t*>(event);
|
||||
WindowSizeChanged(aznumeric_cast<uint32_t>(cne->width),
|
||||
aznumeric_cast<uint32_t>(cne->height));
|
||||
|
||||
if ((cne->width != m_width) || (cne->height != m_height))
|
||||
{
|
||||
WindowSizeChanged(aznumeric_cast<uint32_t>(cne->width), aznumeric_cast<uint32_t>(cne->height));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case XCB_CLIENT_MESSAGE:
|
||||
case XCB_CLIENT_MESSAGE:
|
||||
{
|
||||
xcb_client_message_event_t* cme = reinterpret_cast<xcb_client_message_event_t*>(event);
|
||||
if ((cme->type == m_xcbAtomProtocols) &&
|
||||
(cme->format == s_XcbFormatDataSize) &&
|
||||
(cme->data.data32[0] == m_xcbAtomDeleteWindow))
|
||||
|
||||
if ((cme->type == WM_PROTOCOLS) && (cme->format == s_XcbFormatDataSize) && (cme->data.data32[0] == WM_DELETE_WINDOW))
|
||||
{
|
||||
Deactivate();
|
||||
|
||||
@@ -239,7 +396,8 @@ namespace AzFramework
|
||||
|
||||
if (m_activated)
|
||||
{
|
||||
WindowNotificationBus::Event(reinterpret_cast<NativeWindowHandle>(m_xcbWindow), &WindowNotificationBus::Events::OnWindowResized, width, height);
|
||||
WindowNotificationBus::Event(
|
||||
reinterpret_cast<NativeWindowHandle>(m_xcbWindow), &WindowNotificationBus::Events::OnWindowResized, width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,15 +27,16 @@ namespace AzFramework
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NativeWindow::Implementation
|
||||
void InitWindow(const AZStd::string& title,
|
||||
const WindowGeometry& geometry,
|
||||
const WindowStyleMasks& styleMasks) override;
|
||||
void InitWindow(const AZStd::string& title, const WindowGeometry& geometry, const WindowStyleMasks& styleMasks) override;
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
NativeWindowHandle GetWindowHandle() const override;
|
||||
void SetWindowTitle(const AZStd::string& title) override;
|
||||
void ResizeClientArea(WindowSize clientAreaSize) override;
|
||||
uint32_t GetDisplayRefreshRate() const override;
|
||||
uint32_t GetDisplayRefreshRate() const override;
|
||||
|
||||
bool GetFullScreenState() const override;
|
||||
void SetFullScreenState(bool fullScreenState) override;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// XcbEventHandlerBus::Handler
|
||||
@@ -44,10 +45,46 @@ namespace AzFramework
|
||||
private:
|
||||
bool ValidateXcbResult(xcb_void_cookie_t cookie);
|
||||
void WindowSizeChanged(const uint32_t width, const uint32_t height);
|
||||
int SetAtom(xcb_window_t window, xcb_atom_t atom, xcb_atom_t type, size_t len, void* data);
|
||||
|
||||
xcb_connection_t* m_xcbConnection = nullptr;
|
||||
xcb_window_t m_xcbWindow = 0;
|
||||
xcb_atom_t m_xcbAtomProtocols;
|
||||
xcb_atom_t m_xcbAtomDeleteWindow;
|
||||
// Initialize one atom.
|
||||
xcb_atom_t GetAtom(const char* atomName);
|
||||
|
||||
// Initialize all used atoms.
|
||||
void InitializeAtoms();
|
||||
void GetWMStates();
|
||||
|
||||
xcb_connection_t* m_xcbConnection = nullptr;
|
||||
xcb_screen_t* m_xcbRootScreen = nullptr;
|
||||
xcb_window_t m_xcbWindow = 0;
|
||||
int32_t m_posX;
|
||||
int32_t m_posY;
|
||||
bool m_fullscreenState = false;
|
||||
bool m_horizontalyMaximized = false;
|
||||
bool m_verticallyMaximized = false;
|
||||
|
||||
// Use exact atom names for easy readability and usage.
|
||||
xcb_atom_t WM_PROTOCOLS;
|
||||
xcb_atom_t WM_DELETE_WINDOW;
|
||||
// This atom is used to activate a window.
|
||||
xcb_atom_t _NET_ACTIVE_WINDOW;
|
||||
// This atom is use to bypass a compositor. Used during fullscreen mode.
|
||||
xcb_atom_t _NET_WM_BYPASS_COMPOSITOR;
|
||||
// This atom is used to change the state of a window using the WM.
|
||||
xcb_atom_t _NET_WM_STATE;
|
||||
// This atom is used to enable/disable fullscreen mode of a window.
|
||||
xcb_atom_t _NET_WM_STATE_FULLSCREEN;
|
||||
// This atom is used to extend the window to max vertically.
|
||||
xcb_atom_t _NET_WM_STATE_MAXIMIZED_VERT;
|
||||
// This atom is used to extend the window to max horizontally.
|
||||
xcb_atom_t _NET_WM_STATE_MAXIMIZED_HORZ;
|
||||
// This atom is used to position and resize a window.
|
||||
xcb_atom_t _NET_MOVERESIZE_WINDOW;
|
||||
// This atom is used to request the extent of the window.
|
||||
xcb_atom_t _NET_REQUEST_FRAME_EXTENTS;
|
||||
// This atom is used to identify the reply event for _NET_REQUEST_FRAME_EXTENTS
|
||||
xcb_atom_t _NET_FRAME_EXTENTS;
|
||||
// This atom is used to allow WM to kill app if not responsive anymore
|
||||
xcb_atom_t _NET_WM_PID;
|
||||
};
|
||||
} // namespace AzFramework
|
||||
|
||||
@@ -12,6 +12,8 @@ set(FILES
|
||||
AzFramework/XcbConnectionManager.h
|
||||
AzFramework/XcbInputDeviceKeyboard.cpp
|
||||
AzFramework/XcbInputDeviceKeyboard.h
|
||||
AzFramework/XcbInputDeviceMouse.cpp
|
||||
AzFramework/XcbInputDeviceMouse.h
|
||||
AzFramework/XcbInterface.h
|
||||
AzFramework/XcbNativeWindow.cpp
|
||||
AzFramework/XcbNativeWindow.h
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#if PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
|
||||
#include <AzFramework/XcbInputDeviceMouse.h>
|
||||
#endif
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
InputDeviceMouse::Implementation* InputDeviceMouse::Implementation::Create(InputDeviceMouse& inputDevice)
|
||||
{
|
||||
#if PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
|
||||
return XcbInputDeviceMouse::Create(inputDevice);
|
||||
#elif PAL_TRAIT_LINUX_WINDOW_MANAGER_WAYLAND
|
||||
#error "Linux Window Manager Wayland not supported."
|
||||
return nullptr;
|
||||
#else
|
||||
#error "Linux Window Manager not recognized."
|
||||
return nullptr;
|
||||
#endif // PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
|
||||
}
|
||||
} // namespace AzFramework
|
||||
@@ -22,8 +22,10 @@ if (${PAL_TRAIT_LINUX_WINDOW_MANAGER} STREQUAL "xcb")
|
||||
PRIVATE
|
||||
3rdParty::X11::xcb
|
||||
3rdParty::X11::xcb_xkb
|
||||
3rdParty::X11::xcb_xfixes
|
||||
3rdParty::X11::xkbcommon
|
||||
3rdParty::X11::xkbcommon_X11
|
||||
xcb-xinput
|
||||
)
|
||||
|
||||
elseif(PAL_TRAIT_LINUX_WINDOW_MANAGER STREQUAL "wayland")
|
||||
|
||||
@@ -22,8 +22,8 @@ set(FILES
|
||||
AzFramework/Windowing/NativeWindow_Linux.cpp
|
||||
../Common/Unimplemented/AzFramework/Input/Devices/Gamepad/InputDeviceGamepad_Unimplemented.cpp
|
||||
AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard_Linux.cpp
|
||||
AzFramework/Input/Devices/Mouse/InputDeviceMouse_Linux.cpp
|
||||
../Common/Unimplemented/AzFramework/Input/Devices/Motion/InputDeviceMotion_Unimplemented.cpp
|
||||
../Common/Unimplemented/AzFramework/Input/Devices/Mouse/InputDeviceMouse_Unimplemented.cpp
|
||||
../Common/Unimplemented/AzFramework/Input/Devices/Touch/InputDeviceTouch_Unimplemented.cpp
|
||||
AzFramework/Input/User/LocalUserId_Platform.h
|
||||
../Common/Default/AzFramework/Input/User/LocalUserId_Default.h
|
||||
|
||||
@@ -569,11 +569,12 @@ namespace UnitTest
|
||||
FillSpawnable(NumEntities);
|
||||
CreateEntityReferences(refScheme);
|
||||
|
||||
AZ_PUSH_DISABLE_WARNING(5233, "-Wunused-lambda-capture") // Older versions of MSVC toolchain require to pass constexpr in the
|
||||
// capture. Newer versions issue unused warning
|
||||
auto callback =
|
||||
[this, refScheme, NumEntities](AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstEntityContainerView entities)
|
||||
AZ_POP_DISABLE_WARNING
|
||||
{
|
||||
AZ_UNUSED(refScheme);
|
||||
AZ_UNUSED(NumEntities);
|
||||
ValidateEntityReferences(refScheme, NumEntities, entities);
|
||||
};
|
||||
|
||||
@@ -591,11 +592,12 @@ namespace UnitTest
|
||||
FillSpawnable(NumEntities);
|
||||
CreateEntityReferences(refScheme);
|
||||
|
||||
AZ_PUSH_DISABLE_WARNING(5233, "-Wunused-lambda-capture") // Older versions of MSVC toolchain require to pass constexpr in the
|
||||
// capture. Newer versions issue unused warning
|
||||
auto callback =
|
||||
[this, refScheme, NumEntities](AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstEntityContainerView entities)
|
||||
AZ_POP_DISABLE_WARNING
|
||||
{
|
||||
AZ_UNUSED(refScheme);
|
||||
AZ_UNUSED(NumEntities);
|
||||
ValidateEntityReferences(refScheme, NumEntities, entities);
|
||||
};
|
||||
|
||||
@@ -720,11 +722,12 @@ namespace UnitTest
|
||||
FillSpawnable(NumEntities);
|
||||
CreateEntityReferences(refScheme);
|
||||
|
||||
AZ_PUSH_DISABLE_WARNING(5233, "-Wunused-lambda-capture") // Older versions of MSVC toolchain require to pass constexpr in the
|
||||
// capture. Newer versions issue unused warning
|
||||
auto callback =
|
||||
[this, refScheme, NumEntities](AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstEntityContainerView entities)
|
||||
AZ_POP_DISABLE_WARNING
|
||||
{
|
||||
AZ_UNUSED(refScheme);
|
||||
AZ_UNUSED(NumEntities);
|
||||
ValidateEntityReferences(refScheme, NumEntities, entities);
|
||||
};
|
||||
|
||||
|
||||
+2
@@ -46,6 +46,8 @@ namespace AzManipulatorTestFramework
|
||||
virtual void UpdateVisibility() = 0;
|
||||
//! Set if sticky select is enabled or not.
|
||||
virtual void SetStickySelect(bool enabled) = 0;
|
||||
//! Get default Editor Camera Position.
|
||||
virtual AZ::Vector3 DefaultEditorCameraPosition() const = 0;
|
||||
};
|
||||
|
||||
//! This interface is used to simulate the manipulator manager while the manipulators are under test.
|
||||
|
||||
+1
@@ -36,6 +36,7 @@ namespace AzManipulatorTestFramework
|
||||
int GetViewportId() const override;
|
||||
void UpdateVisibility() override;
|
||||
void SetStickySelect(bool enabled) override;
|
||||
AZ::Vector3 DefaultEditorCameraPosition() const override;
|
||||
|
||||
// ViewportInteractionRequestBus overrides ...
|
||||
AzFramework::CameraState GetCameraState() override;
|
||||
|
||||
@@ -120,6 +120,11 @@ namespace AzManipulatorTestFramework
|
||||
m_stickySelect = enabled;
|
||||
}
|
||||
|
||||
AZ::Vector3 ViewportInteraction::DefaultEditorCameraPosition() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void ViewportInteraction::SetGridSize(float size)
|
||||
{
|
||||
m_gridSize = size;
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace AzNetworking
|
||||
: m_delta(delta)
|
||||
, m_dataSerializer(m_delta.GetBufferPtr(), m_delta.GetBufferCapacity())
|
||||
{
|
||||
m_namePrefix.reserve(128);
|
||||
;
|
||||
}
|
||||
|
||||
DeltaSerializerCreate::~DeltaSerializerCreate()
|
||||
@@ -73,7 +73,7 @@ namespace AzNetworking
|
||||
// Delete any left over records that might be hanging around
|
||||
for (auto iter : m_records)
|
||||
{
|
||||
delete iter.second;
|
||||
delete iter;
|
||||
}
|
||||
m_records.clear();
|
||||
}
|
||||
@@ -160,28 +160,13 @@ namespace AzNetworking
|
||||
return SerializeHelper(buffer, bufferCapacity, isString, outSize, name);
|
||||
}
|
||||
|
||||
AZStd::string DeltaSerializerCreate::GetNextObjectName(const char* name)
|
||||
bool DeltaSerializerCreate::BeginObject([[maybe_unused]] const char* name, [[maybe_unused]] const char* typeName)
|
||||
{
|
||||
AZStd::string objectName = name;
|
||||
objectName += ".";
|
||||
objectName += AZStd::to_string(m_objectCounter);
|
||||
++m_objectCounter;
|
||||
return objectName;
|
||||
}
|
||||
|
||||
bool DeltaSerializerCreate::BeginObject(const char* name, [[maybe_unused]] const char* typeName)
|
||||
{
|
||||
m_nameLengthStack.push_back(m_namePrefix.length());
|
||||
m_namePrefix += GetNextObjectName(name);
|
||||
m_namePrefix += ".";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeltaSerializerCreate::EndObject([[maybe_unused]] const char* name, [[maybe_unused]] const char* typeName)
|
||||
{
|
||||
const size_t prevLen = m_nameLengthStack.back();
|
||||
m_nameLengthStack.pop_back();
|
||||
m_namePrefix.resize(prevLen);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -205,25 +190,15 @@ namespace AzNetworking
|
||||
{
|
||||
typedef AbstractValue::ValueT<T> ValueType;
|
||||
|
||||
const size_t prevLen = m_namePrefix.length();
|
||||
m_namePrefix += GetNextObjectName(name);
|
||||
|
||||
const AZ::HashValue32 nameHash = AZ::TypeHash32(m_namePrefix.c_str());
|
||||
|
||||
m_namePrefix.resize(prevLen);
|
||||
|
||||
AbstractValue::BaseValue*& baseValue = m_records[nameHash];
|
||||
AbstractValue::BaseValue* baseValue = m_records.size() > m_objectCounter ? m_records[m_objectCounter] : nullptr;
|
||||
++m_objectCounter;
|
||||
|
||||
// If we are in the gather records phase, just save off the value records
|
||||
if (m_gatheringRecords)
|
||||
{
|
||||
if (baseValue != nullptr)
|
||||
{
|
||||
AZ_Assert(false, "Duplicate name encountered in delta serializer. This will cause data to be serialized incorrectly.");
|
||||
return false;
|
||||
}
|
||||
|
||||
AZ_Assert(baseValue == nullptr, "Expected to create a new record but found a pre-existing one at index %d", m_objectCounter - 1);
|
||||
baseValue = new ValueType(value);
|
||||
m_records.push_back(baseValue);
|
||||
}
|
||||
else // If we are not gathering records, then we are comparing them
|
||||
{
|
||||
|
||||
@@ -90,8 +90,6 @@ namespace AzNetworking
|
||||
DeltaSerializerCreate(const DeltaSerializerCreate&) = delete;
|
||||
DeltaSerializerCreate& operator=(const DeltaSerializerCreate&) = delete;
|
||||
|
||||
AZStd::string GetNextObjectName(const char* name);
|
||||
|
||||
template <typename T>
|
||||
bool SerializeHelper(T& value, uint32_t bufferCapacity, bool isString, uint32_t& outSize, const char* name);
|
||||
|
||||
@@ -105,9 +103,7 @@ namespace AzNetworking
|
||||
|
||||
bool m_gatheringRecords = false;
|
||||
uint32_t m_objectCounter = 0;
|
||||
AZStd::string m_namePrefix;
|
||||
AZStd::vector<size_t> m_nameLengthStack;
|
||||
AZStd::unordered_map<AZ::HashValue32, AbstractValue::BaseValue*> m_records;
|
||||
AZStd::vector<AbstractValue::BaseValue*> m_records;
|
||||
NetworkInputSerializer m_dataSerializer;
|
||||
};
|
||||
|
||||
|
||||
@@ -11,4 +11,213 @@
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
struct DeltaDataElement
|
||||
{
|
||||
AzNetworking::PacketId m_packetId = AzNetworking::InvalidPacketId;
|
||||
uint32_t m_id = 0;
|
||||
AZ::TimeMs m_timeMs = AZ::TimeMs{ 0 };
|
||||
float m_blendFactor = 0.f;
|
||||
AZStd::vector<int> m_growVector, m_shrinkVector;
|
||||
|
||||
bool Serialize(AzNetworking::ISerializer& serializer)
|
||||
{
|
||||
if (!serializer.Serialize(m_packetId, "PacketId")
|
||||
|| !serializer.Serialize(m_id, "Id")
|
||||
|| !serializer.Serialize(m_timeMs, "TimeMs")
|
||||
|| !serializer.Serialize(m_blendFactor, "BlendFactor")
|
||||
|| !serializer.Serialize(m_growVector, "GrowVector")
|
||||
|| !serializer.Serialize(m_shrinkVector, "ShrinkVector"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct DeltaDataContainer
|
||||
{
|
||||
AZStd::string m_containerName;
|
||||
AZStd::array<DeltaDataElement, 32> m_container;
|
||||
|
||||
// This logic is modeled after NetworkInputArray serialization in the Multiplayer Gem
|
||||
bool Serialize(AzNetworking::ISerializer& serializer)
|
||||
{
|
||||
// Always serialize the full first element
|
||||
if(!m_container[0].Serialize(serializer))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (uint32_t i = 1; i < m_container.size(); ++i)
|
||||
{
|
||||
if (serializer.GetSerializerMode() == AzNetworking::SerializerMode::WriteToObject)
|
||||
{
|
||||
AzNetworking::SerializerDelta deltaSerializer;
|
||||
// Read out the delta
|
||||
if (!deltaSerializer.Serialize(serializer))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Start with previous value
|
||||
m_container[i] = m_container[i - 1];
|
||||
// Then apply delta
|
||||
AzNetworking::DeltaSerializerApply applySerializer(deltaSerializer);
|
||||
if (!applySerializer.ApplyDelta(m_container[i]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AzNetworking::SerializerDelta deltaSerializer;
|
||||
// Create the delta
|
||||
AzNetworking::DeltaSerializerCreate createSerializer(deltaSerializer);
|
||||
if (!createSerializer.CreateDelta(m_container[i - 1], m_container[i]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Then write out the delta
|
||||
if (!deltaSerializer.Serialize(serializer))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// This logic is modeled after NetworkInputArray serialization in the Multiplayer Gem
|
||||
bool SerializeNoDelta(AzNetworking::ISerializer& serializer)
|
||||
{
|
||||
for (uint32_t i = 0; i < m_container.size(); ++i)
|
||||
{
|
||||
if(!m_container[i].Serialize(serializer))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class DeltaSerializerTests
|
||||
: public UnitTest::AllocatorsTestFixture
|
||||
{
|
||||
public:
|
||||
void SetUp() override
|
||||
{
|
||||
UnitTest::AllocatorsTestFixture::SetUp();
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
UnitTest::AllocatorsTestFixture::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
static constexpr float BLEND_FACTOR_SCALE = 1.1f;
|
||||
static constexpr uint32_t TIME_SCALE = 10;
|
||||
|
||||
DeltaDataContainer TestDeltaContainer()
|
||||
{
|
||||
DeltaDataContainer testContainer;
|
||||
AZStd::vector<int> growVector, shrinkVector;
|
||||
shrinkVector.resize(testContainer.m_container.array_size);
|
||||
|
||||
testContainer.m_containerName = "TestContainer";
|
||||
for (int i = 0; i < testContainer.m_container.array_size; ++i)
|
||||
{
|
||||
testContainer.m_container[i].m_packetId = AzNetworking::PacketId(i);
|
||||
testContainer.m_container[i].m_id = i;
|
||||
testContainer.m_container[i].m_timeMs = AZ::TimeMs(i * TIME_SCALE);
|
||||
testContainer.m_container[i].m_blendFactor = BLEND_FACTOR_SCALE * i;
|
||||
growVector.push_back(i);
|
||||
testContainer.m_container[i].m_growVector = growVector;
|
||||
shrinkVector.resize(testContainer.m_container.array_size - i);
|
||||
testContainer.m_container[i].m_shrinkVector = shrinkVector;
|
||||
}
|
||||
|
||||
return testContainer;
|
||||
}
|
||||
|
||||
TEST_F(DeltaSerializerTests, DeltaArray)
|
||||
{
|
||||
DeltaDataContainer inContainer = TestDeltaContainer();
|
||||
AZStd::array<uint8_t, 2048> buffer;
|
||||
AzNetworking::NetworkInputSerializer inSerializer(buffer.data(), static_cast<uint32_t>(buffer.size()));
|
||||
|
||||
// Always serialize the full first element
|
||||
EXPECT_TRUE(inContainer.Serialize(inSerializer));
|
||||
|
||||
DeltaDataContainer outContainer;
|
||||
AzNetworking::NetworkOutputSerializer outSerializer(buffer.data(), static_cast<uint32_t>(buffer.size()));
|
||||
|
||||
EXPECT_TRUE(outContainer.Serialize(outSerializer));
|
||||
|
||||
for (uint32_t i = 0; i > outContainer.m_container.size(); ++i)
|
||||
{
|
||||
EXPECT_EQ(inContainer.m_container[i].m_blendFactor, outContainer.m_container[i].m_blendFactor);
|
||||
EXPECT_EQ(inContainer.m_container[i].m_id, outContainer.m_container[i].m_id);
|
||||
EXPECT_EQ(inContainer.m_container[i].m_packetId, outContainer.m_container[i].m_packetId);
|
||||
EXPECT_EQ(inContainer.m_container[i].m_timeMs, outContainer.m_container[i].m_timeMs);
|
||||
EXPECT_EQ(inContainer.m_container[i].m_growVector[i], outContainer.m_container[i].m_growVector[i]);
|
||||
EXPECT_EQ(inContainer.m_container[i].m_growVector.size(), outContainer.m_container[i].m_growVector.size());
|
||||
EXPECT_EQ(inContainer.m_container[i].m_shrinkVector.size(), outContainer.m_container[i].m_shrinkVector.size());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DeltaSerializerTests, DeltaSerializerCreateUnused)
|
||||
{
|
||||
// Every function here should return a constant value regardless of inputs
|
||||
AzNetworking::SerializerDelta deltaSerializer;
|
||||
AzNetworking::DeltaSerializerCreate createSerializer(deltaSerializer);
|
||||
|
||||
EXPECT_EQ(createSerializer.GetCapacity(), 0);
|
||||
EXPECT_EQ(createSerializer.GetSize(), 0);
|
||||
EXPECT_EQ(createSerializer.GetBuffer(), nullptr);
|
||||
EXPECT_EQ(createSerializer.GetSerializerMode(), AzNetworking::SerializerMode::ReadFromObject);
|
||||
|
||||
createSerializer.ClearTrackedChangesFlag(); //NO-OP
|
||||
EXPECT_FALSE(createSerializer.GetTrackedChangesFlag());
|
||||
EXPECT_TRUE(createSerializer.BeginObject("CreateSerializer", "Begin"));
|
||||
EXPECT_TRUE(createSerializer.EndObject("CreateSerializer", "End"));
|
||||
}
|
||||
|
||||
TEST_F(DeltaSerializerTests, DeltaArraySize)
|
||||
{
|
||||
DeltaDataContainer deltaContainer = TestDeltaContainer();
|
||||
DeltaDataContainer noDeltaContainer = TestDeltaContainer();
|
||||
|
||||
AZStd::array<uint8_t, 2048> deltaBuffer;
|
||||
AzNetworking::NetworkInputSerializer deltaSerializer(deltaBuffer.data(), static_cast<uint32_t>(deltaBuffer.size()));
|
||||
AZStd::array<uint8_t, 2048> noDeltaBuffer;
|
||||
AzNetworking::NetworkInputSerializer noDeltaSerializer(noDeltaBuffer.data(), static_cast<uint32_t>(noDeltaBuffer.size()));
|
||||
|
||||
EXPECT_TRUE(deltaContainer.Serialize(deltaSerializer));
|
||||
EXPECT_FALSE(noDeltaContainer.SerializeNoDelta(noDeltaSerializer)); // Should run out of space
|
||||
EXPECT_EQ(noDeltaSerializer.GetCapacity(), noDeltaSerializer.GetSize()); // Verify that the serializer filled up
|
||||
EXPECT_FALSE(noDeltaSerializer.IsValid()); // and that it is no longer valid due to lack of space
|
||||
}
|
||||
|
||||
TEST_F(DeltaSerializerTests, DeltaSerializerApplyUnused)
|
||||
{
|
||||
// Every function here should return a constant value regardless of inputs
|
||||
AzNetworking::SerializerDelta deltaSerializer;
|
||||
AzNetworking::DeltaSerializerApply applySerializer(deltaSerializer);
|
||||
|
||||
EXPECT_EQ(applySerializer.GetCapacity(), 0);
|
||||
EXPECT_EQ(applySerializer.GetSize(), 0);
|
||||
EXPECT_EQ(applySerializer.GetBuffer(), nullptr);
|
||||
EXPECT_EQ(applySerializer.GetSerializerMode(), AzNetworking::SerializerMode::WriteToObject);
|
||||
|
||||
applySerializer.ClearTrackedChangesFlag(); //NO-OP
|
||||
EXPECT_FALSE(applySerializer.GetTrackedChangesFlag());
|
||||
EXPECT_TRUE(applySerializer.BeginObject("CreateSerializer", "Begin"));
|
||||
EXPECT_TRUE(applySerializer.EndObject("CreateSerializer", "End"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* 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 <AzCore/Component/Entity.h>
|
||||
#include <AzQtComponents/Components/ToastNotification.h>
|
||||
#include <AzQtComponents/Components/ui_ToastNotification.h>
|
||||
|
||||
#include <QCursor>
|
||||
#include <QIcon>
|
||||
#include <QToolButton>
|
||||
#include <QPropertyAnimation>
|
||||
|
||||
namespace AzQtComponents
|
||||
{
|
||||
ToastNotification::ToastNotification(QWidget* parent, const ToastConfiguration& toastConfiguration)
|
||||
: QDialog(parent, Qt::FramelessWindowHint)
|
||||
, m_closeOnClick(true)
|
||||
, m_ui(new Ui::ToastNotification())
|
||||
, m_fadeAnimation(nullptr)
|
||||
{
|
||||
setProperty("HasNoWindowDecorations", true);
|
||||
|
||||
setAttribute(Qt::WA_ShowWithoutActivating);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
m_ui->setupUi(this);
|
||||
|
||||
QIcon toastIcon;
|
||||
|
||||
switch (toastConfiguration.m_toastType)
|
||||
{
|
||||
case ToastType::Error:
|
||||
toastIcon = QIcon(":/stylesheet/img/logging/error.svg");
|
||||
break;
|
||||
case ToastType::Warning:
|
||||
toastIcon = QIcon(":/stylesheet/img/logging/warning-yellow.svg");
|
||||
break;
|
||||
case ToastType::Information:
|
||||
toastIcon = QIcon(":/stylesheet/img/logging/information.svg");
|
||||
break;
|
||||
case ToastType::Custom:
|
||||
toastIcon = QIcon(toastConfiguration.m_customIconImage);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_ui->iconLabel->setPixmap(toastIcon.pixmap(64, 64));
|
||||
|
||||
m_ui->titleLabel->setText(toastConfiguration.m_title);
|
||||
m_ui->mainLabel->setText(toastConfiguration.m_description);
|
||||
|
||||
m_lifeSpan.setInterval(aznumeric_cast<int>(toastConfiguration.m_duration.count()));
|
||||
m_closeOnClick = toastConfiguration.m_closeOnClick;
|
||||
|
||||
m_ui->closeButton->setVisible(m_closeOnClick);
|
||||
QObject::connect(m_ui->closeButton, &QToolButton::clicked, this, &ToastNotification::accept);
|
||||
|
||||
m_fadeDuration = toastConfiguration.m_fadeDuration;
|
||||
|
||||
QObject::connect(&m_lifeSpan, &QTimer::timeout, this, &ToastNotification::FadeOut);
|
||||
}
|
||||
|
||||
ToastNotification::~ToastNotification()
|
||||
{
|
||||
}
|
||||
|
||||
void ToastNotification::ShowToastAtCursor()
|
||||
{
|
||||
QPoint globalCursorPos = QCursor::pos();
|
||||
|
||||
// Left/middle align it relative to the cursor.
|
||||
QPointF anchorPoint(0, 0.5);
|
||||
|
||||
// Magic offset to try to get it to not hide under the cursor.
|
||||
// No way to get this programatically from what I can tell.
|
||||
globalCursorPos.setX(globalCursorPos.x() + 16);
|
||||
|
||||
ShowToastAtPoint(globalCursorPos, anchorPoint);
|
||||
}
|
||||
|
||||
void ToastNotification::ShowToastAtPoint(const QPoint& screenPosition, const QPointF& anchorPoint)
|
||||
{
|
||||
show();
|
||||
updateGeometry();
|
||||
|
||||
UpdatePosition(screenPosition, anchorPoint);
|
||||
}
|
||||
|
||||
void ToastNotification::UpdatePosition(const QPoint& screenPosition, const QPointF& anchorPoint)
|
||||
{
|
||||
QRect dialogGeometry = geometry();
|
||||
|
||||
QPoint finalPosition;
|
||||
finalPosition.setX(aznumeric_cast<int>(screenPosition.x() - dialogGeometry.width() * anchorPoint.x()));
|
||||
finalPosition.setY(aznumeric_cast<int>(screenPosition.y() - dialogGeometry.height() * anchorPoint.y()));
|
||||
|
||||
move(finalPosition);
|
||||
}
|
||||
|
||||
void ToastNotification::showEvent(QShowEvent* showEvent)
|
||||
{
|
||||
QDialog::showEvent(showEvent);
|
||||
|
||||
if (m_fadeDuration.count() > 0)
|
||||
{
|
||||
m_fadeAnimation = new QPropertyAnimation(this, "windowOpacity", this);
|
||||
m_fadeAnimation->setKeyValueAt(0, 0);
|
||||
m_fadeAnimation->setKeyValueAt(1, 1);
|
||||
|
||||
m_fadeAnimation->setDuration(static_cast<int>(m_fadeDuration.count()));
|
||||
|
||||
m_fadeAnimation->start();
|
||||
|
||||
QObject::connect(m_fadeAnimation, &QPropertyAnimation::finished, this, &ToastNotification::StartTimer);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartTimer();
|
||||
}
|
||||
}
|
||||
|
||||
void ToastNotification::hideEvent(QHideEvent* hideEvent)
|
||||
{
|
||||
QDialog::hideEvent(hideEvent);
|
||||
|
||||
m_lifeSpan.stop();
|
||||
|
||||
if (m_fadeAnimation)
|
||||
{
|
||||
m_fadeAnimation->stop();
|
||||
delete m_fadeAnimation;
|
||||
}
|
||||
|
||||
emit ToastNotificationHidden();
|
||||
}
|
||||
|
||||
void ToastNotification::mousePressEvent(QMouseEvent*)
|
||||
{
|
||||
if (m_closeOnClick)
|
||||
{
|
||||
emit ToastNotificationInteraction();
|
||||
accept();
|
||||
}
|
||||
}
|
||||
|
||||
bool ToastNotification::eventFilter(QObject*, QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::MouseButtonPress)
|
||||
{
|
||||
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
|
||||
|
||||
if (mouseEvent && mouseEvent->button() == Qt::MouseButton::LeftButton)
|
||||
{
|
||||
accept();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ToastNotification::StartTimer()
|
||||
{
|
||||
delete m_fadeAnimation;
|
||||
m_fadeAnimation = nullptr;
|
||||
|
||||
if (m_lifeSpan.interval() != 0)
|
||||
{
|
||||
m_lifeSpan.start();
|
||||
}
|
||||
}
|
||||
|
||||
void ToastNotification::FadeOut()
|
||||
{
|
||||
if (m_fadeDuration.count() > 0)
|
||||
{
|
||||
m_fadeAnimation = new QPropertyAnimation(this, "windowOpacity", this);
|
||||
m_fadeAnimation->setKeyValueAt(0, windowOpacity());
|
||||
m_fadeAnimation->setKeyValueAt(1, 0);
|
||||
|
||||
m_fadeAnimation->setDuration(static_cast<int>(m_fadeDuration.count()));
|
||||
|
||||
m_fadeAnimation->start();
|
||||
|
||||
QObject::connect(m_fadeAnimation, &QPropertyAnimation::finished, this, &ToastNotification::accept);
|
||||
}
|
||||
else
|
||||
{
|
||||
accept();
|
||||
}
|
||||
}
|
||||
#include "Components/moc_ToastNotification.cpp"
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzQtComponents/AzQtComponentsAPI.h>
|
||||
#include <AzQtComponents/Components/ToastNotificationConfiguration.h>
|
||||
#include <AzCore/std/smart_ptr/unique_ptr.h>
|
||||
#include <QEvent>
|
||||
#include <QDialog>
|
||||
#include <QMouseEvent>
|
||||
#include <QTimer>
|
||||
#endif
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ToastNotification;
|
||||
}
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QPropertyAnimation)
|
||||
|
||||
namespace AzQtComponents
|
||||
{
|
||||
class AZ_QT_COMPONENTS_API ToastNotification
|
||||
: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(ToastNotification, AZ::SystemAllocator, 0);
|
||||
|
||||
ToastNotification(QWidget* parent, const ToastConfiguration& toastConfiguration);
|
||||
virtual ~ToastNotification();
|
||||
|
||||
// Shows the toast notification relative to the current cursor.
|
||||
void ShowToastAtCursor();
|
||||
|
||||
// Aligns the toast notification so that the specified anchor point on the notification lies on the specified screen position.
|
||||
// i.e. anchor point of 0,0 will align the top left position of the dialog with the screen position
|
||||
// anchor point of 1,1 will align the bottom right position of the dialog with the screen position
|
||||
void ShowToastAtPoint(const QPoint& screenPosition, const QPointF& anchorPoint);
|
||||
|
||||
void UpdatePosition(const QPoint& screenPosition, const QPointF& anchorPoint);
|
||||
|
||||
// QDialog
|
||||
void showEvent(QShowEvent* showEvent) override;
|
||||
void hideEvent(QHideEvent* hideEvent) override;
|
||||
void mousePressEvent(QMouseEvent* mouseEvent) override;
|
||||
bool eventFilter(QObject* object, QEvent* event) override;
|
||||
|
||||
public slots:
|
||||
void StartTimer();
|
||||
void FadeOut();
|
||||
|
||||
signals:
|
||||
void ToastNotificationHidden();
|
||||
void ToastNotificationInteraction();
|
||||
|
||||
private:
|
||||
QPropertyAnimation* m_fadeAnimation;
|
||||
|
||||
bool m_closeOnClick;
|
||||
QTimer m_lifeSpan;
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
AZStd::chrono::milliseconds m_fadeDuration;
|
||||
AZStd::unique_ptr<Ui::ToastNotification> m_ui;
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
};
|
||||
} // namespace AzQtComponents
|
||||
@@ -0,0 +1,236 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ToastNotification</class>
|
||||
<widget class="QDialog" name="ToastNotification">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>225</width>
|
||||
<height>48</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>225</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="icon_frame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgba(255, 255, 255, 20);</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="iconLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgba(255, 255, 255, 0);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="resources.qrc">:/stylesheet/img/logging/information.svg</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="text_frame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="titleFrame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="titleLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Invalid Connection</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="closeButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources.qrc">
|
||||
<normaloff>:/stylesheet/img/close_x.svg</normaloff>:/stylesheet/img/close_x.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="mainLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Types are not a match.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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 <AzQtComponents/Components/ToastNotificationConfiguration.h>
|
||||
|
||||
namespace AzQtComponents
|
||||
{
|
||||
ToastConfiguration::ToastConfiguration(ToastType toastType, const QString& title, const QString& description)
|
||||
: m_toastType(toastType)
|
||||
, m_title(title)
|
||||
, m_description(description)
|
||||
{
|
||||
}
|
||||
} // namespace AzQtComponents
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzQtComponents/AzQtComponentsAPI.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/std/chrono/chrono.h>
|
||||
#include <QString>
|
||||
#endif
|
||||
|
||||
namespace AzQtComponents
|
||||
{
|
||||
enum class ToastType
|
||||
{
|
||||
Information,
|
||||
Warning,
|
||||
Error,
|
||||
Custom
|
||||
};
|
||||
|
||||
class AZ_QT_COMPONENTS_API ToastConfiguration
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(ToastConfiguration, AZ::SystemAllocator, 0);
|
||||
ToastConfiguration(ToastType toastType, const QString& title, const QString& description);
|
||||
|
||||
bool m_closeOnClick = true;
|
||||
|
||||
ToastType m_toastType = ToastType::Information;
|
||||
|
||||
QString m_title;
|
||||
QString m_description;
|
||||
QString m_customIconImage;
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
AZStd::chrono::milliseconds m_duration = AZStd::chrono::milliseconds(5000);
|
||||
AZStd::chrono::milliseconds m_fadeDuration = AZStd::chrono::milliseconds(250);
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
};
|
||||
} // namespace AzQtComponents
|
||||
@@ -49,6 +49,11 @@ set(FILES
|
||||
Components/Titlebar.h
|
||||
Components/TitleBarOverdrawHandler.cpp
|
||||
Components/TitleBarOverdrawHandler.h
|
||||
Components/ToastNotification.cpp
|
||||
Components/ToastNotification.h
|
||||
Components/ToastNotificationConfiguration.h
|
||||
Components/ToastNotificationConfiguration.cpp
|
||||
Components/ToastNotification.ui
|
||||
Components/ToolButtonComboBox.cpp
|
||||
Components/ToolButtonComboBox.h
|
||||
Components/ToolButtonLineEdit.cpp
|
||||
|
||||
@@ -90,19 +90,16 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
//! Filter out integration tests from the test run
|
||||
void excludeIntegTests()
|
||||
{
|
||||
AddExcludeFilter("INTEG_*");
|
||||
AddExcludeFilter("Integ_*");
|
||||
}
|
||||
|
||||
void ApplyGlobalParameters(int* argc, char** argv)
|
||||
{
|
||||
// this is a hook that can be used to apply any other global non-google parameters
|
||||
// that we use.
|
||||
// this is a hook that can be used to apply any other global parameters that we use.
|
||||
AZ_UNUSED(argc);
|
||||
AZ_UNUSED(argv);
|
||||
|
||||
// Disable gtest catching unhandled exceptions, instead, AzTestRunner will do it through:
|
||||
// AZ::Debug::Trace::HandleExceptions(true). This gives us a stack trace when the exception
|
||||
// is thrown (googletest does not).
|
||||
testing::FLAGS_gtest_catch_exceptions = false;
|
||||
}
|
||||
|
||||
//! Print out parameters that are not used by the framework
|
||||
@@ -160,7 +157,6 @@ namespace AZ
|
||||
}
|
||||
|
||||
::testing::InitGoogleMock(&argc, argv);
|
||||
AZ::Test::excludeIntegTests();
|
||||
AZ::Test::ApplyGlobalParameters(&argc, argv);
|
||||
AZ::Test::printUnusedParametersWarning(argc, argv);
|
||||
AZ::Test::addTestEnvironments(m_envs);
|
||||
@@ -281,7 +277,6 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
AZ::Test::excludeIntegTests();
|
||||
AZ::Test::printUnusedParametersWarning(argc, argv);
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
|
||||
@@ -104,7 +104,6 @@ namespace AZ
|
||||
|
||||
void addTestEnvironment(ITestEnvironment* env);
|
||||
void addTestEnvironments(std::vector<ITestEnvironment*> envs);
|
||||
void excludeIntegTests();
|
||||
|
||||
//! A hook that can be used to read any other misc parameters and remove them before google sees them.
|
||||
//! Note that this modifies argc and argv to delete the parameters it consumes.
|
||||
@@ -266,7 +265,6 @@ namespace AZ
|
||||
::testing::TestEventListeners& listeners = testing::UnitTest::GetInstance()->listeners(); \
|
||||
listeners.Append(new AZ::Test::OutputEventListener); \
|
||||
} \
|
||||
AZ::Test::excludeIntegTests(); \
|
||||
AZ::Test::ApplyGlobalParameters(&argc, argv); \
|
||||
AZ::Test::printUnusedParametersWarning(argc, argv); \
|
||||
AZ::Test::addTestEnvironments({TEST_ENV}); \
|
||||
|
||||
+6
-4
@@ -43,8 +43,7 @@ namespace AzToolsFramework
|
||||
};
|
||||
|
||||
//! Provides a bus to notify when the different editor modes are entered/exit.
|
||||
class ViewportEditorModeNotifications
|
||||
: public AZ::EBusTraits
|
||||
class ViewportEditorModeNotifications : public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -58,14 +57,17 @@ namespace AzToolsFramework
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
//! Notifies subscribers of the a given viewport to the activation of the specified editor mode.
|
||||
virtual void OnEditorModeActivated([[maybe_unused]] const ViewportEditorModesInterface& editorModeState, [[maybe_unused]] ViewportEditorMode mode)
|
||||
virtual void OnEditorModeActivated(
|
||||
[[maybe_unused]] const ViewportEditorModesInterface& editorModeState, [[maybe_unused]] ViewportEditorMode mode)
|
||||
{
|
||||
}
|
||||
|
||||
//! Notifies subscribers of the a given viewport to the deactivation of the specified editor mode.
|
||||
virtual void OnEditorModeDeactivated([[maybe_unused]] const ViewportEditorModesInterface& editorModeState, [[maybe_unused]] ViewportEditorMode mode)
|
||||
virtual void OnEditorModeDeactivated(
|
||||
[[maybe_unused]] const ViewportEditorModesInterface& editorModeState, [[maybe_unused]] ViewportEditorMode mode)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
using ViewportEditorModeNotificationsBus = AZ::EBus<ViewportEditorModeNotifications>;
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ namespace AzToolsFramework
|
||||
private slots:
|
||||
void SourceDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
||||
private:
|
||||
int m_numberOfItemsDisplayed = 50;
|
||||
AZ::u64 m_numberOfItemsDisplayed = 0;
|
||||
int m_displayedItemsCounter = 0;
|
||||
QPointer<AssetBrowserFilterModel> m_filterModel;
|
||||
QMap<int, QModelIndex> m_indexMap;
|
||||
|
||||
+52
@@ -137,6 +137,7 @@ namespace AzToolsFramework
|
||||
if (componentTypeIt == m_activeComponentTypes.end())
|
||||
{
|
||||
m_activeComponentTypes.push_back(componentType);
|
||||
m_viewportUiHandlers.emplace_back(componentType);
|
||||
}
|
||||
|
||||
// see if we already have a ComponentModeBuilder for the specific component on this entity
|
||||
@@ -225,6 +226,7 @@ namespace AzToolsFramework
|
||||
if (!m_entitiesAndComponentModes.empty())
|
||||
{
|
||||
RefreshActions();
|
||||
PopulateViewportUi();
|
||||
}
|
||||
|
||||
// if entering ComponentMode not as an undo/redo step (an action was
|
||||
@@ -285,6 +287,10 @@ namespace AzToolsFramework
|
||||
componentModeCommand.release();
|
||||
}
|
||||
|
||||
// remove the component mode viewport border
|
||||
ViewportUi::ViewportUiRequestBus::Event(
|
||||
ViewportUi::DefaultViewportId, &ViewportUi::ViewportUiRequestBus::Events::RemoveViewportBorder);
|
||||
|
||||
// notify listeners the editor has left ComponentMode - listeners may
|
||||
// wish to modify state to indicate this (e.g. appearance, functionality etc.)
|
||||
m_viewportEditorModeTracker->DeactivateMode({ GetEntityContextId() }, ViewportEditorMode::Component);
|
||||
@@ -301,6 +307,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
m_entitiesAndComponentModeBuilders.clear();
|
||||
m_activeComponentTypes.clear();
|
||||
m_viewportUiHandlers.clear();
|
||||
|
||||
m_componentMode = false;
|
||||
m_selectedComponentModeIndex = 0;
|
||||
@@ -385,6 +392,24 @@ namespace AzToolsFramework
|
||||
return m_activeComponentTypes.size() > 1;
|
||||
}
|
||||
|
||||
static ComponentModeViewportUi* FindViewportUiHandlerForType(
|
||||
AZStd::vector<ComponentModeViewportUi>& viewportUiHandlers, const AZ::Uuid& componentType)
|
||||
{
|
||||
auto handler = AZStd::find_if(
|
||||
viewportUiHandlers.begin(), viewportUiHandlers.end(),
|
||||
[componentType](const ComponentModeViewportUi& handler)
|
||||
{
|
||||
return handler.GetComponentType() == componentType;
|
||||
});
|
||||
|
||||
if (handler == viewportUiHandlers.end())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return handler;
|
||||
}
|
||||
|
||||
bool ComponentModeCollection::ActiveComponentModeChanged(const AZ::Uuid& previousComponentType)
|
||||
{
|
||||
if (m_activeComponentTypes[m_selectedComponentModeIndex] != previousComponentType)
|
||||
@@ -410,6 +435,20 @@ namespace AzToolsFramework
|
||||
// replace the current component mode by invoking the builder
|
||||
// for the new 'active' component mode
|
||||
componentMode.m_componentMode = componentModeBuilder->m_componentModeBuilder();
|
||||
|
||||
// populate the viewport UI with the new component mode
|
||||
PopulateViewportUi();
|
||||
|
||||
// set the appropriate viewportUiHandler to active
|
||||
if (auto viewportUiHandler =
|
||||
FindViewportUiHandlerForType(m_viewportUiHandlers, m_activeComponentTypes[m_selectedComponentModeIndex]))
|
||||
{
|
||||
viewportUiHandler->SetComponentModeViewportUiActive(true);
|
||||
}
|
||||
|
||||
ViewportUi::ViewportUiRequestBus::Event(
|
||||
ViewportUi::DefaultViewportId, &ViewportUi::ViewportUiRequestBus::Events::CreateViewportBorder,
|
||||
componentMode.m_componentMode->GetComponentModeName().c_str());
|
||||
}
|
||||
|
||||
RefreshActions();
|
||||
@@ -519,5 +558,18 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
void ComponentModeCollection::PopulateViewportUi()
|
||||
{
|
||||
// update viewport UI for new component type
|
||||
if (m_selectedComponentModeIndex < m_activeComponentTypes.size())
|
||||
{
|
||||
// iterate over all entities and their active Component Mode, populate viewport UI for the new mode
|
||||
for (auto& entityAndComponentMode : m_entitiesAndComponentModes)
|
||||
{
|
||||
// build viewport UI based on current state
|
||||
entityAndComponentMode.m_componentMode->PopulateViewportUi();
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace ComponentModeFramework
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ namespace AzToolsFramework
|
||||
GetEntityComponentIdPair(), elementIdsToDisplay);
|
||||
// create the component mode border with the specific name for this component mode
|
||||
ViewportUi::ViewportUiRequestBus::Event(
|
||||
ViewportUi::DefaultViewportId, &ViewportUi::ViewportUiRequestBus::Events::CreateComponentModeBorder,
|
||||
ViewportUi::DefaultViewportId, &ViewportUi::ViewportUiRequestBus::Events::CreateViewportBorder,
|
||||
GetComponentModeName());
|
||||
// set the EntityComponentId for this ComponentMode to active in the ComponentModeViewportUi system
|
||||
ComponentModeViewportUiRequestBus::Event(
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace AzToolsFramework
|
||||
virtual SettingOutcome GetValue(const AZStd::string_view path) = 0;
|
||||
virtual SettingOutcome SetValue(const AZStd::string_view path, const AZStd::any& value) = 0;
|
||||
virtual ConsoleColorTheme GetConsoleColorTheme() const = 0;
|
||||
virtual int GetMaxNumberOfItemsShownInSearchView() const = 0;
|
||||
virtual AZ::u64 GetMaxNumberOfItemsShownInSearchView() const = 0;
|
||||
};
|
||||
|
||||
using EditorSettingsAPIBus = AZ::EBus<EditorSettingsAPIRequests>;
|
||||
|
||||
@@ -381,22 +381,13 @@ namespace AzToolsFramework
|
||||
return;
|
||||
}
|
||||
|
||||
bool isPrefabSystemEnabled = false;
|
||||
AzFramework::ApplicationRequests::Bus::BroadcastResult(
|
||||
isPrefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
|
||||
|
||||
// For slices, orphan any children that remain attached to the entity
|
||||
// For prefabs, this is an unneeded operation because the prefab system handles the orphans
|
||||
// and the extra reparenting operation can be problematic for consumers subscribed to entity
|
||||
// events, such as the entity outliner.
|
||||
if (!isPrefabSystemEnabled)
|
||||
// Even though these child entities will immediately be destroyed, their entity info may be recycled
|
||||
// Ensure they don't have any lingering inaccurate parent data
|
||||
auto children = entityInfo.GetChildren();
|
||||
for (auto childId : children)
|
||||
{
|
||||
auto children = entityInfo.GetChildren();
|
||||
for (auto childId : children)
|
||||
{
|
||||
ReparentChild(childId, AZ::EntityId(), entityId);
|
||||
m_entityOrphanTable[entityId].insert(childId);
|
||||
}
|
||||
ReparentChild(childId, AZ::EntityId(), entityId);
|
||||
m_entityOrphanTable[entityId].insert(childId);
|
||||
}
|
||||
|
||||
m_savedOrderInfo[entityId] = AZStd::make_pair(entityInfo.GetParent(), entityInfo.GetIndexForSorting());
|
||||
@@ -1200,26 +1191,41 @@ namespace AzToolsFramework
|
||||
auto childItr = m_childIndexCache.find(childId);
|
||||
if (childItr == m_childIndexCache.end())
|
||||
{
|
||||
//cache indices for faster lookup
|
||||
m_childIndexCache[childId] = static_cast<AZ::u64>(m_children.size());
|
||||
m_children.push_back(childId);
|
||||
// m_children is guaranteed to be ordered by EntityId, do a sorted insertion
|
||||
auto insertedChildIndex = AZStd::upper_bound(m_children.begin(), m_children.end(), childId);
|
||||
insertedChildIndex = m_children.insert(insertedChildIndex, childId);
|
||||
|
||||
// Cache all affected child indices for fast lookup
|
||||
for (auto it = insertedChildIndex; it != m_children.end(); ++it)
|
||||
{
|
||||
const AZ::u64 newChildIndex = static_cast<AZ::u64>(it - m_children.begin());
|
||||
m_childIndexCache[*it] = newChildIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EditorEntityModel::EditorEntityModelEntry::RemoveChild(AZ::EntityId childId)
|
||||
{
|
||||
auto childItr = m_childIndexCache.find(childId);
|
||||
if (childItr != m_childIndexCache.end())
|
||||
// Retrieve our child index from the cache
|
||||
auto cachedIndexItr = m_childIndexCache.find(childId);
|
||||
if (cachedIndexItr == m_childIndexCache.end())
|
||||
{
|
||||
// Take the last entry and move it into the removed spot instead of deleting the entry and having to move all
|
||||
// following entries one step down.
|
||||
AZ::EntityId backEntity = m_children.back();
|
||||
m_children[childItr->second] = backEntity;
|
||||
// Update cached index for the moved id to the new index.
|
||||
m_childIndexCache[backEntity] = childItr->second;
|
||||
// Now remove the deleted id from the children and cache.
|
||||
m_childIndexCache.erase(childId);
|
||||
m_children.erase(m_children.end() - 1);
|
||||
AZ_Assert(false, "Attempted to remove an unknown child");
|
||||
return;
|
||||
}
|
||||
|
||||
// Build an iterator for m_children based on our cached index
|
||||
auto childItr = m_children.begin() + cachedIndexItr->second;
|
||||
|
||||
// Remove our child from the cache
|
||||
m_childIndexCache.erase(cachedIndexItr);
|
||||
|
||||
// Remove our child, fix up the cache entries for any subsequent children
|
||||
auto elementsToFixItr = m_children.erase(childItr);
|
||||
for (auto it = elementsToFixItr; it != m_children.end(); ++it)
|
||||
{
|
||||
const AZ::u64 newChildIndex = static_cast<AZ::u64>(it - m_children.begin());
|
||||
m_childIndexCache[*it] = newChildIndex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1256,8 +1262,17 @@ namespace AzToolsFramework
|
||||
|
||||
AZ::u64 EditorEntityModel::EditorEntityModelEntry::GetChildIndex(AZ::EntityId childId) const
|
||||
{
|
||||
// Return the cached index, if available.
|
||||
auto childItr = m_childIndexCache.find(childId);
|
||||
return childItr != m_childIndexCache.end() ? childItr->second : static_cast<AZ::u64>(m_children.size());
|
||||
if (childItr != m_childIndexCache.end())
|
||||
{
|
||||
return childItr->second;
|
||||
}
|
||||
|
||||
// On initialization, GetChildIndex may be queried for a childId that is not yet in the child list.
|
||||
// Return the position it would be inserted at in EditorEntityModelEntry::AddChild
|
||||
auto targetChildPositionItr = AZStd::upper_bound(m_children.begin(), m_children.end(), childId);
|
||||
return static_cast<AZ::u64>(targetChildPositionItr - m_children.begin());
|
||||
}
|
||||
|
||||
AZStd::string EditorEntityModel::EditorEntityModelEntry::GetName() const
|
||||
|
||||
+5
-6
@@ -71,12 +71,7 @@ namespace AzToolsFramework
|
||||
return;
|
||||
}
|
||||
|
||||
AZ::EntityId previousFocusEntityId = m_focusRoot;
|
||||
m_focusRoot = entityId;
|
||||
FocusModeNotificationBus::Broadcast(&FocusModeNotifications::OnEditorFocusChanged, previousFocusEntityId, m_focusRoot);
|
||||
|
||||
if (auto tracker = AZ::Interface<ViewportEditorModeTrackerInterface>::Get();
|
||||
tracker != nullptr)
|
||||
if (auto tracker = AZ::Interface<ViewportEditorModeTrackerInterface>::Get())
|
||||
{
|
||||
if (!m_focusRoot.IsValid() && entityId.IsValid())
|
||||
{
|
||||
@@ -87,6 +82,10 @@ namespace AzToolsFramework
|
||||
tracker->DeactivateMode({ GetEntityContextId() }, ViewportEditorMode::Focus);
|
||||
}
|
||||
}
|
||||
|
||||
AZ::EntityId previousFocusEntityId = m_focusRoot;
|
||||
m_focusRoot = entityId;
|
||||
FocusModeNotificationBus::Broadcast(&FocusModeNotifications::OnEditorFocusChanged, previousFocusEntityId, m_focusRoot);
|
||||
}
|
||||
|
||||
void FocusModeSystemComponent::ClearFocusRoot([[maybe_unused]] AzFramework::EntityContextId entityContextId)
|
||||
|
||||
@@ -244,6 +244,17 @@ namespace AzToolsFramework
|
||||
|
||||
const auto eventType = event->type();
|
||||
|
||||
if (eventType == QEvent::Type::MouseMove)
|
||||
{
|
||||
// clear override cursor when moving outside of the viewport
|
||||
const auto* mouseEvent = static_cast<const QMouseEvent*>(event);
|
||||
if (m_overrideCursor && !m_sourceWidget->geometry().contains(m_sourceWidget->mapFromGlobal(mouseEvent->globalPos())))
|
||||
{
|
||||
qApp->restoreOverrideCursor();
|
||||
m_overrideCursor = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Only accept mouse & key release events that originate from an object that is not our target widget,
|
||||
// as we don't want to erroneously intercept user input meant for another component.
|
||||
if (object != m_sourceWidget && eventType != QEvent::Type::KeyRelease && eventType != QEvent::Type::MouseButtonRelease)
|
||||
@@ -262,7 +273,7 @@ namespace AzToolsFramework
|
||||
if (eventType == QEvent::FocusIn)
|
||||
{
|
||||
const auto globalCursorPosition = QCursor::pos();
|
||||
if (m_sourceWidget->geometry().contains(globalCursorPosition))
|
||||
if (m_sourceWidget->geometry().contains(m_sourceWidget->mapFromGlobal(globalCursorPosition)))
|
||||
{
|
||||
HandleMouseMoveEvent(globalCursorPosition);
|
||||
}
|
||||
@@ -452,4 +463,32 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Qt::CursorShape QtCursorFromAzCursor(const ViewportInteraction::CursorStyleOverride cursorStyleOverride)
|
||||
{
|
||||
switch (cursorStyleOverride)
|
||||
{
|
||||
case ViewportInteraction::CursorStyleOverride::Forbidden:
|
||||
return Qt::ForbiddenCursor;
|
||||
default:
|
||||
return Qt::ArrowCursor;
|
||||
}
|
||||
}
|
||||
|
||||
void QtEventToAzInputMapper::SetOverrideCursor(ViewportInteraction::CursorStyleOverride cursorStyleOverride)
|
||||
{
|
||||
ClearOverrideCursor();
|
||||
|
||||
qApp->setOverrideCursor(QtCursorFromAzCursor(cursorStyleOverride));
|
||||
m_overrideCursor = true;
|
||||
}
|
||||
|
||||
void QtEventToAzInputMapper::ClearOverrideCursor()
|
||||
{
|
||||
if (m_overrideCursor)
|
||||
{
|
||||
qApp->restoreOverrideCursor();
|
||||
m_overrideCursor = false;
|
||||
}
|
||||
}
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
#include <AzFramework/Input/Channels/InputChannelDeltaWithSharedPosition2D.h>
|
||||
#include <AzFramework/Input/Channels/InputChannelDigitalWithSharedModifierKeyStates.h>
|
||||
#include <AzFramework/Input/Channels/InputChannelDigitalWithSharedPosition2D.h>
|
||||
|
||||
#include <AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h>
|
||||
#include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h>
|
||||
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
|
||||
#include <QEvent>
|
||||
#include <QObject>
|
||||
#include <QPoint>
|
||||
@@ -55,6 +56,9 @@ namespace AzToolsFramework
|
||||
//! like a dolly or rotation, where mouse movement is important but cursor location is not.
|
||||
void SetCursorCaptureEnabled(bool enabled);
|
||||
|
||||
void SetOverrideCursor(ViewportInteraction::CursorStyleOverride cursorStyleOverride);
|
||||
void ClearOverrideCursor();
|
||||
|
||||
// QObject overrides...
|
||||
bool eventFilter(QObject* object, QEvent* event) override;
|
||||
|
||||
@@ -164,6 +168,8 @@ namespace AzToolsFramework
|
||||
bool m_enabled = true;
|
||||
// Flags whether or not the cursor is being constrained to the source widget (for invisible mouse movement).
|
||||
bool m_capturingCursor = false;
|
||||
// Flags whether the cursor has been overridden.
|
||||
bool m_overrideCursor = false;
|
||||
|
||||
// Our viewport-specific AZ devices. We control their internal input channel states.
|
||||
AZStd::unique_ptr<EditorQtMouseDevice> m_mouseDevice;
|
||||
|
||||
@@ -1052,10 +1052,10 @@ namespace AzToolsFramework
|
||||
DuplicateNestedEntitiesInInstance(commonOwningInstance->get(),
|
||||
entities, instanceDomAfter, duplicatedEntityAndInstanceIds, duplicateEntityAliasMap);
|
||||
|
||||
PrefabUndoInstance* command = aznew PrefabUndoInstance("Entity/Instance duplication");
|
||||
PrefabUndoInstance* command = aznew PrefabUndoInstance("Entity/Instance duplication", false);
|
||||
command->SetParent(undoBatch.GetUndoBatch());
|
||||
command->Capture(instanceDomBefore, instanceDomAfter, commonOwningInstance->get().GetTemplateId());
|
||||
command->RedoBatched();
|
||||
command->Redo();
|
||||
|
||||
DuplicateNestedInstancesInInstance(commonOwningInstance->get(),
|
||||
instances, instanceDomAfter, duplicatedEntityAndInstanceIds, newInstanceAliasToOldInstanceMap);
|
||||
@@ -1323,7 +1323,7 @@ namespace AzToolsFramework
|
||||
Prefab::PrefabDom instanceDomAfter;
|
||||
m_instanceToTemplateInterface->GenerateDomForInstance(instanceDomAfter, parentInstance);
|
||||
|
||||
PrefabUndoInstance* command = aznew PrefabUndoInstance("Instance detachment");
|
||||
PrefabUndoInstance* command = aznew PrefabUndoInstance("Instance detachment", false);
|
||||
command->Capture(instanceDomBefore, instanceDomAfter, parentTemplateId);
|
||||
command->SetParent(undoBatch.GetUndoBatch());
|
||||
{
|
||||
|
||||
+26
-2
@@ -6,11 +6,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <API/ToolsApplicationAPI.h>
|
||||
#include <AzCore/Component/ComponentApplicationBus.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <Prefab/PrefabSystemComponentInterface.h>
|
||||
#include <Prefab/PrefabSystemScriptingHandler.h>
|
||||
#include <AzCore/Component/Entity.h>
|
||||
#include <Prefab/EditorPrefabComponent.h>
|
||||
#include <ToolsComponents/TransformComponent.h>
|
||||
|
||||
namespace AzToolsFramework::Prefab
|
||||
{
|
||||
@@ -61,9 +64,30 @@ namespace AzToolsFramework::Prefab
|
||||
entities.push_back(entity);
|
||||
}
|
||||
}
|
||||
|
||||
auto prefab = m_prefabSystemComponentInterface->CreatePrefab(entities, {}, AZ::IO::PathView(AZStd::string_view(filePath)));
|
||||
|
||||
bool result = false;
|
||||
[[maybe_unused]] AZ::EntityId commonRoot;
|
||||
EntityList topLevelEntities;
|
||||
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(result, &AzToolsFramework::ToolsApplicationRequestBus::Events::FindCommonRootInactive,
|
||||
entities, commonRoot, &topLevelEntities);
|
||||
|
||||
auto containerEntity = AZStd::make_unique<AZ::Entity>();
|
||||
containerEntity->CreateComponent<Prefab::EditorPrefabComponent>();
|
||||
|
||||
for (AZ::Entity* entity : topLevelEntities)
|
||||
{
|
||||
AzToolsFramework::Components::TransformComponent* transformComponent =
|
||||
entity->FindComponent<AzToolsFramework::Components::TransformComponent>();
|
||||
|
||||
if (transformComponent)
|
||||
{
|
||||
transformComponent->SetParent(containerEntity->GetId());
|
||||
}
|
||||
}
|
||||
|
||||
auto prefab = m_prefabSystemComponentInterface->CreatePrefab(
|
||||
entities, {}, AZ::IO::PathView(AZStd::string_view(filePath)), AZStd::move(containerEntity));
|
||||
|
||||
if (!prefab)
|
||||
{
|
||||
AZ_Error("PrefabSystemComponenent", false, "Failed to create prefab %s", filePath.c_str());
|
||||
|
||||
@@ -17,17 +17,16 @@ namespace AzToolsFramework
|
||||
{
|
||||
PrefabUndoBase::PrefabUndoBase(const AZStd::string& undoOperationName)
|
||||
: UndoSystem::URSequencePoint(undoOperationName)
|
||||
, m_changed(true)
|
||||
, m_templateId(InvalidTemplateId)
|
||||
{
|
||||
m_instanceToTemplateInterface = AZ::Interface<InstanceToTemplateInterface>::Get();
|
||||
AZ_Assert(m_instanceToTemplateInterface, "Failed to grab instance to template interface");
|
||||
}
|
||||
|
||||
//PrefabInstanceUndo
|
||||
PrefabUndoInstance::PrefabUndoInstance(const AZStd::string& undoOperationName)
|
||||
PrefabUndoInstance::PrefabUndoInstance(const AZStd::string& undoOperationName, const bool useImmediatePropagation)
|
||||
: PrefabUndoBase(undoOperationName)
|
||||
{
|
||||
m_useImmediatePropagation = useImmediatePropagation;
|
||||
}
|
||||
|
||||
void PrefabUndoInstance::Capture(
|
||||
@@ -43,17 +42,12 @@ namespace AzToolsFramework
|
||||
|
||||
void PrefabUndoInstance::Undo()
|
||||
{
|
||||
m_instanceToTemplateInterface->PatchTemplate(m_undoPatch, m_templateId, true);
|
||||
m_instanceToTemplateInterface->PatchTemplate(m_undoPatch, m_templateId, m_useImmediatePropagation);
|
||||
}
|
||||
|
||||
void PrefabUndoInstance::Redo()
|
||||
{
|
||||
m_instanceToTemplateInterface->PatchTemplate(m_redoPatch, m_templateId, true);
|
||||
}
|
||||
|
||||
void PrefabUndoInstance::RedoBatched()
|
||||
{
|
||||
m_instanceToTemplateInterface->PatchTemplate(m_redoPatch, m_templateId);
|
||||
m_instanceToTemplateInterface->PatchTemplate(m_redoPatch, m_templateId, m_useImmediatePropagation);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,14 +29,15 @@ namespace AzToolsFramework
|
||||
bool Changed() const override { return m_changed; }
|
||||
|
||||
protected:
|
||||
TemplateId m_templateId;
|
||||
TemplateId m_templateId = InvalidTemplateId;
|
||||
|
||||
PrefabDom m_redoPatch;
|
||||
PrefabDom m_undoPatch;
|
||||
|
||||
InstanceToTemplateInterface* m_instanceToTemplateInterface = nullptr;
|
||||
|
||||
bool m_changed;
|
||||
bool m_changed = true;
|
||||
bool m_useImmediatePropagation = true;
|
||||
};
|
||||
|
||||
//! handles the addition and removal of entities from instances
|
||||
@@ -44,7 +45,7 @@ namespace AzToolsFramework
|
||||
: public PrefabUndoBase
|
||||
{
|
||||
public:
|
||||
explicit PrefabUndoInstance(const AZStd::string& undoOperationName);
|
||||
explicit PrefabUndoInstance(const AZStd::string& undoOperationName, const bool useImmediatePropagation = true);
|
||||
|
||||
void Capture(
|
||||
const PrefabDom& initialState,
|
||||
@@ -53,7 +54,6 @@ namespace AzToolsFramework
|
||||
|
||||
void Undo() override;
|
||||
void Redo() override;
|
||||
void RedoBatched();
|
||||
};
|
||||
|
||||
//! handles entity updates, such as when the values on an entity change
|
||||
|
||||
@@ -23,10 +23,10 @@ namespace AzToolsFramework
|
||||
PrefabDom instanceDomAfterUpdate;
|
||||
PrefabDomUtils::StoreInstanceInPrefabDom(instance, instanceDomAfterUpdate);
|
||||
|
||||
PrefabUndoInstance* state = aznew Prefab::PrefabUndoInstance(undoMessage);
|
||||
PrefabUndoInstance* state = aznew Prefab::PrefabUndoInstance(undoMessage, false);
|
||||
state->Capture(instanceDomBeforeUpdate, instanceDomAfterUpdate, instance.GetTemplateId());
|
||||
state->SetParent(undoBatch);
|
||||
state->RedoBatched();
|
||||
state->Redo();
|
||||
}
|
||||
|
||||
LinkId CreateLink(
|
||||
|
||||
@@ -66,7 +66,16 @@ namespace AzToolsFramework
|
||||
|
||||
bool Template::IsValid() const
|
||||
{
|
||||
return !m_prefabDom.IsNull() && !m_filePath.empty();
|
||||
if (m_prefabDom.IsNull() || m_filePath.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!m_prefabDom.IsObject())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auto source = m_prefabDom.FindMember(PrefabDomUtils::SourceName);
|
||||
return (source != m_prefabDom.MemberEnd());
|
||||
}
|
||||
|
||||
bool Template::IsLoadedWithErrors() const
|
||||
@@ -175,6 +184,26 @@ namespace AzToolsFramework
|
||||
return findInstancesResult->get();
|
||||
}
|
||||
|
||||
bool Template::IsProcedural() const
|
||||
{
|
||||
if (m_isProcedural.has_value())
|
||||
{
|
||||
return m_isProcedural.value();
|
||||
}
|
||||
else if (!IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auto source = m_prefabDom.FindMember(PrefabDomUtils::SourceName);
|
||||
if (!source->value.IsString())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
AZ::IO::PathView path(source->value.GetString());
|
||||
m_isProcedural = AZStd::make_optional(path.Extension().Match(".procprefab"));
|
||||
return m_isProcedural.value();
|
||||
}
|
||||
|
||||
const AZ::IO::Path& Template::GetFilePath() const
|
||||
{
|
||||
return m_filePath;
|
||||
|
||||
@@ -65,6 +65,9 @@ namespace AzToolsFramework
|
||||
const AZ::IO::Path& GetFilePath() const;
|
||||
void SetFilePath(const AZ::IO::PathView& path);
|
||||
|
||||
// To tell if this Template was created from an product asset
|
||||
bool IsProcedural() const;
|
||||
|
||||
private:
|
||||
// Container for keeping links representing the Template's nested instances.
|
||||
Links m_links;
|
||||
@@ -80,6 +83,9 @@ namespace AzToolsFramework
|
||||
|
||||
// Flag to tell if this Template has changes that have yet to be saved to file.
|
||||
bool m_isDirty = false;
|
||||
|
||||
// Flag to tell if this Template was generated outside the Editor
|
||||
mutable AZStd::optional<bool> m_isProcedural;
|
||||
};
|
||||
} // namespace Prefab
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <AzCore/Component/EntityId.h>
|
||||
#include <AzQtComponents/Components/ToastNotificationConfiguration.h>
|
||||
|
||||
#include <QPoint>
|
||||
#endif
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
typedef AZ::EntityId ToastId;
|
||||
|
||||
/**
|
||||
* An EBus for receiving notifications when a user interacts with or dismisses
|
||||
* a toast notification.
|
||||
*/
|
||||
class ToastNotifications
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
|
||||
using BusIdType = ToastId;
|
||||
|
||||
virtual void OnToastInteraction() {}
|
||||
virtual void OnToastDismissed() {}
|
||||
};
|
||||
|
||||
using ToastNotificationBus = AZ::EBus<ToastNotifications>;
|
||||
|
||||
typedef AZ::u32 ToastRequestBusId;
|
||||
|
||||
/**
|
||||
* An EBus used to hide or show toast notifications. Generally, these request are handled by a
|
||||
* ToastNotificationsView that has been created with a specific ToastRequestBusId
|
||||
* e.g. AZ_CRC("ExampleToastNotificationView")
|
||||
*/
|
||||
class ToastRequests
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
|
||||
using BusIdType = ToastRequestBusId; // bus is addressed by CRC of the view name
|
||||
|
||||
/**
|
||||
* Hide a toast notification widget.
|
||||
*
|
||||
* @param toastId The toast notification's ToastId
|
||||
*/
|
||||
virtual void HideToastNotification(const ToastId& toastId) = 0;
|
||||
|
||||
/**
|
||||
* Show a toast notification with the specified toast configuration. When handled by a ToastNotificationsView,
|
||||
* notifications are queued and presented to the user in sequence.
|
||||
*
|
||||
* @param toastConfiguration The toast configuration
|
||||
* @return a ToastId
|
||||
*/
|
||||
virtual ToastId ShowToastNotification(const AzQtComponents::ToastConfiguration& toastConfiguration) = 0;
|
||||
|
||||
/**
|
||||
* Show a toast notification with the specified toast configuration at the current moust cursor location.
|
||||
*
|
||||
* @param toastConfiguration The toast configuration
|
||||
* @return a ToastId
|
||||
*/
|
||||
virtual ToastId ShowToastAtCursor(const AzQtComponents::ToastConfiguration& toastConfiguration) = 0;
|
||||
|
||||
/**
|
||||
* Show a toast notification with the specified toast configuration at the specified location.
|
||||
*
|
||||
* @param screenPosition The screen position
|
||||
* @param anchorPoint The anchorPoint for the toast notification widget
|
||||
* @param toastConfiguration The toast configuration
|
||||
* @return a ToastId
|
||||
*/
|
||||
virtual ToastId ShowToastAtPoint(const QPoint& screenPosition, const QPointF& anchorPoint, const AzQtComponents::ToastConfiguration&) = 0;
|
||||
};
|
||||
|
||||
using ToastRequestBus = AZ::EBus<ToastRequests>;
|
||||
}
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* 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/UI/Notifications/ToastNotificationsView.h>
|
||||
#include <AzQtComponents/Components/ToastNotification.h>
|
||||
#include <AzCore/Component/Entity.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/std/functional.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
ToastNotificationsView::ToastNotificationsView(QWidget* parent, ToastRequestBusId busId)
|
||||
: QWidget(parent)
|
||||
{
|
||||
ToastRequestBus::Handler::BusConnect(busId);
|
||||
}
|
||||
|
||||
ToastNotificationsView::~ToastNotificationsView()
|
||||
{
|
||||
ToastRequestBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void ToastNotificationsView::OnHide()
|
||||
{
|
||||
QWidget::hide();
|
||||
|
||||
if (m_activeNotification.IsValid())
|
||||
{
|
||||
auto notificationIter = m_notifications.find(m_activeNotification);
|
||||
if (notificationIter != m_notifications.end())
|
||||
{
|
||||
notificationIter->second->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ToastNotificationsView::UpdateToastPosition()
|
||||
{
|
||||
if (m_activeNotification.IsValid())
|
||||
{
|
||||
auto notificationIter = m_notifications.find(m_activeNotification);
|
||||
if (notificationIter != m_notifications.end())
|
||||
{
|
||||
notificationIter->second->UpdatePosition(GetGlobalPoint(), m_anchorPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ToastNotificationsView::OnShow()
|
||||
{
|
||||
QWidget::show();
|
||||
|
||||
if (m_activeNotification.IsValid() || !m_queuedNotifications.empty())
|
||||
{
|
||||
DisplayQueuedNotification();
|
||||
}
|
||||
}
|
||||
|
||||
ToastId ToastNotificationsView::ShowToastNotification(const AzQtComponents::ToastConfiguration& toastConfiguration)
|
||||
{
|
||||
ToastId toastId = CreateToastNotification(toastConfiguration);
|
||||
m_queuedNotifications.emplace_back(toastId);
|
||||
|
||||
if (!m_activeNotification.IsValid())
|
||||
{
|
||||
DisplayQueuedNotification();
|
||||
}
|
||||
|
||||
return toastId;
|
||||
}
|
||||
|
||||
ToastId ToastNotificationsView::ShowToastAtCursor(const AzQtComponents::ToastConfiguration& toastConfiguration)
|
||||
{
|
||||
ToastId toastId = CreateToastNotification(toastConfiguration);
|
||||
m_notifications[toastId]->ShowToastAtCursor();
|
||||
return toastId;
|
||||
}
|
||||
|
||||
ToastId ToastNotificationsView::ShowToastAtPoint(const QPoint& screenPosition, const QPointF& anchorPoint, const AzQtComponents::ToastConfiguration& toastConfiguration)
|
||||
{
|
||||
ToastId toastId = CreateToastNotification(toastConfiguration);
|
||||
m_notifications[toastId]->ShowToastAtPoint(screenPosition, anchorPoint);
|
||||
return toastId;
|
||||
}
|
||||
|
||||
void ToastNotificationsView::HideToastNotification(const ToastId& toastId)
|
||||
{
|
||||
auto notificationIter = m_notifications.find(toastId);
|
||||
if (notificationIter != m_notifications.end())
|
||||
{
|
||||
auto queuedIter = AZStd::find(m_queuedNotifications.begin(), m_queuedNotifications.end(), toastId);
|
||||
if (queuedIter != m_queuedNotifications.end())
|
||||
{
|
||||
m_queuedNotifications.erase(queuedIter);
|
||||
}
|
||||
|
||||
notificationIter->second->reject();
|
||||
}
|
||||
}
|
||||
|
||||
ToastId ToastNotificationsView::CreateToastNotification(const AzQtComponents::ToastConfiguration& toastConfiguration)
|
||||
{
|
||||
AzQtComponents::ToastNotification* notification = aznew AzQtComponents::ToastNotification(parentWidget(), toastConfiguration);
|
||||
ToastId toastId = AZ::Entity::MakeId();
|
||||
m_notifications[toastId] = notification;
|
||||
|
||||
QObject::connect(
|
||||
m_notifications[toastId], &AzQtComponents::ToastNotification::ToastNotificationHidden,
|
||||
[toastId]()
|
||||
{
|
||||
ToastNotificationBus::Event(toastId, &ToastNotificationBus::Events::OnToastDismissed);
|
||||
});
|
||||
|
||||
QObject::connect(
|
||||
m_notifications[toastId], &AzQtComponents::ToastNotification::ToastNotificationInteraction,
|
||||
[toastId]()
|
||||
{
|
||||
ToastNotificationBus::Event(toastId, &ToastNotificationBus::Events::OnToastInteraction);
|
||||
});
|
||||
|
||||
return toastId;
|
||||
}
|
||||
|
||||
QPoint ToastNotificationsView::GetGlobalPoint()
|
||||
{
|
||||
QPoint relativePoint = m_offset;
|
||||
|
||||
AZ_Assert(parentWidget(), "ToastNotificationsView has invalid parent QWidget");
|
||||
if (m_anchorPoint.x() == 1.0)
|
||||
{
|
||||
relativePoint.setX(parentWidget()->width() - m_offset.x());
|
||||
}
|
||||
if (m_anchorPoint.y() == 1.0)
|
||||
{
|
||||
relativePoint.setY(parentWidget()->height() - m_offset.y());
|
||||
}
|
||||
|
||||
return parentWidget()->mapToGlobal(relativePoint);
|
||||
}
|
||||
|
||||
void ToastNotificationsView::DisplayQueuedNotification()
|
||||
{
|
||||
AZ_Assert(parentWidget(), "ToastNotificationsView has invalid parent QWidget");
|
||||
if (m_queuedNotifications.empty() || !parentWidget()->isVisible() || !isVisible())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ToastId toastId = m_queuedNotifications.front();
|
||||
m_queuedNotifications.erase(m_queuedNotifications.begin());
|
||||
|
||||
auto notificationIter = m_notifications.find(toastId);
|
||||
if (notificationIter != m_notifications.end())
|
||||
{
|
||||
m_activeNotification = toastId;
|
||||
|
||||
notificationIter->second->ShowToastAtPoint(GetGlobalPoint(), m_anchorPoint);
|
||||
|
||||
QObject::connect(
|
||||
notificationIter->second, &AzQtComponents::ToastNotification::ToastNotificationHidden,
|
||||
[&]()
|
||||
{
|
||||
m_activeNotification.SetInvalid();
|
||||
DisplayQueuedNotification();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// If we didn't actually show something, recurse to avoid things getting stuck in the queue.
|
||||
if (!m_activeNotification.IsValid())
|
||||
{
|
||||
DisplayQueuedNotification();
|
||||
}
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QWidget>
|
||||
#include <QPoint>
|
||||
#include <QPointF>
|
||||
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <AzCore/std/containers/unordered_map.h>
|
||||
#include <AzToolsFramework/UI/Notifications/ToastBus.h>
|
||||
#endif
|
||||
|
||||
namespace AzQtComponents
|
||||
{
|
||||
class ToastNotification;
|
||||
}
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
/**
|
||||
* \brief A QWidget that displays and manages a queue of toast notifications.
|
||||
*
|
||||
* This view must be updated by its parent when the parent widget is show, hidden, moved
|
||||
* or resized because toast notifications are displayed on top of the parent and are not part
|
||||
* of the layout, so they must be manually moved.
|
||||
*/
|
||||
class ToastNotificationsView final
|
||||
: public QWidget
|
||||
, protected ToastRequestBus::Handler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ToastNotificationsView(QWidget* parent, ToastRequestBusId busId);
|
||||
~ToastNotificationsView() override;
|
||||
|
||||
void HideToastNotification(const ToastId& toastId) override;
|
||||
|
||||
ToastId ShowToastNotification(const AzQtComponents::ToastConfiguration& toastConfiguration) override;
|
||||
ToastId ShowToastAtCursor(const AzQtComponents::ToastConfiguration& toastConfiguration) override;
|
||||
ToastId ShowToastAtPoint(const QPoint& screenPosition, const QPointF& anchorPoint, const AzQtComponents::ToastConfiguration&) override;
|
||||
|
||||
void OnHide();
|
||||
void OnShow();
|
||||
void UpdateToastPosition();
|
||||
|
||||
private:
|
||||
ToastId CreateToastNotification(const AzQtComponents::ToastConfiguration& toastConfiguration);
|
||||
void DisplayQueuedNotification();
|
||||
QPoint GetGlobalPoint();
|
||||
|
||||
ToastId m_activeNotification;
|
||||
AZStd::unordered_map<ToastId, AzQtComponents::ToastNotification*> m_notifications;
|
||||
AZStd::vector<ToastId> m_queuedNotifications;
|
||||
|
||||
QPoint m_offset = QPoint(10, 10);
|
||||
QPointF m_anchorPoint = QPointF(1, 0);
|
||||
};
|
||||
} // AzToolsFramework
|
||||
+26
-29
@@ -119,6 +119,12 @@ namespace AzToolsFramework
|
||||
|
||||
int EntityOutlinerListModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
// For QTreeView models, non-0 columns shouldn't have children
|
||||
if (parent.isValid() && parent.column() != 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto parentId = GetEntityFromIndex(parent);
|
||||
|
||||
AZStd::size_t childCount = 0;
|
||||
@@ -133,17 +139,13 @@ namespace AzToolsFramework
|
||||
|
||||
QModelIndex EntityOutlinerListModel::index(int row, int column, const QModelIndex& parent) const
|
||||
{
|
||||
// sanity check
|
||||
if (!hasIndex(row, column, parent) || (parent.isValid() && parent.column() != 0) || (row < 0 || row >= rowCount(parent)))
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
auto parentId = GetEntityFromIndex(parent);
|
||||
|
||||
// We have the row and column, so we just need the child ID to construct our index
|
||||
AZ::EntityId childId;
|
||||
EditorEntityInfoRequestBus::EventResult(childId, parentId, &EditorEntityInfoRequestBus::Events::GetChild, row);
|
||||
return GetIndexFromEntity(childId, column);
|
||||
AZ_Assert(childId.IsValid(), "No child found for parent");
|
||||
return createIndex(row, column, static_cast<AZ::u64>(childId));
|
||||
}
|
||||
|
||||
QVariant EntityOutlinerListModel::data(const QModelIndex& index, int role) const
|
||||
@@ -517,13 +519,18 @@ namespace AzToolsFramework
|
||||
{
|
||||
AZ::EntityId parentId;
|
||||
EditorEntityInfoRequestBus::EventResult(parentId, id, &EditorEntityInfoRequestBus::Events::GetParent);
|
||||
return GetIndexFromEntity(parentId, index.column());
|
||||
return GetIndexFromEntity(parentId, 0);
|
||||
}
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
Qt::ItemFlags EntityOutlinerListModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
{
|
||||
return Qt::ItemIsDropEnabled;
|
||||
}
|
||||
|
||||
Qt::ItemFlags itemFlags = QAbstractItemModel::flags(index);
|
||||
switch (index.column())
|
||||
{
|
||||
@@ -1208,6 +1215,10 @@ namespace AzToolsFramework
|
||||
void EntityOutlinerListModel::ProcessEntityUpdates()
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(Editor);
|
||||
if (!m_entityChangeQueued)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_entityChangeQueued = false;
|
||||
if (m_layoutResetQueued)
|
||||
{
|
||||
@@ -1236,31 +1247,14 @@ namespace AzToolsFramework
|
||||
{
|
||||
AZ_PROFILE_SCOPE(Editor, "EntityOutlinerListModel::ProcessEntityUpdates:ChangeQueue");
|
||||
|
||||
// its faster to just do a bulk data change than to carefully pick out indices
|
||||
// so we'll just merge all ranges into a single range rather than try to make gaps
|
||||
QModelIndex firstChangeIndex;
|
||||
QModelIndex lastChangeIndex;
|
||||
|
||||
for (auto entityId : m_entityChangeQueue)
|
||||
{
|
||||
auto myIndex = GetIndexFromEntity(entityId, ColumnName);
|
||||
if ((!firstChangeIndex.isValid())||(firstChangeIndex.row() > myIndex.row()))
|
||||
if (entityId.IsValid())
|
||||
{
|
||||
firstChangeIndex = myIndex;
|
||||
const QModelIndex beginIndex = GetIndexFromEntity(entityId, ColumnName);
|
||||
const QModelIndex endIndex = createIndex(beginIndex.row(), VisibleColumnCount - 1, beginIndex.internalId());
|
||||
emit dataChanged(beginIndex, endIndex);
|
||||
}
|
||||
|
||||
if ((!lastChangeIndex.isValid())||(lastChangeIndex.row() < myIndex.row()))
|
||||
{
|
||||
// expand it to be the last column:
|
||||
lastChangeIndex = myIndex;
|
||||
}
|
||||
}
|
||||
|
||||
if (firstChangeIndex.isValid())
|
||||
{
|
||||
// expand to cover all visible columns:
|
||||
lastChangeIndex = createIndex(lastChangeIndex.row(), VisibleColumnCount - 1, lastChangeIndex.internalPointer());
|
||||
emit dataChanged(firstChangeIndex, lastChangeIndex);
|
||||
}
|
||||
|
||||
m_entityChangeQueue.clear();
|
||||
@@ -1382,6 +1376,9 @@ namespace AzToolsFramework
|
||||
m_isFilterDirty = true;
|
||||
QueueAncestorUpdate(parentId);
|
||||
emit EnableSelectionUpdates(true);
|
||||
|
||||
// Remove any pending updates for this removed entity.
|
||||
m_entityChangeQueue.erase(childId);
|
||||
}
|
||||
|
||||
void EntityOutlinerListModel::OnEntityInfoUpdatedOrderBegin(AZ::EntityId parentId, AZ::EntityId childId, AZ::u64 index)
|
||||
|
||||
+2
-1
@@ -145,6 +145,8 @@ namespace AzToolsFramework
|
||||
|
||||
void SetSortMode(EntityOutliner::DisplaySortMode sortMode) { m_sortMode = sortMode; }
|
||||
void SetDropOperationInProgress(bool inProgress);
|
||||
void ProcessEntityUpdates();
|
||||
|
||||
Q_SIGNALS:
|
||||
void ExpandEntity(const AZ::EntityId& entityId, bool expand);
|
||||
void SelectEntity(const AZ::EntityId& entityId, bool select);
|
||||
@@ -178,7 +180,6 @@ namespace AzToolsFramework
|
||||
void QueueEntityUpdate(AZ::EntityId entityId);
|
||||
void QueueAncestorUpdate(AZ::EntityId entityId);
|
||||
void QueueEntityToExpand(AZ::EntityId entityId, bool expand);
|
||||
void ProcessEntityUpdates();
|
||||
void ProcessEntityInfoResetEnd();
|
||||
AZStd::unordered_set<AZ::EntityId> m_entitySelectQueue;
|
||||
AZStd::unordered_set<AZ::EntityId> m_entityExpandQueue;
|
||||
|
||||
+1
-8
@@ -766,15 +766,8 @@ namespace AzToolsFramework
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
outPrefabAssetPath = product->GetRelativePath();
|
||||
|
||||
auto asset = AZ::Data::AssetManager::Instance().GetAsset(
|
||||
product->GetAssetId(),
|
||||
azrtti_typeid<AZ::Prefab::ProceduralPrefabAsset>(),
|
||||
AZ::Data::AssetLoadBehavior::Default);
|
||||
|
||||
return asset.BlockUntilLoadComplete() != AZ::Data::AssetData::AssetStatus::Error;
|
||||
return true;
|
||||
}
|
||||
|
||||
void PrefabIntegrationManager::WarnUserOfError(AZStd::string_view title, AZStd::string_view message)
|
||||
|
||||
@@ -198,6 +198,8 @@ namespace AzToolsFramework
|
||||
virtual float ManipulatorCircleBoundWidth() const = 0;
|
||||
//! Returns if sticky select is enabled or not.
|
||||
virtual bool StickySelectEnabled() const = 0;
|
||||
//! Returns the default viewport camera position.
|
||||
virtual AZ::Vector3 DefaultEditorCameraPosition() const = 0;
|
||||
|
||||
protected:
|
||||
~ViewportSettingsRequests() = default;
|
||||
@@ -300,6 +302,12 @@ namespace AzToolsFramework
|
||||
|
||||
using EditorViewportInputTimeNowRequestBus = AZ::EBus<EditorViewportInputTimeNowRequests>;
|
||||
|
||||
//! The style of cursor override.
|
||||
enum class CursorStyleOverride
|
||||
{
|
||||
Forbidden
|
||||
};
|
||||
|
||||
//! Viewport requests for managing the viewport cursor state.
|
||||
class ViewportMouseCursorRequests
|
||||
{
|
||||
@@ -310,6 +318,10 @@ namespace AzToolsFramework
|
||||
virtual void EndCursorCapture() = 0;
|
||||
//! Is the mouse over the viewport.
|
||||
virtual bool IsMouseOver() const = 0;
|
||||
//! Set the cursor style override.
|
||||
virtual void SetOverrideCursor(CursorStyleOverride cursorStyleOverride) = 0;
|
||||
//! Clear the cursor style override.
|
||||
virtual void ClearOverrideCursor() = 0;
|
||||
|
||||
protected:
|
||||
~ViewportMouseCursorRequests() = default;
|
||||
|
||||
+75
-11
@@ -9,6 +9,7 @@
|
||||
#include "EditorHelpers.h"
|
||||
|
||||
#include <AzCore/Console/Console.h>
|
||||
#include <AzCore/Math/VectorConversions.h>
|
||||
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
|
||||
#include <AzFramework/Viewport/CameraState.h>
|
||||
#include <AzFramework/Viewport/ViewportScreen.h>
|
||||
@@ -43,6 +44,13 @@ AZ_CVAR(
|
||||
nullptr,
|
||||
AZ::ConsoleFunctorFlags::Null,
|
||||
"Display the aggregate world bounds for a given entity (the union of all world component Aabbs)");
|
||||
AZ_CVAR(
|
||||
bool,
|
||||
ed_useCursorLockIconInFocusMode,
|
||||
false,
|
||||
nullptr,
|
||||
AZ::ConsoleFunctorFlags::Null,
|
||||
"Use a lock icon when the cursor is over entities that cannot be interacted with");
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -114,6 +122,33 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
CursorEntityIdQuery::CursorEntityIdQuery(AZ::EntityId entityId, AZ::EntityId rootEntityId)
|
||||
: m_entityId(entityId)
|
||||
, m_containerAncestorEntityId(rootEntityId)
|
||||
{
|
||||
}
|
||||
|
||||
AZ::EntityId CursorEntityIdQuery::EntityIdUnderCursor() const
|
||||
{
|
||||
return m_entityId;
|
||||
}
|
||||
|
||||
AZ::EntityId CursorEntityIdQuery::ContainerAncestorEntityId() const
|
||||
{
|
||||
return m_containerAncestorEntityId;
|
||||
}
|
||||
|
||||
bool CursorEntityIdQuery::HasContainerAncestorEntityId() const
|
||||
{
|
||||
if (m_entityId.IsValid())
|
||||
{
|
||||
return m_entityId != m_containerAncestorEntityId;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
EditorHelpers::EditorHelpers(const EditorVisibleEntityDataCache* entityDataCache)
|
||||
: m_entityDataCache(entityDataCache)
|
||||
{
|
||||
@@ -123,9 +158,14 @@ namespace AzToolsFramework
|
||||
"EditorHelpers - "
|
||||
"Focus Mode Interface could not be found. "
|
||||
"Check that it is being correctly initialized.");
|
||||
|
||||
AZStd::vector<AZStd::unique_ptr<InvalidClick>> invalidClicks;
|
||||
invalidClicks.push_back(AZStd::make_unique<FadingText>("Not in focus"));
|
||||
invalidClicks.push_back(AZStd::make_unique<ExpandingFadingCircles>());
|
||||
m_invalidClicks = AZStd::make_unique<InvalidClicks>(AZStd::move(invalidClicks));
|
||||
}
|
||||
|
||||
AZ::EntityId EditorHelpers::HandleMouseInteraction(
|
||||
CursorEntityIdQuery EditorHelpers::FindEntityIdUnderCursor(
|
||||
const AzFramework::CameraState& cameraState, const ViewportInteraction::MouseInteractionEvent& mouseInteraction)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AzToolsFramework);
|
||||
@@ -186,20 +226,44 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
// Verify if the entity Id corresponds to an entity that is focused; if not, halt selection.
|
||||
if (!IsSelectableAccordingToFocusMode(entityIdUnderCursor))
|
||||
// verify if the entity Id corresponds to an entity that is focused; if not, halt selection.
|
||||
if (entityIdUnderCursor.IsValid() && !IsSelectableAccordingToFocusMode(entityIdUnderCursor))
|
||||
{
|
||||
return AZ::EntityId();
|
||||
if (ed_useCursorLockIconInFocusMode)
|
||||
{
|
||||
ViewportInteraction::ViewportMouseCursorRequestBus::Event(
|
||||
viewportId, &ViewportInteraction::ViewportMouseCursorRequestBus::Events::SetOverrideCursor,
|
||||
ViewportInteraction::CursorStyleOverride::Forbidden);
|
||||
}
|
||||
|
||||
if (mouseInteraction.m_mouseInteraction.m_mouseButtons.Left() &&
|
||||
mouseInteraction.m_mouseEvent == ViewportInteraction::MouseEvent::Down ||
|
||||
mouseInteraction.m_mouseEvent == ViewportInteraction::MouseEvent::DoubleClick)
|
||||
{
|
||||
m_invalidClicks->AddInvalidClick(mouseInteraction.m_mouseInteraction.m_mousePick.m_screenCoordinates);
|
||||
}
|
||||
|
||||
return CursorEntityIdQuery(AZ::EntityId(), AZ::EntityId());
|
||||
}
|
||||
|
||||
// Container Entity support - if the entity that is being selected is part of a closed container,
|
||||
ViewportInteraction::ViewportMouseCursorRequestBus::Event(
|
||||
viewportId, &ViewportInteraction::ViewportMouseCursorRequestBus::Events::ClearOverrideCursor);
|
||||
|
||||
// container entity support - if the entity that is being selected is part of a closed container,
|
||||
// change the selection to the container instead.
|
||||
if (ContainerEntityInterface* containerEntityInterface = AZ::Interface<ContainerEntityInterface>::Get())
|
||||
{
|
||||
return containerEntityInterface->FindHighestSelectableEntity(entityIdUnderCursor);
|
||||
const auto highestSelectableEntity = containerEntityInterface->FindHighestSelectableEntity(entityIdUnderCursor);
|
||||
return CursorEntityIdQuery(entityIdUnderCursor, highestSelectableEntity);
|
||||
}
|
||||
|
||||
return entityIdUnderCursor;
|
||||
return CursorEntityIdQuery(entityIdUnderCursor, AZ::EntityId());
|
||||
}
|
||||
|
||||
void EditorHelpers::Display2d(
|
||||
[[maybe_unused]] const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay)
|
||||
{
|
||||
m_invalidClicks->Display2d(viewportInfo, debugDisplay);
|
||||
}
|
||||
|
||||
void EditorHelpers::DisplayHelpers(
|
||||
@@ -263,19 +327,19 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
bool EditorHelpers::IsSelectableInViewport(AZ::EntityId entityId)
|
||||
bool EditorHelpers::IsSelectableInViewport(const AZ::EntityId entityId) const
|
||||
{
|
||||
return IsSelectableAccordingToFocusMode(entityId) && IsSelectableAccordingToContainerEntities(entityId);
|
||||
}
|
||||
|
||||
bool EditorHelpers::IsSelectableAccordingToFocusMode(AZ::EntityId entityId)
|
||||
bool EditorHelpers::IsSelectableAccordingToFocusMode(const AZ::EntityId entityId) const
|
||||
{
|
||||
return m_focusModeInterface->IsInFocusSubTree(entityId);
|
||||
}
|
||||
|
||||
bool EditorHelpers::IsSelectableAccordingToContainerEntities(AZ::EntityId entityId)
|
||||
bool EditorHelpers::IsSelectableAccordingToContainerEntities(const AZ::EntityId entityId) const
|
||||
{
|
||||
if (ContainerEntityInterface* containerEntityInterface = AZ::Interface<ContainerEntityInterface>::Get())
|
||||
if (const auto* containerEntityInterface = AZ::Interface<ContainerEntityInterface>::Get())
|
||||
{
|
||||
return !containerEntityInterface->IsUnderClosedContainerEntity(entityId);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
#include <AzCore/Component/EntityId.h>
|
||||
#include <AzCore/Memory/Memory.h>
|
||||
#include <AzCore/std/functional.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <AzFramework/Viewport/ScreenGeometry.h>
|
||||
#include <AzToolsFramework/ViewportSelection/InvalidClicks.h>
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
@@ -29,6 +32,28 @@ namespace AzToolsFramework
|
||||
struct MouseInteractionEvent;
|
||||
}
|
||||
|
||||
//!< Represents the result of a query to find the id of the entity under the cursor (if any).
|
||||
class CursorEntityIdQuery
|
||||
{
|
||||
public:
|
||||
CursorEntityIdQuery(AZ::EntityId entityId, AZ::EntityId rootEntityId);
|
||||
|
||||
//! Returns the entity id under the cursor (if any).
|
||||
//! @note In the case of no entity id under the cursor, an invalid entity id is returned.
|
||||
AZ::EntityId EntityIdUnderCursor() const;
|
||||
|
||||
//! Returns the topmost container entity id in the hierarchy if the entity id under the cursor is inside a container entity, otherwise returns the entity id.
|
||||
//! @note In the case of no entity id under the cursor, an invalid entity id is returned.
|
||||
AZ::EntityId ContainerAncestorEntityId() const;
|
||||
|
||||
//! Returns true if the query has a container ancestor entity id, otherwise false.
|
||||
bool HasContainerAncestorEntityId() const;
|
||||
|
||||
private:
|
||||
AZ::EntityId m_entityId; //<! The entity id under the cursor.
|
||||
AZ::EntityId m_containerAncestorEntityId; //<! For entities in container entities, the topmost container entity id in the hierarchy, otherwise the entity id under the cursor.
|
||||
};
|
||||
|
||||
//! EditorHelpers are the visualizations that appear for entities
|
||||
//! when 'Display Helpers' is toggled on inside the editor.
|
||||
//! These include but are not limited to entity icons and shape visualizations.
|
||||
@@ -44,9 +69,9 @@ namespace AzToolsFramework
|
||||
EditorHelpers& operator=(const EditorHelpers&) = delete;
|
||||
~EditorHelpers() = default;
|
||||
|
||||
//! Handle any mouse interaction with the EditorHelpers.
|
||||
//! Finds the id of the entity under the cursor (if any). For entities in container entities, also finds the topmost container entity id in the hierarchy.
|
||||
//! Used to check if a particular entity was selected.
|
||||
AZ::EntityId HandleMouseInteraction(
|
||||
CursorEntityIdQuery FindEntityIdUnderCursor(
|
||||
const AzFramework::CameraState& cameraState, const ViewportInteraction::MouseInteractionEvent& mouseInteraction);
|
||||
|
||||
//! Do the drawing responsible for the EditorHelpers.
|
||||
@@ -58,20 +83,27 @@ namespace AzToolsFramework
|
||||
AzFramework::DebugDisplayRequests& debugDisplay,
|
||||
const AZStd::function<bool(AZ::EntityId)>& showIconCheck);
|
||||
|
||||
//! Handle 2d drawing for EditorHelper functionality.
|
||||
void Display2d(
|
||||
const AzFramework::ViewportInfo& viewportInfo,
|
||||
AzFramework::DebugDisplayRequests& debugDisplay);
|
||||
|
||||
//! Returns whether the entityId can be selected in the viewport according
|
||||
//! to the current Editor Focus Mode and Container Entity setup.
|
||||
bool IsSelectableInViewport(AZ::EntityId entityId);
|
||||
bool IsSelectableInViewport(AZ::EntityId entityId) const;
|
||||
|
||||
private:
|
||||
//! Returns whether the entityId can be selected in the viewport according
|
||||
//! to the current Editor Focus Mode setup.
|
||||
bool IsSelectableAccordingToFocusMode(AZ::EntityId entityId);
|
||||
bool IsSelectableAccordingToFocusMode(AZ::EntityId entityId) const;
|
||||
|
||||
//! Returns whether the entityId can be selected in the viewport according
|
||||
//! to the current Container Entityu setup.
|
||||
bool IsSelectableAccordingToContainerEntities(AZ::EntityId entityId);
|
||||
//! to the current Container Entity setup.
|
||||
bool IsSelectableAccordingToContainerEntities(AZ::EntityId entityId) const;
|
||||
|
||||
AZStd::unique_ptr<InvalidClicks> m_invalidClicks; //!< Display for invalid click behavior.
|
||||
|
||||
const EditorVisibleEntityDataCache* m_entityDataCache = nullptr; //!< Entity Data queried by the EditorHelpers.
|
||||
const FocusModeInterface* m_focusModeInterface = nullptr;
|
||||
const FocusModeInterface* m_focusModeInterface = nullptr; //!< API to interact with focus mode functionality.
|
||||
};
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+1
-1
@@ -80,7 +80,7 @@ namespace AzToolsFramework
|
||||
|
||||
const AzFramework::CameraState cameraState = GetCameraState(viewportId);
|
||||
|
||||
m_cachedEntityIdUnderCursor = m_editorHelpers->HandleMouseInteraction(cameraState, mouseInteraction);
|
||||
m_cachedEntityIdUnderCursor = m_editorHelpers->FindEntityIdUnderCursor(cameraState, mouseInteraction).ContainerAncestorEntityId();
|
||||
|
||||
// when left clicking, if we successfully clicked an entity, assign that
|
||||
// to the entity field selected in the entity inspector (RPE)
|
||||
|
||||
+68
-14
@@ -27,6 +27,7 @@
|
||||
#include <AzToolsFramework/Manipulators/ScaleManipulators.h>
|
||||
#include <AzToolsFramework/Manipulators/TranslationManipulators.h>
|
||||
#include <AzToolsFramework/Maths/TransformUtils.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabFocusInterface.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorLockComponentBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorVisibilityBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformComponent.h>
|
||||
@@ -1799,7 +1800,8 @@ namespace AzToolsFramework
|
||||
const AzFramework::ViewportId viewportId = mouseInteraction.m_mouseInteraction.m_interactionId.m_viewportId;
|
||||
const AzFramework::CameraState cameraState = GetCameraState(viewportId);
|
||||
|
||||
m_cachedEntityIdUnderCursor = m_editorHelpers->HandleMouseInteraction(cameraState, mouseInteraction);
|
||||
const auto cursorEntityIdQuery = m_editorHelpers->FindEntityIdUnderCursor(cameraState, mouseInteraction);
|
||||
m_cachedEntityIdUnderCursor = cursorEntityIdQuery.ContainerAncestorEntityId();
|
||||
|
||||
const auto selectClickEvent = ClickDetectorEventFromViewportInteraction(mouseInteraction);
|
||||
m_cursorState.SetCurrentPosition(mouseInteraction.m_mouseInteraction.m_mousePick.m_screenCoordinates);
|
||||
@@ -1825,8 +1827,6 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
const AZ::EntityId entityIdUnderCursor = m_cachedEntityIdUnderCursor;
|
||||
|
||||
EditorContextMenuUpdate(m_contextMenu, mouseInteraction);
|
||||
|
||||
m_boxSelect.HandleMouseInteraction(mouseInteraction);
|
||||
@@ -1842,6 +1842,21 @@ namespace AzToolsFramework
|
||||
return true;
|
||||
}
|
||||
|
||||
const AZ::EntityId entityIdUnderCursor = m_cachedEntityIdUnderCursor;
|
||||
|
||||
if (mouseInteraction.m_mouseEvent == ViewportInteraction::MouseEvent::DoubleClick &&
|
||||
mouseInteraction.m_mouseInteraction.m_mouseButtons.Left())
|
||||
{
|
||||
if (cursorEntityIdQuery.HasContainerAncestorEntityId())
|
||||
{
|
||||
if (auto prefabFocusInterface = AZ::Interface<Prefab::PrefabFocusInterface>::Get())
|
||||
{
|
||||
prefabFocusInterface->FocusOnPrefabInstanceOwningEntityId(cursorEntityIdQuery.ContainerAncestorEntityId());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool stickySelect = false;
|
||||
ViewportInteraction::ViewportSettingsRequestBus::EventResult(
|
||||
stickySelect, viewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::StickySelectEnabled);
|
||||
@@ -3560,6 +3575,8 @@ namespace AzToolsFramework
|
||||
DrawAxisGizmo(viewportInfo, debugDisplay);
|
||||
|
||||
m_boxSelect.Display2d(viewportInfo, debugDisplay);
|
||||
|
||||
m_editorHelpers->Display2d(viewportInfo, debugDisplay);
|
||||
}
|
||||
|
||||
void EditorTransformComponentSelection::RefreshSelectedEntityIds()
|
||||
@@ -3663,26 +3680,63 @@ namespace AzToolsFramework
|
||||
void EditorTransformComponentSelection::OnEditorModeActivated(
|
||||
[[maybe_unused]] const ViewportEditorModesInterface& editorModeState, ViewportEditorMode mode)
|
||||
{
|
||||
if (mode == ViewportEditorMode::Component)
|
||||
switch (mode)
|
||||
{
|
||||
SetAllViewportUiVisible(false);
|
||||
case ViewportEditorMode::Component:
|
||||
{
|
||||
SetAllViewportUiVisible(false);
|
||||
|
||||
EditorEntityLockComponentNotificationBus::Router::BusRouterDisconnect();
|
||||
EditorEntityVisibilityNotificationBus::Router::BusRouterDisconnect();
|
||||
ToolsApplicationNotificationBus::Handler::BusDisconnect();
|
||||
EditorEntityLockComponentNotificationBus::Router::BusRouterDisconnect();
|
||||
EditorEntityVisibilityNotificationBus::Router::BusRouterDisconnect();
|
||||
ToolsApplicationNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
break;
|
||||
case ViewportEditorMode::Focus:
|
||||
{
|
||||
ViewportUi::ViewportUiRequestBus::Event(
|
||||
ViewportUi::DefaultViewportId, &ViewportUi::ViewportUiRequestBus::Events::CreateViewportBorder, "Focus Mode");
|
||||
}
|
||||
break;
|
||||
case ViewportEditorMode::Default:
|
||||
case ViewportEditorMode::Pick:
|
||||
// noop
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void EditorTransformComponentSelection::OnEditorModeDeactivated(
|
||||
[[maybe_unused]] const ViewportEditorModesInterface& editorModeState, ViewportEditorMode mode)
|
||||
const ViewportEditorModesInterface& editorModeState, const ViewportEditorMode mode)
|
||||
{
|
||||
if (mode == ViewportEditorMode::Component)
|
||||
switch (mode)
|
||||
{
|
||||
SetAllViewportUiVisible(true);
|
||||
case ViewportEditorMode::Component:
|
||||
{
|
||||
SetAllViewportUiVisible(true);
|
||||
|
||||
ToolsApplicationNotificationBus::Handler::BusConnect();
|
||||
EditorEntityVisibilityNotificationBus::Router::BusRouterConnect();
|
||||
EditorEntityLockComponentNotificationBus::Router::BusRouterConnect();
|
||||
ToolsApplicationNotificationBus::Handler::BusConnect();
|
||||
EditorEntityVisibilityNotificationBus::Router::BusRouterConnect();
|
||||
EditorEntityLockComponentNotificationBus::Router::BusRouterConnect();
|
||||
|
||||
// note: when leaving component mode, we check if we're still in focus mode (i.e. component mode was
|
||||
// started from within focus mode), if we are, ensure we create/update the viewport border (as leaving
|
||||
// component mode will attempt to remove it)
|
||||
if (editorModeState.IsModeActive(ViewportEditorMode::Focus))
|
||||
{
|
||||
ViewportUi::ViewportUiRequestBus::Event(
|
||||
ViewportUi::DefaultViewportId, &ViewportUi::ViewportUiRequestBus::Events::CreateViewportBorder, "Focus Mode");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ViewportEditorMode::Focus:
|
||||
{
|
||||
ViewportUi::ViewportUiRequestBus::Event(
|
||||
ViewportUi::DefaultViewportId, &ViewportUi::ViewportUiRequestBus::Events::RemoveViewportBorder);
|
||||
}
|
||||
break;
|
||||
case ViewportEditorMode::Default:
|
||||
case ViewportEditorMode::Pick:
|
||||
// noop
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* 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 <AzCore/Console/Console.h>
|
||||
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportTypes.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
|
||||
#include <AzToolsFramework/ViewportSelection/InvalidClicks.h>
|
||||
|
||||
AZ_CVAR(float, ed_invalidClickRadius, 10.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "Maximum invalid click radius to expand to");
|
||||
AZ_CVAR(float, ed_invalidClickDuration, 1.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "Duration to display the invalid click feedback");
|
||||
AZ_CVAR(float, ed_invalidClickMessageSize, 0.8f, nullptr, AZ::ConsoleFunctorFlags::Null, "Size of text for invalid message");
|
||||
AZ_CVAR(
|
||||
float,
|
||||
ed_invalidClickMessageVerticalOffset,
|
||||
30.0f,
|
||||
nullptr,
|
||||
AZ::ConsoleFunctorFlags::Null,
|
||||
"Vertical offset from cursor of invalid click message");
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
void ExpandingFadingCircles::Begin(const AzFramework::ScreenPoint& screenPoint)
|
||||
{
|
||||
FadingCircle fadingCircle;
|
||||
fadingCircle.m_position = screenPoint;
|
||||
fadingCircle.m_opacity = 1.0f;
|
||||
fadingCircle.m_radius = 0.0f;
|
||||
m_fadingCircles.push_back(fadingCircle);
|
||||
}
|
||||
|
||||
void ExpandingFadingCircles::Update(const float deltaTime)
|
||||
{
|
||||
for (auto& fadingCircle : m_fadingCircles)
|
||||
{
|
||||
fadingCircle.m_opacity = AZStd::max(fadingCircle.m_opacity - (deltaTime / ed_invalidClickDuration), 0.0f);
|
||||
fadingCircle.m_radius += deltaTime * ed_invalidClickRadius;
|
||||
}
|
||||
|
||||
m_fadingCircles.erase(
|
||||
AZStd::remove_if(
|
||||
m_fadingCircles.begin(), m_fadingCircles.end(),
|
||||
[](const FadingCircle& fadingCircle)
|
||||
{
|
||||
return fadingCircle.m_opacity <= 0.0f;
|
||||
}),
|
||||
m_fadingCircles.end());
|
||||
}
|
||||
|
||||
bool ExpandingFadingCircles::Updating()
|
||||
{
|
||||
return !m_fadingCircles.empty();
|
||||
}
|
||||
|
||||
void ExpandingFadingCircles::Display(const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay)
|
||||
{
|
||||
const AZ::Vector2 viewportSize = AzToolsFramework::GetCameraState(viewportInfo.m_viewportId).m_viewportSize;
|
||||
|
||||
for (const auto& fadingCircle : m_fadingCircles)
|
||||
{
|
||||
const auto position = AzFramework::Vector2FromScreenPoint(fadingCircle.m_position) / viewportSize;
|
||||
debugDisplay.SetColor(AZ::Color(1.0f, 1.0f, 1.0f, fadingCircle.m_opacity));
|
||||
debugDisplay.DrawWireCircle2d(position, fadingCircle.m_radius * 0.005f, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
void FadingText::Begin(const AzFramework::ScreenPoint& screenPoint)
|
||||
{
|
||||
m_opacity = 1.0f;
|
||||
m_invalidClickPosition = screenPoint;
|
||||
}
|
||||
|
||||
void FadingText::Update(const float deltaTime)
|
||||
{
|
||||
m_opacity -= deltaTime / ed_invalidClickDuration;
|
||||
}
|
||||
|
||||
bool FadingText::Updating()
|
||||
{
|
||||
return m_opacity >= 0.0f;
|
||||
}
|
||||
|
||||
void FadingText::Display(
|
||||
[[maybe_unused]] const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay)
|
||||
{
|
||||
if (constexpr float MinOpacity = 0.05f; m_opacity >= MinOpacity)
|
||||
{
|
||||
debugDisplay.SetColor(AZ::Color(1.0f, 1.0f, 1.0f, m_opacity));
|
||||
debugDisplay.Draw2dTextLabel(
|
||||
aznumeric_cast<float>(m_invalidClickPosition.m_x),
|
||||
aznumeric_cast<float>(m_invalidClickPosition.m_y) - ed_invalidClickMessageVerticalOffset, ed_invalidClickMessageSize,
|
||||
m_message.c_str(), true);
|
||||
}
|
||||
}
|
||||
|
||||
void InvalidClicks::AddInvalidClick(const AzFramework::ScreenPoint& screenPoint)
|
||||
{
|
||||
AZ::TickBus::Handler::BusConnect();
|
||||
|
||||
for (auto& invalidClickBehavior : m_invalidClickBehaviors)
|
||||
{
|
||||
invalidClickBehavior->Begin(screenPoint);
|
||||
}
|
||||
}
|
||||
|
||||
void InvalidClicks::OnTick(const float deltaTime, [[maybe_unused]] const AZ::ScriptTimePoint time)
|
||||
{
|
||||
for (auto& invalidClickBehavior : m_invalidClickBehaviors)
|
||||
{
|
||||
invalidClickBehavior->Update(deltaTime);
|
||||
}
|
||||
|
||||
const auto updating = AZStd::any_of(
|
||||
m_invalidClickBehaviors.begin(), m_invalidClickBehaviors.end(),
|
||||
[](const auto& invalidClickBehavior)
|
||||
{
|
||||
return invalidClickBehavior->Updating();
|
||||
});
|
||||
|
||||
if (!updating && AZ::TickBus::Handler::BusIsConnected())
|
||||
{
|
||||
AZ::TickBus::Handler::BusDisconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void InvalidClicks::Display2d(const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay)
|
||||
{
|
||||
debugDisplay.DepthTestOff();
|
||||
|
||||
for (const auto& invalidClickBehavior : m_invalidClickBehaviors)
|
||||
{
|
||||
invalidClickBehavior->Display(viewportInfo, debugDisplay);
|
||||
}
|
||||
|
||||
debugDisplay.DepthTestOn();
|
||||
}
|
||||
} // namespace AzToolsFramework
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* 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/Component/TickBus.h>
|
||||
#include <AzFramework/Viewport/ScreenGeometry.h>
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
class DebugDisplayRequests;
|
||||
struct ViewportInfo;
|
||||
} // namespace AzFramework
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace ViewportInteraction
|
||||
{
|
||||
struct MouseInteractionEvent;
|
||||
}
|
||||
|
||||
//! An interface to provide invalid click feedback in the editor viewport.
|
||||
class InvalidClick
|
||||
{
|
||||
public:
|
||||
virtual ~InvalidClick() = default;
|
||||
|
||||
//! Begin the feedback.
|
||||
//! @param screenPoint The position of the click in screen coordinates.
|
||||
virtual void Begin(const AzFramework::ScreenPoint& screenPoint) = 0;
|
||||
//! Update the invalid click feedback
|
||||
virtual void Update(float deltaTime) = 0;
|
||||
//! Report if the click feedback is running or not (returning false will signal the TickBus can be disconnected from).
|
||||
virtual bool Updating() = 0;
|
||||
//! Display the click feedback in the viewport.
|
||||
virtual void Display(const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay) = 0;
|
||||
};
|
||||
|
||||
//! Display expanding fading circles for every click of the mouse that is invalid.
|
||||
class ExpandingFadingCircles : public InvalidClick
|
||||
{
|
||||
public:
|
||||
void Begin(const AzFramework::ScreenPoint& screenPoint) override;
|
||||
void Update(float deltaTime) override;
|
||||
bool Updating() override;
|
||||
void Display(const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay) override;
|
||||
|
||||
private:
|
||||
//! Stores a circle representation with a lifetime to grow and fade out over time.
|
||||
struct FadingCircle
|
||||
{
|
||||
AzFramework::ScreenPoint m_position;
|
||||
float m_radius;
|
||||
float m_opacity;
|
||||
};
|
||||
|
||||
using FadingCircles = AZStd::vector<FadingCircle>;
|
||||
FadingCircles m_fadingCircles; //!< Collection of fading circles to draw for clicks that have no effect.
|
||||
};
|
||||
|
||||
//! Display fading text where an invalid click happened.
|
||||
//! @note There is only one fading text, each click will update its position.
|
||||
class FadingText : public InvalidClick
|
||||
{
|
||||
public:
|
||||
explicit FadingText(AZStd::string message)
|
||||
: m_message(AZStd::move(message))
|
||||
{
|
||||
}
|
||||
|
||||
void Begin(const AzFramework::ScreenPoint& screenPoint) override;
|
||||
void Update(float deltaTime) override;
|
||||
bool Updating() override;
|
||||
void Display(const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay) override;
|
||||
|
||||
private:
|
||||
AZStd::string m_message; //!< Message to display for fading text.
|
||||
float m_opacity = 1.0f; //!< The opacity of the invalid click message.
|
||||
AzFramework::ScreenPoint m_invalidClickPosition; //!< The position to display the invalid click message.
|
||||
};
|
||||
|
||||
//! Interface to begin invalid click feedback (will run all added InvalidClick behaviors).
|
||||
class InvalidClicks : private AZ::TickBus::Handler
|
||||
{
|
||||
public:
|
||||
explicit InvalidClicks(AZStd::vector<AZStd::unique_ptr<InvalidClick>> invalidClickBehaviors)
|
||||
: m_invalidClickBehaviors(AZStd::move(invalidClickBehaviors))
|
||||
{
|
||||
}
|
||||
|
||||
//! Add an invalid click and activate one or more of the added invalid click behaviors.
|
||||
void AddInvalidClick(const AzFramework::ScreenPoint& screenPoint);
|
||||
|
||||
//! Handle 2d drawing for EditorHelper functionality.
|
||||
void Display2d(const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay);
|
||||
|
||||
private:
|
||||
//! AZ::TickBus overrides ...
|
||||
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
|
||||
|
||||
AZStd::vector<AZStd::unique_ptr<InvalidClick>> m_invalidClickBehaviors; //!< Invalid click behaviors to run.
|
||||
};
|
||||
} // namespace AzToolsFramework
|
||||
@@ -290,9 +290,9 @@ namespace AzToolsFramework::ViewportUi::Internal
|
||||
return false;
|
||||
}
|
||||
|
||||
void ViewportUiDisplay::CreateComponentModeBorder(const AZStd::string& borderTitle)
|
||||
void ViewportUiDisplay::CreateViewportBorder(const AZStd::string& borderTitle)
|
||||
{
|
||||
AZStd::string styleSheet = AZStd::string::format(
|
||||
const AZStd::string styleSheet = AZStd::string::format(
|
||||
"border: %dpx solid %s; border-top: %dpx solid %s;", HighlightBorderSize, HighlightBorderColor, TopHighlightBorderSize,
|
||||
HighlightBorderColor);
|
||||
m_uiOverlay.setStyleSheet(styleSheet.c_str());
|
||||
@@ -303,7 +303,7 @@ namespace AzToolsFramework::ViewportUi::Internal
|
||||
m_componentModeBorderText.setText(borderTitle.c_str());
|
||||
}
|
||||
|
||||
void ViewportUiDisplay::RemoveComponentModeBorder()
|
||||
void ViewportUiDisplay::RemoveViewportBorder()
|
||||
{
|
||||
m_componentModeBorderText.setVisible(false);
|
||||
m_uiOverlay.setStyleSheet("border: none;");
|
||||
@@ -420,6 +420,7 @@ namespace AzToolsFramework::ViewportUi::Internal
|
||||
m_uiMainWindow.setVisible(true);
|
||||
m_uiOverlay.setVisible(true);
|
||||
}
|
||||
|
||||
m_uiMainWindow.setMask(region);
|
||||
}
|
||||
|
||||
@@ -437,6 +438,7 @@ namespace AzToolsFramework::ViewportUi::Internal
|
||||
{
|
||||
return element->second;
|
||||
}
|
||||
|
||||
return ViewportUiElementInfo{ nullptr, InvalidViewportUiElementId, false };
|
||||
}
|
||||
|
||||
|
||||
@@ -89,8 +89,8 @@ namespace AzToolsFramework::ViewportUi::Internal
|
||||
AZStd::shared_ptr<QWidget> GetViewportUiElement(ViewportUiElementId elementId);
|
||||
bool IsViewportUiElementVisible(ViewportUiElementId elementId);
|
||||
|
||||
void CreateComponentModeBorder(const AZStd::string& borderTitle);
|
||||
void RemoveComponentModeBorder();
|
||||
void CreateViewportBorder(const AZStd::string& borderTitle);
|
||||
void RemoveViewportBorder();
|
||||
|
||||
private:
|
||||
void PrepareWidgetForViewportUi(QPointer<QWidget> widget);
|
||||
|
||||
@@ -240,14 +240,14 @@ namespace AzToolsFramework::ViewportUi
|
||||
}
|
||||
}
|
||||
|
||||
void ViewportUiManager::CreateComponentModeBorder(const AZStd::string& borderTitle)
|
||||
void ViewportUiManager::CreateViewportBorder(const AZStd::string& borderTitle)
|
||||
{
|
||||
m_viewportUi->CreateComponentModeBorder(borderTitle);
|
||||
m_viewportUi->CreateViewportBorder(borderTitle);
|
||||
}
|
||||
|
||||
void ViewportUiManager::RemoveComponentModeBorder()
|
||||
void ViewportUiManager::RemoveViewportBorder()
|
||||
{
|
||||
m_viewportUi->RemoveComponentModeBorder();
|
||||
m_viewportUi->RemoveViewportBorder();
|
||||
}
|
||||
|
||||
void ViewportUiManager::PressButton(ClusterId clusterId, ButtonId buttonId)
|
||||
|
||||
@@ -50,8 +50,8 @@ namespace AzToolsFramework::ViewportUi
|
||||
void RegisterTextFieldCallback(TextFieldId textFieldId, AZ::Event<AZStd::string>::Handler& handler) override;
|
||||
void RemoveTextField(TextFieldId textFieldId) override;
|
||||
void SetTextFieldVisible(TextFieldId textFieldId, bool visible) override;
|
||||
void CreateComponentModeBorder(const AZStd::string& borderTitle) override;
|
||||
void RemoveComponentModeBorder() override;
|
||||
void CreateViewportBorder(const AZStd::string& borderTitle) override;
|
||||
void RemoveViewportBorder() override;
|
||||
void PressButton(ClusterId clusterId, ButtonId buttonId) override;
|
||||
void PressButton(SwitcherId switcherId, ButtonId buttonId) override;
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace AzToolsFramework::ViewportUi
|
||||
virtual void RegisterSwitcherEventHandler(SwitcherId switcherId, AZ::Event<ButtonId>::Handler& handler) = 0;
|
||||
//! Removes a cluster from the Viewport UI system.
|
||||
virtual void RemoveCluster(ClusterId clusterId) = 0;
|
||||
//!
|
||||
//! Removes a switcher from the Viewport UI system.
|
||||
virtual void RemoveSwitcher(SwitcherId switcherId) = 0;
|
||||
//! Sets the visibility of the cluster.
|
||||
virtual void SetClusterVisible(ClusterId clusterId, bool visible) = 0;
|
||||
@@ -96,12 +96,12 @@ namespace AzToolsFramework::ViewportUi
|
||||
//! Sets the visibility of the text field.
|
||||
virtual void SetTextFieldVisible(TextFieldId textFieldId, bool visible) = 0;
|
||||
//! Create the highlight border for Component Mode.
|
||||
virtual void CreateComponentModeBorder(const AZStd::string& borderTitle) = 0;
|
||||
virtual void CreateViewportBorder(const AZStd::string& borderTitle) = 0;
|
||||
//! Remove the highlight border for Component Mode.
|
||||
virtual void RemoveComponentModeBorder() = 0;
|
||||
//! Invoke a button press in a cluster.
|
||||
virtual void RemoveViewportBorder() = 0;
|
||||
//! Invoke a button press on a cluster.
|
||||
virtual void PressButton(ClusterId clusterId, ButtonId buttonId) = 0;
|
||||
//!
|
||||
//! Invoke a button press on a switcher.
|
||||
virtual void PressButton(SwitcherId switcherId, ButtonId buttonId) = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -553,6 +553,8 @@ set(FILES
|
||||
ViewportSelection/EditorTransformComponentSelectionRequestBus.cpp
|
||||
ViewportSelection/EditorVisibleEntityDataCache.h
|
||||
ViewportSelection/EditorVisibleEntityDataCache.cpp
|
||||
ViewportSelection/InvalidClicks.h
|
||||
ViewportSelection/InvalidClicks.cpp
|
||||
ViewportSelection/ViewportEditorModeTracker.cpp
|
||||
ViewportSelection/ViewportEditorModeTracker.h
|
||||
ToolsFileUtils/ToolsFileUtils.h
|
||||
@@ -757,6 +759,9 @@ set(FILES
|
||||
UI/Prefab/PrefabUiHandler.cpp
|
||||
UI/Prefab/PrefabViewportFocusPathHandler.h
|
||||
UI/Prefab/PrefabViewportFocusPathHandler.cpp
|
||||
UI/Notifications/ToastNotificationsView.cpp
|
||||
UI/Notifications/ToastNotificationsView.h
|
||||
UI/Notifications/ToastBus.h
|
||||
PythonTerminal/ScriptHelpDialog.cpp
|
||||
PythonTerminal/ScriptHelpDialog.h
|
||||
PythonTerminal/ScriptHelpDialog.ui
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <Prefab/PrefabTestFixture.h>
|
||||
#include <Prefab/Procedural/ProceduralPrefabAsset.h>
|
||||
#include <AzCore/Serialization/Json/RegistrationContext.h>
|
||||
#include <AzToolsFramework/Prefab/Template/Template.h>
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
@@ -132,4 +133,32 @@ namespace UnitTest
|
||||
EXPECT_TRUE(outputValue.HasMember("member"));
|
||||
EXPECT_STREQ(outputValue.FindMember("member")->value.GetString(), "value");
|
||||
}
|
||||
|
||||
TEST_F(ProceduralPrefabAssetTest, Template_IsProcPrefab_DefaultsToNotProcPrefab)
|
||||
{
|
||||
AzToolsFramework::Prefab::PrefabDom dom;
|
||||
dom.SetObject();
|
||||
dom.AddMember("Source", "foo.prefab", dom.GetAllocator());
|
||||
AzToolsFramework::Prefab::Template fooTemplate("foo", AZStd::move(dom));
|
||||
EXPECT_FALSE(fooTemplate.IsProcedural());
|
||||
}
|
||||
|
||||
TEST_F(ProceduralPrefabAssetTest, Template_IsProcPrefab_DomDrivesFlagToTrue)
|
||||
{
|
||||
AzToolsFramework::Prefab::PrefabDom dom;
|
||||
dom.SetObject();
|
||||
dom.AddMember("Source", "foo.procprefab", dom.GetAllocator());
|
||||
AzToolsFramework::Prefab::Template fooTemplate("foo", AZStd::move(dom));
|
||||
EXPECT_TRUE(fooTemplate.IsProcedural());
|
||||
// the second time should use the cached version of the flag
|
||||
EXPECT_TRUE(fooTemplate.IsProcedural());
|
||||
}
|
||||
|
||||
TEST_F(ProceduralPrefabAssetTest, Template_IsProcPrefab_FailsWithNoSource)
|
||||
{
|
||||
AzToolsFramework::Prefab::PrefabDom dom;
|
||||
dom.SetObject();
|
||||
AzToolsFramework::Prefab::Template fooTemplate("foo", AZStd::move(dom));
|
||||
EXPECT_FALSE(fooTemplate.IsProcedural());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
* 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 <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <AzFramework/Entity/EntityContextBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextComponent.h>
|
||||
#include <AzToolsFramework/Entity/PrefabEditorEntityOwnershipInterface.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformComponent.h>
|
||||
#include <AzToolsFramework/UI/Outliner/EntityOutlinerListModel.hxx>
|
||||
#include <AzToolsFramework/UI/Prefab/PrefabIntegrationManager.h>
|
||||
#include <AzToolsFramework/Undo/UndoSystem.h>
|
||||
#include <Prefab/PrefabTestFixture.h>
|
||||
|
||||
#include <QAbstractItemModelTester>
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
// Test fixture for the entity outliner model that uses a QAbstractItemModelTester to validate the state of the model
|
||||
// when QAbstractItemModel signals fire. Tests will exit with a fatal error if an invalid state is detected.
|
||||
class EntityOutlinerTest : public PrefabTestFixture
|
||||
{
|
||||
protected:
|
||||
void SetUpEditorFixtureImpl() override
|
||||
{
|
||||
PrefabTestFixture::SetUpEditorFixtureImpl();
|
||||
GetApplication()->RegisterComponentDescriptor(AzToolsFramework::EditorEntityContextComponent::CreateDescriptor());
|
||||
|
||||
m_model = AZStd::make_unique<AzToolsFramework::EntityOutlinerListModel>();
|
||||
m_model->Initialize();
|
||||
m_modelTester =
|
||||
AZStd::make_unique<QAbstractItemModelTester>(m_model.get(), QAbstractItemModelTester::FailureReportingMode::Fatal);
|
||||
|
||||
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
|
||||
m_undoStack, &AzToolsFramework::ToolsApplicationRequestBus::Events::GetUndoStack);
|
||||
AZ_Assert(m_undoStack, "Failed to look up undo stack from tools application");
|
||||
|
||||
// Create a new root prefab - the synthetic "NewLevel.prefab" that comes in by default isn't suitable for outliner tests
|
||||
// because it's created before the EditorEntityModel that our EntityOutlinerListModel subscribes to, and we want to
|
||||
// recreate it as part of the fixture regardless.
|
||||
auto entityOwnershipService = AZ::Interface<AzToolsFramework::PrefabEditorEntityOwnershipInterface>::Get();
|
||||
entityOwnershipService->CreateNewLevelPrefab("UnitTestRoot.prefab", "");
|
||||
}
|
||||
|
||||
void TearDownEditorFixtureImpl() override
|
||||
{
|
||||
m_undoStack = nullptr;
|
||||
m_modelTester.reset();
|
||||
m_model.reset();
|
||||
PrefabTestFixture::TearDownEditorFixtureImpl();
|
||||
}
|
||||
|
||||
// Creates an entity with a given name as one undoable operation
|
||||
// Parents to parentId, or the root prefab container entity if parentId is invalid
|
||||
AZ::EntityId CreateNamedEntity(AZStd::string name, AZ::EntityId parentId = AZ::EntityId())
|
||||
{
|
||||
auto createResult = m_prefabPublicInterface->CreateEntity(parentId, AZ::Vector3());
|
||||
AZ_Assert(createResult.IsSuccess(), "Failed to create entity: %s", createResult.GetError().c_str());
|
||||
AZ::EntityId entityId = createResult.GetValue();
|
||||
|
||||
AZ::Entity* entity = nullptr;
|
||||
AZ::ComponentApplicationBus::BroadcastResult(entity, &AZ::ComponentApplicationRequests::FindEntity, entityId);
|
||||
|
||||
entity->Deactivate();
|
||||
|
||||
entity->SetName(name);
|
||||
|
||||
// Normally, in invalid parent ID should automatically parent us to the root prefab, but currently in the unit test
|
||||
// environment entities aren't created with a default transform component, so CreateEntity won't correctly parent.
|
||||
// We get the actual target parent ID here, then create our missing transform component.
|
||||
if (!parentId.IsValid())
|
||||
{
|
||||
auto prefabEditorEntityOwnershipInterface = AZ::Interface<AzToolsFramework::PrefabEditorEntityOwnershipInterface>::Get();
|
||||
parentId = prefabEditorEntityOwnershipInterface->GetRootPrefabInstance()->get().GetContainerEntityId();
|
||||
}
|
||||
|
||||
auto transform = aznew AzToolsFramework::Components::TransformComponent;
|
||||
transform->SetParent(parentId);
|
||||
entity->AddComponent(transform);
|
||||
|
||||
entity->Activate();
|
||||
|
||||
// Update our undo cache entry to include the rename / reparent as one atomic operation.
|
||||
m_prefabPublicInterface->GenerateUndoNodesForEntityChangeAndUpdateCache(entityId, m_undoStack->GetTop());
|
||||
|
||||
ProcessDeferredUpdates();
|
||||
|
||||
return entityId;
|
||||
}
|
||||
|
||||
// Helper to visualize debug state
|
||||
void PrintModel()
|
||||
{
|
||||
AZStd::deque<AZStd::pair<QModelIndex, int>> indices;
|
||||
indices.push_back({ m_model->index(0, 0), 0 });
|
||||
while (!indices.empty())
|
||||
{
|
||||
auto [index, depth] = indices.front();
|
||||
indices.pop_front();
|
||||
|
||||
QString indentString;
|
||||
for (int i = 0; i < depth; ++i)
|
||||
{
|
||||
indentString += " ";
|
||||
}
|
||||
qDebug() << (indentString + index.data(Qt::DisplayRole).toString()) << index.internalId();
|
||||
for (int i = 0; i < m_model->rowCount(index); ++i)
|
||||
{
|
||||
indices.emplace_back(m_model->index(i, 0, index), depth + 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Gets the index of the root prefab, i.e. the "New Level" container entity
|
||||
QModelIndex GetRootIndex() const
|
||||
{
|
||||
return m_model->index(0, 0);
|
||||
}
|
||||
|
||||
// Kicks off any updates scheduled for the next tick
|
||||
void ProcessDeferredUpdates()
|
||||
{
|
||||
// Force a prefab propagation for updates that are deferred to the next tick.
|
||||
m_prefabSystemComponent->OnSystemTick();
|
||||
|
||||
// Ensure the model process its entity update queue
|
||||
m_model->ProcessEntityUpdates();
|
||||
}
|
||||
|
||||
// Performs an undo operation and ensures the tick-scheduled updates happen
|
||||
void Undo()
|
||||
{
|
||||
m_undoStack->Undo();
|
||||
ProcessDeferredUpdates();
|
||||
}
|
||||
|
||||
// Performs a redo operation and ensures the tick-scheduled updates happen
|
||||
void Redo()
|
||||
{
|
||||
m_undoStack->Redo();
|
||||
ProcessDeferredUpdates();
|
||||
}
|
||||
|
||||
AZStd::unique_ptr<AzToolsFramework::EntityOutlinerListModel> m_model;
|
||||
AZStd::unique_ptr<QAbstractItemModelTester> m_modelTester;
|
||||
AzToolsFramework::UndoSystem::UndoStack* m_undoStack = nullptr;
|
||||
};
|
||||
|
||||
TEST_F(EntityOutlinerTest, TestCreateFlatHierarchyUndoAndRedoWorks)
|
||||
{
|
||||
constexpr size_t entityCount = 10;
|
||||
|
||||
for (size_t i = 0; i < entityCount; ++i)
|
||||
{
|
||||
CreateNamedEntity(AZStd::string::format("Entity%zu", i));
|
||||
EXPECT_EQ(m_model->rowCount(GetRootIndex()), i + 1);
|
||||
}
|
||||
|
||||
for (int i = entityCount; i > 0; --i)
|
||||
{
|
||||
Undo();
|
||||
EXPECT_EQ(m_model->rowCount(GetRootIndex()), i - 1);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < entityCount; ++i)
|
||||
{
|
||||
Redo();
|
||||
EXPECT_EQ(m_model->rowCount(GetRootIndex()), i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(EntityOutlinerTest, TestCreateNestedHierarchyUndoAndRedoWorks)
|
||||
{
|
||||
constexpr size_t depth = 5;
|
||||
|
||||
auto modelDepth = [this]() -> int
|
||||
{
|
||||
int depth = 0;
|
||||
QModelIndex index = GetRootIndex();
|
||||
while (m_model->rowCount(index) > 0)
|
||||
{
|
||||
++depth;
|
||||
index = m_model->index(0, 0, index);
|
||||
}
|
||||
return depth;
|
||||
};
|
||||
|
||||
AZ::EntityId parentId;
|
||||
for (int i = 0; i < depth; i++)
|
||||
{
|
||||
parentId = CreateNamedEntity(AZStd::string::format("EntityDepth%i", i), parentId);
|
||||
EXPECT_EQ(modelDepth(), i + 1);
|
||||
}
|
||||
|
||||
for (int i = depth - 1; i >= 0; --i)
|
||||
{
|
||||
Undo();
|
||||
EXPECT_EQ(modelDepth(), i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < depth; ++i)
|
||||
{
|
||||
Redo();
|
||||
EXPECT_EQ(modelDepth(), i + 1);
|
||||
}
|
||||
}
|
||||
} // namespace UnitTest
|
||||
@@ -120,6 +120,8 @@ set(FILES
|
||||
ToolsComponents/EditorLayerComponentTests.cpp
|
||||
ToolsComponents/EditorTransformComponentTests.cpp
|
||||
TransformComponent.cpp
|
||||
UI/EntityIdQLineEditTests.cpp
|
||||
UI/EntityOutlinerTests.cpp
|
||||
UI/EntityPropertyEditorTests.cpp
|
||||
UndoStack.cpp
|
||||
Viewport/ClusterTests.cpp
|
||||
|
||||
@@ -333,7 +333,7 @@ namespace UnitTest
|
||||
};
|
||||
|
||||
template<class SocketProvider = SocketDriverProvider>
|
||||
class Integ_CarrierAsyncHandshakeTestTemplate
|
||||
class CarrierAsyncHandshakeTestTemplate
|
||||
: public GridMateMPTestFixture
|
||||
, protected SocketProvider
|
||||
{
|
||||
@@ -761,7 +761,7 @@ namespace UnitTest
|
||||
};
|
||||
|
||||
template<class SocketProvider = SocketDriverProvider>
|
||||
class Integ_CarrierDisconnectDetectionTestTemplate
|
||||
class CarrierDisconnectDetectionTestTemplate
|
||||
: public GridMateMPTestFixture
|
||||
, protected SocketProvider
|
||||
{
|
||||
@@ -846,7 +846,7 @@ namespace UnitTest
|
||||
* Sends reliable messages across different channels to each other
|
||||
*/
|
||||
template<class SocketProvider = SocketDriverProvider>
|
||||
class Integ_CarrierMultiChannelTestTemplate
|
||||
class CarrierMultiChannelTestTemplate
|
||||
: public GridMateMPTestFixture
|
||||
, protected SocketProvider
|
||||
{
|
||||
@@ -950,7 +950,7 @@ namespace UnitTest
|
||||
* Stress tests multiple simultaneous Carriers
|
||||
*/
|
||||
template<class SocketProvider = SocketDriverProvider>
|
||||
class Integ_CarrierMultiStressTestTemplate
|
||||
class CarrierMultiStressTestTemplate
|
||||
: public GridMateMPTestFixture
|
||||
, protected SocketProvider
|
||||
{
|
||||
@@ -977,7 +977,7 @@ namespace UnitTest
|
||||
public:
|
||||
void run()
|
||||
{
|
||||
AZ_TracePrintf("GridMate", "Integ_CarrierMultiStressTest\n\n");
|
||||
AZ_TracePrintf("GridMate", "CarrierMultiStressTest\n\n");
|
||||
|
||||
// initialize transport
|
||||
const int k_numChannels = 1;
|
||||
@@ -1108,7 +1108,7 @@ namespace UnitTest
|
||||
|
||||
/*** Congestion control back pressure test */
|
||||
template<class SocketProvider = SocketDriverProvider>
|
||||
class Integ_CarrierBackpressureTestTemplate
|
||||
class CarrierBackpressureTestTemplate
|
||||
: public GridMateMPTestFixture
|
||||
, protected SocketProvider
|
||||
, public CarrierEventBus::Handler
|
||||
@@ -1380,7 +1380,7 @@ namespace UnitTest
|
||||
};
|
||||
|
||||
template<class SocketProvider = SocketDriverProvider>
|
||||
class Integ_CarrierACKTestTemplate
|
||||
class CarrierACKTestTemplate
|
||||
: public GridMateMPTestFixture
|
||||
, protected SocketProvider
|
||||
{
|
||||
@@ -1544,13 +1544,13 @@ namespace UnitTest
|
||||
//Create specific tests
|
||||
using CarrierBasicTest = CarrierBasicTestTemplate<>;
|
||||
using CarrierTest = CarrierTestTemplate<>;
|
||||
using Integ_CarrierDisconnectDetectionTest = Integ_CarrierDisconnectDetectionTestTemplate<>;
|
||||
using Integ_CarrierAsyncHandshakeTest = Integ_CarrierAsyncHandshakeTestTemplate<>;
|
||||
using Integ_CarrierStressTest = CarrierStressTestTemplate<>;
|
||||
using Integ_CarrierMultiChannelTest = Integ_CarrierMultiChannelTestTemplate<>;
|
||||
using Integ_CarrierMultiStressTest = Integ_CarrierMultiStressTestTemplate<>;
|
||||
using Integ_CarrierBackpressureTest = Integ_CarrierBackpressureTestTemplate<>;
|
||||
using Integ_CarrierACKTest = Integ_CarrierACKTestTemplate<>;
|
||||
using DISABLED_CarrierDisconnectDetectionTest = CarrierDisconnectDetectionTestTemplate<>;
|
||||
using DISABLED_CarrierAsyncHandshakeTest = CarrierAsyncHandshakeTestTemplate<>;
|
||||
using DISABLED_CarrierStressTest = CarrierStressTestTemplate<>;
|
||||
using DISABLED_CarrierMultiChannelTest = CarrierMultiChannelTestTemplate<>;
|
||||
using DISABLED_CarrierMultiStressTest = CarrierMultiStressTestTemplate<>;
|
||||
using DISABLED_CarrierBackpressureTest = CarrierBackpressureTestTemplate<>;
|
||||
using DISABLED_CarrierACKTest = CarrierACKTestTemplate<>;
|
||||
|
||||
#if AZ_TRAIT_GRIDMATE_TEST_WITH_SECURE_SOCKET_DRIVER
|
||||
|
||||
@@ -1658,20 +1658,20 @@ namespace UnitTest
|
||||
using SecureProviderBadHost = SecureDriverProvider<SecureSocketDriver, SecureSocketHandshakeDrop<false>>;
|
||||
using SecureProviderBadBoth = SecureDriverProvider<SecureSocketHandshakeDrop<true>, SecureSocketHandshakeDrop<false>>;
|
||||
|
||||
using Integ_CarrierSecureSocketHandshakeTestClient = CarrierBasicTestTemplate<SecureProviderBadClient, 200>;
|
||||
using Integ_CarrierSecureSocketHandshakeTestHost = CarrierBasicTestTemplate<SecureProviderBadHost, 200>;
|
||||
using Integ_CarrierSecureSocketHandshakeTestBoth = CarrierBasicTestTemplate<SecureProviderBadBoth, 200>;
|
||||
using DISABLED_CarrierSecureSocketHandshakeTestClient = CarrierBasicTestTemplate<SecureProviderBadClient, 200>;
|
||||
using DISABLED_CarrierSecureSocketHandshakeTestHost = CarrierBasicTestTemplate<SecureProviderBadHost, 200>;
|
||||
using DISABLED_CarrierSecureSocketHandshakeTestBoth = CarrierBasicTestTemplate<SecureProviderBadBoth, 200>;
|
||||
|
||||
//Create secure socket variants of tests
|
||||
using CarrierBasicTestSecure = CarrierBasicTestTemplate<SecureDriverProvider<>>;
|
||||
using CarrierTestSecure = CarrierTestTemplate<SecureDriverProvider<>>;
|
||||
using Integ_CarrierDisconnectDetectionTestSecure = Integ_CarrierDisconnectDetectionTestTemplate<SecureDriverProvider<>>;
|
||||
using Integ_CarrierAsyncHandshakeTestSecure = Integ_CarrierAsyncHandshakeTestTemplate<SecureDriverProvider<>>;
|
||||
using Integ_CarrierStressTestSecure = CarrierStressTestTemplate<SecureDriverProvider<>>;
|
||||
using Integ_CarrierMultiChannelTestSecure = Integ_CarrierMultiChannelTestTemplate<SecureDriverProvider<>>;
|
||||
using Integ_CarrierMultiStressTestSecure = Integ_CarrierMultiStressTestTemplate<SecureDriverProvider<>>;
|
||||
using Integ_CarrierBackpressureTestSecure = Integ_CarrierBackpressureTestTemplate<SecureDriverProvider<>>;
|
||||
using Integ_CarrierACKTestSecure = Integ_CarrierACKTestTemplate<SecureDriverProvider<>>;
|
||||
using DISABLED_CarrierDisconnectDetectionTestSecure = CarrierDisconnectDetectionTestTemplate<SecureDriverProvider<>>;
|
||||
using DISABLED_CarrierAsyncHandshakeTestSecure = CarrierAsyncHandshakeTestTemplate<SecureDriverProvider<>>;
|
||||
using DISABLED_CarrierStressTestSecure = CarrierStressTestTemplate<SecureDriverProvider<>>;
|
||||
using DISABLED_CarrierMultiChannelTestSecure = CarrierMultiChannelTestTemplate<SecureDriverProvider<>>;
|
||||
using DISABLED_CarrierMultiStressTestSecure = CarrierMultiStressTestTemplate<SecureDriverProvider<>>;
|
||||
using DISABLED_CarrierBackpressureTestSecure = CarrierBackpressureTestTemplate<SecureDriverProvider<>>;
|
||||
using DISABLED_CarrierACKTestSecure = CarrierACKTestTemplate<SecureDriverProvider<>>;
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -1720,30 +1720,30 @@ GM_TEST_SUITE(CarrierSuite)
|
||||
GM_TEST(CarrierBasicTest)
|
||||
GM_TEST(CarrierTest)
|
||||
#endif //AZ_TRAIT_GRIDMATE_UNIT_TEST_DISABLE_CARRIER_SESSION_TESTS
|
||||
GM_TEST(Integ_CarrierAsyncHandshakeTest)
|
||||
GM_TEST(DISABLED_CarrierAsyncHandshakeTest)
|
||||
#if !defined(AZ_DEBUG_BUILD) // this test is a little slow for debug
|
||||
GM_TEST(Integ_CarrierStressTest)
|
||||
GM_TEST(Integ_CarrierMultiStressTest)
|
||||
GM_TEST(DISABLED_CarrierStressTest)
|
||||
GM_TEST(DISABLED_CarrierMultiStressTest)
|
||||
#endif
|
||||
GM_TEST(Integ_CarrierMultiChannelTest)
|
||||
GM_TEST(Integ_CarrierBackpressureTest)
|
||||
GM_TEST(Integ_CarrierACKTest)
|
||||
GM_TEST(DISABLED_CarrierMultiChannelTest)
|
||||
GM_TEST(DISABLED_CarrierBackpressureTest)
|
||||
GM_TEST(DISABLED_CarrierACKTest)
|
||||
|
||||
|
||||
#if AZ_TRAIT_GRIDMATE_TEST_WITH_SECURE_SOCKET_DRIVER
|
||||
GM_TEST(CarrierBasicTestSecure)
|
||||
GM_TEST(Integ_CarrierSecureSocketHandshakeTestClient)
|
||||
GM_TEST(Integ_CarrierSecureSocketHandshakeTestHost)
|
||||
GM_TEST(Integ_CarrierSecureSocketHandshakeTestBoth)
|
||||
GM_TEST(DISABLED_CarrierBasicTestSecure)
|
||||
GM_TEST(DISABLED_CarrierSecureSocketHandshakeTestClient)
|
||||
GM_TEST(DISABLED_CarrierSecureSocketHandshakeTestHost)
|
||||
GM_TEST(DISABLED_CarrierSecureSocketHandshakeTestBoth)
|
||||
GM_TEST(CarrierTestSecure)
|
||||
GM_TEST(Integ_CarrierAsyncHandshakeTestSecure)
|
||||
GM_TEST(DISABLED_CarrierAsyncHandshakeTestSecure)
|
||||
#if !defined(AZ_DEBUG_BUILD) // this test is a little slow for debug
|
||||
GM_TEST(Integ_CarrierStressTestSecure)
|
||||
GM_TEST(Integ_CarrierMultiStressTestSecure)
|
||||
GM_TEST(DISABLED_CarrierStressTestSecure)
|
||||
GM_TEST(DISABLED_CarrierMultiStressTestSecure)
|
||||
#endif
|
||||
GM_TEST(Integ_CarrierMultiChannelTestSecure)
|
||||
GM_TEST(Integ_CarrierBackpressureTestSecure)
|
||||
GM_TEST(Integ_CarrierACKTestSecure)
|
||||
GM_TEST(DISABLED_CarrierMultiChannelTestSecure)
|
||||
GM_TEST(DISABLED_CarrierBackpressureTestSecure)
|
||||
GM_TEST(DISABLED_CarrierACKTestSecure)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ public:
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
class Integ_CarrierStreamBasicTest
|
||||
class DISABLED_CarrierStreamBasicTest
|
||||
: public GridMateMPTestFixture
|
||||
, protected SocketDriverSupplier
|
||||
{
|
||||
@@ -330,7 +330,7 @@ namespace UnitTest
|
||||
}
|
||||
};
|
||||
|
||||
class Integ_CarrierStreamAsyncHandshakeTest
|
||||
class DISABLED_CarrierStreamAsyncHandshakeTest
|
||||
: public GridMateMPTestFixture
|
||||
, protected SocketDriverSupplier
|
||||
{
|
||||
@@ -462,7 +462,7 @@ namespace UnitTest
|
||||
}
|
||||
};
|
||||
|
||||
class Integ_CarrierStreamStressTest
|
||||
class CarrierStreamStressTest
|
||||
: public GridMateMPTestFixture
|
||||
, protected SocketDriverSupplier
|
||||
, public ::testing::Test
|
||||
@@ -470,7 +470,7 @@ namespace UnitTest
|
||||
public:
|
||||
};
|
||||
|
||||
TEST_F(Integ_CarrierStreamStressTest, Stress_Test)
|
||||
TEST_F(CarrierStreamStressTest, DISABLED_Stress_Test)
|
||||
{
|
||||
CarrierStreamCallbacksHandler clientCB, serverCB;
|
||||
UnitTest::TestCarrierDesc serverCarrierDesc, clientCarrierDesc;
|
||||
@@ -581,7 +581,7 @@ namespace UnitTest
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
class Integ_CarrierStreamTest
|
||||
class DISABLED_CarrierStreamTest
|
||||
: public GridMateMPTestFixture
|
||||
, protected SocketDriverSupplier
|
||||
{
|
||||
@@ -783,7 +783,7 @@ namespace UnitTest
|
||||
}
|
||||
};
|
||||
|
||||
class Integ_CarrierStreamDisconnectDetectionTest
|
||||
class DISABLED_CarrierStreamDisconnectDetectionTest
|
||||
: public GridMateMPTestFixture
|
||||
, protected SocketDriverSupplier
|
||||
{
|
||||
@@ -873,7 +873,7 @@ namespace UnitTest
|
||||
}
|
||||
};
|
||||
|
||||
class Integ_CarrierStreamMultiChannelTest
|
||||
class DISABLED_CarrierStreamMultiChannelTest
|
||||
: public GridMateMPTestFixture
|
||||
, protected SocketDriverSupplier
|
||||
{
|
||||
@@ -999,8 +999,8 @@ namespace UnitTest
|
||||
}
|
||||
|
||||
GM_TEST_SUITE(CarrierStreamSuite)
|
||||
GM_TEST(Integ_CarrierStreamBasicTest)
|
||||
GM_TEST(Integ_CarrierStreamTest)
|
||||
GM_TEST(Integ_CarrierStreamAsyncHandshakeTest)
|
||||
GM_TEST(Integ_CarrierStreamMultiChannelTest)
|
||||
GM_TEST(DISABLED_CarrierStreamBasicTest)
|
||||
GM_TEST(DISABLED_CarrierStreamTest)
|
||||
GM_TEST(DISABLED_CarrierStreamAsyncHandshakeTest)
|
||||
GM_TEST(DISABLED_CarrierStreamMultiChannelTest)
|
||||
GM_TEST_SUITE_END()
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
*
|
||||
*/
|
||||
#include "Tests.h"
|
||||
#include "TestProfiler.h"
|
||||
|
||||
#include <GridMate/Replica/ReplicaFunctions.h>
|
||||
|
||||
@@ -1888,12 +1887,12 @@ protected:
|
||||
};
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class Integ_ReplicaGMTest
|
||||
class ReplicaGMTest
|
||||
: public UnitTest::GridMateMPTestFixture
|
||||
, public ::testing::Test
|
||||
{};
|
||||
|
||||
TEST_F(Integ_ReplicaGMTest, ReplicaTest)
|
||||
TEST_F(ReplicaGMTest, DISABLED_ReplicaTest)
|
||||
{
|
||||
ReplicaChunkDescriptorTable::Get().RegisterChunkType<MigratableReplica, MigratableReplica::Descriptor>();
|
||||
ReplicaChunkDescriptorTable::Get().RegisterChunkType<NonMigratableReplica>();
|
||||
@@ -2157,7 +2156,7 @@ TEST_F(Integ_ReplicaGMTest, ReplicaTest)
|
||||
}
|
||||
}
|
||||
|
||||
class Integ_ForcedReplicaMigrationTest
|
||||
class ForcedReplicaMigrationTest
|
||||
: public UnitTest::GridMateMPTestFixture
|
||||
, public ReplicaMgrCallbackBus::Handler
|
||||
, public MigratableReplica::MigratableReplicaDebugMsgs::EBus::Handler
|
||||
@@ -2186,8 +2185,8 @@ class Integ_ForcedReplicaMigrationTest
|
||||
}
|
||||
|
||||
public:
|
||||
Integ_ForcedReplicaMigrationTest() { ReplicaMgrCallbackBus::Handler::BusConnect(m_gridMate); }
|
||||
~Integ_ForcedReplicaMigrationTest() { ReplicaMgrCallbackBus::Handler::BusDisconnect(); }
|
||||
ForcedReplicaMigrationTest() { ReplicaMgrCallbackBus::Handler::BusConnect(m_gridMate); }
|
||||
~ForcedReplicaMigrationTest() { ReplicaMgrCallbackBus::Handler::BusDisconnect(); }
|
||||
|
||||
|
||||
enum
|
||||
@@ -2205,11 +2204,11 @@ public:
|
||||
AZStd::unordered_map<ReplicaId, ReplicaManager*> m_replicaOwnership;
|
||||
};
|
||||
|
||||
const int Integ_ForcedReplicaMigrationTest::k_frameTimePerNodeMs;
|
||||
const int Integ_ForcedReplicaMigrationTest::k_numFramesToRun;
|
||||
const int Integ_ForcedReplicaMigrationTest::k_hostSendRateMs;
|
||||
const int ForcedReplicaMigrationTest::k_frameTimePerNodeMs;
|
||||
const int ForcedReplicaMigrationTest::k_numFramesToRun;
|
||||
const int ForcedReplicaMigrationTest::k_hostSendRateMs;
|
||||
|
||||
TEST_F(Integ_ForcedReplicaMigrationTest, ForcedReplicaMigrationTest)
|
||||
TEST_F(ForcedReplicaMigrationTest, DISABLED_ForcedReplicaMigrationTest)
|
||||
{
|
||||
ReplicaChunkDescriptorTable::Get().RegisterChunkType<MigratableReplica, MigratableReplica::Descriptor>();
|
||||
ReplicaChunkDescriptorTable::Get().RegisterChunkType<NonMigratableReplica>();
|
||||
@@ -2360,7 +2359,7 @@ TEST_F(Integ_ForcedReplicaMigrationTest, ForcedReplicaMigrationTest)
|
||||
MigratableReplica::MigratableReplicaDebugMsgs::EBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
class Integ_ReplicaMigrationRequestTest
|
||||
class ReplicaMigrationRequestTest
|
||||
: public UnitTest::GridMateMPTestFixture
|
||||
, public ::testing::Test
|
||||
{
|
||||
@@ -2516,7 +2515,7 @@ public:
|
||||
static const int k_hostSendTimeMs = k_frameTimePerNodeMs * TotalNodes * 4; // limiting host send rate to be x4 times slower than tick
|
||||
};
|
||||
|
||||
TEST_F(Integ_ReplicaMigrationRequestTest, ReplicaMigrationRequestTest)
|
||||
TEST_F(ReplicaMigrationRequestTest, DISABLED_ReplicaMigrationRequestTest)
|
||||
{
|
||||
/*
|
||||
Topology:
|
||||
@@ -2837,11 +2836,11 @@ TEST_F(Integ_ReplicaMigrationRequestTest, ReplicaMigrationRequestTest)
|
||||
}
|
||||
}
|
||||
|
||||
const int Integ_ReplicaMigrationRequestTest::k_frameTimePerNodeMs;
|
||||
const int Integ_ReplicaMigrationRequestTest::k_hostSendTimeMs;
|
||||
const int ReplicaMigrationRequestTest::k_frameTimePerNodeMs;
|
||||
const int ReplicaMigrationRequestTest::k_hostSendTimeMs;
|
||||
|
||||
|
||||
class Integ_PeerRejoinTest
|
||||
class PeerRejoinTest
|
||||
: public UnitTest::GridMateMPTestFixture
|
||||
, public ReplicaMgrCallbackBus::Handler
|
||||
, public ::testing::Test
|
||||
@@ -2860,11 +2859,11 @@ class Integ_PeerRejoinTest
|
||||
}
|
||||
|
||||
public:
|
||||
Integ_PeerRejoinTest() { ReplicaMgrCallbackBus::Handler::BusConnect(m_gridMate); }
|
||||
~Integ_PeerRejoinTest() { ReplicaMgrCallbackBus::Handler::BusDisconnect(); }
|
||||
PeerRejoinTest() { ReplicaMgrCallbackBus::Handler::BusConnect(m_gridMate); }
|
||||
~PeerRejoinTest() { ReplicaMgrCallbackBus::Handler::BusDisconnect(); }
|
||||
};
|
||||
|
||||
TEST_F(Integ_PeerRejoinTest, PeerRejoinTest)
|
||||
TEST_F(PeerRejoinTest, DISABLED_PeerRejoinTest)
|
||||
{
|
||||
ReplicaChunkDescriptorTable::Get().RegisterChunkType<MigratableReplica, MigratableReplica::Descriptor>();
|
||||
ReplicaChunkDescriptorTable::Get().RegisterChunkType<NonMigratableReplica>();
|
||||
@@ -3011,7 +3010,7 @@ TEST_F(Integ_PeerRejoinTest, PeerRejoinTest)
|
||||
}
|
||||
}
|
||||
|
||||
class Integ_ReplicationSecurityOptionsTest
|
||||
class ReplicationSecurityOptionsTest
|
||||
: public UnitTest::GridMateMPTestFixture
|
||||
, public ::testing::Test
|
||||
{
|
||||
@@ -3156,7 +3155,7 @@ public:
|
||||
using TestChunkPtr = AZStd::intrusive_ptr<TestChunk> ;
|
||||
};
|
||||
|
||||
TEST_F(Integ_ReplicationSecurityOptionsTest, ReplicationSecurityOptionsTest)
|
||||
TEST_F(ReplicationSecurityOptionsTest, DISABLED_ReplicationSecurityOptionsTest)
|
||||
{
|
||||
AZ_TracePrintf("GridMate", "\n");
|
||||
|
||||
@@ -3356,7 +3355,7 @@ TEST_F(Integ_ReplicationSecurityOptionsTest, ReplicationSecurityOptionsTest)
|
||||
Replica update time (msec): avg=4.94, min=1, max=9 (peers=40, replicas=16000, freq=10%, samples=4000)
|
||||
Replica update time (msec): avg=8.05, min=6, max=15 (peers=40, replicas=16000, freq=100%, samples=4000)
|
||||
*/
|
||||
class Integ_ReplicaStressTest
|
||||
class DISABLED_ReplicaStressTest
|
||||
: public UnitTest::GridMateMPTestFixture
|
||||
{
|
||||
public:
|
||||
@@ -3388,7 +3387,7 @@ public:
|
||||
static const int BASE_PORT = 44270;
|
||||
|
||||
// TODO: Reduce the size or disable the test for platforms which can't allocate 2 GiB
|
||||
Integ_ReplicaStressTest()
|
||||
DISABLED_ReplicaStressTest()
|
||||
: UnitTest::GridMateMPTestFixture(2000u * 1024u * 1024u)
|
||||
{}
|
||||
|
||||
@@ -3516,33 +3515,33 @@ public:
|
||||
virtual void RunStressTests(MPSession* sessions, vector<AZStd::pair<ReplicaPtr, StressTestReplica::Ptr> >& replicas)
|
||||
{
|
||||
// testing 3 cases & waiting for system to settle in between
|
||||
TestProfiler::StartProfiling();
|
||||
//TestProfiler::StartProfiling();
|
||||
Wait(sessions, replicas, 50, FRAME_TIME);
|
||||
TestProfiler::PrintProfilingTotal("GridMate");
|
||||
//TestProfiler::PrintProfilingTotal("GridMate");
|
||||
|
||||
Wait(sessions, replicas, 20, FRAME_TIME);
|
||||
TestProfiler::StartProfiling();
|
||||
//TestProfiler::StartProfiling();
|
||||
TestReplicas(sessions, replicas, 100, FRAME_TIME, 0.0); // no replicas are dirty
|
||||
TestProfiler::PrintProfilingTotal("GridMate");
|
||||
//TestProfiler::PrintProfilingTotal("GridMate");
|
||||
|
||||
Wait(sessions, replicas, 20, FRAME_TIME);
|
||||
TestProfiler::StartProfiling();
|
||||
//TestProfiler::StartProfiling();
|
||||
TestReplicas(sessions, replicas, 1, FRAME_TIME, 1.0); // single burst dirty replicas
|
||||
Wait(sessions, replicas, 2, FRAME_TIME);
|
||||
TestProfiler::PrintProfilingTotal("GridMate");
|
||||
//TestProfiler::PrintProfilingTotal("GridMate");
|
||||
|
||||
Wait(sessions, replicas, 20, FRAME_TIME);
|
||||
TestProfiler::StartProfiling();
|
||||
//TestProfiler::StartProfiling();
|
||||
TestReplicas(sessions, replicas, 100, FRAME_TIME, 0.1); // 10% of replicas are marked dirty every frame
|
||||
TestProfiler::PrintProfilingTotal("GridMate");
|
||||
//TestProfiler::PrintProfilingTotal("GridMate");
|
||||
|
||||
Wait(sessions, replicas, 20, FRAME_TIME);
|
||||
TestProfiler::StartProfiling();
|
||||
//TestProfiler::StartProfiling();
|
||||
TestReplicas(sessions, replicas, 100, FRAME_TIME, 1.0); // every replica is marked dirty every frame
|
||||
TestProfiler::PrintProfilingTotal("GridMate");
|
||||
TestProfiler::PrintProfilingSelf("GridMate");
|
||||
//TestProfiler::PrintProfilingTotal("GridMate");
|
||||
//TestProfiler::PrintProfilingSelf("GridMate");
|
||||
|
||||
TestProfiler::StopProfiling();
|
||||
//TestProfiler::StopProfiling();
|
||||
}
|
||||
|
||||
virtual void MarkChanging(vector<AZStd::pair<ReplicaPtr, StressTestReplica::Ptr> >& replicas, double freq)
|
||||
@@ -3623,8 +3622,8 @@ public:
|
||||
Replica update time (msec): avg=2.01, min=1, max=5 (peers=40, replicas=16000, freq=10%, samples=4000)
|
||||
Replica update time (msec): avg=4.61, min=3, max=10 (peers=40, replicas=16000, freq=50%, samples=4000)
|
||||
*/
|
||||
class Integ_ReplicaStableStressTest
|
||||
: public Integ_ReplicaStressTest
|
||||
class DISABLED_ReplicaStableStressTest
|
||||
: public DISABLED_ReplicaStressTest
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -3636,21 +3635,21 @@ public:
|
||||
|
||||
void RunStressTests(MPSession* sessions, vector<AZStd::pair<ReplicaPtr, StressTestReplica::Ptr> >& replicas) override
|
||||
{
|
||||
Integ_ReplicaStressTest::MarkChanging(replicas, 0.1); // picks 10% of replicas
|
||||
DISABLED_ReplicaStressTest::MarkChanging(replicas, 0.1); // picks 10% of replicas
|
||||
Wait(sessions, replicas, 20, FRAME_TIME);
|
||||
TestProfiler::StartProfiling();
|
||||
//TestProfiler::StartProfiling();
|
||||
TestReplicas(sessions, replicas, 100, FRAME_TIME, 0.1);
|
||||
TestProfiler::PrintProfilingTotal("GridMate");
|
||||
TestProfiler::PrintProfilingSelf("GridMate");
|
||||
/*TestProfiler::PrintProfilingTotal("GridMate");
|
||||
TestProfiler::PrintProfilingSelf("GridMate");*/
|
||||
|
||||
Integ_ReplicaStressTest::MarkChanging(replicas, 0.5); // picks 50% of replicas
|
||||
DISABLED_ReplicaStressTest::MarkChanging(replicas, 0.5); // picks 50% of replicas
|
||||
Wait(sessions, replicas, 20, FRAME_TIME);
|
||||
TestProfiler::StartProfiling();
|
||||
//TestProfiler::StartProfiling();
|
||||
TestReplicas(sessions, replicas, 100, FRAME_TIME, 0.5);
|
||||
TestProfiler::PrintProfilingTotal("GridMate");
|
||||
/*TestProfiler::PrintProfilingTotal("GridMate");
|
||||
TestProfiler::PrintProfilingSelf("GridMate");
|
||||
|
||||
TestProfiler::StopProfiling();
|
||||
TestProfiler::StopProfiling();*/
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3666,7 +3665,7 @@ public:
|
||||
* expected |none |brst | capped |under cap |brst | capped |
|
||||
*
|
||||
*/
|
||||
class Integ_ReplicaBandiwdthTest
|
||||
class DISABLED_ReplicaBandiwdthTest
|
||||
: public UnitTest::GridMateMPTestFixture
|
||||
{
|
||||
public:
|
||||
@@ -3944,9 +3943,9 @@ GM_TEST_SUITE(ReplicaSuite)
|
||||
GM_TEST(InterpolatorTest)
|
||||
|
||||
#if !defined(AZ_DEBUG_BUILD) // these tests are a little slow for debug
|
||||
GM_TEST(Integ_ReplicaBandiwdthTest)
|
||||
GM_TEST(Integ_ReplicaStressTest)
|
||||
GM_TEST(Integ_ReplicaStableStressTest)
|
||||
GM_TEST(DISABLED_ReplicaBandiwdthTest)
|
||||
GM_TEST(DISABLED_ReplicaStressTest)
|
||||
GM_TEST(DISABLED_ReplicaStableStressTest)
|
||||
#endif
|
||||
|
||||
GM_TEST_SUITE_END()
|
||||
|
||||
@@ -457,13 +457,13 @@ namespace ReplicaBehavior {
|
||||
Completed,
|
||||
};
|
||||
|
||||
class Integ_SimpleBehaviorTest
|
||||
class SimpleBehaviorTest
|
||||
: public UnitTest::GridMateMPTestFixture
|
||||
{
|
||||
public:
|
||||
//GM_CLASS_ALLOCATOR(SimpleBehaviorTest);
|
||||
|
||||
Integ_SimpleBehaviorTest()
|
||||
SimpleBehaviorTest()
|
||||
: m_sessionCount(0) { }
|
||||
|
||||
virtual int GetNumSessions() { return 0; }
|
||||
@@ -654,11 +654,11 @@ namespace ReplicaBehavior {
|
||||
*
|
||||
* This is a simple sanity check to ensure the logic sends the update when it's necessary.
|
||||
*/
|
||||
class Integ_Replica_DontSendDataSets_WithNoDiffFromCtorData
|
||||
: public Integ_SimpleBehaviorTest
|
||||
class Replica_DontSendDataSets_WithNoDiffFromCtorData
|
||||
: public SimpleBehaviorTest
|
||||
{
|
||||
public:
|
||||
Integ_Replica_DontSendDataSets_WithNoDiffFromCtorData()
|
||||
Replica_DontSendDataSets_WithNoDiffFromCtorData()
|
||||
: m_replicaIdDefault(InvalidReplicaId), m_replicaIdModified(InvalidReplicaId)
|
||||
{
|
||||
}
|
||||
@@ -774,9 +774,9 @@ namespace ReplicaBehavior {
|
||||
FilteredHook<LargeChunkWithDefaults> m_driller;
|
||||
};
|
||||
|
||||
TEST(Integ_Replica_DontSendDataSets_WithNoDiffFromCtorData, Integ_Replica_DontSendDataSets_WithNoDiffFromCtorData)
|
||||
TEST(Replica_DontSendDataSets_WithNoDiffFromCtorData, DISABLED_Replica_DontSendDataSets_WithNoDiffFromCtorData)
|
||||
{
|
||||
Integ_Replica_DontSendDataSets_WithNoDiffFromCtorData tester;
|
||||
Replica_DontSendDataSets_WithNoDiffFromCtorData tester;
|
||||
tester.run();
|
||||
}
|
||||
|
||||
@@ -784,11 +784,11 @@ namespace ReplicaBehavior {
|
||||
* This test checks the actual size of the replica as marshalled in the binary payload.
|
||||
* The assessment of the payload size is done using driller EBus.
|
||||
*/
|
||||
class Integ_ReplicaDefaultDataSetDriller
|
||||
: public Integ_SimpleBehaviorTest
|
||||
class ReplicaDefaultDataSetDriller
|
||||
: public SimpleBehaviorTest
|
||||
{
|
||||
public:
|
||||
Integ_ReplicaDefaultDataSetDriller()
|
||||
ReplicaDefaultDataSetDriller()
|
||||
: m_replicaId(InvalidReplicaId)
|
||||
{
|
||||
}
|
||||
@@ -815,7 +815,7 @@ namespace ReplicaBehavior {
|
||||
m_replicaId = m_sessions[sHost].GetReplicaMgr().AddPrimary(replica);
|
||||
}
|
||||
|
||||
~Integ_ReplicaDefaultDataSetDriller() override
|
||||
~ReplicaDefaultDataSetDriller() override
|
||||
{
|
||||
m_driller.BusDisconnect();
|
||||
}
|
||||
@@ -880,11 +880,11 @@ namespace ReplicaBehavior {
|
||||
ReplicaId m_replicaId;
|
||||
};
|
||||
|
||||
const int Integ_ReplicaDefaultDataSetDriller::NonDefaultValue;
|
||||
const int ReplicaDefaultDataSetDriller::NonDefaultValue;
|
||||
|
||||
TEST(Integ_ReplicaDefaultDataSetDriller, Integ_ReplicaDefaultDataSetDriller)
|
||||
TEST(ReplicaDefaultDataSetDriller, DISABLED_ReplicaDefaultDataSetDriller)
|
||||
{
|
||||
Integ_ReplicaDefaultDataSetDriller tester;
|
||||
ReplicaDefaultDataSetDriller tester;
|
||||
tester.run();
|
||||
}
|
||||
|
||||
@@ -892,11 +892,11 @@ namespace ReplicaBehavior {
|
||||
* This test checks the actual size of the replica as marshalled in the binary payload.
|
||||
* The assessment of the payload size is done using driller EBus.
|
||||
*/
|
||||
class Integ_Replica_ComparePackingBoolsVsU8
|
||||
: public Integ_SimpleBehaviorTest
|
||||
class Replica_ComparePackingBoolsVsU8
|
||||
: public SimpleBehaviorTest
|
||||
{
|
||||
public:
|
||||
Integ_Replica_ComparePackingBoolsVsU8()
|
||||
Replica_ComparePackingBoolsVsU8()
|
||||
: m_replicaBoolsId(InvalidReplicaId)
|
||||
, m_replicaU8Id(InvalidReplicaId)
|
||||
{
|
||||
@@ -928,7 +928,7 @@ namespace ReplicaBehavior {
|
||||
m_replicaU8Id = m_sessions[sHost].GetReplicaMgr().AddPrimary(replica2);
|
||||
}
|
||||
|
||||
~Integ_Replica_ComparePackingBoolsVsU8() override
|
||||
~Replica_ComparePackingBoolsVsU8() override
|
||||
{
|
||||
m_driller.BusDisconnect();
|
||||
}
|
||||
@@ -1020,17 +1020,17 @@ namespace ReplicaBehavior {
|
||||
ReplicaId m_replicaU8Id;
|
||||
};
|
||||
|
||||
TEST(Integ_Replica_ComparePackingBoolsVsU8, Integ_Replica_ComparePackingBoolsVsU8)
|
||||
TEST(Replica_ComparePackingBoolsVsU8, DISABLED_Replica_ComparePackingBoolsVsU8)
|
||||
{
|
||||
Integ_Replica_ComparePackingBoolsVsU8 tester;
|
||||
Replica_ComparePackingBoolsVsU8 tester;
|
||||
tester.run();
|
||||
}
|
||||
|
||||
class Integ_CheckDataSetStreamIsntWrittenMoreThanNecessary
|
||||
: public Integ_SimpleBehaviorTest
|
||||
class CheckDataSetStreamIsntWrittenMoreThanNecessary
|
||||
: public SimpleBehaviorTest
|
||||
{
|
||||
public:
|
||||
Integ_CheckDataSetStreamIsntWrittenMoreThanNecessary()
|
||||
CheckDataSetStreamIsntWrittenMoreThanNecessary()
|
||||
: m_replicaId(InvalidReplicaId)
|
||||
{
|
||||
}
|
||||
@@ -1057,7 +1057,7 @@ namespace ReplicaBehavior {
|
||||
m_replicaId = m_sessions[sHost].GetReplicaMgr().AddPrimary(replica);
|
||||
}
|
||||
|
||||
~Integ_CheckDataSetStreamIsntWrittenMoreThanNecessary() override
|
||||
~CheckDataSetStreamIsntWrittenMoreThanNecessary() override
|
||||
{
|
||||
m_driller.BusDisconnect();
|
||||
}
|
||||
@@ -1117,17 +1117,17 @@ namespace ReplicaBehavior {
|
||||
ReplicaId m_replicaId;
|
||||
};
|
||||
|
||||
TEST(Integ_CheckDataSetStreamIsntWrittenMoreThanNecessary, Integ_CheckDataSetStreamIsntWrittenMoreThanNecessary)
|
||||
TEST(CheckDataSetStreamIsntWrittenMoreThanNecessary, DISABLED_CheckDataSetStreamIsntWrittenMoreThanNecessary)
|
||||
{
|
||||
Integ_CheckDataSetStreamIsntWrittenMoreThanNecessary tester;
|
||||
CheckDataSetStreamIsntWrittenMoreThanNecessary tester;
|
||||
tester.run();
|
||||
}
|
||||
|
||||
class Integ_CheckDataSetStreamIsntWrittenMoreThanNecessaryOnceDirty
|
||||
: public Integ_SimpleBehaviorTest
|
||||
class CheckDataSetStreamIsntWrittenMoreThanNecessaryOnceDirty
|
||||
: public SimpleBehaviorTest
|
||||
{
|
||||
public:
|
||||
Integ_CheckDataSetStreamIsntWrittenMoreThanNecessaryOnceDirty()
|
||||
CheckDataSetStreamIsntWrittenMoreThanNecessaryOnceDirty()
|
||||
: m_replicaId(InvalidReplicaId)
|
||||
{
|
||||
}
|
||||
@@ -1154,7 +1154,7 @@ namespace ReplicaBehavior {
|
||||
m_replicaId = m_sessions[sHost].GetReplicaMgr().AddPrimary(replica);
|
||||
}
|
||||
|
||||
~Integ_CheckDataSetStreamIsntWrittenMoreThanNecessaryOnceDirty() override
|
||||
~CheckDataSetStreamIsntWrittenMoreThanNecessaryOnceDirty() override
|
||||
{
|
||||
m_driller.BusDisconnect();
|
||||
}
|
||||
@@ -1213,17 +1213,17 @@ namespace ReplicaBehavior {
|
||||
ReplicaId m_replicaId;
|
||||
};
|
||||
|
||||
TEST(Integ_CheckDataSetStreamIsntWrittenMoreThanNecessaryOnceDirty, Integ_CheckDataSetStreamIsntWrittenMoreThanNecessaryOnceDirty)
|
||||
TEST(CheckDataSetStreamIsntWrittenMoreThanNecessaryOnceDirty, DISABLED_CheckDataSetStreamIsntWrittenMoreThanNecessaryOnceDirty)
|
||||
{
|
||||
Integ_CheckDataSetStreamIsntWrittenMoreThanNecessaryOnceDirty tester;
|
||||
CheckDataSetStreamIsntWrittenMoreThanNecessaryOnceDirty tester;
|
||||
tester.run();
|
||||
}
|
||||
|
||||
class Integ_CheckReplicaIsntSentWithNoChanges
|
||||
: public Integ_SimpleBehaviorTest
|
||||
class CheckReplicaIsntSentWithNoChanges
|
||||
: public SimpleBehaviorTest
|
||||
{
|
||||
public:
|
||||
Integ_CheckReplicaIsntSentWithNoChanges()
|
||||
CheckReplicaIsntSentWithNoChanges()
|
||||
: m_replicaId(InvalidReplicaId)
|
||||
{
|
||||
}
|
||||
@@ -1248,7 +1248,7 @@ namespace ReplicaBehavior {
|
||||
m_replicaId = m_sessions[sHost].GetReplicaMgr().AddPrimary(replica);
|
||||
}
|
||||
|
||||
~Integ_CheckReplicaIsntSentWithNoChanges() override
|
||||
~CheckReplicaIsntSentWithNoChanges() override
|
||||
{
|
||||
m_driller.BusDisconnect();
|
||||
}
|
||||
@@ -1323,17 +1323,17 @@ namespace ReplicaBehavior {
|
||||
ReplicaId m_replicaId;
|
||||
};
|
||||
|
||||
TEST(Integ_CheckReplicaIsntSentWithNoChanges, Integ_CheckReplicaIsntSentWithNoChanges)
|
||||
TEST(CheckReplicaIsntSentWithNoChanges, DISABLED_CheckReplicaIsntSentWithNoChanges)
|
||||
{
|
||||
Integ_CheckReplicaIsntSentWithNoChanges tester;
|
||||
CheckReplicaIsntSentWithNoChanges tester;
|
||||
tester.run();
|
||||
}
|
||||
|
||||
class Integ_CheckEntityScriptReplicaIsntSentWithNoChanges
|
||||
: public Integ_SimpleBehaviorTest
|
||||
class CheckEntityScriptReplicaIsntSentWithNoChanges
|
||||
: public SimpleBehaviorTest
|
||||
{
|
||||
public:
|
||||
Integ_CheckEntityScriptReplicaIsntSentWithNoChanges()
|
||||
CheckEntityScriptReplicaIsntSentWithNoChanges()
|
||||
: m_replicaId(InvalidReplicaId)
|
||||
{
|
||||
}
|
||||
@@ -1359,7 +1359,7 @@ namespace ReplicaBehavior {
|
||||
m_replicaId = m_sessions[sHost].GetReplicaMgr().AddPrimary(replica);
|
||||
}
|
||||
|
||||
~Integ_CheckEntityScriptReplicaIsntSentWithNoChanges() override
|
||||
~CheckEntityScriptReplicaIsntSentWithNoChanges() override
|
||||
{
|
||||
m_driller.BusDisconnect();
|
||||
}
|
||||
@@ -1410,9 +1410,9 @@ namespace ReplicaBehavior {
|
||||
ReplicaId m_replicaId;
|
||||
};
|
||||
|
||||
TEST(Integ_CheckEntityScriptReplicaIsntSentWithNoChanges, Integ_CheckEntityScriptReplicaIsntSentWithNoChanges)
|
||||
TEST(CheckEntityScriptReplicaIsntSentWithNoChanges, DISABLED_CheckEntityScriptReplicaIsntSentWithNoChanges)
|
||||
{
|
||||
Integ_CheckEntityScriptReplicaIsntSentWithNoChanges tester;
|
||||
CheckEntityScriptReplicaIsntSentWithNoChanges tester;
|
||||
tester.run();
|
||||
}
|
||||
|
||||
|
||||
@@ -596,12 +596,12 @@ public:
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
class MPSession
|
||||
class MPSessionMedium
|
||||
: public CarrierEventBus::Handler
|
||||
{
|
||||
public:
|
||||
|
||||
~MPSession() override
|
||||
~MPSessionMedium() override
|
||||
{
|
||||
CarrierEventBus::Handler::BusDisconnect();
|
||||
}
|
||||
@@ -708,14 +708,14 @@ enum class TestStatus
|
||||
Completed,
|
||||
};
|
||||
|
||||
class Integ_SimpleTest
|
||||
class SimpleTest
|
||||
: public UnitTest::GridMateMPTestFixture
|
||||
, public ::testing::Test
|
||||
{
|
||||
public:
|
||||
//GM_CLASS_ALLOCATOR(Integ_SimpleTest);
|
||||
//GM_CLASS_ALLOCATOR(SimpleTest);
|
||||
|
||||
Integ_SimpleTest()
|
||||
SimpleTest()
|
||||
: m_sessionCount(0) { }
|
||||
|
||||
virtual int GetNumSessions() { return 0; }
|
||||
@@ -858,15 +858,15 @@ public:
|
||||
}
|
||||
|
||||
int m_sessionCount;
|
||||
AZStd::array<MPSession, 10> m_sessions;
|
||||
AZStd::array<MPSessionMedium, 10> m_sessions;
|
||||
AZStd::unique_ptr<DefaultSimulator> m_defaultSimulator;
|
||||
};
|
||||
|
||||
class Integ_ReplicaChunkRPCExec
|
||||
: public Integ_SimpleTest
|
||||
class ReplicaChunkRPCExec
|
||||
: public SimpleTest
|
||||
{
|
||||
public:
|
||||
Integ_ReplicaChunkRPCExec()
|
||||
ReplicaChunkRPCExec()
|
||||
: m_chunk(nullptr)
|
||||
, m_replicaId(0)
|
||||
{ }
|
||||
@@ -893,7 +893,7 @@ public:
|
||||
ReplicaId m_replicaId;
|
||||
};
|
||||
|
||||
TEST_F(Integ_ReplicaChunkRPCExec, ReplicaChunkRPCExec)
|
||||
TEST_F(ReplicaChunkRPCExec, DISABLED_ReplicaChunkRPCExec)
|
||||
{
|
||||
RunTickLoop([this](int tick) -> TestStatus
|
||||
{
|
||||
@@ -1050,8 +1050,8 @@ int DestroyRPCChunk::s_afterDestroyFromPrimaryCalls = 0;
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class Integ_ReplicaDestroyedInRPC
|
||||
: public Integ_SimpleTest
|
||||
class ReplicaDestroyedInRPC
|
||||
: public SimpleTest
|
||||
{
|
||||
public:
|
||||
enum
|
||||
@@ -1080,7 +1080,7 @@ public:
|
||||
ReplicaId m_repId[2];
|
||||
};
|
||||
|
||||
TEST_F(Integ_ReplicaDestroyedInRPC, ReplicaDestroyedInRPC)
|
||||
TEST_F(ReplicaDestroyedInRPC, DISABLED_ReplicaDestroyedInRPC)
|
||||
{
|
||||
RunTickLoop([this](int tick)->TestStatus
|
||||
{
|
||||
@@ -1129,11 +1129,11 @@ TEST_F(Integ_ReplicaDestroyedInRPC, ReplicaDestroyedInRPC)
|
||||
});
|
||||
}
|
||||
|
||||
class Integ_ReplicaChunkAddWhileReplicated
|
||||
: public Integ_SimpleTest
|
||||
class ReplicaChunkAddWhileReplicated
|
||||
: public SimpleTest
|
||||
{
|
||||
public:
|
||||
Integ_ReplicaChunkAddWhileReplicated()
|
||||
ReplicaChunkAddWhileReplicated()
|
||||
: m_replica(nullptr)
|
||||
, m_chunk(nullptr)
|
||||
, m_replicaId(0)
|
||||
@@ -1161,7 +1161,7 @@ public:
|
||||
ReplicaId m_replicaId;
|
||||
};
|
||||
|
||||
TEST_F(Integ_ReplicaChunkAddWhileReplicated, ReplicaChunkAddWhileReplicated)
|
||||
TEST_F(ReplicaChunkAddWhileReplicated, DISABLED_ReplicaChunkAddWhileReplicated)
|
||||
{
|
||||
RunTickLoop([this](int tick)-> TestStatus
|
||||
{
|
||||
@@ -1203,11 +1203,11 @@ TEST_F(Integ_ReplicaChunkAddWhileReplicated, ReplicaChunkAddWhileReplicated)
|
||||
}
|
||||
|
||||
|
||||
class Integ_ReplicaRPCValues
|
||||
: public Integ_SimpleTest
|
||||
class ReplicaRPCValues
|
||||
: public SimpleTest
|
||||
{
|
||||
public:
|
||||
Integ_ReplicaRPCValues()
|
||||
ReplicaRPCValues()
|
||||
: m_replica(nullptr)
|
||||
, m_chunk(nullptr)
|
||||
, m_replicaId(0)
|
||||
@@ -1236,7 +1236,7 @@ public:
|
||||
ReplicaId m_replicaId;
|
||||
};
|
||||
|
||||
TEST_F(Integ_ReplicaRPCValues, ReplicaRPCValues)
|
||||
TEST_F(ReplicaRPCValues, DISABLED_ReplicaRPCValues)
|
||||
{
|
||||
RunTickLoop([this](int tick)-> TestStatus
|
||||
{
|
||||
@@ -1257,11 +1257,11 @@ TEST_F(Integ_ReplicaRPCValues, ReplicaRPCValues)
|
||||
});
|
||||
}
|
||||
|
||||
class Integ_FullRPCValues
|
||||
: public Integ_SimpleTest
|
||||
class FullRPCValues
|
||||
: public SimpleTest
|
||||
{
|
||||
public:
|
||||
Integ_FullRPCValues()
|
||||
FullRPCValues()
|
||||
: m_replica(nullptr)
|
||||
, m_chunk(nullptr)
|
||||
, m_replicaId(0)
|
||||
@@ -1290,7 +1290,7 @@ public:
|
||||
ReplicaId m_replicaId;
|
||||
};
|
||||
|
||||
TEST_F(Integ_FullRPCValues, FullRPCValues)
|
||||
TEST_F(FullRPCValues, DISABLED_FullRPCValues)
|
||||
{
|
||||
RunTickLoop([this](int tick)-> TestStatus
|
||||
{
|
||||
@@ -1364,11 +1364,11 @@ TEST_F(Integ_FullRPCValues, FullRPCValues)
|
||||
}
|
||||
|
||||
|
||||
class Integ_ReplicaRemoveProxy
|
||||
: public Integ_SimpleTest
|
||||
class ReplicaRemoveProxy
|
||||
: public SimpleTest
|
||||
{
|
||||
public:
|
||||
Integ_ReplicaRemoveProxy()
|
||||
ReplicaRemoveProxy()
|
||||
: m_replica(nullptr)
|
||||
, m_replicaId(0)
|
||||
{
|
||||
@@ -1395,7 +1395,7 @@ public:
|
||||
ReplicaId m_replicaId;
|
||||
};
|
||||
|
||||
TEST_F(Integ_ReplicaRemoveProxy, ReplicaRemoveProxy)
|
||||
TEST_F(ReplicaRemoveProxy, DISABLED_ReplicaRemoveProxy)
|
||||
{
|
||||
RunTickLoop([this](int tick)-> TestStatus
|
||||
{
|
||||
@@ -1424,11 +1424,11 @@ TEST_F(Integ_ReplicaRemoveProxy, ReplicaRemoveProxy)
|
||||
}
|
||||
|
||||
|
||||
class Integ_ReplicaChunkEvents
|
||||
: public Integ_SimpleTest
|
||||
class ReplicaChunkEvents
|
||||
: public SimpleTest
|
||||
{
|
||||
public:
|
||||
Integ_ReplicaChunkEvents()
|
||||
ReplicaChunkEvents()
|
||||
: m_replicaId(InvalidReplicaId)
|
||||
, m_chunk(nullptr)
|
||||
, m_proxyChunk(nullptr)
|
||||
@@ -1463,7 +1463,7 @@ public:
|
||||
AllEventChunk::Ptr m_proxyChunk;
|
||||
};
|
||||
|
||||
TEST_F(Integ_ReplicaChunkEvents, ReplicaChunkEvents)
|
||||
TEST_F(ReplicaChunkEvents, DISABLED_ReplicaChunkEvents)
|
||||
{
|
||||
RunTickLoop([this](int tick)-> TestStatus
|
||||
{
|
||||
@@ -1501,11 +1501,11 @@ TEST_F(Integ_ReplicaChunkEvents, ReplicaChunkEvents)
|
||||
}
|
||||
|
||||
|
||||
class Integ_ReplicaChunksBeyond32
|
||||
: public Integ_SimpleTest
|
||||
class ReplicaChunksBeyond32
|
||||
: public SimpleTest
|
||||
{
|
||||
public:
|
||||
Integ_ReplicaChunksBeyond32()
|
||||
ReplicaChunksBeyond32()
|
||||
: m_replicaId(InvalidReplicaId)
|
||||
{
|
||||
}
|
||||
@@ -1537,7 +1537,7 @@ public:
|
||||
ReplicaId m_replicaId;
|
||||
};
|
||||
|
||||
TEST_F(Integ_ReplicaChunksBeyond32, ReplicaChunksBeyond32)
|
||||
TEST_F(ReplicaChunksBeyond32, DISABLED_ReplicaChunksBeyond32)
|
||||
{
|
||||
RunTickLoop([this](int tick)-> TestStatus
|
||||
{
|
||||
@@ -1565,11 +1565,11 @@ TEST_F(Integ_ReplicaChunksBeyond32, ReplicaChunksBeyond32)
|
||||
}
|
||||
|
||||
|
||||
class Integ_ReplicaChunkEventsDeactivate
|
||||
: public Integ_SimpleTest
|
||||
class ReplicaChunkEventsDeactivate
|
||||
: public SimpleTest
|
||||
{
|
||||
public:
|
||||
Integ_ReplicaChunkEventsDeactivate()
|
||||
ReplicaChunkEventsDeactivate()
|
||||
: m_replica(nullptr)
|
||||
, m_replicaId(0)
|
||||
, m_chunk(nullptr)
|
||||
@@ -1604,7 +1604,7 @@ public:
|
||||
AllEventChunk::Ptr m_proxyChunk;
|
||||
};
|
||||
|
||||
TEST_F(Integ_ReplicaChunkEventsDeactivate, ReplicaChunkEventsDeactivate)
|
||||
TEST_F(ReplicaChunkEventsDeactivate, DISABLED_ReplicaChunkEventsDeactivate)
|
||||
{
|
||||
RunTickLoop([this](int tick)-> TestStatus
|
||||
{
|
||||
@@ -1649,11 +1649,11 @@ TEST_F(Integ_ReplicaChunkEventsDeactivate, ReplicaChunkEventsDeactivate)
|
||||
}
|
||||
|
||||
|
||||
class Integ_ReplicaDriller
|
||||
: public Integ_SimpleTest
|
||||
class ReplicaDriller
|
||||
: public SimpleTest
|
||||
{
|
||||
public:
|
||||
Integ_ReplicaDriller()
|
||||
ReplicaDriller()
|
||||
: m_replicaId(InvalidReplicaId)
|
||||
{
|
||||
}
|
||||
@@ -2007,7 +2007,7 @@ public:
|
||||
m_replicaId = m_sessions[sHost].GetReplicaMgr().AddPrimary(replica);
|
||||
}
|
||||
|
||||
~Integ_ReplicaDriller() override
|
||||
~ReplicaDriller() override
|
||||
{
|
||||
m_driller.BusDisconnect();
|
||||
}
|
||||
@@ -2016,7 +2016,7 @@ public:
|
||||
ReplicaId m_replicaId;
|
||||
};
|
||||
|
||||
TEST_F(Integ_ReplicaDriller, ReplicaDriller)
|
||||
TEST_F(ReplicaDriller, DISABLED_ReplicaDriller)
|
||||
{
|
||||
RunTickLoop([this](int tick)-> TestStatus
|
||||
{
|
||||
@@ -2082,11 +2082,11 @@ TEST_F(Integ_ReplicaDriller, ReplicaDriller)
|
||||
}
|
||||
|
||||
|
||||
class Integ_DataSetChangedTest
|
||||
: public Integ_SimpleTest
|
||||
class DataSetChangedTest
|
||||
: public SimpleTest
|
||||
{
|
||||
public:
|
||||
Integ_DataSetChangedTest()
|
||||
DataSetChangedTest()
|
||||
: m_replica(nullptr)
|
||||
, m_replicaId(0)
|
||||
, m_chunk(nullptr)
|
||||
@@ -2115,7 +2115,7 @@ public:
|
||||
DataSetChunk::Ptr m_chunk;
|
||||
};
|
||||
|
||||
TEST_F(Integ_DataSetChangedTest, DataSetChangedTest)
|
||||
TEST_F(DataSetChangedTest, DISABLED_DataSetChangedTest)
|
||||
{
|
||||
RunTickLoop([this](int tick)-> TestStatus
|
||||
{
|
||||
@@ -2144,11 +2144,11 @@ TEST_F(Integ_DataSetChangedTest, DataSetChangedTest)
|
||||
}
|
||||
|
||||
|
||||
class Integ_CustomHandlerTest
|
||||
: public Integ_SimpleTest
|
||||
class CustomHandlerTest
|
||||
: public SimpleTest
|
||||
{
|
||||
public:
|
||||
Integ_CustomHandlerTest()
|
||||
CustomHandlerTest()
|
||||
: m_replica(nullptr)
|
||||
, m_replicaId(0)
|
||||
, m_chunk(nullptr)
|
||||
@@ -2181,7 +2181,7 @@ public:
|
||||
AZStd::scoped_ptr<CustomHandler> m_proxyHandler;
|
||||
};
|
||||
|
||||
TEST_F(Integ_CustomHandlerTest, CustomHandlerTest)
|
||||
TEST_F(CustomHandlerTest, DISABLED_CustomHandlerTest)
|
||||
{
|
||||
RunTickLoop([this](int tick)-> TestStatus
|
||||
{
|
||||
@@ -2234,11 +2234,11 @@ TEST_F(Integ_CustomHandlerTest, CustomHandlerTest)
|
||||
}
|
||||
|
||||
|
||||
class Integ_NonConstMarshalerTest
|
||||
: public Integ_SimpleTest
|
||||
class NonConstMarshalerTest
|
||||
: public SimpleTest
|
||||
{
|
||||
public:
|
||||
Integ_NonConstMarshalerTest()
|
||||
NonConstMarshalerTest()
|
||||
: m_replica(nullptr)
|
||||
, m_replicaId(0)
|
||||
, m_chunk(nullptr)
|
||||
@@ -2266,7 +2266,7 @@ public:
|
||||
NonConstMarshalerChunk::Ptr m_chunk;
|
||||
};
|
||||
|
||||
TEST_F(Integ_NonConstMarshalerTest, NonConstMarshalerTest)
|
||||
TEST_F(NonConstMarshalerTest, DISABLED_NonConstMarshalerTest)
|
||||
{
|
||||
RunTickLoop([this](int tick)-> TestStatus
|
||||
{
|
||||
@@ -2309,11 +2309,11 @@ TEST_F(Integ_NonConstMarshalerTest, NonConstMarshalerTest)
|
||||
}
|
||||
|
||||
|
||||
class Integ_SourcePeerTest
|
||||
: public Integ_SimpleTest
|
||||
class SourcePeerTest
|
||||
: public SimpleTest
|
||||
{
|
||||
public:
|
||||
Integ_SourcePeerTest()
|
||||
SourcePeerTest()
|
||||
: m_replica(nullptr)
|
||||
, m_replicaId(0)
|
||||
, m_chunk(nullptr)
|
||||
@@ -2343,7 +2343,7 @@ public:
|
||||
SourcePeerChunk::Ptr m_chunk2;
|
||||
};
|
||||
|
||||
TEST_F(Integ_SourcePeerTest, SourcePeerTest)
|
||||
TEST_F(SourcePeerTest, DISABLED_SourcePeerTest)
|
||||
{
|
||||
RunTickLoop([this](int tick)-> TestStatus
|
||||
{
|
||||
@@ -2404,8 +2404,8 @@ TEST_F(Integ_SourcePeerTest, SourcePeerTest)
|
||||
}
|
||||
|
||||
|
||||
class Integ_SendWithPriority
|
||||
: public Integ_SimpleTest
|
||||
class SendWithPriority
|
||||
: public SimpleTest
|
||||
{
|
||||
public:
|
||||
enum
|
||||
@@ -2438,8 +2438,8 @@ public:
|
||||
{
|
||||
public:
|
||||
ReplicaDrillerHook()
|
||||
: m_expectedSendValue(Integ_SendWithPriority::kNumReplicas)
|
||||
, m_expectedRecvValue(Integ_SendWithPriority::kNumReplicas)
|
||||
: m_expectedSendValue(SendWithPriority::kNumReplicas)
|
||||
, m_expectedRecvValue(SendWithPriority::kNumReplicas)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -2495,7 +2495,7 @@ public:
|
||||
PriorityChunk::Ptr m_chunks[kNumReplicas];
|
||||
};
|
||||
|
||||
TEST_F(Integ_SendWithPriority, SendWithPriority)
|
||||
TEST_F(SendWithPriority, DISABLED_SendWithPriority)
|
||||
{
|
||||
RunTickLoop([this](int tick)-> TestStatus
|
||||
{
|
||||
@@ -2511,8 +2511,8 @@ TEST_F(Integ_SendWithPriority, SendWithPriority)
|
||||
}
|
||||
|
||||
|
||||
class Integ_SuspendUpdatesTest
|
||||
: public Integ_SimpleTest
|
||||
class SuspendUpdatesTest
|
||||
: public SimpleTest
|
||||
{
|
||||
public:
|
||||
enum
|
||||
@@ -2597,7 +2597,7 @@ public:
|
||||
unsigned int m_numRpcCalled = 0;
|
||||
};
|
||||
|
||||
TEST_F(Integ_SuspendUpdatesTest, SuspendUpdatesTest)
|
||||
TEST_F(SuspendUpdatesTest, DISABLED_SuspendUpdatesTest)
|
||||
{
|
||||
RunTickLoop([this](int tick)-> TestStatus
|
||||
{
|
||||
@@ -2657,7 +2657,7 @@ TEST_F(Integ_SuspendUpdatesTest, SuspendUpdatesTest)
|
||||
}
|
||||
|
||||
|
||||
class Integ_BasicHostChunkDescriptorTest
|
||||
class BasicHostChunkDescriptorTest
|
||||
: public UnitTest::GridMateMPTestFixture
|
||||
, public ::testing::Test
|
||||
{
|
||||
@@ -2694,17 +2694,17 @@ public:
|
||||
static int nProxyActivations;
|
||||
};
|
||||
};
|
||||
int Integ_BasicHostChunkDescriptorTest::HostChunk::nPrimaryActivations = 0;
|
||||
int Integ_BasicHostChunkDescriptorTest::HostChunk::nProxyActivations = 0;
|
||||
int BasicHostChunkDescriptorTest::HostChunk::nPrimaryActivations = 0;
|
||||
int BasicHostChunkDescriptorTest::HostChunk::nProxyActivations = 0;
|
||||
|
||||
TEST_F(Integ_BasicHostChunkDescriptorTest, BasicHostChunkDescriptorTest)
|
||||
TEST_F(BasicHostChunkDescriptorTest, DISABLED_BasicHostChunkDescriptorTest)
|
||||
{
|
||||
AZ_TracePrintf("GridMate", "\n");
|
||||
|
||||
// Register test chunks
|
||||
ReplicaChunkDescriptorTable::Get().RegisterChunkType<HostChunk, GridMate::BasicHostChunkDescriptor<HostChunk>>();
|
||||
|
||||
MPSession nodes[nNodes];
|
||||
MPSessionMedium nodes[nNodes];
|
||||
|
||||
// initialize transport
|
||||
int basePort = 4427;
|
||||
@@ -2791,8 +2791,8 @@ TEST_F(Integ_BasicHostChunkDescriptorTest, BasicHostChunkDescriptorTest)
|
||||
* Create and immedietly destroy primary replica
|
||||
* Test that it does not result in any network sync
|
||||
*/
|
||||
class Integ_CreateDestroyPrimary
|
||||
: public Integ_SimpleTest
|
||||
class CreateDestroyPrimary
|
||||
: public SimpleTest
|
||||
, public Debug::ReplicaDrillerBus::Handler
|
||||
{
|
||||
public:
|
||||
@@ -2827,7 +2827,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(Integ_CreateDestroyPrimary, CreateDestroyPrimary)
|
||||
TEST_F(CreateDestroyPrimary, DISABLED_CreateDestroyPrimary)
|
||||
{
|
||||
RunTickLoop([this](int tick)-> TestStatus
|
||||
{
|
||||
@@ -2861,7 +2861,7 @@ TEST_F(Integ_CreateDestroyPrimary, CreateDestroyPrimary)
|
||||
* The ReplicaTarget will prevent sending more updates.
|
||||
*/
|
||||
class ReplicaACKfeedbackTestFixture
|
||||
: public Integ_SimpleTest
|
||||
: public SimpleTest
|
||||
{
|
||||
public:
|
||||
ReplicaACKfeedbackTestFixture()
|
||||
@@ -2900,7 +2900,7 @@ public:
|
||||
|
||||
size_t m_replicaBytesSentPrev = 0;
|
||||
ReplicaId m_replicaId;
|
||||
Integ_ReplicaDriller::ReplicaDrillerHook m_driller;
|
||||
ReplicaDriller::ReplicaDrillerHook m_driller;
|
||||
};
|
||||
|
||||
TEST_F(ReplicaACKfeedbackTestFixture, ReplicaACKfeedbackTest)
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace UnitTest
|
||||
}
|
||||
}
|
||||
|
||||
class Integ_LANSessionMatchmakingParamsTest
|
||||
class DISABLED_LANSessionMatchmakingParamsTest
|
||||
: public GridMateMPTestFixture
|
||||
, public SessionEventBus::MultiHandler
|
||||
{
|
||||
@@ -52,7 +52,7 @@ namespace UnitTest
|
||||
}
|
||||
|
||||
public:
|
||||
Integ_LANSessionMatchmakingParamsTest(bool useIPv6 = false)
|
||||
DISABLED_LANSessionMatchmakingParamsTest(bool useIPv6 = false)
|
||||
: m_hostSession(nullptr)
|
||||
, m_clientGridMate(nullptr)
|
||||
{
|
||||
@@ -71,7 +71,7 @@ namespace UnitTest
|
||||
AZ_TEST_ASSERT(GridMate::LANSessionServiceBus::FindFirstHandler(m_clientGridMate) != nullptr);
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
~Integ_LANSessionMatchmakingParamsTest() override
|
||||
~DISABLED_LANSessionMatchmakingParamsTest() override
|
||||
{
|
||||
SessionEventBus::MultiHandler::BusDisconnect(m_gridMate);
|
||||
SessionEventBus::MultiHandler::BusDisconnect(m_clientGridMate);
|
||||
@@ -192,7 +192,7 @@ namespace UnitTest
|
||||
IGridMate* m_clientGridMate;
|
||||
};
|
||||
|
||||
class Integ_LANSessionTest
|
||||
class DISABLED_LANSessionTest
|
||||
: public GridMateMPTestFixture
|
||||
{
|
||||
class TestPeerInfo
|
||||
@@ -264,7 +264,7 @@ namespace UnitTest
|
||||
};
|
||||
|
||||
public:
|
||||
Integ_LANSessionTest(bool useIPv6 = false)
|
||||
DISABLED_LANSessionTest(bool useIPv6 = false)
|
||||
{
|
||||
m_driverType = useIPv6 ? Driver::BSD_AF_INET6 : Driver::BSD_AF_INET;
|
||||
m_doSessionParamsTest = k_numMachines > 1;
|
||||
@@ -290,7 +290,7 @@ namespace UnitTest
|
||||
AZ_TEST_ASSERT(LANSessionServiceBus::FindFirstHandler(m_peers[i].m_gridMate) != nullptr);
|
||||
}
|
||||
}
|
||||
~Integ_LANSessionTest() override
|
||||
~DISABLED_LANSessionTest() override
|
||||
{
|
||||
StopGridMateService<LANSessionService>(m_peers[0].m_gridMate);
|
||||
|
||||
@@ -555,15 +555,15 @@ namespace UnitTest
|
||||
bool m_doSessionParamsTest;
|
||||
};
|
||||
|
||||
class Integ_LANSessionTestIPv6
|
||||
: public Integ_LANSessionTest
|
||||
class DISABLED_LANSessionTestIPv6
|
||||
: public DISABLED_LANSessionTest
|
||||
{
|
||||
public:
|
||||
Integ_LANSessionTestIPv6()
|
||||
: Integ_LANSessionTest(true) {}
|
||||
DISABLED_LANSessionTestIPv6()
|
||||
: DISABLED_LANSessionTest(true) {}
|
||||
};
|
||||
|
||||
class Integ_LANMultipleSessionTest
|
||||
class DISABLED_LANMultipleSessionTest
|
||||
: public GridMateMPTestFixture
|
||||
, public SessionEventBus::Handler
|
||||
{
|
||||
@@ -620,7 +620,7 @@ namespace UnitTest
|
||||
m_sessions[i] = nullptr;
|
||||
}
|
||||
|
||||
Integ_LANMultipleSessionTest()
|
||||
DISABLED_LANMultipleSessionTest()
|
||||
: GridMateMPTestFixture(200 * 1024 * 1024)
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -645,7 +645,7 @@ namespace UnitTest
|
||||
}
|
||||
}
|
||||
|
||||
~Integ_LANMultipleSessionTest() override
|
||||
~DISABLED_LANMultipleSessionTest() override
|
||||
{
|
||||
GridMate::StopGridMateService<GridMate::LANSessionService>(m_gridMates[0]);
|
||||
|
||||
@@ -799,7 +799,7 @@ namespace UnitTest
|
||||
* Testing session with low latency. This is special mode usually used by tools and communication channels
|
||||
* where we try to response instantly on messages.
|
||||
*/
|
||||
class Integ_LANLatencySessionTest
|
||||
class DISABLED_LANLatencySessionTest
|
||||
: public GridMateMPTestFixture
|
||||
, public SessionEventBus::Handler
|
||||
{
|
||||
@@ -857,7 +857,7 @@ namespace UnitTest
|
||||
m_sessions[i] = nullptr;
|
||||
}
|
||||
|
||||
Integ_LANLatencySessionTest()
|
||||
DISABLED_LANLatencySessionTest()
|
||||
#ifdef AZ_TEST_LANLATENCY_ENABLE_MONSTER_BUFFER
|
||||
: GridMateMPTestFixture(50 * 1024 * 1024)
|
||||
#endif
|
||||
@@ -884,7 +884,7 @@ namespace UnitTest
|
||||
}
|
||||
}
|
||||
|
||||
~Integ_LANLatencySessionTest() override
|
||||
~DISABLED_LANLatencySessionTest() override
|
||||
{
|
||||
StopGridMateService<LANSessionService>(m_gridMates[0]);
|
||||
|
||||
@@ -1162,7 +1162,7 @@ namespace UnitTest
|
||||
* 5. After host migration we drop the new host again. (after migration we have 3 members).
|
||||
* Session should be fully operational at the end with 3 members left.
|
||||
*/
|
||||
class Integ_LANSessionMigarationTestTest
|
||||
class LANSessionMigarationTestTest
|
||||
: public SessionEventBus::Handler
|
||||
, public GridMateMPTestFixture
|
||||
{
|
||||
@@ -1257,7 +1257,7 @@ namespace UnitTest
|
||||
}
|
||||
}
|
||||
|
||||
Integ_LANSessionMigarationTestTest()
|
||||
LANSessionMigarationTestTest()
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Create all grid mates
|
||||
@@ -1283,7 +1283,7 @@ namespace UnitTest
|
||||
//StartDrilling("lanmigration");
|
||||
}
|
||||
|
||||
~Integ_LANSessionMigarationTestTest() override
|
||||
~LANSessionMigarationTestTest() override
|
||||
{
|
||||
StopGridMateService<LANSessionService>(m_gridMates[0]);
|
||||
|
||||
@@ -1476,7 +1476,7 @@ namespace UnitTest
|
||||
* 5. We join a 2 new members to the session.
|
||||
* Session should be fully operational at the end with 4 members in it.
|
||||
*/
|
||||
class Integ_LANSessionMigarationTestTest2
|
||||
class LANSessionMigarationTestTest2
|
||||
: public SessionEventBus::Handler
|
||||
, public GridMateMPTestFixture
|
||||
{
|
||||
@@ -1571,7 +1571,7 @@ namespace UnitTest
|
||||
}
|
||||
}
|
||||
}
|
||||
Integ_LANSessionMigarationTestTest2()
|
||||
LANSessionMigarationTestTest2()
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Create all grid mates
|
||||
@@ -1597,7 +1597,7 @@ namespace UnitTest
|
||||
|
||||
//StartDrilling("lanmigration2");
|
||||
}
|
||||
~Integ_LANSessionMigarationTestTest2() override
|
||||
~LANSessionMigarationTestTest2() override
|
||||
{
|
||||
StopGridMateService<LANSessionService>(m_gridMates[0]);
|
||||
|
||||
@@ -1816,7 +1816,7 @@ namespace UnitTest
|
||||
* 3. Add 2 new joins to the original session.
|
||||
* Original session should remain fully operational with 4 members in it.
|
||||
*/
|
||||
class Integ_LANSessionMigarationTestTest3
|
||||
class LANSessionMigarationTestTest3
|
||||
: public SessionEventBus::Handler
|
||||
, public GridMateMPTestFixture
|
||||
{
|
||||
@@ -1910,7 +1910,7 @@ namespace UnitTest
|
||||
}
|
||||
}
|
||||
}
|
||||
Integ_LANSessionMigarationTestTest3()
|
||||
LANSessionMigarationTestTest3()
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Create all grid mates
|
||||
@@ -1936,7 +1936,7 @@ namespace UnitTest
|
||||
//StartDrilling("lanmigration2");
|
||||
}
|
||||
|
||||
~Integ_LANSessionMigarationTestTest3() override
|
||||
~LANSessionMigarationTestTest3() override
|
||||
{
|
||||
StopGridMateService<LANSessionService>(m_gridMates[0]);
|
||||
|
||||
@@ -2122,13 +2122,13 @@ namespace UnitTest
|
||||
}
|
||||
|
||||
GM_TEST_SUITE(SessionSuite)
|
||||
GM_TEST(Integ_LANSessionMatchmakingParamsTest)
|
||||
GM_TEST(Integ_LANSessionTest)
|
||||
GM_TEST(DISABLED_LANSessionMatchmakingParamsTest)
|
||||
GM_TEST(DISABLED_LANSessionTest)
|
||||
#if (AZ_TRAIT_GRIDMATE_TEST_SOCKET_IPV6_SUPPORT_ENABLED)
|
||||
GM_TEST(Integ_LANSessionTestIPv6)
|
||||
GM_TEST(DISABLED_LANSessionTestIPv6)
|
||||
#endif
|
||||
GM_TEST(Integ_LANMultipleSessionTest)
|
||||
GM_TEST(Integ_LANLatencySessionTest)
|
||||
GM_TEST(DISABLED_LANMultipleSessionTest)
|
||||
GM_TEST(DISABLED_LANLatencySessionTest)
|
||||
|
||||
// Manually enabled tests (require 2+ machines and online services)
|
||||
//GM_TEST(LANSessionMigarationTestTest)
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace UnitTest
|
||||
std::array<char, SIZE> m_buffer;
|
||||
};
|
||||
|
||||
class Integ_StreamSecureSocketDriverTestsBindSocketEmpty
|
||||
class DISABLED_StreamSecureSocketDriverTestsBindSocketEmpty
|
||||
: public GridMateMPTestFixture
|
||||
{
|
||||
public:
|
||||
@@ -134,7 +134,7 @@ namespace UnitTest
|
||||
}
|
||||
};
|
||||
|
||||
class Integ_StreamSecureSocketDriverTestsConnection
|
||||
class DISABLED_StreamSecureSocketDriverTestsConnection
|
||||
: public GridMateMPTestFixture
|
||||
{
|
||||
public:
|
||||
@@ -146,7 +146,7 @@ namespace UnitTest
|
||||
}
|
||||
};
|
||||
|
||||
class Integ_StreamSecureSocketDriverTestsConnectionAndHelloWorld
|
||||
class DISABLED_StreamSecureSocketDriverTestsConnectionAndHelloWorld
|
||||
: public GridMateMPTestFixture
|
||||
{
|
||||
public:
|
||||
@@ -190,7 +190,7 @@ namespace UnitTest
|
||||
}
|
||||
};
|
||||
|
||||
class Integ_StreamSecureSocketDriverTestsPingPong
|
||||
class DISABLED_StreamSecureSocketDriverTestsPingPong
|
||||
: public GridMateMPTestFixture
|
||||
{
|
||||
public:
|
||||
@@ -425,13 +425,13 @@ namespace UnitTest
|
||||
|
||||
void BuildStateMachine()
|
||||
{
|
||||
m_stateMachine.SetStateHandler(AZ_HSM_STATE_NAME(TS_TOP), AZ::HSM::StateHandler(this, &Integ_StreamSecureSocketDriverTestsPingPong::OnStateTop), AZ::HSM::InvalidStateId, TS_START);
|
||||
m_stateMachine.SetStateHandler(AZ_HSM_STATE_NAME(TS_START), AZ::HSM::StateHandler(this, &Integ_StreamSecureSocketDriverTestsPingPong::OnStateStart), TS_TOP);
|
||||
m_stateMachine.SetStateHandler(AZ_HSM_STATE_NAME(TS_SERVER_GET_PING), AZ::HSM::StateHandler(this, &Integ_StreamSecureSocketDriverTestsPingPong::OnStateServerGetPing), TS_TOP);
|
||||
m_stateMachine.SetStateHandler(AZ_HSM_STATE_NAME(TS_PING_GET_SERVER), AZ::HSM::StateHandler(this, &Integ_StreamSecureSocketDriverTestsPingPong::OnStatePingGetServer), TS_TOP);
|
||||
m_stateMachine.SetStateHandler(AZ_HSM_STATE_NAME(TS_SERVER_GET_PONG), AZ::HSM::StateHandler(this, &Integ_StreamSecureSocketDriverTestsPingPong::OnStateServerGetPong), TS_TOP);
|
||||
m_stateMachine.SetStateHandler(AZ_HSM_STATE_NAME(TS_PONG_GET_SERVER), AZ::HSM::StateHandler(this, &Integ_StreamSecureSocketDriverTestsPingPong::OnStatePongGetServer), TS_TOP);
|
||||
m_stateMachine.SetStateHandler(AZ_HSM_STATE_NAME(TS_IN_ERROR), AZ::HSM::StateHandler(this, &Integ_StreamSecureSocketDriverTestsPingPong::OnStateInError), TS_TOP);
|
||||
m_stateMachine.SetStateHandler(AZ_HSM_STATE_NAME(TS_TOP), AZ::HSM::StateHandler(this, &DISABLED_StreamSecureSocketDriverTestsPingPong::OnStateTop), AZ::HSM::InvalidStateId, TS_START);
|
||||
m_stateMachine.SetStateHandler(AZ_HSM_STATE_NAME(TS_START), AZ::HSM::StateHandler(this, &DISABLED_StreamSecureSocketDriverTestsPingPong::OnStateStart), TS_TOP);
|
||||
m_stateMachine.SetStateHandler(AZ_HSM_STATE_NAME(TS_SERVER_GET_PING), AZ::HSM::StateHandler(this, &DISABLED_StreamSecureSocketDriverTestsPingPong::OnStateServerGetPing), TS_TOP);
|
||||
m_stateMachine.SetStateHandler(AZ_HSM_STATE_NAME(TS_PING_GET_SERVER), AZ::HSM::StateHandler(this, &DISABLED_StreamSecureSocketDriverTestsPingPong::OnStatePingGetServer), TS_TOP);
|
||||
m_stateMachine.SetStateHandler(AZ_HSM_STATE_NAME(TS_SERVER_GET_PONG), AZ::HSM::StateHandler(this, &DISABLED_StreamSecureSocketDriverTestsPingPong::OnStateServerGetPong), TS_TOP);
|
||||
m_stateMachine.SetStateHandler(AZ_HSM_STATE_NAME(TS_PONG_GET_SERVER), AZ::HSM::StateHandler(this, &DISABLED_StreamSecureSocketDriverTestsPingPong::OnStatePongGetServer), TS_TOP);
|
||||
m_stateMachine.SetStateHandler(AZ_HSM_STATE_NAME(TS_IN_ERROR), AZ::HSM::StateHandler(this, &DISABLED_StreamSecureSocketDriverTestsPingPong::OnStateInError), TS_TOP);
|
||||
m_stateMachine.Start();
|
||||
}
|
||||
|
||||
@@ -486,10 +486,10 @@ namespace UnitTest
|
||||
}
|
||||
|
||||
GM_TEST_SUITE(StreamSecureSocketDriverTests)
|
||||
GM_TEST(Integ_StreamSecureSocketDriverTestsBindSocketEmpty);
|
||||
GM_TEST(Integ_StreamSecureSocketDriverTestsConnection);
|
||||
GM_TEST(Integ_StreamSecureSocketDriverTestsConnectionAndHelloWorld);
|
||||
GM_TEST(Integ_StreamSecureSocketDriverTestsPingPong);
|
||||
GM_TEST(DISABLED_StreamSecureSocketDriverTestsBindSocketEmpty);
|
||||
GM_TEST(DISABLED_StreamSecureSocketDriverTestsConnection);
|
||||
GM_TEST(DISABLED_StreamSecureSocketDriverTestsConnectionAndHelloWorld);
|
||||
GM_TEST(DISABLED_StreamSecureSocketDriverTestsPingPong);
|
||||
GM_TEST_SUITE_END()
|
||||
|
||||
#endif // AZ_TRAIT_GRIDMATE_ENABLE_OPENSSL
|
||||
|
||||
@@ -308,7 +308,7 @@ namespace UnitTest
|
||||
}
|
||||
};
|
||||
|
||||
class Integ_StreamSocketDriverTestsTooManyConnections
|
||||
class DISABLED_StreamSocketDriverTestsTooManyConnections
|
||||
: public GridMateMPTestFixture
|
||||
{
|
||||
public:
|
||||
@@ -529,7 +529,7 @@ GM_TEST_SUITE(StreamSocketDriverTests)
|
||||
GM_TEST(StreamSocketDriverTestsSimpleLockStepConnection);
|
||||
GM_TEST(StreamSocketDriverTestsEstablishConnectAndSend);
|
||||
GM_TEST(StreamSocketDriverTestsManyRandomPackets);
|
||||
GM_TEST(Integ_StreamSocketDriverTestsTooManyConnections);
|
||||
GM_TEST(DISABLED_StreamSocketDriverTestsTooManyConnections);
|
||||
GM_TEST(StreamSocketDriverTestsClientToInvalidServer);
|
||||
GM_TEST(StreamSocketDriverTestsManySends);
|
||||
|
||||
|
||||
@@ -1,244 +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 "Tests.h"
|
||||
#include "TestProfiler.h"
|
||||
|
||||
#include <AzCore/Debug/Profiler.h>
|
||||
#include <AzCore/Math/Crc.h>
|
||||
|
||||
#include <GridMate/Containers/set.h>
|
||||
#include <GridMate/Containers/unordered_set.h>
|
||||
|
||||
using namespace GridMate;
|
||||
|
||||
typedef set<const AZ::Debug::ProfilerRegister*> ProfilerSet;
|
||||
|
||||
static bool CollectPerformanceCounters(const AZ::Debug::ProfilerRegister& reg, const AZStd::thread_id&, ProfilerSet& profilers, const char* systemId)
|
||||
{
|
||||
if (reg.m_type != AZ::Debug::ProfilerRegister::PRT_TIME)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (reg.m_systemId != AZ::Crc32(systemId))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
const AZ::Debug::ProfilerRegister* profReg = ®
|
||||
profilers.insert(profReg);
|
||||
return true;
|
||||
}
|
||||
|
||||
static AZStd::string FormatString(const AZStd::string& pre, const AZStd::string& name, const AZStd::string& post, AZ::u64 time, AZ::u64 calls)
|
||||
{
|
||||
AZStd::string units = "us";
|
||||
if (AZ::u64 divtime = time / 1000)
|
||||
{
|
||||
time = divtime;
|
||||
units = "ms";
|
||||
}
|
||||
return AZStd::string::format("%s%s %s %10llu%s (%llu calls)\n", pre.c_str(), name.c_str(), post.c_str(), time, units.c_str(), calls);
|
||||
}
|
||||
|
||||
struct TotalSortContainer
|
||||
{
|
||||
TotalSortContainer(const AZ::Debug::ProfilerRegister* self = nullptr)
|
||||
{
|
||||
m_self = self;
|
||||
}
|
||||
|
||||
void Print(AZ::s32 level, const char* systemId)
|
||||
{
|
||||
if (m_self && level >= 0)
|
||||
{
|
||||
AZStd::string levelIndent;
|
||||
for (AZ::s32 i = 0; i < level; i++)
|
||||
{
|
||||
levelIndent += (i == level - 1) ? "+---" : "| ";
|
||||
}
|
||||
AZStd::string name = m_self->m_name ? m_self->m_name : m_self->m_function;
|
||||
AZStd::string outputTotal = FormatString(levelIndent, name, " Total:", m_self->m_timeData.m_time, m_self->m_timeData.m_calls);
|
||||
AZ_Printf(systemId, outputTotal.c_str());
|
||||
|
||||
if (m_self->m_timeData.m_childrenTime || m_self->m_timeData.m_childrenCalls)
|
||||
{
|
||||
AZStd::string childIndent = levelIndent;
|
||||
for (auto i = name.begin(); i != name.end(); ++i)
|
||||
{
|
||||
childIndent += " ";
|
||||
}
|
||||
childIndent[level * 4] = '|';
|
||||
|
||||
AZStd::string outputChild = FormatString(childIndent, "", "Child:", m_self->m_timeData.m_childrenTime, m_self->m_timeData.m_childrenCalls);
|
||||
AZ_Printf(systemId, outputChild.c_str());
|
||||
|
||||
AZStd::string outputSelf = FormatString(childIndent, "", "Self :", m_self->m_timeData.m_time - m_self->m_timeData.m_childrenTime, m_self->m_timeData.m_calls);
|
||||
AZ_Printf(systemId, outputSelf.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
for (auto i = m_children.begin(); i != m_children.end(); ++i)
|
||||
{
|
||||
i->Print(level + 1, systemId);
|
||||
}
|
||||
}
|
||||
|
||||
TotalSortContainer* Find(const AZ::Debug::ProfilerRegister* obj)
|
||||
{
|
||||
if (m_self == obj)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
for (TotalSortContainer& child : m_children)
|
||||
{
|
||||
TotalSortContainer* found = child.Find(obj);
|
||||
if (found)
|
||||
{
|
||||
return found;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct TotalSorter
|
||||
{
|
||||
bool operator()(const TotalSortContainer& a, const TotalSortContainer& b) const
|
||||
{
|
||||
if (a.m_self->m_timeData.m_time == b.m_self->m_timeData.m_time)
|
||||
{
|
||||
return a.m_self > b.m_self;
|
||||
}
|
||||
return a.m_self->m_timeData.m_time > b.m_self->m_timeData.m_time;
|
||||
}
|
||||
};
|
||||
set<TotalSortContainer, TotalSorter> m_children;
|
||||
const AZ::Debug::ProfilerRegister* m_self;
|
||||
};
|
||||
|
||||
void TestProfiler::StartProfiling()
|
||||
{
|
||||
StopProfiling();
|
||||
|
||||
AZ::Debug::Profiler::Create();
|
||||
}
|
||||
|
||||
void TestProfiler::StopProfiling()
|
||||
{
|
||||
if (AZ::Debug::Profiler::IsReady())
|
||||
{
|
||||
AZ::Debug::Profiler::Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
void TestProfiler::PrintProfilingTotal(const char* systemId)
|
||||
{
|
||||
if (!AZ::Debug::Profiler::IsReady())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ProfilerSet profilers;
|
||||
AZ::Debug::Profiler::Instance().ReadRegisterValues(AZStd::bind(&CollectPerformanceCounters, AZStd::placeholders::_1, AZStd::placeholders::_2, AZStd::ref(profilers), systemId));
|
||||
|
||||
// Validate we wont get stuck in an infinite loop
|
||||
TotalSortContainer root;
|
||||
for (auto i = profilers.begin(); i != profilers.end(); )
|
||||
{
|
||||
const AZ::Debug::ProfilerRegister* profile = *i;
|
||||
if (profile->m_timeData.m_lastParent)
|
||||
{
|
||||
auto parent = profilers.find(profile->m_timeData.m_lastParent);
|
||||
if (parent == profilers.end())
|
||||
{
|
||||
// Error, just ignore this entry
|
||||
i = profilers.erase(i);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
// Put all root nodes into the final list
|
||||
for (auto i = profilers.begin(); i != profilers.end(); )
|
||||
{
|
||||
const AZ::Debug::ProfilerRegister* profile = *i;
|
||||
if (!profile->m_timeData.m_lastParent)
|
||||
{
|
||||
root.m_children.insert(profile);
|
||||
i = profilers.erase(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
// Put all non-root nodes into the final list
|
||||
while (!profilers.empty())
|
||||
{
|
||||
for (auto i = profilers.begin(); i != profilers.end(); )
|
||||
{
|
||||
const AZ::Debug::ProfilerRegister* profile = *i;
|
||||
TotalSortContainer* found = root.Find(profile->m_timeData.m_lastParent);
|
||||
if (found)
|
||||
{
|
||||
found->m_children.insert(profile);
|
||||
i = profilers.erase(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AZ_Printf(systemId, "Profiling timers by total execution time:\n");
|
||||
root.Print(-1, systemId);
|
||||
}
|
||||
|
||||
void TestProfiler::PrintProfilingSelf(const char* systemId)
|
||||
{
|
||||
if (!AZ::Debug::Profiler::IsReady())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ProfilerSet profilers;
|
||||
AZ::Debug::Profiler::Instance().ReadRegisterValues(AZStd::bind(&CollectPerformanceCounters, AZStd::placeholders::_1, AZStd::placeholders::_2, AZStd::ref(profilers), systemId));
|
||||
|
||||
struct SelfSorter
|
||||
{
|
||||
bool operator()(const AZ::Debug::ProfilerRegister* a, const AZ::Debug::ProfilerRegister* b) const
|
||||
{
|
||||
auto aTime = a->m_timeData.m_time - a->m_timeData.m_childrenTime;
|
||||
auto bTime = b->m_timeData.m_time - b->m_timeData.m_childrenTime;
|
||||
|
||||
if (aTime == bTime)
|
||||
{
|
||||
return a > b;
|
||||
}
|
||||
return aTime > bTime;
|
||||
}
|
||||
};
|
||||
|
||||
set<const AZ::Debug::ProfilerRegister*, SelfSorter> selfSorted;
|
||||
for (auto& profiler : profilers)
|
||||
{
|
||||
selfSorted.insert(profiler);
|
||||
}
|
||||
|
||||
AZ_Printf(systemId, "Profiling timers by exclusive execution time:\n");
|
||||
for (auto profiler : selfSorted)
|
||||
{
|
||||
AZStd::string str = FormatString("", profiler->m_name ? profiler->m_name : profiler->m_function, "Self Time:",
|
||||
profiler->m_timeData.m_time - profiler->m_timeData.m_childrenTime, profiler->m_timeData.m_calls);
|
||||
AZ_Printf(systemId, str.c_str());
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user