Integrating latest 47acbe8
This commit is contained in:
@@ -57,11 +57,13 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
ly_add_target(
|
||||
NAME ScriptCanvasDeveloper.Editor MODULE
|
||||
NAMESPACE Gem
|
||||
AUTOMOC
|
||||
OUTPUT_NAME Gem.ScriptCanvasDeveloperGem.Editor.f905c05883b94fd6bddc91052c3c5a86.v0.1.0
|
||||
FILES_CMAKE
|
||||
scriptcanvasdeveloper_gem_editor_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
.
|
||||
Source
|
||||
Editor/Include
|
||||
Editor/Source
|
||||
@@ -75,7 +77,7 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
AZ::AzFramework
|
||||
AZ::AzToolsFramework
|
||||
Gem::ScriptCanvasDeveloper.Static
|
||||
Gem::ScriptCanvasGem.Editor.Static
|
||||
Gem::ScriptCanvas.Editor.Static
|
||||
Gem::GraphCanvasWidgets
|
||||
)
|
||||
endif()
|
||||
|
||||
+2
-2
@@ -12,12 +12,12 @@
|
||||
#pragma once
|
||||
|
||||
class QAction;
|
||||
class QWidget;
|
||||
class QMenu;
|
||||
|
||||
namespace ScriptCanvasDeveloperEditor
|
||||
{
|
||||
namespace DynamicSlotFullCreation
|
||||
{
|
||||
QAction* CreateDynamicSlotFullCreationAction(QWidget* mainWindow);
|
||||
QAction* CreateDynamicSlotFullCreationAction(QMenu* mainWindow);
|
||||
};
|
||||
}
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
class QAction;
|
||||
class QMenu;
|
||||
|
||||
namespace ScriptCanvasDeveloperEditor
|
||||
{
|
||||
namespace NodePaletteFullCreation
|
||||
{
|
||||
QAction* FullyConnectedNodePaletteCreation(QMenu* mainWindow);
|
||||
};
|
||||
}
|
||||
+2
-2
@@ -12,12 +12,12 @@
|
||||
#pragma once
|
||||
|
||||
class QAction;
|
||||
class QWidget;
|
||||
class QMenu;
|
||||
|
||||
namespace ScriptCanvasDeveloperEditor
|
||||
{
|
||||
namespace NodePaletteFullCreation
|
||||
{
|
||||
QAction* CreateNodePaletteFullCreationAction(QWidget* mainWindow);
|
||||
QAction* CreateNodePaletteFullCreationAction(QMenu* mainWindow);
|
||||
};
|
||||
}
|
||||
|
||||
+2
-2
@@ -12,12 +12,12 @@
|
||||
#pragma once
|
||||
|
||||
class QAction;
|
||||
class QWidget;
|
||||
class QMenu;
|
||||
|
||||
namespace ScriptCanvasDeveloperEditor
|
||||
{
|
||||
namespace VariablePaletteFullCreation
|
||||
{
|
||||
QAction* CreateVariablePaletteFullCreationAction(QWidget* mainWindow);
|
||||
QAction* CreateVariablePaletteFullCreationAction(QMenu* mainWindow);
|
||||
};
|
||||
}
|
||||
|
||||
+21
-1
@@ -13,8 +13,11 @@
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <GraphCanvas/Types/Endpoint.h>
|
||||
#include <GraphCanvas/Widgets/NodePalette/TreeItems/NodePaletteTreeItem.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/NodeIdPair.h>
|
||||
#include <ScriptCanvas/Core/Endpoint.h>
|
||||
#include <ScriptCanvas/Data/Data.h>
|
||||
|
||||
namespace ScriptCanvasDeveloperEditor
|
||||
@@ -23,6 +26,7 @@ namespace ScriptCanvasDeveloperEditor
|
||||
{
|
||||
public:
|
||||
virtual void SetupInterface(const AZ::EntityId& activeGraphCanvasGraphId, const ScriptCanvas::ScriptCanvasId& activeScriptCanvasId) = 0;
|
||||
virtual void OnProcessingComplete() {};
|
||||
};
|
||||
|
||||
class ProcessNodePaletteInterface
|
||||
@@ -40,13 +44,29 @@ namespace ScriptCanvasDeveloperEditor
|
||||
virtual bool ShouldProcessVariableType(const ScriptCanvas::Data::Type& dataType) const = 0;
|
||||
virtual void ProcessVariableType(const ScriptCanvas::Data::Type& dataType) = 0;
|
||||
};
|
||||
|
||||
|
||||
class DeveloperUtils
|
||||
{
|
||||
public:
|
||||
enum ConnectionStyle
|
||||
{
|
||||
NoConnections,
|
||||
SingleExecutionConnection
|
||||
};
|
||||
|
||||
struct CreateConnectedChainConfig
|
||||
{
|
||||
bool m_skipHandlers = false;
|
||||
ConnectionStyle m_connectionStyle = ConnectionStyle::NoConnections;
|
||||
|
||||
ScriptCanvasEditor::NodeIdPair m_fallbackNode;
|
||||
GraphCanvas::Endpoint m_previousEndpoint;
|
||||
};
|
||||
|
||||
static ScriptCanvasEditor::NodeIdPair HandleMimeEvent(GraphCanvas::GraphCanvasMimeEvent* mimeEvent, GraphCanvas::GraphId graphCanvasGraphId, const QRectF& viewportRectangle, int& widthOffset, int& heightOffset, int& maxRowHeight, AZ::Vector2 spacing);
|
||||
|
||||
static void UpdateViewportPositionOffsetForNode(GraphCanvas::NodeId nodeId, const QRectF& viewportRectangle, int& widthOffset, int& heightOffset, int& maxRowHeight, AZ::Vector2 spacing);
|
||||
static bool CreateConnectedChain(const ScriptCanvasEditor::NodeIdPair& nodeIdPair, CreateConnectedChainConfig& connectionConfig);
|
||||
|
||||
static void ProcessNodePalette(ProcessNodePaletteInterface& processNodePaletteInterface);
|
||||
static void ProcessVariablePalette(ProcessVariablePaletteInterface& processVariablePaletteInterface);
|
||||
|
||||
+71
@@ -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.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QWindow>
|
||||
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/RTTI/RTTI.h>
|
||||
|
||||
#include <AzCore/Outcome/Outcome.h>
|
||||
|
||||
class QMainWindow;
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
typedef AZ::Outcome<void, AZStd::string> ActionReport;
|
||||
|
||||
/**
|
||||
EditorAutomationAction is the base class that all other actions will inherit from. Exposes a setup, and a tick function which returns whether or not the action is complete.
|
||||
*/
|
||||
class EditorAutomationAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(EditorAutomationAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(EditorAutomationAction, "{133E2ECE-5829-432F-BA37-60C75C5CCC34}")
|
||||
|
||||
EditorAutomationAction() = default;
|
||||
virtual ~EditorAutomationAction() = default;
|
||||
|
||||
bool IsAtPreconditionLimit() const { return m_preconditionAttempts >= 10; }
|
||||
|
||||
virtual bool IsMissingPrecondition() { return false; }
|
||||
|
||||
void ResetPreconditionAttempts() { m_preconditionAttempts = 0; }
|
||||
|
||||
EditorAutomationAction* GenerationPreconditionActions()
|
||||
{
|
||||
++m_preconditionAttempts;
|
||||
return GenerateMissingPreconditionAction();
|
||||
}
|
||||
|
||||
void SignalActionBegin()
|
||||
{
|
||||
ResetPreconditionAttempts();
|
||||
SetupAction();
|
||||
}
|
||||
|
||||
virtual bool Tick() = 0;
|
||||
|
||||
virtual ActionReport GenerateReport() const { return AZ::Success(); }
|
||||
|
||||
protected:
|
||||
|
||||
virtual EditorAutomationAction* GenerateMissingPreconditionAction() { return nullptr; }
|
||||
virtual void SetupAction() {}
|
||||
|
||||
private:
|
||||
|
||||
int m_preconditionAttempts = 0;
|
||||
};
|
||||
}
|
||||
+109
@@ -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/PlatformIncl.h>
|
||||
|
||||
#include <QPoint>
|
||||
#include <QKeySequence>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationAction.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/GenericActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorAutomationAction that will simulate a key action(press or release) for the specified key
|
||||
*/
|
||||
class SimulateKeyAction
|
||||
: public EditorAutomationAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(SimulateKeyAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(SimulateKeyAction, "{07259AB5-E5B1-4A4E-8966-610CA3E5F5E3}", EditorAutomationAction);
|
||||
|
||||
enum class KeyAction
|
||||
{
|
||||
Press,
|
||||
Release
|
||||
};
|
||||
|
||||
SimulateKeyAction(KeyAction keyAction, AZ::u32 keyValue = 0);
|
||||
~SimulateKeyAction() override = default;
|
||||
|
||||
bool Tick() override;
|
||||
|
||||
private:
|
||||
|
||||
AZ::u32 m_keyValue;
|
||||
KeyAction m_keyAction;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will simulate a press action for the specified key
|
||||
*/
|
||||
class KeyPressAction
|
||||
: public SimulateKeyAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(KeyPressAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(KeyPressAction, "{20F93C69-993C-4658-974B-06F1EE9AFBAC}", SimulateKeyAction);
|
||||
|
||||
explicit KeyPressAction(AZ::u32 keyValue = 0)
|
||||
: SimulateKeyAction(SimulateKeyAction::KeyAction::Press, keyValue)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will simulate a release action for the specified key
|
||||
*/
|
||||
class KeyReleaseAction
|
||||
: public SimulateKeyAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(KeyReleaseAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(KeyReleaseAction, "{B4000C12-03F9-4AC1-B1BA-88D8B7FC4CB1}", SimulateKeyAction);
|
||||
|
||||
explicit KeyReleaseAction(AZ::u32 keyValue = 0)
|
||||
: SimulateKeyAction(SimulateKeyAction::KeyAction::Release, keyValue)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will simulate a press and a release action for the specified key(currently limited support for QChar to a-z,0-9, *, (, and ) )
|
||||
*/
|
||||
class TypeCharAction
|
||||
: public CompoundAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(TypeCharAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(TypeCharAction, "{67FBD994-18BB-4434-AD8E-70F446A9B185}", CompoundAction);
|
||||
|
||||
explicit TypeCharAction(QChar qChar);
|
||||
explicit TypeCharAction(AZ::u32 key);
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will simulate a user typing in the specified string.
|
||||
*/
|
||||
class TypeStringAction
|
||||
: public CompoundAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(TypeStringAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(TypeStringAction, "{51D701B1-6386-420C-A1BD-D72272BBBBD5}", CompoundAction);
|
||||
|
||||
explicit TypeStringAction(QString targetString);
|
||||
};
|
||||
}
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* 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 <QPoint>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationAction.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/GenericActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorAutomationAction that will simulate a user pressing or releasing a mouse button
|
||||
*/
|
||||
class SimulateMouseButtonAction
|
||||
: public EditorAutomationAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(SimulateMouseButtonAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(SimulateMouseButtonAction, "{89D4E6F5-983C-4877-9A32-0929F7D2BB8E}", EditorAutomationAction);
|
||||
|
||||
enum class MouseAction
|
||||
{
|
||||
Press,
|
||||
Release
|
||||
};
|
||||
|
||||
SimulateMouseButtonAction(MouseAction mouseAction, Qt::MouseButton mouseButton = Qt::LeftButton);
|
||||
|
||||
void SetTarget(QWidget* targetDispatch);
|
||||
|
||||
bool Tick() override;
|
||||
|
||||
private:
|
||||
|
||||
QWidget* m_targetDispatch = nullptr;
|
||||
|
||||
MouseAction m_mouseAction;
|
||||
Qt::MouseButton m_mouseButton = Qt::LeftButton;
|
||||
Qt::KeyboardModifiers m_keyboardModifiers = Qt::NoModifier;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will simulate a user pressing a mouse button
|
||||
*/
|
||||
class PressMouseButtonAction
|
||||
: public SimulateMouseButtonAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(PressMouseButtonAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(PressMouseButtonAction, "{DA89D548-3506-4DB1-BCCF-6C03ABD75FFB}", SimulateMouseButtonAction);
|
||||
|
||||
PressMouseButtonAction(Qt::MouseButton mouseButton = Qt::LeftButton)
|
||||
: SimulateMouseButtonAction(SimulateMouseButtonAction::MouseAction::Press, mouseButton)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will simulate a user releasing a mouse button
|
||||
*/
|
||||
class ReleaseMouseButtonAction
|
||||
: public SimulateMouseButtonAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(ReleaseMouseButtonAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(ReleaseMouseButtonAction, "{448D4A65-5BF8-4643-AE31-E979F176C3AF}", SimulateMouseButtonAction);
|
||||
|
||||
ReleaseMouseButtonAction(Qt::MouseButton mouseButton = Qt::LeftButton)
|
||||
: SimulateMouseButtonAction(SimulateMouseButtonAction::MouseAction::Release, mouseButton)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will simulate a user clicking a mouse button. Can take in a point to click on.
|
||||
*/
|
||||
class MouseClickAction
|
||||
: public CompoundAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(MouseClickAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(MouseClickAction, "{AEA337E8-0B2F-443B-AFFB-5688CB996D8E}", CompoundAction);
|
||||
|
||||
MouseClickAction(Qt::MouseButton mouseButton);
|
||||
MouseClickAction(Qt::MouseButton mouseButton, QPoint cursorPosition);
|
||||
~MouseClickAction() override = default;
|
||||
|
||||
bool IsMissingPrecondition() override;
|
||||
EditorAutomationAction* GenerateMissingPreconditionAction() override;
|
||||
|
||||
protected:
|
||||
|
||||
void PopulateActionQueue();
|
||||
|
||||
private:
|
||||
|
||||
Qt::MouseButton m_mouseButton;
|
||||
Qt::KeyboardModifiers m_keyboardModifiers = Qt::NoModifier;
|
||||
|
||||
bool m_hasFixedTarget;
|
||||
QPoint m_cursorPosition;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will simulate a user moving their mouse to the specified point
|
||||
*/
|
||||
class MouseMoveAction
|
||||
: public EditorAutomationAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(MouseMoveAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(MouseMoveAction, "{AEA337E8-0B2F-443B-AFFB-5688CB996D8E}", EditorAutomationAction);
|
||||
|
||||
MouseMoveAction(QPoint targetPosition, int ticks = 20);
|
||||
~MouseMoveAction() override = default;
|
||||
|
||||
void SetupAction() override;
|
||||
bool Tick() override;
|
||||
|
||||
private:
|
||||
|
||||
int m_tickDuration = 0;
|
||||
int m_tickCount = 0;
|
||||
|
||||
bool m_hasStartPosition = false;
|
||||
QPoint m_startPosition;
|
||||
QPoint m_targetPosition;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will simulate a user draging the mouse between the specified points, using the specified button.
|
||||
*/
|
||||
class MouseDragAction
|
||||
: public CompoundAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(MouseDragAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(MouseDragAction, "{0B704B80-1BCB-4396-99A6-C5CAC462A7DB}", CompoundAction);
|
||||
|
||||
MouseDragAction(QPoint startPosition, QPoint endPosition, Qt::MouseButton holdButton = Qt::MouseButton::LeftButton);
|
||||
|
||||
private:
|
||||
|
||||
Qt::MouseButton m_holdButton;
|
||||
|
||||
QPoint m_startPosition;
|
||||
QPoint m_endPosition;
|
||||
};
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* 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 <QPoint>
|
||||
#include <QWidget>
|
||||
|
||||
#include <GraphCanvas/Types/Endpoint.h>
|
||||
#include <GraphCanvas/Types/Types.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationAction.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorAutomationAction that will be composed of a series EditorAutomationActions that will be executed in order.
|
||||
The CompoundAction will take ownership of the actions added to it.
|
||||
*/
|
||||
class CompoundAction
|
||||
: public EditorAutomationAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(CompoundAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(CompoundAction, "{3F9A5736-111C-4D49-A3D5-BA3484D74F4D}", EditorAutomationAction);
|
||||
|
||||
CompoundAction();
|
||||
~CompoundAction() override;
|
||||
|
||||
void SetupAction() override;
|
||||
bool Tick() override;
|
||||
|
||||
void AddAction(EditorAutomationAction* action);
|
||||
|
||||
ActionReport GenerateReport() const override;
|
||||
|
||||
protected:
|
||||
|
||||
void ClearActionQueue();
|
||||
|
||||
virtual void OnActionsComplete() {}
|
||||
|
||||
private:
|
||||
|
||||
AZStd::vector< ActionReport > m_errorReports;
|
||||
AZStd::vector< EditorAutomationAction* > m_actionQueue;
|
||||
|
||||
EditorAutomationActionRunner m_actionRunner;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will delay for the specified time
|
||||
*/
|
||||
class DelayAction
|
||||
: public EditorAutomationAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(DelayAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(DelayAction, "{44927F65-58DF-4142-8C04-6EC7A10050FB}", EditorAutomationAction);
|
||||
|
||||
DelayAction(AZStd::chrono::milliseconds delayTime = AZStd::chrono::milliseconds(250));
|
||||
|
||||
void SetupAction() override;
|
||||
bool Tick() override;
|
||||
|
||||
private:
|
||||
|
||||
AZStd::chrono::time_point<AZStd::chrono::system_clock> m_startPoint;
|
||||
|
||||
AZStd::chrono::milliseconds m_delay;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will delay so the OS can process the faked events, then pump the Qt application to process the events.
|
||||
*/
|
||||
class ProcessUserEventsAction
|
||||
: public DelayAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(ProcessUserEventsAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(ProcessUserEventsAction, "{CB6D47D6-2E63-4277-BCD0-F9014D74CC48}", DelayAction);
|
||||
|
||||
ProcessUserEventsAction(AZStd::chrono::milliseconds delayTime = AZStd::chrono::milliseconds(250));
|
||||
|
||||
void SetupAction() override;
|
||||
|
||||
bool Tick() override;
|
||||
private:
|
||||
|
||||
bool m_delayComplete = false;
|
||||
bool m_processingComplete = false;
|
||||
AZStd::atomic<bool> m_processingEventsSwitch = false;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will print out the specified string during execution
|
||||
*/
|
||||
class TraceEvent
|
||||
: public EditorAutomationAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(TraceEvent, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(TraceEvent, "{A2C0B4B1-9FD7-4441-86EB-B63C8DDD2C97}", EditorAutomationAction);
|
||||
|
||||
TraceEvent(AZStd::string traceName);
|
||||
|
||||
bool Tick() override;
|
||||
|
||||
private:
|
||||
|
||||
AZStd::string m_traceName;
|
||||
};
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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 <GraphCanvas/Types/Endpoint.h>
|
||||
#include <GraphCanvas/Types/Types.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/GenericActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorAutomationAction that will couple the two specified nodes together. The ordering of the coupling is decided by the specified connection type from the perspective of the 'nodeToPickUp'
|
||||
*/
|
||||
class CoupleNodesAction
|
||||
: public CompoundAction
|
||||
, public GraphCanvas::SceneNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(CoupleNodesAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(CoupleNodesAction, "{DC6B3198-E127-4833-BC44-B27083A36045}", CompoundAction);
|
||||
|
||||
CoupleNodesAction(GraphCanvas::NodeId nodeToPickUp, GraphCanvas::ConnectionType connectionType, GraphCanvas::NodeId coupleTarget);
|
||||
|
||||
bool IsMissingPrecondition() override;
|
||||
EditorAutomationAction* GenerateMissingPreconditionAction() override;
|
||||
|
||||
AZStd::vector< GraphCanvas::ConnectionId > GetConnectionIds() const;
|
||||
|
||||
// GraphCanvas::SceneNotificaionBus
|
||||
void OnConnectionAdded(const AZ::EntityId& connectionId) override;
|
||||
////
|
||||
|
||||
protected:
|
||||
|
||||
void SetupAction() override;
|
||||
|
||||
void OnActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
QRectF m_sceneRect;
|
||||
|
||||
QRectF m_pickUpRect;
|
||||
QRectF m_targetRect;
|
||||
|
||||
GraphCanvas::NodeId m_nodeToPickUp;
|
||||
|
||||
GraphCanvas::ConnectionType m_connectionType;
|
||||
|
||||
GraphCanvas::NodeId m_targetNode;
|
||||
|
||||
AZStd::vector< GraphCanvas::ConnectionId > m_connections;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will attempt to create a connection between the two specified endpoints
|
||||
*/
|
||||
class ConnectEndpointsAction
|
||||
: public CompoundAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(ConnectEndpointsAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(ConnectEndpointsAction, "{94941CCD-D8FA-4B01-8876-5D32723BD0C2}", CompoundAction);
|
||||
|
||||
ConnectEndpointsAction(GraphCanvas::Endpoint startEndpoint, GraphCanvas::Endpoint targetEndpoint);
|
||||
|
||||
GraphCanvas::ConnectionId GetConnectionId() const;
|
||||
|
||||
protected:
|
||||
|
||||
void OnActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
QRectF m_sceneRect;
|
||||
|
||||
GraphCanvas::ConnectionId m_connectionId;
|
||||
|
||||
GraphCanvas::Endpoint m_startEndpoint;
|
||||
GraphCanvas::Endpoint m_targetEndpoint;
|
||||
};
|
||||
}
|
||||
+254
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
* 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 <GraphCanvas/Types/Endpoint.h>
|
||||
#include <GraphCanvas/Types/Types.h>
|
||||
#include <GraphCanvas/Widgets/NodePalette/NodePaletteWidget.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationModelIds.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/GenericActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorAutomationAction that will create the specified node from the NodePalette at the specified scene point
|
||||
*/
|
||||
class CreateNodeFromPaletteAction
|
||||
: public CompoundAction
|
||||
, public GraphCanvas::SceneNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(CreateNodeFromPaletteAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(CreateNodeFromPaletteAction, "{5711220C-48D6-4853-87B9-A9866B82DFCD}", CompoundAction);
|
||||
|
||||
CreateNodeFromPaletteAction(GraphCanvas::NodePaletteWidget* paletteWidget, GraphCanvas::GraphId graphId, QString nodeName, QPointF scenePoint);
|
||||
CreateNodeFromPaletteAction(GraphCanvas::NodePaletteWidget* paletteWidget, GraphCanvas::GraphId graphId, QString nodeName, GraphCanvas::ConnectionId connectionId);
|
||||
|
||||
bool IsMissingPrecondition() override;
|
||||
EditorAutomationAction* GenerateMissingPreconditionAction() override;
|
||||
|
||||
void SetupAction() override;
|
||||
|
||||
GraphCanvas::NodeId GetCreatedNodeId() const;
|
||||
|
||||
// GraphCanvas::SceneNotificationBus::Handler
|
||||
void OnNodeAdded(const AZ::EntityId& nodeId, bool isPaste) override;
|
||||
////
|
||||
|
||||
ActionReport GenerateReport() const override;
|
||||
|
||||
protected:
|
||||
|
||||
void OnActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
GraphCanvas::ConnectionId m_spliceTarget;
|
||||
GraphCanvas::Endpoint m_sourceEndpoint;
|
||||
GraphCanvas::Endpoint m_targetEndpoint;
|
||||
|
||||
GraphCanvas::GraphId m_graphId;
|
||||
QPointF m_scenePoint;
|
||||
QString m_nodeName;
|
||||
|
||||
GraphCanvas::NodePaletteWidget* m_paletteWidget;
|
||||
|
||||
GraphCanvas::NodeId m_createdNodeId;
|
||||
|
||||
bool m_centerOnScene = false;
|
||||
bool m_writeToSearchFilter = false;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will create all nodes under the specified category from the NodePalette at the specified scene point
|
||||
*/
|
||||
class CreateCategoryFromNodePaletteAction
|
||||
: public CompoundAction
|
||||
, public GraphCanvas::SceneNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(CreateCategoryFromNodePaletteAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(CreateCategoryFromNodePaletteAction, "{FA073F04-5DE2-4124-9BAB-7507FFD046CD}", CompoundAction);
|
||||
|
||||
CreateCategoryFromNodePaletteAction(GraphCanvas::NodePaletteWidget* nodePalette, GraphCanvas::GraphId graphId, QString category, QPointF scenePoint);
|
||||
~CreateCategoryFromNodePaletteAction() override = default;
|
||||
|
||||
bool IsMissingPrecondition() override;
|
||||
EditorAutomationAction* GenerateMissingPreconditionAction() override;
|
||||
|
||||
void SetupAction() override;
|
||||
|
||||
// GraphCanvas::SceneNotificationBus::Handler
|
||||
void OnNodeAdded(const AZ::EntityId& nodeId, bool isPaste) override;
|
||||
////
|
||||
|
||||
AZStd::vector< GraphCanvas::NodeId > GetCreatedNodes() const;
|
||||
|
||||
ActionReport GenerateReport() const override;
|
||||
|
||||
protected:
|
||||
|
||||
void OnActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
GraphCanvas::GraphId m_graphId;
|
||||
QPointF m_scenePoint;
|
||||
|
||||
QString m_categoryName;
|
||||
|
||||
GraphCanvas::NodePaletteWidget* m_paletteWidget;
|
||||
|
||||
int m_expectedCreations = 0;
|
||||
AZStd::vector< GraphCanvas::NodeId > m_createdNodeIds;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will create the specified node at the specified point using the context menu.
|
||||
Can specify a ConnectionId instead of a scene point to use the context menu to splice a node onto the given connection as well
|
||||
*/
|
||||
class CreateNodeFromContextMenuAction
|
||||
: public CompoundAction
|
||||
, public GraphCanvas::SceneNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(CreateNodeFromContextMenuAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(CreateNodeFromContextMenuAction, "{0318F9D3-6433-400F-9E29-41B57A8ADB32}", CompoundAction);
|
||||
|
||||
CreateNodeFromContextMenuAction(GraphCanvas::GraphId graphId, QString nodeName, QPointF scenePoint);
|
||||
CreateNodeFromContextMenuAction(GraphCanvas::GraphId graphId, QString nodeName, AZ::EntityId connectionId);
|
||||
|
||||
bool IsMissingPrecondition() override;
|
||||
EditorAutomationAction* GenerateMissingPreconditionAction() override;
|
||||
|
||||
void SetupAction() override;
|
||||
|
||||
// GraphCanvas::SceneNotificationBus::Handler
|
||||
void OnNodeAdded(const AZ::EntityId& nodeId, bool isPaste) override;
|
||||
////
|
||||
|
||||
AZ::EntityId GetCreatedNodeId() const;
|
||||
|
||||
ActionReport GenerateReport() const override;
|
||||
|
||||
protected:
|
||||
|
||||
void OnActionsComplete();
|
||||
|
||||
private:
|
||||
|
||||
AZ::EntityId m_spliceTarget;
|
||||
GraphCanvas::Endpoint m_sourceEndpoint;
|
||||
GraphCanvas::Endpoint m_targetEndpoint;
|
||||
|
||||
GraphCanvas::GraphId m_graphId;
|
||||
QPointF m_scenePoint;
|
||||
QString m_nodeName;
|
||||
|
||||
GraphCanvas::NodeId m_createdNodeId;
|
||||
|
||||
bool m_centerOnScene = false;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will create the specified node at the specified point by dragging a connection from the specified endpoint.
|
||||
Will place the new node at a 'reasonable' distance from the specified endpoint, or at the specified point.
|
||||
*/
|
||||
class CreateNodeFromProposalAction
|
||||
: public CompoundAction
|
||||
, public GraphCanvas::SceneNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(CreateNodeFromProposalAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(CreateNodeFromProposalAction, "{236A56E5-73A8-42B0-9239-77670DD4EA44}", CompoundAction);
|
||||
|
||||
CreateNodeFromProposalAction(GraphCanvas::GraphId graphId, GraphCanvas::Endpoint endpoint, QString nodeName);
|
||||
CreateNodeFromProposalAction(GraphCanvas::GraphId graphId, GraphCanvas::Endpoint endpoint, QString nodeName, QPointF scenePoint);
|
||||
|
||||
bool IsMissingPrecondition() override;
|
||||
EditorAutomationAction* GenerateMissingPreconditionAction() override;
|
||||
|
||||
void SetupAction() override;
|
||||
|
||||
// GraphCanvas::SceneNotificationBus::Handler
|
||||
void OnNodeAdded(const AZ::EntityId& nodeId, bool isPaste) override;
|
||||
////
|
||||
|
||||
AZ::EntityId GetCreatedNodeId() const;
|
||||
AZ::EntityId GetConnectionId() const;
|
||||
|
||||
ActionReport GenerateReport() const override;
|
||||
|
||||
protected:
|
||||
|
||||
void OnActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
GraphCanvas::GraphId m_graphId;
|
||||
|
||||
GraphCanvas::Endpoint m_endpoint;
|
||||
|
||||
QPointF m_scenePoint;
|
||||
QString m_nodeName;
|
||||
|
||||
GraphCanvas::NodeId m_createdNodeId;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will create a group using the specified creation type[Hotkey action or toolbar click]
|
||||
*/
|
||||
class CreateGroupAction
|
||||
: public CompoundAction
|
||||
, public GraphCanvas::SceneNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
|
||||
enum class CreationType
|
||||
{
|
||||
Toolbar,
|
||||
Hotkey
|
||||
};
|
||||
|
||||
AZ_CLASS_ALLOCATOR(CreateGroupAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(CreateGroupAction, "{853F34EB-F8AB-47E3-A601-35091DC23E11}", CompoundAction);
|
||||
|
||||
CreateGroupAction(GraphCanvas::EditorId editorGraph, GraphCanvas::GraphId graphId, CreationType creationType = CreationType::Hotkey);
|
||||
~CreateGroupAction() override = default;
|
||||
|
||||
void SetupAction();
|
||||
|
||||
// GraphCanvas::SceneNotificationBus::Handler
|
||||
void OnNodeAdded(const AZ::EntityId& groupId, bool isPaste = false) override;
|
||||
////
|
||||
|
||||
AZ::EntityId GetCreatedGroupId() const;
|
||||
ActionReport GenerateReport() const override;
|
||||
|
||||
protected:
|
||||
|
||||
void SetupToolbarAction();
|
||||
void SetupHotkeyAction();
|
||||
|
||||
void OnActionsComplete();
|
||||
|
||||
private:
|
||||
|
||||
GraphCanvas::EditorId m_editorId;
|
||||
GraphCanvas::GraphId m_graphId;
|
||||
|
||||
CreationType m_creationType = CreationType::Hotkey;
|
||||
|
||||
AZ::EntityId m_createdGroup;
|
||||
};
|
||||
}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* 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 <GraphCanvas/Types/Types.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/GenericActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorAutomationAction that will center the specified graph onto the specified point
|
||||
*/
|
||||
class CenterOnScenePointAction
|
||||
: public EditorAutomationAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(CenterOnScenePointAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(CenterOnScenePointAction, "{527B3EE0-258F-4D0C-8642-6923D81A9C40}", EditorAutomationAction);
|
||||
|
||||
CenterOnScenePointAction(GraphCanvas::GraphId graphId, QPointF scenePoint);
|
||||
~CenterOnScenePointAction() override = default;
|
||||
|
||||
bool Tick() override;
|
||||
|
||||
private:
|
||||
|
||||
GraphCanvas::GraphId m_graphId;
|
||||
QPointF m_scenePoint;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will ensure that the given rect is visible inside of the specified graph
|
||||
*/
|
||||
class EnsureSceneRectVisibleAction
|
||||
: public DelayAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(EnsureSceneRectVisibleAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(EnsureSceneRectVisibleAction, "{BF412F21-62F1-48AA-891E-266C986820FA}", DelayAction);
|
||||
|
||||
EnsureSceneRectVisibleAction(GraphCanvas::GraphId graphId, QRectF sceneRect);
|
||||
~EnsureSceneRectVisibleAction() override = default;
|
||||
|
||||
void SetupAction() override;
|
||||
bool Tick() override;
|
||||
|
||||
private:
|
||||
|
||||
bool m_firstTick = false;
|
||||
|
||||
GraphCanvas::GraphId m_graphId;
|
||||
QRectF m_sceneRect;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will move the mouse to the specified point in the scene.
|
||||
*/
|
||||
class SceneMouseMoveAction
|
||||
: public CompoundAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(SceneMouseMoveAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(SceneMouseMoveAction, "{A26D0034-0682-4F61-9425-EF659D1ABAD0}", CompoundAction);
|
||||
|
||||
SceneMouseMoveAction(GraphCanvas::GraphId graphId, QPointF scenePoint);
|
||||
~SceneMouseMoveAction() override = default;
|
||||
|
||||
bool IsMissingPrecondition() override;
|
||||
EditorAutomationAction* GenerateMissingPreconditionAction() override;
|
||||
|
||||
void SetupAction() override;
|
||||
|
||||
private:
|
||||
|
||||
GraphCanvas::GraphId m_graphId;
|
||||
GraphCanvas::ViewId m_viewId;
|
||||
|
||||
QPointF m_scenePoint;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will drag the mouse between the two specified points in the scene
|
||||
*/
|
||||
class SceneMouseDragAction
|
||||
: public CompoundAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(SceneMouseDragAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(SceneMouseDragAction, "{5A422603-1A84-40B2-B051-94D324F94C7A}", CompoundAction);
|
||||
|
||||
SceneMouseDragAction(GraphCanvas::GraphId graphId, QPointF sceneStart, QPointF sceneEnd, Qt::MouseButton mouseButton = Qt::MouseButton::LeftButton);
|
||||
~SceneMouseDragAction() override = default;
|
||||
|
||||
bool IsMissingPrecondition() override;
|
||||
EditorAutomationAction* GenerateMissingPreconditionAction() override;
|
||||
|
||||
void SetupAction() override;
|
||||
|
||||
private:
|
||||
|
||||
GraphCanvas::GraphId m_graphId;
|
||||
GraphCanvas::ViewId m_viewId;
|
||||
|
||||
QPointF m_sceneStart;
|
||||
QPointF m_sceneEnd;
|
||||
|
||||
Qt::MouseButton m_mouseButton;
|
||||
};
|
||||
}
|
||||
+111
@@ -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 <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Editor/EditorTypes.h>
|
||||
#include <GraphCanvas/Types/Types.h>
|
||||
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/GenericActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorAutomationAction that will select the specified entity inside of the active Graph scene
|
||||
*/
|
||||
class SelectSceneElementAction
|
||||
: public CompoundAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(SelectSceneElementAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(SelectSceneElementAction, "{D1EA3B23-D7FD-411A-87BC-4D9D88D35A03}", CompoundAction);
|
||||
|
||||
SelectSceneElementAction(AZ::EntityId sceneMemberId);
|
||||
~SelectSceneElementAction() override = default;
|
||||
|
||||
bool IsMissingPrecondition() override;
|
||||
EditorAutomationAction* GenerateMissingPreconditionAction() override;
|
||||
|
||||
void SetupAction();
|
||||
|
||||
private:
|
||||
|
||||
QPointF m_scenePoint;
|
||||
|
||||
AZ::EntityId m_sceneMemberId;
|
||||
GraphCanvas::GraphId m_graphId;
|
||||
GraphCanvas::ViewId m_viewId;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will alt click the specified entity inside of the active Graph scene in order
|
||||
Should delete the element that is clicked on
|
||||
*/
|
||||
class AltClickSceneElementAction
|
||||
: public CompoundAction
|
||||
, public GraphCanvas::SceneNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(AltClickSceneElementAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(AltClickSceneElementAction, "{FF99EC14-53B3-474E-A7A1-6D30800B9583}", CompoundAction);
|
||||
|
||||
AltClickSceneElementAction(AZ::EntityId sceneMemberId);
|
||||
~AltClickSceneElementAction() override = default;
|
||||
|
||||
bool IsMissingPrecondition() override;
|
||||
EditorAutomationAction* GenerateMissingPreconditionAction() override;
|
||||
|
||||
void SetupAction() override;
|
||||
|
||||
ActionReport GenerateReport() const override;
|
||||
|
||||
// SceneNotificaitonBus
|
||||
void OnNodeRemoved(const AZ::EntityId& nodeId);
|
||||
|
||||
void OnConnectionRemoved(const AZ::EntityId& connectionId);
|
||||
////
|
||||
|
||||
protected:
|
||||
|
||||
void OnActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
QPointF m_scenePoint;
|
||||
|
||||
bool m_sceneMemberRemoved = false;
|
||||
AZ::EntityId m_sceneMemberId;
|
||||
GraphCanvas::GraphId m_graphId;
|
||||
GraphCanvas::ViewId m_viewId;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will move the mouse to the NodePropertyDisplay for the specified GraphCanvas SlotId
|
||||
*/
|
||||
class MouseToNodePropertyEditorAction
|
||||
: public CompoundAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(MouseToNodePropertyEditorAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(MouseToNodePropertyEditorAction, "{03BE0BBE-B977-4103-BC6D-0357B7CEA46E}", CompoundAction);
|
||||
|
||||
MouseToNodePropertyEditorAction(GraphCanvas::SlotId slotId);
|
||||
~MouseToNodePropertyEditorAction() override = default;
|
||||
|
||||
void SetupAction();
|
||||
|
||||
private:
|
||||
|
||||
GraphCanvas::SlotId m_slotId;
|
||||
};
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* 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 <GraphCanvas/Editor/AssetEditorBus.h>
|
||||
#include <GraphCanvas/Types/Types.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/GenericActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
|
||||
//! This action waits for the signal from AssetEditorNotificationBus that signals the active graph
|
||||
//! has changed, meaning that in the context of these tests, the newly created graph is in focus.
|
||||
class WaitForNewGraphAction
|
||||
: public EditorAutomationAction
|
||||
, public GraphCanvas::AssetEditorNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(WaitForNewGraphAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(WaitForNewGraphAction, "{0632736B-ACC3-4051-9772-3A7169B375E9}", EditorAutomationAction);
|
||||
|
||||
WaitForNewGraphAction();
|
||||
~WaitForNewGraphAction() override;
|
||||
|
||||
bool Tick() override;
|
||||
|
||||
const GraphCanvas::GraphId& GetGraphId() const { return m_graphId; }
|
||||
|
||||
private:
|
||||
|
||||
// AssetEditorNotificationBus...
|
||||
void OnActiveGraphChanged(const AZ::EntityId& graphId) override;
|
||||
|
||||
|
||||
bool m_newGraphCreated = false;
|
||||
AZ::EntityId m_graphId;
|
||||
};
|
||||
|
||||
|
||||
//! Action that will create a new runtime graph using the toolbar button
|
||||
class CreateNewGraphAction
|
||||
: public CompoundAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(CreateNewGraphAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(CreateNewGraphAction, "{26A316D4-ADCC-4796-A3C5-E0545EB96C0E}", CompoundAction);
|
||||
|
||||
CreateNewGraphAction();
|
||||
~CreateNewGraphAction() override = default;
|
||||
|
||||
void SetupAction() override;
|
||||
|
||||
GraphCanvas::GraphId GetGraphId() const;
|
||||
|
||||
ActionReport GenerateReport() const override;
|
||||
|
||||
protected:
|
||||
|
||||
void OnActionsComplete() override;
|
||||
|
||||
GraphCanvas::GraphId m_graphId;
|
||||
WaitForNewGraphAction* m_newGraphAction;
|
||||
};
|
||||
|
||||
//! Action that will create a new function graph using the toolbar button
|
||||
class CreateNewFunctionAction
|
||||
: public CreateNewGraphAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(CreateNewFunctionAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(CreateNewFunctionAction, "{EF730E0B-AA26-4A81-BC48-22FBEB06CBF9}", CreateNewGraphAction);
|
||||
|
||||
CreateNewFunctionAction();
|
||||
~CreateNewFunctionAction() override = default;
|
||||
|
||||
void SetupAction() override;
|
||||
|
||||
ActionReport GenerateReport() const override;
|
||||
|
||||
protected:
|
||||
|
||||
void OnActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
GraphCanvas::GraphId m_graphId;
|
||||
};
|
||||
|
||||
//! Action that will forcibly close the active graph, bypassing any prompts for saving
|
||||
class ForceCloseActiveGraphAction
|
||||
: public ProcessUserEventsAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(ForceCloseActiveGraphAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(ForceCloseActiveGraphAction, "{39BE4561-49A3-4087-BC70-15773EC2117F}", ProcessUserEventsAction);
|
||||
|
||||
ForceCloseActiveGraphAction();
|
||||
~ForceCloseActiveGraphAction() override = default;
|
||||
|
||||
void SetupAction() override;
|
||||
bool Tick() override;
|
||||
|
||||
ActionReport GenerateReport() const override;
|
||||
|
||||
private:
|
||||
|
||||
GraphCanvas::GraphId m_activeGraphId;
|
||||
|
||||
bool m_firstTick = false;
|
||||
};
|
||||
}
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* 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 <QAbstractItemView>
|
||||
#include <QLineEdit>
|
||||
#include <QRect>
|
||||
#include <QPoint>
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
|
||||
#include <GraphCanvas/Types/Endpoint.h>
|
||||
#include <GraphCanvas/Types/Types.h>
|
||||
#include <GraphCanvas/Widgets/NodePalette/NodePaletteWidget.h>
|
||||
|
||||
#include <ScriptCanvas/Core/Datum.h>
|
||||
#include <ScriptCanvas/Variable/VariableCore.h>
|
||||
#include <ScriptCanvas/Variable/VariableBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/GenericActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorAutomationAction that will create a variable in the active graph using the specified creation action
|
||||
*/
|
||||
class CreateVariableAction
|
||||
: public CompoundAction
|
||||
, public ScriptCanvas::GraphVariableManagerNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
|
||||
enum class CreationType
|
||||
{
|
||||
Palette,
|
||||
AutoComplete,
|
||||
Programmatic
|
||||
};
|
||||
|
||||
AZ_CLASS_ALLOCATOR(CreateVariableAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(CreateVariableAction, "{0C2A4B3C-FCE3-4611-BACB-4651B40CD715}", CompoundAction);
|
||||
|
||||
CreateVariableAction(ScriptCanvas::Data::Type dataType, CreationType creationType = CreationType::AutoComplete);
|
||||
CreateVariableAction(ScriptCanvas::Data::Type dataType, QString variableName, CreationType creationType = CreationType::AutoComplete);
|
||||
~CreateVariableAction() override = default;
|
||||
|
||||
void SetErrorOnNameMisMatch(bool enabled);
|
||||
|
||||
void SetupAction() override;
|
||||
|
||||
ScriptCanvas::VariableId GetVariableId() const;
|
||||
|
||||
// GraphVariableManagerNotificationBus
|
||||
void OnVariableAddedToGraph(const ScriptCanvas::VariableId& variableId, AZStd::string_view variableName) override;
|
||||
////
|
||||
|
||||
ActionReport GenerateReport() const override;
|
||||
|
||||
protected:
|
||||
|
||||
void OnActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
CreationType m_creationType = CreationType::AutoComplete;
|
||||
|
||||
bool m_errorOnNameMismatch = true;
|
||||
QString m_variableName;
|
||||
|
||||
ScriptCanvas::Data::Type m_dataType;
|
||||
QString m_typeName;
|
||||
|
||||
ScriptCanvas::ScriptCanvasId m_scriptCanvasId;
|
||||
ScriptCanvas::VariableId m_variableId;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will create a get/set variable node from the variable palette
|
||||
*/
|
||||
class CreateVariableNodeFromGraphPalette
|
||||
: public CompoundAction
|
||||
, public GraphCanvas::SceneNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(CreateVariableNodeFromGraphPalette, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(CreateVariableNodeFromGraphPalette, "{B0E36790-2BED-4338-A462-7F302AFA5671}", CompoundAction);
|
||||
|
||||
CreateVariableNodeFromGraphPalette(const AZStd::string& variableName, const GraphCanvas::GraphId& graphId, QPoint scenePoint, Qt::KeyboardModifier = Qt::KeyboardModifier::ShiftModifier);
|
||||
~CreateVariableNodeFromGraphPalette() override = default;
|
||||
|
||||
bool IsMissingPrecondition() override;
|
||||
EditorAutomationAction* GenerateMissingPreconditionAction() override;
|
||||
|
||||
void SetupAction();
|
||||
|
||||
// GraphCanvas::SceneNotificationBus
|
||||
void OnNodeAdded(const AZ::EntityId& nodeId, bool isPaste) override;
|
||||
////
|
||||
|
||||
AZ::EntityId GetCreatedNodeId() const;
|
||||
|
||||
ActionReport GenerateReport() const override;
|
||||
|
||||
protected:
|
||||
|
||||
void OnActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
QTableView* m_graphPalette = nullptr;
|
||||
QLineEdit* m_textFilter = nullptr;
|
||||
|
||||
bool m_isShowingPalette = false;
|
||||
bool m_isFiltered = false;
|
||||
bool m_indexIsVisible = false;
|
||||
bool m_scenePointVisible = false;
|
||||
|
||||
QModelIndex m_displayIndex;
|
||||
|
||||
AZStd::string m_variableName;
|
||||
|
||||
GraphCanvas::GraphId m_graphId;
|
||||
GraphCanvas::ViewId m_viewId;
|
||||
QPoint m_scenePoint;
|
||||
|
||||
AZ::EntityId m_createdNodeId;
|
||||
|
||||
Qt::KeyboardModifier m_modifier;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will ensure that VariableWidget is showing the active GraphVariables list
|
||||
*/
|
||||
class ShowGraphVariablesAction
|
||||
: public CompoundAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(ShowGraphVariablesAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(ShowGraphVariablesAction, "{853F34EB-F8AB-47E3-A601-35091DC23E11}", CompoundAction);
|
||||
|
||||
ShowGraphVariablesAction() = default;
|
||||
~ShowGraphVariablesAction() override = default;
|
||||
|
||||
void SetupAction();
|
||||
|
||||
ActionReport GenerateReport() const override;
|
||||
};
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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 <QAbstractItemView>
|
||||
#include <QLineEdit>
|
||||
#include <QRect>
|
||||
#include <QPoint>
|
||||
#include <QString>
|
||||
|
||||
#include <GraphCanvas/Types/Types.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/GenericActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorAutomationAction that will write a string to the specified line edit.
|
||||
*/
|
||||
class WriteToLineEditAction
|
||||
: public CompoundAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(WriteToLineEditAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(WriteToLineEditAction, "{EAF64BDE-9A06-4169-8FD1-50D6BFEBA73A}", CompoundAction);
|
||||
|
||||
WriteToLineEditAction(QLineEdit* targetEdit, QString targetText);
|
||||
|
||||
void SetupAction() override;
|
||||
|
||||
private:
|
||||
|
||||
QLineEdit* m_targetEdit;
|
||||
QString m_targetText;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationAction that will move the mouse to the specified row for the specified ItemView
|
||||
*/
|
||||
class MoveMouseToViewRowAction
|
||||
: public CompoundAction
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(MoveMouseToViewRowAction, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(MoveMouseToViewRowAction, "{094DD153-BDE4-4E56-B14A-25FE5C6348A1}", CompoundAction);
|
||||
|
||||
MoveMouseToViewRowAction(QAbstractItemView* tableView, int row, QModelIndex parentIndex = QModelIndex());
|
||||
~MoveMouseToViewRowAction() override = default;
|
||||
|
||||
void SetupAction() override;
|
||||
|
||||
private:
|
||||
|
||||
QAbstractItemView* m_itemView = nullptr;
|
||||
int m_row;
|
||||
QModelIndex m_parentIndex;
|
||||
};
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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/std/string/string.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
typedef AZStd::string AutomationStateModelId;
|
||||
namespace StateModelIds
|
||||
{
|
||||
static const char* GraphCanvasId = "::GraphCanvasId";
|
||||
static const char* ScriptCanvasId = "::ScriptCanvasId";
|
||||
static const char* ViewId = "::ViewId";
|
||||
static const char* MinorStep = "::MinorStep";
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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 <GraphCanvas/Types/Endpoint.h>
|
||||
#include <GraphCanvas/Types/Types.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ConnectionActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorAutomationState that will couple the two specified nodes together. The ordering of the coupling is decided by the specified connection type from the perspective of the 'nodeToPickUp'
|
||||
*/
|
||||
class CoupleNodesState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
CoupleNodesState(AutomationStateModelId firstNode, GraphCanvas::ConnectionType connectionType, AutomationStateModelId secondNode, AutomationStateModelId outputId = "");
|
||||
~CoupleNodesState() override = default;
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
AutomationStateModelId m_pickUpNode;
|
||||
AutomationStateModelId m_targetNode;
|
||||
|
||||
GraphCanvas::ConnectionType m_connectionType;
|
||||
|
||||
CoupleNodesAction* m_coupleNodesAction = nullptr;
|
||||
|
||||
AutomationStateModelId m_outputId;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationState that will attempt to create a connection between the two specified endpoints
|
||||
*/
|
||||
class ConnectEndpointsState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
ConnectEndpointsState(AutomationStateModelId sourceEndpoint, AutomationStateModelId targetEndpoint, AutomationStateModelId outputId = "");
|
||||
~ConnectEndpointsState() override = default;
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
AutomationStateModelId m_sourceEndpoint;
|
||||
AutomationStateModelId m_targetEndpoint;
|
||||
|
||||
ConnectEndpointsAction* m_connectEndpointsAction = nullptr;
|
||||
|
||||
AutomationStateModelId m_outputId;
|
||||
};
|
||||
}
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* 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 <GraphCanvas/Types/Endpoint.h>
|
||||
#include <GraphCanvas/Types/Types.h>
|
||||
#include <GraphCanvas/Widgets/NodePalette/NodePaletteWidget.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationModelIds.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/CreateElementsActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorAutomationState that will create the specified node from the NodePalette either at the specified point, or via splicing
|
||||
*/
|
||||
class CreateNodeFromPaletteState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
enum class CreationType
|
||||
{
|
||||
ScenePosition,
|
||||
Splice
|
||||
};
|
||||
|
||||
CreateNodeFromPaletteState(GraphCanvas::NodePaletteWidget* paletteWidget, const QString& nodeName, CreationType creationType, AutomationStateModelId creationDataId, AutomationStateModelId outputId = "");
|
||||
~CreateNodeFromPaletteState() override = default;
|
||||
|
||||
protected:
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
GraphCanvas::NodePaletteWidget* m_nodePaletteWidget = nullptr;
|
||||
QString m_nodeName;
|
||||
|
||||
CreationType m_creationType;
|
||||
AutomationStateModelId m_creationDataId;
|
||||
|
||||
AutomationStateModelId m_outputId;
|
||||
|
||||
CreateNodeFromPaletteAction* m_createNodeAction = nullptr;
|
||||
DelayAction m_delayAction;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationState that will create all of the nodes under the specified category
|
||||
*/
|
||||
class CreateCategoryFromNodePaletteState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
|
||||
CreateCategoryFromNodePaletteState(GraphCanvas::NodePaletteWidget* paletteWidget, AutomationStateModelId categoryId, AutomationStateModelId scenePoint, AutomationStateModelId outputId = "");
|
||||
~CreateCategoryFromNodePaletteState() override = default;
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
AutomationStateModelId m_categoryId;
|
||||
AutomationStateModelId m_scenePoint;
|
||||
AutomationStateModelId m_outputId;
|
||||
|
||||
GraphCanvas::NodePaletteWidget* m_paletteWidget = nullptr;
|
||||
|
||||
CreateCategoryFromNodePaletteAction* m_creationAction = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationState that will create the specified node at either the specified point using the context menu, or by
|
||||
splicing it onto a ConnectionId
|
||||
*/
|
||||
class CreateNodeFromContextMenuState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
enum class CreationType
|
||||
{
|
||||
ScenePosition,
|
||||
Splice
|
||||
};
|
||||
|
||||
CreateNodeFromContextMenuState(const QString& nodeName, CreationType creationType, AutomationStateModelId creationDataId, AutomationStateModelId outputId = "");
|
||||
~CreateNodeFromContextMenuState() override = default;
|
||||
|
||||
protected:
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
QString m_nodeName;
|
||||
|
||||
CreationType m_creationType;
|
||||
AutomationStateModelId m_creationDataId;
|
||||
|
||||
AutomationStateModelId m_outputId;
|
||||
|
||||
CreateNodeFromContextMenuAction* m_createNodeAction = nullptr;
|
||||
DelayAction m_delayAction;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationState that will create the specified node at the specified point by dragging a connection from the specified endpoint.
|
||||
Will place the new node at a 'reasonable' distance from the specified endpoint, or at the specified point.
|
||||
*/
|
||||
class CreateNodeFromProposalState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
CreateNodeFromProposalState(const QString& nodeName, AutomationStateModelId endpointId, AutomationStateModelId scenePointId = "", AutomationStateModelId nodeOutputId = "", AutomationStateModelId connectionOutputId = "");
|
||||
~CreateNodeFromProposalState() override = default;
|
||||
|
||||
protected:
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
QString m_nodeName;
|
||||
|
||||
AutomationStateModelId m_endpointId = nullptr;
|
||||
|
||||
AutomationStateModelId m_scenePointId;
|
||||
AutomationStateModelId m_nodeOutputId;
|
||||
AutomationStateModelId m_connectionOutputId;
|
||||
|
||||
CreateNodeFromProposalAction* m_createNodeAction = nullptr;
|
||||
DelayAction m_delayAction;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationState that will create a Group using the specified creation method.
|
||||
*/
|
||||
class CreateGroupState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
CreateGroupState(GraphCanvas::EditorId editorId, CreateGroupAction::CreationType creationType = CreateGroupAction::CreationType::Hotkey, AutomationStateModelId outputId = "");
|
||||
~CreateGroupState() override = default;
|
||||
|
||||
protected:
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
GraphCanvas::EditorId m_editorId;
|
||||
CreateGroupAction::CreationType m_creationType;
|
||||
|
||||
AutomationStateModelId m_outputId;
|
||||
|
||||
CreateGroupAction* m_createGroupAction;
|
||||
DelayAction m_delayAction;
|
||||
};
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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 <GraphCanvas/Types/Types.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/WidgetActions.h>
|
||||
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorAutomationState that will move the mouse to a particular point in the scene.
|
||||
*/
|
||||
class SceneMouseMoveState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
SceneMouseMoveState(AutomationStateModelId targetPoint);
|
||||
~SceneMouseMoveState() override = default;
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
AutomationStateModelId m_targetPoint;
|
||||
|
||||
SceneMouseMoveAction* m_moveAction = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationState that will execute a Mouse Drag Action inside of the scene
|
||||
*/
|
||||
class SceneMouseDragState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
SceneMouseDragState(AutomationStateModelId startPoint, AutomationStateModelId endPoint, Qt::MouseButton mouseButton = Qt::MouseButton::LeftButton);
|
||||
~SceneMouseDragState() override = default;
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
AutomationStateModelId m_startPoint;
|
||||
AutomationStateModelId m_endPoint;
|
||||
|
||||
Qt::MouseButton m_mouseButton;
|
||||
|
||||
SceneMouseDragAction* m_dragAction = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationState that will find the view center and store it in the supplied id.
|
||||
*/
|
||||
class FindViewCenterState
|
||||
: public CustomActionState
|
||||
{
|
||||
public:
|
||||
FindViewCenterState(AutomationStateModelId outputId);
|
||||
~FindViewCenterState() override = default;
|
||||
|
||||
void OnCustomAction();
|
||||
|
||||
private:
|
||||
|
||||
AutomationStateModelId m_outputId;
|
||||
};
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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 <GraphCanvas/Types/Types.h>
|
||||
#include <GraphCanvas/Editor/EditorTypes.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ElementInteractions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorAutomationState that will select the specified target
|
||||
*/
|
||||
class SelectSceneElementState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
SelectSceneElementState(AutomationStateModelId targetId);
|
||||
~SelectSceneElementState() override = default;
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
SelectSceneElementAction* m_selectSceneElement = nullptr;
|
||||
|
||||
AutomationStateModelId m_targetId;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationState that will execute the alt click scene element action
|
||||
*/
|
||||
class AltClickSceneElementState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
AltClickSceneElementState(AutomationStateModelId targetId);
|
||||
~AltClickSceneElementState() override = default;
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
AltClickSceneElementAction* m_altClickAction = nullptr;
|
||||
|
||||
AutomationStateModelId m_targetId;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationState that will execute the mouse to node property editor action
|
||||
*/
|
||||
class MouseToNodePropertyEditorState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
MouseToNodePropertyEditorState(AutomationStateModelId slotId);
|
||||
~MouseToNodePropertyEditorState() override = default;
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
ProcessUserEventsAction m_processEvents;
|
||||
MouseToNodePropertyEditorAction* m_moveToPropertyAction = nullptr;
|
||||
|
||||
AutomationStateModelId m_slotId;
|
||||
};
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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 <GraphCanvas/Editor/AssetEditorBus.h>
|
||||
#include <GraphCanvas/Types/Types.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/GraphActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorAutomationState that will create a runtime graph
|
||||
*/
|
||||
DefineStateId(CreateRuntimeGraphState);
|
||||
|
||||
class CreateRuntimeGraphState
|
||||
: public StaticIdAutomationState<CreateRuntimeGraphStateId>
|
||||
{
|
||||
public:
|
||||
|
||||
CreateRuntimeGraphState();
|
||||
~CreateRuntimeGraphState() override = default;
|
||||
|
||||
protected:
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
CreateNewGraphAction m_createNewGraphAction;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationState that will create a function graph
|
||||
*/
|
||||
DefineStateId(CreateFunctionGraphState);
|
||||
|
||||
class CreateFunctionGraphState
|
||||
: public StaticIdAutomationState<CreateFunctionGraphStateId>
|
||||
{
|
||||
public:
|
||||
|
||||
CreateFunctionGraphState();
|
||||
~CreateFunctionGraphState() override = default;
|
||||
|
||||
protected:
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
CreateNewFunctionAction m_createNewFunctionAction;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationState that will force close the currently opened graph, bypassing any save prompts.
|
||||
*/
|
||||
DefineStateId(ForceCloseActiveGraphState);
|
||||
|
||||
class ForceCloseActiveGraphState
|
||||
: public StaticIdAutomationState<ForceCloseActiveGraphStateId>
|
||||
{
|
||||
public:
|
||||
|
||||
ForceCloseActiveGraphState();
|
||||
~ForceCloseActiveGraphState() override = default;
|
||||
|
||||
protected:
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
|
||||
private:
|
||||
|
||||
ForceCloseActiveGraphAction m_forceCloseActiveGraph;
|
||||
};
|
||||
}
|
||||
+197
@@ -0,0 +1,197 @@
|
||||
/*
|
||||
* 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 <GraphCanvas/Types/Types.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/WidgetActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
struct FindPositionOffsets
|
||||
{
|
||||
// 0 is top. 1 is bottom.
|
||||
float m_verticalPosition = 0;
|
||||
|
||||
// Offset will be added on to the relative anchor point
|
||||
int m_verticalOffset = 0;
|
||||
|
||||
// 0 is left, 1 is right
|
||||
float m_horizontalPosition = 0;
|
||||
|
||||
// Offset will be added on to the relative anchor point
|
||||
int m_horizontalOffset = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationState that will find the node position and store it in the supplied id.
|
||||
- By default will return the 'center' of the node. The offset vector will determine
|
||||
a direction on the node to offset to the edge of, and the length deterines how much
|
||||
extra space to apply in that offset direction
|
||||
|
||||
0 is right/up, 1 is left/down
|
||||
*/
|
||||
class FindNodePosition
|
||||
: public CustomActionState
|
||||
{
|
||||
public:
|
||||
FindNodePosition(AutomationStateModelId nodeId, AutomationStateModelId outputId, FindPositionOffsets offsets = FindPositionOffsets());
|
||||
~FindNodePosition() override = default;
|
||||
|
||||
void OnCustomAction() override;
|
||||
|
||||
private:
|
||||
|
||||
FindPositionOffsets m_offsets;
|
||||
|
||||
AutomationStateModelId m_nodeId;
|
||||
AutomationStateModelId m_outputId;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationState that will find the group position and store it in the supplied id.
|
||||
- By default will return the 'center' of the node. The offset vector will determine
|
||||
a direction on the node to offset to the edge of, and the length deterines how much
|
||||
extra space to apply in that offset direction
|
||||
|
||||
0 is right/up, 1 is left/down
|
||||
*/
|
||||
class FindGroupPosition
|
||||
: public CustomActionState
|
||||
{
|
||||
public:
|
||||
FindGroupPosition(AutomationStateModelId groupId, AutomationStateModelId outputId, FindPositionOffsets offsets = FindPositionOffsets());
|
||||
~FindGroupPosition() override = default;
|
||||
|
||||
void OnCustomAction() override;
|
||||
|
||||
private:
|
||||
|
||||
FindPositionOffsets m_offsets;
|
||||
|
||||
AutomationStateModelId m_groupId;
|
||||
AutomationStateModelId m_outputId;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationState that will find an endpoint of the specified type on the supplied node.
|
||||
Slot number will be the number of the slot that you are looking for(index 0).
|
||||
*/
|
||||
class FindEndpointOfTypeState
|
||||
: public CustomActionState
|
||||
{
|
||||
public:
|
||||
|
||||
FindEndpointOfTypeState(AutomationStateModelId targetNodeId, AutomationStateModelId outputId, GraphCanvas::ConnectionType connectionType, GraphCanvas::SlotType slotType, int slotNumber = 0);
|
||||
~FindEndpointOfTypeState() override = default;
|
||||
|
||||
void OnCustomAction() override;
|
||||
|
||||
private:
|
||||
|
||||
AutomationStateModelId m_targetNodeId;
|
||||
AutomationStateModelId m_outputId;
|
||||
|
||||
int m_slotNumber;
|
||||
|
||||
GraphCanvas::ConnectionType m_connectionType = GraphCanvas::ConnectionType::CT_Invalid;
|
||||
GraphCanvas::SlotType m_slotType = GraphCanvas::SlotTypes::Invalid;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationState that will find the last connection for the specified endpoint
|
||||
*/
|
||||
class GetLastConnection
|
||||
: public CustomActionState
|
||||
{
|
||||
public:
|
||||
GetLastConnection(AutomationStateModelId targetEndpoint, AutomationStateModelId outputId);
|
||||
~GetLastConnection() override = default;
|
||||
|
||||
void OnCustomAction() override;
|
||||
|
||||
private:
|
||||
|
||||
AutomationStateModelId m_targetEndpoint;
|
||||
AutomationStateModelId m_outputId;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationState that will delete the specified row from the GraphVariablesPalette
|
||||
*/
|
||||
class DeleteVariableRowFromPaletteState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
|
||||
DeleteVariableRowFromPaletteState(int row);
|
||||
~DeleteVariableRowFromPaletteState() override = default;
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
int m_row = 0;
|
||||
int m_rowCount = 0;
|
||||
|
||||
MoveMouseToViewRowAction* m_mouseToRow = nullptr;
|
||||
|
||||
MouseClickAction m_clickAction;
|
||||
TypeCharAction m_deleteAction;
|
||||
ProcessUserEventsAction m_processEvents;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationState will confirm the supplied group status of the provided scene member to the provided group.
|
||||
*/
|
||||
class CheckIsInGroup
|
||||
: public CustomActionState
|
||||
{
|
||||
public:
|
||||
CheckIsInGroup(AutomationStateModelId sceneMemberId, AutomationStateModelId groupId, bool expectResult, AZStd::string stateName = "");
|
||||
~CheckIsInGroup() override = default;
|
||||
|
||||
void OnCustomAction() override;
|
||||
|
||||
private:
|
||||
|
||||
bool m_expectResult = false;
|
||||
|
||||
AutomationStateModelId m_sceneMemberId;
|
||||
AutomationStateModelId m_groupId;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationState that triggers the specified character with the 'ctrl' key.
|
||||
*/
|
||||
class TriggerHotKey
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
TriggerHotKey(QChar hotkey, AZStd::string stateId = "");
|
||||
~TriggerHotKey() override = default;
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
|
||||
private:
|
||||
|
||||
TypeCharAction m_typeAction;
|
||||
|
||||
ProcessUserEventsAction m_processEvents;
|
||||
|
||||
KeyPressAction m_pressCtrlAction;
|
||||
KeyReleaseAction m_releaseCtrlAction;
|
||||
};
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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 <QAbstractItemView>
|
||||
#include <QLineEdit>
|
||||
#include <QRect>
|
||||
#include <QPoint>
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
|
||||
#include <GraphCanvas/Types/Endpoint.h>
|
||||
#include <GraphCanvas/Types/Types.h>
|
||||
#include <GraphCanvas/Widgets/NodePalette/NodePaletteWidget.h>
|
||||
|
||||
#include <ScriptCanvas/Core/Datum.h>
|
||||
#include <ScriptCanvas/Variable/VariableCore.h>
|
||||
#include <ScriptCanvas/Variable/VariableBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/GenericActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/VariableActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorAutomationState that will create a variable and give it a name(assuming one is provided), using the specified creation method.
|
||||
*/
|
||||
class CreateVariableState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
CreateVariableState(AutomationStateModelId dataTypeId, AutomationStateModelId nameId, bool errorOnNameMismatch = true, CreateVariableAction::CreationType creationType = CreateVariableAction::CreationType::AutoComplete, AutomationStateModelId outputId = "");
|
||||
~CreateVariableState() override = default;
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
AutomationStateModelId m_dataTypeId;
|
||||
AutomationStateModelId m_nameId;
|
||||
AutomationStateModelId m_outputId;
|
||||
|
||||
CreateVariableAction::CreationType m_creationType;
|
||||
|
||||
bool m_errorOnNameMismatch = true;
|
||||
|
||||
CreateVariableAction* m_createVariableAction = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationState that will create a variable node by holding down a modifier and dragging off of the GraphVariablePalette
|
||||
*/
|
||||
class CreateVariableNodeFromGraphPaletteState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
CreateVariableNodeFromGraphPaletteState(AutomationStateModelId variableNameId, AutomationStateModelId scenePoint, Qt::KeyboardModifier modifier, AutomationStateModelId outputId);
|
||||
~CreateVariableNodeFromGraphPaletteState() override = default;
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
AutomationStateModelId m_variableNameId;
|
||||
AutomationStateModelId m_scenePoint;
|
||||
AutomationStateModelId m_outputId;
|
||||
|
||||
Qt::KeyboardModifier m_modifier;
|
||||
|
||||
CreateVariableNodeFromGraphPalette* m_createVariable = nullptr;
|
||||
};
|
||||
}
|
||||
+337
@@ -0,0 +1,337 @@
|
||||
/*
|
||||
* 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 <QString>
|
||||
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationAction.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationModelIds.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
ActionRunner that will manage the editor automation stack, and handle pushing the precondition elements into the queue.
|
||||
Will not take ownership of all actions added manually, but any precondition elements will be deleted.
|
||||
|
||||
Needs to be externally ticked.
|
||||
*/
|
||||
class EditorAutomationActionRunner
|
||||
{
|
||||
public:
|
||||
|
||||
EditorAutomationActionRunner() = default;
|
||||
~EditorAutomationActionRunner();
|
||||
|
||||
void Reset();
|
||||
bool Tick();
|
||||
|
||||
// Pushes actions onto a stack.
|
||||
void AddAction(EditorAutomationAction* actionToRun);
|
||||
|
||||
bool HasActions() const;
|
||||
|
||||
bool HasErrors() const;
|
||||
const AZStd::vector< ActionReport >& GetErrors() const;
|
||||
|
||||
private:
|
||||
|
||||
AZStd::vector< ActionReport > m_errorReports;
|
||||
AZStd::vector< EditorAutomationAction* > m_executionStack;
|
||||
AZStd::unordered_set< EditorAutomationAction* > m_actionsToDelete;
|
||||
|
||||
EditorAutomationAction* m_currentAction = nullptr;
|
||||
};
|
||||
|
||||
class StateModel
|
||||
{
|
||||
public:
|
||||
|
||||
typedef AZStd::string DataKey;
|
||||
|
||||
StateModel() = default;
|
||||
virtual ~StateModel() = default;
|
||||
|
||||
|
||||
const AZStd::any* FindStateData(const DataKey& dataId) const;
|
||||
|
||||
template<typename T>
|
||||
const T* GetStateDataAs(const DataKey& dataId) const
|
||||
{
|
||||
const AZStd::any* stateData = FindStateData(dataId);
|
||||
return AZStd::any_cast<T>(stateData);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void SetStateData(const DataKey& dataId, const T& data)
|
||||
{
|
||||
auto insertResult = m_stateData.insert(dataId);
|
||||
auto dataIter = insertResult.first;
|
||||
|
||||
dataIter->second = data;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void ClearModelData();
|
||||
|
||||
|
||||
private:
|
||||
AZStd::unordered_map< DataKey, AZStd::any > m_stateData;
|
||||
};
|
||||
|
||||
template <AZ::u32 Id>
|
||||
struct StateTraits
|
||||
{
|
||||
static int StateID() { return Id; }
|
||||
};
|
||||
|
||||
class EditorAutomationState
|
||||
{
|
||||
public:
|
||||
static constexpr int EXIT_STATE_ID = (-1);
|
||||
|
||||
AZ_TYPE_INFO(EditorAutomationState, "{B18A0531-E3C2-4209-8A9E-1B0195C28443}");
|
||||
AZ_CLASS_ALLOCATOR(EditorAutomationState, AZ::SystemAllocator, 0);
|
||||
|
||||
virtual ~EditorAutomationState() = default;
|
||||
|
||||
virtual int GetStateId() const = 0;
|
||||
virtual const char* GetStateName() const = 0;
|
||||
|
||||
void SetStateModel(StateModel* stateModel)
|
||||
{
|
||||
m_stateModel = stateModel;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void SetModelData(StateModel::DataKey dataKey, const T& modelData)
|
||||
{
|
||||
m_stateModel->SetStateData<T>(dataKey, modelData);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const T* GetModelData(StateModel::DataKey dataKey)
|
||||
{
|
||||
return m_stateModel->GetStateDataAs<T>(dataKey);
|
||||
}
|
||||
|
||||
StateModel* GetStateModel() const
|
||||
{
|
||||
return m_stateModel;
|
||||
}
|
||||
|
||||
void SetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
m_error = "";
|
||||
|
||||
OnSetupStateActions(actionRunner);
|
||||
}
|
||||
|
||||
void StateActionsComplete()
|
||||
{
|
||||
OnStateActionsComplete();
|
||||
}
|
||||
|
||||
bool HasErrors() const
|
||||
{
|
||||
return !m_error.empty();
|
||||
}
|
||||
|
||||
void ReportError(AZStd::string error)
|
||||
{
|
||||
m_error += AZStd::string::format("%s - %s\n", GetStateName(), error.c_str());
|
||||
}
|
||||
|
||||
const AZStd::string& GetError() const
|
||||
{
|
||||
return m_error;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) = 0;
|
||||
virtual void OnStateActionsComplete() {};
|
||||
|
||||
private:
|
||||
StateModel* m_stateModel = nullptr;
|
||||
|
||||
AZStd::string m_error;
|
||||
};
|
||||
|
||||
template <typename Traits>
|
||||
class StaticIdAutomationState : public EditorAutomationState
|
||||
{
|
||||
public:
|
||||
|
||||
AZ_TYPE_INFO(StaticIdAutomationState, "{7E7450F7-5553-4877-8AC9-365A052F2758}");
|
||||
|
||||
StaticIdAutomationState() = default;
|
||||
|
||||
int GetStateId() const override { return Traits::StateID(); }
|
||||
const char* GetStateName() const override { return Traits::StateName(); }
|
||||
|
||||
static int StateID() { return Traits::StateID(); }
|
||||
};
|
||||
|
||||
// In order to re-use some states with different constructions setups without needing
|
||||
// a bunch of one off states to re-configure the pre-existing states through data model values
|
||||
// named state provides a way for states to construct their names at the expense of not
|
||||
// being able to statically reference the name/stateid.
|
||||
class NamedAutomationState : public EditorAutomationState
|
||||
{
|
||||
public:
|
||||
|
||||
AZ_TYPE_INFO(NamedAutomationState, "{62DD037C-D80F-4B1B-9F3E-9F05400ABA24}");
|
||||
|
||||
NamedAutomationState() = delete;
|
||||
NamedAutomationState(const char* name)
|
||||
{
|
||||
SetStateName(name);
|
||||
m_stateId = AZ::Crc32(name);
|
||||
}
|
||||
|
||||
NamedAutomationState(const AZStd::string& stateName)
|
||||
{
|
||||
SetStateName(stateName);
|
||||
}
|
||||
|
||||
int GetStateId() const override { return m_stateId; }
|
||||
|
||||
protected:
|
||||
|
||||
void SetStateName(const AZStd::string& stateName)
|
||||
{
|
||||
m_name = stateName;
|
||||
m_stateId = AZ_CRC(stateName.c_str());
|
||||
}
|
||||
|
||||
const char* GetStateName() const override { return m_name.c_str(); }
|
||||
|
||||
private:
|
||||
|
||||
AZStd::string m_name;
|
||||
int m_stateId = EXIT_STATE_ID;
|
||||
};
|
||||
|
||||
class CustomActionState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO(CustomActionState, "{DA39829B-08F8-47BF-890D-9DA695BAD5A0}");
|
||||
|
||||
CustomActionState(const char* name)
|
||||
: NamedAutomationState(name)
|
||||
{
|
||||
}
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner&) override final
|
||||
{
|
||||
}
|
||||
|
||||
void OnStateActionsComplete() override final
|
||||
{
|
||||
OnCustomAction();
|
||||
}
|
||||
|
||||
virtual void OnCustomAction() = 0;
|
||||
};
|
||||
|
||||
#define DefineStateId(className) class className##Id : public StateTraits<AZ_CRC_CE(#className)> {\
|
||||
public:\
|
||||
static const char* StateName()\
|
||||
{\
|
||||
return #className;\
|
||||
}\
|
||||
};
|
||||
|
||||
/**
|
||||
Generic test base class that will handle incrementing test steps, running the action runner, and interface with the test dialog to report back errors.
|
||||
*/
|
||||
class EditorAutomationTest
|
||||
: public AZ::SystemTickBus::Handler
|
||||
, public StateModel
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(EditorAutomationTest, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(EditorAutomationTest, "{C46081C5-E7E9-47C7-96D4-29E7D1C4D403}");
|
||||
|
||||
~EditorAutomationTest();
|
||||
|
||||
void StartTest();
|
||||
|
||||
// AZ::SystemTick::Handler
|
||||
void OnSystemTick();
|
||||
////
|
||||
|
||||
void AddState(EditorAutomationState* newState);
|
||||
|
||||
void SetHasCustomTransitions(bool hasCustomTransition);
|
||||
|
||||
template <typename IdClass>
|
||||
void SetInitialStateId()
|
||||
{
|
||||
m_initialStateId = IdClass::StateID();
|
||||
AZ_TracePrintf("Script Canvas", "Initial State: %s\n", IdClass::StateName());
|
||||
}
|
||||
|
||||
virtual void OnTestStarting() {}
|
||||
virtual void OnStateComplete(int /*stateId*/) {}
|
||||
virtual void OnTestComplete() {}
|
||||
|
||||
|
||||
bool HasRun() const;
|
||||
bool IsRunning() const;
|
||||
|
||||
void SetTestName(QString testName) { m_testName = testName; }
|
||||
QString GetTestName() { return m_testName; }
|
||||
bool HasErrors() const { return !m_testErrors.empty(); }
|
||||
|
||||
AZStd::vector< AZStd::string > GetErrors() const { return m_testErrors; }
|
||||
|
||||
protected:
|
||||
|
||||
bool SetupState(int stateId);
|
||||
|
||||
int FindNextState(int stateId);
|
||||
|
||||
virtual int EvaluateTransition(int)
|
||||
{
|
||||
return EditorAutomationState::EXIT_STATE_ID;
|
||||
}
|
||||
|
||||
EditorAutomationTest(QString testName);
|
||||
|
||||
void AddError(AZStd::string error);
|
||||
|
||||
EditorAutomationActionRunner m_actionRunner;
|
||||
AZStd::vector< AZStd::string > m_testErrors;
|
||||
|
||||
bool m_hasCustomTransitions = false;
|
||||
|
||||
AZStd::vector< int > m_registrationOrder;
|
||||
AZStd::unordered_map< int, EditorAutomationState* > m_states;
|
||||
|
||||
private:
|
||||
|
||||
QString m_testName;
|
||||
|
||||
int m_initialStateId = EditorAutomationState::EXIT_STATE_ID;
|
||||
|
||||
int m_stateId = EditorAutomationState::EXIT_STATE_ID;
|
||||
EditorAutomationState* m_currentState = nullptr;
|
||||
//int m_state = 0;
|
||||
|
||||
bool m_hasRun = false;
|
||||
};
|
||||
}
|
||||
+2
-2
@@ -13,12 +13,12 @@
|
||||
#pragma once
|
||||
|
||||
class QAction;
|
||||
class QWidget;
|
||||
class QMenu;
|
||||
|
||||
namespace ScriptCanvasDeveloperEditor
|
||||
{
|
||||
namespace NodeListDumpAction
|
||||
{
|
||||
QAction* CreateNodeListDumpAction(QWidget* mainWindow);
|
||||
QAction* CreateNodeListDumpAction(QMenu* mainWindow);
|
||||
};
|
||||
}
|
||||
|
||||
+3
-1
@@ -15,6 +15,8 @@
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <ScriptCanvas/Bus/ScriptCanvasBus.h>
|
||||
|
||||
class QMainWindow;
|
||||
|
||||
namespace ScriptCanvasDeveloperEditor
|
||||
{
|
||||
class SystemComponent
|
||||
@@ -38,6 +40,6 @@ namespace ScriptCanvasDeveloperEditor
|
||||
////
|
||||
|
||||
// ScriptCanvasEditor::UINotificationBus
|
||||
void MainWindowCreationEvent(QWidget*) override;
|
||||
void MainWindowCreationEvent(QMainWindow* mainWindow) override;
|
||||
};
|
||||
}
|
||||
|
||||
+2
-2
@@ -13,12 +13,12 @@
|
||||
#pragma once
|
||||
|
||||
class QAction;
|
||||
class QWidget;
|
||||
class QMenu;
|
||||
|
||||
namespace ScriptCanvasDeveloperEditor
|
||||
{
|
||||
namespace TSGenerateAction
|
||||
{
|
||||
QAction* SetupTSFileAction(QWidget* mainWindow);
|
||||
QAction* SetupTSFileAction(QMenu* mainWindow);
|
||||
};
|
||||
}
|
||||
|
||||
+100
-11
@@ -11,6 +11,8 @@
|
||||
*/
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
#include <GraphCanvas/Components/GridBus.h>
|
||||
#include <GraphCanvas/Components/Nodes/Comment/CommentBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
@@ -42,6 +44,12 @@ namespace ScriptCanvasDeveloperEditor
|
||||
{
|
||||
public:
|
||||
|
||||
DynamicSlotFullCreationInterface(DeveloperUtils::ConnectionStyle connectionStyle)
|
||||
{
|
||||
m_chainConfig.m_connectionStyle = connectionStyle;
|
||||
m_chainConfig.m_skipHandlers = true;
|
||||
}
|
||||
|
||||
void SetupInterface(const AZ::EntityId& activeGraphCanvasGraphId, const ScriptCanvas::ScriptCanvasId& scriptCanvasId)
|
||||
{
|
||||
m_graphCanvasGraphId = activeGraphCanvasGraphId;
|
||||
@@ -52,6 +60,17 @@ namespace ScriptCanvasDeveloperEditor
|
||||
|
||||
GraphCanvas::GridRequestBus::EventResult(m_minorPitch, m_gridId, &GraphCanvas::GridRequests::GetMinorPitch);
|
||||
|
||||
QGraphicsScene* graphicsScene = nullptr;
|
||||
GraphCanvas::SceneRequestBus::EventResult(graphicsScene, activeGraphCanvasGraphId, &GraphCanvas::SceneRequests::AsQGraphicsScene);
|
||||
|
||||
if (graphicsScene)
|
||||
{
|
||||
QRectF sceneArea = graphicsScene->sceneRect();
|
||||
sceneArea.adjust(m_minorPitch.GetX(), m_minorPitch.GetY(), -m_minorPitch.GetX(), -m_minorPitch.GetY());
|
||||
GraphCanvas::ViewRequestBus::Event(m_viewId, &GraphCanvas::ViewRequests::CenterOnArea, sceneArea);
|
||||
QApplication::processEvents();
|
||||
}
|
||||
|
||||
GraphCanvas::ViewRequestBus::EventResult(m_nodeCreationPos, m_viewId, &GraphCanvas::ViewRequests::GetViewSceneCenter);
|
||||
|
||||
GraphCanvas::GraphCanvasGraphicsView* graphicsView = nullptr;
|
||||
@@ -80,6 +99,52 @@ namespace ScriptCanvasDeveloperEditor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Temporary work around until the extra automation tools can be merged over that have better ways of doing this.
|
||||
const GraphCanvas::GraphCanvasTreeItem* treeItem = nullptr;
|
||||
ScriptCanvasEditor::AutomationRequestBus::BroadcastResult(treeItem, &ScriptCanvasEditor::AutomationRequests::GetNodePaletteRoot);
|
||||
|
||||
const GraphCanvas::NodePaletteTreeItem* onGraphStartItem = nullptr;
|
||||
|
||||
if (treeItem)
|
||||
{
|
||||
AZStd::unordered_set< const GraphCanvas::GraphCanvasTreeItem* > unexploredSet = { treeItem };
|
||||
|
||||
while (!unexploredSet.empty())
|
||||
{
|
||||
const GraphCanvas::GraphCanvasTreeItem* treeItem2 = (*unexploredSet.begin());
|
||||
unexploredSet.erase(unexploredSet.begin());
|
||||
|
||||
const GraphCanvas::NodePaletteTreeItem* nodePaletteTreeItem = azrtti_cast<const GraphCanvas::NodePaletteTreeItem*>(treeItem2);
|
||||
|
||||
if (nodePaletteTreeItem && nodePaletteTreeItem->GetName().compare("On Graph Start") == 0)
|
||||
{
|
||||
onGraphStartItem = nodePaletteTreeItem;
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < treeItem2->GetChildCount(); ++i)
|
||||
{
|
||||
const GraphCanvas::GraphCanvasTreeItem* childItem = treeItem2->FindChildByRow(i);
|
||||
|
||||
if (childItem)
|
||||
{
|
||||
unexploredSet.insert(childItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (onGraphStartItem)
|
||||
{
|
||||
GraphCanvas::GraphCanvasMimeEvent* mimeEvent = onGraphStartItem->CreateMimeEvent();
|
||||
|
||||
if (mimeEvent)
|
||||
{
|
||||
ScriptCanvasEditor::NodeIdPair createdPair = DeveloperUtils::HandleMimeEvent(mimeEvent, m_graphCanvasGraphId, m_viewportRectangle, m_widthOffset, m_heightOffset, m_maxRowHeight, m_minorPitch);
|
||||
DeveloperUtils::CreateConnectedChain(createdPair, m_chainConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ShouldProcessItem([[maybe_unused]] const GraphCanvas::NodePaletteTreeItem* nodePaletteTreeItem) const
|
||||
@@ -256,6 +321,7 @@ namespace ScriptCanvasDeveloperEditor
|
||||
// If we succeeded, we need to update our offsets, and create a new node.
|
||||
if (i >= slotOrdering.size())
|
||||
{
|
||||
DeveloperUtils::CreateConnectedChain(nodeIdPair, m_chainConfig);
|
||||
usedGraphCanvasNodeIds.emplace_back(nodeIdPair.m_graphCanvasId);
|
||||
|
||||
DeveloperUtils::UpdateViewportPositionOffsetForNode(nodeIdPair.m_graphCanvasId, m_viewportRectangle, m_widthOffset, m_heightOffset, m_maxRowHeight, m_minorPitch);
|
||||
@@ -434,6 +500,8 @@ namespace ScriptCanvasDeveloperEditor
|
||||
|
||||
ScriptCanvas::Graph* m_graph = nullptr;
|
||||
|
||||
DeveloperUtils::CreateConnectedChainConfig m_chainConfig;
|
||||
|
||||
AZStd::vector<ScriptCanvas::VariableId> m_availableVariableIds;
|
||||
AZStd::unordered_map<ScriptCanvas::VariableId, ScriptCanvas::Data::Type> m_variableTypeMapping;
|
||||
};
|
||||
@@ -442,28 +510,49 @@ namespace ScriptCanvasDeveloperEditor
|
||||
{
|
||||
ScriptCanvasEditor::AutomationRequestBus::Broadcast(&ScriptCanvasEditor::AutomationRequests::SignalAutomationBegin);
|
||||
|
||||
DynamicSlotFullCreationInterface fullCreationInterface;
|
||||
DynamicSlotFullCreationInterface fullCreationInterface(DeveloperUtils::NoConnections);
|
||||
DeveloperUtils::ProcessNodePalette(fullCreationInterface);
|
||||
|
||||
ScriptCanvasEditor::AutomationRequestBus::Broadcast(&ScriptCanvasEditor::AutomationRequests::SignalAutomationEnd);
|
||||
}
|
||||
|
||||
QAction* CreateDynamicSlotFullCreationAction(QWidget* mainWindow)
|
||||
void VariablePaletteFullyConnectionCreationAction()
|
||||
{
|
||||
QAction* createVariablePaletteAction = nullptr;
|
||||
ScriptCanvasEditor::AutomationRequestBus::Broadcast(&ScriptCanvasEditor::AutomationRequests::SignalAutomationBegin);
|
||||
|
||||
if (mainWindow)
|
||||
DynamicSlotFullCreationInterface fullCreationInterface(DeveloperUtils::SingleExecutionConnection);
|
||||
DeveloperUtils::ProcessNodePalette(fullCreationInterface);
|
||||
|
||||
ScriptCanvasEditor::AutomationRequestBus::Broadcast(&ScriptCanvasEditor::AutomationRequests::SignalAutomationEnd);
|
||||
}
|
||||
|
||||
QAction* CreateDynamicSlotFullCreationAction(QMenu* mainMenu)
|
||||
{
|
||||
QAction* dynamicSlotFullCreationAction = nullptr;
|
||||
|
||||
if (mainMenu)
|
||||
{
|
||||
createVariablePaletteAction = new QAction(QAction::tr("Create Dynamic Node Range"), mainWindow);
|
||||
createVariablePaletteAction->setAutoRepeat(false);
|
||||
createVariablePaletteAction->setToolTip("Tries to create every node in the node palette with dynamic slots. And will generate variations of the node with variables assigned to each slot in each combination depending on what variables are available in the Variable Manager.");
|
||||
createVariablePaletteAction->setShortcut(QKeySequence(QAction::tr("Ctrl+Shift+k", "Debug|Create Variable Palette")));
|
||||
mainMenu->addSeparator();
|
||||
|
||||
mainWindow->addAction(createVariablePaletteAction);
|
||||
mainWindow->connect(createVariablePaletteAction, &QAction::triggered, &VariablePaletteFullCreationAction);
|
||||
{
|
||||
dynamicSlotFullCreationAction = mainMenu->addAction(QAction::tr("Mass Populate Dynamic Nodes"));
|
||||
dynamicSlotFullCreationAction->setAutoRepeat(false);
|
||||
dynamicSlotFullCreationAction->setToolTip("Tries to create every node in the node palette with dynamic slots.\nAnd will generate variations of the node with variables assigned to each slot in each combination depending on what variables are available in the Variable Manager.");
|
||||
dynamicSlotFullCreationAction->setShortcut(QKeySequence(QAction::tr("Ctrl+Shift+k", "Debug|Create Variable Palette")));
|
||||
|
||||
QObject::connect(dynamicSlotFullCreationAction, &QAction::triggered, &VariablePaletteFullCreationAction);
|
||||
}
|
||||
|
||||
{
|
||||
dynamicSlotFullCreationAction = mainMenu->addAction(QAction::tr("Mass Populate and Connect Dynamic Nodes"));
|
||||
dynamicSlotFullCreationAction->setAutoRepeat(false);
|
||||
dynamicSlotFullCreationAction->setToolTip("Tries to create and connect every node in the node palette with dynamic slots.\nAnd will generate variations of the node with variables assigned to each slot in each combination depending on what variables are available in the Variable Manager.");
|
||||
|
||||
QObject::connect(dynamicSlotFullCreationAction, &QAction::triggered, &VariablePaletteFullyConnectionCreationAction);
|
||||
}
|
||||
}
|
||||
|
||||
return createVariablePaletteAction;
|
||||
return dynamicSlotFullCreationAction;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+247
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
#include <GraphCanvas/Components/GridBus.h>
|
||||
#include <GraphCanvas/Components/Nodes/NodeBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Editor/EditorTypes.h>
|
||||
#include <GraphCanvas/Utils/GraphUtils.h>
|
||||
#include <GraphCanvas/Widgets/GraphCanvasGraphicsView/GraphCanvasGraphicsView.h>
|
||||
#include <GraphCanvas/Widgets/NodePalette/NodePaletteWidget.h>
|
||||
#include <GraphCanvas/Widgets/NodePalette/NodePaletteDockWidget.h>
|
||||
#include <GraphCanvas/Widgets/NodePalette/TreeItems/NodePaletteTreeItem.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
#include <ScriptCanvas/GraphCanvas/NodeDescriptorBus.h>
|
||||
#include <Editor/Include/ScriptCanvas/Bus/NodeIdPair.h>
|
||||
#include <Editor/View/Widgets/NodePalette/CreateNodeMimeEvent.h>
|
||||
#include <Editor/View/Widgets/NodePalette/GeneralNodePaletteTreeItemTypes.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/AutomationActions/NodePaletteFullCreation.h>
|
||||
#include <ScriptCanvasDeveloperEditor/DeveloperUtils.h>
|
||||
|
||||
namespace ScriptCanvasDeveloperEditor
|
||||
{
|
||||
namespace NodePaletteFullCreation
|
||||
{
|
||||
class CreateFullyConnectedNodePaletteInterface
|
||||
: public ProcessNodePaletteInterface
|
||||
{
|
||||
public:
|
||||
|
||||
CreateFullyConnectedNodePaletteInterface(DeveloperUtils::ConnectionStyle connectionStyle, bool skipHandlers = false)
|
||||
{
|
||||
m_chainConfig.m_connectionStyle = connectionStyle;
|
||||
m_chainConfig.m_skipHandlers = skipHandlers;
|
||||
}
|
||||
|
||||
void SetupInterface(const AZ::EntityId& activeGraphCanvasGraphId, const ScriptCanvas::ScriptCanvasId& scriptCanvasId)
|
||||
{
|
||||
m_graphCanvasGraphId = activeGraphCanvasGraphId;
|
||||
m_scriptCanvasId = scriptCanvasId;
|
||||
|
||||
GraphCanvas::SceneRequestBus::EventResult(m_viewId, activeGraphCanvasGraphId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
GraphCanvas::SceneRequestBus::EventResult(m_gridId, activeGraphCanvasGraphId, &GraphCanvas::SceneRequests::GetGrid);
|
||||
|
||||
GraphCanvas::GridRequestBus::EventResult(m_minorPitch, m_gridId, &GraphCanvas::GridRequests::GetMinorPitch);
|
||||
|
||||
QGraphicsScene* graphicsScene = nullptr;
|
||||
GraphCanvas::SceneRequestBus::EventResult(graphicsScene, activeGraphCanvasGraphId, &GraphCanvas::SceneRequests::AsQGraphicsScene);
|
||||
|
||||
if (graphicsScene)
|
||||
{
|
||||
QRectF sceneArea = graphicsScene->sceneRect();
|
||||
sceneArea.adjust(m_minorPitch.GetX(), m_minorPitch.GetY(), -m_minorPitch.GetX(), -m_minorPitch.GetY());
|
||||
GraphCanvas::ViewRequestBus::Event(m_viewId, &GraphCanvas::ViewRequests::CenterOnArea, sceneArea);
|
||||
QApplication::processEvents();
|
||||
}
|
||||
|
||||
GraphCanvas::ViewRequestBus::EventResult(m_nodeCreationPos, m_viewId, &GraphCanvas::ViewRequests::GetViewSceneCenter);
|
||||
|
||||
GraphCanvas::GraphCanvasGraphicsView* graphicsView = nullptr;
|
||||
GraphCanvas::ViewRequestBus::EventResult(graphicsView, m_viewId, &GraphCanvas::ViewRequests::AsGraphicsView);
|
||||
|
||||
m_viewportRectangle = graphicsView->mapToScene(graphicsView->viewport()->geometry()).boundingRect();
|
||||
|
||||
// Temporary work around until the extra automation tools can be merged over that have better ways of doing this.
|
||||
const GraphCanvas::GraphCanvasTreeItem* treeItem = nullptr;
|
||||
ScriptCanvasEditor::AutomationRequestBus::BroadcastResult(treeItem, &ScriptCanvasEditor::AutomationRequests::GetNodePaletteRoot);
|
||||
|
||||
const GraphCanvas::NodePaletteTreeItem* onGraphStartItem = nullptr;
|
||||
|
||||
if (treeItem)
|
||||
{
|
||||
AZStd::unordered_set< const GraphCanvas::GraphCanvasTreeItem* > unexploredSet = { treeItem };
|
||||
|
||||
while (!unexploredSet.empty())
|
||||
{
|
||||
const GraphCanvas::GraphCanvasTreeItem* treeItem = (*unexploredSet.begin());
|
||||
unexploredSet.erase(unexploredSet.begin());
|
||||
|
||||
const GraphCanvas::NodePaletteTreeItem* nodePaletteTreeItem = azrtti_cast<const GraphCanvas::NodePaletteTreeItem*>(treeItem);
|
||||
|
||||
if (nodePaletteTreeItem && nodePaletteTreeItem->GetName().compare("On Graph Start") == 0)
|
||||
{
|
||||
onGraphStartItem = nodePaletteTreeItem;
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < treeItem->GetChildCount(); ++i)
|
||||
{
|
||||
const GraphCanvas::GraphCanvasTreeItem* childItem = treeItem->FindChildByRow(i);
|
||||
|
||||
if (childItem)
|
||||
{
|
||||
unexploredSet.insert(childItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (onGraphStartItem)
|
||||
{
|
||||
ProcessItem(onGraphStartItem);
|
||||
}
|
||||
}
|
||||
|
||||
int m_counter = 60;
|
||||
|
||||
bool ShouldProcessItem(const GraphCanvas::NodePaletteTreeItem* nodePaletteTreeItem) const
|
||||
{
|
||||
return m_counter > 0;
|
||||
}
|
||||
|
||||
void ProcessItem(const GraphCanvas::NodePaletteTreeItem* nodePaletteTreeItem)
|
||||
{
|
||||
GraphCanvas::GraphCanvasMimeEvent* mimeEvent = nodePaletteTreeItem->CreateMimeEvent();
|
||||
|
||||
if (ScriptCanvasEditor::MultiCreateNodeMimeEvent* multiCreateMimeEvent = azrtti_cast<ScriptCanvasEditor::MultiCreateNodeMimeEvent*>(mimeEvent))
|
||||
{
|
||||
--m_counter;
|
||||
AZStd::vector< GraphCanvas::GraphCanvasMimeEvent* > mimeEvents = multiCreateMimeEvent->CreateMimeEvents();
|
||||
|
||||
for (GraphCanvas::GraphCanvasMimeEvent* currentEvent : mimeEvents)
|
||||
{
|
||||
ScriptCanvasEditor::NodeIdPair createdPair = DeveloperUtils::HandleMimeEvent(currentEvent, m_graphCanvasGraphId, m_viewportRectangle, m_widthOffset, m_heightOffset, m_maxRowHeight, m_minorPitch);
|
||||
delete currentEvent;
|
||||
|
||||
if (DeveloperUtils::CreateConnectedChain(createdPair, m_chainConfig))
|
||||
{
|
||||
m_createdNodes.emplace_back(createdPair);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nodesToDelete.insert(GraphCanvas::GraphUtils::FindOutermostNode(createdPair.m_graphCanvasId));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (mimeEvent)
|
||||
{
|
||||
--m_counter;
|
||||
ScriptCanvasEditor::NodeIdPair createdPair = DeveloperUtils::HandleMimeEvent(mimeEvent, m_graphCanvasGraphId, m_viewportRectangle, m_widthOffset, m_heightOffset, m_maxRowHeight, m_minorPitch);
|
||||
|
||||
if (DeveloperUtils::CreateConnectedChain(createdPair, m_chainConfig))
|
||||
{
|
||||
m_createdNodes.emplace_back(createdPair);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nodesToDelete.insert(GraphCanvas::GraphUtils::FindOutermostNode(createdPair.m_graphCanvasId));
|
||||
}
|
||||
}
|
||||
|
||||
delete mimeEvent;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void OnProcessingComplete() override
|
||||
{
|
||||
GraphCanvas::SceneRequestBus::Event(m_graphCanvasGraphId, &GraphCanvas::SceneRequests::Delete, m_nodesToDelete);
|
||||
}
|
||||
|
||||
DeveloperUtils::CreateConnectedChainConfig m_chainConfig;
|
||||
|
||||
AZStd::vector<ScriptCanvasEditor::NodeIdPair> m_createdNodes;
|
||||
AZStd::unordered_set<AZ::EntityId> m_nodesToDelete;
|
||||
|
||||
AZ::EntityId m_graphCanvasGraphId;
|
||||
ScriptCanvas::ScriptCanvasId m_scriptCanvasId;
|
||||
|
||||
AZ::Vector2 m_nodeCreationPos = AZ::Vector2::CreateZero();
|
||||
|
||||
AZ::EntityId m_viewId;
|
||||
AZ::EntityId m_gridId;
|
||||
|
||||
AZ::Vector2 m_minorPitch = AZ::Vector2::CreateZero();
|
||||
|
||||
QRectF m_viewportRectangle;
|
||||
|
||||
int m_widthOffset = 0;
|
||||
int m_heightOffset = 0;
|
||||
|
||||
int m_maxRowHeight = 0;
|
||||
};
|
||||
|
||||
void CreateSingleExecutionConnectedNodePaletteAction()
|
||||
{
|
||||
ScriptCanvasEditor::AutomationRequestBus::Broadcast(&ScriptCanvasEditor::AutomationRequests::SignalAutomationBegin);
|
||||
|
||||
CreateFullyConnectedNodePaletteInterface nodePaletteInterface(DeveloperUtils::ConnectionStyle::SingleExecutionConnection);
|
||||
DeveloperUtils::ProcessNodePalette(nodePaletteInterface);
|
||||
|
||||
ScriptCanvasEditor::AutomationRequestBus::Broadcast(&ScriptCanvasEditor::AutomationRequests::SignalAutomationEnd);
|
||||
}
|
||||
|
||||
void CreateSingleExecutionConnectedNodePaletteExcludeHandlersAction()
|
||||
{
|
||||
ScriptCanvasEditor::AutomationRequestBus::Broadcast(&ScriptCanvasEditor::AutomationRequests::SignalAutomationBegin);
|
||||
|
||||
CreateFullyConnectedNodePaletteInterface nodePaletteInterface(DeveloperUtils::ConnectionStyle::SingleExecutionConnection, true);
|
||||
DeveloperUtils::ProcessNodePalette(nodePaletteInterface);
|
||||
|
||||
ScriptCanvasEditor::AutomationRequestBus::Broadcast(&ScriptCanvasEditor::AutomationRequests::SignalAutomationEnd);
|
||||
}
|
||||
|
||||
QAction* FullyConnectedNodePaletteCreation(QMenu* mainMenu)
|
||||
{
|
||||
QAction* createNodePaletteAction = nullptr;
|
||||
|
||||
if (mainMenu)
|
||||
{
|
||||
{
|
||||
createNodePaletteAction = mainMenu->addAction(QAction::tr("Create Execution Connected Node Palette"));
|
||||
createNodePaletteAction->setAutoRepeat(false);
|
||||
createNodePaletteAction->setToolTip("Tries to create every node in the node palette and will attempt to create an execution path through them.");
|
||||
|
||||
QObject::connect(createNodePaletteAction, &QAction::triggered, &CreateSingleExecutionConnectedNodePaletteAction);
|
||||
}
|
||||
|
||||
{
|
||||
createNodePaletteAction = mainMenu->addAction(QAction::tr("Create Execution Connected Node Palette sans Handlers"));
|
||||
createNodePaletteAction->setAutoRepeat(false);
|
||||
createNodePaletteAction->setToolTip("Tries to create every node in the node palette(except EBus Handlers) and attempt to create an execution path through them..");
|
||||
|
||||
QObject::connect(createNodePaletteAction, &QAction::triggered, &CreateSingleExecutionConnectedNodePaletteExcludeHandlersAction);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return createNodePaletteAction;
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-5
@@ -11,6 +11,8 @@
|
||||
*/
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/GridBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
@@ -109,19 +111,18 @@ namespace ScriptCanvasDeveloperEditor
|
||||
ScriptCanvasEditor::AutomationRequestBus::Broadcast(&ScriptCanvasEditor::AutomationRequests::SignalAutomationEnd);
|
||||
}
|
||||
|
||||
QAction* CreateNodePaletteFullCreationAction(QWidget* mainWindow)
|
||||
QAction* CreateNodePaletteFullCreationAction(QMenu* mainMenu)
|
||||
{
|
||||
QAction* createNodePaletteAction = nullptr;
|
||||
|
||||
if (mainWindow)
|
||||
if (mainMenu)
|
||||
{
|
||||
createNodePaletteAction = new QAction(QAction::tr("Create Node Palette"), mainWindow);
|
||||
createNodePaletteAction = mainMenu->addAction(QAction::tr("Create Node Palette"));
|
||||
createNodePaletteAction->setAutoRepeat(false);
|
||||
createNodePaletteAction->setToolTip("Tries to create every node in the node palette. All of them. At once.");
|
||||
createNodePaletteAction->setShortcut(QKeySequence(QAction::tr("Ctrl+Shift+h", "Debug|Create Node Palette")));
|
||||
|
||||
mainWindow->addAction(createNodePaletteAction);
|
||||
mainWindow->connect(createNodePaletteAction, &QAction::triggered, &NodePaletteFullCreationAction);
|
||||
QObject::connect(createNodePaletteAction, &QAction::triggered, &NodePaletteFullCreationAction);
|
||||
}
|
||||
|
||||
return createNodePaletteAction;
|
||||
|
||||
+6
-5
@@ -11,6 +11,8 @@
|
||||
*/
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/GridBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
@@ -84,19 +86,18 @@ namespace ScriptCanvasDeveloperEditor
|
||||
ScriptCanvasEditor::AutomationRequestBus::Broadcast(&ScriptCanvasEditor::AutomationRequests::SignalAutomationEnd);
|
||||
}
|
||||
|
||||
QAction* CreateVariablePaletteFullCreationAction(QWidget* mainWindow)
|
||||
QAction* CreateVariablePaletteFullCreationAction(QMenu* mainMenu)
|
||||
{
|
||||
QAction* createVariablePaletteAction = nullptr;
|
||||
|
||||
if (mainWindow)
|
||||
if (mainMenu)
|
||||
{
|
||||
createVariablePaletteAction = new QAction(QAction::tr("Create Node Palette"), mainWindow);
|
||||
createVariablePaletteAction = mainMenu->addAction(QAction::tr("Create All Variables"));
|
||||
createVariablePaletteAction->setAutoRepeat(false);
|
||||
createVariablePaletteAction->setToolTip("Tries to create every variable in the variable palette. All of them. At once.");
|
||||
createVariablePaletteAction->setShortcut(QKeySequence(QAction::tr("Ctrl+Shift+j", "Debug|Create Variable Palette")));
|
||||
|
||||
mainWindow->addAction(createVariablePaletteAction);
|
||||
mainWindow->connect(createVariablePaletteAction, &QAction::triggered, &VariablePaletteFullCreationAction);
|
||||
QObject::connect(createVariablePaletteAction, &QAction::triggered, &VariablePaletteFullCreationAction);
|
||||
}
|
||||
|
||||
return createVariablePaletteAction;
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
*/
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/GridBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Nodes/NodeBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Editor/EditorTypes.h>
|
||||
#include <GraphCanvas/Components/Nodes/NodeUIBus.h>
|
||||
@@ -21,6 +22,7 @@
|
||||
#include <Editor/View/Widgets/NodePalette/CreateNodeMimeEvent.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
#include <ScriptCanvas/GraphCanvas/NodeDescriptorBus.h>
|
||||
#include <ScriptCanvas/Variable/VariableBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/DeveloperUtils.h>
|
||||
@@ -72,6 +74,74 @@ namespace ScriptCanvasDeveloperEditor
|
||||
}
|
||||
}
|
||||
|
||||
bool DeveloperUtils::CreateConnectedChain(const ScriptCanvasEditor::NodeIdPair& nodeIdPair, DeveloperUtils::CreateConnectedChainConfig& connectionConfig)
|
||||
{
|
||||
if (connectionConfig.m_connectionStyle == ConnectionStyle::NoConnections)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!nodeIdPair.m_graphCanvasId.IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Crappy work around to ensure we know our 'seeded' element for a random connection
|
||||
if (!connectionConfig.m_fallbackNode.m_graphCanvasId.IsValid())
|
||||
{
|
||||
connectionConfig.m_fallbackNode = nodeIdPair;
|
||||
}
|
||||
|
||||
if (connectionConfig.m_skipHandlers)
|
||||
{
|
||||
AZ::EntityId outermostNode = GraphCanvas::GraphUtils::FindOutermostNode(nodeIdPair.m_graphCanvasId);
|
||||
|
||||
bool isHandler = false;
|
||||
ScriptCanvasEditor::NodeDescriptorRequestBus::EventResult(isHandler, outermostNode, &ScriptCanvasEditor::NodeDescriptorRequests::IsType, ScriptCanvasEditor::NodeDescriptorType::EBusHandler);
|
||||
|
||||
if (isHandler)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Hacky way to deal with finding the InputHandler node.
|
||||
// And the On Graph Start node that we will stumble into in the middle of the node palette as well
|
||||
AZStd::vector< GraphCanvas::SlotId > executionIns;
|
||||
GraphCanvas::NodeRequestBus::EventResult(executionIns, outermostNode, &GraphCanvas::NodeRequests::FindVisibleSlotIdsByType, GraphCanvas::CT_Input, GraphCanvas::SlotTypes::ExecutionSlot);
|
||||
|
||||
if (executionIns.empty() && connectionConfig.m_fallbackNode.m_graphCanvasId != outermostNode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
AZStd::vector< GraphCanvas::SlotId > executionIns;
|
||||
GraphCanvas::NodeRequestBus::EventResult(executionIns, nodeIdPair.m_graphCanvasId, &GraphCanvas::NodeRequests::FindVisibleSlotIdsByType, GraphCanvas::CT_Input, GraphCanvas::SlotTypes::ExecutionSlot);
|
||||
|
||||
if (!executionIns.empty())
|
||||
{
|
||||
GraphCanvas::Endpoint executionIn = GraphCanvas::Endpoint(nodeIdPair.m_graphCanvasId, executionIns.front());
|
||||
|
||||
if (connectionConfig.m_previousEndpoint.IsValid())
|
||||
{
|
||||
if (connectionConfig.m_connectionStyle == ConnectionStyle::SingleExecutionConnection)
|
||||
{
|
||||
GraphCanvas::SlotRequestBus::Event(executionIn.GetSlotId(), &GraphCanvas::SlotRequests::CreateConnectionWithEndpoint, connectionConfig.m_previousEndpoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AZStd::vector< GraphCanvas::SlotId > executionOuts;
|
||||
GraphCanvas::NodeRequestBus::EventResult(executionOuts, nodeIdPair.m_graphCanvasId, &GraphCanvas::NodeRequests::FindVisibleSlotIdsByType, GraphCanvas::CT_Output, GraphCanvas::SlotTypes::ExecutionSlot);
|
||||
|
||||
if (!executionOuts.empty())
|
||||
{
|
||||
connectionConfig.m_previousEndpoint = GraphCanvas::Endpoint(nodeIdPair.m_graphCanvasId, executionOuts.front());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeveloperUtils::ProcessNodePalette(ProcessNodePaletteInterface& processNodePaletteInterface)
|
||||
{
|
||||
AZ::EntityId activeGraphCanvasGraphId;
|
||||
@@ -120,6 +190,8 @@ namespace ScriptCanvasDeveloperEditor
|
||||
}
|
||||
}
|
||||
|
||||
processNodePaletteInterface.OnProcessingComplete();
|
||||
|
||||
ScriptCanvasEditor::GeneralRequestBus::Broadcast(&ScriptCanvasEditor::GeneralRequests::PopPreventUndoStateUpdate);
|
||||
ScriptCanvasEditor::GeneralRequestBus::Broadcast(&ScriptCanvasEditor::GeneralRequests::PostUndoPoint, activeScriptCanvasId);
|
||||
}
|
||||
@@ -151,6 +223,8 @@ namespace ScriptCanvasDeveloperEditor
|
||||
}
|
||||
}
|
||||
|
||||
variablePaletteInterface.OnProcessingComplete();
|
||||
|
||||
ScriptCanvasEditor::GeneralRequestBus::Broadcast(&ScriptCanvasEditor::GeneralRequests::PopPreventUndoStateUpdate);
|
||||
ScriptCanvasEditor::GeneralRequestBus::Broadcast(&ScriptCanvasEditor::GeneralRequests::PostUndoPoint, activeScriptCanvasId);
|
||||
}
|
||||
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QKeyEvent>
|
||||
#include <QtTest/qtest.h>
|
||||
#include <QWidget>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
//////////////////////
|
||||
// SimulateKeyAction
|
||||
//////////////////////
|
||||
|
||||
SimulateKeyAction::SimulateKeyAction(KeyAction keyAction, AZ::u32 keyValue)
|
||||
: m_keyValue(keyValue)
|
||||
, m_keyAction(keyAction)
|
||||
{
|
||||
}
|
||||
|
||||
bool SimulateKeyAction::Tick()
|
||||
{
|
||||
#if defined(AZ_COMPILER_MSVC)
|
||||
INPUT osInput = { 0 };
|
||||
osInput.type = INPUT_KEYBOARD;
|
||||
osInput.ki.wVk = m_keyValue;
|
||||
|
||||
switch (m_keyAction)
|
||||
{
|
||||
case KeyAction::Press:
|
||||
break;
|
||||
case KeyAction::Release:
|
||||
osInput.ki.dwFlags = KEYEVENTF_KEYUP;
|
||||
break;
|
||||
}
|
||||
|
||||
::SendInput(1, &osInput, sizeof(INPUT));
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////////
|
||||
// TypeCharAction
|
||||
///////////////////
|
||||
|
||||
TypeCharAction::TypeCharAction(QChar testCharacter)
|
||||
{
|
||||
#if defined(AZ_COMPILER_MSVC)
|
||||
// This is a. Going to use this to manage most of my elements
|
||||
AZ::u32 aOffset = 0x41;
|
||||
AZ::u32 zeroOffset = 0x30;
|
||||
|
||||
ushort unicodeA = QChar('a').unicode();
|
||||
ushort unicodeZero = QChar('0').unicode();
|
||||
|
||||
if (testCharacter.isLetterOrNumber())
|
||||
{
|
||||
ushort unicodeValue = testCharacter.unicode();
|
||||
|
||||
AZ::u32 offsetStart = 0;
|
||||
ushort difference = 0;
|
||||
|
||||
if (testCharacter.isLetter())
|
||||
{
|
||||
offsetStart = aOffset;
|
||||
difference = unicodeValue - unicodeA;
|
||||
}
|
||||
else if (testCharacter.isNumber())
|
||||
{
|
||||
offsetStart = zeroOffset;
|
||||
difference = unicodeValue - unicodeZero;
|
||||
}
|
||||
|
||||
AZ::u32 finalKey = offsetStart + difference;
|
||||
AddAction(aznew TypeCharAction(finalKey));
|
||||
}
|
||||
else if (testCharacter == QChar(' '))
|
||||
{
|
||||
AddAction(aznew TypeCharAction(VK_SPACE));
|
||||
}
|
||||
else if (testCharacter == QChar('*'))
|
||||
{
|
||||
AddAction(aznew KeyPressAction(VK_SHIFT));
|
||||
AddAction(aznew TypeCharAction(unicodeZero + 8));
|
||||
AddAction(aznew KeyReleaseAction(VK_SHIFT));
|
||||
}
|
||||
else if (testCharacter == QChar('('))
|
||||
{
|
||||
AddAction(aznew KeyPressAction(VK_SHIFT));
|
||||
AddAction(aznew TypeCharAction(unicodeZero + 9));
|
||||
AddAction(aznew KeyReleaseAction(VK_SHIFT));
|
||||
}
|
||||
else if (testCharacter == QChar(')'))
|
||||
{
|
||||
AddAction(aznew KeyPressAction(VK_SHIFT));
|
||||
AddAction(aznew TypeCharAction(unicodeZero + 0));
|
||||
AddAction(aznew KeyReleaseAction(VK_SHIFT));
|
||||
}
|
||||
else if (testCharacter == QChar(':'))
|
||||
{
|
||||
AddAction(aznew KeyPressAction(VK_SHIFT));
|
||||
AddAction(aznew TypeCharAction(VK_OEM_1));
|
||||
AddAction(aznew KeyReleaseAction(VK_SHIFT));
|
||||
}
|
||||
else if (testCharacter == QChar('.'))
|
||||
{
|
||||
AddAction(aznew TypeCharAction(VK_OEM_PERIOD));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
TypeCharAction::TypeCharAction(AZ::u32 keyValue)
|
||||
{
|
||||
AddAction(aznew KeyPressAction(keyValue));
|
||||
AddAction(aznew KeyReleaseAction(keyValue));
|
||||
}
|
||||
|
||||
/////////////////////
|
||||
// TypeStringAction
|
||||
/////////////////////
|
||||
|
||||
TypeStringAction::TypeStringAction(QString targetString)
|
||||
{
|
||||
for (int i = 0; i < targetString.size(); ++i)
|
||||
{
|
||||
QChar testCharacter = targetString.at(i).toLower();
|
||||
AddAction(aznew TypeCharAction(testCharacter));
|
||||
}
|
||||
}
|
||||
}
|
||||
+209
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCursor>
|
||||
#include <QMainWindow>
|
||||
#include <QMouseEvent>
|
||||
#include <QtTest/qtest.h>
|
||||
#include <QWidget>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/GenericActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
//////////////////////////////
|
||||
// SimulateMouseButtonAction
|
||||
//////////////////////////////
|
||||
|
||||
SimulateMouseButtonAction::SimulateMouseButtonAction(MouseAction mouseAction, Qt::MouseButton mouseButton)
|
||||
: m_mouseAction(mouseAction)
|
||||
, m_mouseButton(mouseButton)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SimulateMouseButtonAction::SetTarget(QWidget* targetDispatch)
|
||||
{
|
||||
m_targetDispatch = targetDispatch;
|
||||
}
|
||||
|
||||
bool SimulateMouseButtonAction::Tick()
|
||||
{
|
||||
#if defined(AZ_COMPILER_MSVC)
|
||||
INPUT osInput = { 0 };
|
||||
osInput.type = INPUT_MOUSE;
|
||||
|
||||
osInput.mi.mouseData = 0;
|
||||
osInput.mi.time = 0;
|
||||
|
||||
switch (m_mouseAction)
|
||||
{
|
||||
case MouseAction::Press:
|
||||
switch (m_mouseButton)
|
||||
{
|
||||
case Qt::MouseButton::LeftButton:
|
||||
osInput.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
|
||||
break;
|
||||
case Qt::MouseButton::RightButton:
|
||||
osInput.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MouseAction::Release:
|
||||
switch (m_mouseButton)
|
||||
{
|
||||
case Qt::MouseButton::LeftButton:
|
||||
osInput.mi.dwFlags = MOUSEEVENTF_LEFTUP;
|
||||
break;
|
||||
case Qt::MouseButton::RightButton:
|
||||
osInput.mi.dwFlags = MOUSEEVENTF_RIGHTUP;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
::SendInput(1, &osInput, sizeof(INPUT));
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
/////////////////////
|
||||
// MouseClickAction
|
||||
/////////////////////
|
||||
|
||||
MouseClickAction::MouseClickAction(Qt::MouseButton mouseButton)
|
||||
: CompoundAction()
|
||||
, m_mouseButton(mouseButton)
|
||||
, m_hasFixedTarget(false)
|
||||
{
|
||||
PopulateActionQueue();
|
||||
}
|
||||
|
||||
MouseClickAction::MouseClickAction(Qt::MouseButton mouseButton, QPoint cursorPosition)
|
||||
: CompoundAction()
|
||||
, m_mouseButton(mouseButton)
|
||||
, m_hasFixedTarget(true)
|
||||
, m_cursorPosition(cursorPosition)
|
||||
{
|
||||
PopulateActionQueue();
|
||||
}
|
||||
|
||||
bool MouseClickAction::IsMissingPrecondition()
|
||||
{
|
||||
if (m_hasFixedTarget)
|
||||
{
|
||||
QPoint screenPoint = QCursor::pos();
|
||||
|
||||
// Need to give this a little 'wiggle' room.
|
||||
QRectF clickArea = QRectF(screenPoint, screenPoint);
|
||||
clickArea.adjust(-2, -2, 2, 2);
|
||||
|
||||
return !clickArea.contains(m_cursorPosition);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
EditorAutomationAction* MouseClickAction::GenerateMissingPreconditionAction()
|
||||
{
|
||||
return aznew MouseMoveAction(m_cursorPosition);
|
||||
}
|
||||
|
||||
void MouseClickAction::PopulateActionQueue()
|
||||
{
|
||||
AddAction(aznew DelayAction(AZStd::chrono::milliseconds(500)));
|
||||
AddAction(aznew PressMouseButtonAction(m_mouseButton));
|
||||
AddAction(aznew DelayAction(AZStd::chrono::milliseconds(10)));
|
||||
AddAction(aznew ReleaseMouseButtonAction(m_mouseButton));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// MouseMoveAction
|
||||
////////////////////
|
||||
|
||||
MouseMoveAction::MouseMoveAction(QPoint targetPosition, int ticks)
|
||||
: m_tickDuration(ticks)
|
||||
, m_targetPosition(targetPosition)
|
||||
{
|
||||
}
|
||||
|
||||
void MouseMoveAction::SetupAction()
|
||||
{
|
||||
m_tickCount = 0;
|
||||
m_hasStartPosition = false;
|
||||
}
|
||||
|
||||
bool MouseMoveAction::Tick()
|
||||
{
|
||||
++m_tickCount;
|
||||
|
||||
if (!m_hasStartPosition)
|
||||
{
|
||||
m_startPosition = QCursor::pos();
|
||||
}
|
||||
|
||||
QPointF currentPosition = QCursor::pos();
|
||||
QPointF targetPoint = m_targetPosition;
|
||||
|
||||
float percentage = aznumeric_cast<float>(m_tickCount)/aznumeric_cast<float>(m_tickDuration);
|
||||
|
||||
if (!AZ::IsClose(percentage, 1.0f, AZ::Constants::FloatEpsilon))
|
||||
{
|
||||
int lerpedX = aznumeric_cast<int>((m_targetPosition.x() - m_startPosition.x()) * percentage) + m_startPosition.x();
|
||||
int lerpedY = aznumeric_cast<int>((m_targetPosition.y() - m_startPosition.y()) * percentage) + m_startPosition.y();
|
||||
|
||||
targetPoint = QPointF(lerpedX, lerpedY);
|
||||
}
|
||||
|
||||
#if defined(AZ_COMPILER_MSVC)
|
||||
INPUT osInput = { 0 };
|
||||
|
||||
osInput.type = INPUT_MOUSE;
|
||||
osInput.mi.mouseData = 0;
|
||||
osInput.mi.time = 0;
|
||||
osInput.mi.dx = targetPoint.x() - currentPosition.x();
|
||||
osInput.mi.dy = targetPoint.y() - currentPosition.y();
|
||||
osInput.mi.dwFlags = MOUSEEVENTF_MOVE;
|
||||
|
||||
::SendInput(1, &osInput, sizeof(osInput));
|
||||
#endif
|
||||
|
||||
return AZ::IsClose(percentage, 1.0f, AZ::Constants::FloatEpsilon);
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// MouseDragAction
|
||||
////////////////////
|
||||
|
||||
MouseDragAction::MouseDragAction(QPoint startPosition, QPoint endPosition, Qt::MouseButton holdButton)
|
||||
: m_holdButton(holdButton)
|
||||
, m_startPosition(startPosition)
|
||||
, m_endPosition(endPosition)
|
||||
{
|
||||
AddAction(aznew MouseMoveAction(m_startPosition));
|
||||
AddAction(aznew PressMouseButtonAction(m_holdButton));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
AddAction(aznew MouseMoveAction(m_endPosition));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
AddAction(aznew ReleaseMouseButtonAction(m_holdButton));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
}
|
||||
}
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/GenericActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
///////////////////
|
||||
// CompoundAction
|
||||
///////////////////
|
||||
|
||||
CompoundAction::CompoundAction()
|
||||
{
|
||||
}
|
||||
|
||||
CompoundAction::~CompoundAction()
|
||||
{
|
||||
ClearActionQueue();
|
||||
}
|
||||
|
||||
void CompoundAction::SetupAction()
|
||||
{
|
||||
m_actionRunner.Reset();
|
||||
|
||||
for (EditorAutomationAction* action : m_actionQueue)
|
||||
{
|
||||
m_actionRunner.AddAction(action);
|
||||
}
|
||||
|
||||
m_errorReports.clear();
|
||||
}
|
||||
|
||||
bool CompoundAction::Tick()
|
||||
{
|
||||
if (m_actionRunner.Tick())
|
||||
{
|
||||
m_errorReports = m_actionRunner.GetErrors();
|
||||
OnActionsComplete();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CompoundAction::AddAction(EditorAutomationAction* action)
|
||||
{
|
||||
m_actionQueue.emplace_back(action);
|
||||
}
|
||||
|
||||
ActionReport CompoundAction::GenerateReport() const
|
||||
{
|
||||
if (!m_errorReports.empty())
|
||||
{
|
||||
AZStd::string finalErrorString = "Compound Action Error: ";
|
||||
|
||||
bool firstAdd = false;
|
||||
|
||||
for (ActionReport errorReport : m_errorReports)
|
||||
{
|
||||
if (!firstAdd)
|
||||
{
|
||||
finalErrorString.append(", ");
|
||||
}
|
||||
|
||||
firstAdd = false;
|
||||
|
||||
finalErrorString.append(errorReport.GetError());
|
||||
}
|
||||
|
||||
return AZ::Failure(finalErrorString);
|
||||
}
|
||||
|
||||
return AZ::Success();
|
||||
}
|
||||
|
||||
void CompoundAction::ClearActionQueue()
|
||||
{
|
||||
m_actionRunner.Reset();
|
||||
|
||||
for (EditorAutomationAction* action : m_actionQueue)
|
||||
{
|
||||
delete action;
|
||||
}
|
||||
|
||||
m_actionQueue.clear();
|
||||
|
||||
m_errorReports.clear();
|
||||
}
|
||||
|
||||
////////////////
|
||||
// DelayAction
|
||||
////////////////
|
||||
|
||||
DelayAction::DelayAction(AZStd::chrono::milliseconds delayTime)
|
||||
: m_delay(delayTime)
|
||||
{
|
||||
}
|
||||
|
||||
void DelayAction::SetupAction()
|
||||
{
|
||||
m_startPoint = AZStd::chrono::system_clock::now();
|
||||
}
|
||||
|
||||
bool DelayAction::Tick()
|
||||
{
|
||||
auto currentTime = AZStd::chrono::system_clock::now();
|
||||
|
||||
auto elapsedTime = AZStd::chrono::duration_cast<AZStd::chrono::milliseconds>(currentTime - m_startPoint);
|
||||
|
||||
return elapsedTime >= m_delay;
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
// ProcessUserEventsAction
|
||||
////////////////////////////
|
||||
|
||||
ProcessUserEventsAction::ProcessUserEventsAction(AZStd::chrono::milliseconds delayTime)
|
||||
: DelayAction(delayTime)
|
||||
{
|
||||
}
|
||||
|
||||
void ProcessUserEventsAction::SetupAction()
|
||||
{
|
||||
DelayAction::SetupAction();
|
||||
|
||||
m_delayComplete = false;
|
||||
m_processingComplete = false;
|
||||
m_processingEventsSwitch = false;
|
||||
}
|
||||
|
||||
bool ProcessUserEventsAction::Tick()
|
||||
{
|
||||
if (!m_delayComplete)
|
||||
{
|
||||
m_delayComplete = DelayAction::Tick();
|
||||
}
|
||||
|
||||
if (m_delayComplete && !m_processingEventsSwitch)
|
||||
{
|
||||
m_processingEventsSwitch = true;
|
||||
|
||||
if (!m_processingComplete)
|
||||
{
|
||||
QApplication::processEvents();
|
||||
m_processingComplete = true;
|
||||
}
|
||||
}
|
||||
|
||||
return m_delayComplete && m_processingComplete;
|
||||
}
|
||||
|
||||
///////////////
|
||||
// TraceEvent
|
||||
///////////////
|
||||
|
||||
TraceEvent::TraceEvent(AZStd::string traceName)
|
||||
: m_traceName(traceName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool TraceEvent::Tick()
|
||||
{
|
||||
AZ_TracePrintf("Testing", "TraceEvent::%s", m_traceName.c_str());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+191
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/SlotBus.h>
|
||||
#include <GraphCanvas/Components/ViewBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Editor/AssetEditorBus.h>
|
||||
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ConnectionActions.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
//////////////////////
|
||||
// CoupleNodesAction
|
||||
//////////////////////
|
||||
|
||||
CoupleNodesAction::CoupleNodesAction(GraphCanvas::NodeId nodeToPickUp, GraphCanvas::ConnectionType connectionType, GraphCanvas::NodeId coupleTarget)
|
||||
: m_nodeToPickUp(nodeToPickUp)
|
||||
, m_connectionType(connectionType)
|
||||
, m_targetNode(coupleTarget)
|
||||
{
|
||||
}
|
||||
|
||||
bool CoupleNodesAction::IsMissingPrecondition()
|
||||
{
|
||||
QGraphicsItem* sourceGraphicsItem = nullptr;
|
||||
GraphCanvas::VisualRequestBus::EventResult(sourceGraphicsItem, m_nodeToPickUp, &GraphCanvas::VisualRequests::AsGraphicsItem);
|
||||
|
||||
if (sourceGraphicsItem)
|
||||
{
|
||||
m_pickUpRect = sourceGraphicsItem->sceneBoundingRect();
|
||||
}
|
||||
|
||||
QGraphicsItem* targetGraphicsItem = nullptr;
|
||||
GraphCanvas::VisualRequestBus::EventResult(targetGraphicsItem, m_targetNode, &GraphCanvas::VisualRequests::AsGraphicsItem);
|
||||
|
||||
if (targetGraphicsItem)
|
||||
{
|
||||
m_targetRect = targetGraphicsItem->sceneBoundingRect();
|
||||
}
|
||||
|
||||
m_sceneRect = m_pickUpRect;
|
||||
m_sceneRect |= m_targetRect;
|
||||
|
||||
// Provide some extra spacing just to provide some safety
|
||||
m_sceneRect = m_sceneRect.adjusted(-m_sceneRect.width() * 0.25f, -m_sceneRect.height() * 0.25f, m_sceneRect.width() * 0.25f, m_sceneRect.height() * 0.25f);
|
||||
|
||||
GraphCanvas::GraphId graphId;
|
||||
GraphCanvas::SceneMemberRequestBus::EventResult(graphId, m_nodeToPickUp, &GraphCanvas::SceneMemberRequests::GetScene);
|
||||
|
||||
GraphCanvas::ViewId viewId;
|
||||
GraphCanvas::SceneRequestBus::EventResult(viewId, graphId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
|
||||
QRectF viewableArea;
|
||||
GraphCanvas::ViewRequestBus::EventResult(viewableArea, viewId, &GraphCanvas::ViewRequests::GetViewableAreaInSceneCoordinates);
|
||||
|
||||
return !viewableArea.contains(m_sceneRect);
|
||||
}
|
||||
|
||||
EditorAutomationAction* CoupleNodesAction::GenerateMissingPreconditionAction()
|
||||
{
|
||||
GraphCanvas::GraphId graphId;
|
||||
GraphCanvas::SceneMemberRequestBus::EventResult(graphId, m_nodeToPickUp, &GraphCanvas::SceneMemberRequests::GetScene);
|
||||
|
||||
return aznew EnsureSceneRectVisibleAction(graphId, m_sceneRect);
|
||||
}
|
||||
|
||||
AZStd::vector< GraphCanvas::ConnectionId > CoupleNodesAction::GetConnectionIds() const
|
||||
{
|
||||
return m_connections;
|
||||
}
|
||||
|
||||
void CoupleNodesAction::OnConnectionAdded(const AZ::EntityId& connectionId)
|
||||
{
|
||||
m_connections.emplace_back(connectionId);
|
||||
}
|
||||
|
||||
void CoupleNodesAction::SetupAction()
|
||||
{
|
||||
ClearActionQueue();
|
||||
|
||||
QPointF mouseStartPoint = QPointF(m_pickUpRect.center().x(), m_pickUpRect.top() + 5);
|
||||
|
||||
GraphCanvas::GraphId graphId;
|
||||
GraphCanvas::SceneMemberRequestBus::EventResult(graphId, m_nodeToPickUp, &GraphCanvas::SceneMemberRequests::GetScene);
|
||||
|
||||
GraphCanvas::ViewId viewId;
|
||||
GraphCanvas::SceneRequestBus::EventResult(viewId, graphId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
|
||||
GraphCanvas::ViewRequests* viewRequests = GraphCanvas::ViewRequestBus::FindFirstHandler(viewId);
|
||||
|
||||
if (viewRequests)
|
||||
{
|
||||
QPoint initialMousePosition = GraphCanvas::ConversionUtils::AZToQPoint(viewRequests->MapToGlobal(GraphCanvas::ConversionUtils::QPointToVector(mouseStartPoint))).toPoint();
|
||||
AddAction(aznew MouseMoveAction(initialMousePosition));
|
||||
AddAction(aznew PressMouseButtonAction(Qt::MouseButton::LeftButton));
|
||||
|
||||
QPointF targetPoint = m_targetRect.center();
|
||||
QPointF startPoint = m_pickUpRect.center();
|
||||
|
||||
// Depending on which side of the pick-up node we want to connect, we need to target a different edge of the target node.
|
||||
if (m_connectionType == GraphCanvas::ConnectionType::CT_Input)
|
||||
{
|
||||
targetPoint = QPointF(m_targetRect.right(), targetPoint.y());
|
||||
}
|
||||
else if (m_connectionType == GraphCanvas::ConnectionType::CT_Output)
|
||||
{
|
||||
targetPoint = QPointF(m_targetRect.left(), targetPoint.y());
|
||||
}
|
||||
|
||||
QPointF lineDelta = QPointF(targetPoint.x() - startPoint.x(), targetPoint.y() - startPoint.y());
|
||||
|
||||
QPointF targetMousePosition = QPointF(mouseStartPoint.x() + lineDelta.x(), mouseStartPoint.y() + lineDelta.y());
|
||||
|
||||
AddAction(aznew MouseMoveAction(GraphCanvas::ConversionUtils::AZToQPoint(viewRequests->MapToGlobal(GraphCanvas::ConversionUtils::QPointToVector(targetMousePosition))).toPoint()));
|
||||
|
||||
GraphCanvas::EditorId editorId;
|
||||
GraphCanvas::SceneRequestBus::EventResult(editorId, graphId, &GraphCanvas::SceneRequests::GetEditorId);
|
||||
|
||||
AZStd::chrono::milliseconds coupleDuration;
|
||||
GraphCanvas::AssetEditorSettingsRequestBus::EventResult(coupleDuration, editorId, &GraphCanvas::AssetEditorSettingsRequests::GetDragCouplingTime);
|
||||
|
||||
// Double the couple duration to be safe.
|
||||
coupleDuration = coupleDuration + coupleDuration;
|
||||
|
||||
AddAction(aznew DelayAction(coupleDuration));
|
||||
AddAction(aznew MouseMoveAction(initialMousePosition));
|
||||
AddAction(aznew ReleaseMouseButtonAction(Qt::MouseButton::LeftButton));
|
||||
AddAction(aznew DelayAction(AZStd::chrono::milliseconds(250)));
|
||||
}
|
||||
|
||||
m_connections.clear();
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusConnect(graphId);
|
||||
|
||||
CompoundAction::SetupAction();
|
||||
}
|
||||
|
||||
void CoupleNodesAction::OnActionsComplete()
|
||||
{
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
// ConnectEndpointsAction
|
||||
///////////////////////////
|
||||
|
||||
ConnectEndpointsAction::ConnectEndpointsAction(GraphCanvas::Endpoint startEndpoint, GraphCanvas::Endpoint targetEndpoint)
|
||||
: m_startEndpoint(startEndpoint)
|
||||
, m_targetEndpoint(targetEndpoint)
|
||||
{
|
||||
QPointF startScenePoint;
|
||||
GraphCanvas::SlotUIRequestBus::EventResult(startScenePoint, startEndpoint.m_slotId, &GraphCanvas::SlotUIRequests::GetPinCenter);
|
||||
|
||||
QPointF targetScenePoint;
|
||||
GraphCanvas::SlotUIRequestBus::EventResult(targetScenePoint, targetEndpoint.m_slotId, &GraphCanvas::SlotUIRequests::GetPinCenter);
|
||||
|
||||
GraphCanvas::GraphId graphId;
|
||||
GraphCanvas::SceneMemberRequestBus::EventResult(graphId, startEndpoint.m_nodeId, &GraphCanvas::SceneMemberRequests::GetScene);
|
||||
|
||||
AddAction(aznew SceneMouseDragAction(graphId, startScenePoint, targetScenePoint, Qt::MouseButton::LeftButton));
|
||||
}
|
||||
|
||||
GraphCanvas::ConnectionId ConnectEndpointsAction::GetConnectionId() const
|
||||
{
|
||||
return m_connectionId;
|
||||
}
|
||||
|
||||
void ConnectEndpointsAction::OnActionsComplete()
|
||||
{
|
||||
GraphCanvas::SlotRequestBus::EventResult(m_connectionId, m_startEndpoint.GetSlotId(), &GraphCanvas::SlotRequests::GetLastConnection);
|
||||
}
|
||||
}
|
||||
+761
@@ -0,0 +1,761 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <QToolButton>
|
||||
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/SlotBus.h>
|
||||
#include <GraphCanvas/Components/Slots/Data/DataSlotBus.h>
|
||||
#include <GraphCanvas/Components/ViewBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Editor/AssetEditorBus.h>
|
||||
#include <GraphCanvas/Editor/Automation/AutomationIds.h>
|
||||
#include <GraphCanvas/Editor/Automation/AutomationUtils.h>
|
||||
|
||||
#include <GraphCanvas/Widgets/NodePalette/Model/NodePaletteSortFilterProxyModel.h>
|
||||
#include <GraphCanvas/Widgets/NodePalette/NodePaletteTreeView.h>
|
||||
#include <GraphCanvas/Widgets/NodePalette/TreeItems/NodePaletteTreeItem.h>
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
#include <Editor/View/Widgets/VariablePanel/VariableDockWidget.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
#include <ScriptCanvas/GraphCanvas/NodeDescriptorBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/CreateElementsActions.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/WidgetActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
////////////////////////////////
|
||||
// CreateNodeFromPaletteAction
|
||||
////////////////////////////////
|
||||
|
||||
CreateNodeFromPaletteAction::CreateNodeFromPaletteAction(GraphCanvas::NodePaletteWidget* paletteWidget, GraphCanvas::GraphId graphId, QString nodeName, QPointF scenePoint)
|
||||
: m_graphId(graphId)
|
||||
, m_scenePoint(scenePoint)
|
||||
, m_nodeName(nodeName)
|
||||
, m_paletteWidget(paletteWidget)
|
||||
{
|
||||
}
|
||||
|
||||
CreateNodeFromPaletteAction::CreateNodeFromPaletteAction(GraphCanvas::NodePaletteWidget* paletteWidget, GraphCanvas::GraphId graphId, QString nodeName, GraphCanvas::ConnectionId connectionId)
|
||||
: m_spliceTarget(connectionId)
|
||||
, m_graphId(graphId)
|
||||
, m_nodeName(nodeName)
|
||||
, m_paletteWidget(paletteWidget)
|
||||
{
|
||||
if (GraphCanvas::GraphUtils::IsConnection(connectionId))
|
||||
{
|
||||
QPainterPath outlinePath;
|
||||
GraphCanvas::SceneMemberUIRequestBus::EventResult(outlinePath, connectionId, &GraphCanvas::SceneMemberUIRequests::GetOutline);
|
||||
|
||||
m_scenePoint = outlinePath.pointAtPercent(0.5);
|
||||
|
||||
GraphCanvas::ConnectionRequestBus::EventResult(m_sourceEndpoint, connectionId, &GraphCanvas::ConnectionRequests::GetSourceEndpoint);
|
||||
GraphCanvas::ConnectionRequestBus::EventResult(m_targetEndpoint, connectionId, &GraphCanvas::ConnectionRequests::GetTargetEndpoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_scenePoint = QPointF(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
bool CreateNodeFromPaletteAction::IsMissingPrecondition()
|
||||
{
|
||||
if (!m_centerOnScene && !m_writeToSearchFilter)
|
||||
{
|
||||
GraphCanvas::ViewId viewId;
|
||||
GraphCanvas::SceneRequestBus::EventResult(viewId, m_graphId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
|
||||
AZ::Vector2 viewCenter;
|
||||
GraphCanvas::ViewRequestBus::EventResult(viewCenter, viewId, &GraphCanvas::ViewRequests::GetViewSceneCenter);
|
||||
|
||||
QRectF viewRect = QRectF(GraphCanvas::ConversionUtils::AZToQPoint(viewCenter), GraphCanvas::ConversionUtils::AZToQPoint(viewCenter));
|
||||
viewRect.adjust(-2, -2, 2, 2);
|
||||
|
||||
m_centerOnScene = !viewRect.contains(m_scenePoint);
|
||||
m_writeToSearchFilter = (m_paletteWidget->GetSearchFilter()->text().compare(m_nodeName, Qt::CaseInsensitive) != 0);
|
||||
|
||||
return m_centerOnScene || m_writeToSearchFilter;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
EditorAutomationAction* CreateNodeFromPaletteAction::GenerateMissingPreconditionAction()
|
||||
{
|
||||
CompoundAction* compoundAction = aznew CompoundAction();
|
||||
|
||||
if (m_centerOnScene)
|
||||
{
|
||||
compoundAction->AddAction(aznew CenterOnScenePointAction(m_graphId, m_scenePoint));
|
||||
}
|
||||
|
||||
if (m_writeToSearchFilter)
|
||||
{
|
||||
compoundAction->AddAction(aznew WriteToLineEditAction(m_paletteWidget->GetSearchFilter(), m_nodeName));
|
||||
#if defined(AZ_COMPILER_MSVC)
|
||||
compoundAction->AddAction(aznew TypeCharAction(VK_RETURN));
|
||||
#endif
|
||||
compoundAction->AddAction(aznew DelayAction(AZStd::chrono::milliseconds(400)));
|
||||
}
|
||||
|
||||
return compoundAction;
|
||||
}
|
||||
|
||||
void CreateNodeFromPaletteAction::SetupAction()
|
||||
{
|
||||
ClearActionQueue();
|
||||
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusConnect(m_graphId);
|
||||
m_createdNodeId.SetInvalid();
|
||||
|
||||
GraphCanvas::GraphCanvasTreeItem* paletteItem = m_paletteWidget->FindItemWithName(m_nodeName);
|
||||
|
||||
if (paletteItem)
|
||||
{
|
||||
QModelIndex modelIndex = paletteItem->GetIndexFromModel();
|
||||
|
||||
GraphCanvas::NodePaletteSortFilterProxyModel* proxyModel = m_paletteWidget->GetFilterModel();
|
||||
QModelIndex filteredParentIndex = proxyModel->mapFromSource(paletteItem->GetParent()->GetIndexFromModel());
|
||||
QModelIndex filteredElementIndex = proxyModel->mapFromSource(modelIndex);
|
||||
|
||||
AddAction(aznew MoveMouseToViewRowAction(m_paletteWidget->GetTreeView(), filteredElementIndex.row(), filteredParentIndex));
|
||||
AddAction(aznew PressMouseButtonAction(Qt::MouseButton::LeftButton));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
|
||||
GraphCanvas::ViewId viewId;
|
||||
GraphCanvas::SceneRequestBus::EventResult(viewId, m_graphId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
|
||||
AZ::Vector2 screenPoint;
|
||||
GraphCanvas::ViewRequestBus::EventResult(screenPoint, viewId, &GraphCanvas::ViewRequests::MapToGlobal, GraphCanvas::ConversionUtils::QPointToVector(m_scenePoint));
|
||||
|
||||
AddAction(aznew MouseMoveAction(GraphCanvas::ConversionUtils::AZToQPoint(screenPoint).toPoint()));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
|
||||
// If we are splicing, we need to hold a little bit before we release the button.
|
||||
if (m_spliceTarget.IsValid())
|
||||
{
|
||||
AZStd::chrono::milliseconds connectionDelay;
|
||||
GraphCanvas::AssetEditorSettingsRequestBus::EventResult(connectionDelay, ScriptCanvasEditor::AssetEditorId, &GraphCanvas::AssetEditorSettingsRequests::GetDropConnectionSpliceTime);
|
||||
|
||||
// Give it some buffer room on the delay before we release.
|
||||
connectionDelay = connectionDelay + connectionDelay * 0.5f;
|
||||
|
||||
AddAction(aznew ProcessUserEventsAction(connectionDelay));
|
||||
}
|
||||
|
||||
AddAction(aznew ReleaseMouseButtonAction(Qt::MouseButton::LeftButton));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
AddAction(aznew MouseMoveAction(GraphCanvas::ConversionUtils::AZToQPoint(screenPoint + AZ::Vector2(1,1)).toPoint()));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
}
|
||||
|
||||
CompoundAction::SetupAction();
|
||||
}
|
||||
|
||||
GraphCanvas::NodeId CreateNodeFromPaletteAction::GetCreatedNodeId() const
|
||||
{
|
||||
return GraphCanvas::GraphUtils::FindOutermostNode(m_createdNodeId);
|
||||
}
|
||||
|
||||
void CreateNodeFromPaletteAction::OnNodeAdded(const AZ::EntityId& nodeId, bool)
|
||||
{
|
||||
if (!m_createdNodeId.IsValid())
|
||||
{
|
||||
m_createdNodeId = nodeId;
|
||||
}
|
||||
}
|
||||
|
||||
ActionReport CreateNodeFromPaletteAction::GenerateReport() const
|
||||
{
|
||||
if (!m_createdNodeId.IsValid())
|
||||
{
|
||||
return AZ::Failure<AZStd::string>(AZStd::string::format("Failed to create %s", m_nodeName.toUtf8().data()));
|
||||
}
|
||||
else if (m_spliceTarget.IsValid())
|
||||
{
|
||||
GraphCanvas::NodeId nodeId = GetCreatedNodeId();
|
||||
|
||||
GraphCanvas::ConnectionId connectionId;
|
||||
GraphCanvas::SlotRequestBus::EventResult(connectionId, m_sourceEndpoint.m_slotId, &GraphCanvas::SlotRequests::GetLastConnection);
|
||||
|
||||
GraphCanvas::Endpoint otherEndpoint;
|
||||
GraphCanvas::ConnectionRequestBus::EventResult(otherEndpoint, connectionId, &GraphCanvas::ConnectionRequests::FindOtherEndpoint, m_sourceEndpoint);
|
||||
|
||||
if (!otherEndpoint.IsValid()
|
||||
|| otherEndpoint.GetNodeId() != nodeId)
|
||||
{
|
||||
return AZ::Failure<AZStd::string>(AZStd::string::format("Spliced connection failed to create connection from source Endpoint to %s node", m_nodeName.toUtf8().data()));
|
||||
}
|
||||
|
||||
connectionId.SetInvalid();
|
||||
GraphCanvas::SlotRequestBus::EventResult(connectionId, m_targetEndpoint.m_slotId, &GraphCanvas::SlotRequests::GetLastConnection);
|
||||
|
||||
otherEndpoint = GraphCanvas::Endpoint();
|
||||
GraphCanvas::ConnectionRequestBus::EventResult(otherEndpoint, connectionId, &GraphCanvas::ConnectionRequests::FindOtherEndpoint, m_targetEndpoint);
|
||||
|
||||
if (!otherEndpoint.IsValid()
|
||||
|| otherEndpoint.GetNodeId() != nodeId)
|
||||
{
|
||||
return AZ::Failure<AZStd::string>(AZStd::string::format("Spliced connection failed to create connection from target Endpoint to %s node", m_nodeName.toUtf8().data()));
|
||||
}
|
||||
}
|
||||
|
||||
return CompoundAction::GenerateReport();
|
||||
}
|
||||
|
||||
void CreateNodeFromPaletteAction::OnActionsComplete()
|
||||
{
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusDisconnect();
|
||||
|
||||
m_centerOnScene = false;
|
||||
m_writeToSearchFilter = false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
// CreateCategoryFromNodePaletteAction
|
||||
////////////////////////////////////////
|
||||
|
||||
CreateCategoryFromNodePaletteAction::CreateCategoryFromNodePaletteAction(GraphCanvas::NodePaletteWidget* paletteWidget, GraphCanvas::GraphId graphId, QString category, QPointF scenePoint)
|
||||
: m_graphId(graphId)
|
||||
, m_scenePoint(scenePoint)
|
||||
, m_categoryName(category)
|
||||
, m_paletteWidget(paletteWidget)
|
||||
{
|
||||
}
|
||||
|
||||
bool CreateCategoryFromNodePaletteAction::IsMissingPrecondition()
|
||||
{
|
||||
return m_paletteWidget->GetSearchFilter()->text().compare(m_categoryName, Qt::CaseInsensitive) != 0;
|
||||
}
|
||||
|
||||
EditorAutomationAction* CreateCategoryFromNodePaletteAction::GenerateMissingPreconditionAction()
|
||||
{
|
||||
CompoundAction* compoundAction = aznew CompoundAction();
|
||||
|
||||
compoundAction->AddAction(aznew WriteToLineEditAction(m_paletteWidget->GetSearchFilter(), m_categoryName));
|
||||
#if defined(AZ_COMPILER_MSVC)
|
||||
compoundAction->AddAction(aznew TypeCharAction(VK_RETURN));
|
||||
#endif
|
||||
compoundAction->AddAction(aznew ProcessUserEventsAction());
|
||||
|
||||
return compoundAction;
|
||||
}
|
||||
|
||||
void CreateCategoryFromNodePaletteAction::SetupAction()
|
||||
{
|
||||
ClearActionQueue();
|
||||
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusConnect(m_graphId);
|
||||
|
||||
GraphCanvas::GraphCanvasTreeItem* rootItem = m_paletteWidget->FindItemWithName(m_categoryName);
|
||||
|
||||
AZStd::vector<AZStd::pair<int, QModelIndex>> creationIndexes;
|
||||
|
||||
if (rootItem)
|
||||
{
|
||||
AZStd::unordered_set< GraphCanvas::GraphCanvasTreeItem* > unexploredItems = { rootItem };
|
||||
|
||||
while (!unexploredItems.empty())
|
||||
{
|
||||
GraphCanvas::GraphCanvasTreeItem* currentItem = (*unexploredItems.begin());
|
||||
unexploredItems.erase(unexploredItems.begin());
|
||||
|
||||
if (currentItem)
|
||||
{
|
||||
if (currentItem->GetChildCount() == 0)
|
||||
{
|
||||
QModelIndex currentRow = m_paletteWidget->GetFilterModel()->mapFromSource(currentItem->GetIndexFromModel());
|
||||
QModelIndex parentIndex = m_paletteWidget->GetFilterModel()->mapFromSource(currentItem->GetParent()->GetIndexFromModel());
|
||||
|
||||
if (currentRow.isValid() && parentIndex.isValid())
|
||||
{
|
||||
creationIndexes.emplace_back(currentRow.row(), parentIndex);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < currentItem->GetChildCount(); ++i)
|
||||
{
|
||||
unexploredItems.insert(currentItem->FindChildByRow(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_expectedCreations = aznumeric_cast<int>(creationIndexes.size());
|
||||
|
||||
for (int i = 0; i < creationIndexes.size(); ++i)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
#if defined(AZ_COMPILER_MSVC)
|
||||
AddAction(aznew KeyPressAction(VK_CONTROL));
|
||||
#endif
|
||||
}
|
||||
|
||||
const auto& creationPair = creationIndexes[i];
|
||||
|
||||
AddAction(aznew MoveMouseToViewRowAction(m_paletteWidget->GetTreeView(), creationPair.first, creationPair.second));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
|
||||
if (i + 1 >= creationIndexes.size())
|
||||
{
|
||||
AddAction(aznew PressMouseButtonAction(Qt::MouseButton::LeftButton));
|
||||
}
|
||||
else
|
||||
{
|
||||
AddAction(aznew MouseClickAction(Qt::MouseButton::LeftButton));
|
||||
}
|
||||
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
}
|
||||
|
||||
GraphCanvas::ViewId viewId;
|
||||
GraphCanvas::SceneRequestBus::EventResult(viewId, m_graphId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
|
||||
AZ::Vector2 screenPoint;
|
||||
GraphCanvas::ViewRequestBus::EventResult(screenPoint, viewId, &GraphCanvas::ViewRequests::MapToGlobal, GraphCanvas::ConversionUtils::QPointToVector(m_scenePoint));
|
||||
|
||||
AddAction(aznew MouseMoveAction(GraphCanvas::ConversionUtils::AZToQPoint(screenPoint).toPoint()));
|
||||
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
|
||||
AddAction(aznew ReleaseMouseButtonAction(Qt::MouseButton::LeftButton));
|
||||
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
|
||||
AddAction(aznew MouseMoveAction(GraphCanvas::ConversionUtils::AZToQPoint(screenPoint + AZ::Vector2(1, 1)).toPoint()));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
|
||||
#if defined(AZ_COMPILER_MSVC)
|
||||
AddAction(aznew KeyReleaseAction(VK_CONTROL));
|
||||
#endif
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
}
|
||||
|
||||
CompoundAction::SetupAction();
|
||||
}
|
||||
|
||||
void CreateCategoryFromNodePaletteAction::OnNodeAdded(const AZ::EntityId& nodeId, bool)
|
||||
{
|
||||
m_createdNodeIds.emplace_back(nodeId);
|
||||
}
|
||||
|
||||
AZStd::vector< GraphCanvas::NodeId > CreateCategoryFromNodePaletteAction::GetCreatedNodes() const
|
||||
{
|
||||
return m_createdNodeIds;
|
||||
}
|
||||
|
||||
void CreateCategoryFromNodePaletteAction::OnActionsComplete()
|
||||
{
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusDisconnect();
|
||||
|
||||
AZStd::vector< GraphCanvas::NodeId > nodes = m_createdNodeIds;
|
||||
AZStd::unordered_set< GraphCanvas::NodeId > rootNodes;
|
||||
|
||||
m_createdNodeIds.clear();
|
||||
|
||||
for (GraphCanvas::NodeId nodeId : nodes)
|
||||
{
|
||||
GraphCanvas::NodeId outermostNode = GraphCanvas::GraphUtils::FindOutermostNode(nodeId);
|
||||
rootNodes.insert(outermostNode);
|
||||
}
|
||||
|
||||
m_createdNodeIds.insert(m_createdNodeIds.begin(), rootNodes.begin(), rootNodes.end());
|
||||
}
|
||||
|
||||
ActionReport CreateCategoryFromNodePaletteAction::GenerateReport() const
|
||||
{
|
||||
if (m_createdNodeIds.size() != m_expectedCreations)
|
||||
{
|
||||
return AZ::Failure<AZStd::string>(AZStd::string::format("Failed to create all nodes. %i expected, %i created", aznumeric_cast<int>(m_createdNodeIds.size()), m_expectedCreations));
|
||||
}
|
||||
|
||||
return CompoundAction::GenerateReport();
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
// CreateNodeFromContextMenuAction
|
||||
////////////////////////////////////
|
||||
|
||||
CreateNodeFromContextMenuAction::CreateNodeFromContextMenuAction(GraphCanvas::GraphId graphId, QString nodeName, QPointF scenePoint)
|
||||
: m_graphId(graphId)
|
||||
, m_scenePoint(scenePoint)
|
||||
, m_nodeName(nodeName)
|
||||
{
|
||||
}
|
||||
|
||||
CreateNodeFromContextMenuAction::CreateNodeFromContextMenuAction(GraphCanvas::GraphId graphId, QString nodeName, AZ::EntityId connectionId)
|
||||
: m_graphId(graphId)
|
||||
, m_nodeName(nodeName)
|
||||
{
|
||||
if (GraphCanvas::GraphUtils::IsConnection(connectionId))
|
||||
{
|
||||
QPainterPath outlinePath;
|
||||
GraphCanvas::SceneMemberUIRequestBus::EventResult(outlinePath, connectionId, &GraphCanvas::SceneMemberUIRequests::GetOutline);
|
||||
|
||||
m_scenePoint = outlinePath.pointAtPercent(0.5);
|
||||
|
||||
m_spliceTarget = connectionId;
|
||||
|
||||
GraphCanvas::ConnectionRequestBus::EventResult(m_sourceEndpoint, connectionId, &GraphCanvas::ConnectionRequests::GetSourceEndpoint);
|
||||
GraphCanvas::ConnectionRequestBus::EventResult(m_targetEndpoint, connectionId, &GraphCanvas::ConnectionRequests::GetTargetEndpoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_scenePoint = QPointF(0,0);
|
||||
}
|
||||
}
|
||||
|
||||
bool CreateNodeFromContextMenuAction::IsMissingPrecondition()
|
||||
{
|
||||
return m_centerOnScene;
|
||||
}
|
||||
|
||||
EditorAutomationAction* CreateNodeFromContextMenuAction::GenerateMissingPreconditionAction()
|
||||
{
|
||||
m_centerOnScene = false;
|
||||
|
||||
return aznew CenterOnScenePointAction(m_graphId, m_scenePoint);
|
||||
}
|
||||
|
||||
void CreateNodeFromContextMenuAction::SetupAction()
|
||||
{
|
||||
ClearActionQueue();
|
||||
|
||||
m_createdNodeId.SetInvalid();
|
||||
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusConnect(m_graphId);
|
||||
|
||||
GraphCanvas::ViewId viewId;
|
||||
GraphCanvas::SceneRequestBus::EventResult(viewId, m_graphId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
|
||||
AZ::Vector2 screenPoint;
|
||||
GraphCanvas::ViewRequestBus::EventResult(screenPoint, viewId, &GraphCanvas::ViewRequests::MapToGlobal, GraphCanvas::ConversionUtils::QPointToVector(m_scenePoint));
|
||||
|
||||
AddAction(aznew MouseMoveAction(GraphCanvas::ConversionUtils::AZToQPoint(screenPoint).toPoint()));
|
||||
|
||||
AddAction(aznew MouseClickAction(Qt::MouseButton::RightButton));
|
||||
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
|
||||
AddAction(aznew TypeStringAction(m_nodeName));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
#if defined(AZ_COMPILER_MSVC)
|
||||
AddAction(aznew TypeCharAction(VK_RETURN));
|
||||
#endif
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
|
||||
CompoundAction::SetupAction();
|
||||
}
|
||||
|
||||
void CreateNodeFromContextMenuAction::OnNodeAdded(const AZ::EntityId& nodeId, bool)
|
||||
{
|
||||
m_createdNodeId = nodeId;
|
||||
}
|
||||
|
||||
AZ::EntityId CreateNodeFromContextMenuAction::GetCreatedNodeId() const
|
||||
{
|
||||
return m_createdNodeId;
|
||||
}
|
||||
|
||||
void CreateNodeFromContextMenuAction::OnActionsComplete()
|
||||
{
|
||||
m_createdNodeId = GraphCanvas::GraphUtils::FindOutermostNode(m_createdNodeId);
|
||||
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusDisconnect();
|
||||
|
||||
m_centerOnScene = true;
|
||||
}
|
||||
|
||||
ActionReport CreateNodeFromContextMenuAction::GenerateReport() const
|
||||
{
|
||||
if (!m_createdNodeId.IsValid())
|
||||
{
|
||||
return AZ::Failure<AZStd::string>(AZStd::string::format("Failed to create Node %s.", m_nodeName.toUtf8().data()));
|
||||
}
|
||||
else if (m_spliceTarget.IsValid())
|
||||
{
|
||||
GraphCanvas::NodeId nodeId = GetCreatedNodeId();
|
||||
|
||||
GraphCanvas::ConnectionId connectionId;
|
||||
GraphCanvas::SlotRequestBus::EventResult(connectionId, m_sourceEndpoint.m_slotId, &GraphCanvas::SlotRequests::GetLastConnection);
|
||||
|
||||
GraphCanvas::Endpoint otherEndpoint;
|
||||
GraphCanvas::ConnectionRequestBus::EventResult(otherEndpoint, connectionId, &GraphCanvas::ConnectionRequests::FindOtherEndpoint, m_sourceEndpoint);
|
||||
|
||||
if (!otherEndpoint.IsValid()
|
||||
|| otherEndpoint.GetNodeId() != nodeId)
|
||||
{
|
||||
return AZ::Failure<AZStd::string>(AZStd::string::format("Spliced connection failed to create connection from source Endpoint to %s node", m_nodeName.toUtf8().data()));
|
||||
}
|
||||
|
||||
connectionId.SetInvalid();
|
||||
GraphCanvas::SlotRequestBus::EventResult(connectionId, m_targetEndpoint.m_slotId, &GraphCanvas::SlotRequests::GetLastConnection);
|
||||
|
||||
otherEndpoint = GraphCanvas::Endpoint();
|
||||
GraphCanvas::ConnectionRequestBus::EventResult(otherEndpoint, connectionId, &GraphCanvas::ConnectionRequests::FindOtherEndpoint, m_targetEndpoint);
|
||||
|
||||
if (!otherEndpoint.IsValid()
|
||||
|| otherEndpoint.GetNodeId() != nodeId)
|
||||
{
|
||||
return AZ::Failure<AZStd::string>(AZStd::string::format("Spliced connection failed to create connection from target Endpoint to %s node", m_nodeName.toUtf8().data()));
|
||||
}
|
||||
}
|
||||
|
||||
return CompoundAction::GenerateReport();
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
// CreateNodeFromProposalAction
|
||||
/////////////////////////////////
|
||||
|
||||
CreateNodeFromProposalAction::CreateNodeFromProposalAction(GraphCanvas::GraphId graphId, GraphCanvas::Endpoint endpoint, QString nodeName)
|
||||
: m_graphId(graphId)
|
||||
, m_endpoint(endpoint)
|
||||
, m_nodeName(nodeName)
|
||||
{
|
||||
AZ::Vector2 stepSize = GraphCanvas::GraphUtils::FindMinorStep(graphId);
|
||||
|
||||
GraphCanvas::SlotUIRequestBus::EventResult(m_scenePoint, m_endpoint.GetSlotId(), &GraphCanvas::SlotUIRequests::GetConnectionPoint);
|
||||
|
||||
QPointF jutDirection;
|
||||
GraphCanvas::SlotUIRequestBus::EventResult(jutDirection, m_endpoint.GetSlotId(), &GraphCanvas::SlotUIRequests::GetJutDirection);
|
||||
|
||||
AZ::Vector2 stepDirection = AZ::Vector2::CreateZero();
|
||||
|
||||
stepDirection.SetX(jutDirection.x() * stepSize.GetX());
|
||||
stepDirection.SetY(jutDirection.y() * stepSize.GetY());
|
||||
|
||||
m_scenePoint.setX(m_scenePoint.x() + stepDirection.GetX() * 2);
|
||||
}
|
||||
|
||||
CreateNodeFromProposalAction::CreateNodeFromProposalAction(GraphCanvas::GraphId graphId, GraphCanvas::Endpoint endpoint, QString nodeName, QPointF scenePoint)
|
||||
: m_graphId(graphId)
|
||||
, m_endpoint(endpoint)
|
||||
, m_scenePoint(scenePoint)
|
||||
, m_nodeName(nodeName)
|
||||
{
|
||||
}
|
||||
|
||||
bool CreateNodeFromProposalAction::IsMissingPrecondition()
|
||||
{
|
||||
GraphCanvas::ViewId viewId;
|
||||
GraphCanvas::SceneRequestBus::EventResult(viewId, m_graphId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
|
||||
QRectF viewableBounds;
|
||||
GraphCanvas::ViewRequestBus::EventResult(viewableBounds, viewId, &GraphCanvas::ViewRequests::GetViewableAreaInSceneCoordinates);
|
||||
|
||||
QPointF pinCenter;
|
||||
GraphCanvas::SlotUIRequestBus::EventResult(pinCenter, m_endpoint.GetSlotId(), &GraphCanvas::SlotUIRequests::GetPinCenter);
|
||||
|
||||
QRectF sceneRect(pinCenter, m_scenePoint);
|
||||
sceneRect.adjust(-10, -10, 10, 10);
|
||||
|
||||
return !viewableBounds.isEmpty() && !viewableBounds.contains(sceneRect);
|
||||
}
|
||||
|
||||
EditorAutomationAction* CreateNodeFromProposalAction::GenerateMissingPreconditionAction()
|
||||
{
|
||||
GraphCanvas::ViewId viewId;
|
||||
GraphCanvas::SceneRequestBus::EventResult(viewId, m_graphId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
|
||||
QRectF viewableBounds;
|
||||
GraphCanvas::ViewRequestBus::EventResult(viewableBounds, viewId, &GraphCanvas::ViewRequests::GetViewableAreaInSceneCoordinates);
|
||||
|
||||
QPointF pinCenter;
|
||||
GraphCanvas::SlotUIRequestBus::EventResult(pinCenter, m_endpoint.GetSlotId(), &GraphCanvas::SlotUIRequests::GetPinCenter);
|
||||
|
||||
QRectF sceneRect(pinCenter, m_scenePoint);
|
||||
|
||||
return aznew EnsureSceneRectVisibleAction(m_graphId, sceneRect);
|
||||
}
|
||||
|
||||
void CreateNodeFromProposalAction::SetupAction()
|
||||
{
|
||||
ClearActionQueue();
|
||||
|
||||
m_createdNodeId.SetInvalid();
|
||||
|
||||
QPointF pinCenter;
|
||||
GraphCanvas::SlotUIRequestBus::EventResult(pinCenter, m_endpoint.GetSlotId(), &GraphCanvas::SlotUIRequests::GetPinCenter);
|
||||
|
||||
AddAction(aznew SceneMouseDragAction(m_graphId, pinCenter, m_scenePoint));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
AddAction(aznew TypeStringAction(m_nodeName));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
#if defined(AZ_COMPILER_MSVC)
|
||||
AddAction(aznew TypeCharAction(VK_RETURN));
|
||||
#endif
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusConnect(m_graphId);
|
||||
|
||||
CompoundAction::SetupAction();
|
||||
}
|
||||
|
||||
void CreateNodeFromProposalAction::OnNodeAdded(const AZ::EntityId& nodeId, bool)
|
||||
{
|
||||
m_createdNodeId = nodeId;
|
||||
}
|
||||
|
||||
AZ::EntityId CreateNodeFromProposalAction::GetCreatedNodeId() const
|
||||
{
|
||||
return GraphCanvas::GraphUtils::FindOutermostNode(m_createdNodeId);
|
||||
}
|
||||
|
||||
AZ::EntityId CreateNodeFromProposalAction::GetConnectionId() const
|
||||
{
|
||||
GraphCanvas::ConnectionId lastConnectionId;
|
||||
GraphCanvas::SlotRequestBus::EventResult(lastConnectionId, m_endpoint.m_slotId, &GraphCanvas::SlotRequests::GetLastConnection);
|
||||
|
||||
return lastConnectionId;
|
||||
}
|
||||
|
||||
ActionReport CreateNodeFromProposalAction::GenerateReport() const
|
||||
{
|
||||
if (!m_createdNodeId.IsValid())
|
||||
{
|
||||
return AZ::Failure<AZStd::string>(AZStd::string::format("Failed to create Node(%s)", m_nodeName.toUtf8().data()));
|
||||
}
|
||||
else
|
||||
{
|
||||
GraphCanvas::ConnectionId lastConnectionId;
|
||||
GraphCanvas::SlotRequestBus::EventResult(lastConnectionId, m_endpoint.m_slotId, &GraphCanvas::SlotRequests::GetLastConnection);
|
||||
|
||||
GraphCanvas::Endpoint otherEndpoint;
|
||||
GraphCanvas::ConnectionRequestBus::EventResult(otherEndpoint, lastConnectionId, &GraphCanvas::ConnectionRequests::FindOtherEndpoint, m_endpoint);
|
||||
|
||||
if (otherEndpoint.IsValid())
|
||||
{
|
||||
AZ::EntityId nodeId = GetCreatedNodeId();
|
||||
|
||||
if (otherEndpoint.GetNodeId() != nodeId)
|
||||
{
|
||||
return AZ::Failure<AZStd::string>(AZStd::string::format("Failed to create connection to Node(%s)", m_nodeName.toUtf8().data()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return AZ::Failure<AZStd::string>(AZStd::string::format("Failed to create connection to Node(%s)", m_nodeName.toUtf8().data()));
|
||||
}
|
||||
}
|
||||
|
||||
return CompoundAction::GenerateReport();
|
||||
}
|
||||
|
||||
void CreateNodeFromProposalAction::OnActionsComplete()
|
||||
{
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
// CreateGroupAction
|
||||
//////////////////////
|
||||
|
||||
CreateGroupAction::CreateGroupAction(GraphCanvas::EditorId editorId, GraphCanvas::GraphId graphId, CreationType creationType)
|
||||
: m_editorId(editorId)
|
||||
, m_graphId(graphId)
|
||||
, m_creationType(creationType)
|
||||
{
|
||||
if (m_creationType == CreationType::Hotkey)
|
||||
{
|
||||
SetupHotkeyAction();
|
||||
}
|
||||
}
|
||||
|
||||
void CreateGroupAction::SetupAction()
|
||||
{
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusConnect(m_graphId);
|
||||
|
||||
m_createdGroup.SetInvalid();
|
||||
|
||||
if (m_creationType == CreationType::Toolbar)
|
||||
{
|
||||
SetupToolbarAction();
|
||||
}
|
||||
|
||||
CompoundAction::SetupAction();
|
||||
}
|
||||
|
||||
void CreateGroupAction::OnNodeAdded(const AZ::EntityId& groupId, bool)
|
||||
{
|
||||
m_createdGroup = groupId;
|
||||
}
|
||||
|
||||
AZ::EntityId CreateGroupAction::GetCreatedGroupId() const
|
||||
{
|
||||
return m_createdGroup;
|
||||
}
|
||||
|
||||
ActionReport CreateGroupAction::GenerateReport() const
|
||||
{
|
||||
if (!m_createdGroup.IsValid())
|
||||
{
|
||||
if (m_creationType == CreationType::Hotkey)
|
||||
{
|
||||
return AZ::Failure<AZStd::string>("Failed to create Group using HotKey");
|
||||
}
|
||||
else if (m_creationType == CreationType::Toolbar)
|
||||
{
|
||||
return AZ::Failure<AZStd::string>("Failed to create Group using Toolbar");
|
||||
}
|
||||
}
|
||||
|
||||
return CompoundAction::GenerateReport();
|
||||
}
|
||||
|
||||
void CreateGroupAction::SetupToolbarAction()
|
||||
{
|
||||
QToolButton* createGroupButton = GraphCanvas::AutomationUtils::FindObjectById<QToolButton>(m_editorId, GraphCanvas::AutomationIds::GroupButton);
|
||||
|
||||
if (createGroupButton)
|
||||
{
|
||||
QPoint clickPoint = createGroupButton->mapToGlobal(createGroupButton->rect().center());
|
||||
|
||||
ClearActionQueue();
|
||||
AddAction(aznew MouseClickAction(Qt::MouseButton::LeftButton, clickPoint));
|
||||
}
|
||||
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
}
|
||||
|
||||
void CreateGroupAction::SetupHotkeyAction()
|
||||
{
|
||||
ClearActionQueue();
|
||||
|
||||
#if defined(AZ_COMPILER_MSVC)
|
||||
AddAction(aznew KeyPressAction(VK_CONTROL));
|
||||
AddAction(aznew KeyPressAction(VK_LSHIFT));
|
||||
AddAction(aznew TypeCharAction('G'));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
AddAction(aznew KeyReleaseAction(VK_LSHIFT));
|
||||
AddAction(aznew KeyReleaseAction(VK_CONTROL));
|
||||
#endif
|
||||
}
|
||||
|
||||
void CreateGroupAction::OnActionsComplete()
|
||||
{
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
}
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <GraphCanvas/Components/Nodes/NodeBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/ViewBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/////////////////////////////
|
||||
// CenterOnScenePointAction
|
||||
/////////////////////////////
|
||||
|
||||
CenterOnScenePointAction::CenterOnScenePointAction(GraphCanvas::GraphId graphId, QPointF scenePoint)
|
||||
: m_graphId(graphId)
|
||||
, m_scenePoint(scenePoint)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CenterOnScenePointAction::Tick()
|
||||
{
|
||||
GraphCanvas::ViewId viewId;
|
||||
GraphCanvas::SceneRequestBus::EventResult(viewId, m_graphId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
|
||||
if (viewId.IsValid())
|
||||
{
|
||||
GraphCanvas::ViewRequestBus::Event(viewId, &GraphCanvas::ViewRequests::CenterOn, m_scenePoint);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
// EnsureSceneRectVisibleAction
|
||||
/////////////////////////////////
|
||||
|
||||
EnsureSceneRectVisibleAction::EnsureSceneRectVisibleAction(GraphCanvas::GraphId graphId, QRectF sceneRect)
|
||||
: DelayAction(AZStd::chrono::milliseconds(250))
|
||||
, m_graphId(graphId)
|
||||
, m_sceneRect(sceneRect)
|
||||
{
|
||||
}
|
||||
|
||||
void EnsureSceneRectVisibleAction::SetupAction()
|
||||
{
|
||||
DelayAction::SetupAction();
|
||||
|
||||
m_firstTick = true;
|
||||
}
|
||||
|
||||
bool EnsureSceneRectVisibleAction::Tick()
|
||||
{
|
||||
if (m_firstTick)
|
||||
{
|
||||
m_firstTick = false;
|
||||
GraphCanvas::ViewId viewId;
|
||||
GraphCanvas::SceneRequestBus::EventResult(viewId, m_graphId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
|
||||
if (viewId.IsValid())
|
||||
{
|
||||
GraphCanvas::ViewRequestBus::Event(viewId, &GraphCanvas::ViewRequests::CenterOnArea, m_sceneRect);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return DelayAction::Tick();
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////
|
||||
// SceneMouseMoveAction
|
||||
/////////////////////////
|
||||
|
||||
SceneMouseMoveAction::SceneMouseMoveAction(GraphCanvas::GraphId graphId, QPointF scenePoint)
|
||||
: m_graphId(graphId)
|
||||
, m_scenePoint(scenePoint)
|
||||
{
|
||||
GraphCanvas::SceneRequestBus::EventResult(m_viewId, m_graphId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
}
|
||||
|
||||
bool SceneMouseMoveAction::IsMissingPrecondition()
|
||||
{
|
||||
QRectF viewableBounds = QRectF(m_scenePoint, m_scenePoint);
|
||||
viewableBounds.adjust(-10, -10, 10, 10);
|
||||
|
||||
QRectF viewableArea;
|
||||
GraphCanvas::ViewRequestBus::EventResult(viewableArea, m_viewId, &GraphCanvas::ViewRequests::GetViewableAreaInSceneCoordinates);
|
||||
|
||||
return !viewableArea.isEmpty() && !viewableArea.contains(viewableBounds);
|
||||
}
|
||||
|
||||
EditorAutomationAction* SceneMouseMoveAction::GenerateMissingPreconditionAction()
|
||||
{
|
||||
QRectF viewableBounds = QRectF(m_scenePoint, m_scenePoint);
|
||||
viewableBounds.adjust(-10, -10, 10, 10);
|
||||
|
||||
return aznew EnsureSceneRectVisibleAction(m_graphId, viewableBounds);
|
||||
}
|
||||
|
||||
void SceneMouseMoveAction::SetupAction()
|
||||
{
|
||||
ClearActionQueue();
|
||||
|
||||
AZ::Vector2 tempVector = AZ::Vector2::CreateZero();
|
||||
|
||||
QPoint screenPoint;
|
||||
GraphCanvas::ViewRequestBus::EventResult(tempVector, m_viewId, &GraphCanvas::ViewRequests::MapToGlobal, GraphCanvas::ConversionUtils::QPointToVector(m_scenePoint));
|
||||
|
||||
screenPoint = GraphCanvas::ConversionUtils::AZToQPoint(tempVector).toPoint();
|
||||
|
||||
AddAction(aznew MouseMoveAction(screenPoint));
|
||||
|
||||
CompoundAction::SetupAction();
|
||||
}
|
||||
|
||||
/////////////////////////
|
||||
// SceneMouseDragAction
|
||||
/////////////////////////
|
||||
|
||||
SceneMouseDragAction::SceneMouseDragAction(GraphCanvas::GraphId graphId, QPointF sceneStart, QPointF sceneEnd, Qt::MouseButton mouseButton)
|
||||
: m_graphId(graphId)
|
||||
, m_sceneStart(sceneStart)
|
||||
, m_sceneEnd(sceneEnd)
|
||||
, m_mouseButton(mouseButton)
|
||||
{
|
||||
GraphCanvas::SceneRequestBus::EventResult(m_viewId, m_graphId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
}
|
||||
|
||||
bool SceneMouseDragAction::IsMissingPrecondition()
|
||||
{
|
||||
QRectF viewableBounds = QRectF(m_sceneStart, m_sceneEnd);
|
||||
viewableBounds.adjust(-10, -10, 10, 10);
|
||||
|
||||
QRectF viewableArea;
|
||||
GraphCanvas::ViewRequestBus::EventResult(viewableArea, m_viewId, &GraphCanvas::ViewRequests::GetViewableAreaInSceneCoordinates);
|
||||
|
||||
return !viewableArea.contains(viewableBounds);
|
||||
}
|
||||
|
||||
EditorAutomationAction* SceneMouseDragAction::GenerateMissingPreconditionAction()
|
||||
{
|
||||
QRectF viewableBounds = QRectF(m_sceneStart, m_sceneEnd);
|
||||
viewableBounds.adjust(-10, -10, 10, 10);
|
||||
|
||||
return aznew EnsureSceneRectVisibleAction(m_graphId, viewableBounds);
|
||||
}
|
||||
|
||||
void SceneMouseDragAction::SetupAction()
|
||||
{
|
||||
AZ::Vector2 tempVector = AZ::Vector2::CreateZero();
|
||||
|
||||
QPoint screenStart;
|
||||
GraphCanvas::ViewRequestBus::EventResult(tempVector, m_viewId, &GraphCanvas::ViewRequests::MapToGlobal, GraphCanvas::ConversionUtils::QPointToVector(m_sceneStart));
|
||||
|
||||
screenStart = GraphCanvas::ConversionUtils::AZToQPoint(tempVector).toPoint();
|
||||
|
||||
tempVector = AZ::Vector2::CreateZero();
|
||||
|
||||
QPoint screenEnd;
|
||||
GraphCanvas::ViewRequestBus::EventResult(tempVector, m_viewId, &GraphCanvas::ViewRequests::MapToGlobal, GraphCanvas::ConversionUtils::QPointToVector(m_sceneEnd));
|
||||
|
||||
screenEnd = GraphCanvas::ConversionUtils::AZToQPoint(tempVector).toPoint();
|
||||
|
||||
AddAction(aznew MouseDragAction(screenStart, screenEnd, m_mouseButton));
|
||||
|
||||
CompoundAction::SetupAction();
|
||||
}
|
||||
}
|
||||
+245
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/SlotBus.h>
|
||||
#include <GraphCanvas/Components/Slots/Data/DataSlotBus.h>
|
||||
#include <GraphCanvas/Components/ViewBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Editor/AssetEditorBus.h>
|
||||
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
#include <Editor/View/Widgets/VariablePanel/VariableDockWidget.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ElementInteractions.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/////////////////////////////
|
||||
// SelectSceneElementAction
|
||||
/////////////////////////////
|
||||
|
||||
SelectSceneElementAction::SelectSceneElementAction(AZ::EntityId sceneMemberId)
|
||||
: m_sceneMemberId(sceneMemberId)
|
||||
{
|
||||
GraphCanvas::SceneMemberRequestBus::EventResult(m_graphId, m_sceneMemberId, &GraphCanvas::SceneMemberRequests::GetScene);
|
||||
|
||||
GraphCanvas::SceneRequestBus::EventResult(m_viewId, m_graphId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
|
||||
if (!GraphCanvas::GraphUtils::IsConnection(sceneMemberId))
|
||||
{
|
||||
QRectF boundingRect;
|
||||
|
||||
QGraphicsItem* graphicsItem = nullptr;
|
||||
GraphCanvas::VisualRequestBus::EventResult(graphicsItem, sceneMemberId, &GraphCanvas::VisualRequests::AsGraphicsItem);
|
||||
|
||||
if (graphicsItem)
|
||||
{
|
||||
boundingRect = graphicsItem->sceneBoundingRect();
|
||||
}
|
||||
|
||||
m_scenePoint = boundingRect.topLeft();
|
||||
m_scenePoint.setX(boundingRect.center().x());
|
||||
m_scenePoint.setY(m_scenePoint.y() + 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
QPainterPath outlinePath;
|
||||
GraphCanvas::SceneMemberUIRequestBus::EventResult(outlinePath, sceneMemberId, &GraphCanvas::SceneMemberUIRequests::GetOutline);
|
||||
|
||||
m_scenePoint = outlinePath.pointAtPercent(0.5);
|
||||
}
|
||||
}
|
||||
|
||||
bool SelectSceneElementAction::IsMissingPrecondition()
|
||||
{
|
||||
QRectF viewableArea;
|
||||
GraphCanvas::ViewRequestBus::EventResult(viewableArea, m_viewId, &GraphCanvas::ViewRequests::GetViewableAreaInSceneCoordinates);
|
||||
|
||||
return m_sceneMemberId.IsValid() && m_graphId.IsValid() && !viewableArea.contains(m_scenePoint);
|
||||
}
|
||||
|
||||
EditorAutomationAction* SelectSceneElementAction::GenerateMissingPreconditionAction()
|
||||
{
|
||||
CompoundAction* compoundAction = aznew CompoundAction();
|
||||
|
||||
QPoint startPoint(m_scenePoint.x() - 5, m_scenePoint.y() - 5);
|
||||
QPoint endPoint(m_scenePoint.x() + 5, m_scenePoint.y() + 5);
|
||||
|
||||
QRect sceneRect = QRect(startPoint, endPoint);
|
||||
|
||||
compoundAction->AddAction(aznew EnsureSceneRectVisibleAction(m_graphId, sceneRect));
|
||||
compoundAction->AddAction(aznew ProcessUserEventsAction());
|
||||
|
||||
return compoundAction;
|
||||
}
|
||||
|
||||
void SelectSceneElementAction::SetupAction()
|
||||
{
|
||||
ClearActionQueue();
|
||||
|
||||
AZ::Vector2 screenPoint = AZ::Vector2::CreateZero();
|
||||
GraphCanvas::ViewRequestBus::EventResult(screenPoint, m_viewId, &GraphCanvas::ViewRequests::MapToGlobal, GraphCanvas::ConversionUtils::QPointToVector(m_scenePoint));
|
||||
|
||||
AddAction(aznew MouseClickAction(Qt::MouseButton::LeftButton, GraphCanvas::ConversionUtils::AZToQPoint(screenPoint).toPoint()));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
|
||||
CompoundAction::SetupAction();
|
||||
}
|
||||
|
||||
///////////////////////////////
|
||||
// AltClickSceneElementAction
|
||||
///////////////////////////////
|
||||
|
||||
AltClickSceneElementAction::AltClickSceneElementAction(AZ::EntityId sceneMemberId)
|
||||
: m_sceneMemberId(sceneMemberId)
|
||||
{
|
||||
GraphCanvas::SceneMemberRequestBus::EventResult(m_graphId, m_sceneMemberId, &GraphCanvas::SceneMemberRequests::GetScene);
|
||||
|
||||
GraphCanvas::SceneRequestBus::EventResult(m_viewId, m_graphId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
|
||||
if (!GraphCanvas::GraphUtils::IsConnection(sceneMemberId))
|
||||
{
|
||||
QRectF boundingRect;
|
||||
|
||||
QGraphicsItem* graphicsItem = nullptr;
|
||||
GraphCanvas::VisualRequestBus::EventResult(graphicsItem, sceneMemberId, &GraphCanvas::VisualRequests::AsGraphicsItem);
|
||||
|
||||
if (graphicsItem)
|
||||
{
|
||||
boundingRect = graphicsItem->sceneBoundingRect();
|
||||
}
|
||||
|
||||
m_scenePoint = boundingRect.topLeft();
|
||||
m_scenePoint.setX(boundingRect.center().x());
|
||||
m_scenePoint.setY(m_scenePoint.y() + 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
QPainterPath outlinePath;
|
||||
GraphCanvas::SceneMemberUIRequestBus::EventResult(outlinePath, sceneMemberId, &GraphCanvas::SceneMemberUIRequests::GetOutline);
|
||||
|
||||
m_scenePoint = outlinePath.pointAtPercent(0.5);
|
||||
}
|
||||
}
|
||||
|
||||
bool AltClickSceneElementAction::IsMissingPrecondition()
|
||||
{
|
||||
QRectF viewableArea;
|
||||
GraphCanvas::ViewRequestBus::EventResult(viewableArea, m_viewId, &GraphCanvas::ViewRequests::GetViewableAreaInSceneCoordinates);
|
||||
|
||||
return !viewableArea.contains(m_scenePoint);
|
||||
}
|
||||
|
||||
EditorAutomationAction* AltClickSceneElementAction::GenerateMissingPreconditionAction()
|
||||
{
|
||||
CompoundAction* compoundAction = aznew CompoundAction();
|
||||
|
||||
QPoint startPoint(m_scenePoint.x() - 5, m_scenePoint.y() - 5);
|
||||
QPoint endPoint(m_scenePoint.x() + 5, m_scenePoint.y() + 5);
|
||||
|
||||
QRect sceneRect = QRect(startPoint, endPoint);
|
||||
|
||||
compoundAction->AddAction(aznew EnsureSceneRectVisibleAction(m_graphId, sceneRect));
|
||||
compoundAction->AddAction(aznew ProcessUserEventsAction());
|
||||
|
||||
return compoundAction;
|
||||
}
|
||||
|
||||
void AltClickSceneElementAction::SetupAction()
|
||||
{
|
||||
ClearActionQueue();
|
||||
m_sceneMemberRemoved = false;
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusConnect(m_graphId);
|
||||
#if defined(AZ_COMPILER_MSVC)
|
||||
AddAction(aznew KeyPressAction(VK_LMENU));
|
||||
|
||||
AZ::Vector2 screenPoint = AZ::Vector2::CreateZero();
|
||||
GraphCanvas::ViewRequestBus::EventResult(screenPoint, m_viewId, &GraphCanvas::ViewRequests::MapToGlobal, GraphCanvas::ConversionUtils::QPointToVector(m_scenePoint));
|
||||
|
||||
AddAction(aznew MouseClickAction(Qt::MouseButton::LeftButton, GraphCanvas::ConversionUtils::AZToQPoint(screenPoint).toPoint()));
|
||||
AddAction(aznew KeyReleaseAction(VK_LMENU));
|
||||
AddAction(aznew ProcessUserEventsAction(AZStd::chrono::milliseconds(750)));
|
||||
#endif
|
||||
CompoundAction::SetupAction();
|
||||
}
|
||||
|
||||
ActionReport AltClickSceneElementAction::GenerateReport() const
|
||||
{
|
||||
if (!m_sceneMemberRemoved)
|
||||
{
|
||||
return AZ::Failure<AZStd::string>("Failed to delete target scene element with Alt+Click");
|
||||
}
|
||||
|
||||
return CompoundAction::GenerateReport();
|
||||
}
|
||||
|
||||
void AltClickSceneElementAction::OnNodeRemoved(const AZ::EntityId& nodeId)
|
||||
{
|
||||
if (m_sceneMemberId == nodeId)
|
||||
{
|
||||
m_sceneMemberRemoved = true;
|
||||
}
|
||||
}
|
||||
|
||||
void AltClickSceneElementAction::OnConnectionRemoved(const AZ::EntityId& connectionId)
|
||||
{
|
||||
if (m_sceneMemberId == connectionId)
|
||||
{
|
||||
m_sceneMemberRemoved = true;
|
||||
}
|
||||
}
|
||||
|
||||
void AltClickSceneElementAction::OnActionsComplete()
|
||||
{
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
// MouseToNodePropertyEditorAction
|
||||
////////////////////////////////////
|
||||
|
||||
MouseToNodePropertyEditorAction::MouseToNodePropertyEditorAction(GraphCanvas::SlotId slotId)
|
||||
: m_slotId(slotId)
|
||||
{
|
||||
}
|
||||
|
||||
void MouseToNodePropertyEditorAction::SetupAction()
|
||||
{
|
||||
ClearActionQueue();
|
||||
|
||||
GraphCanvas::NodeId nodeId;
|
||||
GraphCanvas::SlotRequestBus::EventResult(nodeId, m_slotId, &GraphCanvas::SlotRequests::GetNode);
|
||||
|
||||
GraphCanvas::GraphId graphId;
|
||||
GraphCanvas::SceneMemberRequestBus::EventResult(graphId, nodeId, &GraphCanvas::SceneMemberRequests::GetScene);
|
||||
|
||||
QRectF sceneBoundingRect;
|
||||
GraphCanvas::SlotRequestBus::EventResult(nodeId, m_slotId, &GraphCanvas::SlotRequests::GetNode);
|
||||
GraphCanvas::DataSlotLayoutRequestBus::EventResult(sceneBoundingRect, m_slotId, &GraphCanvas::DataSlotLayoutRequests::GetWidgetSceneBoundingRect);
|
||||
|
||||
AddAction(aznew SceneMouseMoveAction(graphId, sceneBoundingRect.center()));
|
||||
|
||||
CompoundAction::SetupAction();
|
||||
}
|
||||
}
|
||||
+244
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <QToolButton>
|
||||
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Editor/Automation/AutomationUtils.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
#include <ScriptCanvas/GraphCanvas/NodeDescriptorBus.h>
|
||||
#include <Editor/GraphCanvas/AutomationIds.h>
|
||||
#include <Editor/Include/ScriptCanvas/Bus/EditorScriptCanvasBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/GraphActions.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/////////////////////////
|
||||
// CreateNewGraphAction
|
||||
/////////////////////////
|
||||
|
||||
CreateNewGraphAction::CreateNewGraphAction()
|
||||
{
|
||||
}
|
||||
|
||||
void CreateNewGraphAction::SetupAction()
|
||||
{
|
||||
m_graphId.SetInvalid();
|
||||
|
||||
ClearActionQueue();
|
||||
|
||||
QToolButton* createNewGraphButton = GraphCanvas::AutomationUtils::FindObjectById<QToolButton>(ScriptCanvasEditor::AssetEditorId, ScriptCanvasEditor::AutomationIds::CreateScriptCanvasButton);
|
||||
|
||||
if (createNewGraphButton)
|
||||
{
|
||||
QPointF point = createNewGraphButton->mapToGlobal(createNewGraphButton->rect().center());
|
||||
|
||||
m_newGraphAction = aznew WaitForNewGraphAction();
|
||||
AddAction(aznew MouseClickAction(Qt::MouseButton::LeftButton, point.toPoint()));
|
||||
AddAction(m_newGraphAction);
|
||||
}
|
||||
|
||||
CompoundAction::SetupAction();
|
||||
}
|
||||
|
||||
GraphCanvas::GraphId CreateNewGraphAction::GetGraphId() const
|
||||
{
|
||||
return m_graphId;
|
||||
}
|
||||
|
||||
ActionReport CreateNewGraphAction::GenerateReport() const
|
||||
{
|
||||
if (!m_graphId.IsValid())
|
||||
{
|
||||
return AZ::Failure<AZStd::string>("Failed to create New Runtime Graph");
|
||||
}
|
||||
else
|
||||
{
|
||||
GraphCanvas::GraphId activeGraphCanvasId;
|
||||
ScriptCanvasEditor::GeneralRequestBus::BroadcastResult(activeGraphCanvasId, &ScriptCanvasEditor::GeneralRequests::GetActiveGraphCanvasGraphId);
|
||||
|
||||
if (activeGraphCanvasId != m_graphId)
|
||||
{
|
||||
return AZ::Failure<AZStd::string>("Active graph is not the newly created graph.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ScriptCanvas::ScriptCanvasId scriptCanvasId;
|
||||
ScriptCanvasEditor::GeneralRequestBus::BroadcastResult(scriptCanvasId, &ScriptCanvasEditor::GeneralRequests::GetScriptCanvasId, activeGraphCanvasId);
|
||||
|
||||
bool isRuntimeGraph = false;
|
||||
ScriptCanvasEditor::EditorGraphRequestBus::EventResult(isRuntimeGraph, scriptCanvasId, &ScriptCanvasEditor::EditorGraphRequests::IsRuntimeGraph);
|
||||
|
||||
if (!isRuntimeGraph)
|
||||
{
|
||||
return AZ::Failure<AZStd::string>("Created a new Graph, but graph is not of type Runtime Graph.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return CompoundAction::GenerateReport();
|
||||
}
|
||||
|
||||
void CreateNewGraphAction::OnActionsComplete()
|
||||
{
|
||||
m_graphId = m_newGraphAction->GetGraphId();
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
// CreateNewFunctionAction
|
||||
////////////////////////////
|
||||
|
||||
CreateNewFunctionAction::CreateNewFunctionAction()
|
||||
: CreateNewGraphAction()
|
||||
{
|
||||
}
|
||||
|
||||
void CreateNewFunctionAction::SetupAction()
|
||||
{
|
||||
m_graphId.SetInvalid();
|
||||
|
||||
ClearActionQueue();
|
||||
|
||||
QToolButton* createNewFunctionButton = GraphCanvas::AutomationUtils::FindObjectById<QToolButton>(ScriptCanvasEditor::AssetEditorId, ScriptCanvasEditor::AutomationIds::CreateScriptCanvasFunctionButton);
|
||||
|
||||
if (createNewFunctionButton)
|
||||
{
|
||||
QPointF point = createNewFunctionButton->mapToGlobal(createNewFunctionButton->rect().center());
|
||||
|
||||
m_newGraphAction = aznew WaitForNewGraphAction();
|
||||
AddAction(aznew MouseClickAction(Qt::MouseButton::LeftButton, point.toPoint()));
|
||||
AddAction(m_newGraphAction);
|
||||
}
|
||||
|
||||
CompoundAction::SetupAction();
|
||||
}
|
||||
|
||||
ActionReport CreateNewFunctionAction::GenerateReport() const
|
||||
{
|
||||
if (!m_graphId.IsValid())
|
||||
{
|
||||
return AZ::Failure<AZStd::string>("Failed to create New Function");
|
||||
}
|
||||
else
|
||||
{
|
||||
GraphCanvas::GraphId activeGraphCanvasId;
|
||||
ScriptCanvasEditor::GeneralRequestBus::BroadcastResult(activeGraphCanvasId, &ScriptCanvasEditor::GeneralRequests::GetActiveGraphCanvasGraphId);
|
||||
|
||||
if (activeGraphCanvasId != m_graphId)
|
||||
{
|
||||
return AZ::Failure<AZStd::string>("Active graph is not the newly created function.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ScriptCanvas::ScriptCanvasId scriptCanvasId;
|
||||
ScriptCanvasEditor::GeneralRequestBus::BroadcastResult(scriptCanvasId, &ScriptCanvasEditor::GeneralRequests::GetScriptCanvasId, activeGraphCanvasId);
|
||||
|
||||
bool isFunctionGraph = false;
|
||||
ScriptCanvasEditor::EditorGraphRequestBus::EventResult(isFunctionGraph, scriptCanvasId, &ScriptCanvasEditor::EditorGraphRequests::IsFunctionGraph);
|
||||
|
||||
if (!isFunctionGraph)
|
||||
{
|
||||
return AZ::Failure<AZStd::string>("Created a new Graph, but graph is not of type Function.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return CompoundAction::GenerateReport();
|
||||
}
|
||||
|
||||
void CreateNewFunctionAction::OnActionsComplete()
|
||||
{
|
||||
m_graphId = m_newGraphAction->GetGraphId();
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// ForceCloseActiveGraphAction
|
||||
////////////////////////////////
|
||||
|
||||
ForceCloseActiveGraphAction::ForceCloseActiveGraphAction()
|
||||
: ProcessUserEventsAction(AZStd::chrono::milliseconds(500))
|
||||
{
|
||||
}
|
||||
|
||||
void ForceCloseActiveGraphAction::SetupAction()
|
||||
{
|
||||
ProcessUserEventsAction::SetupAction();
|
||||
|
||||
m_firstTick = true;
|
||||
ScriptCanvasEditor::GeneralRequestBus::BroadcastResult(m_activeGraphId, &ScriptCanvasEditor::GeneralRequests::GetActiveGraphCanvasGraphId);
|
||||
}
|
||||
|
||||
bool ForceCloseActiveGraphAction::Tick()
|
||||
{
|
||||
if (m_firstTick)
|
||||
{
|
||||
ScriptCanvasEditor::AutomationRequestBus::Broadcast(&ScriptCanvasEditor::AutomationRequests::ForceCloseActiveAsset);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ProcessUserEventsAction::Tick();
|
||||
}
|
||||
}
|
||||
|
||||
ActionReport ForceCloseActiveGraphAction::GenerateReport() const
|
||||
{
|
||||
GraphCanvas::GraphId activeGraphCanvasId;
|
||||
ScriptCanvasEditor::GeneralRequestBus::BroadcastResult(activeGraphCanvasId, &ScriptCanvasEditor::GeneralRequests::GetActiveGraphCanvasGraphId);
|
||||
|
||||
if (activeGraphCanvasId == m_activeGraphId
|
||||
&& m_activeGraphId.IsValid())
|
||||
{
|
||||
return AZ::Failure<AZStd::string>("Failed to close down currently active graph");
|
||||
}
|
||||
|
||||
return ProcessUserEventsAction::GenerateReport();
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// WaitForNewGraphAction
|
||||
////////////////////////////////
|
||||
|
||||
WaitForNewGraphAction::WaitForNewGraphAction()
|
||||
{
|
||||
m_newGraphCreated = false;
|
||||
GraphCanvas::AssetEditorNotificationBus::Handler::BusConnect(ScriptCanvasEditor::AssetEditorId);
|
||||
}
|
||||
|
||||
WaitForNewGraphAction::~WaitForNewGraphAction()
|
||||
{
|
||||
GraphCanvas::AssetEditorNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
bool WaitForNewGraphAction::Tick()
|
||||
{
|
||||
return m_newGraphCreated;
|
||||
}
|
||||
|
||||
void WaitForNewGraphAction::OnActiveGraphChanged(const AZ::EntityId& graphId)
|
||||
{
|
||||
m_graphId = graphId;
|
||||
m_newGraphCreated = true;
|
||||
|
||||
GraphCanvas::AssetEditorNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
}
|
||||
+444
@@ -0,0 +1,444 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QPushButton>
|
||||
#include <QTableView>
|
||||
#include <QToolButton>
|
||||
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/SlotBus.h>
|
||||
#include <GraphCanvas/Components/Slots/Data/DataSlotBus.h>
|
||||
#include <GraphCanvas/Components/ViewBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Editor/AssetEditorBus.h>
|
||||
|
||||
#include <GraphCanvas/Widgets/NodePalette/Model/NodePaletteSortFilterProxyModel.h>
|
||||
#include <GraphCanvas/Widgets/NodePalette/NodePaletteTreeView.h>
|
||||
#include <GraphCanvas/Widgets/NodePalette/TreeItems/NodePaletteTreeItem.h>
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
#include <Editor/View/Widgets/VariablePanel/VariableDockWidget.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
#include <ScriptCanvas/GraphCanvas/NodeDescriptorBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/VariableActions.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/WidgetActions.h>
|
||||
|
||||
#if !defined(AZ_COMPILER_MSVC)
|
||||
#ifndef VK_RETURN
|
||||
#define VK_RETURN 0x0D
|
||||
#endif
|
||||
#ifndef VK_ESCAPE
|
||||
#define VK_ESCAPE 0x1B
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/////////////////////////
|
||||
// CreateVariableAction
|
||||
/////////////////////////
|
||||
|
||||
CreateVariableAction::CreateVariableAction(ScriptCanvas::Data::Type dataType, CreationType creationType)
|
||||
: m_creationType(creationType)
|
||||
, m_dataType(dataType)
|
||||
, m_typeName(ScriptCanvas::Data::GetName(dataType).c_str())
|
||||
{
|
||||
}
|
||||
|
||||
CreateVariableAction::CreateVariableAction(ScriptCanvas::Data::Type dataType, QString variableName, CreationType creationType)
|
||||
: m_creationType(creationType)
|
||||
, m_variableName(variableName)
|
||||
, m_dataType(dataType)
|
||||
, m_typeName(ScriptCanvas::Data::GetName(dataType).c_str())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CreateVariableAction::SetErrorOnNameMisMatch(bool enabled)
|
||||
{
|
||||
m_errorOnNameMismatch = enabled;
|
||||
}
|
||||
|
||||
void CreateVariableAction::SetupAction()
|
||||
{
|
||||
ScriptCanvasEditor::GeneralRequestBus::BroadcastResult(m_scriptCanvasId, &ScriptCanvasEditor::GeneralRequests::GetActiveScriptCanvasId);
|
||||
|
||||
ClearActionQueue();
|
||||
|
||||
if (m_creationType != CreationType::Programmatic)
|
||||
{
|
||||
bool isShowingCreatePalette = false;
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(isShowingCreatePalette, &ScriptCanvasEditor::VariableAutomationRequests::IsShowingVariablePalette);
|
||||
|
||||
if (!isShowingCreatePalette)
|
||||
{
|
||||
QPushButton* targetButton = nullptr;
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(targetButton, &ScriptCanvasEditor::VariableAutomationRequests::GetCreateVariableButton);
|
||||
|
||||
QPoint targetPoint = targetButton->mapToGlobal(targetButton->rect().center());
|
||||
|
||||
AddAction(aznew MouseClickAction(Qt::MouseButton::LeftButton, targetPoint));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
}
|
||||
|
||||
QLineEdit* searchFilter = nullptr;
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(searchFilter, &ScriptCanvasEditor::VariableAutomationRequests::GetVariablePaletteFilter);
|
||||
|
||||
if (searchFilter)
|
||||
{
|
||||
AddAction(aznew WriteToLineEditAction(searchFilter, m_typeName));
|
||||
}
|
||||
}
|
||||
|
||||
switch (m_creationType)
|
||||
{
|
||||
case CreationType::Palette:
|
||||
{
|
||||
QTableView* variableView = nullptr;
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(variableView, &ScriptCanvasEditor::VariableAutomationRequests::GetVariablePaletteTableView);
|
||||
|
||||
AddAction(aznew ProcessUserEventsAction(AZStd::chrono::milliseconds(500)));
|
||||
AddAction(aznew MoveMouseToViewRowAction(variableView, 0));
|
||||
AddAction(aznew MouseClickAction(Qt::MouseButton::LeftButton));
|
||||
}
|
||||
break;
|
||||
case CreationType::AutoComplete:
|
||||
{
|
||||
AddAction(aznew TypeCharAction(VK_RETURN));
|
||||
}
|
||||
break;
|
||||
case CreationType::Programmatic:
|
||||
{
|
||||
bool nameAvailable = false;
|
||||
AZStd::string variableName;
|
||||
|
||||
if (!m_variableName.isEmpty())
|
||||
{
|
||||
variableName = m_variableName.toUtf8().data();
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(nameAvailable, m_scriptCanvasId, &ScriptCanvas::GraphVariableManagerRequests::IsNameAvailable, variableName);
|
||||
}
|
||||
|
||||
if (!nameAvailable)
|
||||
{
|
||||
int variableCounter = 1;
|
||||
|
||||
do
|
||||
{
|
||||
ScriptCanvasEditor::SceneCounterRequestBus::EventResult(variableCounter, m_scriptCanvasId, &ScriptCanvasEditor::SceneCounterRequests::GetNewVariableCounter);
|
||||
|
||||
// Cribbed from VariableDockWidget. Shuld always be in sync with that.
|
||||
variableName = AZStd::string::format("Variable %u", variableCounter);
|
||||
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(nameAvailable, m_scriptCanvasId, &ScriptCanvas::GraphVariableManagerRequests::IsNameAvailable, variableName);
|
||||
} while (!nameAvailable);
|
||||
}
|
||||
|
||||
ScriptCanvas::Datum datum(m_dataType, ScriptCanvas::Datum::eOriginality::Original);
|
||||
|
||||
AZ::Outcome<ScriptCanvas::VariableId, AZStd::string> outcome = AZ::Failure(AZStd::string());
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(outcome, m_scriptCanvasId, &ScriptCanvas::GraphVariableManagerRequests::AddVariable, variableName, datum);
|
||||
|
||||
if (outcome)
|
||||
{
|
||||
m_variableId = outcome.GetValue();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
|
||||
if (m_creationType != CreationType::Programmatic)
|
||||
{
|
||||
if (!m_variableName.isEmpty())
|
||||
{
|
||||
AddAction(aznew TypeStringAction(m_variableName));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
AddAction(aznew TypeCharAction(VK_RETURN));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
}
|
||||
else
|
||||
{
|
||||
AddAction(aznew TypeCharAction(VK_ESCAPE));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
}
|
||||
}
|
||||
|
||||
ScriptCanvas::GraphVariableManagerNotificationBus::Handler::BusConnect(m_scriptCanvasId);
|
||||
|
||||
CompoundAction::SetupAction();
|
||||
}
|
||||
|
||||
ScriptCanvas::VariableId CreateVariableAction::GetVariableId() const
|
||||
{
|
||||
return m_variableId;
|
||||
}
|
||||
|
||||
void CreateVariableAction::OnVariableAddedToGraph(const ScriptCanvas::VariableId& variableId, AZStd::string_view /*variableName*/)
|
||||
{
|
||||
m_variableId = variableId;
|
||||
}
|
||||
|
||||
ActionReport CreateVariableAction::GenerateReport() const
|
||||
{
|
||||
if (!m_variableId.IsValid())
|
||||
{
|
||||
return AZ::Failure<AZStd::string>(AZStd::string::format("Failed to create Variable with type %s", ScriptCanvas::Data::GetName(m_dataType).c_str()));
|
||||
}
|
||||
else if (!m_variableName.isEmpty() && m_errorOnNameMismatch)
|
||||
{
|
||||
ScriptCanvas::GraphVariable* graphVariable = nullptr;
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(graphVariable, m_scriptCanvasId, &ScriptCanvas::GraphVariableManagerRequests::FindVariableById, m_variableId);
|
||||
|
||||
if (graphVariable)
|
||||
{
|
||||
if (m_variableName.compare(graphVariable->GetVariableName().data(), Qt::CaseInsensitive) != 0)
|
||||
{
|
||||
return AZ::Failure<AZStd::string>(AZStd::string::format("Failed to name Variable %s", m_variableName.toUtf8().data()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return CompoundAction::GenerateReport();
|
||||
}
|
||||
|
||||
void CreateVariableAction::OnActionsComplete()
|
||||
{
|
||||
ScriptCanvas::GraphVariableManagerNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
///////////////////////////////////////
|
||||
// CreateVariableNodeFromGraphPalette
|
||||
///////////////////////////////////////
|
||||
|
||||
CreateVariableNodeFromGraphPalette::CreateVariableNodeFromGraphPalette(const AZStd::string& variableName, const GraphCanvas::GraphId& graphId, QPoint scenePoint, Qt::KeyboardModifier modifier)
|
||||
: m_variableName(variableName)
|
||||
, m_graphId(graphId)
|
||||
, m_modifier(modifier)
|
||||
, m_scenePoint(scenePoint)
|
||||
{
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(m_graphPalette, &ScriptCanvasEditor::VariableAutomationRequests::GetGraphPaletteTableView);
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(m_textFilter, &ScriptCanvasEditor::VariableAutomationRequests::GetGraphVariablesFilter);
|
||||
|
||||
GraphCanvas::SceneRequestBus::EventResult(m_viewId, m_graphId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
}
|
||||
|
||||
bool CreateVariableNodeFromGraphPalette::IsMissingPrecondition()
|
||||
{
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(m_isShowingPalette, &ScriptCanvasEditor::VariableAutomationRequests::IsShowingGraphVariables);
|
||||
|
||||
if (m_textFilter)
|
||||
{
|
||||
m_isFiltered = (m_textFilter->text().compare(m_variableName.c_str(), Qt::CaseInsensitive) == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_isFiltered = true;
|
||||
}
|
||||
|
||||
m_indexIsVisible = false;
|
||||
m_displayIndex = QModelIndex();
|
||||
|
||||
if (m_isFiltered)
|
||||
{
|
||||
int rowCount = m_graphPalette->model()->rowCount();
|
||||
|
||||
for (int i = 0; i < rowCount; ++i)
|
||||
{
|
||||
m_displayIndex = m_graphPalette->model()->index(i, 0);
|
||||
|
||||
if (m_displayIndex.isValid())
|
||||
{
|
||||
QVariant variant = m_graphPalette->model()->data(m_displayIndex, Qt::DisplayRole);
|
||||
QString name = variant.toString();
|
||||
|
||||
if (name.compare(m_variableName.c_str(), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QRegion region = m_graphPalette->visibleRegion();
|
||||
QRect boundingRegion = region.boundingRect();
|
||||
m_indexIsVisible = region.contains(m_graphPalette->visualRect(m_displayIndex).center());
|
||||
}
|
||||
|
||||
m_scenePointVisible = false;
|
||||
|
||||
QRectF viewableArea;
|
||||
GraphCanvas::ViewRequestBus::EventResult(viewableArea, m_viewId, &GraphCanvas::ViewRequests::GetViewableAreaInSceneCoordinates);
|
||||
|
||||
m_scenePointVisible = viewableArea.contains(m_scenePoint);
|
||||
|
||||
return !m_isShowingPalette || !m_isFiltered || !m_indexIsVisible || ! m_scenePointVisible;
|
||||
}
|
||||
|
||||
EditorAutomationAction* CreateVariableNodeFromGraphPalette::GenerateMissingPreconditionAction()
|
||||
{
|
||||
CompoundAction* compoundAction = aznew CompoundAction();
|
||||
|
||||
if (!m_isShowingPalette)
|
||||
{
|
||||
QPushButton* pushButton = nullptr;
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(pushButton, &ScriptCanvasEditor::VariableAutomationRequests::GetCreateVariableButton);
|
||||
|
||||
MouseClickAction* clickAction = aznew MouseClickAction(Qt::MouseButton::LeftButton, pushButton->mapToGlobal(pushButton->rect().center()));
|
||||
|
||||
compoundAction->AddAction(clickAction);
|
||||
compoundAction->AddAction(aznew ProcessUserEventsAction());
|
||||
}
|
||||
else if (!m_isFiltered)
|
||||
{
|
||||
compoundAction->AddAction(aznew WriteToLineEditAction(m_textFilter, m_variableName.c_str()));
|
||||
compoundAction->AddAction(aznew ProcessUserEventsAction());
|
||||
}
|
||||
else if (!m_indexIsVisible)
|
||||
{
|
||||
m_graphPalette->scrollTo(m_displayIndex);
|
||||
compoundAction->AddAction(aznew ProcessUserEventsAction());
|
||||
}
|
||||
|
||||
if (!m_scenePointVisible)
|
||||
{
|
||||
QRect sceneRect(m_scenePoint, m_scenePoint);
|
||||
sceneRect.adjust(-5, -5, 5, 5);
|
||||
|
||||
compoundAction->AddAction(aznew EnsureSceneRectVisibleAction(m_graphId, sceneRect));
|
||||
compoundAction->AddAction(aznew ProcessUserEventsAction());
|
||||
}
|
||||
|
||||
return compoundAction;
|
||||
}
|
||||
void CreateVariableNodeFromGraphPalette::SetupAction()
|
||||
{
|
||||
m_createdNodeId.SetInvalid();
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusConnect(m_graphId);
|
||||
|
||||
ClearActionQueue();
|
||||
|
||||
QPoint screenPoint = m_graphPalette->mapToGlobal(m_graphPalette->visualRect(m_displayIndex).center());
|
||||
|
||||
AZ::Vector2 targetPoint;
|
||||
GraphCanvas::ViewRequestBus::EventResult(targetPoint, m_viewId, &GraphCanvas::ViewRequests::MapToGlobal, GraphCanvas::ConversionUtils::QPointToVector(m_scenePoint));
|
||||
|
||||
AZ::Vector2 flushTarget = targetPoint + AZ::Vector2(1, 1);
|
||||
|
||||
if (m_modifier == Qt::ShiftModifier)
|
||||
{
|
||||
#if defined(AZ_COMPILER_MSVC)
|
||||
AddAction(aznew KeyPressAction(VK_LSHIFT));
|
||||
#endif
|
||||
}
|
||||
else if (m_modifier == Qt::AltModifier)
|
||||
{
|
||||
#if defined(AZ_COMPILER_MSVC)
|
||||
AddAction(aznew KeyPressAction(VK_LMENU));
|
||||
#endif
|
||||
}
|
||||
|
||||
AddAction(aznew MouseDragAction(screenPoint, GraphCanvas::ConversionUtils::AZToQPoint(targetPoint).toPoint()));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
|
||||
if (m_modifier == Qt::ShiftModifier)
|
||||
{
|
||||
#if defined(AZ_COMPILER_MSVC)
|
||||
AddAction(aznew KeyReleaseAction(VK_LSHIFT));
|
||||
#endif
|
||||
}
|
||||
else if (m_modifier == Qt::AltModifier)
|
||||
{
|
||||
#if defined(AZ_COMPILER_MSVC)
|
||||
AddAction(aznew KeyReleaseAction(VK_LMENU));
|
||||
#endif
|
||||
}
|
||||
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
AddAction(aznew MouseMoveAction(GraphCanvas::ConversionUtils::AZToQPoint(flushTarget).toPoint()));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
|
||||
CompoundAction::SetupAction();
|
||||
}
|
||||
|
||||
void CreateVariableNodeFromGraphPalette::OnNodeAdded(const AZ::EntityId& nodeId, bool)
|
||||
{
|
||||
m_createdNodeId = nodeId;
|
||||
}
|
||||
|
||||
void CreateVariableNodeFromGraphPalette::OnActionsComplete()
|
||||
{
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
AZ::EntityId CreateVariableNodeFromGraphPalette::GetCreatedNodeId() const
|
||||
{
|
||||
return GraphCanvas::GraphUtils::FindOutermostNode(m_createdNodeId);
|
||||
}
|
||||
|
||||
ActionReport CreateVariableNodeFromGraphPalette::GenerateReport() const
|
||||
{
|
||||
if (!m_createdNodeId.IsValid())
|
||||
{
|
||||
AZStd::string errorString = AZStd::string::format("Failed to create a node for Variable(%s) from the Variable Palette", m_variableName.c_str());
|
||||
return AZ::Failure(errorString);
|
||||
}
|
||||
|
||||
return CompoundAction::GenerateReport();
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
// ShowGraphVariablesAction
|
||||
/////////////////////////////
|
||||
|
||||
void ShowGraphVariablesAction::SetupAction()
|
||||
{
|
||||
ClearActionQueue();
|
||||
|
||||
bool isShowingGraphPalette = false;
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(isShowingGraphPalette, &ScriptCanvasEditor::VariableAutomationRequests::IsShowingGraphVariables);
|
||||
|
||||
if (!isShowingGraphPalette)
|
||||
{
|
||||
QPushButton* createButton = nullptr;
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(createButton, &ScriptCanvasEditor::VariableAutomationRequests::GetCreateVariableButton);
|
||||
|
||||
AddAction(aznew MouseClickAction(Qt::MouseButton::LeftButton, createButton->mapToGlobal(createButton->rect().center())));
|
||||
AddAction(aznew ProcessUserEventsAction());
|
||||
}
|
||||
|
||||
CompoundAction::SetupAction();
|
||||
}
|
||||
|
||||
ActionReport ShowGraphVariablesAction::GenerateReport() const
|
||||
{
|
||||
bool isShowingGraphPalette = false;
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(isShowingGraphPalette, &ScriptCanvasEditor::VariableAutomationRequests::IsShowingGraphVariables);
|
||||
|
||||
if (!isShowingGraphPalette)
|
||||
{
|
||||
return AZ::Failure<AZStd::string>("Failed to Show Graph Variable");
|
||||
}
|
||||
|
||||
return CompoundAction::GenerateReport();
|
||||
}
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <QTableView>
|
||||
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/SlotBus.h>
|
||||
#include <GraphCanvas/Components/Slots/Data/DataSlotBus.h>
|
||||
#include <GraphCanvas/Components/ViewBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Editor/AssetEditorBus.h>
|
||||
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/WidgetActions.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
//////////////////////////
|
||||
// WriteToLineEditAction
|
||||
//////////////////////////
|
||||
|
||||
WriteToLineEditAction::WriteToLineEditAction(QLineEdit* targetEdit, QString targetText)
|
||||
: m_targetEdit(targetEdit)
|
||||
, m_targetText(targetText)
|
||||
{
|
||||
}
|
||||
|
||||
void WriteToLineEditAction::SetupAction()
|
||||
{
|
||||
ClearActionQueue();
|
||||
|
||||
QPoint targetPoint = m_targetEdit->mapToGlobal(QPoint(5, m_targetEdit->height() * 0.5f));
|
||||
|
||||
// Cheaty clear for right now.
|
||||
m_targetEdit->clear();
|
||||
|
||||
AddAction(aznew ScriptCanvasDeveloper::MouseClickAction(Qt::MouseButton::LeftButton, targetPoint));
|
||||
AddAction(aznew ScriptCanvasDeveloper::TypeStringAction(m_targetText));
|
||||
|
||||
CompoundAction::SetupAction();
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
// MoveMouseToViewRowAction
|
||||
/////////////////////////////
|
||||
|
||||
MoveMouseToViewRowAction::MoveMouseToViewRowAction(QAbstractItemView* itemView, int row, QModelIndex parentIndex)
|
||||
: m_itemView(itemView)
|
||||
, m_row(row)
|
||||
, m_parentIndex(parentIndex)
|
||||
{
|
||||
}
|
||||
|
||||
void MoveMouseToViewRowAction::SetupAction()
|
||||
{
|
||||
ClearActionQueue();
|
||||
|
||||
QModelIndex index = m_itemView->model()->index(m_row, 0, m_parentIndex);
|
||||
|
||||
if (index.isValid())
|
||||
{
|
||||
QRect targetRect = m_itemView->visualRect(index);
|
||||
|
||||
int column = 1;
|
||||
|
||||
while (column < m_itemView->model()->columnCount())
|
||||
{
|
||||
targetRect |= m_itemView->visualRect(m_itemView->model()->index(m_row, column, m_parentIndex));
|
||||
++column;
|
||||
}
|
||||
|
||||
AddAction(aznew MouseMoveAction(m_itemView->mapToGlobal(targetRect.center())));
|
||||
}
|
||||
|
||||
CompoundAction::SetupAction();
|
||||
}
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/SlotBus.h>
|
||||
#include <GraphCanvas/Components/ViewBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Editor/AssetEditorBus.h>
|
||||
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/ConnectionStates.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ConnectionActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/////////////////////
|
||||
// CoupleNodesState
|
||||
/////////////////////
|
||||
|
||||
CoupleNodesState::CoupleNodesState(AutomationStateModelId pickUpNode, GraphCanvas::ConnectionType connectionType, AutomationStateModelId targetNode, AutomationStateModelId outputId)
|
||||
: NamedAutomationState("CoupleNodesState")
|
||||
, m_pickUpNode(pickUpNode)
|
||||
, m_targetNode(targetNode)
|
||||
, m_connectionType(connectionType)
|
||||
, m_outputId(outputId)
|
||||
{
|
||||
SetStateName(AZStd::string::format("CoupleNodes::%s::%s", m_pickUpNode.c_str(), m_targetNode.c_str()));
|
||||
}
|
||||
|
||||
void CoupleNodesState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
const GraphCanvas::NodeId* pickUpNodeId = GetStateModel()->GetStateDataAs<GraphCanvas::NodeId>(m_pickUpNode);
|
||||
const GraphCanvas::NodeId* targetNodeId = GetStateModel()->GetStateDataAs<GraphCanvas::NodeId>(m_targetNode);
|
||||
|
||||
if (pickUpNodeId && targetNodeId)
|
||||
{
|
||||
m_coupleNodesAction = aznew CoupleNodesAction((*pickUpNodeId), m_connectionType, (*targetNodeId));
|
||||
actionRunner.AddAction(m_coupleNodesAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pickUpNodeId == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid EntityId", m_pickUpNode.c_str()));
|
||||
}
|
||||
|
||||
if (targetNodeId == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid EntityId", m_targetNode.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CoupleNodesState::OnStateActionsComplete()
|
||||
{
|
||||
if (!m_outputId.empty())
|
||||
{
|
||||
AZStd::vector< GraphCanvas::ConnectionId > connectionId = m_coupleNodesAction->GetConnectionIds();
|
||||
GetStateModel()->SetStateData(m_outputId, connectionId);
|
||||
}
|
||||
|
||||
delete m_coupleNodesAction;
|
||||
m_coupleNodesAction = nullptr;
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
// ConnectEndpointsState
|
||||
//////////////////////////
|
||||
|
||||
ConnectEndpointsState::ConnectEndpointsState(AutomationStateModelId sourceEndpoint, AutomationStateModelId targetEndpoint, AutomationStateModelId outputId)
|
||||
: NamedAutomationState("ConnectEndpointsState")
|
||||
, m_sourceEndpoint(sourceEndpoint)
|
||||
, m_targetEndpoint(targetEndpoint)
|
||||
, m_outputId(outputId)
|
||||
{
|
||||
SetStateName(AZStd::string::format("ConnectEndpoints::%s::%s", sourceEndpoint.c_str(), targetEndpoint.c_str()));
|
||||
}
|
||||
|
||||
void ConnectEndpointsState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
const GraphCanvas::Endpoint* sourceEndpoint = GetStateModel()->GetStateDataAs<GraphCanvas::Endpoint>(m_sourceEndpoint);
|
||||
const GraphCanvas::Endpoint* targetEndpoint = GetStateModel()->GetStateDataAs<GraphCanvas::Endpoint>(m_targetEndpoint);
|
||||
|
||||
if (sourceEndpoint && targetEndpoint)
|
||||
{
|
||||
m_connectEndpointsAction = aznew ConnectEndpointsAction((*sourceEndpoint), (*targetEndpoint));
|
||||
actionRunner.AddAction(m_connectEndpointsAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sourceEndpoint == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid GraphCanvas::Endpoint", m_sourceEndpoint.c_str()));
|
||||
}
|
||||
|
||||
if (targetEndpoint == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid GraphCanvas::Endpoint", m_targetEndpoint.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectEndpointsState::OnStateActionsComplete()
|
||||
{
|
||||
if (!m_outputId.empty())
|
||||
{
|
||||
GraphCanvas::ConnectionId connectionId = m_connectEndpointsAction->GetConnectionId();
|
||||
GetStateModel()->SetStateData(m_outputId, connectionId);
|
||||
}
|
||||
|
||||
delete m_connectEndpointsAction;
|
||||
m_connectEndpointsAction = nullptr;
|
||||
}
|
||||
}
|
||||
+408
@@ -0,0 +1,408 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <QToolButton>
|
||||
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/SlotBus.h>
|
||||
#include <GraphCanvas/Components/Slots/Data/DataSlotBus.h>
|
||||
#include <GraphCanvas/Components/ViewBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Editor/AssetEditorBus.h>
|
||||
#include <GraphCanvas/Editor/Automation/AutomationIds.h>
|
||||
#include <GraphCanvas/Editor/Automation/AutomationUtils.h>
|
||||
|
||||
#include <GraphCanvas/Widgets/NodePalette/Model/NodePaletteSortFilterProxyModel.h>
|
||||
#include <GraphCanvas/Widgets/NodePalette/NodePaletteTreeView.h>
|
||||
#include <GraphCanvas/Widgets/NodePalette/TreeItems/NodePaletteTreeItem.h>
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
#include <Editor/View/Widgets/VariablePanel/VariableDockWidget.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
#include <ScriptCanvas/GraphCanvas/NodeDescriptorBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/CreateElementsStates.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/CreateElementsActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/WidgetActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
///////////////////////////////
|
||||
// CreateNodeFromPaletteState
|
||||
///////////////////////////////
|
||||
|
||||
CreateNodeFromPaletteState::CreateNodeFromPaletteState(GraphCanvas::NodePaletteWidget* paletteWidget, const QString& nodeName, CreationType creationType, AutomationStateModelId creationDataId, AutomationStateModelId outputId)
|
||||
: NamedAutomationState("CreateNodeFromPaletteState")
|
||||
, m_nodePaletteWidget(paletteWidget)
|
||||
, m_nodeName(nodeName)
|
||||
, m_creationType(creationType)
|
||||
, m_creationDataId(creationDataId)
|
||||
, m_outputId(outputId)
|
||||
, m_delayAction(AZStd::chrono::milliseconds(500))
|
||||
{
|
||||
AZStd::string nameString = AZStd::string::format("CreateNodeFromPaletteState::%s", nodeName.toUtf8().data());
|
||||
|
||||
SetStateName(nameString);
|
||||
}
|
||||
|
||||
void CreateNodeFromPaletteState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
const GraphCanvas::GraphId* graphId = GetStateModel()->GetStateDataAs<GraphCanvas::GraphId>(StateModelIds::GraphCanvasId);
|
||||
|
||||
if (graphId != nullptr && m_nodePaletteWidget != nullptr)
|
||||
{
|
||||
switch (m_creationType)
|
||||
{
|
||||
case CreationType::ScenePosition:
|
||||
{
|
||||
const AZ::Vector2* dropPoint = GetStateModel()->GetStateDataAs<AZ::Vector2>(m_creationDataId);
|
||||
|
||||
if (dropPoint)
|
||||
{
|
||||
QPointF qPoint = QPoint(dropPoint->GetX(), dropPoint->GetY());
|
||||
m_createNodeAction = aznew CreateNodeFromPaletteAction(m_nodePaletteWidget, (*graphId), m_nodeName, qPoint);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CreationType::Splice:
|
||||
{
|
||||
const GraphCanvas::ConnectionId* connectionId = GetStateModel()->GetStateDataAs<GraphCanvas::ConnectionId>(m_creationDataId);
|
||||
|
||||
if (connectionId)
|
||||
{
|
||||
m_createNodeAction = aznew CreateNodeFromPaletteAction(m_nodePaletteWidget, (*graphId), m_nodeName, (*connectionId));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_createNodeAction)
|
||||
{
|
||||
actionRunner.AddAction(m_createNodeAction);
|
||||
actionRunner.AddAction(&m_delayAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError("Unknown creation type provided");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (graphId == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid GraphCanvas::GraphId", StateModelIds::GraphCanvasId));
|
||||
}
|
||||
|
||||
if (m_nodePaletteWidget == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("NodePaletteWidget not provided"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CreateNodeFromPaletteState::OnStateActionsComplete()
|
||||
{
|
||||
if (m_createNodeAction)
|
||||
{
|
||||
if (!m_outputId.empty())
|
||||
{
|
||||
GraphCanvas::NodeId nodeId = m_createNodeAction->GetCreatedNodeId();
|
||||
GetStateModel()->SetStateData(m_outputId, nodeId);
|
||||
}
|
||||
|
||||
delete m_createNodeAction;
|
||||
m_createNodeAction = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////
|
||||
// CreateCategoryFromNodePaletteState
|
||||
///////////////////////////////////////
|
||||
|
||||
CreateCategoryFromNodePaletteState::CreateCategoryFromNodePaletteState(GraphCanvas::NodePaletteWidget* paletteWidget, AutomationStateModelId categoryId, AutomationStateModelId scenePoint, AutomationStateModelId outputId)
|
||||
: NamedAutomationState("CreateCategoryFromNodePaletteState")
|
||||
, m_paletteWidget(paletteWidget)
|
||||
, m_categoryId(categoryId)
|
||||
, m_scenePoint(scenePoint)
|
||||
, m_outputId(outputId)
|
||||
{
|
||||
SetStateName(AZStd::string::format("CreateCategoryFromNodePaletteState::%s", m_categoryId.c_str()));
|
||||
}
|
||||
|
||||
void CreateCategoryFromNodePaletteState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
const GraphCanvas::GraphId* graphId = GetStateModel()->GetStateDataAs<GraphCanvas::GraphId>(StateModelIds::GraphCanvasId);
|
||||
const AZ::Vector2* scenePoint = GetStateModel()->GetStateDataAs<AZ::Vector2>(m_scenePoint);
|
||||
const AZStd::string* category = GetStateModel()->GetStateDataAs<AZStd::string>(m_categoryId);
|
||||
|
||||
if (graphId && scenePoint && category)
|
||||
{
|
||||
m_creationAction = aznew CreateCategoryFromNodePaletteAction(m_paletteWidget, (*graphId), category->c_str(), GraphCanvas::ConversionUtils::AZToQPoint((*scenePoint)));
|
||||
actionRunner.AddAction(m_creationAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (graphId == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid GraphCanvas::GraphId", StateModelIds::GraphCanvasId));
|
||||
}
|
||||
|
||||
if (scenePoint == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid Vector2", m_scenePoint.c_str()));
|
||||
}
|
||||
|
||||
if (category == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid string", m_categoryId.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CreateCategoryFromNodePaletteState::OnStateActionsComplete()
|
||||
{
|
||||
if (m_creationAction)
|
||||
{
|
||||
if (!m_outputId.empty())
|
||||
{
|
||||
auto createdNodeIds = m_creationAction->GetCreatedNodes();
|
||||
GetStateModel()->SetStateData(m_outputId, createdNodeIds);
|
||||
}
|
||||
|
||||
delete m_creationAction;
|
||||
m_creationAction = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
// CreateNodeFromContextMenuState
|
||||
///////////////////////////////////
|
||||
|
||||
CreateNodeFromContextMenuState::CreateNodeFromContextMenuState(const QString& nodeName, CreationType creationType, AutomationStateModelId creationDataId, AutomationStateModelId outputId)
|
||||
: NamedAutomationState("CreateNodeFromContextMenuState")
|
||||
, m_nodeName(nodeName)
|
||||
, m_creationType(creationType)
|
||||
, m_creationDataId(creationDataId)
|
||||
, m_outputId(outputId)
|
||||
, m_delayAction(AZStd::chrono::milliseconds(500))
|
||||
{
|
||||
AZStd::string nameString = AZStd::string::format("CreateNodeFromContextMenuState::%s", nodeName.toUtf8().data());
|
||||
|
||||
SetStateName(nameString);
|
||||
}
|
||||
|
||||
void CreateNodeFromContextMenuState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
const GraphCanvas::GraphId* graphId = GetStateModel()->GetStateDataAs<GraphCanvas::GraphId>(StateModelIds::GraphCanvasId);
|
||||
|
||||
if (graphId != nullptr)
|
||||
{
|
||||
switch (m_creationType)
|
||||
{
|
||||
case CreationType::ScenePosition:
|
||||
{
|
||||
const AZ::Vector2* dropPoint = GetStateModel()->GetStateDataAs<AZ::Vector2>(m_creationDataId);
|
||||
|
||||
if (dropPoint)
|
||||
{
|
||||
QPointF qPoint = QPoint(dropPoint->GetX(), dropPoint->GetY());
|
||||
m_createNodeAction = aznew CreateNodeFromContextMenuAction((*graphId), m_nodeName, qPoint);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CreationType::Splice:
|
||||
{
|
||||
const GraphCanvas::ConnectionId* connectionId = GetStateModel()->GetStateDataAs<GraphCanvas::ConnectionId>(m_creationDataId);
|
||||
|
||||
if (connectionId)
|
||||
{
|
||||
m_createNodeAction = aznew CreateNodeFromContextMenuAction((*graphId), m_nodeName, (*connectionId));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_createNodeAction)
|
||||
{
|
||||
actionRunner.AddAction(m_createNodeAction);
|
||||
actionRunner.AddAction(&m_delayAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError(AZStd::string::format("Failed to configure CreateNodeFromContextMenuState::%s", m_nodeName.toUtf8().data()));
|
||||
}
|
||||
}
|
||||
|
||||
void CreateNodeFromContextMenuState::OnStateActionsComplete()
|
||||
{
|
||||
if (m_createNodeAction)
|
||||
{
|
||||
if (!m_outputId.empty())
|
||||
{
|
||||
GraphCanvas::NodeId nodeId = m_createNodeAction->GetCreatedNodeId();
|
||||
GetStateModel()->SetStateData(m_outputId, nodeId);
|
||||
}
|
||||
|
||||
delete m_createNodeAction;
|
||||
m_createNodeAction = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// CreateNodeFromProposalState
|
||||
////////////////////////////////
|
||||
|
||||
CreateNodeFromProposalState::CreateNodeFromProposalState(const QString& nodeName, AutomationStateModelId endpointId, AutomationStateModelId scenePointId, AutomationStateModelId nodeOutputId, AutomationStateModelId connectionOutputId)
|
||||
: NamedAutomationState("CreateNodeFromProposalState")
|
||||
, m_nodeName(nodeName)
|
||||
, m_endpointId(endpointId)
|
||||
, m_scenePointId(scenePointId)
|
||||
, m_nodeOutputId(nodeOutputId)
|
||||
, m_connectionOutputId(connectionOutputId)
|
||||
, m_delayAction(AZStd::chrono::milliseconds(500))
|
||||
{
|
||||
AZStd::string stateId = AZStd::string::format("CreateNodeFromProposalState::%s", nodeName.toUtf8().data());
|
||||
SetStateName(stateId);
|
||||
}
|
||||
|
||||
void CreateNodeFromProposalState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
const GraphCanvas::GraphId* graphId = GetStateModel()->GetStateDataAs<GraphCanvas::GraphId>(StateModelIds::GraphCanvasId);
|
||||
const GraphCanvas::Endpoint* endpoint = GetStateModel()->GetStateDataAs<GraphCanvas::Endpoint>(m_endpointId);
|
||||
|
||||
if (graphId && endpoint)
|
||||
{
|
||||
if (!m_scenePointId.empty())
|
||||
{
|
||||
const AZ::Vector2* scenePoint = GetStateModel()->GetStateDataAs<AZ::Vector2>(m_scenePointId);
|
||||
|
||||
if (scenePoint)
|
||||
{
|
||||
m_createNodeAction = aznew CreateNodeFromProposalAction((*graphId), (*endpoint), m_nodeName, GraphCanvas::ConversionUtils::AZToQPoint((*scenePoint)));
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is an invalid Vector2", m_scenePointId.c_str()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_createNodeAction = aznew CreateNodeFromProposalAction((*graphId), (*endpoint), m_nodeName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (graphId == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is an invalid GraphCanvas::GraphId", StateModelIds::GraphCanvasId));
|
||||
}
|
||||
|
||||
if (endpoint == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is an invalid GraphCanvas::Endpoint", m_endpointId.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
if (m_createNodeAction)
|
||||
{
|
||||
actionRunner.AddAction(m_createNodeAction);
|
||||
actionRunner.AddAction(&m_delayAction);
|
||||
}
|
||||
}
|
||||
|
||||
void CreateNodeFromProposalState::OnStateActionsComplete()
|
||||
{
|
||||
if (m_createNodeAction)
|
||||
{
|
||||
if (!m_nodeOutputId.empty())
|
||||
{
|
||||
GraphCanvas::NodeId nodeId = m_createNodeAction->GetCreatedNodeId();
|
||||
GetStateModel()->SetStateData(m_nodeOutputId, nodeId);
|
||||
}
|
||||
|
||||
if (!m_connectionOutputId.empty())
|
||||
{
|
||||
GraphCanvas::ConnectionId connectionId = m_createNodeAction->GetConnectionId();
|
||||
GetStateModel()->SetStateData(m_connectionOutputId, connectionId);
|
||||
}
|
||||
|
||||
delete m_createNodeAction;
|
||||
m_createNodeAction = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////
|
||||
// CreateGroupState
|
||||
/////////////////////
|
||||
|
||||
CreateGroupState::CreateGroupState(GraphCanvas::EditorId editorId, CreateGroupAction::CreationType creationType, AutomationStateModelId outputId)
|
||||
: NamedAutomationState("CreateGroupState")
|
||||
, m_editorId(editorId)
|
||||
, m_creationType(creationType)
|
||||
, m_outputId(outputId)
|
||||
, m_delayAction(AZStd::chrono::milliseconds(500))
|
||||
{
|
||||
AZStd::string stateName = "CreateGroupState::%s";
|
||||
|
||||
if (!m_outputId.empty())
|
||||
{
|
||||
stateName.append("::");
|
||||
stateName.append(m_outputId);
|
||||
}
|
||||
|
||||
switch (m_creationType)
|
||||
{
|
||||
case CreateGroupAction::CreationType::Hotkey:
|
||||
stateName = AZStd::string::format(stateName.c_str(), "HotKey");
|
||||
break;
|
||||
case CreateGroupAction::CreationType::Toolbar:
|
||||
stateName = AZStd::string::format(stateName.c_str(), "Toolbar");
|
||||
break;
|
||||
}
|
||||
|
||||
SetStateName(stateName);
|
||||
}
|
||||
|
||||
void CreateGroupState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
const GraphCanvas::GraphId* graphId = GetStateModel()->GetStateDataAs<GraphCanvas::GraphId>(StateModelIds::GraphCanvasId);
|
||||
|
||||
m_createGroupAction = aznew CreateGroupAction(m_editorId, (*graphId), m_creationType);
|
||||
|
||||
actionRunner.AddAction(m_createGroupAction);
|
||||
actionRunner.AddAction(&m_delayAction);
|
||||
}
|
||||
|
||||
void CreateGroupState::OnStateActionsComplete()
|
||||
{
|
||||
if (!m_outputId.empty())
|
||||
{
|
||||
AZ::EntityId groupId = m_createGroupAction->GetCreatedGroupId();
|
||||
GetStateModel()->SetStateData(m_outputId, groupId);
|
||||
}
|
||||
|
||||
delete m_createGroupAction;
|
||||
m_createGroupAction = nullptr;
|
||||
}
|
||||
}
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <QTableView>
|
||||
|
||||
#include <GraphCanvas/Components/Nodes/NodeBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/ViewBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/EditorViewStates.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.h>
|
||||
|
||||
#include <Editor/Include/ScriptCanvas/Bus/RequestBus.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
////////////////////////
|
||||
// SceneMouseMoveState
|
||||
////////////////////////
|
||||
|
||||
SceneMouseMoveState::SceneMouseMoveState(AutomationStateModelId targetPoint)
|
||||
: NamedAutomationState("SceneMouseMoveState")
|
||||
, m_targetPoint(targetPoint)
|
||||
{
|
||||
SetStateName(AZStd::string::format("SceneMouseMoveState::%s", targetPoint.c_str()));
|
||||
}
|
||||
|
||||
void SceneMouseMoveState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
const GraphCanvas::GraphId* graphId = GetStateModel()->GetStateDataAs<GraphCanvas::GraphId>(StateModelIds::GraphCanvasId);
|
||||
const AZ::Vector2* scenePoint = GetStateModel()->GetStateDataAs<AZ::Vector2>(m_targetPoint);
|
||||
|
||||
if (scenePoint && graphId)
|
||||
{
|
||||
m_moveAction = aznew SceneMouseMoveAction((*graphId), GraphCanvas::ConversionUtils::AZToQPoint((*scenePoint)));
|
||||
actionRunner.AddAction(m_moveAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (graphId == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid GraphCanvas::GraphId", StateModelIds::GraphCanvasId));
|
||||
}
|
||||
|
||||
if (scenePoint == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid AZ::Vector2", m_targetPoint.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SceneMouseMoveState::OnStateActionsComplete()
|
||||
{
|
||||
delete m_moveAction;
|
||||
m_moveAction = nullptr;
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
// SceneMouseDragState
|
||||
////////////////////////
|
||||
|
||||
SceneMouseDragState::SceneMouseDragState(AutomationStateModelId startPoint, AutomationStateModelId endPoint, Qt::MouseButton mouseButton)
|
||||
: NamedAutomationState("SceneMouseDragState")
|
||||
, m_startPoint(startPoint)
|
||||
, m_endPoint(endPoint)
|
||||
, m_mouseButton(mouseButton)
|
||||
{
|
||||
SetStateName(AZStd::string::format("SceneMouseDragState::%s::%s", m_startPoint.c_str(), m_endPoint.c_str()));
|
||||
}
|
||||
|
||||
void SceneMouseDragState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
const GraphCanvas::GraphId* graphId = GetStateModel()->GetStateDataAs<GraphCanvas::GraphId>(StateModelIds::GraphCanvasId);
|
||||
|
||||
const AZ::Vector2* startPoint = GetStateModel()->GetStateDataAs<AZ::Vector2>(m_startPoint);
|
||||
const AZ::Vector2* endPoint = GetStateModel()->GetStateDataAs<AZ::Vector2>(m_endPoint);
|
||||
|
||||
if (startPoint && endPoint && graphId)
|
||||
{
|
||||
m_dragAction = aznew SceneMouseDragAction((*graphId), GraphCanvas::ConversionUtils::AZToQPoint((*startPoint)), GraphCanvas::ConversionUtils::AZToQPoint((*endPoint)), m_mouseButton);
|
||||
actionRunner.AddAction(m_dragAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (startPoint == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid AZ::Vector2", m_startPoint.c_str()));
|
||||
}
|
||||
|
||||
if (endPoint == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid AZ::Vector2", m_endPoint.c_str()));
|
||||
}
|
||||
|
||||
if (graphId == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid GraphCanvas::GraphId", StateModelIds::GraphCanvasId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SceneMouseDragState::OnStateActionsComplete()
|
||||
{
|
||||
delete m_dragAction;
|
||||
m_dragAction = nullptr;
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
// FindViewCenterState
|
||||
////////////////////////
|
||||
|
||||
FindViewCenterState::FindViewCenterState(AutomationStateModelId outputId)
|
||||
: CustomActionState("FindViewCenterState")
|
||||
, m_outputId(outputId)
|
||||
{
|
||||
SetStateName(AZStd::string::format("FindViewCenterState::%s", outputId.c_str()));
|
||||
}
|
||||
|
||||
void FindViewCenterState::OnCustomAction()
|
||||
{
|
||||
if (!m_outputId.empty())
|
||||
{
|
||||
const GraphCanvas::ViewId* viewId = GetStateModel()->GetStateDataAs<GraphCanvas::ViewId>(StateModelIds::ViewId);
|
||||
|
||||
if (viewId)
|
||||
{
|
||||
QRectF viewableRect;
|
||||
GraphCanvas::ViewRequestBus::EventResult(viewableRect, (*viewId), &GraphCanvas::ViewRequests::GetViewableAreaInSceneCoordinates);
|
||||
|
||||
AZ::Vector2 viewCenter = GraphCanvas::ConversionUtils::QPointToVector(viewableRect.center());
|
||||
GetStateModel()->SetStateData(m_outputId, viewCenter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <platform.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/ElementInteractionStates.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
////////////////////////////
|
||||
// SelectSceneElementState
|
||||
////////////////////////////
|
||||
|
||||
SelectSceneElementState::SelectSceneElementState(AutomationStateModelId targetId)
|
||||
: NamedAutomationState("SelectSceneElementState")
|
||||
, m_targetId(targetId)
|
||||
{
|
||||
SetStateName(AZStd::string::format("SelectSceneElementState::%s", targetId.c_str()));
|
||||
}
|
||||
|
||||
void SelectSceneElementState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
const AZ::EntityId* targetId = GetStateModel()->GetStateDataAs<AZ::EntityId>(m_targetId);
|
||||
|
||||
if (targetId)
|
||||
{
|
||||
m_selectSceneElement = aznew SelectSceneElementAction((*targetId));
|
||||
actionRunner.AddAction(m_selectSceneElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid EntityId", m_targetId.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
void SelectSceneElementState::OnStateActionsComplete()
|
||||
{
|
||||
if (m_selectSceneElement)
|
||||
{
|
||||
delete m_selectSceneElement;
|
||||
m_selectSceneElement = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// AltClickSceneElementState
|
||||
//////////////////////////////
|
||||
|
||||
AltClickSceneElementState::AltClickSceneElementState(AutomationStateModelId targetId)
|
||||
: NamedAutomationState("AltClickSceneElementState")
|
||||
, m_targetId(targetId)
|
||||
{
|
||||
SetStateName(AZStd::string::format("AltClickSceneElementState::%s", targetId.c_str()));
|
||||
}
|
||||
|
||||
void AltClickSceneElementState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
const AZ::EntityId* targetId = GetStateModel()->GetStateDataAs<AZ::EntityId>(m_targetId);
|
||||
|
||||
if (targetId)
|
||||
{
|
||||
m_altClickAction = aznew AltClickSceneElementAction((*targetId));
|
||||
actionRunner.AddAction(m_altClickAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid EntityId", m_targetId.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
void AltClickSceneElementState::OnStateActionsComplete()
|
||||
{
|
||||
if (m_altClickAction)
|
||||
{
|
||||
delete m_altClickAction;
|
||||
m_altClickAction = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
// MouseToNodePropertyEditorState
|
||||
///////////////////////////////////
|
||||
|
||||
MouseToNodePropertyEditorState::MouseToNodePropertyEditorState(AutomationStateModelId slotId)
|
||||
: NamedAutomationState("MouseToNodePropertyEditorState")
|
||||
, m_slotId(slotId)
|
||||
{
|
||||
SetStateName(AZStd::string::format("MouseToNodePropertyEditorState::%s", slotId.c_str()));
|
||||
}
|
||||
|
||||
void MouseToNodePropertyEditorState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
const GraphCanvas::SlotId* slotId = GetStateModel()->GetStateDataAs<GraphCanvas::SlotId>(m_slotId);
|
||||
|
||||
if (slotId)
|
||||
{
|
||||
m_moveToPropertyAction = aznew MouseToNodePropertyEditorAction((*slotId));
|
||||
actionRunner.AddAction(m_moveToPropertyAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid SlotId", m_slotId.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
void MouseToNodePropertyEditorState::OnStateActionsComplete()
|
||||
{
|
||||
delete m_moveToPropertyAction;
|
||||
m_moveToPropertyAction = nullptr;
|
||||
}
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <QToolButton>
|
||||
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Editor/Automation/AutomationUtils.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
#include <ScriptCanvas/GraphCanvas/NodeDescriptorBus.h>
|
||||
#include <Editor/GraphCanvas/AutomationIds.h>
|
||||
#include <Editor/Include/ScriptCanvas/Bus/EditorScriptCanvasBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/GraphStates.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
////////////////////////////
|
||||
// CreateRuntimeGraphState
|
||||
////////////////////////////
|
||||
|
||||
CreateRuntimeGraphState::CreateRuntimeGraphState()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CreateRuntimeGraphState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
actionRunner.AddAction(&m_createNewGraphAction);
|
||||
}
|
||||
|
||||
void CreateRuntimeGraphState::OnStateActionsComplete()
|
||||
{
|
||||
GraphCanvas::GraphId graphId = m_createNewGraphAction.GetGraphId();
|
||||
SetModelData(StateModelIds::GraphCanvasId, graphId);
|
||||
|
||||
ScriptCanvas::ScriptCanvasId scriptCanvasId;
|
||||
ScriptCanvasEditor::GeneralRequestBus::BroadcastResult(scriptCanvasId, &ScriptCanvasEditor::GeneralRequests::GetScriptCanvasId, graphId);
|
||||
SetModelData(StateModelIds::ScriptCanvasId, scriptCanvasId);
|
||||
|
||||
GraphCanvas::ViewId viewId;
|
||||
GraphCanvas::SceneRequestBus::EventResult(viewId, graphId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
SetModelData(StateModelIds::ViewId, viewId);
|
||||
|
||||
AZ::Vector2 minorStep = GraphCanvas::GraphUtils::FindMinorStep(graphId);
|
||||
SetModelData(StateModelIds::MinorStep, minorStep);
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
// CreateFunctionGraphState
|
||||
/////////////////////////////
|
||||
|
||||
CreateFunctionGraphState::CreateFunctionGraphState()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CreateFunctionGraphState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
actionRunner.AddAction(&m_createNewFunctionAction);
|
||||
}
|
||||
|
||||
void CreateFunctionGraphState::OnStateActionsComplete()
|
||||
{
|
||||
GraphCanvas::GraphId graphId = m_createNewFunctionAction.GetGraphId();
|
||||
SetModelData(StateModelIds::GraphCanvasId, graphId);
|
||||
|
||||
ScriptCanvas::ScriptCanvasId scriptCanvasId;
|
||||
ScriptCanvasEditor::GeneralRequestBus::BroadcastResult(scriptCanvasId, &ScriptCanvasEditor::GeneralRequests::GetScriptCanvasId, graphId);
|
||||
SetModelData(StateModelIds::ScriptCanvasId, scriptCanvasId);
|
||||
|
||||
GraphCanvas::ViewId viewId;
|
||||
GraphCanvas::SceneRequestBus::EventResult(viewId, graphId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
SetModelData(StateModelIds::ViewId, viewId);
|
||||
|
||||
AZ::Vector2 minorStep = GraphCanvas::GraphUtils::FindMinorStep(graphId);
|
||||
SetModelData(StateModelIds::MinorStep, minorStep);
|
||||
}
|
||||
|
||||
///////////////////////////////
|
||||
// ForceCloseActiveGraphState
|
||||
///////////////////////////////
|
||||
|
||||
ForceCloseActiveGraphState::ForceCloseActiveGraphState()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ForceCloseActiveGraphState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
actionRunner.AddAction(&m_forceCloseActiveGraph);
|
||||
}
|
||||
}
|
||||
+322
@@ -0,0 +1,322 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <QTableView>
|
||||
|
||||
#include <GraphCanvas/Components/Nodes/Group/NodeGroupBus.h>
|
||||
#include <GraphCanvas/Components/Nodes/NodeBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/ViewBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/UtilityStates.h>
|
||||
|
||||
#include <Editor/Include/ScriptCanvas/Bus/RequestBus.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/////////////////////
|
||||
// FindNodePosition
|
||||
/////////////////////
|
||||
|
||||
FindNodePosition::FindNodePosition(AutomationStateModelId nodeId, AutomationStateModelId outputId, FindPositionOffsets offsets)
|
||||
: CustomActionState("FindNodePosition")
|
||||
, m_offsets(offsets)
|
||||
, m_nodeId(nodeId)
|
||||
, m_outputId(outputId)
|
||||
{
|
||||
SetStateName(AZStd::string::format("FindNodePosition::%s::%s", m_nodeId.c_str(), m_outputId.c_str()));
|
||||
}
|
||||
|
||||
void FindNodePosition::OnCustomAction()
|
||||
{
|
||||
const GraphCanvas::NodeId* nodeId = GetStateModel()->GetStateDataAs<GraphCanvas::NodeId>(m_nodeId);
|
||||
|
||||
if (nodeId)
|
||||
{
|
||||
QGraphicsItem* graphicsItem = nullptr;
|
||||
GraphCanvas::VisualRequestBus::EventResult(graphicsItem, (*nodeId), &GraphCanvas::VisualRequests::AsGraphicsItem);
|
||||
|
||||
if (graphicsItem)
|
||||
{
|
||||
QRectF boundingRect = graphicsItem->sceneBoundingRect();
|
||||
|
||||
qreal horizontalPoint = boundingRect.left() + boundingRect.width() * m_offsets.m_horizontalPosition;
|
||||
horizontalPoint += m_offsets.m_horizontalOffset;
|
||||
|
||||
qreal verticalPoint = boundingRect.top() + boundingRect.height() * m_offsets.m_verticalPosition;
|
||||
verticalPoint += m_offsets.m_verticalOffset;
|
||||
|
||||
AZ::Vector2 scenePoint(horizontalPoint, verticalPoint);
|
||||
GetStateModel()->SetStateData(m_outputId, scenePoint);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid EntityId", m_nodeId.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
// FindGroupPosition
|
||||
//////////////////////
|
||||
|
||||
FindGroupPosition::FindGroupPosition(AutomationStateModelId groupId, AutomationStateModelId outputId, FindPositionOffsets offsets)
|
||||
: CustomActionState("FindGroupPosition")
|
||||
, m_offsets(offsets)
|
||||
, m_groupId(groupId)
|
||||
, m_outputId(outputId)
|
||||
{
|
||||
SetStateName(AZStd::string::format("FindGroupPosition::%s::%s", m_groupId.c_str(), m_outputId.c_str()));
|
||||
}
|
||||
|
||||
void FindGroupPosition::OnCustomAction()
|
||||
{
|
||||
const AZ::EntityId* groupId = GetStateModel()->GetStateDataAs<AZ::EntityId>(m_groupId);
|
||||
|
||||
if (groupId)
|
||||
{
|
||||
QRectF groupBoundingBox;
|
||||
GraphCanvas::NodeGroupRequestBus::EventResult(groupBoundingBox, (*groupId), &GraphCanvas::NodeGroupRequests::GetGroupBoundingBox);
|
||||
|
||||
qreal horizontalPoint = groupBoundingBox.left() + groupBoundingBox.width() * m_offsets.m_horizontalPosition;
|
||||
horizontalPoint += m_offsets.m_horizontalOffset;
|
||||
|
||||
qreal verticalPoint = groupBoundingBox.top() + groupBoundingBox.height() * m_offsets.m_verticalPosition;
|
||||
verticalPoint += m_offsets.m_verticalPosition;
|
||||
|
||||
AZ::Vector2 scenePoint(horizontalPoint, verticalPoint);
|
||||
GetStateModel()->SetStateData(m_outputId, scenePoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid EntityId", m_groupId.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
// FindEndpointOfTypeState
|
||||
////////////////////////////
|
||||
|
||||
FindEndpointOfTypeState::FindEndpointOfTypeState(AutomationStateModelId targetNodeId, AutomationStateModelId outputId, GraphCanvas::ConnectionType connectionType, GraphCanvas::SlotType slotType, int slotNumber)
|
||||
: CustomActionState("FindEndpointOfTypeState")
|
||||
, m_targetNodeId(targetNodeId)
|
||||
, m_outputId(outputId)
|
||||
, m_slotNumber(slotNumber)
|
||||
, m_connectionType(connectionType)
|
||||
, m_slotType(slotType)
|
||||
{
|
||||
SetStateName(AZStd::string::format("FindEndpointOfType::%s::%s", targetNodeId.c_str(), outputId.c_str()));
|
||||
}
|
||||
|
||||
void FindEndpointOfTypeState::OnCustomAction()
|
||||
{
|
||||
const GraphCanvas::NodeId* nodeId = GetStateModel()->GetStateDataAs<GraphCanvas::NodeId>(m_targetNodeId);
|
||||
|
||||
if (nodeId)
|
||||
{
|
||||
AZStd::vector< GraphCanvas::SlotId > slotIds;
|
||||
GraphCanvas::NodeRequestBus::EventResult(slotIds, (*nodeId), &GraphCanvas::NodeRequests::FindVisibleSlotIdsByType, m_connectionType, m_slotType);
|
||||
|
||||
if (slotIds.size() <= m_slotNumber)
|
||||
{
|
||||
ReportError(AZStd::string::format("Slot Number %i is out of scope for the current node.", m_slotNumber));
|
||||
return;
|
||||
}
|
||||
|
||||
GraphCanvas::SlotId slotId = slotIds[m_slotNumber];
|
||||
|
||||
GraphCanvas::Endpoint endpoint = GraphCanvas::Endpoint((*nodeId), slotId);
|
||||
GetStateModel()->SetStateData(m_outputId, endpoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid EntityId", m_targetNodeId.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
// GetLastConnection
|
||||
//////////////////////
|
||||
|
||||
GetLastConnection::GetLastConnection(AutomationStateModelId targetEndpoint, AutomationStateModelId outputId)
|
||||
: CustomActionState("GetLastConnection")
|
||||
, m_targetEndpoint(targetEndpoint)
|
||||
, m_outputId(outputId)
|
||||
{
|
||||
SetStateName(AZStd::string::format("GetLastConnection::%s", targetEndpoint.c_str()));
|
||||
}
|
||||
|
||||
void GetLastConnection::OnCustomAction()
|
||||
{
|
||||
const GraphCanvas::Endpoint* targetEndpoint = GetStateModel()->GetStateDataAs<GraphCanvas::Endpoint>(m_targetEndpoint);
|
||||
|
||||
if (targetEndpoint)
|
||||
{
|
||||
GraphCanvas::ConnectionId connectionId;
|
||||
GraphCanvas::SlotRequestBus::EventResult(connectionId, targetEndpoint->GetSlotId(), &GraphCanvas::SlotRequests::GetLastConnection);
|
||||
|
||||
GetStateModel()->SetStateData(m_outputId, connectionId);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid GraphCanvas::Endpoint", m_targetEndpoint.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// DeleteVariableRowFromPaletteState
|
||||
//////////////////////////////////////
|
||||
|
||||
#if !defined(AZ_COMPILER_MSVC)
|
||||
#ifndef VK_DELETE
|
||||
#define VK_DELETE 0x2E
|
||||
#endif
|
||||
|
||||
#ifndef VK_CONTROL
|
||||
#define VK_CONTROL 0x11
|
||||
#endif
|
||||
#endif
|
||||
|
||||
DeleteVariableRowFromPaletteState::DeleteVariableRowFromPaletteState(int row)
|
||||
: NamedAutomationState("DeleteVariableRowFromPaletteState")
|
||||
, m_row(row)
|
||||
, m_clickAction(Qt::MouseButton::LeftButton)
|
||||
, m_deleteAction(VK_DELETE)
|
||||
{
|
||||
SetStateName(AZStd::string::format("DeleteVariableRowState::%i", row));
|
||||
}
|
||||
|
||||
void DeleteVariableRowFromPaletteState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
QTableView* graphPalette;
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(graphPalette, &ScriptCanvasEditor::VariableAutomationRequests::GetGraphPaletteTableView);
|
||||
|
||||
m_rowCount = graphPalette->model()->rowCount();
|
||||
|
||||
m_mouseToRow = aznew MoveMouseToViewRowAction(graphPalette, 0);
|
||||
|
||||
actionRunner.AddAction(m_mouseToRow);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
actionRunner.AddAction(&m_clickAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
actionRunner.AddAction(&m_deleteAction);
|
||||
}
|
||||
|
||||
void DeleteVariableRowFromPaletteState::OnStateActionsComplete()
|
||||
{
|
||||
delete m_mouseToRow;
|
||||
m_mouseToRow = nullptr;
|
||||
|
||||
QTableView* graphPalette;
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(graphPalette, &ScriptCanvasEditor::VariableAutomationRequests::GetGraphPaletteTableView);
|
||||
|
||||
if (graphPalette->model()->rowCount() >= m_rowCount)
|
||||
{
|
||||
ReportError("Failed to delete variable row from table.");
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////
|
||||
// CheckIsInGroup
|
||||
///////////////////
|
||||
|
||||
CheckIsInGroup::CheckIsInGroup(AutomationStateModelId sceneMemberId, AutomationStateModelId groupId, bool expectResult, AZStd::string stateName)
|
||||
: CustomActionState("CheckIsInGroup")
|
||||
, m_sceneMemberId(sceneMemberId)
|
||||
, m_groupId(groupId)
|
||||
, m_expectResult(expectResult)
|
||||
{
|
||||
if (stateName.empty())
|
||||
{
|
||||
SetStateName(AZStd::string::format("CheckGroupStatus::%s::%s", sceneMemberId.c_str(), groupId.c_str()));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetStateName(stateName);
|
||||
}
|
||||
}
|
||||
|
||||
void CheckIsInGroup::OnCustomAction()
|
||||
{
|
||||
const AZ::EntityId* sceneMemberTarget = GetStateModel()->GetStateDataAs<AZ::EntityId>(m_sceneMemberId);
|
||||
const AZ::EntityId* targetGroupId = GetStateModel()->GetStateDataAs<AZ::EntityId>(m_groupId);
|
||||
|
||||
if (sceneMemberTarget && targetGroupId)
|
||||
{
|
||||
AZ::EntityId groupId;
|
||||
GraphCanvas::GroupableSceneMemberRequestBus::EventResult(groupId, (*sceneMemberTarget), &GraphCanvas::GroupableSceneMemberRequests::GetGroupId);
|
||||
|
||||
bool groupMatch = groupId == (*targetGroupId);
|
||||
|
||||
if (groupMatch != m_expectResult)
|
||||
{
|
||||
ReportError(AZStd::string::format("Group Status of %s not in expected state.", m_sceneMemberId.c_str()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AZStd::string errorString;
|
||||
|
||||
if (sceneMemberTarget == nullptr)
|
||||
{
|
||||
errorString = AZStd::string::format("%s is not a valid EntityId", m_sceneMemberId.c_str());
|
||||
}
|
||||
|
||||
if (targetGroupId == nullptr)
|
||||
{
|
||||
if (!errorString.empty())
|
||||
{
|
||||
errorString += ", ";
|
||||
}
|
||||
|
||||
errorString += AZStd::string::format("%s is not a valid EntityId", m_groupId.c_str());
|
||||
}
|
||||
|
||||
ReportError(errorString);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// TriggerHotKey
|
||||
//////////////////
|
||||
|
||||
TriggerHotKey::TriggerHotKey(QChar hotKey, AZStd::string stateId)
|
||||
: NamedAutomationState("TriggerHotKey")
|
||||
, m_typeAction(hotKey)
|
||||
, m_pressCtrlAction(VK_CONTROL)
|
||||
, m_releaseCtrlAction(VK_CONTROL)
|
||||
{
|
||||
if (stateId.empty())
|
||||
{
|
||||
QString name = hotKey;
|
||||
SetStateName(AZStd::string::format("TriggerHotKey::%s", name.toUtf8().data()));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetStateName(stateId);
|
||||
}
|
||||
}
|
||||
|
||||
void TriggerHotKey::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
actionRunner.AddAction(&m_pressCtrlAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
actionRunner.AddAction(&m_typeAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
actionRunner.AddAction(&m_releaseCtrlAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
}
|
||||
}
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QPushButton>
|
||||
#include <QTableView>
|
||||
#include <QToolButton>
|
||||
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/SlotBus.h>
|
||||
#include <GraphCanvas/Components/Slots/Data/DataSlotBus.h>
|
||||
#include <GraphCanvas/Components/ViewBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Editor/AssetEditorBus.h>
|
||||
|
||||
#include <GraphCanvas/Widgets/NodePalette/Model/NodePaletteSortFilterProxyModel.h>
|
||||
#include <GraphCanvas/Widgets/NodePalette/NodePaletteTreeView.h>
|
||||
#include <GraphCanvas/Widgets/NodePalette/TreeItems/NodePaletteTreeItem.h>
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
#include <Editor/View/Widgets/VariablePanel/VariableDockWidget.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
#include <ScriptCanvas/GraphCanvas/NodeDescriptorBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/VariableStates.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/WidgetActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
////////////////////////
|
||||
// CreateVariableState
|
||||
////////////////////////
|
||||
|
||||
CreateVariableState::CreateVariableState(AutomationStateModelId dataTypeId, AutomationStateModelId nameId, bool errorOnNameMisMatch, CreateVariableAction::CreationType creationType, AutomationStateModelId outputId)
|
||||
: NamedAutomationState("CreateVariableState")
|
||||
, m_dataTypeId(dataTypeId)
|
||||
, m_nameId(nameId)
|
||||
, m_outputId(outputId)
|
||||
, m_creationType(creationType)
|
||||
, m_errorOnNameMismatch(errorOnNameMisMatch)
|
||||
{
|
||||
SetStateName(AZStd::string::format("CreateVariableState::%s", dataTypeId.c_str()));
|
||||
}
|
||||
|
||||
void CreateVariableState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
const ScriptCanvas::Data::Type* dataType = GetStateModel()->GetStateDataAs<ScriptCanvas::Data::Type>(m_dataTypeId);
|
||||
|
||||
if (dataType)
|
||||
{
|
||||
if (!m_nameId.empty())
|
||||
{
|
||||
const AZStd::string* variableName = GetStateModel()->GetStateDataAs<AZStd::string>(m_nameId);
|
||||
|
||||
if (variableName)
|
||||
{
|
||||
QString name = QString(variableName->c_str());
|
||||
m_createVariableAction = aznew CreateVariableAction((*dataType), name, m_creationType);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a string value", m_nameId.c_str()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_createVariableAction = aznew CreateVariableAction((*dataType), m_creationType);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid ScriptCanvas::Data::DataType", m_dataTypeId.c_str()));
|
||||
}
|
||||
|
||||
if (m_createVariableAction)
|
||||
{
|
||||
m_createVariableAction->SetErrorOnNameMisMatch(m_errorOnNameMismatch);
|
||||
actionRunner.AddAction(m_createVariableAction);
|
||||
}
|
||||
}
|
||||
|
||||
void CreateVariableState::OnStateActionsComplete()
|
||||
{
|
||||
if (m_createVariableAction)
|
||||
{
|
||||
if (!m_outputId.empty())
|
||||
{
|
||||
ScriptCanvas::VariableId variableId = m_createVariableAction->GetVariableId();
|
||||
GetStateModel()->SetStateData(m_outputId, variableId);
|
||||
}
|
||||
|
||||
delete m_createVariableAction;
|
||||
m_createVariableAction = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
// CreateVariableNodeFromGraphPaletteState
|
||||
////////////////////////////////////////////
|
||||
|
||||
CreateVariableNodeFromGraphPaletteState::CreateVariableNodeFromGraphPaletteState(AutomationStateModelId variableNameId, AutomationStateModelId scenePoint, Qt::KeyboardModifier modifier, AutomationStateModelId outputId)
|
||||
: NamedAutomationState("CreateVariableNodeFromGraphPaletteState")
|
||||
, m_variableNameId(variableNameId)
|
||||
, m_scenePoint(scenePoint)
|
||||
, m_outputId(outputId)
|
||||
, m_modifier(modifier)
|
||||
{
|
||||
AZStd::string keyModifier;
|
||||
|
||||
if (modifier == Qt::KeyboardModifier::AltModifier)
|
||||
{
|
||||
keyModifier = "Alt";
|
||||
}
|
||||
else if (modifier == Qt::KeyboardModifier::ShiftModifier)
|
||||
{
|
||||
keyModifier = "Shift";
|
||||
}
|
||||
else
|
||||
{
|
||||
keyModifier = "???";
|
||||
}
|
||||
|
||||
SetStateName(AZStd::string::format("CreateVariableNodeFromGraphPaletteState::%s::%s", m_variableNameId.c_str(), keyModifier.c_str()));
|
||||
}
|
||||
|
||||
void CreateVariableNodeFromGraphPaletteState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
const GraphCanvas::GraphId* graphId = GetStateModel()->GetStateDataAs<GraphCanvas::GraphId>(StateModelIds::GraphCanvasId);
|
||||
const AZStd::string* variableName = GetStateModel()->GetStateDataAs<AZStd::string>(m_variableNameId);
|
||||
const AZ::Vector2* scenePoint = GetStateModel()->GetStateDataAs<AZ::Vector2>(m_scenePoint);
|
||||
|
||||
if (graphId && variableName && scenePoint)
|
||||
{
|
||||
m_createVariable = aznew CreateVariableNodeFromGraphPalette((*variableName), (*graphId), GraphCanvas::ConversionUtils::AZToQPoint((*scenePoint)).toPoint(), m_modifier);
|
||||
actionRunner.AddAction(m_createVariable);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (graphId == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a GraphCanvas::GraphId", StateModelIds::GraphCanvasId));
|
||||
}
|
||||
|
||||
if (variableName == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid string", m_variableNameId.c_str()));
|
||||
}
|
||||
|
||||
if (scenePoint == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid Vector2", m_scenePoint.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CreateVariableNodeFromGraphPaletteState::OnStateActionsComplete()
|
||||
{
|
||||
if (m_createVariable)
|
||||
{
|
||||
if (!m_outputId.empty())
|
||||
{
|
||||
AZ::EntityId nodeId = m_createVariable->GetCreatedNodeId();
|
||||
GetStateModel()->SetStateData(m_outputId, nodeId);
|
||||
}
|
||||
|
||||
delete m_createVariable;
|
||||
m_createVariable = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
+357
@@ -0,0 +1,357 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/////////////////////////////////
|
||||
// EditorAutomationActionRunner
|
||||
/////////////////////////////////
|
||||
|
||||
EditorAutomationActionRunner::~EditorAutomationActionRunner()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
void EditorAutomationActionRunner::Reset()
|
||||
{
|
||||
for (EditorAutomationAction* deleteAction : m_actionsToDelete)
|
||||
{
|
||||
delete deleteAction;
|
||||
}
|
||||
|
||||
m_actionsToDelete.clear();
|
||||
|
||||
while (!m_executionStack.empty())
|
||||
{
|
||||
m_executionStack.erase(m_executionStack.begin());
|
||||
}
|
||||
|
||||
m_errorReports.clear();
|
||||
m_currentAction = nullptr;
|
||||
}
|
||||
|
||||
bool EditorAutomationActionRunner::Tick()
|
||||
{
|
||||
if (m_currentAction == nullptr)
|
||||
{
|
||||
if (m_executionStack.empty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_currentAction = m_executionStack.front();
|
||||
|
||||
while (m_currentAction->IsMissingPrecondition())
|
||||
{
|
||||
if (m_currentAction->IsAtPreconditionLimit())
|
||||
{
|
||||
ActionReport failureReport;
|
||||
failureReport = AZ::Failure<AZStd::string>("Action failed to setup its preconditions in a reasonable amount of iterations. Exiting test.");
|
||||
m_errorReports.emplace_back(failureReport);
|
||||
|
||||
m_currentAction->ResetPreconditionAttempts();
|
||||
|
||||
// Leak elements, then we'll just exit through normal paths next tick.
|
||||
m_executionStack.clear();
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorAutomationAction* newAction = m_currentAction->GenerationPreconditionActions();
|
||||
|
||||
m_actionsToDelete.emplace(newAction);
|
||||
|
||||
if (newAction)
|
||||
{
|
||||
m_currentAction = newAction;
|
||||
m_executionStack.insert(m_executionStack.begin(), newAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Erase our current front of stack, as that is our current action.
|
||||
m_executionStack.erase(m_executionStack.begin());
|
||||
|
||||
AZ_Assert(m_currentAction, "Current Action should not be null at this point.");
|
||||
|
||||
if (m_currentAction == nullptr)
|
||||
{
|
||||
// Leak all the memory. We'll just exit through the normal path next tick.
|
||||
m_executionStack.clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_currentAction->SignalActionBegin();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_currentAction)
|
||||
{
|
||||
if (m_currentAction->Tick())
|
||||
{
|
||||
ActionReport errorReport = m_currentAction->GenerateReport();
|
||||
|
||||
if (!errorReport.IsSuccess())
|
||||
{
|
||||
m_errorReports.emplace_back(errorReport);
|
||||
}
|
||||
|
||||
m_currentAction = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void EditorAutomationActionRunner::AddAction(EditorAutomationAction* actionToRun)
|
||||
{
|
||||
m_executionStack.emplace_back(actionToRun);
|
||||
}
|
||||
|
||||
bool EditorAutomationActionRunner::HasActions() const
|
||||
{
|
||||
return !m_executionStack.empty();
|
||||
}
|
||||
|
||||
bool EditorAutomationActionRunner::HasErrors() const
|
||||
{
|
||||
return !m_errorReports.empty();
|
||||
}
|
||||
|
||||
const AZStd::vector< ActionReport >& EditorAutomationActionRunner::GetErrors() const
|
||||
{
|
||||
return m_errorReports;
|
||||
}
|
||||
|
||||
///////////////
|
||||
// StateModel
|
||||
///////////////
|
||||
|
||||
const AZStd::any* StateModel::FindStateData(const DataKey& dataId) const
|
||||
{
|
||||
auto dataIter = m_stateData.find(dataId);
|
||||
|
||||
if (dataIter != m_stateData.end())
|
||||
{
|
||||
return &dataIter->second;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void StateModel::ClearModelData()
|
||||
{
|
||||
m_stateData.clear();
|
||||
}
|
||||
|
||||
/////////////////////////
|
||||
// EditorAutomationTest
|
||||
/////////////////////////
|
||||
|
||||
EditorAutomationTest::EditorAutomationTest(QString testName)
|
||||
: m_testName(testName)
|
||||
{
|
||||
}
|
||||
|
||||
EditorAutomationTest::~EditorAutomationTest()
|
||||
{
|
||||
for (const auto& statePair : m_states)
|
||||
{
|
||||
delete statePair.second;
|
||||
}
|
||||
|
||||
m_states.clear();
|
||||
}
|
||||
|
||||
void EditorAutomationTest::StartTest()
|
||||
{
|
||||
m_hasRun = true;
|
||||
|
||||
m_testErrors.clear();
|
||||
|
||||
OnTestStarting();
|
||||
|
||||
m_stateId = m_initialStateId;
|
||||
m_actionRunner.Reset();
|
||||
|
||||
if (SetupState(m_stateId))
|
||||
{
|
||||
AZ::SystemTickBus::Handler::BusConnect();
|
||||
}
|
||||
else
|
||||
{
|
||||
OnTestComplete();
|
||||
}
|
||||
}
|
||||
|
||||
void EditorAutomationTest::OnSystemTick()
|
||||
{
|
||||
if (m_actionRunner.Tick())
|
||||
{
|
||||
if (!HasErrors())
|
||||
{
|
||||
if (m_actionRunner.HasErrors())
|
||||
{
|
||||
const AZStd::vector<ActionReport>& actionErrors = m_actionRunner.GetErrors();
|
||||
|
||||
for (const ActionReport& actionErrorReport : actionErrors)
|
||||
{
|
||||
AddError(actionErrorReport.GetError());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_currentState->StateActionsComplete();
|
||||
|
||||
if (m_currentState->HasErrors())
|
||||
{
|
||||
AddError(m_currentState->GetError());
|
||||
}
|
||||
|
||||
m_currentState = nullptr;
|
||||
}
|
||||
|
||||
//++m_state;
|
||||
|
||||
m_actionRunner.Reset();
|
||||
|
||||
if (!HasErrors())
|
||||
{
|
||||
OnStateComplete(m_stateId);
|
||||
|
||||
int nextStateId = FindNextState(m_stateId);
|
||||
if (!SetupState(nextStateId))
|
||||
{
|
||||
AZ::SystemTickBus::Handler::BusDisconnect();
|
||||
OnTestComplete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ::SystemTickBus::Handler::BusDisconnect();
|
||||
OnTestComplete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ::SystemTickBus::Handler::BusDisconnect();
|
||||
OnTestComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EditorAutomationTest::AddState(EditorAutomationState* newState)
|
||||
{
|
||||
int stateId = newState->GetStateId();
|
||||
|
||||
if (stateId == EditorAutomationState::EXIT_STATE_ID)
|
||||
{
|
||||
AZ_Error("EditorAutomationTest", false, "Trying to use reserved exit state id");
|
||||
delete newState;
|
||||
return;
|
||||
}
|
||||
|
||||
auto stateIter = m_states.find(stateId);
|
||||
|
||||
if (stateIter != m_states.end())
|
||||
{
|
||||
AZ_Error("EditorAutomationTest", false, "Collision on StateId %i found. Maintaining first state with id", stateId);
|
||||
delete newState;
|
||||
return;
|
||||
}
|
||||
|
||||
m_registrationOrder.emplace_back(stateId);
|
||||
m_states[stateId] = newState;
|
||||
newState->SetStateModel(this);
|
||||
|
||||
if (m_initialStateId == EditorAutomationState::EXIT_STATE_ID)
|
||||
{
|
||||
m_initialStateId = stateId;
|
||||
}
|
||||
}
|
||||
|
||||
void EditorAutomationTest::SetHasCustomTransitions(bool hasCustomTransition)
|
||||
{
|
||||
m_hasCustomTransitions = hasCustomTransition;
|
||||
}
|
||||
|
||||
bool EditorAutomationTest::HasRun() const
|
||||
{
|
||||
return m_hasRun;
|
||||
}
|
||||
|
||||
bool EditorAutomationTest::IsRunning() const
|
||||
{
|
||||
return AZ::SystemTickBus::Handler::BusIsConnected();
|
||||
}
|
||||
|
||||
bool EditorAutomationTest::SetupState(int stateId)
|
||||
{
|
||||
m_stateId = EditorAutomationState::EXIT_STATE_ID;
|
||||
m_currentState = nullptr;
|
||||
|
||||
auto stateIter = m_states.find(stateId);
|
||||
|
||||
if (stateIter != m_states.end())
|
||||
{
|
||||
m_currentState = stateIter->second;
|
||||
}
|
||||
|
||||
if (m_currentState)
|
||||
{
|
||||
m_stateId = stateId;
|
||||
|
||||
m_actionRunner.Reset();
|
||||
m_currentState->SetupStateActions(m_actionRunner);
|
||||
}
|
||||
|
||||
return m_currentState != nullptr;
|
||||
}
|
||||
|
||||
int EditorAutomationTest::FindNextState(int stateId)
|
||||
{
|
||||
int nextStateId = EditorAutomationState::EXIT_STATE_ID;
|
||||
|
||||
if (m_hasCustomTransitions)
|
||||
{
|
||||
nextStateId = EvaluateTransition(stateId);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do a minus one here, so we can just blindly add 1 instead of needing to safety check it.
|
||||
// We default to EXIT so the result is the same.
|
||||
for (int i = 0; i < m_registrationOrder.size() - 1; ++i)
|
||||
{
|
||||
if (m_registrationOrder[i] == stateId)
|
||||
{
|
||||
nextStateId = m_registrationOrder[i + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nextStateId;
|
||||
}
|
||||
|
||||
void EditorAutomationTest::AddError(AZStd::string error)
|
||||
{
|
||||
AZ_TracePrintf("EditorAutomationTestDialog", "Error in %s :: %s", m_testName.toUtf8().data(), error.c_str());
|
||||
m_testErrors.emplace_back(error);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,538 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <QHeaderView>
|
||||
#include <QItemSelectionModel>
|
||||
#include <QMainWindow>
|
||||
#include <QMenuBar>
|
||||
#include <QPushButton>
|
||||
#include <QScreen>
|
||||
#include <QTableView>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWindow>
|
||||
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
|
||||
#include <GraphCanvas/Editor/Automation/AutomationUtils.h>
|
||||
#include <GraphCanvas/Widgets/NodePalette/NodePaletteDockWidget.h>
|
||||
#include <GraphCanvas/Widgets/NodePalette/NodePaletteWidget.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
|
||||
#include <Editor/GraphCanvas/AutomationIds.h>
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
|
||||
#include <EditorAutomationTestDialog.h>
|
||||
#include <EditorAutomationTests/EditorAutomationTests.h>
|
||||
#include <EditorAutomationTests/GraphCreationTests.h>
|
||||
#include <EditorAutomationTests/GroupTests.h>
|
||||
#include <EditorAutomationTests/InteractionTests.h>
|
||||
#include <EditorAutomationTests/NodeCreationTests.h>
|
||||
#include <EditorAutomationTests/VariableTests.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
//////////////////
|
||||
// TestListModel
|
||||
//////////////////
|
||||
|
||||
TestListModel::TestListModel()
|
||||
: m_runningIcon("Editor/Icons/AssetBrowser/in_progress.gif")
|
||||
, m_passedIcon(":/ScriptCanvasEditorResources/Resources/valid_icon.png")
|
||||
, m_failedIcon(":/ScriptCanvasEditorResources/Resources/error_icon.png")
|
||||
{
|
||||
}
|
||||
|
||||
TestListModel::~TestListModel()
|
||||
{
|
||||
for (EditorAutomationTest* test : m_actionTests)
|
||||
{
|
||||
delete test;
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex TestListModel::index(int row, int column, const QModelIndex&) const
|
||||
{
|
||||
if (row < 0 || row >= m_actionTests.size())
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
return createIndex(row, column, nullptr);
|
||||
}
|
||||
|
||||
QModelIndex TestListModel::parent(const QModelIndex&) const
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
int TestListModel::columnCount(const QModelIndex&) const
|
||||
{
|
||||
return ColumnIndex::Count;
|
||||
}
|
||||
|
||||
int TestListModel::rowCount(const QModelIndex&) const
|
||||
{
|
||||
return static_cast<int>(m_actionTests.size());
|
||||
}
|
||||
|
||||
QVariant TestListModel::headerData(int, Qt::Orientation, int) const
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant TestListModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
EditorAutomationTest* actionTest = FindTestForIndex(index);
|
||||
|
||||
if (actionTest == nullptr)
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
if (index.column() == ColumnIndex::TestName)
|
||||
{
|
||||
return actionTest->GetTestName();
|
||||
}
|
||||
}
|
||||
else if (role == Qt::DecorationRole)
|
||||
{
|
||||
if (index.column() == ColumnIndex::TestName)
|
||||
{
|
||||
if (actionTest->HasRun() || actionTest->IsRunning())
|
||||
{
|
||||
if (actionTest->IsRunning())
|
||||
{
|
||||
return m_runningIcon;
|
||||
}
|
||||
else if (actionTest->HasErrors())
|
||||
{
|
||||
return m_failedIcon;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_passedIcon;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void TestListModel::AddTest(EditorAutomationTest* actionTest)
|
||||
{
|
||||
m_actionTests.emplace_back(actionTest);
|
||||
}
|
||||
|
||||
EditorAutomationTest* TestListModel::FindTestForIndex(const QModelIndex& index) const
|
||||
{
|
||||
if (index.isValid())
|
||||
{
|
||||
return FindTestForRow(index.row());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
EditorAutomationTest* TestListModel::FindTestForRow(int row) const
|
||||
{
|
||||
if (row >= 0 && row < m_actionTests.size())
|
||||
{
|
||||
return m_actionTests[row];
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int TestListModel::FindRowForTest(EditorAutomationTest* actionTest)
|
||||
{
|
||||
for (int i = 0; i < m_actionTests.size(); ++i)
|
||||
{
|
||||
if (m_actionTests[i] == actionTest)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void TestListModel::UpdateTestDisplay(EditorAutomationTest* actionTest)
|
||||
{
|
||||
int row = FindRowForTest(actionTest);
|
||||
|
||||
if (row >= 0)
|
||||
{
|
||||
dataChanged(index(0, 0, QModelIndex()), index(0, ColumnIndex::Count - 1, QModelIndex()));
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////
|
||||
// EditorAutomationTestDialog
|
||||
///////////////////////////////
|
||||
|
||||
EditorAutomationTestDialog::EditorAutomationTestDialog(QMainWindow* mainWindow)
|
||||
: QDialog()
|
||||
, m_scriptCanvasWindow(mainWindow)
|
||||
{
|
||||
EditorAutomationTestDialogRequestBus::Handler::BusConnect(ScriptCanvasEditor::AssetEditorId);
|
||||
|
||||
QMenuBar* menuBar = mainWindow->menuBar();
|
||||
|
||||
const QObjectList& objectList = menuBar->children();
|
||||
|
||||
QMenu* targetMenu = nullptr;
|
||||
|
||||
for (QObject* object : objectList)
|
||||
{
|
||||
QMenu* menu = qobject_cast<QMenu*>(object);
|
||||
|
||||
if (menu && menu->title() == "Developer")
|
||||
{
|
||||
targetMenu = menu;
|
||||
}
|
||||
}
|
||||
|
||||
QObject* object = GraphCanvas::AutomationUtils::FindObjectById<QObject>(ScriptCanvasEditor::AssetEditorId, ScriptCanvasEditor::AutomationIds::NodePaletteWidget);
|
||||
|
||||
// Can't use qobject_cast, since it is accessing across DLLs
|
||||
GraphCanvas::NodePaletteWidget* nodePaletteWidget = static_cast<GraphCanvas::NodePaletteWidget*>(object);
|
||||
|
||||
if (nodePaletteWidget == nullptr)
|
||||
{
|
||||
AZ_Error("Editor Automation", false, "Failed to find NodePaletteWidget");
|
||||
}
|
||||
|
||||
QLineEdit* searchFilter = nodePaletteWidget->GetSearchFilter();
|
||||
|
||||
setWindowFlag(Qt::WindowType::WindowCloseButtonHint);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
QLayout* layout = new QVBoxLayout();
|
||||
|
||||
m_tableView = new QTableView();
|
||||
m_tableView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
m_tableView->setMinimumSize(QSize(250, 250));
|
||||
m_tableView->setAlternatingRowColors(true);
|
||||
m_tableView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||
|
||||
m_testListModel = new TestListModel();
|
||||
|
||||
// Populate tests here
|
||||
|
||||
// General Sanity Tests of the interactions
|
||||
m_testListModel->AddTest(aznew OpenMenuTest(targetMenu));
|
||||
m_testListModel->AddTest(aznew WriteTextToInput(searchFilter, "Multiply (*)"));
|
||||
m_testListModel->AddTest(aznew WriteTextToInput(searchFilter, "::Test::"));
|
||||
////
|
||||
|
||||
// General Test for Graph Creation
|
||||
m_testListModel->AddTest(aznew CreateGraphTest());
|
||||
m_testListModel->AddTest(aznew CreateFunctionTest());
|
||||
////
|
||||
|
||||
// General Tests for Node Creation
|
||||
m_testListModel->AddTest(aznew CreateNodeFromPaletteTest("Multiply (*)", nodePaletteWidget));
|
||||
m_testListModel->AddTest(aznew CreateNodeFromPaletteTest("Print", nodePaletteWidget));
|
||||
m_testListModel->AddTest(aznew CreateNodeFromContextMenuTest("Multiply (*)"));
|
||||
m_testListModel->AddTest(aznew CreateNodeFromContextMenuTest("Print"));
|
||||
|
||||
m_testListModel->AddTest(aznew CreateHelloWorldFromPalette(nodePaletteWidget));
|
||||
m_testListModel->AddTest(aznew CreateHelloWorldFromContextMenu());
|
||||
|
||||
m_testListModel->AddTest(aznew CreateExecutionSplicedNodeTest("Build String"));
|
||||
m_testListModel->AddTest(aznew CreateDragDropExecutionSpliceNodeTest(nodePaletteWidget, "Build String"));
|
||||
////
|
||||
|
||||
m_testListModel->AddTest(aznew AltClickDeleteTest());
|
||||
|
||||
// Actual BAT tests
|
||||
m_testListModel->AddTest(aznew ManuallyCreateVariableTest(ScriptCanvas::Data::Type::Number(), CreateVariableAction::CreationType::AutoComplete));
|
||||
m_testListModel->AddTest(aznew ManuallyCreateVariableTest(ScriptCanvas::Data::Type::Number(), CreateVariableAction::CreationType::Palette));
|
||||
m_testListModel->AddTest(aznew ManuallyCreateVariableTest(ScriptCanvas::Data::Type::Number(), CreateVariableAction::CreationType::Programmatic));
|
||||
|
||||
m_testListModel->AddTest(aznew ManuallyCreateVariableTest(ScriptCanvas::Data::Type::Vector3(), CreateVariableAction::CreationType::AutoComplete));
|
||||
m_testListModel->AddTest(aznew ManuallyCreateVariableTest(ScriptCanvas::Data::Type::Vector3(), CreateVariableAction::CreationType::Palette));
|
||||
m_testListModel->AddTest(aznew ManuallyCreateVariableTest(ScriptCanvas::Data::Type::Vector3(), CreateVariableAction::CreationType::Programmatic));
|
||||
|
||||
m_testListModel->AddTest(aznew CreateNamedVariableTest(ScriptCanvas::Data::Type::EntityID(), "Caterpillar", CreateVariableAction::CreationType::AutoComplete));
|
||||
|
||||
m_testListModel->AddTest(aznew DuplicateVariableNameTest(ScriptCanvas::Data::Type::Number(), ScriptCanvas::Data::Type::Number(), "SameType"));
|
||||
m_testListModel->AddTest(aznew DuplicateVariableNameTest(ScriptCanvas::Data::Type::Color(), ScriptCanvas::Data::Type::String(), "DifferentType"));
|
||||
|
||||
m_testListModel->AddTest(aznew ModifyNumericInputTest(123.45));
|
||||
m_testListModel->AddTest(aznew ModifyStringInputTest("abcdefghijklmnopqrstuvwxyz"));
|
||||
m_testListModel->AddTest(aznew ToggleBoolInputTest());
|
||||
|
||||
|
||||
AZStd::vector< ScriptCanvas::Data::Type > primitiveTypes;
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(primitiveTypes, &ScriptCanvasEditor::VariableAutomationRequests::GetPrimitiveTypes);
|
||||
|
||||
m_testListModel->AddTest(aznew VariableLifeCycleTest("Primitive Variable LifeCycle Test", primitiveTypes));
|
||||
|
||||
AZStd::vector< ScriptCanvas::Data::Type > objectTypes;
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(objectTypes, &ScriptCanvasEditor::VariableAutomationRequests::GetBehaviorContextObjectTypes);
|
||||
|
||||
m_testListModel->AddTest(aznew VariableLifeCycleTest("BCO Variable LifeCycle Test", objectTypes));
|
||||
|
||||
AZStd::vector< ScriptCanvas::Data::Type > mapTypes;
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(mapTypes, &ScriptCanvasEditor::VariableAutomationRequests::GetMapTypes);
|
||||
|
||||
{
|
||||
AZStd::vector< ScriptCanvas::Data::Type > tempTypes;
|
||||
|
||||
for (int i = 0; i < AZStd::GetMin(aznumeric_cast<int>(mapTypes.size()), 10); ++i)
|
||||
{
|
||||
tempTypes.emplace_back((*mapTypes.begin()));
|
||||
mapTypes.erase(mapTypes.begin());
|
||||
}
|
||||
|
||||
mapTypes.clear();
|
||||
mapTypes = tempTypes;
|
||||
}
|
||||
|
||||
m_testListModel->AddTest(aznew VariableLifeCycleTest("Map Variable LifeCycle Test", mapTypes, CreateVariableAction::CreationType::Programmatic));
|
||||
|
||||
AZStd::vector< ScriptCanvas::Data::Type > arrayTypes;
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(arrayTypes, &ScriptCanvasEditor::VariableAutomationRequests::GetArrayTypes);
|
||||
|
||||
{
|
||||
AZStd::vector< ScriptCanvas::Data::Type > tempTypes;
|
||||
|
||||
for (int i = 0; i < AZStd::GetMin(aznumeric_cast<int>(arrayTypes.size()), 10); ++i)
|
||||
{
|
||||
tempTypes.emplace_back((*arrayTypes.begin()));
|
||||
arrayTypes.erase(arrayTypes.begin());
|
||||
}
|
||||
|
||||
arrayTypes.clear();
|
||||
arrayTypes = tempTypes;
|
||||
}
|
||||
|
||||
m_testListModel->AddTest(aznew VariableLifeCycleTest("Array Variable LifeCycle Test", arrayTypes, CreateVariableAction::CreationType::Programmatic));
|
||||
|
||||
m_testListModel->AddTest(aznew RapidVariableCreationDeletionTest());
|
||||
|
||||
|
||||
m_testListModel->AddTest(aznew CreateCategoryTest("Logic", nodePaletteWidget));
|
||||
|
||||
m_testListModel->AddTest(aznew CreateGroupTest());
|
||||
m_testListModel->AddTest(aznew CreateGroupTest(CreateGroupAction::CreationType::Toolbar));
|
||||
|
||||
|
||||
m_testListModel->AddTest(aznew GroupManipulationTest(nodePaletteWidget));
|
||||
|
||||
m_testListModel->AddTest(aznew CutCopyPasteDuplicateTest("On Tick"));
|
||||
m_testListModel->AddTest(aznew CutCopyPasteDuplicateTest("Multiply (*)"));
|
||||
m_testListModel->AddTest(aznew CutCopyPasteDuplicateTest("Print"));
|
||||
////
|
||||
|
||||
////
|
||||
|
||||
m_tableView->setModel(m_testListModel);
|
||||
m_tableView->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
|
||||
m_tableView->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
|
||||
|
||||
m_tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::Stretch);
|
||||
|
||||
QPushButton* button = new QPushButton();
|
||||
button->setText("Run All Tests");
|
||||
layout->addWidget(button);
|
||||
|
||||
m_runLabel = new QLabel();
|
||||
layout->addWidget(m_runLabel);
|
||||
|
||||
layout->addWidget(m_tableView);
|
||||
|
||||
m_errorTestLabel = new QLabel();
|
||||
m_errorTestLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
|
||||
layout->addWidget(m_errorTestLabel);
|
||||
|
||||
setLayout(layout);
|
||||
|
||||
setWindowTitle("Editor Automated Testing");
|
||||
|
||||
QObject::connect(button, &QPushButton::clicked, this, &EditorAutomationTestDialog::RunAllTests);
|
||||
|
||||
QObject::connect(m_tableView, &QTableView::doubleClicked, this, &EditorAutomationTestDialog::RunTest);
|
||||
QObject::connect(m_tableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &EditorAutomationTestDialog::OnSelectionChanged);
|
||||
}
|
||||
|
||||
EditorAutomationTestDialog::~EditorAutomationTestDialog()
|
||||
{
|
||||
EditorAutomationTestDialogRequestBus::Handler::BusDisconnect();;
|
||||
}
|
||||
|
||||
void EditorAutomationTestDialog::RunAllTests()
|
||||
{
|
||||
for (int i = 0; i < m_testListModel->rowCount(); ++i)
|
||||
{
|
||||
EditorAutomationTest* test = m_testListModel->FindTestForRow(i);
|
||||
|
||||
if (test)
|
||||
{
|
||||
m_testQueue.insert(test);
|
||||
}
|
||||
}
|
||||
|
||||
if (!AZ::SystemTickBus::Handler::BusIsConnected())
|
||||
{
|
||||
StartNewTestRun();
|
||||
}
|
||||
}
|
||||
|
||||
void EditorAutomationTestDialog::RunTest(QModelIndex modelIndex)
|
||||
{
|
||||
EditorAutomationTest* test = m_testListModel->FindTestForIndex(modelIndex);
|
||||
|
||||
if (test)
|
||||
{
|
||||
m_testQueue.insert(test);
|
||||
|
||||
if (!AZ::SystemTickBus::Handler::BusIsConnected())
|
||||
{
|
||||
StartNewTestRun();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EditorAutomationTestDialog::OnSystemTick()
|
||||
{
|
||||
auto currentTime = AZStd::chrono::system_clock::now();
|
||||
auto elapsedTimed = AZStd::chrono::duration_cast<AZStd::chrono::milliseconds>(currentTime - m_startTime);
|
||||
|
||||
if (m_activeTest)
|
||||
{
|
||||
if (!m_activeTest->IsRunning())
|
||||
{
|
||||
if (!m_activeTest->HasErrors())
|
||||
{
|
||||
++m_successCount;
|
||||
}
|
||||
|
||||
m_testListModel->UpdateTestDisplay(m_activeTest);
|
||||
|
||||
int row = m_testListModel->FindRowForTest(m_activeTest);
|
||||
|
||||
if (m_tableView)
|
||||
{
|
||||
if (m_tableView->selectionModel()->currentIndex().row() == row)
|
||||
{
|
||||
DisplayErrorsForTest(m_activeTest);
|
||||
}
|
||||
}
|
||||
|
||||
m_activeTest = nullptr;
|
||||
m_startTime = AZStd::chrono::system_clock::now();
|
||||
|
||||
UpdateRunLabel();
|
||||
}
|
||||
}
|
||||
else if (elapsedTimed >= AZStd::chrono::milliseconds(1000))
|
||||
{
|
||||
if (m_testQueue.empty())
|
||||
{
|
||||
FinishTestRun();
|
||||
|
||||
// Force the entire layout to refresh for now.
|
||||
m_testListModel->layoutChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_scriptCanvasWindow->show();
|
||||
m_scriptCanvasWindow->raise();
|
||||
m_scriptCanvasWindow->activateWindow();
|
||||
m_scriptCanvasWindow->setFocus(Qt::FocusReason::MouseFocusReason);
|
||||
|
||||
m_activeTest = (*m_testQueue.begin());
|
||||
m_testQueue.erase(m_testQueue.begin());
|
||||
|
||||
m_runCount++;
|
||||
|
||||
m_activeTest->StartTest();
|
||||
|
||||
m_testListModel->UpdateTestDisplay(m_activeTest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EditorAutomationTestDialog::ShowTestDialog()
|
||||
{
|
||||
show();
|
||||
raise();
|
||||
activateWindow();
|
||||
setFocus(Qt::FocusReason::MouseFocusReason);
|
||||
}
|
||||
|
||||
void EditorAutomationTestDialog::OnSelectionChanged(const QItemSelection& selected, const QItemSelection&)
|
||||
{
|
||||
m_errorTestLabel->clear();
|
||||
|
||||
if (selected.size() == 1)
|
||||
{
|
||||
EditorAutomationTest* test = m_testListModel->FindTestForIndex(selected.front().indexes().front());
|
||||
|
||||
DisplayErrorsForTest(test);
|
||||
}
|
||||
}
|
||||
|
||||
void EditorAutomationTestDialog::StartNewTestRun()
|
||||
{
|
||||
m_runCount = 0;
|
||||
m_successCount = 0;
|
||||
|
||||
AZ::SystemTickBus::Handler::BusConnect();
|
||||
m_startTime = AZStd::chrono::system_clock::now();
|
||||
|
||||
UpdateRunLabel();
|
||||
}
|
||||
|
||||
void EditorAutomationTestDialog::FinishTestRun()
|
||||
{
|
||||
AZ::SystemTickBus::Handler::BusDisconnect();
|
||||
|
||||
m_runLabel->setText(QString("%1 of %2 Test rans successfully").arg(m_successCount).arg(m_runCount));
|
||||
|
||||
ShowTestDialog();
|
||||
}
|
||||
|
||||
void EditorAutomationTestDialog::UpdateRunLabel()
|
||||
{
|
||||
m_runLabel->setText(QString("Running Tests.... %1 remaining.").arg(m_testQueue.size()));
|
||||
}
|
||||
|
||||
void EditorAutomationTestDialog::DisplayErrorsForTest(EditorAutomationTest* actionTest)
|
||||
{
|
||||
AZStd::vector<AZStd::string> errorStrings = actionTest->GetErrors();
|
||||
|
||||
QString displayString;
|
||||
|
||||
for (const AZStd::string& errorString : errorStrings)
|
||||
{
|
||||
if (!displayString.isEmpty())
|
||||
{
|
||||
displayString.append("\n");
|
||||
}
|
||||
|
||||
displayString.append(errorString.c_str());
|
||||
}
|
||||
|
||||
m_errorTestLabel->setText(displayString);
|
||||
}
|
||||
|
||||
#include <Editor/Source/moc_EditorAutomationTestDialog.cpp>
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* 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 <QAbstractItemModel>
|
||||
#include <QDialog>
|
||||
#include <QIcon>
|
||||
#include <QItemSelection>
|
||||
#include <QLabel>
|
||||
#include <QTableView>
|
||||
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h>
|
||||
|
||||
#include <GraphCanvas/Editor/EditorTypes.h>
|
||||
|
||||
class QWindow;
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
class EditorAutomationTestDialogRequests
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
|
||||
using BusIdType = GraphCanvas::EditorId;
|
||||
|
||||
virtual void ShowTestDialog() = 0;
|
||||
};
|
||||
|
||||
using EditorAutomationTestDialogRequestBus = AZ::EBus<EditorAutomationTestDialogRequests>;
|
||||
|
||||
class QtActionTest;
|
||||
|
||||
class TestListModel
|
||||
: public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(TestListModel, AZ::SystemAllocator, 0);
|
||||
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexForce = -1,
|
||||
|
||||
TestName,
|
||||
|
||||
Count
|
||||
};
|
||||
|
||||
TestListModel();
|
||||
~TestListModel() override;
|
||||
|
||||
// QAbstractItemModel
|
||||
QModelIndex index(int row, int column, const QModelIndex& parent) const override;
|
||||
QModelIndex parent(const QModelIndex& index = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
////
|
||||
|
||||
void AddTest(EditorAutomationTest* actionTest);
|
||||
|
||||
EditorAutomationTest* FindTestForIndex(const QModelIndex& index) const;
|
||||
EditorAutomationTest* FindTestForRow(int row) const;
|
||||
|
||||
int FindRowForTest(EditorAutomationTest* actionTest);
|
||||
|
||||
void UpdateTestDisplay(EditorAutomationTest* actionTest);
|
||||
|
||||
private:
|
||||
|
||||
AZStd::vector< EditorAutomationTest* > m_actionTests;
|
||||
|
||||
QIcon m_runningIcon;
|
||||
QIcon m_passedIcon;
|
||||
QIcon m_failedIcon;
|
||||
};
|
||||
|
||||
class EditorAutomationTestDialog
|
||||
: public QDialog
|
||||
, public AZ::SystemTickBus::Handler
|
||||
, public EditorAutomationTestDialogRequestBus::Handler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
EditorAutomationTestDialog(QMainWindow* mainWindow);
|
||||
~EditorAutomationTestDialog() override;
|
||||
|
||||
void RunAllTests();
|
||||
void RunTest(QModelIndex index);
|
||||
|
||||
// SystemTickBus
|
||||
void OnSystemTick();
|
||||
////
|
||||
|
||||
// EditorAutomationTestDialogRequestBus::Handler
|
||||
void ShowTestDialog() override;
|
||||
////
|
||||
|
||||
void OnSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
|
||||
|
||||
private:
|
||||
|
||||
void StartNewTestRun();
|
||||
void FinishTestRun();
|
||||
|
||||
void DisplayErrorsForTest(EditorAutomationTest* actionTest);
|
||||
void UpdateRunLabel();
|
||||
|
||||
int m_runCount = 0;
|
||||
int m_successCount = 0;
|
||||
|
||||
AZStd::chrono::time_point<AZStd::chrono::system_clock> m_startTime;
|
||||
|
||||
EditorAutomationTest* m_activeTest = nullptr;
|
||||
AZStd::unordered_set< EditorAutomationTest* > m_testQueue;
|
||||
|
||||
TestListModel* m_testListModel = nullptr;
|
||||
|
||||
QTableView* m_tableView = nullptr;
|
||||
|
||||
QLabel* m_errorTestLabel = nullptr;
|
||||
QLabel* m_runLabel = nullptr;
|
||||
QMainWindow* m_scriptCanvasWindow = nullptr;
|
||||
|
||||
QWindow* m_canvasWindow = nullptr;
|
||||
};
|
||||
}
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* 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 <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QString>
|
||||
|
||||
#include <GraphCanvas/Components/Nodes/NodeBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/SlotBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/WidgetActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ConnectionActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/CreateElementsActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ElementInteractions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/GraphActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/VariableActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
DefineStateId(OpenMenuTest_OpenMenuState);
|
||||
|
||||
/**
|
||||
EditorAutomationTest to test the general systems. Will open the Developer menu.
|
||||
*/
|
||||
class OpenMenuTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
class OpenMenuState : public StaticIdAutomationState<OpenMenuTest_OpenMenuStateId>
|
||||
{
|
||||
public:
|
||||
OpenMenuState(QMenu* targetMenu)
|
||||
: m_targetMenu(targetMenu)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
m_shownMenu = false;
|
||||
|
||||
if (m_clickAction == nullptr)
|
||||
{
|
||||
QPoint targetPoint = m_targetMenu->mapToGlobal(QPoint(15, -10));
|
||||
|
||||
m_clickAction = aznew MouseClickAction(Qt::MouseButton::LeftButton, targetPoint);
|
||||
actionRunner.AddAction(m_clickAction);
|
||||
}
|
||||
|
||||
actionRunner.AddAction(&m_delayAction);
|
||||
|
||||
m_eventConnection = QObject::connect(m_targetMenu, &QMenu::aboutToShow, [this]()
|
||||
{
|
||||
this->OnTargetMenuShown();
|
||||
});
|
||||
}
|
||||
|
||||
void OnStateActionsComplete()
|
||||
{
|
||||
QObject::disconnect(m_eventConnection);
|
||||
|
||||
if (!m_shownMenu)
|
||||
{
|
||||
ReportError("Failed to show the menu");
|
||||
}
|
||||
|
||||
delete m_clickAction;
|
||||
m_clickAction = nullptr;
|
||||
}
|
||||
|
||||
void OnTargetMenuShown()
|
||||
{
|
||||
m_shownMenu = true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
QMenu* m_targetMenu;
|
||||
|
||||
MouseClickAction* m_clickAction = nullptr;
|
||||
DelayAction m_delayAction;
|
||||
|
||||
QMetaObject::Connection m_eventConnection;
|
||||
|
||||
bool m_shownMenu = false;
|
||||
};
|
||||
|
||||
public:
|
||||
OpenMenuTest(QMenu* targetMenu)
|
||||
: EditorAutomationTest("Open Menu Test")
|
||||
{
|
||||
AddState(new OpenMenuState(targetMenu));
|
||||
}
|
||||
|
||||
~OpenMenuTest() = default;
|
||||
};
|
||||
|
||||
DefineStateId(WriteToLineEditState);
|
||||
|
||||
class WriteToLineEditState : public StaticIdAutomationState<WriteToLineEditStateId>
|
||||
{
|
||||
public:
|
||||
WriteToLineEditState(QLineEdit* targetEdit, QString targetText)
|
||||
: m_writeToLineEdit(targetEdit, targetText)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
actionRunner.AddAction(&m_writeToLineEdit);
|
||||
}
|
||||
|
||||
private:
|
||||
WriteToLineEditAction m_writeToLineEdit;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorAutomationTest to test the general systems. Will write the target string to the target line edit
|
||||
*/
|
||||
class WriteTextToInput
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
WriteTextToInput(QLineEdit* targetEdit, QString targetText)
|
||||
: EditorAutomationTest(QString("Write '%1' To Input").arg(targetText))
|
||||
{
|
||||
AddState(new WriteToLineEditState(targetEdit, targetText));
|
||||
}
|
||||
|
||||
~WriteTextToInput() = default;
|
||||
};
|
||||
}
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <qpushbutton.h>
|
||||
|
||||
#include <GraphCanvas/Components/GridBus.h>
|
||||
#include <GraphCanvas/Components/Nodes/Group/NodeGroupBus.h>
|
||||
|
||||
#include <Editor/Source/EditorAutomationTests/GraphCreationTests.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
|
||||
#include <ScriptCanvas/GraphCanvas/MappingBus.h>
|
||||
#include <ScriptCanvas/Core/Node.h>
|
||||
#include <ScriptCanvas/Core/NodeBus.h>
|
||||
#include <ScriptCanvas/Bus/EditorScriptCanvasBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/GraphStates.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
///////////////////////////
|
||||
// CreateGraphHotKeyState
|
||||
///////////////////////////
|
||||
#if !defined(AZ_COMPILER_MSVC)
|
||||
#ifndef VK_CONTROL
|
||||
#define VK_CONTROL 0x11
|
||||
#endif
|
||||
#endif
|
||||
|
||||
CreateGraphTest::CreateGraphHotKeyState::CreateGraphHotKeyState()
|
||||
: m_pressControl(VK_CONTROL)
|
||||
, m_releaseControl(VK_CONTROL)
|
||||
, m_typeN(QChar('n'))
|
||||
, m_longProcessEvents(AZStd::chrono::milliseconds(1000))
|
||||
{
|
||||
}
|
||||
|
||||
void CreateGraphTest::CreateGraphHotKeyState::OnActiveGraphChanged(const AZ::EntityId& graphCanvasId)
|
||||
{
|
||||
m_hotKeyGraphId = graphCanvasId;
|
||||
}
|
||||
|
||||
void CreateGraphTest::CreateGraphHotKeyState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
GraphCanvas::AssetEditorNotificationBus::Handler::BusConnect(ScriptCanvasEditor::AssetEditorId);
|
||||
|
||||
actionRunner.AddAction(&m_pressControl);
|
||||
actionRunner.AddAction(&m_shortProcessEvents);
|
||||
actionRunner.AddAction(&m_typeN);
|
||||
actionRunner.AddAction(&m_longProcessEvents);
|
||||
actionRunner.AddAction(&m_releaseControl);
|
||||
actionRunner.AddAction(&m_shortProcessEvents);
|
||||
|
||||
m_hotKeyGraphId.SetInvalid();
|
||||
}
|
||||
|
||||
void CreateGraphTest::CreateGraphHotKeyState::OnStateActionsComplete()
|
||||
{
|
||||
if (!m_hotKeyGraphId.IsValid())
|
||||
{
|
||||
ReportError("Failed to create graph using hot key");
|
||||
}
|
||||
else
|
||||
{
|
||||
GraphCanvas::GraphId activeGraphCanvasId;
|
||||
ScriptCanvasEditor::GeneralRequestBus::BroadcastResult(activeGraphCanvasId, &ScriptCanvasEditor::GeneralRequests::GetActiveGraphCanvasGraphId);
|
||||
|
||||
if (activeGraphCanvasId != m_hotKeyGraphId)
|
||||
{
|
||||
ReportError("Active graph is not the newly created graph using hotkey.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ScriptCanvas::ScriptCanvasId scriptCanvasId;
|
||||
ScriptCanvasEditor::GeneralRequestBus::BroadcastResult(scriptCanvasId, &ScriptCanvasEditor::GeneralRequests::GetScriptCanvasId, activeGraphCanvasId);
|
||||
|
||||
bool isRuntimeGraph = false;
|
||||
ScriptCanvasEditor::EditorGraphRequestBus::EventResult(isRuntimeGraph, scriptCanvasId, &ScriptCanvasEditor::EditorGraphRequests::IsRuntimeGraph);
|
||||
|
||||
if (!isRuntimeGraph)
|
||||
{
|
||||
ReportError("Failed to create Runtime graph using button");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GraphCanvas::AssetEditorNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// CreateGraphTest
|
||||
////////////////////
|
||||
|
||||
CreateGraphTest::CreateGraphTest()
|
||||
: EditorAutomationTest("Create Graph Test")
|
||||
{
|
||||
SetHasCustomTransitions(true);
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
AddState(new CreateGraphHotKeyState());
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
|
||||
SetInitialStateId<CreateRuntimeGraphStateId>();
|
||||
}
|
||||
|
||||
void CreateGraphTest::OnTestStarting()
|
||||
{
|
||||
m_creationState = CreateRuntimeGraphStateId::StateID();
|
||||
}
|
||||
|
||||
int CreateGraphTest::EvaluateTransition(int stateId)
|
||||
{
|
||||
if (stateId == CreateRuntimeGraphState::StateID()
|
||||
|| stateId == CreateGraphHotKeyState::StateID())
|
||||
{
|
||||
return ForceCloseActiveGraphState::StateID();
|
||||
}
|
||||
else if (stateId == ForceCloseActiveGraphState::StateID())
|
||||
{
|
||||
if (m_creationState == CreateRuntimeGraphStateId::StateID())
|
||||
{
|
||||
m_creationState = CreateGraphHotKeyState::StateID();
|
||||
return m_creationState;
|
||||
}
|
||||
}
|
||||
|
||||
return EditorAutomationState::EXIT_STATE_ID;
|
||||
}
|
||||
|
||||
///////////////////////
|
||||
// CreateFunctionTest
|
||||
///////////////////////
|
||||
|
||||
CreateFunctionTest::CreateFunctionTest()
|
||||
: EditorAutomationTest("Create Function Test")
|
||||
{
|
||||
AddState(new CreateFunctionGraphState());
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* 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 <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QString>
|
||||
#include <QTableView>
|
||||
|
||||
#include <GraphCanvas/Components/Nodes/NodeBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/SlotBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/WidgetActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ConnectionActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/CreateElementsActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ElementInteractions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/GraphActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/VariableActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
DefineStateId(CreateGraphTest_CreateGraphHotKeyState);
|
||||
|
||||
/**
|
||||
EditorautomationTest that will test out the ways of creating a runtime graph
|
||||
*/
|
||||
class CreateGraphTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
class CreateGraphHotKeyState
|
||||
: public StaticIdAutomationState<CreateGraphTest_CreateGraphHotKeyStateId>
|
||||
, public GraphCanvas::AssetEditorNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
CreateGraphHotKeyState();
|
||||
~CreateGraphHotKeyState() override = default;
|
||||
|
||||
// AssetEditorNotificationBus
|
||||
void OnActiveGraphChanged(const AZ::EntityId& graphCanvasId) override;
|
||||
////
|
||||
|
||||
protected:
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner);
|
||||
void OnStateActionsComplete();
|
||||
|
||||
private:
|
||||
|
||||
GraphCanvas::GraphId m_hotKeyGraphId;
|
||||
|
||||
KeyPressAction m_pressControl;
|
||||
KeyReleaseAction m_releaseControl;
|
||||
TypeCharAction m_typeN;
|
||||
|
||||
ProcessUserEventsAction m_shortProcessEvents;
|
||||
ProcessUserEventsAction m_longProcessEvents;
|
||||
};
|
||||
|
||||
public:
|
||||
CreateGraphTest();
|
||||
~CreateGraphTest() override = default;
|
||||
|
||||
void OnTestStarting() override;
|
||||
|
||||
protected:
|
||||
|
||||
int EvaluateTransition(int stateId) override;
|
||||
|
||||
private:
|
||||
|
||||
int m_creationState = EditorAutomationState::EXIT_STATE_ID;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that will test out the ways of creating a function graph.
|
||||
*/
|
||||
class CreateFunctionTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
CreateFunctionTest();
|
||||
~CreateFunctionTest() override = default;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <qpushbutton.h>
|
||||
|
||||
#include <GraphCanvas/Components/GridBus.h>
|
||||
#include <GraphCanvas/Components/Nodes/Group/NodeGroupBus.h>
|
||||
|
||||
#include <EditorAutomationTests/GroupTests.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
|
||||
#include <ScriptCanvas/GraphCanvas/MappingBus.h>
|
||||
#include <ScriptCanvas/Core/Node.h>
|
||||
#include <ScriptCanvas/Core/NodeBus.h>
|
||||
#include <ScriptCanvas/Bus/EditorScriptCanvasBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ElementInteractions.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/CreateElementsStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/EditorViewStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/GraphStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/UtilityStates.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
////////////////////
|
||||
// CreateGroupTest
|
||||
////////////////////
|
||||
|
||||
CreateGroupTest::CreateGroupTest(CreateGroupAction::CreationType creationType)
|
||||
: EditorAutomationTest(creationType == CreateGroupAction::CreationType::Hotkey ? "Create Group Test" : "Create Group Test With Toolbar")
|
||||
{
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
AddState(new CreateGroupState(ScriptCanvasEditor::AssetEditorId, creationType));
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
// GroupManipulationTest
|
||||
//////////////////////////
|
||||
|
||||
GroupManipulationTest::OffsetPositionByNodeDimension::OffsetPositionByNodeDimension(float horizontalDimension, float verticalDimension, AutomationStateModelId nodeId, AutomationStateModelId positionId)
|
||||
: CustomActionState("OffsetPositionByNodeDimension")
|
||||
, m_horizontalDimension(horizontalDimension)
|
||||
, m_verticalDimension(verticalDimension)
|
||||
, m_nodeId(nodeId)
|
||||
, m_positionId(positionId)
|
||||
{
|
||||
SetStateName(AZStd::string::format("OffsetPosition::%s::ByNodeDimension::%s", m_positionId.c_str(), m_nodeId.c_str()));
|
||||
}
|
||||
|
||||
void GroupManipulationTest::OffsetPositionByNodeDimension::OnCustomAction()
|
||||
{
|
||||
const AZ::EntityId* nodeId = GetStateModel()->GetStateDataAs<AZ::EntityId>(m_nodeId);
|
||||
const AZ::Vector2* position = GetStateModel()->GetStateDataAs<AZ::Vector2>(m_positionId);
|
||||
|
||||
if (nodeId && position)
|
||||
{
|
||||
QGraphicsItem* nodeItem = nullptr;
|
||||
GraphCanvas::VisualRequestBus::EventResult(nodeItem, (*nodeId), &GraphCanvas::VisualRequests::AsGraphicsItem);
|
||||
|
||||
if (nodeItem)
|
||||
{
|
||||
AZ::Vector2 modifiedValue = (*position);
|
||||
|
||||
QRectF sceneBoundingBox = nodeItem->sceneBoundingRect();
|
||||
modifiedValue.SetX(position->GetX() + sceneBoundingBox.width() * m_horizontalDimension);
|
||||
modifiedValue.SetY(position->GetY() + sceneBoundingBox.height() * m_verticalDimension);
|
||||
|
||||
GetStateModel()->SetStateData(m_positionId, modifiedValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nodeId == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid EntityId", m_nodeId.c_str()));
|
||||
}
|
||||
|
||||
if (position == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid Vector2", m_positionId.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GroupManipulationTest::GroupManipulationTest(GraphCanvas::NodePaletteWidget* nodePaletteWidget)
|
||||
: EditorAutomationTest("Group Manipulation Test")
|
||||
{
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId groupId = "GroupId";
|
||||
|
||||
AddState(new CreateGroupState(ScriptCanvasEditor::AssetEditorId, CreateGroupAction::CreationType::Hotkey, groupId));
|
||||
|
||||
AutomationStateModelId groupCenter = "GroupCenter";
|
||||
|
||||
{
|
||||
FindPositionOffsets groupOffsets;
|
||||
groupOffsets.m_horizontalPosition = 0.5f;
|
||||
groupOffsets.m_verticalPosition = 0.5f;
|
||||
|
||||
AddState(new FindGroupPosition(groupId, groupCenter, groupOffsets));
|
||||
}
|
||||
|
||||
AutomationStateModelId buildStringNode = "BuildStringNode";
|
||||
AddState(new CreateNodeFromContextMenuState("Build String", CreateNodeFromContextMenuState::CreationType::ScenePosition, groupCenter, buildStringNode));
|
||||
|
||||
AddState(new CheckIsInGroup(buildStringNode, groupId, true, "CheckGroupStatus::ContextMenuCreation"));
|
||||
|
||||
AutomationStateModelId moveOutSceneDragStart = "MoveOutSceneDragStart";
|
||||
AutomationStateModelId moveOutSceneDragEnd = "MoveOutSceneDragEnd";
|
||||
|
||||
{
|
||||
FindPositionOffsets nodeOffsets;
|
||||
nodeOffsets.m_horizontalPosition = 0.5f;
|
||||
nodeOffsets.m_verticalPosition = 0.0f;
|
||||
nodeOffsets.m_verticalOffset = 10;
|
||||
|
||||
AddState(new FindNodePosition(buildStringNode, moveOutSceneDragStart, nodeOffsets));
|
||||
AddState(new FindNodePosition(buildStringNode, moveOutSceneDragEnd, nodeOffsets));
|
||||
}
|
||||
|
||||
AddState(new OffsetPositionByNodeDimension(1.0f, 0.0f, groupId, moveOutSceneDragEnd));
|
||||
AddState(new OffsetPositionByNodeDimension(1.0f, 0.0f, buildStringNode, moveOutSceneDragEnd));
|
||||
|
||||
AddState(new SceneMouseDragState(moveOutSceneDragStart, moveOutSceneDragEnd));
|
||||
AddState(new CheckIsInGroup(buildStringNode, groupId, false, "CheckGroupStatus::DragOutOfGroup"));
|
||||
|
||||
AutomationStateModelId envelopDragStart = "EnvelopDragStart";
|
||||
AutomationStateModelId envelopDragEnd = "EnvelopDragEnd";
|
||||
|
||||
{
|
||||
FindPositionOffsets groupOffsets;
|
||||
groupOffsets.m_horizontalPosition = 1.0f;
|
||||
groupOffsets.m_horizontalOffset = -5;
|
||||
groupOffsets.m_verticalPosition = 0.5f;
|
||||
|
||||
AddState(new FindGroupPosition(groupId, envelopDragStart, groupOffsets));
|
||||
AddState(new FindGroupPosition(groupId, envelopDragEnd, groupOffsets));
|
||||
}
|
||||
|
||||
AddState(new OffsetPositionByNodeDimension(1.0f, 0.0f, groupId, envelopDragEnd));
|
||||
AddState(new OffsetPositionByNodeDimension(1.0f, 0.0f, buildStringNode, envelopDragEnd));
|
||||
|
||||
AddState(new SceneMouseDragState(envelopDragStart, envelopDragEnd));
|
||||
AddState(new CheckIsInGroup(buildStringNode, groupId, true, "CheckGroupStatus::ResizeToInclude"));
|
||||
|
||||
AddState(new SceneMouseDragState(envelopDragEnd, envelopDragStart));
|
||||
AddState(new CheckIsInGroup(buildStringNode, groupId, false, "CheckGroupStatus::ResizeToExclude"));
|
||||
|
||||
AddState(new SceneMouseDragState(moveOutSceneDragEnd, moveOutSceneDragStart));
|
||||
AddState(new CheckIsInGroup(buildStringNode, groupId, true, "CheckGroupStatus::DragIntoGroup"));
|
||||
|
||||
AutomationStateModelId proposalEndpoint = "ProposalEndpoint";
|
||||
AddState(new FindEndpointOfTypeState(buildStringNode, proposalEndpoint, GraphCanvas::ConnectionType::CT_Output, GraphCanvas::SlotTypes::ExecutionSlot));
|
||||
|
||||
AutomationStateModelId printNode = "PrintNode";
|
||||
AddState(new CreateNodeFromProposalState("Print", proposalEndpoint, envelopDragStart, printNode));
|
||||
|
||||
AddState(new CheckIsInGroup(printNode, groupId, true, "CheckGroupStatus::PoposalCreation"));
|
||||
|
||||
AutomationStateModelId onGraphStartNode = "OnGraphStartNode";
|
||||
AddState(new CreateNodeFromPaletteState(nodePaletteWidget, "On Graph Start", CreateNodeFromPaletteState::CreationType::ScenePosition, groupCenter, onGraphStartNode));
|
||||
|
||||
AddState(new CheckIsInGroup(onGraphStartNode, groupId, true, "CheckGroupStatus::PaletteDrop"));
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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 <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QString>
|
||||
#include <QTableView>
|
||||
|
||||
#include <GraphCanvas/Components/Nodes/NodeBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/SlotBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/WidgetActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ConnectionActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/CreateElementsActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ElementInteractions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/GraphActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/VariableActions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorautomationTest that will test out various methods creating a group
|
||||
*/
|
||||
class CreateGroupTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
CreateGroupTest(CreateGroupAction::CreationType creationType = CreateGroupAction::CreationType::Hotkey);
|
||||
~CreateGroupTest() override = default;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that will test out how elements are added/removed from groups in several situations(Addition to group via context menu, drag/drop, connection proposal, or resizing. Removal from group through movement and resizing).
|
||||
*/
|
||||
class GroupManipulationTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
private:
|
||||
|
||||
class OffsetPositionByNodeDimension
|
||||
: public CustomActionState
|
||||
{
|
||||
public:
|
||||
// -1 to 1 will decide how much and which direction we manipulate the specified value by our width/height.
|
||||
OffsetPositionByNodeDimension(float horizontalDimension, float verticalDimension, AutomationStateModelId nodeId, AutomationStateModelId position);
|
||||
~OffsetPositionByNodeDimension() override = default;
|
||||
|
||||
void OnCustomAction() override;
|
||||
|
||||
private:
|
||||
|
||||
float m_horizontalDimension = 0.0f;
|
||||
float m_verticalDimension = 0.0f;
|
||||
|
||||
AutomationStateModelId m_nodeId;
|
||||
AutomationStateModelId m_positionId;
|
||||
};
|
||||
|
||||
public:
|
||||
GroupManipulationTest(GraphCanvas::NodePaletteWidget* nodePaletteWidget);
|
||||
~GroupManipulationTest() override = default;
|
||||
};
|
||||
}
|
||||
+433
@@ -0,0 +1,433 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <qpushbutton.h>
|
||||
|
||||
#include <GraphCanvas/Components/GridBus.h>
|
||||
#include <GraphCanvas/Components/Nodes/Group/NodeGroupBus.h>
|
||||
|
||||
#include <EditorAutomationTests/InteractionTests.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
|
||||
#include <ScriptCanvas/GraphCanvas/MappingBus.h>
|
||||
#include <ScriptCanvas/Core/Node.h>
|
||||
#include <ScriptCanvas/Core/NodeBus.h>
|
||||
#include <ScriptCanvas/Bus/EditorScriptCanvasBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/EditorViewStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/ElementInteractionStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/GraphStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/UtilityStates.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
///////////////////////
|
||||
// AltClickDeleteTest
|
||||
///////////////////////
|
||||
|
||||
AltClickDeleteTest::AltClickDeleteTest()
|
||||
: EditorAutomationTest("Alt Click Deletion Test")
|
||||
{
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId onGraphStartTargetPointId = "OnGraphStartScenePoint";
|
||||
AutomationStateModelId onGraphStartId = "OnGraphStartId";
|
||||
|
||||
AddState(new FindViewCenterState(onGraphStartTargetPointId));
|
||||
AddState(new CreateNodeFromContextMenuState("On Graph Start", CreateNodeFromContextMenuState::CreationType::ScenePosition, onGraphStartTargetPointId, onGraphStartId));
|
||||
|
||||
AutomationStateModelId onGraphStartEndpoint = "OnGraphStart::ExecutionEndpoint";
|
||||
|
||||
AddState(new FindEndpointOfTypeState(onGraphStartId, onGraphStartEndpoint, GraphCanvas::CT_Output, GraphCanvas::SlotTypes::ExecutionSlot));
|
||||
|
||||
AutomationStateModelId buildStringNodeId = "BuildStringId";
|
||||
AddState(new CreateNodeFromProposalState("Build String", onGraphStartEndpoint, "", buildStringNodeId));
|
||||
|
||||
AutomationStateModelId buildStringEndpoint = "BuildString::ExecutionEndpoint";
|
||||
|
||||
AddState(new FindEndpointOfTypeState(buildStringNodeId, buildStringEndpoint, GraphCanvas::CT_Output, GraphCanvas::SlotTypes::ExecutionSlot));
|
||||
|
||||
AutomationStateModelId printNodeId = "PrintNodeId";
|
||||
AddState(new CreateNodeFromProposalState("Print", buildStringEndpoint, "", printNodeId));
|
||||
|
||||
AddState(new AltClickSceneElementState(buildStringNodeId));
|
||||
|
||||
AutomationStateModelId altClickConnectionTarget = "ConnectionTarget";
|
||||
AddState(new GetLastConnection(onGraphStartEndpoint, altClickConnectionTarget));
|
||||
|
||||
AddState(new AltClickSceneElementState(altClickConnectionTarget));
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// CutCopyPasteDuplicateTest
|
||||
//////////////////////////////
|
||||
|
||||
CutCopyPasteDuplicateTest::CheckpointState::CheckpointState(AZStd::string checkPoint)
|
||||
: CustomActionState(checkPoint.c_str())
|
||||
{
|
||||
}
|
||||
|
||||
CutCopyPasteDuplicateTest::CutCopyPasteDuplicateTest(QString nodeName)
|
||||
: EditorAutomationTest(QString("Cut/Copy/Paste/Duplicate %1 Test").arg(nodeName))
|
||||
, m_originalNodeId("OriginalNodeId")
|
||||
{
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId viewCenter = "ViewCenter";
|
||||
AddState(new FindViewCenterState(viewCenter));
|
||||
|
||||
m_createNodeState = new CreateNodeFromContextMenuState(nodeName, CreateNodeFromContextMenuState::CreationType::ScenePosition, viewCenter, m_originalNodeId);
|
||||
AddState(m_createNodeState);
|
||||
|
||||
AddState(new SelectSceneElementState(m_originalNodeId));
|
||||
|
||||
AddState(new TriggerHotKey(QChar('x'), "CutOriginal"));
|
||||
AddState(new TriggerHotKey(QChar('v'), "PasteOriginal"));
|
||||
|
||||
m_cutPasteCheckpoint = new CheckpointState("Confirm Cut/Paste");
|
||||
AddState(m_cutPasteCheckpoint);
|
||||
|
||||
AddState(new TriggerHotKey(QChar('c'), "CopyOriginal"));
|
||||
AddState(new TriggerHotKey(QChar('v'), "PasteCopied"));
|
||||
|
||||
m_copyPasteCheckpoint = new CheckpointState("Confirm Copy/Paste");
|
||||
AddState(m_copyPasteCheckpoint);
|
||||
|
||||
AddState(new TriggerHotKey(QChar('c'), "CopyCopied"));
|
||||
AddState(new TriggerHotKey(QChar('v'), "PasteCopiedCopied"));
|
||||
|
||||
m_copyPasteCopyCheckpoint = new CheckpointState("Confirm Copy/Paste for Copy");
|
||||
AddState(m_copyPasteCopyCheckpoint);
|
||||
|
||||
AddState(new TriggerHotKey(QChar('d'), "Duplicate"));
|
||||
|
||||
m_duplicateCheckpoint = new CheckpointState("Confirm Duplication");
|
||||
AddState(m_duplicateCheckpoint);
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
|
||||
void CutCopyPasteDuplicateTest::OnNodeAdded(const AZ::EntityId& nodeId, bool)
|
||||
{
|
||||
m_createdSet.insert(nodeId);
|
||||
}
|
||||
|
||||
void CutCopyPasteDuplicateTest::OnNodeRemoved(const AZ::EntityId& nodeId)
|
||||
{
|
||||
if (nodeId == m_removalTarget)
|
||||
{
|
||||
m_removalTarget.SetInvalid();
|
||||
}
|
||||
}
|
||||
|
||||
void CutCopyPasteDuplicateTest::OnStateComplete(int stateId)
|
||||
{
|
||||
if (stateId == CreateRuntimeGraphStateId::StateID())
|
||||
{
|
||||
const GraphCanvas::GraphId* graphId = GetStateDataAs<GraphCanvas::GraphId>(StateModelIds::GraphCanvasId);
|
||||
|
||||
if (graphId)
|
||||
{
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusConnect((*graphId));
|
||||
}
|
||||
}
|
||||
else if (stateId == m_createNodeState->GetStateId())
|
||||
{
|
||||
const GraphCanvas::NodeId* nodeId = GetStateDataAs<GraphCanvas::GraphId>(m_originalNodeId);
|
||||
|
||||
if (nodeId)
|
||||
{
|
||||
m_removalTarget = (*nodeId);
|
||||
m_createdSet.clear();
|
||||
}
|
||||
}
|
||||
else if (stateId == m_cutPasteCheckpoint->GetStateId())
|
||||
{
|
||||
if (m_removalTarget.IsValid())
|
||||
{
|
||||
AddError("Cut failed to remove original element from the scene.");
|
||||
}
|
||||
else if (m_createdSet.empty())
|
||||
{
|
||||
AddError("Paste failed to add element to the scene.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessCreationSet();
|
||||
}
|
||||
}
|
||||
else if (stateId == m_copyPasteCheckpoint->GetStateId()
|
||||
|| stateId == m_copyPasteCopyCheckpoint->GetStateId())
|
||||
{
|
||||
if (m_createdSet.empty())
|
||||
{
|
||||
AddError("Paste failed to add element to the scene.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessCreationSet();
|
||||
}
|
||||
}
|
||||
else if (stateId == stateId == m_duplicateCheckpoint->GetStateId())
|
||||
{
|
||||
if (m_createdSet.empty())
|
||||
{
|
||||
AddError("Duplicate failed to add element to the scene.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessCreationSet();
|
||||
}
|
||||
}
|
||||
else if (stateId == ForceCloseActiveGraphStateId::StateID())
|
||||
{
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void CutCopyPasteDuplicateTest::ProcessCreationSet()
|
||||
{
|
||||
AZ::EntityId testId;
|
||||
|
||||
for (GraphCanvas::NodeId nodeId : m_createdSet)
|
||||
{
|
||||
if (GraphCanvas::GraphUtils::IsNodeWrapped(nodeId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
testId = nodeId;
|
||||
break;
|
||||
}
|
||||
|
||||
m_createdSet.clear();
|
||||
|
||||
bool isSelected = false;
|
||||
GraphCanvas::SceneMemberUIRequestBus::EventResult(isSelected, testId, &GraphCanvas::SceneMemberUIRequests::IsSelected);
|
||||
|
||||
if (!isSelected)
|
||||
{
|
||||
AddError("Pasted node is not selected by default.");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
bool CutCopyPasteDuplicateTest::TransitionToState(int state)
|
||||
{
|
||||
if (state == CutOriginalNode)
|
||||
{
|
||||
delete m_selectElement;
|
||||
m_selectElement = aznew SelectSceneElementAction(m_target);
|
||||
|
||||
m_removalTarget = m_target;
|
||||
|
||||
m_actionRunner.AddAction(m_selectElement);
|
||||
m_actionRunner.AddAction(&m_pressCtrlAction);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_typeX);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_releaseCtrlAction);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
}
|
||||
else if (state == PasteOriginalNode)
|
||||
{
|
||||
m_actionRunner.AddAction(&m_pressCtrlAction);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_typeV);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_releaseCtrlAction);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
}
|
||||
else if (state == CopyPasteOriginalNodeState)
|
||||
{
|
||||
m_actionRunner.AddAction(&m_pressCtrlAction);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_typeC);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_typeV);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_releaseCtrlAction);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
}
|
||||
else if (state == CopyPasteDuplicatedNodeState)
|
||||
{
|
||||
m_actionRunner.AddAction(&m_pressCtrlAction);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_typeC);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_typeV);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_releaseCtrlAction);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
}
|
||||
else if (state == DuplicateNodeState)
|
||||
{
|
||||
m_actionRunner.AddAction(&m_pressCtrlAction);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_typeD);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
m_actionRunner.AddAction(&m_releaseCtrlAction);
|
||||
m_actionRunner.AddAction(&m_processEvents);
|
||||
}
|
||||
else if (state == ForceCloseGraphState)
|
||||
{
|
||||
m_actionRunner.AddAction(&m_forceCloseGraphAction);
|
||||
}
|
||||
|
||||
return m_actionRunner.HasActions();
|
||||
}
|
||||
|
||||
void CutCopyPasteDuplicateTest::OnTestComplete()
|
||||
{
|
||||
delete m_createFromContextMenu;
|
||||
m_createFromContextMenu = nullptr;
|
||||
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void CutCopyPasteDuplicateTest::OnStateComplete(int state)
|
||||
{
|
||||
if (state == CreateGraphState)
|
||||
{
|
||||
m_graphId = m_createNewGraphAction.GetGraphId();
|
||||
GraphCanvas::SceneNotificationBus::Handler::BusConnect(m_graphId);
|
||||
}
|
||||
else if (state == CreateNodeState)
|
||||
{
|
||||
m_target = m_createFromContextMenu->GetCreatedNodeId();
|
||||
m_createdSet.clear();
|
||||
}
|
||||
else if (state == CutOriginalNode)
|
||||
{
|
||||
if (m_removalTarget.IsValid())
|
||||
{
|
||||
AddError(QString("Failed to cut %1").arg(m_nodeName).toUtf8().data());
|
||||
}
|
||||
}
|
||||
else if (state == PasteOriginalNode)
|
||||
{
|
||||
if (m_createdSet.empty())
|
||||
{
|
||||
AddError(QString("Failed to cut and paste original %1").arg(m_nodeName).toUtf8().data());
|
||||
}
|
||||
else
|
||||
{
|
||||
for (GraphCanvas::NodeId nodeId : m_createdSet)
|
||||
{
|
||||
if (GraphCanvas::GraphUtils::IsNodeWrapped(nodeId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
m_target = nodeId;
|
||||
break;
|
||||
}
|
||||
|
||||
m_createdSet.clear();
|
||||
|
||||
bool isSelected = false;
|
||||
GraphCanvas::SceneMemberUIRequestBus::EventResult(isSelected, m_target, &GraphCanvas::SceneMemberUIRequests::IsSelected);
|
||||
|
||||
if (!isSelected)
|
||||
{
|
||||
AddError("Pasted node is not selected by default.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (state == CopyPasteOriginalNodeState)
|
||||
{
|
||||
if (m_createdSet.empty())
|
||||
{
|
||||
AddError(QString("Failed to copy and paste original %1").arg(m_nodeName).toUtf8().data());
|
||||
}
|
||||
else
|
||||
{
|
||||
for (GraphCanvas::NodeId nodeId : m_createdSet)
|
||||
{
|
||||
if (GraphCanvas::GraphUtils::IsNodeWrapped(nodeId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
m_target = nodeId;
|
||||
break;
|
||||
}
|
||||
|
||||
m_createdSet.clear();
|
||||
|
||||
bool isSelected = false;
|
||||
GraphCanvas::SceneMemberUIRequestBus::EventResult(isSelected, m_target, &GraphCanvas::SceneMemberUIRequests::IsSelected);
|
||||
|
||||
if (!isSelected)
|
||||
{
|
||||
AddError("Pasted node is not selected by default.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (state == CopyPasteDuplicatedNodeState)
|
||||
{
|
||||
if (m_createdSet.empty())
|
||||
{
|
||||
AddError(QString("Failed to copy and paste duplicated %1").arg(m_nodeName).toUtf8().data());
|
||||
}
|
||||
else
|
||||
{
|
||||
for (GraphCanvas::NodeId nodeId : m_createdSet)
|
||||
{
|
||||
if (GraphCanvas::GraphUtils::IsNodeWrapped(nodeId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
m_target = nodeId;
|
||||
break;
|
||||
}
|
||||
|
||||
m_createdSet.clear();
|
||||
|
||||
bool isSelected = false;
|
||||
GraphCanvas::SceneMemberUIRequestBus::EventResult(isSelected, m_target, &GraphCanvas::SceneMemberUIRequests::IsSelected);
|
||||
|
||||
if (!isSelected)
|
||||
{
|
||||
AddError("Pasted node is not selected by default.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (state == DuplicateNodeState)
|
||||
{
|
||||
if (m_createdSet.empty())
|
||||
{
|
||||
AddError(QString("Failed to duplicate %1").arg(m_nodeName).toUtf8().data());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_createdSet.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CutCopyPasteDuplicateTest::CleanupAfterErrorState()
|
||||
{
|
||||
if (m_createNewGraphAction.GetGraphId().IsValid())
|
||||
{
|
||||
m_actionRunner.AddAction(&m_forceCloseGraphAction);
|
||||
}
|
||||
|
||||
return m_actionRunner.HasActions();
|
||||
}
|
||||
*/
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 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 <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QString>
|
||||
#include <QTableView>
|
||||
|
||||
#include <GraphCanvas/Components/Nodes/NodeBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/SlotBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/CreateElementsStates.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorautomationTest that will test out the AltClick to delete elements functionality for nodes, connected nodes, and connections
|
||||
*/
|
||||
class AltClickDeleteTest
|
||||
: public EditorAutomationTest
|
||||
, public GraphCanvas::SceneNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AltClickDeleteTest();
|
||||
~AltClickDeleteTest() override = default;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that will test out the cut/copy/paste functions
|
||||
*/
|
||||
class CutCopyPasteDuplicateTest
|
||||
: public EditorAutomationTest
|
||||
, public GraphCanvas::SceneNotificationBus::Handler
|
||||
{
|
||||
class CheckpointState
|
||||
: public CustomActionState
|
||||
{
|
||||
public:
|
||||
CheckpointState(AZStd::string checkpoint);
|
||||
~CheckpointState() override = default;
|
||||
|
||||
void OnCustomAction() override {}
|
||||
};
|
||||
|
||||
public:
|
||||
CutCopyPasteDuplicateTest(QString nodeName);
|
||||
~CutCopyPasteDuplicateTest() override = default;
|
||||
|
||||
// SceneNotificationBus
|
||||
void OnNodeAdded(const AZ::EntityId& nodeId, bool isPaste) override;
|
||||
void OnNodeRemoved(const AZ::EntityId& nodeId) override;
|
||||
///
|
||||
|
||||
// EditorAutomationTests
|
||||
void OnStateComplete(int stateId) override;
|
||||
////
|
||||
|
||||
private:
|
||||
|
||||
void ProcessCreationSet();
|
||||
|
||||
AutomationStateModelId m_originalNodeId;
|
||||
|
||||
GraphCanvas::NodeId m_removalTarget;
|
||||
AZStd::unordered_set< GraphCanvas::NodeId > m_createdSet;
|
||||
|
||||
CreateNodeFromContextMenuState* m_createNodeState = nullptr;
|
||||
|
||||
CheckpointState* m_cutPasteCheckpoint = nullptr;
|
||||
CheckpointState* m_copyPasteCheckpoint = nullptr;
|
||||
CheckpointState* m_copyPasteCopyCheckpoint = nullptr;
|
||||
CheckpointState* m_duplicateCheckpoint = nullptr;
|
||||
};
|
||||
}
|
||||
+107
@@ -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.
|
||||
*
|
||||
*/
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <qpushbutton.h>
|
||||
|
||||
#include <GraphCanvas/Components/GridBus.h>
|
||||
#include <GraphCanvas/Components/Nodes/Group/NodeGroupBus.h>
|
||||
|
||||
#include <EditorAutomationTests/NodeCreationTests.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
|
||||
#include <ScriptCanvas/GraphCanvas/MappingBus.h>
|
||||
#include <ScriptCanvas/Core/Node.h>
|
||||
#include <ScriptCanvas/Core/NodeBus.h>
|
||||
#include <ScriptCanvas/Bus/EditorScriptCanvasBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ElementInteractions.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
///////////////////////
|
||||
// CreateCategoryTest
|
||||
///////////////////////
|
||||
|
||||
CreateCategoryTest::CreateCategoryTest(AZStd::string categoryString, GraphCanvas::NodePaletteWidget* nodePaletteWidget)
|
||||
: EditorAutomationTest(QString("Create %1 Category from Palette").arg(categoryString.c_str()))
|
||||
{
|
||||
AutomationStateModelId categoryId = "CategoryId";
|
||||
SetStateData(categoryId, categoryString);
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId viewCenterId = "ViewCenterId";
|
||||
AddState(new FindViewCenterState(viewCenterId));
|
||||
|
||||
AddState(new CreateCategoryFromNodePaletteState(nodePaletteWidget, categoryId, viewCenterId));
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
// CreateExecutionSplicedNodeTest
|
||||
///////////////////////////////////
|
||||
|
||||
CreateExecutionSplicedNodeTest::CreateExecutionSplicedNodeTest(QString nodeName)
|
||||
: EditorAutomationTest(QString("Create %1 via Connection Splice").arg(nodeName))
|
||||
{
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId onGraphStartTargetPointId = "OnGraphStartScenePoint";
|
||||
AutomationStateModelId onGraphStartId = "OnGraphStartId";
|
||||
|
||||
AddState(new FindViewCenterState(onGraphStartTargetPointId));
|
||||
AddState(new CreateNodeFromContextMenuState("On Graph Start", CreateNodeFromContextMenuState::CreationType::ScenePosition, onGraphStartTargetPointId, onGraphStartId));
|
||||
|
||||
AutomationStateModelId onGraphStartEndpoint = "OnGraphStart::ExecutionEndpoint";
|
||||
|
||||
AddState(new FindEndpointOfTypeState(onGraphStartId, onGraphStartEndpoint, GraphCanvas::CT_Output, GraphCanvas::SlotTypes::ExecutionSlot));
|
||||
|
||||
AutomationStateModelId printNodeId = "PrintId";
|
||||
AutomationStateModelId spliceTargetId = "SpliceTargetId";
|
||||
AddState(new CreateNodeFromProposalState("Print", onGraphStartEndpoint, "", printNodeId, spliceTargetId));
|
||||
|
||||
AddState(new CreateNodeFromContextMenuState(nodeName, CreateNodeFromContextMenuState::CreationType::Splice, spliceTargetId));
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
// CreateExecutionSplicedNodeTest
|
||||
///////////////////////////////////
|
||||
|
||||
CreateDragDropExecutionSpliceNodeTest::CreateDragDropExecutionSpliceNodeTest(GraphCanvas::NodePaletteWidget* nodePaletteWidget, QString nodeName)
|
||||
: EditorAutomationTest(QString("Create %1 via Dropped Connection Splice").arg(nodeName))
|
||||
{
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId onGraphStartTargetPointId = "OnGraphStartScenePoint";
|
||||
AutomationStateModelId onGraphStartId = "OnGraphStartId";
|
||||
|
||||
AddState(new FindViewCenterState(onGraphStartTargetPointId));
|
||||
AddState(new CreateNodeFromContextMenuState("On Graph Start", CreateNodeFromContextMenuState::CreationType::ScenePosition, onGraphStartTargetPointId, onGraphStartId));
|
||||
|
||||
AutomationStateModelId onGraphStartEndpoint = "OnGraphStart::ExecutionEndpoint";
|
||||
|
||||
AddState(new FindEndpointOfTypeState(onGraphStartId, onGraphStartEndpoint, GraphCanvas::CT_Output, GraphCanvas::SlotTypes::ExecutionSlot));
|
||||
|
||||
AutomationStateModelId printNodeId = "PrintId";
|
||||
AutomationStateModelId spliceTargetId = "SpliceTargetId";
|
||||
AddState(new CreateNodeFromProposalState("Print", onGraphStartEndpoint, "", printNodeId, spliceTargetId));
|
||||
|
||||
AddState(new CreateNodeFromPaletteState(nodePaletteWidget, nodeName, CreateNodeFromPaletteState::CreationType::Splice, spliceTargetId));
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
}
|
||||
+177
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* 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 <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QString>
|
||||
|
||||
#include <GraphCanvas/Components/Nodes/NodeBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/SlotBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/ConnectionStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/CreateElementsStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/EditorViewStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/ElementInteractionStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/GraphStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/UtilityStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/VariableStates.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorautomationTest that creates a node from the node palette using drag/drop
|
||||
*/
|
||||
class CreateNodeFromPaletteTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
|
||||
CreateNodeFromPaletteTest(const AZStd::string& nodeName, GraphCanvas::NodePaletteWidget* paletteWidget)
|
||||
: EditorAutomationTest(AZStd::string::format("Create %s from Node Palette", nodeName.c_str()).c_str())
|
||||
{
|
||||
AutomationStateModelId viewCenterModelId = "ViewCenter";
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
AddState(new FindViewCenterState(viewCenterModelId));
|
||||
AddState(new CreateNodeFromPaletteState(paletteWidget, nodeName.c_str(), CreateNodeFromPaletteState::CreationType::ScenePosition, viewCenterModelId));
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that creates a node from the context menu
|
||||
*/
|
||||
class CreateNodeFromContextMenuTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
|
||||
CreateNodeFromContextMenuTest(const AZStd::string& nodeName)
|
||||
: EditorAutomationTest(AZStd::string::format("Create %s from Context Menu", nodeName.c_str()).c_str())
|
||||
{
|
||||
AutomationStateModelId viewCenterModelId = "ViewCenter";
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
AddState(new FindViewCenterState(viewCenterModelId));
|
||||
AddState(new CreateNodeFromContextMenuState(nodeName.c_str(), CreateNodeFromContextMenuState::CreationType::ScenePosition, viewCenterModelId));
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that creates a simple graph from the node palette and coupling.
|
||||
*/
|
||||
class CreateHelloWorldFromPalette
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
|
||||
CreateHelloWorldFromPalette(GraphCanvas::NodePaletteWidget* paletteWidget)
|
||||
: EditorAutomationTest("Create Hello World From Palette")
|
||||
{
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId onGraphStartTargetPointId = "OnGraphStartScenePoint";
|
||||
AutomationStateModelId onGraphStartId = "OnGraphStartId";
|
||||
|
||||
AddState(new FindViewCenterState(onGraphStartTargetPointId));
|
||||
AddState(new CreateNodeFromPaletteState(paletteWidget, "On Graph Start", CreateNodeFromPaletteState::CreationType::ScenePosition, onGraphStartTargetPointId, onGraphStartId));
|
||||
|
||||
AutomationStateModelId printTargetPoint = "PrintScenePoint";
|
||||
AutomationStateModelId printId = "PrintId";
|
||||
|
||||
FindPositionOffsets offsets;
|
||||
offsets.m_horizontalPosition = 1;
|
||||
offsets.m_horizontalOffset = 50;
|
||||
|
||||
AddState(new FindNodePosition(onGraphStartId, printTargetPoint, offsets));
|
||||
AddState(new CreateNodeFromPaletteState(paletteWidget, "Print", CreateNodeFromPaletteState::CreationType::ScenePosition, printTargetPoint, printId));
|
||||
|
||||
AddState(new CoupleNodesState(onGraphStartId, GraphCanvas::ConnectionType::CT_Output, printId));
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that creates a simple graph from the context menu and coupling.
|
||||
*/
|
||||
class CreateHelloWorldFromContextMenu
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
|
||||
CreateHelloWorldFromContextMenu()
|
||||
: EditorAutomationTest("Create Hello World From Context Menu")
|
||||
{
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId onGraphStartTargetPointId = "OnGraphStartScenePoint";
|
||||
AutomationStateModelId onGraphStartId = "OnGraphStartId";
|
||||
|
||||
AddState(new FindViewCenterState(onGraphStartTargetPointId));
|
||||
AddState(new CreateNodeFromContextMenuState("On Graph Start", CreateNodeFromContextMenuState::CreationType::ScenePosition, onGraphStartTargetPointId, onGraphStartId));
|
||||
|
||||
AutomationStateModelId printTargetPoint = "PrintScenePoint";
|
||||
AutomationStateModelId printId = "PrintId";
|
||||
|
||||
FindPositionOffsets offsets;
|
||||
offsets.m_horizontalPosition = 1;
|
||||
offsets.m_horizontalOffset = 50;
|
||||
|
||||
AddState(new FindNodePosition(onGraphStartId, printTargetPoint, offsets));
|
||||
AddState(new CreateNodeFromContextMenuState("Print", CreateNodeFromContextMenuState::CreationType::ScenePosition, printTargetPoint, printId));
|
||||
|
||||
AddState(new CoupleNodesState(onGraphStartId, GraphCanvas::ConnectionType::CT_Output, printId));
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that creates all of the nodes under the specified category
|
||||
*/
|
||||
class CreateCategoryTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
CreateCategoryTest(AZStd::string categoryString, GraphCanvas::NodePaletteWidget* nodePaletteWidget);
|
||||
~CreateCategoryTest() override = default;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that will splice the specified node onto a simple graph using execution connections and the context menu
|
||||
*/
|
||||
class CreateExecutionSplicedNodeTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
CreateExecutionSplicedNodeTest(QString nodeName);
|
||||
~CreateExecutionSplicedNodeTest() override = default;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that will splice the specified node onto a simple graph using execution connections and dragging/dropping
|
||||
*/
|
||||
class CreateDragDropExecutionSpliceNodeTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
CreateDragDropExecutionSpliceNodeTest(GraphCanvas::NodePaletteWidget* nodePaletteWidget, QString nodeName);
|
||||
~CreateDragDropExecutionSpliceNodeTest() override = default;
|
||||
};
|
||||
}
|
||||
+886
@@ -0,0 +1,886 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <qpushbutton.h>
|
||||
|
||||
#include <GraphCanvas/Components/GridBus.h>
|
||||
#include <GraphCanvas/Components/Nodes/Group/NodeGroupBus.h>
|
||||
|
||||
#include <EditorAutomationTests/VariableTests.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
|
||||
#include <ScriptCanvas/GraphCanvas/MappingBus.h>
|
||||
#include <ScriptCanvas/Core/Node.h>
|
||||
#include <ScriptCanvas/Core/NodeBus.h>
|
||||
#include <ScriptCanvas/Bus/EditorScriptCanvasBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ElementInteractions.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/EditorViewStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/ElementInteractionStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/GraphStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/UtilityStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/VariableStates.h>
|
||||
|
||||
#if !defined(AZ_COMPILER_MSVC)
|
||||
#ifndef VK_RETURN
|
||||
#define VK_RETURN 0x0D
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
///////////////////////////////
|
||||
// ManuallyCreateVariableTest
|
||||
///////////////////////////////
|
||||
|
||||
AZStd::string GetModifierDescription(CreateVariableAction::CreationType creationType)
|
||||
{
|
||||
AZStd::string modifierDescription;
|
||||
|
||||
switch (creationType)
|
||||
{
|
||||
case CreateVariableAction::CreationType::AutoComplete:
|
||||
break;
|
||||
case CreateVariableAction::CreationType::Palette:
|
||||
modifierDescription = "From Palette";
|
||||
break;
|
||||
case CreateVariableAction::CreationType::Programmatic:
|
||||
modifierDescription = "Programmatically";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return modifierDescription;
|
||||
}
|
||||
|
||||
ManuallyCreateVariableTest::ManuallyCreateVariableTest(ScriptCanvas::Data::Type dataType, CreateVariableAction::CreationType creationType, AZStd::string variableName)
|
||||
: EditorAutomationTest(QString("Create %1 %2").arg(ScriptCanvas::Data::GetName(dataType).c_str()).arg(GetModifierDescription(creationType).c_str()))
|
||||
{
|
||||
AutomationStateModelId variableTypeId = "VariableDataType";
|
||||
SetStateData(variableTypeId, dataType);
|
||||
|
||||
AutomationStateModelId variableNameId = "VariableName";
|
||||
SetStateData(variableNameId, variableName);
|
||||
|
||||
constexpr bool errorOnNameMismatch = true;
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
AddState(new CreateVariableState(variableTypeId, variableNameId, errorOnNameMismatch, creationType));
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
// CreateNamedVariableTest
|
||||
////////////////////////////
|
||||
|
||||
CreateNamedVariableTest::CreateNamedVariableTest(ScriptCanvas::Data::Type dataType, AZStd::string name, CreateVariableAction::CreationType creationType)
|
||||
: ManuallyCreateVariableTest(dataType, creationType, name)
|
||||
{
|
||||
SetTestName(AZStd::string::format("Create %s with name %s", ScriptCanvas::Data::GetName(dataType).c_str(), name.c_str()).c_str());
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// DuplicateVariableNameTest
|
||||
//////////////////////////////
|
||||
|
||||
DuplicateVariableNameTest::CheckVariableForNameMismatchState::CheckVariableForNameMismatchState(AutomationStateModelId nameId, AutomationStateModelId variableId)
|
||||
: CustomActionState("CheckVariableForNameMismatchState")
|
||||
, m_nameId(nameId)
|
||||
, m_variableId(variableId)
|
||||
{
|
||||
SetStateName("CheckVariableForNameMismatchState");
|
||||
}
|
||||
|
||||
void DuplicateVariableNameTest::CheckVariableForNameMismatchState::OnCustomAction()
|
||||
{
|
||||
const ScriptCanvas::ScriptCanvasId* scriptCanvasId = GetStateModel()->GetStateDataAs<ScriptCanvas::ScriptCanvasId>(StateModelIds::ScriptCanvasId);
|
||||
const ScriptCanvas::VariableId* variableId = GetStateModel()->GetStateDataAs<ScriptCanvas::VariableId>(m_variableId);
|
||||
const AZStd::string* variableName = GetStateModel()->GetStateDataAs<AZStd::string>(m_nameId);
|
||||
|
||||
if (variableId && scriptCanvasId && variableName)
|
||||
{
|
||||
ScriptCanvas::GraphVariable* graphVariable = nullptr;
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(graphVariable, (*scriptCanvasId), &ScriptCanvas::GraphVariableManagerRequests::FindVariableById, (*variableId));
|
||||
|
||||
QString testName = QString(variableName->c_str());
|
||||
|
||||
if (testName.compare(graphVariable->GetVariableName().data(), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
ReportError(AZStd::string::format("Second Variable has duplicate name %s", testName.toUtf8().data()).c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (variableId == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid VariableId", m_variableId.c_str()));
|
||||
}
|
||||
|
||||
if (variableName == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid string", m_nameId.c_str()));
|
||||
}
|
||||
|
||||
if (scriptCanvasId == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid ScriptCanvas::ScriptCanvasId", StateModelIds::ScriptCanvasId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DuplicateVariableNameTest::DuplicateVariableNameTest(ScriptCanvas::Data::Type firstType, ScriptCanvas::Data::Type secondType, AZStd::string variableName)
|
||||
: EditorAutomationTest(QString("Duplicate Variable name %1 Test").arg(variableName.c_str()))
|
||||
{
|
||||
AutomationStateModelId firstVariableTypeId = "VariableDataType::1";
|
||||
SetStateData(firstVariableTypeId, firstType);
|
||||
|
||||
AutomationStateModelId secondVariableTypeId = "VariableDataType::2";
|
||||
SetStateData(secondVariableTypeId, secondType);
|
||||
|
||||
AutomationStateModelId variableNameId = "VariableName";
|
||||
SetStateData(variableNameId, variableName);
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
constexpr bool errorOnNameMismatch = true;
|
||||
|
||||
AutomationStateModelId firstVariableId = "VariableId::1";
|
||||
AddState(new CreateVariableState(firstVariableTypeId, variableNameId, errorOnNameMismatch, CreateVariableAction::CreationType::AutoComplete, firstVariableId));
|
||||
|
||||
AutomationStateModelId secondVariableId = "VariableId::2";
|
||||
AddState(new CreateVariableState(secondVariableTypeId, variableNameId, !errorOnNameMismatch, CreateVariableAction::CreationType::AutoComplete, secondVariableId));
|
||||
|
||||
AddState(new CheckVariableForNameMismatchState(variableNameId, secondVariableId));
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
|
||||
namespace EditStringLike
|
||||
{
|
||||
VariableInPaletteState::VariableInPaletteState(AZStd::string value, AutomationStateModelId variableId, VariablePaletteValidator validator)
|
||||
: NamedAutomationState("EditStringLikeVariableInPaletteState")
|
||||
, m_stringValue(value)
|
||||
, m_variableId(variableId)
|
||||
, m_validator(validator)
|
||||
, m_clickAction(Qt::MouseButton::LeftButton)
|
||||
, m_typeStringAction(value.c_str())
|
||||
, m_typeReturnAction(VK_RETURN)
|
||||
{
|
||||
}
|
||||
|
||||
void VariableInPaletteState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
QTableView* graphPalette = nullptr;
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(graphPalette, &ScriptCanvasEditor::VariableAutomationRequests::GetGraphPaletteTableView);
|
||||
|
||||
if (graphPalette)
|
||||
{
|
||||
// 0 is the row, we've only created the single variable in this test, so we can assume that.
|
||||
// 2 is the column, this is just the column we need to click on in order to enter the editing mode.
|
||||
QModelIndex tableIndex = graphPalette->model()->index(0, 2);
|
||||
|
||||
QRectF visualRect = graphPalette->visualRect(tableIndex);
|
||||
QPoint targetPoint = graphPalette->mapToGlobal(visualRect.center().toPoint());
|
||||
|
||||
m_moveToTableRow = aznew MouseMoveAction(targetPoint);
|
||||
|
||||
actionRunner.AddAction(m_moveToTableRow);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
actionRunner.AddAction(&m_clickAction);
|
||||
actionRunner.AddAction(&m_clickAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
actionRunner.AddAction(&m_typeStringAction);
|
||||
actionRunner.AddAction(&m_typeReturnAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError("GraphPalette cannot be found in EditNumberInPaletteState");
|
||||
}
|
||||
}
|
||||
|
||||
void VariableInPaletteState::OnStateActionsComplete()
|
||||
{
|
||||
const ScriptCanvas::ScriptCanvasId* scriptCanvasId = GetStateModel()->GetStateDataAs<ScriptCanvas::ScriptCanvasId>(StateModelIds::ScriptCanvasId);
|
||||
const ScriptCanvas::VariableId* variableId = GetStateModel()->GetStateDataAs<ScriptCanvas::VariableId>(m_variableId);
|
||||
|
||||
if (scriptCanvasId)
|
||||
{
|
||||
ScriptCanvas::GraphVariable* graphVariable = nullptr;
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(graphVariable, (*scriptCanvasId), &ScriptCanvas::GraphVariableManagerRequests::FindVariableById, (*variableId));
|
||||
|
||||
if (graphVariable)
|
||||
{
|
||||
AZ::Outcome<void, AZStd::string> validationResult = m_validator(graphVariable);
|
||||
|
||||
if (!validationResult)
|
||||
{
|
||||
ReportError(validationResult.GetError());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError("Failed to find Created Variable");
|
||||
}
|
||||
}
|
||||
|
||||
if (m_moveToTableRow)
|
||||
{
|
||||
delete m_moveToTableRow;
|
||||
m_moveToTableRow = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
ValueInNodeState::ValueInNodeState(AZStd::string value, AutomationStateModelId endpointId, DatumValidator datumValidator)
|
||||
: NamedAutomationState("EditNumberInNodeState")
|
||||
, m_stringValue(value)
|
||||
, m_endpointId(endpointId)
|
||||
, m_datumValidator(datumValidator)
|
||||
, m_clickAction(Qt::MouseButton::LeftButton)
|
||||
, m_typeStringAction(value.c_str())
|
||||
, m_typeReturnAction(VK_RETURN)
|
||||
{
|
||||
}
|
||||
|
||||
void ValueInNodeState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
const GraphCanvas::Endpoint* targetEndpoint = GetStateModel()->GetStateDataAs<GraphCanvas::Endpoint>(m_endpointId);
|
||||
|
||||
if (targetEndpoint)
|
||||
{
|
||||
m_moveToPropertyAction = aznew MouseToNodePropertyEditorAction(targetEndpoint->GetSlotId());
|
||||
|
||||
actionRunner.AddAction(m_moveToPropertyAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
actionRunner.AddAction(&m_clickAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
actionRunner.AddAction(&m_typeStringAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
actionRunner.AddAction(&m_typeReturnAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid GraphCanvas::Endpoint", m_endpointId.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
void ValueInNodeState::OnStateActionsComplete()
|
||||
{
|
||||
const GraphCanvas::Endpoint* targetEndpoint = GetStateModel()->GetStateDataAs<GraphCanvas::Endpoint>(m_endpointId);
|
||||
const ScriptCanvas::ScriptCanvasId* scriptCanvasId = GetStateModel()->GetStateDataAs<ScriptCanvas::ScriptCanvasId>(StateModelIds::ScriptCanvasId);
|
||||
|
||||
if (targetEndpoint && scriptCanvasId)
|
||||
{
|
||||
ScriptCanvas::Endpoint scriptCanvasEndpoint;
|
||||
ScriptCanvasEditor::EditorGraphRequestBus::EventResult(scriptCanvasEndpoint, (*scriptCanvasId), &ScriptCanvasEditor::EditorGraphRequests::ConvertToScriptCanvasEndpoint, (*targetEndpoint));
|
||||
|
||||
if (scriptCanvasEndpoint.IsValid())
|
||||
{
|
||||
const ScriptCanvas::Datum* datum = nullptr;
|
||||
ScriptCanvas::NodeRequestBus::EventResult(datum, scriptCanvasEndpoint.GetNodeId(), &ScriptCanvas::NodeRequests::FindDatum, scriptCanvasEndpoint.GetSlotId());
|
||||
|
||||
AZ::Outcome<void, AZStd::string> datumValidation = m_datumValidator(datum);
|
||||
|
||||
if (!datumValidation)
|
||||
{
|
||||
ReportError(datumValidation.GetError());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError("Failed to convert Graph Canvas endpoint to Script Canvas endpoint");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
// ModifyNumericInputTest
|
||||
///////////////////////////
|
||||
|
||||
ModifyNumericInputTest::ModifyNumericInputTest(double value)
|
||||
: EditorAutomationTest("Numeric Input Test")
|
||||
{
|
||||
auto paletteDataValidator = [value](const ScriptCanvas::GraphVariable* graphVariable) -> AZ::Outcome<void, AZStd::string>
|
||||
{
|
||||
const ScriptCanvas::Datum* datum = graphVariable->GetDatum();
|
||||
|
||||
if (datum && datum->GetType() == ScriptCanvas::Data::Type::Number())
|
||||
{
|
||||
double currentValue = (*datum->GetAs<ScriptCanvas::Data::NumberType>());
|
||||
|
||||
if (!AZ::IsClose(currentValue, value, DBL_EPSILON))
|
||||
{
|
||||
return AZ::Failure<AZStd::string>(AZStd::string::format("Expected value %f found %f", value, currentValue));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return AZ::Failure<AZStd::string>("Datum is missing or incorrect type.");
|
||||
}
|
||||
|
||||
return AZ::Success();
|
||||
};
|
||||
|
||||
auto datumValidator = [value](const ScriptCanvas::Datum* datum) -> AZ::Outcome<void, AZStd::string>
|
||||
{
|
||||
if (datum && datum->GetType() == ScriptCanvas::Data::Type::Number())
|
||||
{
|
||||
const ScriptCanvas::Data::NumberType* numberType = datum->GetAs<ScriptCanvas::Data::NumberType>();
|
||||
|
||||
if (numberType)
|
||||
{
|
||||
if (!AZ::IsClose(value, (*numberType), DBL_EPSILON))
|
||||
{
|
||||
return AZ::Failure<AZStd::string>(AZStd::string::format("Expected datum value to be %f, got %f", value, (*numberType)));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return AZ::Failure<AZStd::string>("Datum is missing or incorrect type.");
|
||||
}
|
||||
|
||||
return AZ::Success();
|
||||
};
|
||||
|
||||
AZStd::string inputString = AZStd::string::format("%f", value);
|
||||
|
||||
AutomationStateModelId firstVariableTypeId = "VariableDataType";
|
||||
SetStateData(firstVariableTypeId, ScriptCanvas::Data::Type::Number());
|
||||
|
||||
AutomationStateModelId variableNameId = "VariableName";
|
||||
SetStateData(variableNameId, AZStd::string("Numeric"));
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId variableId = "VariableId";
|
||||
AddState(new CreateVariableState(firstVariableTypeId, variableNameId, false, CreateVariableAction::CreationType::AutoComplete, variableId));
|
||||
|
||||
AddState(new EditStringLike::VariableInPaletteState(inputString, variableId, paletteDataValidator));
|
||||
|
||||
AutomationStateModelId viewCenter = "ViewCenter";
|
||||
AddState(new FindViewCenterState(viewCenter));
|
||||
|
||||
AutomationStateModelId variableNodeId = "VariableNodeId";
|
||||
AddState(new CreateVariableNodeFromGraphPaletteState(variableNameId, viewCenter, Qt::KeyboardModifier::AltModifier, variableNodeId));
|
||||
|
||||
AutomationStateModelId dataSlotId = "DataSlotId";
|
||||
AddState(new FindEndpointOfTypeState(variableNodeId, dataSlotId, GraphCanvas::ConnectionType::CT_Input, GraphCanvas::SlotTypes::DataSlot));
|
||||
|
||||
AddState(new EditStringLike::ValueInNodeState(inputString, dataSlotId, datumValidator));
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
// ModifyStringInputTest
|
||||
//////////////////////////
|
||||
|
||||
ModifyStringInputTest::ModifyStringInputTest(AZStd::string value)
|
||||
: EditorAutomationTest("String Input Test")
|
||||
{
|
||||
auto paletteDataValidator = [value](const ScriptCanvas::GraphVariable* graphVariable) -> AZ::Outcome<void, AZStd::string>
|
||||
{
|
||||
const ScriptCanvas::Datum* datum = graphVariable->GetDatum();
|
||||
|
||||
if (datum && datum->GetType() == ScriptCanvas::Data::Type::String())
|
||||
{
|
||||
AZStd::string currentValue = (*datum->GetAs<ScriptCanvas::Data::StringType>());
|
||||
|
||||
if (currentValue.compare(value) != 0)
|
||||
{
|
||||
return AZ::Failure<AZStd::string>(AZStd::string::format("Expected value %s found %s", value.c_str(), currentValue.c_str()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return AZ::Failure<AZStd::string>("Datum is missing or incorrect type.");
|
||||
}
|
||||
|
||||
return AZ::Success();
|
||||
};
|
||||
|
||||
auto datumValidator = [value](const ScriptCanvas::Datum* datum) -> AZ::Outcome<void, AZStd::string>
|
||||
{
|
||||
if (datum && datum->GetType() == ScriptCanvas::Data::Type::String())
|
||||
{
|
||||
const ScriptCanvas::Data::StringType* stringType = datum->GetAs<ScriptCanvas::Data::StringType>();
|
||||
|
||||
if (stringType)
|
||||
{
|
||||
if (value.compare(stringType->c_str()) != 0)
|
||||
{
|
||||
return AZ::Failure<AZStd::string>(AZStd::string::format("Expected datum value to be %s, got %s", value.c_str(), (*stringType).c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return AZ::Failure<AZStd::string>("Datum is missing or incorrect type.");
|
||||
}
|
||||
|
||||
return AZ::Success();
|
||||
};
|
||||
|
||||
AutomationStateModelId firstVariableTypeId = "VariableDataType";
|
||||
SetStateData(firstVariableTypeId, ScriptCanvas::Data::Type::String());
|
||||
|
||||
AutomationStateModelId variableNameId = "VariableName";
|
||||
SetStateData(variableNameId, AZStd::string("String"));
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId variableId = "VariableId";
|
||||
AddState(new CreateVariableState(firstVariableTypeId, variableNameId, false, CreateVariableAction::CreationType::AutoComplete, variableId));
|
||||
|
||||
AddState(new EditStringLike::VariableInPaletteState(value, variableId, paletteDataValidator));
|
||||
|
||||
AutomationStateModelId viewCenter = "ViewCenter";
|
||||
AddState(new FindViewCenterState(viewCenter));
|
||||
|
||||
AutomationStateModelId variableNodeId = "VariableNodeId";
|
||||
AddState(new CreateVariableNodeFromGraphPaletteState(variableNameId, viewCenter, Qt::KeyboardModifier::AltModifier, variableNodeId));
|
||||
|
||||
AutomationStateModelId dataSlotId = "DataSlotId";
|
||||
AddState(new FindEndpointOfTypeState(variableNodeId, dataSlotId, GraphCanvas::ConnectionType::CT_Input, GraphCanvas::SlotTypes::DataSlot));
|
||||
|
||||
AddState(new EditStringLike::ValueInNodeState(value, dataSlotId, datumValidator));
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
// ToggleBoolInputTest
|
||||
////////////////////////
|
||||
|
||||
ToggleBoolInputTest::ToggleBoolInPaletteState::ToggleBoolInPaletteState(AutomationStateModelId variableId)
|
||||
: NamedAutomationState("ToggleBoolInPaletteState")
|
||||
, m_variableId(variableId)
|
||||
{
|
||||
SetStateName(AZStd::string::format("ToggleBoolInPaletteState::%s", m_variableId.c_str()));
|
||||
}
|
||||
|
||||
void ToggleBoolInputTest::ToggleBoolInPaletteState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
const ScriptCanvas::VariableId* variableId = GetStateModel()->GetStateDataAs<ScriptCanvas::VariableId>(m_variableId);
|
||||
const ScriptCanvas::ScriptCanvasId* scriptCanvasId = GetStateModel()->GetStateDataAs<ScriptCanvas::ScriptCanvasId>(StateModelIds::ScriptCanvasId);
|
||||
|
||||
if (variableId && scriptCanvasId)
|
||||
{
|
||||
ScriptCanvas::GraphVariable* graphVariable = nullptr;
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(graphVariable, (*scriptCanvasId), &ScriptCanvas::GraphVariableManagerRequests::FindVariableById, (*variableId));
|
||||
|
||||
if (graphVariable)
|
||||
{
|
||||
const ScriptCanvas::Datum* datum = graphVariable->GetDatum();
|
||||
|
||||
if (datum && datum->GetType() == ScriptCanvas::Data::Type::Boolean())
|
||||
{
|
||||
m_originalValue = (*datum->GetAs<ScriptCanvas::Data::BooleanType>());
|
||||
}
|
||||
|
||||
QTableView* graphPalette = nullptr;
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(graphPalette, &ScriptCanvasEditor::VariableAutomationRequests::GetGraphPaletteTableView);
|
||||
|
||||
if (graphPalette)
|
||||
{
|
||||
// Assume that the variable will be the only element created in this state. So we can just use row 0.
|
||||
QModelIndex tableIndex = graphPalette->model()->index(0, 2);
|
||||
|
||||
QRectF visualRect = graphPalette->visualRect(tableIndex);
|
||||
QPointF clickPoint = visualRect.center();
|
||||
clickPoint.setX(visualRect.left() + 15);
|
||||
|
||||
QPoint targetPoint = graphPalette->mapToGlobal(clickPoint.toPoint());
|
||||
|
||||
m_interactWithTableAction = aznew MouseClickAction(Qt::MouseButton::LeftButton, targetPoint);
|
||||
|
||||
actionRunner.AddAction(m_interactWithTableAction);
|
||||
}
|
||||
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError("Failed to find Created Variable");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (variableId == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid ScriptCanvas::VariableId", m_variableId.c_str()));
|
||||
}
|
||||
|
||||
if (scriptCanvasId == nullptr)
|
||||
{
|
||||
ReportError(AZStd::string::format("%s is not a valid ScriptCanvasId", StateModelIds::ScriptCanvasId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ToggleBoolInputTest::ToggleBoolInPaletteState::OnStateActionsComplete()
|
||||
{
|
||||
const ScriptCanvas::VariableId* variableId = GetStateModel()->GetStateDataAs<ScriptCanvas::VariableId>(m_variableId);
|
||||
const ScriptCanvas::ScriptCanvasId* scriptCanvasId = GetStateModel()->GetStateDataAs<ScriptCanvas::ScriptCanvasId>(StateModelIds::ScriptCanvasId);
|
||||
|
||||
if (variableId && scriptCanvasId)
|
||||
{
|
||||
ScriptCanvas::GraphVariable* graphVariable = nullptr;
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(graphVariable, (*scriptCanvasId), &ScriptCanvas::GraphVariableManagerRequests::FindVariableById, (*variableId));
|
||||
|
||||
if (graphVariable)
|
||||
{
|
||||
const ScriptCanvas::Datum* datum = graphVariable->GetDatum();
|
||||
|
||||
if (datum && datum->GetType() == ScriptCanvas::Data::Type::Boolean())
|
||||
{
|
||||
bool currentValue = (*datum->GetAs<ScriptCanvas::Data::BooleanType>());
|
||||
|
||||
if (currentValue == m_originalValue)
|
||||
{
|
||||
ReportError("Failed to toggle Boolean value");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ToggleBoolInputTest::ToggleBoolInNodeState::ToggleBoolInNodeState(AutomationStateModelId endpointId)
|
||||
: NamedAutomationState("ToggleBoolInNodeState")
|
||||
, m_endpointId(endpointId)
|
||||
, m_clickAction(Qt::MouseButton::LeftButton)
|
||||
{
|
||||
SetStateName(AZStd::string::format("ToggleBoolInNodeState::%s", endpointId.c_str()));
|
||||
}
|
||||
|
||||
void ToggleBoolInputTest::ToggleBoolInNodeState::OnSetupStateActions(EditorAutomationActionRunner& actionRunner)
|
||||
{
|
||||
m_scriptCanvasEndpoint = ScriptCanvas::Endpoint();
|
||||
|
||||
const GraphCanvas::Endpoint* gcEndpoint = GetStateModel()->GetStateDataAs<GraphCanvas::Endpoint>(m_endpointId);
|
||||
const ScriptCanvas::ScriptCanvasId* scriptCanvasId = GetStateModel()->GetStateDataAs<ScriptCanvas::ScriptCanvasId>(StateModelIds::ScriptCanvasId);
|
||||
|
||||
if (gcEndpoint && scriptCanvasId)
|
||||
{
|
||||
ScriptCanvasEditor::EditorGraphRequestBus::EventResult(m_scriptCanvasEndpoint, (*scriptCanvasId), &ScriptCanvasEditor::EditorGraphRequests::ConvertToScriptCanvasEndpoint, (*gcEndpoint));
|
||||
|
||||
if (m_scriptCanvasEndpoint.IsValid())
|
||||
{
|
||||
const ScriptCanvas::Datum* datum = nullptr;
|
||||
ScriptCanvas::NodeRequestBus::EventResult(datum, m_scriptCanvasEndpoint.GetNodeId(), &ScriptCanvas::NodeRequests::FindDatum, m_scriptCanvasEndpoint.GetSlotId());
|
||||
|
||||
if (datum && datum->GetType() == ScriptCanvas::Data::Type::Boolean())
|
||||
{
|
||||
const ScriptCanvas::Data::BooleanType* booleanType = datum->GetAs<ScriptCanvas::Data::BooleanType>();
|
||||
|
||||
if (booleanType)
|
||||
{
|
||||
m_originalValue = (*booleanType);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError("Datum is missing or incorrect type.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError("Failed to convert Graph Canvas endpoint to Script Canvas endpoint");
|
||||
}
|
||||
|
||||
m_mouseToNodePropertyEditorAction = aznew MouseToNodePropertyEditorAction(gcEndpoint->GetSlotId());
|
||||
|
||||
actionRunner.AddAction(m_mouseToNodePropertyEditorAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
actionRunner.AddAction(&m_clickAction);
|
||||
actionRunner.AddAction(&m_processEvents);
|
||||
}
|
||||
}
|
||||
|
||||
void ToggleBoolInputTest::ToggleBoolInNodeState::OnStateActionsComplete()
|
||||
{
|
||||
if (m_scriptCanvasEndpoint.IsValid())
|
||||
{
|
||||
const ScriptCanvas::Datum* datum = nullptr;
|
||||
ScriptCanvas::NodeRequestBus::EventResult(datum, m_scriptCanvasEndpoint.GetNodeId(), &ScriptCanvas::NodeRequests::FindDatum, m_scriptCanvasEndpoint.GetSlotId());
|
||||
|
||||
if (datum && datum->GetType() == ScriptCanvas::Data::Type::Boolean())
|
||||
{
|
||||
const ScriptCanvas::Data::BooleanType* booleanType = datum->GetAs<ScriptCanvas::Data::BooleanType>();
|
||||
|
||||
if (booleanType)
|
||||
{
|
||||
if ((*booleanType) == m_originalValue)
|
||||
{
|
||||
ReportError("Boolean datum did not toggle after interaction");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError("Datum is missing or incorrect type.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ToggleBoolInputTest::ToggleBoolInputTest()
|
||||
: EditorAutomationTest("Bool Input Test")
|
||||
{
|
||||
AutomationStateModelId firstVariableTypeId = "VariableDataType";
|
||||
SetStateData(firstVariableTypeId, ScriptCanvas::Data::Type::Boolean());
|
||||
|
||||
AutomationStateModelId variableNameId = "VariableName";
|
||||
SetStateData(variableNameId, AZStd::string("Boolean"));
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
AutomationStateModelId variableId = "VariableId";
|
||||
AddState(new CreateVariableState(firstVariableTypeId, variableNameId, false, CreateVariableAction::CreationType::AutoComplete, variableId));
|
||||
|
||||
AddState(new ToggleBoolInPaletteState(variableId));
|
||||
|
||||
AutomationStateModelId viewCenter = "ViewCenter";
|
||||
AddState(new FindViewCenterState(viewCenter));
|
||||
|
||||
AutomationStateModelId variableNodeId = "VariableNodeId";
|
||||
AddState(new CreateVariableNodeFromGraphPaletteState(variableNameId, viewCenter, Qt::KeyboardModifier::AltModifier, variableNodeId));
|
||||
|
||||
AutomationStateModelId dataSlotId = "DataSlotId";
|
||||
AddState(new FindEndpointOfTypeState(variableNodeId, dataSlotId, GraphCanvas::ConnectionType::CT_Input, GraphCanvas::SlotTypes::DataSlot));
|
||||
|
||||
AddState(new ToggleBoolInNodeState(dataSlotId));
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
// VariableLifeCycleTest
|
||||
//////////////////////////
|
||||
|
||||
VariableLifeCycleTest::VariableLifeCycleTest(AZStd::string name, AZStd::vector<ScriptCanvas::Data::Type> dataTypes, CreateVariableAction::CreationType creationType)
|
||||
: EditorAutomationTest(name.c_str())
|
||||
, m_creationType(creationType)
|
||||
, m_typesToMake(dataTypes)
|
||||
{
|
||||
m_variableTypeId = "ActiveVariableTypeId";
|
||||
m_variableId = "ActiveVariableId";
|
||||
m_viewCenter = "ViewCenter";
|
||||
m_offsetCenter = "OffsetCenter";
|
||||
|
||||
AutomationStateModelId variableNameId = "VariableName";
|
||||
|
||||
AutomationStateModelId setNodeId = "SetNodeId";
|
||||
AutomationStateModelId getNodeId = "GetNodeId";
|
||||
|
||||
SetStateData(variableNameId, AZStd::string("LifeCycle"));
|
||||
|
||||
SetHasCustomTransitions(true);
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
m_findViewCenterState = new FindViewCenterState(m_viewCenter);
|
||||
AddState(m_findViewCenterState);
|
||||
|
||||
m_createVariableState = new CreateVariableState(m_variableTypeId, variableNameId, false, creationType, m_variableId);
|
||||
|
||||
AddState(m_createVariableState);
|
||||
|
||||
m_dragCreateGetNode = new CreateVariableNodeFromGraphPaletteState(variableNameId, m_viewCenter, Qt::KeyboardModifier::ShiftModifier, getNodeId);
|
||||
m_dragCreateSetNode = new CreateVariableNodeFromGraphPaletteState(variableNameId, m_offsetCenter, Qt::KeyboardModifier::AltModifier, setNodeId);
|
||||
|
||||
AddState(m_dragCreateSetNode);
|
||||
AddState(m_dragCreateGetNode);
|
||||
|
||||
m_createGetNode = new CreateNodeFromContextMenuState("Get LifeCycle", CreateNodeFromContextMenuState::CreationType::ScenePosition, m_viewCenter, getNodeId);
|
||||
m_createSetNode = new CreateNodeFromContextMenuState("Set LifeCycle", CreateNodeFromContextMenuState::CreationType::ScenePosition, m_offsetCenter, setNodeId);
|
||||
|
||||
AddState(m_createGetNode);
|
||||
AddState(m_createSetNode);
|
||||
|
||||
m_destroyGetNode = new AltClickSceneElementState(getNodeId);
|
||||
m_destroySetNode = new AltClickSceneElementState(setNodeId);
|
||||
|
||||
AddState(m_destroyGetNode);
|
||||
AddState(m_destroySetNode);
|
||||
|
||||
m_deleteVariableRowState = new DeleteVariableRowFromPaletteState(0);
|
||||
AddState(m_deleteVariableRowState);
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
|
||||
SetInitialStateId<CreateRuntimeGraphStateId>();
|
||||
}
|
||||
|
||||
void VariableLifeCycleTest::OnTestStarting()
|
||||
{
|
||||
m_activeIndex = -1;
|
||||
}
|
||||
|
||||
int VariableLifeCycleTest::EvaluateTransition(int stateId)
|
||||
{
|
||||
if (stateId == ForceCloseActiveGraphStateId::StateID())
|
||||
{
|
||||
return EditorAutomationState::EXIT_STATE_ID;
|
||||
}
|
||||
else if (stateId == CreateRuntimeGraphStateId::StateID())
|
||||
{
|
||||
return m_findViewCenterState->GetStateId();
|
||||
}
|
||||
else if (stateId == m_findViewCenterState->GetStateId())
|
||||
{
|
||||
const AZ::Vector2* viewCenter = GetStateDataAs<AZ::Vector2>(m_viewCenter);
|
||||
|
||||
if (viewCenter)
|
||||
{
|
||||
AZ::Vector2 offsetCenter = (*viewCenter);
|
||||
|
||||
const AZ::Vector2* minorStep = GetStateDataAs<AZ::Vector2>(StateModelIds::MinorStep);
|
||||
|
||||
if (minorStep)
|
||||
{
|
||||
offsetCenter -= (*minorStep);
|
||||
}
|
||||
|
||||
SetStateData(m_offsetCenter, offsetCenter);
|
||||
}
|
||||
|
||||
return SetupNextVariable();
|
||||
}
|
||||
else if (stateId == m_createVariableState->GetStateId())
|
||||
{
|
||||
if (m_createVariablesNodesViaContextMenu)
|
||||
{
|
||||
return m_createGetNode->GetStateId();
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_dragCreateGetNode->GetStateId();
|
||||
}
|
||||
}
|
||||
else if (stateId == m_createGetNode->GetStateId())
|
||||
{
|
||||
return m_createSetNode->GetStateId();
|
||||
}
|
||||
else if (stateId == m_dragCreateGetNode->GetStateId())
|
||||
{
|
||||
return m_dragCreateSetNode->GetStateId();
|
||||
}
|
||||
else if (stateId == m_createSetNode->GetStateId()
|
||||
|| stateId == m_dragCreateSetNode->GetStateId())
|
||||
{
|
||||
return m_destroySetNode->GetStateId();
|
||||
}
|
||||
else if (stateId == m_destroySetNode->GetStateId())
|
||||
{
|
||||
return m_destroyGetNode->GetStateId();
|
||||
}
|
||||
else if (stateId == m_destroyGetNode->GetStateId())
|
||||
{
|
||||
return m_deleteVariableRowState->GetStateId();
|
||||
}
|
||||
else if (stateId == m_deleteVariableRowState->GetStateId())
|
||||
{
|
||||
return SetupNextVariable();
|
||||
}
|
||||
|
||||
return EditorAutomationState::EXIT_STATE_ID;
|
||||
|
||||
}
|
||||
|
||||
int VariableLifeCycleTest::SetupNextVariable()
|
||||
{
|
||||
++m_activeIndex;
|
||||
|
||||
if (m_activeIndex < m_typesToMake.size())
|
||||
{
|
||||
SetStateData(m_variableTypeId, m_typesToMake[m_activeIndex]);
|
||||
SetStateData(m_variableId, ScriptCanvas::VariableId());
|
||||
|
||||
return m_createVariableState->GetStateId();
|
||||
}
|
||||
|
||||
return ForceCloseActiveGraphStateId::StateID();
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// RapidVariableCreationDeletionTest
|
||||
//////////////////////////////////////
|
||||
|
||||
RapidVariableCreationDeletionTest::RapidVariableCreationDeletionTest()
|
||||
: EditorAutomationTest("Mass Create/Destroy Variable Test")
|
||||
, m_variableType("Variable Type")
|
||||
{
|
||||
SetHasCustomTransitions(true);
|
||||
|
||||
AddState(new CreateRuntimeGraphState());
|
||||
|
||||
m_createVariableState = new CreateVariableState(m_variableType, "", false, CreateVariableAction::CreationType::Programmatic);
|
||||
AddState(m_createVariableState);
|
||||
|
||||
m_deleteVariableRowState = new DeleteVariableRowFromPaletteState(0);
|
||||
AddState(m_deleteVariableRowState);
|
||||
|
||||
AddState(new ForceCloseActiveGraphState());
|
||||
|
||||
SetInitialStateId<CreateRuntimeGraphStateId>();
|
||||
}
|
||||
|
||||
void RapidVariableCreationDeletionTest::OnTestStarting()
|
||||
{
|
||||
m_activeIndex = 0;
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(m_variableTypes, &ScriptCanvasEditor::VariableAutomationRequests::GetVariableTypes);
|
||||
ScriptCanvasEditor::VariableAutomationRequestBus::BroadcastResult(m_graphPalette, &ScriptCanvasEditor::VariableAutomationRequests::GetGraphPaletteTableView);
|
||||
}
|
||||
|
||||
int RapidVariableCreationDeletionTest::EvaluateTransition(int stateId)
|
||||
{
|
||||
if (stateId == CreateRuntimeGraphStateId::StateID()
|
||||
|| stateId == m_createVariableState->GetStateId())
|
||||
{
|
||||
return SetupNextVariable();
|
||||
}
|
||||
else if (stateId == m_deleteVariableRowState->GetStateId())
|
||||
{
|
||||
if (m_graphPalette->model()->rowCount() > 0)
|
||||
{
|
||||
return m_deleteVariableRowState->GetStateId();
|
||||
}
|
||||
else
|
||||
{
|
||||
return ForceCloseActiveGraphStateId::StateID();
|
||||
}
|
||||
}
|
||||
|
||||
return EditorAutomationState::EXIT_STATE_ID;
|
||||
}
|
||||
|
||||
int RapidVariableCreationDeletionTest::SetupNextVariable()
|
||||
{
|
||||
if (m_activeIndex >= m_variableTypes.size())
|
||||
{
|
||||
m_graphPalette->scrollToTop();
|
||||
return m_deleteVariableRowState->GetStateId();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetStateData(m_variableType, m_variableTypes[m_activeIndex]);
|
||||
++m_activeIndex;
|
||||
return m_createVariableState->GetStateId();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,333 @@
|
||||
/*
|
||||
* 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 <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QString>
|
||||
#include <QTableView>
|
||||
|
||||
#include <GraphCanvas/Components/Nodes/NodeBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/SlotBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
#include <GraphCanvas/Utils/ConversionUtils.h>
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/WidgetActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ConnectionActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/CreateElementsActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ElementInteractions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/GraphActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/VariableActions.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/CreateElementsStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/EditorViewStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/ElementInteractionStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/VariableStates.h>
|
||||
#include <ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/UtilityStates.h>
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
/**
|
||||
EditorAutmationTest that will create a variable of the specified type using the specified creation type, and optionally give it a name
|
||||
*/
|
||||
class ManuallyCreateVariableTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
ManuallyCreateVariableTest(ScriptCanvas::Data::Type dataType, CreateVariableAction::CreationType creationType, AZStd::string variableName = AZStd::string());
|
||||
~ManuallyCreateVariableTest() override = default;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that will provide a nicer name for the test.
|
||||
*/
|
||||
class CreateNamedVariableTest
|
||||
: public ManuallyCreateVariableTest
|
||||
{
|
||||
public:
|
||||
CreateNamedVariableTest(ScriptCanvas::Data::Type dataType, AZStd::string name, CreateVariableAction::CreationType creationType = CreateVariableAction::CreationType::AutoComplete);
|
||||
~CreateNamedVariableTest() override = default;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that will create a two variables with a duplicated name
|
||||
*/
|
||||
class DuplicateVariableNameTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
class CheckVariableForNameMismatchState
|
||||
: public CustomActionState
|
||||
{
|
||||
public:
|
||||
CheckVariableForNameMismatchState(AutomationStateModelId nameId, AutomationStateModelId variableId);
|
||||
~CheckVariableForNameMismatchState() override = default;
|
||||
|
||||
void OnCustomAction() override;
|
||||
|
||||
private:
|
||||
|
||||
AutomationStateModelId m_nameId;
|
||||
AutomationStateModelId m_variableId;
|
||||
};
|
||||
|
||||
public:
|
||||
DuplicateVariableNameTest(ScriptCanvas::Data::Type firstType, ScriptCanvas::Data::Type secondType, AZStd::string variableName);
|
||||
~DuplicateVariableNameTest() override = default;
|
||||
};
|
||||
|
||||
// General Helper States for the tests in this file.
|
||||
namespace EditStringLike
|
||||
{
|
||||
class VariableInPaletteState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
typedef std::function< AZ::Outcome<void, AZStd::string>(const ScriptCanvas::GraphVariable*)> VariablePaletteValidator;
|
||||
|
||||
VariableInPaletteState(AZStd::string value, AutomationStateModelId variableId, VariablePaletteValidator validator);
|
||||
~VariableInPaletteState() override = default;
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
AZStd::string m_stringValue;
|
||||
AutomationStateModelId m_variableId;
|
||||
|
||||
VariablePaletteValidator m_validator;
|
||||
|
||||
MouseMoveAction* m_moveToTableRow = nullptr;
|
||||
MouseClickAction m_clickAction;
|
||||
|
||||
ProcessUserEventsAction m_processEvents;
|
||||
|
||||
TypeStringAction m_typeStringAction;
|
||||
TypeCharAction m_typeReturnAction;
|
||||
};
|
||||
|
||||
class ValueInNodeState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
typedef std::function< AZ::Outcome<void, AZStd::string>(const ScriptCanvas::Datum*)> DatumValidator;
|
||||
|
||||
ValueInNodeState(AZStd::string value, AutomationStateModelId endpointId, DatumValidator datumValidator);
|
||||
~ValueInNodeState() override = default;
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
AZStd::string m_stringValue;
|
||||
AutomationStateModelId m_endpointId;
|
||||
|
||||
DatumValidator m_datumValidator;
|
||||
|
||||
MouseClickAction m_clickAction;
|
||||
|
||||
ProcessUserEventsAction m_processEvents;
|
||||
|
||||
TypeStringAction m_typeStringAction;
|
||||
TypeCharAction m_typeReturnAction;
|
||||
|
||||
MouseToNodePropertyEditorAction* m_moveToPropertyAction = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
EditorautomationTest that will test out a couple of ways of editing a number[GraphPalette modification, and on-node editing]
|
||||
*/
|
||||
class ModifyNumericInputTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
ModifyNumericInputTest(double value);
|
||||
~ModifyNumericInputTest() override = default;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that will test out a couple of ways of editing a string[GraphPalette modification, an on-node editing]
|
||||
*/
|
||||
class ModifyStringInputTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
ModifyStringInputTest(AZStd::string value);
|
||||
~ModifyStringInputTest() override = default;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that will test out a couple of ways of editing a bool[GraphPalette modification, an on-node editing]
|
||||
*/
|
||||
class ToggleBoolInputTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
enum State
|
||||
{
|
||||
CreateGraph,
|
||||
CreateVariable,
|
||||
ToggleBoolInPalette,
|
||||
CreateSetNode,
|
||||
ToggleBoolInNode,
|
||||
|
||||
CloseGraph
|
||||
};
|
||||
|
||||
class ToggleBoolInPaletteState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
ToggleBoolInPaletteState(AutomationStateModelId variableId);
|
||||
~ToggleBoolInPaletteState() override = default;
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
bool m_originalValue = false;
|
||||
|
||||
AutomationStateModelId m_variableId;
|
||||
|
||||
MouseClickAction* m_interactWithTableAction = nullptr;
|
||||
ProcessUserEventsAction m_processEvents;
|
||||
};
|
||||
|
||||
class ToggleBoolInNodeState
|
||||
: public NamedAutomationState
|
||||
{
|
||||
public:
|
||||
ToggleBoolInNodeState(AutomationStateModelId endpointId);
|
||||
~ToggleBoolInNodeState() override = default;
|
||||
|
||||
void OnSetupStateActions(EditorAutomationActionRunner& actionRunner) override;
|
||||
void OnStateActionsComplete() override;
|
||||
|
||||
private:
|
||||
|
||||
ScriptCanvas::Endpoint m_scriptCanvasEndpoint;
|
||||
bool m_originalValue = false;
|
||||
|
||||
AutomationStateModelId m_endpointId;
|
||||
|
||||
MouseToNodePropertyEditorAction* m_mouseToNodePropertyEditorAction = nullptr;
|
||||
|
||||
ProcessUserEventsAction m_processEvents;
|
||||
MouseClickAction m_clickAction;
|
||||
};
|
||||
|
||||
public:
|
||||
ToggleBoolInputTest();
|
||||
~ToggleBoolInputTest() override = default;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that takes in a set of variable types to create. For each type it will then create the variable, create a get and set node for that variable. Then clean-up the nodes and delete the variable.
|
||||
*/
|
||||
class VariableLifeCycleTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
VariableLifeCycleTest(AZStd::string name, AZStd::vector<ScriptCanvas::Data::Type> dataTypes, CreateVariableAction::CreationType creationType = CreateVariableAction::CreationType::AutoComplete);
|
||||
~VariableLifeCycleTest() override = default;
|
||||
|
||||
void OnTestStarting() override;
|
||||
|
||||
protected:
|
||||
|
||||
// Custom Transition
|
||||
int EvaluateTransition(int stateId) override;
|
||||
////
|
||||
|
||||
private:
|
||||
|
||||
int SetupNextVariable();
|
||||
|
||||
CreateVariableAction::CreationType m_creationType = CreateVariableAction::CreationType::AutoComplete;
|
||||
|
||||
ScriptCanvas::VariableId m_activeVariableId;
|
||||
AZStd::vector<CreateVariableAction*> m_createVariables;
|
||||
AZStd::vector<ScriptCanvas::Data::Type> m_typesToMake;
|
||||
|
||||
bool m_createVariablesNodesViaContextMenu = true;
|
||||
bool m_closedGraph = false;
|
||||
int m_activeIndex = 0;
|
||||
|
||||
GraphCanvas::ViewId m_viewId;
|
||||
GraphCanvas::GraphId m_graphId;
|
||||
ScriptCanvas::ScriptCanvasId m_scriptCanvasId;
|
||||
|
||||
AutomationStateModelId m_variableTypeId;
|
||||
AutomationStateModelId m_variableId;
|
||||
AutomationStateModelId m_viewCenter;
|
||||
AutomationStateModelId m_offsetCenter;
|
||||
|
||||
FindViewCenterState* m_findViewCenterState;
|
||||
|
||||
CreateVariableState* m_createVariableState;
|
||||
|
||||
CreateVariableNodeFromGraphPaletteState* m_dragCreateGetNode = nullptr;
|
||||
CreateVariableNodeFromGraphPaletteState* m_dragCreateSetNode = nullptr;
|
||||
|
||||
CreateNodeFromContextMenuState* m_createGetNode = nullptr;
|
||||
CreateNodeFromContextMenuState* m_createSetNode = nullptr;
|
||||
|
||||
AltClickSceneElementState* m_destroyGetNode = nullptr;
|
||||
AltClickSceneElementState* m_destroySetNode = nullptr;
|
||||
|
||||
DeleteVariableRowFromPaletteState* m_deleteVariableRowState = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
EditorautomationTest that will create every variable type(including all variations of containers) and then delete them all.
|
||||
*/
|
||||
class RapidVariableCreationDeletionTest
|
||||
: public EditorAutomationTest
|
||||
{
|
||||
public:
|
||||
|
||||
RapidVariableCreationDeletionTest();
|
||||
~RapidVariableCreationDeletionTest() override = default;
|
||||
|
||||
void OnTestStarting() override;
|
||||
|
||||
// Custom Transition
|
||||
int EvaluateTransition(int stateId) override;
|
||||
////
|
||||
|
||||
private:
|
||||
|
||||
int SetupNextVariable();
|
||||
|
||||
private:
|
||||
|
||||
QTableView* m_graphPalette = nullptr;
|
||||
|
||||
int m_activeIndex = 0;
|
||||
AZStd::vector< ScriptCanvas::Data::Type > m_variableTypes;
|
||||
|
||||
AutomationStateModelId m_variableType;
|
||||
|
||||
CreateVariableState* m_createVariableState = nullptr;
|
||||
DeleteVariableRowFromPaletteState* m_deleteVariableRowState = nullptr;
|
||||
|
||||
ShowGraphVariablesAction m_showGraphVariableAction;
|
||||
};
|
||||
}
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QMimeData>
|
||||
#include <QMenu>
|
||||
|
||||
namespace ScriptCanvasDeveloperEditor
|
||||
{
|
||||
@@ -34,17 +35,18 @@ namespace ScriptCanvasDeveloperEditor
|
||||
void DumpBehaviorContextMethods(AZStd::string& dumpStr);
|
||||
void DumpBehaviorContextEbuses(AZStd::string& dumpStr);
|
||||
|
||||
QAction* CreateNodeListDumpAction(QWidget* mainWindow)
|
||||
QAction* CreateNodeListDumpAction(QMenu* mainMenu)
|
||||
{
|
||||
QAction* nodeDumpAction{};
|
||||
if (mainWindow)
|
||||
QAction* nodeDumpAction = nullptr;
|
||||
|
||||
if (mainMenu)
|
||||
{
|
||||
nodeDumpAction = new QAction(QAction::tr("Dump EBus Nodes"), mainWindow);
|
||||
nodeDumpAction = mainMenu->addAction(QAction::tr("Dump EBus Nodes"));
|
||||
nodeDumpAction->setAutoRepeat(false);
|
||||
nodeDumpAction->setToolTip("Dumps a list of all EBus nodes(their inputs and outputs) to the clipboard");
|
||||
nodeDumpAction->setShortcut(QKeySequence(QAction::tr("Ctrl+Alt+N", "Debug|Dump EBus Nodes")));
|
||||
mainWindow->addAction(nodeDumpAction);
|
||||
mainWindow->connect(nodeDumpAction, &QAction::triggered, &DumpBehaviorContextNodes);
|
||||
|
||||
QObject::connect(nodeDumpAction, &QAction::triggered, &DumpBehaviorContextNodes);
|
||||
}
|
||||
|
||||
return nodeDumpAction;
|
||||
@@ -391,5 +393,5 @@ namespace ScriptCanvasDeveloperEditor
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace NodeListDumpAction
|
||||
}
|
||||
}
|
||||
|
||||
+49
-7
@@ -11,6 +11,9 @@
|
||||
*/
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QMenuBar>
|
||||
|
||||
#include <AzToolsFramework/UI/PropertyEditor/GenericComboBoxCtrl.h>
|
||||
|
||||
#include <ScriptCanvas/Libraries/Libraries.h>
|
||||
@@ -19,12 +22,20 @@
|
||||
#include <ScriptCanvasDeveloperEditor/NodeListDumpAction.h>
|
||||
#include <ScriptCanvasDeveloperEditor/TSGenerateAction.h>
|
||||
#include <ScriptCanvasDeveloperEditor/AutomationActions/DynamicSlotFullCreation.h>
|
||||
#include <ScriptCanvasDeveloperEditor/AutomationActions/FullyConnectedNodePaletteCreation.h>
|
||||
#include <ScriptCanvasDeveloperEditor/AutomationActions/NodePaletteFullCreation.h>
|
||||
#include <ScriptCanvasDeveloperEditor/AutomationActions/VariableListFullCreation.h>
|
||||
#include <ScriptCanvasDeveloperEditor/Developer.h>
|
||||
|
||||
#include <EditorAutomationTestDialog.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
|
||||
namespace ScriptCanvasDeveloperEditor
|
||||
{
|
||||
////////////////////
|
||||
// SystemComponent
|
||||
////////////////////
|
||||
void SystemComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
ScriptCanvasDeveloper::Libraries::Developer::Reflect(context);
|
||||
@@ -59,12 +70,14 @@ namespace ScriptCanvasDeveloperEditor
|
||||
|
||||
void SystemComponent::Activate()
|
||||
{
|
||||
QWidget* mainWindow{};
|
||||
QMainWindow* mainWindow = nullptr;
|
||||
ScriptCanvasEditor::UIRequestBus::BroadcastResult(mainWindow, &ScriptCanvasEditor::UIRequests::GetMainWindow);
|
||||
|
||||
if (mainWindow)
|
||||
{
|
||||
MainWindowCreationEvent(mainWindow);
|
||||
}
|
||||
|
||||
ScriptCanvasEditor::UINotificationBus::Handler::BusConnect();
|
||||
|
||||
AzToolsFramework::RegisterGenericComboBoxHandler<ScriptCanvas::Data::Type>();
|
||||
@@ -75,13 +88,42 @@ namespace ScriptCanvasDeveloperEditor
|
||||
ScriptCanvasEditor::UINotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void SystemComponent::MainWindowCreationEvent(QWidget* mainWindow)
|
||||
void SystemComponent::MainWindowCreationEvent(QMainWindow* mainWindow)
|
||||
{
|
||||
NodeListDumpAction::CreateNodeListDumpAction(mainWindow);
|
||||
TSGenerateAction::SetupTSFileAction(mainWindow);
|
||||
DynamicSlotFullCreation::CreateDynamicSlotFullCreationAction(mainWindow);
|
||||
NodePaletteFullCreation::CreateNodePaletteFullCreationAction(mainWindow);
|
||||
VariablePaletteFullCreation::CreateVariablePaletteFullCreationAction(mainWindow);
|
||||
QMenuBar* menuBar = mainWindow->menuBar();
|
||||
|
||||
QMenu* developerMenu = menuBar->addMenu("Developer");
|
||||
|
||||
VariablePaletteFullCreation::CreateVariablePaletteFullCreationAction(developerMenu);
|
||||
|
||||
developerMenu->addSeparator();
|
||||
|
||||
NodePaletteFullCreation::CreateNodePaletteFullCreationAction(developerMenu);
|
||||
DynamicSlotFullCreation::CreateDynamicSlotFullCreationAction(developerMenu);
|
||||
|
||||
developerMenu->addSeparator();
|
||||
|
||||
NodeListDumpAction::CreateNodeListDumpAction(developerMenu);
|
||||
TSGenerateAction::SetupTSFileAction(developerMenu);
|
||||
|
||||
developerMenu->addSeparator();
|
||||
|
||||
QAction* action = developerMenu->addAction("Open Menu Test");
|
||||
|
||||
QObject::connect(action, &QAction::triggered, [mainWindow]()
|
||||
{
|
||||
ScriptCanvasDeveloper::EditorAutomationTestDialogRequests* requests = ScriptCanvasDeveloper::EditorAutomationTestDialogRequestBus::FindFirstHandler(ScriptCanvasEditor::AssetEditorId);
|
||||
|
||||
if (requests)
|
||||
{
|
||||
requests->ShowTestDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
ScriptCanvasDeveloper::EditorAutomationTestDialog* testDialog = new ScriptCanvasDeveloper::EditorAutomationTestDialog(mainWindow);
|
||||
testDialog->ShowTestDialog();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QMimeData>
|
||||
#include <QMenu>
|
||||
|
||||
namespace ScriptCanvasDeveloperEditor
|
||||
{
|
||||
@@ -40,18 +41,18 @@ namespace ScriptCanvasDeveloperEditor
|
||||
void AddMessageNode(const XMLDocPtr& doc, const AZStd::string& classorbusName, const AZStd::string& eventormethodName, const AZStd::string& toolTip, const AZStd::string& categoryName, const AZ::BehaviorEBusHandler::BusForwarderEvent& event);
|
||||
void AddMessageNode(const XMLDocPtr& doc, const AZStd::string& classorbusName, const AZStd::string& eventormethodName, const AZStd::string& toolTip, const AZStd::string& categoryName, const AZ::BehaviorMethod* method);
|
||||
|
||||
QAction* SetupTSFileAction(QWidget* mainWindow)
|
||||
QAction* SetupTSFileAction(QMenu* mainMenu)
|
||||
{
|
||||
QAction* qAction = nullptr;
|
||||
|
||||
if (mainWindow)
|
||||
if (mainMenu)
|
||||
{
|
||||
qAction = new QAction(QAction::tr("Create EBus Localization File"), mainWindow);
|
||||
qAction = mainMenu->addAction(QAction::tr("Create EBus Localization File"));
|
||||
qAction->setAutoRepeat(false);
|
||||
qAction->setToolTip("Creates a QT .TS file of all EBus nodes(their inputs and outputs) to a file in the current folder.");
|
||||
qAction->setShortcut(QKeySequence(QAction::tr("Ctrl+Alt+X", "Debug|Build EBus .TS file")));
|
||||
mainWindow->addAction(qAction);
|
||||
mainWindow->connect(qAction, &QAction::triggered, &GenerateTSFile);
|
||||
|
||||
QObject::connect(qAction, &QAction::triggered, &GenerateTSFile);
|
||||
}
|
||||
|
||||
return qAction;
|
||||
@@ -437,5 +438,5 @@ namespace ScriptCanvasDeveloperEditor
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace TSGenerateAction
|
||||
}
|
||||
}
|
||||
|
||||
+23
-1
@@ -14,10 +14,20 @@
|
||||
|
||||
#include <AzCore/Component/Component.h>
|
||||
|
||||
#include <ScriptCanvas/PerformanceStatistician.h>
|
||||
|
||||
#ifdef IMGUI_ENABLED
|
||||
#include <imgui/imgui.h>
|
||||
#include <ImGuiBus.h>
|
||||
#endif // IMGUI_ENABLED
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
class SystemComponent
|
||||
: public AZ::Component
|
||||
#ifdef IMGUI_ENABLED
|
||||
, public ImGui::ImGuiUpdateListenerBus::Handler
|
||||
#endif // IMGUI_ENABLED
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(SystemComponent, "{46BDD372-8E86-4C0F-B12C-DC271C5DCED1}");
|
||||
@@ -29,10 +39,22 @@ namespace ScriptCanvasDeveloper
|
||||
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// AZ::Component interface implementation
|
||||
// AZ::Component...
|
||||
void Init() override;
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
////
|
||||
|
||||
#ifdef IMGUI_ENABLED
|
||||
|
||||
void OnImGuiMainMenuUpdate() override;
|
||||
|
||||
void GraphHistoryListBox();
|
||||
|
||||
void FullPerformanceWindow();
|
||||
|
||||
#endif // IMGUI_ENABLED
|
||||
private:
|
||||
ScriptCanvas::Execution::PerformanceStatistician m_perfStatistician;
|
||||
};
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,4 +30,4 @@ namespace ScriptCanvasDeveloper
|
||||
AZ::ComponentTypeList GetRequiredSystemComponents() const override;
|
||||
|
||||
};
|
||||
} // namespace ScriptCanvasDeveloper
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
@@ -9,13 +9,31 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <ScriptCanvasDeveloper/ScriptCanvasDeveloperComponent.h>
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <ScriptCanvas/Core/Connection.h>
|
||||
#include <ScriptCanvas/Core/Graph.h>
|
||||
#include <ScriptCanvas/Core/Node.h>
|
||||
#include <ScriptCanvasDeveloper/ScriptCanvasDeveloperComponent.h>
|
||||
|
||||
namespace ScriptCanvasDeveloperComponentCpp
|
||||
{
|
||||
bool GetListEntryFromAZStdStringVector(void* data, int idx, const char** out_text)
|
||||
{
|
||||
AZStd::vector<AZStd::string>* vector = reinterpret_cast<AZStd::vector<AZStd::string>*>(data);
|
||||
|
||||
if (idx < vector->size())
|
||||
{
|
||||
*out_text = (*vector)[idx].c_str();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace ScriptCanvasDeveloper
|
||||
{
|
||||
@@ -27,6 +45,8 @@ namespace ScriptCanvasDeveloper
|
||||
->Version(0)
|
||||
;
|
||||
}
|
||||
|
||||
ScriptCanvas::Execution::PerformanceStatistician::Reflect(context);
|
||||
}
|
||||
|
||||
void SystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
|
||||
@@ -41,9 +61,43 @@ namespace ScriptCanvasDeveloper
|
||||
|
||||
void SystemComponent::Activate()
|
||||
{
|
||||
#ifdef IMGUI_ENABLED
|
||||
ImGui::ImGuiUpdateListenerBus::Handler::BusConnect();
|
||||
#endif // IMGUI_ENABLED
|
||||
|
||||
}
|
||||
|
||||
void SystemComponent::Deactivate()
|
||||
{
|
||||
#ifdef IMGUI_ENABLED
|
||||
ImGui::ImGuiUpdateListenerBus::Handler::BusDisconnect();
|
||||
#endif // IMGUI_ENABLED
|
||||
}
|
||||
|
||||
#ifdef IMGUI_ENABLED
|
||||
|
||||
void SystemComponent::FullPerformanceWindow()
|
||||
{
|
||||
GraphHistoryListBox();
|
||||
}
|
||||
|
||||
void SystemComponent::GraphHistoryListBox()
|
||||
{
|
||||
AZStd::vector<AZStd::string> scriptHistory = m_perfStatistician.GetExecutedScriptsSinceLastSnapshot();
|
||||
int index = 0;
|
||||
const int k_HeightInItemCount = 30;
|
||||
ImGui::ListBox(":Graph", &index, &ScriptCanvasDeveloperComponentCpp::GetListEntryFromAZStdStringVector, &scriptHistory, aznumeric_cast<int>(scriptHistory.size()), k_HeightInItemCount);
|
||||
}
|
||||
|
||||
void SystemComponent::OnImGuiMainMenuUpdate()
|
||||
{
|
||||
if (ImGui::BeginMenu("Script Canvas"))
|
||||
{
|
||||
FullPerformanceWindow();
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
#endif // IMGUI_ENABLED
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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 "precompiled.h"
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
class ScriptCanvasDeveloperTest
|
||||
: public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
static void TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
TEST_F(ScriptCanvasDeveloperTest, Sanity_Pass)
|
||||
{
|
||||
EXPECT_TRUE(true);
|
||||
}
|
||||
|
||||
|
||||
AZ_UNIT_TEST_HOOK();
|
||||
@@ -10,6 +10,26 @@
|
||||
#
|
||||
|
||||
set(FILES
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationAction.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationModelIds.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ConnectionActions.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/CreateElementsActions.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ElementInteractions.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/GraphActions.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/VariableActions.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorKeyActions.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/EditorMouseActions.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/GenericActions.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationActions/WidgetActions.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/ConnectionStates.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/CreateElementsStates.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/EditorViewStates.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/ElementInteractionStates.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/GraphStates.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/UtilityStates.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/VariableStates.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/Developer.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/DeveloperUtils.h
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/ScriptCanvasDeveloperEditorComponent.h
|
||||
@@ -22,6 +42,8 @@ set(FILES
|
||||
Editor/Include/ScriptCanvasDeveloperEditor/AutomationActions/VariableListFullCreation.h
|
||||
Editor/Source/Developer.cpp
|
||||
Editor/Source/DeveloperUtils.cpp
|
||||
Editor/Source/EditorAutomationTestDialog.h
|
||||
Editor/Source/EditorAutomationTestDialog.cpp
|
||||
Editor/Source/ScriptCanvasDeveloperGem.cpp
|
||||
Editor/Source/ScriptCanvasDeveloperEditorComponent.cpp
|
||||
Editor/Source/Mock.cpp
|
||||
@@ -33,4 +55,33 @@ set(FILES
|
||||
Editor/Source/AutomationActions/DynamicSlotFullCreation.cpp
|
||||
Editor/Source/AutomationActions/NodePaletteFullCreation.cpp
|
||||
Editor/Source/AutomationActions/VariableListFullCreation.cpp
|
||||
Editor/Source/EditorAutomation/EditorAutomationTest.cpp
|
||||
Editor/Source/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ConnectionActions.cpp
|
||||
Editor/Source/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/CreateElementsActions.cpp
|
||||
Editor/Source/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/EditorViewActions.cpp
|
||||
Editor/Source/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/ElementInteractions.cpp
|
||||
Editor/Source/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/GraphActions.cpp
|
||||
Editor/Source/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/VariableActions.cpp
|
||||
Editor/Source/EditorAutomation/EditorAutomationActions/EditorKeyActions.cpp
|
||||
Editor/Source/EditorAutomation/EditorAutomationActions/EditorMouseActions.cpp
|
||||
Editor/Source/EditorAutomation/EditorAutomationActions/GenericActions.cpp
|
||||
Editor/Source/EditorAutomation/EditorAutomationActions/WidgetActions.cpp
|
||||
Editor/Source/EditorAutomation/EditorAutomationStates/ConnectionStates.cpp
|
||||
Editor/Source/EditorAutomation/EditorAutomationStates/CreateElementsStates.cpp
|
||||
Editor/Source/EditorAutomation/EditorAutomationStates/EditorViewStates.cpp
|
||||
Editor/Source/EditorAutomation/EditorAutomationStates/ElementInteractionStates.cpp
|
||||
Editor/Source/EditorAutomation/EditorAutomationStates/GraphStates.cpp
|
||||
Editor/Source/EditorAutomation/EditorAutomationStates/UtilityStates.cpp
|
||||
Editor/Source/EditorAutomation/EditorAutomationStates/VariableStates.cpp
|
||||
Editor/Source/EditorAutomationTests/EditorAutomationTests.h
|
||||
Editor/Source/EditorAutomationTests/GraphCreationTests.h
|
||||
Editor/Source/EditorAutomationTests/GraphCreationTests.cpp
|
||||
Editor/Source/EditorAutomationTests/GroupTests.h
|
||||
Editor/Source/EditorAutomationTests/GroupTests.cpp
|
||||
Editor/Source/EditorAutomationTests/InteractionTests.h
|
||||
Editor/Source/EditorAutomationTests/InteractionTests.cpp
|
||||
Editor/Source/EditorAutomationTests/NodeCreationTests.h
|
||||
Editor/Source/EditorAutomationTests/NodeCreationTests.cpp
|
||||
Editor/Source/EditorAutomationTests/VariableTests.h
|
||||
Editor/Source/EditorAutomationTests/VariableTests.cpp
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user