initial scriptcanvas source handle
Signed-off-by: chcurran <82187351+carlitosan@users.noreply.github.com>
This commit is contained in:
@@ -20,11 +20,6 @@ namespace AZ
|
||||
|
||||
namespace ScriptCanvasEditor
|
||||
{
|
||||
AZ::Outcome<void, AZStd::string> LoadScriptCanvasDataFromJson
|
||||
( ScriptCanvas::ScriptCanvasData& dataTarget
|
||||
, AZStd::string_view source
|
||||
, AZ::SerializeContext& serializeContext);
|
||||
|
||||
/**
|
||||
* Manages editor Script Canvas graph assets.
|
||||
*/
|
||||
|
||||
+12
-2
@@ -11,13 +11,23 @@
|
||||
|
||||
namespace ScriptCanvas
|
||||
{
|
||||
const Graph* ScriptCanvasData::GetGraph() const
|
||||
{
|
||||
return AZ::EntityUtils::FindFirstDerivedComponent<ScriptCanvas::Graph>(m_scriptCanvasEntity.get());
|
||||
}
|
||||
|
||||
const ScriptCanvasEditor::Graph* ScriptCanvasData::GetEditorGraph() const
|
||||
{
|
||||
return AZ::EntityUtils::FindFirstDerivedComponent<ScriptCanvasEditor::Graph>(m_scriptCanvasEntity.get());
|
||||
}
|
||||
|
||||
Graph* ScriptCanvasData::ModGraph()
|
||||
{
|
||||
return AZ::EntityUtils::FindFirstDerivedComponent<ScriptCanvas::Graph>(m_scriptCanvasEntity.get());
|
||||
}
|
||||
|
||||
const Graph* ScriptCanvasData::GetGraph() const
|
||||
ScriptCanvasEditor::Graph* ScriptCanvasData::ModEditorGraph()
|
||||
{
|
||||
return AZ::EntityUtils::FindFirstDerivedComponent<ScriptCanvas::Graph>(m_scriptCanvasEntity.get());
|
||||
return AZ::EntityUtils::FindFirstDerivedComponent<ScriptCanvasEditor::Graph>(m_scriptCanvasEntity.get());
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -28,9 +28,13 @@ namespace ScriptCanvas
|
||||
|
||||
AZ::Entity* GetScriptCanvasEntity() const { return m_scriptCanvasEntity.get(); }
|
||||
|
||||
const Graph* GetGraph() const;
|
||||
|
||||
const ScriptCanvasEditor::Graph* GetEditorGraph() const;
|
||||
|
||||
Graph* ModGraph();
|
||||
|
||||
const Graph* GetGraph() const;
|
||||
ScriptCanvasEditor::Graph* ModEditorGraph();
|
||||
|
||||
AZStd::unique_ptr<AZ::Entity> m_scriptCanvasEntity;
|
||||
private:
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Asset/AssetManager.h>
|
||||
#include <AzCore/Asset/AssetTypeInfoBus.h>
|
||||
#include <AzCore/Serialization/ObjectStream.h>
|
||||
#include <ScriptCanvas/Assets/ScriptCanvasAsset.h>
|
||||
#include <ScriptCanvas/Assets/ScriptCanvasSourceFileHandle.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
class SerializeContext;
|
||||
}
|
||||
|
||||
namespace ScriptCanvas
|
||||
{
|
||||
class ScriptCanvasData;
|
||||
}
|
||||
|
||||
namespace ScriptCanvasEditor
|
||||
{
|
||||
AZ::Outcome<ScriptCanvasEditor::SourceHandle, AZStd::string> LoadFromFile(AZStd::string_view path);
|
||||
|
||||
AZ::Outcome<void, AZStd::string> LoadDataFromJson
|
||||
( ScriptCanvas::ScriptCanvasData& dataTarget
|
||||
, AZStd::string_view source
|
||||
, AZ::SerializeContext& serializeContext);
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Editor/Include/ScriptCanvas/Assets/ScriptCanvasSourceFileHandle.h>
|
||||
#include <Editor/Include/ScriptCanvas/Assets/ScriptCanvasBaseAssetData.h>
|
||||
|
||||
namespace ScriptCanvasEditor
|
||||
{
|
||||
SourceHandle::SourceHandle(ScriptCanvas::DataPtr graph, const AZ::Uuid& id, AZStd::string_view path)
|
||||
: m_data(graph)
|
||||
, m_id(id)
|
||||
, m_path(path)
|
||||
{}
|
||||
|
||||
void SourceHandle::Clear()
|
||||
{
|
||||
m_data = nullptr;
|
||||
m_id = AZ::Uuid::CreateNull();
|
||||
m_path.clear();
|
||||
}
|
||||
|
||||
GraphPtrConst SourceHandle::Get() const
|
||||
{
|
||||
return m_data ? m_data->GetEditorGraph() : nullptr;
|
||||
}
|
||||
|
||||
const AZ::Uuid& SourceHandle::Id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
bool SourceHandle::IsValid() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
GraphPtr SourceHandle::Mod() const
|
||||
{
|
||||
return m_data ? m_data->ModEditorGraph() : nullptr;
|
||||
}
|
||||
|
||||
SourceHandle::operator bool() const
|
||||
{
|
||||
return m_data != nullptr;
|
||||
}
|
||||
|
||||
bool SourceHandle::operator!() const
|
||||
{
|
||||
return m_data == nullptr;
|
||||
}
|
||||
|
||||
const AZStd::string& SourceHandle::Path() const
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Math/Uuid.h>
|
||||
#include <ScriptCanvas/Core/Core.h>
|
||||
|
||||
namespace ScriptCanvasEditor
|
||||
{
|
||||
class SourceHandle
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO(SourceHandle, "{65855A98-AE2F-427F-BFC8-69D45265E312}");
|
||||
AZ_CLASS_ALLOCATOR(SourceHandle, AZ::SystemAllocator, 0);
|
||||
|
||||
SourceHandle() = default;
|
||||
|
||||
SourceHandle(ScriptCanvas::DataPtr graph, const AZ::Uuid& id, AZStd::string_view path);
|
||||
|
||||
void Clear();
|
||||
|
||||
GraphPtrConst Get() const;
|
||||
|
||||
const AZ::Uuid& Id() const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
GraphPtr Mod() const;
|
||||
|
||||
operator bool() const;
|
||||
|
||||
bool operator!() const;
|
||||
|
||||
const AZStd::string& Path() const;
|
||||
|
||||
private:
|
||||
ScriptCanvas::DataPtr m_data;
|
||||
AZ::Uuid m_id = AZ::Uuid::CreateNull();
|
||||
AZStd::string m_path;
|
||||
};
|
||||
}
|
||||
@@ -126,7 +126,7 @@ namespace ScriptCanvasEditor
|
||||
virtual void DisconnectEndpoints(const AZ::EntityId& /*sceneId*/, const AZStd::vector<GraphCanvas::Endpoint>& /*endpoints*/) {}
|
||||
|
||||
virtual void PostUndoPoint(ScriptCanvas::ScriptCanvasId) = 0;
|
||||
virtual void SignalSceneDirty(AZ::Data::AssetId) = 0;
|
||||
virtual void SignalSceneDirty(SourceHandle) = 0;
|
||||
|
||||
// Increment the value of the ignore undo point tracker
|
||||
virtual void PushPreventUndoStateUpdate() = 0;
|
||||
|
||||
@@ -101,6 +101,8 @@ namespace ScriptCanvasEditor
|
||||
public:
|
||||
AZ_COMPONENT(Graph, "{4D755CA9-AB92-462C-B24F-0B3376F19967}", ScriptCanvas::Graph);
|
||||
|
||||
static ScriptCanvas::DataPtr Create();
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
Graph(const ScriptCanvas::ScriptCanvasId& scriptCanvasId = AZ::Entity::MakeId())
|
||||
|
||||
Reference in New Issue
Block a user