Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,71 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef AZTOOLSFRAMEWORK_ASSETDATABASEAPI_H
#define AZTOOLSFRAMEWORK_ASSETDATABASEAPI_H
#include <AzCore/base.h>
#include <AzCore/EBus/EBus.h>
#include <AzCore/Asset/AssetCommon.h>
namespace AzToolsFramework
{
namespace AssetDatabase
{
class ProductDatabaseEntry;
class SourceDatabaseEntry;
typedef AZStd::vector<ProductDatabaseEntry> ProductDatabaseEntryContainer;
/**
* Bus used by the Tools Asset Database itself to talk to the running application environment
* Functions on this bus could be implemented by different parts of the application
* and are thus not result-based, but instead passed in params which are expected to not be touched
* unless you have an answer to give.
*/
class AssetDatabaseRequests
: public AZ::EBusTraits
{
public:
using Bus = AZ::EBus<AssetDatabaseRequests>;
/*!
* Used to retrieve the current database location from the running environment
*/
virtual bool GetAssetDatabaseLocation(AZStd::string& location) = 0;
};
using AssetDatabaseRequestsBus = AZ::EBus<AssetDatabaseRequests>;
class AssetDatabaseNotifications
: public AZ::EBusTraits
{
public:
typedef AZStd::recursive_mutex MutexType;
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple; // multiple listeners
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
virtual ~AssetDatabaseNotifications() = default;
virtual void OnSourceFileChanged(const SourceDatabaseEntry& /*entry*/) {}
virtual void OnSourceFileRemoved(AZ::s64 /*sourceId*/) {}
virtual void OnProductFileChanged(const ProductDatabaseEntry& /*entry*/) {}
virtual void OnProductFileRemoved(AZ::s64 /*productId*/) {}
virtual void OnProductFilesRemoved(const ProductDatabaseEntryContainer& /*products*/) {}
};
using AssetDatabaseNotificationBus = AZ::EBus<AssetDatabaseNotifications>;
} // namespace AssetDatabase
} // namespace AzToolsFramework
#endif // AZTOOLSFRAMEWORK_ASSETDATABASEAPI_H
@@ -0,0 +1,78 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/EBus/EBus.h>
#include <AzCore/Component/EntityId.h>
#include <AzCore/Component/ComponentBus.h>
#include <AzToolsFramework/ToolsComponents/EditorSelectionAccentSystemComponent.h>
class CEntityObject;
namespace AzToolsFramework
{
/**
* Bus for querying about sandbox data associated with a given Entity.
*/
class ComponentEntityEditorRequests
: public AZ::ComponentBus
{
public:
virtual ~ComponentEntityEditorRequests() {}
/// Retrieve sandbox object associated with the entity.
virtual CEntityObject* GetSandboxObject() = 0;
/// Returns true if the object is highlighted.
virtual bool IsSandboxObjectHighlighted() = 0;
// Sets accent for the component entity
virtual void SetSandboxObjectAccent(EntityAccentType accent) = 0;
// Set the component entity's isolation flag when the editor is in Isolation Mode
virtual void SetSandBoxObjectIsolated(bool isIsolated) = 0;
// Returns if the component entity is isolated when the editor is in Isolation Mode
virtual bool IsSandBoxObjectIsolated() = 0;
/// Updates the entity to match the visibility and lock state of its hierarchy.
/// Necessary because ancestors that are layers can override the current entity's visibility and lock state.
virtual void RefreshVisibilityAndLock() = 0;
};
using ComponentEntityEditorRequestBus = AZ::EBus < ComponentEntityEditorRequests >;
class ComponentEntityObjectRequests
: public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
typedef void* BusIdType; // ID'd on CComponentEntityObject pointer.
//////////////////////////////////////////////////////////////////////////
virtual ~ComponentEntityObjectRequests() {}
/// Retrieve AZ Entity Id associated with this sandbox object.
virtual AZ::EntityId GetAssociatedEntityId() = 0;
/// Updates the undo cache for this sandbox object
virtual void UpdatePreemptiveUndoCache() = 0;
};
using ComponentEntityObjectRequestBus = AZ::EBus < ComponentEntityObjectRequests >;
} // namespace AzToolsFramework
@@ -0,0 +1,107 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/EBus/EBus.h>
#include <AzCore/Component/EntityId.h>
#include <AzFramework/Render/GeometryIntersectionStructures.h>
#include <AzToolsFramework/ToolsComponents/EditorSelectionAccentSystemComponent.h>
class CEntityObject;
namespace AzFramework
{
struct ViewportInfo;
}
namespace AzToolsFramework
{
/// Bus for customizing Entity selection logic from within the EditorComponents.
/// Used to provide with custom implementation for Ray intersection tests, specifying AABB, etc.
class EditorComponentSelectionRequests
: public AZ::ComponentBus
{
public:
/// @brief Returns an AABB that encompasses the object.
/// @return AABB that encompasses the object.
/// @note ViewportInfo may be necessary if the all or part of the object
/// stays at a constant size regardless of camera position.
virtual AZ::Aabb GetEditorSelectionBoundsViewport(
const AzFramework::ViewportInfo& /*viewportInfo*/)
{
AZ_Assert(!SupportsEditorRayIntersect(),
"Component claims to support ray intersection but GetEditorSelectionBoundsViewport "
"has not been implemented in the derived class");
return AZ::Aabb::CreateNull();
}
/// @brief Returns true if editor selection ray intersects with the handler.
/// @return True if the editor selection ray intersects the handler.
/// @note ViewportInfo may be necessary if the all or part of the object
/// stays at a constant size regardless of camera position.
virtual bool EditorSelectionIntersectRayViewport(
const AzFramework::ViewportInfo& /*viewportInfo*/,
const AZ::Vector3& /*src*/, const AZ::Vector3& /*dir*/, float& /*distance*/)
{
AZ_Assert(!SupportsEditorRayIntersect(),
"Component claims to support ray intersection but EditorSelectionIntersectRayViewport "
"has not been implemented in the derived class");
return false;
}
/// @brief Returns true if the component overrides EditorSelectionIntersectRay method,
/// otherwise selection will be based only on AABB test.
/// @return True if EditorSelectionIntersectRay method is implemented.
virtual bool SupportsEditorRayIntersect() { return false; }
protected:
~EditorComponentSelectionRequests() = default;
};
/// Type to inherit to implement EditorComponentSelectionRequests.
using EditorComponentSelectionRequestsBus = AZ::EBus<EditorComponentSelectionRequests>;
/// Bus that provides notifications about selection events of the parent Entity.
class EditorComponentSelectionNotifications
: public AZ::EBusTraits
{
public:
// EBusTraits overrides
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
typedef AZ::EntityId BusIdType;
/// @brief Notifies listeners about in-editor selection events (mouse hover, selected, etc.)
virtual void OnAccentTypeChanged(EntityAccentType /*accent*/) {}
protected:
~EditorComponentSelectionNotifications() = default;
};
/// Type to inherit to implement EditorComponentSelectionNotifications.
using EditorComponentSelectionNotificationsBus = AZ::EBus<EditorComponentSelectionNotifications>;
/// Returns the union of all editor selection bounds on a given Entity.
/// @note The returned Aabb is in world space.
inline AZ::Aabb CalculateEditorEntitySelectionBounds(
const AZ::EntityId entityId, const AzFramework::ViewportInfo& viewportInfo)
{
AZ::EBusReduceResult<AZ::Aabb, AzFramework::AabbUnionAggregator> aabbResult(AZ::Aabb::CreateNull());
EditorComponentSelectionRequestsBus::EventResult(
aabbResult, entityId, &EditorComponentSelectionRequests::GetEditorSelectionBoundsViewport, viewportInfo);
return aabbResult.value;
}
} // namespace AzToolsFramework
@@ -0,0 +1,39 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
namespace AzToolsFramework
{
/**
* This bus allows you to make editor specific requests of the Animation System
*/
class EditorAnimationSystemRequests : public AZ::EBusTraits
{
public:
virtual ~EditorAnimationSystemRequests() = default;
enum AnimationSystem
{
EMotionFX,
CryAnimation
};
/**
* Determines if the given animation system is active
* @param systemType the type of system to query for
*/
virtual bool IsSystemActive([[maybe_unused]] AnimationSystem systemType) { return false; }
};
using EditorAnimationSystemRequestsBus = AZ::EBus<EditorAnimationSystemRequests>;
}
@@ -0,0 +1,320 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/EBus/EBus.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/std/string/string.h>
#include <AzCore/Outcome/Outcome.h>
#include <AzCore/Math/Crc.h>
#include <AzCore/Asset/AssetCommon.h>
#include <AzCore/Asset/AssetManagerBus.h>
#include <AzCore/PlatformDef.h>
namespace AzToolsFramework
{
namespace AssetSystem
{
class AssetJobsInfoResponse;
class AssetJobsInfoRequest;
//! A bus to talk to the asset system as a tool or editor
//! This contains things that only tools or editors should be given access to
//! If you want to talk to it as if a game engine component or runtime component
//! \ref AssetSystemBus.h
//! in the common header location.
class AssetSystemRequest
: public AZ::EBusTraits
{
public:
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single; // single listener
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; // single bus
using MutexType = AZStd::recursive_mutex;
// don't lock this bus during dispatch - its mainly just a forwarder of socket-based network requests
// so when one thread is asking for status of an asset, its okay for another thread to do the same.
static const bool LocklessDispatch = true;
virtual ~AssetSystemRequest() = default;
//! Retrieve the absolute path for the Asset Database Location
virtual bool GetAbsoluteAssetDatabaseLocation(AZStd::string& /*result*/) { return false; }
//! Retrieve the absolute folder path to the current game's source assets (the ones that go into source control)
//! This may include the current mod path, if a mod is being edited by the editor
virtual const char* GetAbsoluteDevGameFolderPath() = 0;
//! Retrieve the absolute folder path to the current developer root ('dev'), which contains source artifacts
//! and is generally checked into source control.
virtual const char* GetAbsoluteDevRootFolderPath() = 0;
/// Convert a full source path like "c:\\dev\gamename\\blah\\test.tga" into a relative product path.
/// asset paths never mention their alias and are relative to the asset cache root
virtual bool GetRelativeProductPathFromFullSourceOrProductPath(const AZStd::string& fullPath, AZStd::string& relativeProductPath) = 0;
/// Convert a relative asset path like "blah/test.tga" to a full source path path.
/// Once the asset processor has finished building, this function is capable of handling even when the extension changes
/// or when the source is in a different folder or in a different location (such as inside gems)
virtual bool GetFullSourcePathFromRelativeProductPath(const AZStd::string& relPath, AZStd::string& fullSourcePath) = 0;
//! retrieve an Az::Data::AssetInfo class for the given assetId. this may map to source too in which case rootFilePath will be non-empty.
virtual bool GetAssetInfoById(const AZ::Data::AssetId& assetId, const AZ::Data::AssetType& assetType, const AZStd::string& platformName, AZ::Data::AssetInfo& assetInfo, AZStd::string& rootFilePath) = 0;
/**
* Given a path to a source file, retrieve its actual watch folder path and details.
* @param sourcePath is either a relative or absolute path to a source file.
* @param assetInfo is a /ref AZ::Data::AssetInfo filled out with details about the asset including its relative path to its watch folder
* note that inside assetInfo is a AssetId, but only the UUID-part will ever have a value since we are dealing with a source file (no subid)
* @param watchFolder is the scan folder that it was found inside (the path in the assetInfo is relative to this folder).
* If you Path::Join the watchFolder and the assetInfo relative path, you get the full path.
* returns false if it cannot find the source, true otherwise.
*/
virtual bool GetSourceInfoBySourcePath(const char* sourcePath, AZ::Data::AssetInfo& assetInfo, AZStd::string& watchFolder) = 0;
/**
* Given a UUID of a source file, retrieve its actual watch folder path and other details.
* @param sourceUUID is the UUID of a source file - If you have an AssetID, its the m_guid member of that assetId
* @param assetInfo is a /ref AZ::Data::AssetInfo filled out with details about the asset including its relative path to its watch folder
* note that inside assetInfo is a AssetId, but only the UUID-part will ever have a value since we are dealing with a source file (no subid)
* @param watchFolder is the scan folder that it was found inside (the path in the assetInfo is relative to this folder).
* If you Path::Join the watchFolder and the assetInfo relative path, you get the full path to the source file on physical media
* returns false if it cannot find the source, true otherwise.
*/
virtual bool GetSourceInfoBySourceUUID(const AZ::Uuid& sourceUuid, AZ::Data::AssetInfo& assetInfo, AZStd::string& watchFolder) = 0;
/**
* Returns a list of scan folders recorded in the database.
* @param scanFolder gets appended with the found folders.
*/
virtual bool GetScanFolders(AZStd::vector<AZStd::string>& scanFolders) = 0;
/**
* Populates a list with folders that are safe to store assets in.
* This is a subset of the scan folders.
* @param scanFolder gets appended with the found folders.
* @return false if this process fails.
*/
virtual bool GetAssetSafeFolders(AZStd::vector<AZStd::string>& assetSafeFolders) = 0;
/**
* Query to see if a specific asset platform is enabled
* @param platform the asset platform to check e.g. es3, ios, etc.
* @return true if enabled, false otherwise
*/
virtual bool IsAssetPlatformEnabled(const char* platform) = 0;
/**
* Get the total number of pending assets left to process for a specific asset platform
* @param platform the asset platform to check e.g. es3, ios, etc.
* @return -1 if the process fails, a positive number otherwise
*/
virtual int GetPendingAssetsForPlatform(const char* platform) = 0;
/**
* Given a UUID of a source file, retrieve the products info.
* @param sourceUUID is the UUID of a source file - If you have an AssetID, its the m_guid member of that assetId
* @param productsAssetInfo is a /ref AZStd::vector<AZ::Data::AssetInfo> filled out with details about the products
* returns false if it cannot find the source, true otherwise.
*/
virtual bool GetAssetsProducedBySourceUUID(const AZ::Uuid& sourceUuid, AZStd::vector<AZ::Data::AssetInfo>& productsAssetInfo) = 0;
};
//! AssetSystemBusTraits
//! This bus is for events that concern individual assets and is addressed by file extension
class AssetSystemNotifications
: public AZ::EBusTraits
{
public:
typedef AZStd::recursive_mutex MutexType;
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple; // multiple listeners
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
static const bool EnableEventQueue = true; // enabled queued events, asset messages come from any thread
virtual ~AssetSystemNotifications() = default;
//! Called by the AssetProcessor when a source of an asset has been modified.
virtual void SourceFileChanged(AZStd::string /*relativePath*/, AZStd::string /*scanFolder*/, AZ::Uuid /*sourceUUID*/) {}
//! Called by the AssetProcessor when a source of an asset has been removed.
virtual void SourceFileRemoved(AZStd::string /*relativePath*/, AZStd::string /*scanFolder*/, AZ::Uuid /*sourceUUID*/) {}
//! This will be used by the asset processor to notify whenever a source file fails to process.
virtual void SourceFileFailed(AZStd::string /*relativePath*/, AZStd::string /*scanFolder*/, AZ::Uuid /*sourceUUID*/) {}
};
//! This enum have all the different job states
//! Please note that these job status are written to the database, so it is very important that any new status should be added at the end else the database might get corrupted
enum class JobStatus
{
Any = -1, //used exclusively by the database to indicate any state query, no job should ever actually be in this state, we start in Queued and progress from there
Queued, // its in the queue and will be built shortly
InProgress, // its being compiled right now.
Failed,
Failed_InvalidSourceNameExceedsMaxLimit, // use this enum to indicate that the job failed because the source file name length exceeds the maximum length allowed
Completed, // built successfully (no failure occurred)
Missing //indicate that the job is not present for example if the source file is not there, or if job key is not there
};
inline const char* JobStatusString(JobStatus status)
{
switch(status)
{
case JobStatus::Any: return "Any";
case JobStatus::Queued: return "Queued";
case JobStatus::InProgress: return "InProgress";
case JobStatus::Failed: return "Failed";
case JobStatus::Failed_InvalidSourceNameExceedsMaxLimit: return "Failed_InvalidSourceNameExceedsMaxLimit";
case JobStatus::Completed: return "Completed";
case JobStatus::Missing: return "Missing";
}
return nullptr;
}
//! This struct is used for responses and requests about Asset Processor Jobs
struct JobInfo
{
AZ_TYPE_INFO(JobInfo, "{276C9DE3-0C81-4721-91FE-F7C961D28DA8}")
JobInfo()
{
m_jobRunKey = rand();
}
AZ::u32 GetHash() const
{
AZ::Crc32 crc(m_sourceFile.c_str());
crc.Add(m_platform.c_str());
crc.Add(m_jobKey.c_str());
crc.Add(m_builderGuid.ToString<AZStd::string>().c_str());
return crc;
}
static void Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context);
if (serialize)
{
serialize->Class<JobInfo>()
->Version(4)
->Field("sourceFile", &JobInfo::m_sourceFile)
->Field("platform", &JobInfo::m_platform)
->Field("builderUuid", &JobInfo::m_builderGuid)
->Field("jobKey", &JobInfo::m_jobKey)
->Field("jobRunKey", &JobInfo::m_jobRunKey)
->Field("status", &JobInfo::m_status)
->Field("firstFailLogTime", &JobInfo::m_firstFailLogTime)
->Field("firstFailLogFile", &JobInfo::m_firstFailLogFile)
->Field("lastFailLogTime", &JobInfo::m_lastFailLogTime)
->Field("lastFailLogFile", &JobInfo::m_lastFailLogFile)
->Field("lastLogTime", &JobInfo::m_lastLogTime)
->Field("lastLogFile", &JobInfo::m_lastLogFile)
->Field("jobID", &JobInfo::m_jobID)
->Field("watchFolder", &JobInfo::m_watchFolder)
->Field("errorCount", &JobInfo::m_errorCount)
->Field("warningCount", &JobInfo::m_warningCount)
;
}
}
//! the file from which this job was originally spawned. Is just the relative source file name ("whatever/something.tif", not an absolute path)
AZStd::string m_sourceFile;
//! the watchfolder for the file from which this job was originally spawned.
AZStd::string m_watchFolder;
//! which platform this is for. Will be something like "pc" or "android"
AZStd::string m_platform;
//! The uuid of the builder
AZ::Uuid m_builderGuid = AZ::Uuid::CreateNull();
//! Job Key is arbitrarily defined by the builder. Used to differentiate between different jobs emitted for the same input file, for the same platform, for the same builder.
//! for example, you might want to split a particularly complicated and time consuming job into multiple sub-jobs. In which case they'd all have the same input file,
//! the same platform, the same builder UUID (since its the UUID of the builder itself)
//! but would have different job keys.
AZStd::string m_jobKey;
//random int made to identify this attempt to process this job
AZ::u64 m_jobRunKey = 0;
//current status
JobStatus m_status = JobStatus::Queued;
//logging
AZ::s64 m_firstFailLogTime = 0;
AZStd::string m_firstFailLogFile;
AZ::s64 m_lastFailLogTime = 0;
AZStd::string m_lastFailLogFile;
AZ::s64 m_lastLogTime = 0;
AZStd::string m_lastLogFile;
AZ::s64 m_errorCount = 0;
AZ::s64 m_warningCount = 0;
AZ::s64 m_jobID = 0; // this is the actual database row. Client is unlikely to need this.
};
typedef AZStd::vector<JobInfo> JobInfoContainer;
//! This Ebus will be used to retrieve all the job related information from AP
class AssetSystemJobRequest
: public AZ::EBusTraits
{
public:
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single; // single listener
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; //single bus
virtual ~AssetSystemJobRequest() = default;
/// Retrieve Jobs information for the given source file, setting escalteJobs to true will escalate all queued jobs
virtual AZ::Outcome<JobInfoContainer> GetAssetJobsInfo(const AZStd::string& sourcePath, const bool escalateJobs) = 0;
/// Retrieve Jobs information for the given assetId, setting escalteJobs to true will escalate all queued jobs
/// you can also specify whether fencing is required
virtual AZ::Outcome<JobInfoContainer> GetAssetJobsInfoByAssetID(const AZ::Data::AssetId& assetId, const bool escalateJobs, bool requireFencing) = 0;
/// Retrieve Jobs information for the given jobKey
virtual AZ::Outcome<JobInfoContainer> GetAssetJobsInfoByJobKey(const AZStd::string& jobKey, const bool escalateJobs) = 0;
/// Retrieve Job Status for the given jobKey.
/// If no jobs are present, return missing,
/// else, if any matching jobs have failed, it will return failed
/// else, if any of the matching jobs are queued, it will return queued
/// else, if any matching jobs are in progress, will return inprogress
/// else it will return the completed job status.
virtual AZ::Outcome<JobStatus> GetAssetJobsStatusByJobKey(const AZStd::string& jobKey, const bool escalateJobs) = 0;
/// Retrieve the actual log content for a particular job. you can retrieve the run key from the above info function.
virtual AZ::Outcome<AZStd::string> GetJobLog(AZ::u64 jobrunkey) = 0;
};
inline const char* GetHostAssetPlatform()
{
#if defined(AZ_PLATFORM_MAC)
return "osx_gl";
#elif defined(AZ_PLATFORM_WINDOWS)
return "pc";
#elif defined(AZ_PLATFORM_LINUX)
// set this to pc because that's what bootstrap.cfg currently defines the platform to "pc", even on Linux
return "pc";
#else
#error Unimplemented Host Asset Platform
#endif
}
} // namespace AssetSystem
using AssetSystemBus = AZ::EBus<AssetSystem::AssetSystemNotifications>;
using AssetSystemRequestBus = AZ::EBus<AssetSystem::AssetSystemRequest>;
using AssetSystemJobRequestBus = AZ::EBus<AssetSystem::AssetSystemJobRequest>;
} // namespace AzToolsFramework
@@ -0,0 +1,33 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/RTTI/BehaviorContext.h>
#include "EditorCameraBus.h"
namespace Camera
{
void EditorCameraRequests::Reflect(AZ::ReflectContext* context)
{
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->EBus<EditorCameraRequestBus>("EditorCameraRequestBus")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
->Attribute(AZ::Script::Attributes::Category, "Editor")
->Attribute(AZ::Script::Attributes::Module, "editor")
->Event("SetViewFromEntityPerspective", &EditorCameraRequestBus::Events::SetViewFromEntityPerspective)
->Event("SetViewAndMovementLockFromEntityPerspective", &EditorCameraRequestBus::Events::SetViewAndMovementLockFromEntityPerspective)
->Event("GetCurrentViewEntityId", &EditorCameraRequestBus::Events::GetCurrentViewEntityId)
->Event("GetActiveCameraPosition", &EditorCameraRequestBus::Events::GetActiveCameraPosition)
;
}
}
}
@@ -0,0 +1,111 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Math/Vector3.h>
#include <AzCore/Component/Component.h>
namespace Camera
{
/**
* This bus allows you to get and set the current editor viewport camera
*/
class EditorCameraRequests : public AZ::EBusTraits
{
public:
using Bus = AZ::EBus<EditorCameraRequests>;
virtual ~EditorCameraRequests() = default;
static void Reflect(AZ::ReflectContext* context);
/**
* Sets the view from the entity's perspective
* @param entityId the id of the entity whose perspective is to be used
*/
virtual void SetViewFromEntityPerspective(const AZ::EntityId& /*entityId*/) {}
/**
* Sets the view from the entity's perspective
* @param entityId the id of the entity whose perspective is to be used
* @param lockCameraMovement disallow camera movement from user input in the editor render viewport.
*/
virtual void SetViewAndMovementLockFromEntityPerspective(const AZ::EntityId& /*entityId*/, bool /*lockCameraMovement*/) {}
/**
* Gets the id of the current view entity. Invalid EntityId is returned for the default editor camera
* @return the entityId of the entity currently being used as the view. The Invalid entity id is returned for the default editor camera
*/
virtual AZ::EntityId GetCurrentViewEntityId() { return AZ::EntityId(); }
/**
* Gets the position of the currently active Editor camera.
* The Editor can have multiple viewports displayed, though at most only one is active at any point in time.
* (Active is not the same as "has focus" - a different editor pane can have focus, but there's still one
* active viewport that's updating every frame, and the others are not)
* @param cameraPos On return, the current camera position in the one active Editor viewport.
* @return True if the camera position was successfully retrieved, false if not.
*/
virtual bool GetActiveCameraPosition(AZ::Vector3& /*cameraPos*/) { return false; }
};
using EditorCameraRequestBus = AZ::EBus<EditorCameraRequests>;
/**
* This is the bus to interface with the camera system component
*/
class EditorCameraSystemRequests : public AZ::EBusTraits
{
public:
using Bus = AZ::EBus<EditorCameraSystemRequests>;
virtual ~EditorCameraSystemRequests() = default;
virtual void CreateCameraEntityFromViewport() {}
};
using EditorCameraSystemRequestBus = AZ::EBus<EditorCameraSystemRequests>;
/**
* Handle this bus to be notified when the current editor viewport entity id changes
*/
class EditorCameraNotifications : public AZ::EBusTraits
{
public:
virtual ~EditorCameraNotifications() = default;
/**
* Handle this message to know when the current viewports view entity has changed
* @param newViewId the id of the entity the current view has switched to
*/
virtual void OnViewportViewEntityChanged(const AZ::EntityId& /*newViewId*/) {}
};
using EditorCameraNotificationBus = AZ::EBus<EditorCameraNotifications>;
/**
* This bus is for requesting any camera-view-related changes
*/
class EditorCameraViewRequests : public AZ::ComponentBus
{
public:
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
virtual ~EditorCameraViewRequests() = default;
/**
* Sets this camera as the active view in the scene, otherwise restores the default editor camera if it was already active
*/
virtual void ToggleCameraAsActiveView() = 0;
};
using EditorCameraViewRequestBus = AZ::EBus<EditorCameraViewRequests>;
} // namespace Camera
@@ -0,0 +1,29 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/EBus/EBus.h>
namespace AzToolsFramework
{
class EditorLevelNotifications : public AZ::EBusTraits
{
public:
virtual ~EditorLevelNotifications() = default;
//! Invoked when a new level is created in the editor
virtual void OnNewLevelCreated() {}
};
using EditorLevelNotificationBus = AZ::EBus<EditorLevelNotifications>;
}
@@ -0,0 +1,109 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/EBus/EBus.h>
#include <AzCore/Interface/Interface.h>
namespace AzToolsFramework
{
//! Interface into the Python virtual machine's data
class EditorPythonConsoleInterface
{
protected:
EditorPythonConsoleInterface() = default;
virtual ~EditorPythonConsoleInterface() = default;
EditorPythonConsoleInterface(EditorPythonConsoleInterface&&) = delete;
EditorPythonConsoleInterface& operator=(EditorPythonConsoleInterface&&) = delete;
public:
AZ_RTTI(EditorPythonConsoleInterface, "{CAE877C8-DAA8-4535-BCBF-F392EAA7CEA9}");
//! Returns the known list of modules exported to Python
virtual void GetModuleList(AZStd::vector<AZStd::string_view>& moduleList) const = 0;
//! Returns the known list of global functions inside a Python module
struct GlobalFunction
{
AZStd::string_view m_moduleName;
AZStd::string_view m_functionName;
AZStd::string_view m_description;
};
using GlobalFunctionCollection = AZStd::vector<GlobalFunction>;
virtual void GetGlobalFunctionList(GlobalFunctionCollection& globalFunctionCollection) const = 0;
};
//! Interface to signal the phases for the Python virtual machine
class EditorPythonEventsInterface
{
protected:
EditorPythonEventsInterface() = default;
virtual ~EditorPythonEventsInterface() = default;
EditorPythonEventsInterface(EditorPythonEventsInterface&&) = delete;
EditorPythonEventsInterface& operator=(EditorPythonEventsInterface&&) = delete;
public:
AZ_RTTI(EditorPythonEventsInterface, "{F50AE641-2C80-4E07-B4B3-7CB34FFAB393}");
//! Signal the Python handler to start
virtual bool StartPython(bool silenceWarnings = false) = 0;
//! Signal the Python handler to stop
virtual bool StopPython(bool silenceWarnings = false) = 0;
//! Determines if the caller needs to wait for the Python VM to initialize (non-main thread only)
virtual void WaitForInitialization() {}
//! Acquires the Python global interpreter lock (GIL) and executed the callback
virtual void ExecuteWithLock(AZStd::function<void()> executionCallback) = 0;
};
//! A bus to handle post notifications to the console views of Python output
class EditorPythonConsoleNotifications
: public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::MultipleAndOrdered;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
// used with the AZ::EBusHandlerPolicy::MultipleAndOrdered HandlerPolicy
struct BusHandlerOrderCompare
{
bool operator()(EditorPythonConsoleNotifications* left, EditorPythonConsoleNotifications* right) const
{
return left->GetOrder() < right->GetOrder();
}
};
/**
* Specifies the order a handler receives events relative to other handlers
* @return a value specifying this handler's relative order
*/
virtual int GetOrder()
{
return std::numeric_limits<int>::max();
}
//////////////////////////////////////////////////////////////////////////
//! post a normal message to the console
virtual void OnTraceMessage(AZStd::string_view message) = 0;
//! post an error message to the console
virtual void OnErrorMessage(AZStd::string_view message) = 0;
//! post an internal Python exception from a script call
virtual void OnExceptionMessage(AZStd::string_view message) = 0;
};
using EditorPythonConsoleNotificationBus = AZ::EBus<EditorPythonConsoleNotifications>;
}
@@ -0,0 +1,46 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/EBus/EBus.h>
namespace AzToolsFramework
{
/**
* Provides a bus to run Python scripts
*/
class EditorPythonRunnerRequests
: public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
//////////////////////////////////////////////////////////////////////////
//! executes a Python script using a string, prints the result if printResult is true and script is an expression
virtual void ExecuteByString(AZStd::string_view script, bool printResult) { AZ_UNUSED(script); AZ_UNUSED(printResult); }
//! executes a Python script using a filename
virtual void ExecuteByFilename(AZStd::string_view filename) { AZ_UNUSED(filename); }
//! executes a Python script using a filename and args
virtual void ExecuteByFilenameWithArgs(AZStd::string_view filename, const AZStd::vector<AZStd::string_view>& args) { AZ_UNUSED(filename); AZ_UNUSED(args); }
//! executes a Python script as a test
virtual void ExecuteByFilenameAsTest(AZStd::string_view filename, const AZStd::vector<AZStd::string_view>& args) { AZ_UNUSED(filename); AZ_UNUSED(args); }
};
using EditorPythonRunnerRequestBus = AZ::EBus<EditorPythonRunnerRequests>;
} // namespace AzToolsFramework
@@ -0,0 +1,46 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/base.h>
#include <AzCore/EBus/EBus.h>
class CVegetationMap;
struct CVegetationInstance;
namespace AzToolsFramework
{
namespace EditorVegetation
{
/**
* Bus used to talk to VegetationMap across the application
*/
class EditorVegetationRequests
: public AZ::EBusTraits
{
public:
using Bus = AZ::EBus<EditorVegetationRequests>;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
typedef CVegetationMap* BusIdType;
virtual ~EditorVegetationRequests() {}
virtual AZStd::vector<CVegetationInstance*> GetObjectInstances(const AZ::Vector2& min, const AZ::Vector2& max) = 0;
virtual void DeleteObjectInstance(CVegetationInstance* instance) = 0;
};
using EditorVegetationRequestsBus = AZ::EBus<EditorVegetationRequests>;
}
}
@@ -0,0 +1,48 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef AZTOOLSFRAMEWORK_EDITORWINDOWREQUESTBUS_H
#define AZTOOLSFRAMEWORK_EDITORWINDOWREQUESTBUS_H
#include <AzCore/base.h>
#pragma once
#include <AzCore/EBus/EBus.h>
class QWidget;
namespace AzToolsFramework
{
/**
* Bus for general editor window requests to be intercepted by the application.
*/
class EditorWindowRequests
: public AZ::EBusTraits
{
public:
using Bus = AZ::EBus<EditorWindowRequests>;
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
//////////////////////////////////////////////////////////////////////////
/// Retrieve the main application window.
virtual QWidget* GetAppMainWindow() { return nullptr; }
};
using EditorWindowRequestBus = AZ::EBus<EditorWindowRequests>;
} // namespace AzToolsFramework
#endif // AZTOOLSFRAMEWORK_EDITORWINDOWREQUESTBUS_H
@@ -0,0 +1,55 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/base.h>
#include <AzCore/EBus/EBus.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Component/ComponentBus.h>
#include <AzCore/Component/Entity.h>
namespace AzToolsFramework
{
using EntityIdList = AZStd::vector<AZ::EntityId>;
class EntityCompositionNotifications
: public AZ::EBusTraits
{
public:
/*!
* Notification that the specified entities are about to have their composition changed due to user interaction in the editor
*
* \param entityIds Entities about to be changed
*/
virtual void OnEntityCompositionChanging(const AzToolsFramework::EntityIdList& /*entityIds*/) {};
/*!
* Notification that the specified entities had their composition changed due to user interaction in the editor
*
* \param entityIds Entities changed
*/
virtual void OnEntityCompositionChanged(const AzToolsFramework::EntityIdList& /*entityIds*/) {};
/*!@{
* Discrete composition events for adding, removing, enabling and disabling components
*/
virtual void OnEntityComponentAdded(const AZ::EntityId& /*entityId*/, const AZ::ComponentId& /*componentId*/) {};
virtual void OnEntityComponentRemoved(const AZ::EntityId& /*entityId*/, const AZ::ComponentId& /*componentId*/) {};
virtual void OnEntityComponentEnabled(const AZ::EntityId& /*entityId*/, const AZ::ComponentId& /*componentId*/) {};
virtual void OnEntityComponentDisabled(const AZ::EntityId& /*entityId*/, const AZ::ComponentId& /*componentId*/) {};
//!@}
};
using EntityCompositionNotificationBus = AZ::EBus<EntityCompositionNotifications>;
}
@@ -0,0 +1,320 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/base.h>
#include <AzCore/EBus/EBus.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Component/Component.h>
#include <AzCore/Component/Entity.h>
#include <AzCore/Outcome/Outcome.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
namespace AzToolsFramework
{
class EntityCompositionRequests
: public AZ::EBusTraits
{
public:
struct AddComponentsResults
{
// This is the original list of components added (whether or not they are pending, in the order of class data requested)
AZ::Entity::ComponentArrayType m_componentsAdded;
/*!
* Adding a component can only cause the following to occur:
* 1) Component gets added to the pending list
* 2) Components Gets added to the entity as a valid component
* 3) Cause pending components to be added to the entity as valid components (by satisfying previously missing services)
*
* The following three vectors represent each occurrence, respectively.
*/
AZ::Entity::ComponentArrayType m_addedPendingComponents;
AZ::Entity::ComponentArrayType m_addedValidComponents;
AZ::Entity::ComponentArrayType m_additionalValidatedComponents;
};
/*!
* Stores a map of entity ids to component results that were added during AddComponentsToEntities.
* You can use this to look up what exactly happened to each entity involved.
* Components requested to be added will be stored in either addedPendingComponents or addedValidComponents
* Any other previously pending components that are now valid will be stored in additionalValidatedComponents
*/
using EntityToAddedComponentsMap = AZStd::unordered_map<AZ::EntityId, AddComponentsResults>;
/*!
* Outcome will be true if successful and return the above results structure to indicate what happened
* Outcome will be false if critical underlying system failure occurred (which is not expected) and an error string will describe the problem
*/
using AddComponentsOutcome = AZ::Outcome<EntityToAddedComponentsMap, AZStd::string>;
/*!
* Outcome will be true if successful and return one instance of the above AddComponentsResults structure (since only one entity is involved)
*/
using AddExistingComponentsOutcome = AZ::Outcome<AddComponentsResults, AZStd::string>;
/*!
* Add the specified component types to the specified entities.
*
* \param entityIds Entities to receive the new components.
* \param componentsToAdd A list of AZ::Uuid representing the unique id of the type of components to add.
*
* \return Returns a successful outcome if components were added to entities.
* If the operation could not be completed then the failed
* outcome contains a string describing what went wrong.
*/
virtual AddComponentsOutcome AddComponentsToEntities(const EntityIdList& entityIds, const AZ::ComponentTypeList& componentsToAdd) = 0;
/*!
* Add the specified existing components to the specified entity.
*
* \param entityId The AZ::EntityId to add the existing components to, with full editor-level checking with pending component support
* \param componentsToAdd A list of AZ::Component* containing existing components to add. (Note: These components must not already be tied to another entity!)
*
* \return Returns a successful outcome if components were added to entities.
* If the operation could not be completed then the failed
* outcome contains a string describing what went wrong.
*/
virtual AddExistingComponentsOutcome AddExistingComponentsToEntityById(const AZ::EntityId& entityId, const AZStd::vector<AZ::Component*>& componentsToAdd) = 0;
// Removing a component can only cause the following to occur:
// 1) Invalidate other components by removing missing services
// 2) Validate other components by removing conflicting pending services
struct RemoveComponentsResults
{
//! Invalidated Components are those that were previously valid but no longer are valid.
AZ::Entity::ComponentArrayType m_invalidatedComponents;
//! Validated Components are those that were previously invalid (and being held back) and are now valid.
//! Note that during a "Scrub" operation, this remains true - it will only list those that were previously
//! inactive, and were activated by the scrub, it will not contain the list of previously active that remain active.
AZ::Entity::ComponentArrayType m_validatedComponents;
};
using EntityToRemoveComponentsResultMap = AZStd::unordered_map<AZ::EntityId, RemoveComponentsResults>;
using RemoveComponentsOutcome = AZ::Outcome<EntityToRemoveComponentsResultMap, AZStd::string>;
/*!
* Removes the specified components from the specified entities.
*
* \param componentsToRemove List of component pointers to remove (from their respective entities).
* \return true if the components were successfully removed or false otherwise.
*/
virtual RemoveComponentsOutcome RemoveComponents(const AZStd::vector<AZ::Component*>& componentsToRemove) = 0;
using ScrubEntityResults = RemoveComponentsResults;
using EntityToScrubEntityResultsMap = AZStd::unordered_map<AZ::EntityId, ScrubEntityResults>;
using ScrubEntitiesOutcome = AZ::Outcome<EntityToScrubEntityResultsMap, AZStd::string>;
/*!
* Scrub entities so that they can be activated.
* Components will be moved to the pending list if they cannot be activated.
* If a component had been pending, but can now be activated, then it will be re-enabled.
*
* ScrubEntities() may be called on entities before they are initialized.
*
* \return If successful, outcome contains details about the scrubbing.
* If unsuccessful, outcome contains a string describing what went wrong.
*
* To decipher the outcome, understand that when you run the scrub an entity, 4 possible things can happen to each component:
* 1) Component was active before and remains active now
* --> These can be retrieved from Entity::GetComponents() and are unchanged
* 2) Component was active before, but is now INACTIVE due to invalid requirements.
* --> These are on the Outcome's m_invalidatedComponents list.
* --> They are also added to a EditorPendingCompositionComponent on the entity. This component's job is to keep track
* of invalid components and save their data in case they become active again in a later scrub.
* 3) Components which were inactive before (because of #2 above, in a previous scrub), but now have their requirements
* satisfied during this new scrub.
* --> These will be in Entity::GetComponents() but also the m_validated components list to distinguish them from the first case 1) above.
* 4) "Hidden" built-in components may be deprecated or invalid.
* ---> These will be deleted and a warning will be issued. They will not be in any list, since they are deleted.
*/
virtual ScrubEntitiesOutcome ScrubEntities(const EntityList& entities) = 0;
/*!
* Removes the given components from their respective entities (currently only single entity is supported) and copies the data to the clipboard if successful
* \param components vector of components to cut (this method will delete the components provided on successful removal)
*/
virtual void CutComponents(const AZStd::vector<AZ::Component*>& components) = 0;
/*!
* Copies the given components from their respective entities (multiple source entities are supported) into mime data on the clipboard for pasting elsewhere
* \param components vector of components to copy
*/
virtual void CopyComponents(const AZStd::vector<AZ::Component*>& components) = 0;
/*!
* Pastes components from the mime data on the clipboard (assuming it is component data) to the given entity
* \param entityId the Id of the entity to paste to
*/
virtual void PasteComponentsToEntity(AZ::EntityId entityId) = 0;
/*!
* Checks if there is component data available to paste into an entity
* \return true if paste is available, false otherwise
*/
virtual bool HasComponentsToPaste() = 0;
/*!
* Enables the given components
* \param components vector of components to enable
*/
virtual void EnableComponents(const AZStd::vector<AZ::Component*>& components) = 0;
/*!
* Disables the given components
* \param components vector of components to disable
*/
virtual void DisableComponents(const AZStd::vector<AZ::Component*>& components) = 0;
using ComponentServicesList = AZStd::vector<AZ::ComponentServiceType>;
/*!
* Info detailing why a pending component cannot be activated.
*/
struct PendingComponentInfo
{
AZ::Entity::ComponentArrayType m_validComponentsThatAreIncompatible;
AZ::Entity::ComponentArrayType m_pendingComponentsWithRequiredServices;
AZ::Entity::StringWarningArray m_warnings;
ComponentServicesList m_missingRequiredServices;
ComponentServicesList m_incompatibleServices;
};
/*
* Returns detailed info regarding a pending component.
* Pending components are those that cannot be activated due to
* missing requirements or incompatibilities with another component.
*/
virtual PendingComponentInfo GetPendingComponentInfo(const AZ::Component* component) = 0;
/*!
* Returns a name for the given component Note: This will always dig into the underlying type. e.g. you will never get the GenericComponentWrapper name, but always the actual underlying component
* \param component the pointer to the component for which you want the name.
*/
virtual AZStd::string GetComponentName(const AZ::Component* component) = 0;
};
using EntityCompositionRequestBus = AZ::EBus<EntityCompositionRequests>;
//! Return whether component should appear in an entity's "Add Component" menu.
//! \param entityType The type of entity (ex: "Game", "System")
static bool AppearsInAddComponentMenu(const AZ::SerializeContext::ClassData& classData, const AZ::Crc32& entityType);
//! ComponentFilter for components that users can add to game entities.
static bool AppearsInGameComponentMenu(const AZ::SerializeContext::ClassData&);
//! ComponentFilter for components that can be added to system entities.
static bool AppearsInSystemComponentMenu(const AZ::SerializeContext::ClassData&);
//
// Implementation
//
inline bool AppearsInAddComponentMenu(const AZ::SerializeContext::ClassData& classData, const AZ::Crc32& entityType)
{
if (classData.m_editData)
{
if (auto editorDataElement = classData.m_editData->FindElementData(AZ::Edit::ClassElements::EditorData))
{
for (const AZ::Edit::AttributePair& attribPair : editorDataElement->m_attributes)
{
if (attribPair.first == AZ::Edit::Attributes::AppearsInAddComponentMenu)
{
PropertyAttributeReader reader(nullptr, attribPair.second);
AZ::Crc32 classEntityType = 0;
AZStd::vector<AZ::Crc32> classEntityTypes;
if (reader.Read<AZ::Crc32>(classEntityType))
{
if (static_cast<AZ::u32>(entityType) == classEntityType)
{
return true;
}
}
else if (reader.Read<AZStd::vector<AZ::Crc32>>(classEntityTypes))
{
if (AZStd::find(classEntityTypes.begin(), classEntityTypes.end(), entityType) != classEntityTypes.end())
{
return true;
}
}
}
}
}
}
return false;
}
inline bool AppearsInGameComponentMenu(const AZ::SerializeContext::ClassData& classData)
{
// We don't call AppearsInAddComponentMenu(...) because we support legacy values.
// AppearsInAddComponentMenu used to be a bool,
// and it used to only be applied to components on in-game entities.
if (classData.m_editData)
{
if (auto editorDataElement = classData.m_editData->FindElementData(AZ::Edit::ClassElements::EditorData))
{
for (const AZ::Edit::AttributePair& attribPair : editorDataElement->m_attributes)
{
if (attribPair.first == AZ::Edit::Attributes::AppearsInAddComponentMenu)
{
PropertyAttributeReader reader(nullptr, attribPair.second);
AZ::Crc32 classEntityType;
AZStd::vector<AZ::Crc32> classEntityTypes;
if (reader.Read<AZ::Crc32>(classEntityType))
{
if (classEntityType == AZ_CRC("Game", 0x232b318c))
{
return true;
}
}
else if (reader.Read<AZStd::vector<AZ::Crc32>>(classEntityTypes))
{
if (AZStd::find(classEntityTypes.begin(), classEntityTypes.end(), AZ_CRC("Game", 0x232b318c)) != classEntityTypes.end())
{
return true;
}
}
bool legacyAppearsInComponentMenu = false;
if (reader.Read<bool>(legacyAppearsInComponentMenu))
{
AZ_WarningOnce(classData.m_name, false, "%s %s 'AppearsInAddComponentMenu' uses legacy value 'true', should be 'AZ_CRC(\"Game\")'.",
classData.m_name, classData.m_typeId.ToString<AZStd::string>().c_str());
return legacyAppearsInComponentMenu;
}
}
}
}
}
return false;
}
inline bool AppearsInSystemComponentMenu(const AZ::SerializeContext::ClassData& classData)
{
return AppearsInAddComponentMenu(classData, AZ_CRC("System", 0xc94d118b));
}
inline bool AppearsInLayerComponentMenu(const AZ::SerializeContext::ClassData& classData)
{
return AppearsInAddComponentMenu(classData, AZ_CRC("Layer", 0xe4db211a));
}
inline bool AppearsInLevelComponentMenu(const AZ::SerializeContext::ClassData& classData)
{
return AppearsInAddComponentMenu(classData, AZ_CRC("Level", 0x9aeacc13));
}
inline bool AppearsInAnyComponentMenu(const AZ::SerializeContext::ClassData& classData)
{
return (AppearsInGameComponentMenu(classData) || AppearsInSystemComponentMenu(classData) || AppearsInLayerComponentMenu(classData) || AppearsInLevelComponentMenu(classData));
}
}
@@ -0,0 +1,37 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/EBus/EBus.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
namespace AzToolsFramework
{
//! Requests to be made of all EntityPropertyEditorRequests
//! Beware, there may be more than one EntityPropertyEditor that can respond
//! Broadcast should be used for accessing these functions
class EntityPropertyEditorRequests
: public AZ::EBusTraits
{
public:
//! Allows a component to get the list of selected entities or if in a pinned window, the list of entities in that window
//! \param selectedEntityIds the return vector holding the entities required
virtual void GetSelectedAndPinnedEntities(EntityIdList& selectedEntityIds) = 0;
//! Allows a component to get the list of selected entities
//! \param selectedEntityIds the return vector holding the entities required
virtual void GetSelectedEntities(EntityIdList& selectedEntityIds) = 0;
};
using EntityPropertyEditorRequestBus = AZ::EBus<EntityPropertyEditorRequests>;
} // namespace AzToolsFramework
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,53 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/RTTI/TypeInfo.h>
#include <QRect>
#include <QKeySequence>
#include <QString>
namespace AzToolsFramework
{
struct ViewPaneOptions
{
AZ_TYPE_INFO(ViewPaneOptions, "{E9FB803A-2A47-4BCF-8A50-AB4C9D73AED2}");
QRect paneRect = QRect(50, 50, 1000, 800); ///< default size/position of the view pane, if no previous state is saved
Qt::DockWidgetArea preferedDockingArea = Qt::NoDockWidgetArea; ///< default docking area to place the view pane in, if no previous state is saved
bool isDeletable = true; ///< set to false if you want the view pane to hide on close, instead of being deleted
bool isStandard = false; ///< for internal use; leave set to false
bool showInMenu = true; ///< set to false if you'd like to register a view pane and have it NOT appear under the Tools menu
bool canHaveMultipleInstances = false; ///< ignored; left for backwards code compatibility
int viewportType = -1; ///< for internal use; leave set to -1
bool isPreview = false; ///< indicates if a view pane is still pre-release
QKeySequence shortcut; ///< default shortcut to allow the user to open the view pane
int builtInActionId = -1; ///< for internal use; leave set to -1
bool isDockable = true; ///< set to false if the view pane should not be dockable; this can be necessary in certain cases, such as with QOpenGLWidgets
QString optionalMenuText; ///< set this to the text you'd like to appear under the Tools menu; leave it blank to use the view pane name under the Tools menu instead
bool isLegacy = false; ///< set this to true if you are marking this as a legacy (and likely to be deprecated) viewpane
bool isLegacyReplacement = false; ///< set this to true if this is a viewpane to replace an older viewpane
QString saveKeyName; ///< can be zero length; set this if you want to use a name other than the viewpane name set in RegisterViewPane.
bool detachedWindow = false; ///< set to true if the view pane should use a detached, non-dockable widget. This is to workaround a problem with QOpenGLWidget on macOS. Currently this has no effect on other platforms.
bool isDisabledInSimMode = false; ///< set to true if the view pane should not be openable from level editor menu when editor is in simulation mode.
};
} // namespace AzToolsFramework
// Left in for backwards compatibility, so that any code forward declaring
// QtViewOptions will continue to work.
struct QtViewOptions : public AzToolsFramework::ViewPaneOptions
{
};