Merge branch 'development' into cmake/remove_align_macros
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -19,6 +19,66 @@ namespace UnitTest
|
||||
|
||||
using AzToolsFramework::ViewportInteraction::MouseInteractionEvent;
|
||||
|
||||
class ViewportMouseCursorRequestImpl : public AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
void Connect(const AzFramework::ViewportId viewportId, AzToolsFramework::QtEventToAzInputMapper* inputChannelMapper)
|
||||
{
|
||||
AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Handler::BusConnect(viewportId);
|
||||
m_inputChannelMapper = inputChannelMapper;
|
||||
}
|
||||
|
||||
void Disconnect()
|
||||
{
|
||||
AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
// ViewportMouseCursorRequestBus overrides ...
|
||||
void BeginCursorCapture() override;
|
||||
void EndCursorCapture() override;
|
||||
bool IsMouseOver() const override;
|
||||
|
||||
private:
|
||||
AzToolsFramework::QtEventToAzInputMapper* m_inputChannelMapper = nullptr;
|
||||
};
|
||||
|
||||
void ViewportMouseCursorRequestImpl::BeginCursorCapture()
|
||||
{
|
||||
m_inputChannelMapper->SetCursorCaptureEnabled(true);
|
||||
}
|
||||
|
||||
void ViewportMouseCursorRequestImpl::EndCursorCapture()
|
||||
{
|
||||
m_inputChannelMapper->SetCursorCaptureEnabled(false);
|
||||
}
|
||||
|
||||
bool ViewportMouseCursorRequestImpl::IsMouseOver() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
class TestModularCameraViewportContextImpl : public AtomToolsFramework::ModularCameraViewportContext
|
||||
{
|
||||
public:
|
||||
AZ::Transform GetCameraTransform() const override
|
||||
{
|
||||
return m_cameraTransform;
|
||||
}
|
||||
|
||||
void SetCameraTransform(const AZ::Transform& transform) override
|
||||
{
|
||||
m_cameraTransform = transform;
|
||||
}
|
||||
|
||||
void ConnectViewMatrixChangedHandler(AZ::RPI::ViewportContext::MatrixChangedEvent::Handler&) override
|
||||
{
|
||||
// noop
|
||||
}
|
||||
|
||||
private:
|
||||
AZ::Transform m_cameraTransform = AZ::Transform::CreateIdentity();
|
||||
};
|
||||
|
||||
class ModularViewportCameraControllerFixture : public AllocatorsTestFixture
|
||||
{
|
||||
public:
|
||||
@@ -48,123 +108,159 @@ namespace UnitTest
|
||||
AllocatorsTestFixture::TearDown();
|
||||
}
|
||||
|
||||
void PrepareCollaborators()
|
||||
{
|
||||
AzFramework::NativeWindowHandle nativeWindowHandle = nullptr;
|
||||
|
||||
// listen for events signaled from QtEventToAzInputMapper and forward to the controller list
|
||||
QObject::connect(
|
||||
m_inputChannelMapper.get(), &AzToolsFramework::QtEventToAzInputMapper::InputChannelUpdated, m_rootWidget.get(),
|
||||
[this, nativeWindowHandle](const AzFramework::InputChannel* inputChannel, [[maybe_unused]] QEvent* event)
|
||||
{
|
||||
m_controllerList->HandleInputChannelEvent(
|
||||
AzFramework::ViewportControllerInputEvent{ TestViewportId, nativeWindowHandle, *inputChannel });
|
||||
});
|
||||
|
||||
m_mockWindowRequests.Connect(nativeWindowHandle);
|
||||
|
||||
using ::testing::Return;
|
||||
// note: WindowRequests is used internally by ModularViewportCameraController, this ensures it returns the viewport size we want
|
||||
ON_CALL(m_mockWindowRequests, GetClientAreaSize())
|
||||
.WillByDefault(Return(AzFramework::WindowSize(WidgetSize.width(), WidgetSize.height())));
|
||||
|
||||
// respond to begin/end cursor capture events
|
||||
m_viewportMouseCursorRequests.Connect(TestViewportId, m_inputChannelMapper.get());
|
||||
|
||||
// create editor modular camera
|
||||
auto controller = CreateModularViewportCameraController(TestViewportId);
|
||||
|
||||
// set some overrides for the test
|
||||
controller->SetCameraViewportContextBuilderCallback(
|
||||
[this](AZStd::unique_ptr<AtomToolsFramework::ModularCameraViewportContext>& cameraViewportContext)
|
||||
{
|
||||
cameraViewportContext = AZStd::make_unique<TestModularCameraViewportContextImpl>();
|
||||
m_cameraViewportContextView = cameraViewportContext.get();
|
||||
});
|
||||
|
||||
// disable smoothing in the test
|
||||
controller->SetCameraPropsBuilderCallback(
|
||||
[](AzFramework::CameraProps& cameraProps)
|
||||
{
|
||||
cameraProps.m_rotateSmoothingEnabledFn = []
|
||||
{
|
||||
return false;
|
||||
};
|
||||
|
||||
cameraProps.m_translateSmoothingEnabledFn = []
|
||||
{
|
||||
return false;
|
||||
};
|
||||
});
|
||||
|
||||
m_controllerList->Add(controller);
|
||||
}
|
||||
|
||||
void HaltCollaborators()
|
||||
{
|
||||
m_mockWindowRequests.Disconnect();
|
||||
m_viewportMouseCursorRequests.Disconnect();
|
||||
m_cameraViewportContextView = nullptr;
|
||||
}
|
||||
|
||||
void RepeatDiagonalMouseMovements(const AZStd::function<float()>& deltaTimeFn)
|
||||
{
|
||||
// move to the center of the screen
|
||||
auto start = QPoint(WidgetSize.width() / 2, WidgetSize.height() / 2);
|
||||
MouseMove(m_rootWidget.get(), start, QPoint(0, 0));
|
||||
m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(deltaTimeFn()), AZ::ScriptTimePoint() });
|
||||
|
||||
// move mouse diagonally to top right, then to bottom left and back repeatedly
|
||||
auto current = start;
|
||||
auto halfDelta = QPoint(200, -200);
|
||||
const int iterationsPerDiagonal = 50;
|
||||
for (int diagonals = 0; diagonals < 80; ++diagonals)
|
||||
{
|
||||
for (int i = 0; i < iterationsPerDiagonal; ++i)
|
||||
{
|
||||
MousePressAndMove(m_rootWidget.get(), current, halfDelta / iterationsPerDiagonal, Qt::MouseButton::RightButton);
|
||||
m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(deltaTimeFn()), AZ::ScriptTimePoint() });
|
||||
current += halfDelta / iterationsPerDiagonal;
|
||||
}
|
||||
|
||||
if (diagonals % 2 == 0)
|
||||
{
|
||||
halfDelta.setX(halfDelta.x() * -1);
|
||||
halfDelta.setY(halfDelta.y() * -1);
|
||||
}
|
||||
}
|
||||
|
||||
QTest::mouseRelease(m_rootWidget.get(), Qt::MouseButton::RightButton, Qt::KeyboardModifier::NoModifier, current);
|
||||
m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(deltaTimeFn()), AZ::ScriptTimePoint() });
|
||||
}
|
||||
|
||||
AZStd::unique_ptr<QWidget> m_rootWidget;
|
||||
AzFramework::ViewportControllerListPtr m_controllerList;
|
||||
AZStd::unique_ptr<AzToolsFramework::QtEventToAzInputMapper> m_inputChannelMapper;
|
||||
::testing::NiceMock<MockWindowRequests> m_mockWindowRequests;
|
||||
ViewportMouseCursorRequestImpl m_viewportMouseCursorRequests;
|
||||
AtomToolsFramework::ModularCameraViewportContext* m_cameraViewportContextView = nullptr;
|
||||
};
|
||||
|
||||
const AzFramework::ViewportId ModularViewportCameraControllerFixture::TestViewportId = AzFramework::ViewportId(0);
|
||||
|
||||
class TestModularCameraViewportContextImpl : public AtomToolsFramework::ModularCameraViewportContext
|
||||
TEST_F(ModularViewportCameraControllerFixture, MouseMovementDoesNotAccumulateExcessiveDriftInModularViewportCameraWithVaryingDeltaTime)
|
||||
{
|
||||
public:
|
||||
AZ::Transform GetCameraTransform() const override
|
||||
{
|
||||
return m_cameraTransform;
|
||||
}
|
||||
|
||||
void SetCameraTransform(const AZ::Transform& transform) override
|
||||
{
|
||||
m_cameraTransform = transform;
|
||||
}
|
||||
|
||||
void ConnectViewMatrixChangedHandler(AZ::RPI::ViewportContext::MatrixChangedEvent::Handler&) override
|
||||
{
|
||||
// noop
|
||||
}
|
||||
|
||||
private:
|
||||
AZ::Transform m_cameraTransform = AZ::Transform::CreateIdentity();
|
||||
};
|
||||
|
||||
TEST_F(ModularViewportCameraControllerFixture, Mouse_movement_does_not_accumulate_excessive_drift_in_modular_viewport_camera)
|
||||
{
|
||||
AzFramework::NativeWindowHandle nativeWindowHandle = nullptr;
|
||||
|
||||
const float deltaTime = 1.0f / 60.0f; // mimic 60fps
|
||||
|
||||
// Given
|
||||
// listen for events signaled from QtEventToAzInputMapper and forward to the controller list
|
||||
QObject::connect(
|
||||
m_inputChannelMapper.get(), &AzToolsFramework::QtEventToAzInputMapper::InputChannelUpdated, m_rootWidget.get(),
|
||||
[this, nativeWindowHandle](const AzFramework::InputChannel* inputChannel, [[maybe_unused]] QEvent* event)
|
||||
{
|
||||
m_controllerList->HandleInputChannelEvent(
|
||||
AzFramework::ViewportControllerInputEvent{ TestViewportId, nativeWindowHandle, *inputChannel });
|
||||
});
|
||||
|
||||
using ::testing::NiceMock;
|
||||
using ::testing::Return;
|
||||
|
||||
NiceMock<MockWindowRequests> mockWindowRequests;
|
||||
mockWindowRequests.Connect(nativeWindowHandle);
|
||||
|
||||
// note: WindowRequests is used internally by ModularViewportCameraController, this ensures it returns the viewport size we want
|
||||
ON_CALL(mockWindowRequests, GetClientAreaSize())
|
||||
.WillByDefault(Return(AzFramework::WindowSize(WidgetSize.width(), WidgetSize.height())));
|
||||
|
||||
// create editor modular camera
|
||||
auto controller = CreateModularViewportCameraController(TestViewportId);
|
||||
|
||||
// set some overrides for the test
|
||||
AtomToolsFramework::ModularCameraViewportContext* cameraViewportContextView = nullptr;
|
||||
controller->SetCameraViewportContextBuilderCallback(
|
||||
[&cameraViewportContextView](AZStd::unique_ptr<AtomToolsFramework::ModularCameraViewportContext>& cameraViewportContext)
|
||||
{
|
||||
cameraViewportContext = AZStd::make_unique<TestModularCameraViewportContextImpl>();
|
||||
cameraViewportContextView = cameraViewportContext.get();
|
||||
});
|
||||
|
||||
controller->SetCameraPropsBuilderCallback(
|
||||
[](AzFramework::CameraProps& cameraProps)
|
||||
{
|
||||
cameraProps.m_rotateSmoothingEnabledFn = []
|
||||
{
|
||||
return false;
|
||||
};
|
||||
|
||||
cameraProps.m_translateSmoothingEnabledFn = []
|
||||
{
|
||||
return false;
|
||||
};
|
||||
});
|
||||
|
||||
m_controllerList->Add(controller);
|
||||
|
||||
// move to the center of the screen
|
||||
auto start = QPoint(WidgetSize.width() / 2, WidgetSize.height() / 2);
|
||||
MouseMove(m_rootWidget.get(), start, QPoint(0, 0));
|
||||
m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(deltaTime), AZ::ScriptTimePoint() });
|
||||
PrepareCollaborators();
|
||||
|
||||
// When
|
||||
// move mouse diagonally to top right, then to bottom left and back repeatedly
|
||||
auto current = start;
|
||||
auto halfDelta = QPoint(200, -200);
|
||||
const int iterationsPerDiagonal = 50;
|
||||
for (int diagonals = 0; diagonals < 80; ++diagonals)
|
||||
{
|
||||
for (int i = 0; i < iterationsPerDiagonal; ++i)
|
||||
RepeatDiagonalMouseMovements(
|
||||
[t = 0.0f]() mutable
|
||||
{
|
||||
MousePressAndMove(m_rootWidget.get(), current, halfDelta / iterationsPerDiagonal, Qt::MouseButton::RightButton);
|
||||
m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(deltaTime), AZ::ScriptTimePoint() });
|
||||
current += halfDelta / iterationsPerDiagonal;
|
||||
}
|
||||
|
||||
if (diagonals % 2 == 0)
|
||||
{
|
||||
halfDelta.setX(halfDelta.x() * -1);
|
||||
halfDelta.setY(halfDelta.y() * -1);
|
||||
}
|
||||
}
|
||||
|
||||
QTest::mouseRelease(m_rootWidget.get(), Qt::MouseButton::RightButton, Qt::KeyboardModifier::NoModifier, current);
|
||||
m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(deltaTime), AZ::ScriptTimePoint() });
|
||||
// vary between 30 and 50 fps (40 +/- 10)
|
||||
const float fps = 40.0f + (10.0f * AZStd::sin(t));
|
||||
t += AZ::DegToRad(5.0f);
|
||||
return 1.0f / fps;
|
||||
});
|
||||
|
||||
// Then
|
||||
// ensure the camera rotation is the identity (no significant drift has occurred as we moved the mouse)
|
||||
const AZ::Transform cameraRotation = cameraViewportContextView->GetCameraTransform();
|
||||
const AZ::Transform cameraRotation = m_cameraViewportContextView->GetCameraTransform();
|
||||
EXPECT_THAT(cameraRotation.GetRotation(), IsClose(AZ::Quaternion::CreateIdentity()));
|
||||
|
||||
mockWindowRequests.Disconnect();
|
||||
// Clean-up
|
||||
HaltCollaborators();
|
||||
}
|
||||
|
||||
class ModularViewportCameraControllerDeltaTimeParamFixture
|
||||
: public ModularViewportCameraControllerFixture
|
||||
, public ::testing::WithParamInterface<float> // delta time
|
||||
{
|
||||
};
|
||||
|
||||
TEST_P(
|
||||
ModularViewportCameraControllerDeltaTimeParamFixture,
|
||||
MouseMovementDoesNotAccumulateExcessiveDriftInModularViewportCameraWithFixedDeltaTime)
|
||||
{
|
||||
// Given
|
||||
PrepareCollaborators();
|
||||
|
||||
// When
|
||||
RepeatDiagonalMouseMovements(
|
||||
[this]
|
||||
{
|
||||
return GetParam();
|
||||
});
|
||||
|
||||
// Then
|
||||
// ensure the camera rotation is the identity (no significant drift has occurred as we moved the mouse)
|
||||
const AZ::Transform cameraRotation = m_cameraViewportContextView->GetCameraTransform();
|
||||
EXPECT_THAT(cameraRotation.GetRotation(), IsClose(AZ::Quaternion::CreateIdentity()));
|
||||
|
||||
// Clean-up
|
||||
HaltCollaborators();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
All, ModularViewportCameraControllerDeltaTimeParamFixture, testing::Values(1.0f / 60.0f, 1.0f / 50.0f, 1.0f / 30.0f));
|
||||
} // namespace UnitTest
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace AzFramework
|
||||
//! Predefined input event listener priority, used to sort handlers from highest to lowest
|
||||
inline static AZ::s32 GetPriorityFirst() { return std::numeric_limits<AZ::s32>::max(); }
|
||||
inline static AZ::s32 GetPriorityDebug() { return (GetPriorityFirst() / 4) * 3; }
|
||||
inline static AZ::s32 GetPriorityDebugUI() { return (GetPriorityFirst() / 8) * 5; }
|
||||
inline static AZ::s32 GetPriorityUI() { return GetPriorityFirst() / 2; }
|
||||
inline static AZ::s32 GetPriorityDefault() { return 0; }
|
||||
inline static AZ::s32 GetPriorityLast() { return std::numeric_limits<AZ::s32>::min(); }
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace AzFramework
|
||||
//! Predefined text event listener priority, used to sort handlers from highest to lowest
|
||||
inline static AZ::s32 GetPriorityFirst() { return std::numeric_limits<AZ::s32>::max(); }
|
||||
inline static AZ::s32 GetPriorityDebug() { return (GetPriorityFirst() / 4) * 3; }
|
||||
inline static AZ::s32 GetPriorityDebugUI() { return (GetPriorityFirst() / 8) * 5; }
|
||||
inline static AZ::s32 GetPriorityUI() { return GetPriorityFirst() / 2; }
|
||||
inline static AZ::s32 GetPriorityDefault() { return 0; }
|
||||
inline static AZ::s32 GetPriorityLast() { return std::numeric_limits<AZ::s32>::min(); }
|
||||
|
||||
@@ -13,14 +13,6 @@
|
||||
|
||||
#include <AzFramework/Physics/CollisionBus.h>
|
||||
|
||||
//This bit is defined in the TouchBending Gem wscript.
|
||||
//Make sure the bit has a valid value.
|
||||
#ifdef TOUCHBENDING_LAYER_BIT
|
||||
#if (TOUCHBENDING_LAYER_BIT < 1) || (TOUCHBENDING_LAYER_BIT > 63)
|
||||
#error Invalid Bit Definition For the TouchBending Layer Bit
|
||||
#endif
|
||||
#endif //#ifdef TOUCHBENDING_LAYER_BIT
|
||||
|
||||
namespace AzPhysics
|
||||
{
|
||||
AZ_CLASS_ALLOCATOR_IMPL(CollisionGroup, AZ::SystemAllocator, 0);
|
||||
@@ -31,10 +23,6 @@ namespace AzPhysics
|
||||
const CollisionGroup CollisionGroup::None = 0x0000000000000000ULL;
|
||||
const CollisionGroup CollisionGroup::All = 0xFFFFFFFFFFFFFFFFULL;
|
||||
|
||||
#ifdef TOUCHBENDING_LAYER_BIT
|
||||
const CollisionGroup CollisionGroup::All_NoTouchBend = CollisionGroup::All.GetMask() & ~CollisionLayer::TouchBend.GetMask();
|
||||
#endif
|
||||
|
||||
void CollisionGroupScriptConstructor(CollisionGroup* thisPtr, AZ::ScriptDataContext& scriptDataContext)
|
||||
{
|
||||
if (int numArgs = scriptDataContext.GetNumArguments();
|
||||
|
||||
@@ -14,14 +14,6 @@
|
||||
|
||||
#include <AzFramework/Physics/CollisionBus.h>
|
||||
|
||||
//This bit is defined in the TouchBending Gem wscript.
|
||||
//Make sure the bit has a valid value.
|
||||
#ifdef TOUCHBENDING_LAYER_BIT
|
||||
#if (TOUCHBENDING_LAYER_BIT < 1) || (TOUCHBENDING_LAYER_BIT > 63)
|
||||
#error Invalid Bit Definition For the TouchBending Layer Bit
|
||||
#endif
|
||||
#endif //#ifdef TOUCHBENDING_LAYER_BIT
|
||||
|
||||
namespace AzPhysics
|
||||
{
|
||||
AZ_CLASS_ALLOCATOR_IMPL(CollisionLayer, AZ::SystemAllocator, 0);
|
||||
@@ -29,10 +21,6 @@ namespace AzPhysics
|
||||
|
||||
const CollisionLayer CollisionLayer::Default = 0;
|
||||
|
||||
#ifdef TOUCHBENDING_LAYER_BIT
|
||||
const CollisionLayer CollisionLayer::TouchBend = TOUCHBENDING_LAYER_BIT;
|
||||
#endif
|
||||
|
||||
void CollisionLayer::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
|
||||
@@ -32,12 +32,20 @@ namespace AzPhysics
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR_DECL;
|
||||
AZ_RTTI(StaticRigidBody, "{13A677BB-7085-4EDB-BCC8-306548238692}", SimulatedBody);
|
||||
AZ_RTTI(AzPhysics::StaticRigidBody, "{13A677BB-7085-4EDB-BCC8-306548238692}", AzPhysics::SimulatedBody);
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
//Legacy API - may change with LYN-438
|
||||
//! Add a shape to the static rigid body.
|
||||
//! @param shape A shared pointer of the shape to add.
|
||||
virtual void AddShape(const AZStd::shared_ptr<Physics::Shape>& shape) = 0;
|
||||
|
||||
//! Returns the number of shapes that make up this static rigid body.
|
||||
//! @return Returns the number of shapes as a AZ::u32.
|
||||
virtual AZ::u32 GetShapeCount() { return 0; }
|
||||
|
||||
//! Returns a shared pointer to the requested shape index.
|
||||
//! @param index The index of the shapes to return. Expected to be between 0 and GetShapeCount().
|
||||
//! @return Returns a shared pointer of the shape requested or nullptr if index is out of bounds.
|
||||
virtual AZStd::shared_ptr<Physics::Shape> GetShape([[maybe_unused]]AZ::u32 index) { return nullptr; }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -802,7 +802,6 @@ namespace AzFramework
|
||||
{
|
||||
return VerticalMotionEvent{ aznumeric_cast<int>(inputChannel.GetValue()) };
|
||||
}
|
||||
|
||||
else if (inputChannelId == InputDeviceMouse::Movement::Z)
|
||||
{
|
||||
return ScrollEvent{ inputChannel.GetValue() };
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME})
|
||||
ly_get_list_relative_pal_filename(common_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/Common)
|
||||
|
||||
set(LY_TOUCHBENDING_LAYER_BIT 63 CACHE STRING "Use TouchBending as the collision layer. The TouchBending layer can be a number from 1 to 63 (Default=63).")
|
||||
|
||||
ly_add_target(
|
||||
NAME AzFramework STATIC
|
||||
NAMESPACE AZ
|
||||
@@ -37,14 +35,6 @@ ly_add_target(
|
||||
3rdParty::lz4
|
||||
)
|
||||
|
||||
ly_add_source_properties(
|
||||
SOURCES
|
||||
AzFramework/Physics/Collision/CollisionGroups.cpp
|
||||
AzFramework/Physics/Collision/CollisionLayers.cpp
|
||||
PROPERTY COMPILE_DEFINITIONS
|
||||
VALUES TOUCHBENDING_LAYER_BIT=${LY_TOUCHBENDING_LAYER_BIT}
|
||||
)
|
||||
|
||||
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
|
||||
ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Tests/Platform/${PAL_PLATFORM_NAME})
|
||||
|
||||
@@ -650,7 +650,10 @@ namespace AzToolsFramework
|
||||
|
||||
AZStd::unique_ptr<AZ::Entity> Instance::DetachContainerEntity()
|
||||
{
|
||||
m_instanceEntityMapper->UnregisterEntity(m_containerEntity->GetId());
|
||||
if (m_containerEntity)
|
||||
{
|
||||
m_instanceEntityMapper->UnregisterEntity(m_containerEntity->GetId());
|
||||
}
|
||||
return AZStd::move(m_containerEntity);
|
||||
}
|
||||
}
|
||||
|
||||
+14
-6
@@ -65,16 +65,24 @@ namespace AzToolsFramework::Prefab::PrefabConversionUtils
|
||||
AzFramework::Spawnable::EntityList& entities = spawnable->GetEntities();
|
||||
for (auto it = entities.begin(); it != entities.end(); )
|
||||
{
|
||||
(*it)->InvalidateDependencies();
|
||||
AZ::Entity::DependencySortOutcome evaluation = (*it)->EvaluateDependenciesGetDetails();
|
||||
if (evaluation.IsSuccess())
|
||||
if (*it)
|
||||
{
|
||||
++it;
|
||||
(*it)->InvalidateDependencies();
|
||||
AZ::Entity::DependencySortOutcome evaluation = (*it)->EvaluateDependenciesGetDetails();
|
||||
if (evaluation.IsSuccess())
|
||||
{
|
||||
++it;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Error(
|
||||
"Prefabs", false, "Entity '%s' %s cannot be activated for the following reason: %s", (*it)->GetName().c_str(),
|
||||
(*it)->GetId().ToString().c_str(), evaluation.GetError().m_message.c_str());
|
||||
it = entities.erase(it);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Error("Prefabs", false, "Entity '%s' %s cannot be activated for the following reason: %s",
|
||||
(*it)->GetName().c_str(), (*it)->GetId().ToString().c_str(), evaluation.GetError().m_message.c_str());
|
||||
it = entities.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,9 +275,7 @@ namespace AzToolsFramework
|
||||
virtual void BeginCursorCapture() = 0;
|
||||
//! Restores the cursor and ends locking it in place, allowing it to be moved freely.
|
||||
virtual void EndCursorCapture() = 0;
|
||||
//! Gets the most recent recorded cursor position in the viewport in screen space coordinates.
|
||||
virtual AzFramework::ScreenPoint ViewportCursorScreenPosition() = 0;
|
||||
//! Is mouse over viewport.
|
||||
//! Is the mouse over the viewport.
|
||||
virtual bool IsMouseOver() const = 0;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -20,8 +20,7 @@ QPushButton:focus {
|
||||
QTabBar {
|
||||
background-color: transparent;
|
||||
}
|
||||
QTabWidget::tab-bar
|
||||
{
|
||||
QTabWidget::tab-bar {
|
||||
left: 78px; /* make room for the logo */
|
||||
}
|
||||
QTabBar::tab {
|
||||
@@ -32,27 +31,35 @@ QTabBar::tab {
|
||||
margin-right:40px;
|
||||
border-bottom: 3px solid transparent;
|
||||
}
|
||||
QTabBar::tab:text
|
||||
{
|
||||
QTabBar::tab:text {
|
||||
text-align:left;
|
||||
}
|
||||
QTabWidget::pane {
|
||||
background-color: #333333;
|
||||
border:0 none;
|
||||
}
|
||||
QTabBar::tab:selected
|
||||
{
|
||||
QTabBar::tab:selected {
|
||||
background-color: transparent;
|
||||
border-bottom: 3px solid #1e70eb;
|
||||
color: #1e70eb;
|
||||
font-weight: 500;
|
||||
}
|
||||
QTabBar::tab:hover
|
||||
{
|
||||
QTabBar::tab:hover {
|
||||
color: #1e70eb;
|
||||
font-weight: 500;
|
||||
}
|
||||
QTabBar::tab:pressed
|
||||
{
|
||||
QTabBar::tab:pressed {
|
||||
color: #0e60eb;
|
||||
}
|
||||
QTabBar::focus {
|
||||
outline: 0px;
|
||||
outline: none;
|
||||
outline-style: none;
|
||||
}
|
||||
QTabBar::tab:focus {
|
||||
background-color: #525252;
|
||||
color: #4082eb;
|
||||
}
|
||||
|
||||
/************** General (Forms) **************/
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace O3DE::ProjectManager
|
||||
gemNames.reserve(gems.size());
|
||||
for (const QModelIndex& modelIndex : gems)
|
||||
{
|
||||
gemNames.push_back(GemModel::GetName(modelIndex));
|
||||
gemNames.push_back(GemModel::GetDisplayName(modelIndex));
|
||||
}
|
||||
return gemNames;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace O3DE::ProjectManager
|
||||
if (!result.IsSuccess())
|
||||
{
|
||||
QMessageBox::critical(nullptr, "Operation failed",
|
||||
QString("Cannot add gem %1 to project.\n\nError:\n%2").arg(GemModel::GetName(modelIndex), result.GetError().c_str()));
|
||||
QString("Cannot add gem %1 to project.\n\nError:\n%2").arg(GemModel::GetDisplayName(modelIndex), result.GetError().c_str()));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -169,7 +169,7 @@ namespace O3DE::ProjectManager
|
||||
if (!result.IsSuccess())
|
||||
{
|
||||
QMessageBox::critical(nullptr, "Operation failed",
|
||||
QString("Cannot remove gem %1 from project.\n\nError:\n%2").arg(GemModel::GetName(modelIndex), result.GetError().c_str()));
|
||||
QString("Cannot remove gem %1 from project.\n\nError:\n%2").arg(GemModel::GetDisplayName(modelIndex), result.GetError().c_str()));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace O3DE::ProjectManager
|
||||
m_mainWidget->hide();
|
||||
}
|
||||
|
||||
m_nameLabel->setText(m_model->GetName(modelIndex));
|
||||
m_nameLabel->setText(m_model->GetDisplayName(modelIndex));
|
||||
m_creatorLabel->setText(m_model->GetCreator(modelIndex));
|
||||
|
||||
m_summaryLabel->setText(m_model->GetSummary(modelIndex));
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace O3DE::ProjectManager
|
||||
}
|
||||
|
||||
// Gem name
|
||||
QString gemName = GemModel::GetName(modelIndex);
|
||||
QString gemName = GemModel::GetDisplayName(modelIndex);
|
||||
QFont gemNameFont(options.font);
|
||||
const int firstColumnMaxTextWidth = s_summaryStartX - 30;
|
||||
gemNameFont.setPixelSize(static_cast<int>(s_gemNameFontSize));
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace O3DE::ProjectManager
|
||||
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||
|
||||
item->setData(gemInfo.m_name, RoleName);
|
||||
item->setData(gemInfo.m_displayName, RoleDisplayName);
|
||||
item->setData(gemInfo.m_creator, RoleCreator);
|
||||
item->setData(gemInfo.m_gemOrigin, RoleGemOrigin);
|
||||
item->setData(aznumeric_cast<int>(gemInfo.m_platforms), RolePlatforms);
|
||||
@@ -64,6 +65,20 @@ namespace O3DE::ProjectManager
|
||||
return modelIndex.data(RoleName).toString();
|
||||
}
|
||||
|
||||
QString GemModel::GetDisplayName(const QModelIndex& modelIndex)
|
||||
{
|
||||
QString displayName = modelIndex.data(RoleDisplayName).toString();
|
||||
|
||||
if (displayName.isEmpty())
|
||||
{
|
||||
return GetName(modelIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
return displayName;
|
||||
}
|
||||
}
|
||||
|
||||
QString GemModel::GetCreator(const QModelIndex& modelIndex)
|
||||
{
|
||||
return modelIndex.data(RoleCreator).toString();
|
||||
@@ -117,7 +132,7 @@ namespace O3DE::ProjectManager
|
||||
QModelIndex modelIndex = FindIndexByNameString(dependingGemString);
|
||||
if (modelIndex.isValid())
|
||||
{
|
||||
dependingGemString = GetName(modelIndex);
|
||||
dependingGemString = GetDisplayName(modelIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace O3DE::ProjectManager
|
||||
QStringList GetConflictingGemNames(const QModelIndex& modelIndex);
|
||||
|
||||
static QString GetName(const QModelIndex& modelIndex);
|
||||
static QString GetDisplayName(const QModelIndex& modelIndex);
|
||||
static QString GetCreator(const QModelIndex& modelIndex);
|
||||
static GemInfo::GemOrigin GetGemOrigin(const QModelIndex& modelIndex);
|
||||
static GemInfo::Platforms GetPlatforms(const QModelIndex& modelIndex);
|
||||
@@ -69,6 +70,7 @@ namespace O3DE::ProjectManager
|
||||
enum UserRole
|
||||
{
|
||||
RoleName = Qt::UserRole,
|
||||
RoleDisplayName,
|
||||
RoleCreator,
|
||||
RoleGemOrigin,
|
||||
RolePlatforms,
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace O3DE::ProjectManager
|
||||
painter->fillRect(itemRect, itemBackgroundColor);
|
||||
|
||||
// Gem name
|
||||
QString gemName = GemModel::GetName(modelIndex);
|
||||
QString gemName = GemModel::GetDisplayName(modelIndex);
|
||||
QFont gemNameFont(options.font);
|
||||
const int firstColumnMaxTextWidth = s_summaryStartX - 30;
|
||||
gemName = QFontMetrics(gemNameFont).elidedText(gemName, Qt::TextElideMode::ElideRight, firstColumnMaxTextWidth);
|
||||
|
||||
@@ -28,9 +28,26 @@ namespace O3DE::ProjectManager
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_sourceModel->GetName(sourceIndex).contains(m_searchString, Qt::CaseInsensitive))
|
||||
// Search Bar
|
||||
if (!m_sourceModel->GetDisplayName(sourceIndex).contains(m_searchString, Qt::CaseInsensitive) &&
|
||||
!m_sourceModel->GetName(sourceIndex).contains(m_searchString, Qt::CaseInsensitive) &&
|
||||
!m_sourceModel->GetCreator(sourceIndex).contains(m_searchString, Qt::CaseInsensitive) &&
|
||||
!m_sourceModel->GetSummary(sourceIndex).contains(m_searchString, Qt::CaseInsensitive))
|
||||
{
|
||||
return false;
|
||||
bool foundFeature = false;
|
||||
for (const QString& feature : m_sourceModel->GetFeatures(sourceIndex))
|
||||
{
|
||||
if (feature.contains(m_searchString, Qt::CaseInsensitive))
|
||||
{
|
||||
foundFeature = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundFeature)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Gem status
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace O3DE::ProjectManager
|
||||
|
||||
if (projectButton)
|
||||
{
|
||||
projectButton->SetProjectBuilding();
|
||||
projectButton->SetProjectButtonAction(tr("Cancel Build"), [this] { HandleCancel(); });
|
||||
|
||||
if (m_lastProgress != 0)
|
||||
@@ -111,6 +112,10 @@ namespace O3DE::ProjectManager
|
||||
emit Done(false);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_projectInfo.m_buildFailed = false;
|
||||
}
|
||||
|
||||
emit Done(true);
|
||||
}
|
||||
|
||||
@@ -162,22 +162,9 @@ namespace O3DE::ProjectManager
|
||||
QDesktopServices::openUrl(m_logUrl);
|
||||
}
|
||||
|
||||
ProjectButton::ProjectButton(const ProjectInfo& projectInfo, QWidget* parent, bool processing)
|
||||
ProjectButton::ProjectButton(const ProjectInfo& projectInfo, QWidget* parent)
|
||||
: QFrame(parent)
|
||||
, m_projectInfo(projectInfo)
|
||||
{
|
||||
BaseSetup();
|
||||
if (processing)
|
||||
{
|
||||
ProcessingSetup();
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadySetup();
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectButton::BaseSetup()
|
||||
{
|
||||
setObjectName("projectButton");
|
||||
|
||||
@@ -199,50 +186,63 @@ namespace O3DE::ProjectManager
|
||||
}
|
||||
m_projectImageLabel->setPixmap(QPixmap(projectPreviewPath).scaled(m_projectImageLabel->size(), Qt::KeepAspectRatioByExpanding));
|
||||
|
||||
m_projectFooter = new QFrame(this);
|
||||
QFrame* projectFooter = new QFrame(this);
|
||||
QHBoxLayout* hLayout = new QHBoxLayout();
|
||||
hLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_projectFooter->setLayout(hLayout);
|
||||
projectFooter->setLayout(hLayout);
|
||||
{
|
||||
QLabel* projectNameLabel = new QLabel(m_projectInfo.GetProjectDisplayName(), this);
|
||||
hLayout->addWidget(projectNameLabel);
|
||||
|
||||
QMenu* menu = new QMenu(this);
|
||||
menu->addAction(tr("Edit Project Settings..."), this, [this]() { emit EditProject(m_projectInfo.m_path); });
|
||||
menu->addAction(tr("Build"), this, [this]() { emit BuildProject(m_projectInfo); });
|
||||
menu->addSeparator();
|
||||
menu->addAction(tr("Open Project folder..."), this, [this]()
|
||||
{
|
||||
AzQtComponents::ShowFileOnDesktop(m_projectInfo.m_path);
|
||||
});
|
||||
menu->addSeparator();
|
||||
menu->addAction(tr("Duplicate"), this, [this]() { emit CopyProject(m_projectInfo); });
|
||||
menu->addSeparator();
|
||||
menu->addAction(tr("Remove from O3DE"), this, [this]() { emit RemoveProject(m_projectInfo.m_path); });
|
||||
menu->addAction(tr("Delete this Project"), this, [this]() { emit DeleteProject(m_projectInfo.m_path); });
|
||||
|
||||
m_projectMenuButton = new QPushButton(this);
|
||||
m_projectMenuButton->setObjectName("projectMenuButton");
|
||||
m_projectMenuButton->setMenu(menu);
|
||||
hLayout->addWidget(m_projectMenuButton);
|
||||
}
|
||||
|
||||
vLayout->addWidget(m_projectFooter);
|
||||
vLayout->addWidget(projectFooter);
|
||||
|
||||
connect(m_projectImageLabel->GetOpenEditorButton(), &QPushButton::clicked, [this](){ emit OpenProject(m_projectInfo.m_path); });
|
||||
}
|
||||
|
||||
void ProjectButton::ProcessingSetup()
|
||||
const ProjectInfo& ProjectButton::GetProjectInfo() const
|
||||
{
|
||||
m_projectImageLabel->SetEnabled(false);
|
||||
m_projectImageLabel->SetOverlayText(tr("Processing...\n\n"));
|
||||
return m_projectInfo;
|
||||
}
|
||||
|
||||
void ProjectButton::RestoreDefaultState()
|
||||
{
|
||||
m_projectImageLabel->SetEnabled(true);
|
||||
m_projectImageLabel->SetOverlayText("");
|
||||
m_projectMenuButton->setVisible(true);
|
||||
|
||||
QProgressBar* progressBar = m_projectImageLabel->GetProgressBar();
|
||||
progressBar->setVisible(true);
|
||||
progressBar->setVisible(false);
|
||||
progressBar->setValue(0);
|
||||
}
|
||||
|
||||
void ProjectButton::ReadySetup()
|
||||
{
|
||||
connect(m_projectImageLabel->GetOpenEditorButton(), &QPushButton::clicked, [this](){ emit OpenProject(m_projectInfo.m_path); });
|
||||
QPushButton* projectActionButton = m_projectImageLabel->GetActionButton();
|
||||
projectActionButton->setVisible(false);
|
||||
if (m_actionButtonConnection)
|
||||
{
|
||||
disconnect(m_actionButtonConnection);
|
||||
}
|
||||
|
||||
QMenu* menu = new QMenu(this);
|
||||
menu->addAction(tr("Edit Project Settings..."), this, [this]() { emit EditProject(m_projectInfo.m_path); });
|
||||
menu->addAction(tr("Build"), this, [this]() { emit BuildProject(m_projectInfo); });
|
||||
menu->addSeparator();
|
||||
menu->addAction(tr("Open Project folder..."), this, [this]()
|
||||
{
|
||||
AzQtComponents::ShowFileOnDesktop(m_projectInfo.m_path);
|
||||
});
|
||||
menu->addSeparator();
|
||||
menu->addAction(tr("Duplicate"), this, [this]() { emit CopyProject(m_projectInfo); });
|
||||
menu->addSeparator();
|
||||
menu->addAction(tr("Remove from O3DE"), this, [this]() { emit RemoveProject(m_projectInfo.m_path); });
|
||||
menu->addAction(tr("Delete this Project"), this, [this]() { emit DeleteProject(m_projectInfo.m_path); });
|
||||
|
||||
QPushButton* projectMenuButton = new QPushButton(this);
|
||||
projectMenuButton->setObjectName("projectMenuButton");
|
||||
projectMenuButton->setMenu(menu);
|
||||
m_projectFooter->layout()->addWidget(projectMenuButton);
|
||||
m_projectImageLabel->GetWarningIcon()->setVisible(false);
|
||||
m_projectImageLabel->GetWarningLabel()->setVisible(false);
|
||||
}
|
||||
|
||||
void ProjectButton::SetProjectButtonAction(const QString& text, AZStd::function<void()> lambda)
|
||||
@@ -292,9 +292,15 @@ namespace O3DE::ProjectManager
|
||||
SetProjectButtonAction(tr("Build Project"), [this]() { emit BuildProject(m_projectInfo); });
|
||||
}
|
||||
|
||||
void ProjectButton::BuildThisProject()
|
||||
void ProjectButton::SetProjectBuilding()
|
||||
{
|
||||
emit BuildProject(m_projectInfo);
|
||||
m_projectImageLabel->SetEnabled(false);
|
||||
m_projectImageLabel->SetOverlayText(tr("Building...\n\n"));
|
||||
m_projectMenuButton->setVisible(false);
|
||||
|
||||
QProgressBar* progressBar = m_projectImageLabel->GetProgressBar();
|
||||
progressBar->setVisible(true);
|
||||
progressBar->setValue(0);
|
||||
}
|
||||
|
||||
void ProjectButton::SetLaunchButtonEnabled(bool enabled)
|
||||
|
||||
@@ -56,13 +56,14 @@ namespace O3DE::ProjectManager
|
||||
void OnLinkActivated(const QString& link);
|
||||
|
||||
private:
|
||||
QVBoxLayout* m_buildOverlayLayout;
|
||||
QLabel* m_overlayLabel;
|
||||
QProgressBar* m_progressBar;
|
||||
QPushButton* m_openEditorButton;
|
||||
QPushButton* m_actionButton;
|
||||
QLabel* m_warningText;
|
||||
QLabel* m_warningIcon;
|
||||
QVBoxLayout* m_buildOverlayLayout = nullptr;
|
||||
QLabel* m_overlayLabel = nullptr;
|
||||
QProgressBar* m_progressBar = nullptr;
|
||||
QPushButton* m_openEditorButton = nullptr;
|
||||
QPushButton* m_actionButton = nullptr;
|
||||
QLabel* m_warningText = nullptr;
|
||||
QLabel* m_warningIcon = nullptr;
|
||||
|
||||
QUrl m_logUrl;
|
||||
bool m_enabled = true;
|
||||
};
|
||||
@@ -73,13 +74,18 @@ namespace O3DE::ProjectManager
|
||||
Q_OBJECT // AUTOMOC
|
||||
|
||||
public:
|
||||
explicit ProjectButton(const ProjectInfo& m_projectInfo, QWidget* parent = nullptr, bool processing = false);
|
||||
explicit ProjectButton(const ProjectInfo& m_projectInfo, QWidget* parent = nullptr);
|
||||
~ProjectButton() = default;
|
||||
|
||||
const ProjectInfo& GetProjectInfo() const;
|
||||
|
||||
void RestoreDefaultState();
|
||||
|
||||
void SetProjectButtonAction(const QString& text, AZStd::function<void()> lambda);
|
||||
void SetProjectBuildButtonAction();
|
||||
void SetBuildLogsLink(const QUrl& logUrl);
|
||||
void ShowBuildFailed(bool show, const QUrl& logUrl);
|
||||
void SetProjectBuilding();
|
||||
|
||||
void SetLaunchButtonEnabled(bool enabled);
|
||||
void SetButtonOverlayText(const QString& text);
|
||||
@@ -95,17 +101,14 @@ namespace O3DE::ProjectManager
|
||||
void BuildProject(const ProjectInfo& projectInfo);
|
||||
|
||||
private:
|
||||
void BaseSetup();
|
||||
void ProcessingSetup();
|
||||
void ReadySetup();
|
||||
void enterEvent(QEvent* event) override;
|
||||
void leaveEvent(QEvent* event) override;
|
||||
void BuildThisProject();
|
||||
|
||||
ProjectInfo m_projectInfo;
|
||||
LabelButton* m_projectImageLabel;
|
||||
QFrame* m_projectFooter;
|
||||
QLayout* m_requiresBuildLayout;
|
||||
|
||||
LabelButton* m_projectImageLabel = nullptr;
|
||||
QPushButton* m_projectMenuButton = nullptr;
|
||||
QLayout* m_requiresBuildLayout = nullptr;
|
||||
|
||||
QMetaObject::Connection m_actionButtonConnection;
|
||||
};
|
||||
|
||||
@@ -68,9 +68,7 @@ namespace O3DE::ProjectManager
|
||||
}
|
||||
|
||||
ProjectsScreen::~ProjectsScreen()
|
||||
|
||||
{
|
||||
delete m_currentBuilder;
|
||||
}
|
||||
|
||||
QFrame* ProjectsScreen::CreateFirstTimeContent()
|
||||
@@ -114,10 +112,8 @@ namespace O3DE::ProjectManager
|
||||
return frame;
|
||||
}
|
||||
|
||||
QFrame* ProjectsScreen::CreateProjectsContent(QString buildProjectPath, ProjectButton** projectButton)
|
||||
QFrame* ProjectsScreen::CreateProjectsContent()
|
||||
{
|
||||
RemoveInvalidProjects();
|
||||
|
||||
QFrame* frame = new QFrame(this);
|
||||
frame->setObjectName("projectsContent");
|
||||
{
|
||||
@@ -126,7 +122,7 @@ namespace O3DE::ProjectManager
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
frame->setLayout(layout);
|
||||
|
||||
QFrame* header = new QFrame(this);
|
||||
QFrame* header = new QFrame(frame);
|
||||
QHBoxLayout* headerLayout = new QHBoxLayout();
|
||||
{
|
||||
QLabel* titleLabel = new QLabel(tr("My Projects"), this);
|
||||
@@ -150,87 +146,34 @@ namespace O3DE::ProjectManager
|
||||
|
||||
layout->addWidget(header);
|
||||
|
||||
// Get all projects and create a horizontal scrolling list of them
|
||||
auto projectsResult = PythonBindingsInterface::Get()->GetProjects();
|
||||
if (projectsResult.IsSuccess() && !projectsResult.GetValue().isEmpty())
|
||||
{
|
||||
QScrollArea* projectsScrollArea = new QScrollArea(this);
|
||||
QWidget* scrollWidget = new QWidget();
|
||||
QScrollArea* projectsScrollArea = new QScrollArea(this);
|
||||
QWidget* scrollWidget = new QWidget();
|
||||
|
||||
FlowLayout* flowLayout = new FlowLayout(0, s_spacerSize, s_spacerSize);
|
||||
scrollWidget->setLayout(flowLayout);
|
||||
m_projectsFlowLayout = new FlowLayout(0, s_spacerSize, s_spacerSize);
|
||||
scrollWidget->setLayout(m_projectsFlowLayout);
|
||||
|
||||
projectsScrollArea->setWidget(scrollWidget);
|
||||
projectsScrollArea->setWidgetResizable(true);
|
||||
projectsScrollArea->setWidget(scrollWidget);
|
||||
projectsScrollArea->setWidgetResizable(true);
|
||||
|
||||
QVector<ProjectInfo> nonProcessingProjects;
|
||||
buildProjectPath = QDir::fromNativeSeparators(buildProjectPath);
|
||||
for (auto& project : projectsResult.GetValue())
|
||||
{
|
||||
if (projectButton && !*projectButton)
|
||||
{
|
||||
if (QDir::fromNativeSeparators(project.m_path) == buildProjectPath)
|
||||
{
|
||||
*projectButton = CreateProjectButton(project, flowLayout, true);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
ResetProjectsContent();
|
||||
|
||||
nonProcessingProjects.append(project);
|
||||
}
|
||||
|
||||
for (auto& project : nonProcessingProjects)
|
||||
{
|
||||
ProjectButton* projectButtonWidget = CreateProjectButton(project, flowLayout);
|
||||
|
||||
if (BuildQueueContainsProject(project.m_path))
|
||||
{
|
||||
projectButtonWidget->SetProjectButtonAction(tr("Cancel Queued Build"),
|
||||
[this, project]
|
||||
{
|
||||
UnqueueBuildProject(project);
|
||||
SuggestBuildProjectMsg(project, false);
|
||||
});
|
||||
}
|
||||
else if (RequiresBuildProjectIterator(project.m_path) != m_requiresBuild.end())
|
||||
{
|
||||
auto buildProjectIterator = RequiresBuildProjectIterator(project.m_path);
|
||||
if (buildProjectIterator != m_requiresBuild.end())
|
||||
{
|
||||
if (buildProjectIterator->m_buildFailed)
|
||||
{
|
||||
projectButtonWidget->ShowBuildFailed(true, buildProjectIterator->m_logUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
projectButtonWidget->SetProjectBuildButtonAction();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
layout->addWidget(projectsScrollArea);
|
||||
}
|
||||
layout->addWidget(projectsScrollArea);
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
ProjectButton* ProjectsScreen::CreateProjectButton(ProjectInfo& project, QLayout* flowLayout, bool processing)
|
||||
ProjectButton* ProjectsScreen::CreateProjectButton(const ProjectInfo& project)
|
||||
{
|
||||
ProjectButton* projectButton = new ProjectButton(project, this, processing);
|
||||
ProjectButton* projectButton = new ProjectButton(project, this);
|
||||
m_projectButtons.insert(project.m_path, projectButton);
|
||||
m_projectsFlowLayout->addWidget(projectButton);
|
||||
|
||||
flowLayout->addWidget(projectButton);
|
||||
|
||||
if (!processing)
|
||||
{
|
||||
connect(projectButton, &ProjectButton::OpenProject, this, &ProjectsScreen::HandleOpenProject);
|
||||
connect(projectButton, &ProjectButton::EditProject, this, &ProjectsScreen::HandleEditProject);
|
||||
connect(projectButton, &ProjectButton::CopyProject, this, &ProjectsScreen::HandleCopyProject);
|
||||
connect(projectButton, &ProjectButton::RemoveProject, this, &ProjectsScreen::HandleRemoveProject);
|
||||
connect(projectButton, &ProjectButton::DeleteProject, this, &ProjectsScreen::HandleDeleteProject);
|
||||
}
|
||||
connect(projectButton, &ProjectButton::OpenProject, this, &ProjectsScreen::HandleOpenProject);
|
||||
connect(projectButton, &ProjectButton::EditProject, this, &ProjectsScreen::HandleEditProject);
|
||||
connect(projectButton, &ProjectButton::CopyProject, this, &ProjectsScreen::HandleCopyProject);
|
||||
connect(projectButton, &ProjectButton::RemoveProject, this, &ProjectsScreen::HandleRemoveProject);
|
||||
connect(projectButton, &ProjectButton::DeleteProject, this, &ProjectsScreen::HandleDeleteProject);
|
||||
connect(projectButton, &ProjectButton::BuildProject, this, &ProjectsScreen::QueueBuildProject);
|
||||
|
||||
return projectButton;
|
||||
@@ -238,29 +181,128 @@ namespace O3DE::ProjectManager
|
||||
|
||||
void ProjectsScreen::ResetProjectsContent()
|
||||
{
|
||||
// refresh the projects content by re-creating it for now
|
||||
if (m_projectsContent)
|
||||
RemoveInvalidProjects();
|
||||
|
||||
// Get all projects and create a vertical scrolling list of them
|
||||
// Sort building and queued projects first
|
||||
auto projectsResult = PythonBindingsInterface::Get()->GetProjects();
|
||||
if (projectsResult.IsSuccess() && !projectsResult.GetValue().isEmpty())
|
||||
{
|
||||
m_stack->removeWidget(m_projectsContent);
|
||||
m_projectsContent->deleteLater();
|
||||
QVector<ProjectInfo> projectsVector = projectsResult.GetValue();
|
||||
// If a project path is in this set then the button for it will be kept
|
||||
QSet<QString> keepProject;
|
||||
for (const ProjectInfo& project : projectsVector)
|
||||
{
|
||||
keepProject.insert(project.m_path);
|
||||
}
|
||||
|
||||
// Clear flow and delete buttons for removed projects
|
||||
auto projectButtonsIter = m_projectButtons.begin();
|
||||
while (projectButtonsIter != m_projectButtons.end())
|
||||
{
|
||||
m_projectsFlowLayout->removeWidget(projectButtonsIter.value());
|
||||
|
||||
if (!keepProject.contains(projectButtonsIter.key()))
|
||||
{
|
||||
projectButtonsIter = m_projectButtons.erase(projectButtonsIter);
|
||||
}
|
||||
else
|
||||
{
|
||||
++projectButtonsIter;
|
||||
}
|
||||
}
|
||||
|
||||
QString buildProjectPath = "";
|
||||
if (m_currentBuilder)
|
||||
{
|
||||
buildProjectPath = m_currentBuilder->GetProjectInfo().m_path;
|
||||
}
|
||||
|
||||
// Put currently building project in front, then queued projects, then sorts alphabetically
|
||||
std::sort(projectsVector.begin(), projectsVector.end(), [buildProjectPath, this](const ProjectInfo& arg1, const ProjectInfo& arg2)
|
||||
{
|
||||
if (arg1.m_path == buildProjectPath)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (arg2.m_path == buildProjectPath)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool arg1InBuildQueue = BuildQueueContainsProject(arg1.m_path);
|
||||
bool arg2InBuildQueue = BuildQueueContainsProject(arg2.m_path);
|
||||
if (arg1InBuildQueue && !arg2InBuildQueue)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (!arg1InBuildQueue && arg2InBuildQueue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return arg1.m_displayName.toLower() < arg2.m_displayName.toLower();
|
||||
}
|
||||
});
|
||||
|
||||
// Add any missing project buttons and restore buttons to default state
|
||||
for (const ProjectInfo& project : projectsVector)
|
||||
{
|
||||
if (!m_projectButtons.contains(project.m_path))
|
||||
{
|
||||
m_projectButtons.insert(project.m_path, CreateProjectButton(project));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto projectButtonIter = m_projectButtons.find(project.m_path);
|
||||
if (projectButtonIter != m_projectButtons.end())
|
||||
{
|
||||
projectButtonIter.value()->RestoreDefaultState();
|
||||
m_projectsFlowLayout->addWidget(projectButtonIter.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Setup building button again
|
||||
auto buildProjectIter = m_projectButtons.find(buildProjectPath);
|
||||
if (buildProjectIter != m_projectButtons.end())
|
||||
{
|
||||
m_currentBuilder->SetProjectButton(buildProjectIter.value());
|
||||
}
|
||||
|
||||
for (const ProjectInfo& project : m_buildQueue)
|
||||
{
|
||||
auto projectIter = m_projectButtons.find(project.m_path);
|
||||
if (projectIter != m_projectButtons.end())
|
||||
{
|
||||
projectIter.value()->SetProjectButtonAction(
|
||||
tr("Cancel Queued Build"),
|
||||
[this, project]
|
||||
{
|
||||
UnqueueBuildProject(project);
|
||||
SuggestBuildProjectMsg(project, false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (const ProjectInfo& project : m_requiresBuild)
|
||||
{
|
||||
auto projectIter = m_projectButtons.find(project.m_path);
|
||||
if (projectIter != m_projectButtons.end())
|
||||
{
|
||||
if (project.m_buildFailed)
|
||||
{
|
||||
projectIter.value()->ShowBuildFailed(true, project.m_logUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
projectIter.value()->SetProjectBuildButtonAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_background.load(":/Backgrounds/DefaultBackground.jpg");
|
||||
|
||||
// Make sure to update builder with latest Project Button
|
||||
if (m_currentBuilder)
|
||||
{
|
||||
ProjectButton* projectButtonPtr = nullptr;
|
||||
|
||||
m_projectsContent = CreateProjectsContent(m_currentBuilder->GetProjectInfo().m_path, &projectButtonPtr);
|
||||
m_currentBuilder->SetProjectButton(projectButtonPtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_projectsContent = CreateProjectsContent();
|
||||
}
|
||||
|
||||
m_stack->addWidget(m_projectsContent);
|
||||
m_stack->setCurrentWidget(m_projectsContent);
|
||||
}
|
||||
|
||||
@@ -466,7 +508,7 @@ namespace O3DE::ProjectManager
|
||||
if (m_buildQueue.empty() && !m_currentBuilder)
|
||||
{
|
||||
StartProjectBuild(projectInfo);
|
||||
// Projects Content is already reset in fuction
|
||||
// Projects Content is already reset in function
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -491,6 +533,7 @@ namespace O3DE::ProjectManager
|
||||
}
|
||||
else
|
||||
{
|
||||
m_background.load(":/Backgrounds/DefaultBackground.jpg");
|
||||
ResetProjectsContent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ QT_FORWARD_DECLARE_CLASS(QPaintEvent)
|
||||
QT_FORWARD_DECLARE_CLASS(QFrame)
|
||||
QT_FORWARD_DECLARE_CLASS(QStackedWidget)
|
||||
QT_FORWARD_DECLARE_CLASS(QLayout)
|
||||
QT_FORWARD_DECLARE_CLASS(FlowLayout)
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
@@ -59,8 +60,8 @@ namespace O3DE::ProjectManager
|
||||
|
||||
private:
|
||||
QFrame* CreateFirstTimeContent();
|
||||
QFrame* CreateProjectsContent(QString buildProjectPath = "", ProjectButton** projectButton = nullptr);
|
||||
ProjectButton* CreateProjectButton(ProjectInfo& project, QLayout* flowLayout, bool processing = false);
|
||||
QFrame* CreateProjectsContent();
|
||||
ProjectButton* CreateProjectButton(const ProjectInfo& project);
|
||||
void ResetProjectsContent();
|
||||
bool ShouldDisplayFirstTimeContent();
|
||||
bool RemoveInvalidProjects();
|
||||
@@ -75,7 +76,9 @@ namespace O3DE::ProjectManager
|
||||
QPixmap m_background;
|
||||
QFrame* m_firstTimeContent = nullptr;
|
||||
QFrame* m_projectsContent = nullptr;
|
||||
FlowLayout* m_projectsFlowLayout = nullptr;
|
||||
QStackedWidget* m_stack = nullptr;
|
||||
QHash<QString, ProjectButton*> m_projectButtons;
|
||||
QList<ProjectInfo> m_requiresBuild;
|
||||
QQueue<ProjectInfo> m_buildQueue;
|
||||
ProjectBuilderController* m_currentBuilder = nullptr;
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace O3DE::ProjectManager
|
||||
|
||||
// add a tab widget at the bottom of the stack
|
||||
m_tabWidget = new QTabWidget();
|
||||
m_tabWidget->tabBar()->setFocusPolicy(Qt::TabFocus);
|
||||
m_screenStack->addWidget(m_tabWidget);
|
||||
connect(m_tabWidget, &QTabWidget::currentChanged, this, &ScreensCtrl::TabChanged);
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace O3DE::ProjectManager
|
||||
QTabWidget* tabWidget = new QTabWidget();
|
||||
tabWidget->setObjectName("projectSettingsTab");
|
||||
tabWidget->tabBar()->setObjectName("projectSettingsTabBar");
|
||||
tabWidget->tabBar()->setFocusPolicy(Qt::TabFocus);
|
||||
tabWidget->addTab(m_updateSettingsScreen, tr("General"));
|
||||
|
||||
QPushButton* gemsButton = new QPushButton(tr("Configure Gems"), this);
|
||||
|
||||
@@ -24,7 +24,12 @@ namespace AZ
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
virtual void ReportJobDependencies(JobDependencyList& jobDependencyList, const char* platformIdentifier) = 0;
|
||||
//! Builders can implement this function to add job dependencies on other assets that may be used in the scene file conversion process.
|
||||
virtual void ReportJobDependencies(JobDependencyList& jobDependencyList, const char* platformIdentifier) { AZ_UNUSED(jobDependencyList); AZ_UNUSED(platformIdentifier); }
|
||||
|
||||
//! Builders can implement this function to append to the job analysis fingerprint. This can be used to trigger rebuilds when global configuration changes.
|
||||
//! See also AssetBuilderDesc::m_analysisFingerprint.
|
||||
virtual void AddFingerprintInfo(AZStd::set<AZStd::string>& fingerprintInfo) { AZ_UNUSED(fingerprintInfo); }
|
||||
};
|
||||
using SceneBuilderDependencyBus = EBus<SceneBuilderDependencyRequests>;
|
||||
} // namespace SceneAPI
|
||||
|
||||
Reference in New Issue
Block a user