Merge branch 'development' into hultonha_LYN-7394_focus_cursor
Signed-off-by: hultonha <hultonha@amazon.co.uk>
This commit is contained in:
@@ -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());
|
||||
{
|
||||
|
||||
+25
-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 <AzCore/Component/TransformBus.h>
|
||||
#include <ToolsComponents/TransformComponent.h>
|
||||
|
||||
namespace AzToolsFramework::Prefab
|
||||
{
|
||||
@@ -61,9 +64,29 @@ 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>();
|
||||
|
||||
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(
|
||||
|
||||
+25
-6
@@ -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>
|
||||
@@ -123,6 +124,11 @@ 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(
|
||||
@@ -186,12 +192,19 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
// Verify if the entity Id corresponds to an entity that is focused; if not, halt selection.
|
||||
// verify if the entity Id corresponds to an entity that is focused; if not, halt selection.
|
||||
if (entityIdUnderCursor.IsValid() && !IsSelectableAccordingToFocusMode(entityIdUnderCursor))
|
||||
{
|
||||
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 AZ::EntityId();
|
||||
}
|
||||
@@ -199,7 +212,7 @@ namespace AzToolsFramework
|
||||
ViewportInteraction::ViewportMouseCursorRequestBus::Event(
|
||||
viewportId, &ViewportInteraction::ViewportMouseCursorRequestBus::Events::ClearOverrideCursor);
|
||||
|
||||
// Container Entity support - if the entity that is being selected is part of a closed container,
|
||||
// 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())
|
||||
{
|
||||
@@ -209,6 +222,12 @@ namespace AzToolsFramework
|
||||
return entityIdUnderCursor;
|
||||
}
|
||||
|
||||
void EditorHelpers::Display2d(
|
||||
[[maybe_unused]] const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay)
|
||||
{
|
||||
m_invalidClicks->Display2d(viewportInfo, debugDisplay);
|
||||
}
|
||||
|
||||
void EditorHelpers::DisplayHelpers(
|
||||
const AzFramework::ViewportInfo& viewportInfo,
|
||||
const AzFramework::CameraState& cameraState,
|
||||
@@ -270,19 +289,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
|
||||
{
|
||||
@@ -58,20 +61,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
|
||||
|
||||
+2
@@ -3560,6 +3560,8 @@ namespace AzToolsFramework
|
||||
DrawAxisGizmo(viewportInfo, debugDisplay);
|
||||
|
||||
m_boxSelect.Display2d(viewportInfo, debugDisplay);
|
||||
|
||||
m_editorHelpers->Display2d(viewportInfo, debugDisplay);
|
||||
}
|
||||
|
||||
void EditorTransformComponentSelection::RefreshSelectedEntityIds()
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user