10#include "../system/system_utils.h"
47 doc->type = graphType;
48 doc->graphKind = graphKind;
50 std::string name = graphKind +
" " + std::to_string(
newId.value);
57 SYSTEM_LOG <<
"[NodeGraphManager] Created graph " <<
newId.
value <<
" (" << graphKind <<
")" << std::endl;
67 SYSTEM_LOG <<
"[NodeGraphManager] Failed to load graph from " << filepath << std::endl;
78 std::string name = filepath;
79 size_t lastSlash = filepath.find_last_of(
"/\\");
90 SYSTEM_LOG <<
"[NodeGraphManager] Loaded graph " <<
newId.
value <<
" from " << filepath << std::endl;
100 SYSTEM_LOG <<
"[NodeGraphManager] Cannot save: graph " <<
id.value <<
" not found" << std::endl;
108 SYSTEM_LOG <<
"[NodeGraphManager] Failed to save graph to " << filepath << std::endl;
112 it->second->SetDirty(
false);
114 SYSTEM_LOG <<
"[NodeGraphManager] Saved graph " <<
id.value <<
" to " << filepath << std::endl;
150 SYSTEM_LOG <<
"[NodeGraphManager] Closed graph " <<
id.
value << std::endl;
185 return it->second.get();
192 std::vector<GraphId>
ids;
195 ids.push_back(
it->first);
ComponentTypeID GetComponentTypeID_Static()
Migration system for JSON versions.
Singleton manager for multiple node graphs.
Main document class for a node graph.
static GraphDocument LoadWithMigration(const json &j)
Load graph with automatic migration.
Singleton manager for multiple node graphs.
std::string GetGraphName(GraphId id) const
Get graph name (for tab display)
std::map< GraphId, std::string > m_graphNames
GraphDocument * GetGraph(GraphId id)
Get graph by ID.
static NodeGraphManager & Get()
Get singleton instance.
void SetActiveGraph(GraphId id)
Set active graph.
GraphDocument * GetActiveGraph()
Get active graph.
GraphId CreateGraph(const std::string &graphType, const std::string &graphKind)
Create a new graph.
bool SaveGraph(GraphId id, const std::string &filepath)
Save a graph to file.
std::vector< GraphId > GetAllGraphIds() const
Get all graph IDs.
std::vector< GraphId > m_graphOrder
GraphId LoadGraph(const std::string &filepath)
Load a graph from file.
std::map< GraphId, std::unique_ptr< GraphDocument > > m_graphs
bool CloseGraph(GraphId id)
Close a graph.
bool LoadJsonFromFile(const std::string &filepath, json &j)
Load and parse a JSON file.
bool SaveJsonToFile(const std::string &filepath, const json &j, int indent=4)
Save a JSON object to a file with formatting.
< Provides AssetID and INVALID_ASSET_ID