partial reload from json working, but edges make problems
This commit is contained in:
+21
-3
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include "graph-manager.h"
|
||||
#include "node.h"
|
||||
#include "vmath.h"
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
@@ -82,7 +83,24 @@ int main(){
|
||||
std::ifstream f("state.json");
|
||||
json graph = json::parse(f);
|
||||
|
||||
app.gm = graph["graphmanager"].template get<VISEQ::GRAPH::GraphManager>();
|
||||
// app.gm = graph["graphmanager"].get<VISEQ::GRAPH::GraphManager>();
|
||||
for(auto n : graph.at("graphmanager").at("nodes")){
|
||||
std::shared_ptr<MidiNode> mn = n;
|
||||
app.gm.nodes.push_back(mn);
|
||||
/*app.gm.addMidiNode(n.at("position").get<Vec2Df>());*/
|
||||
/*app.gm.nodes.back().midi_note_channel = n.at("midi_note_channel").get<int>();*/
|
||||
}
|
||||
|
||||
for(auto e : graph.at("graphmanager").at("edges")){
|
||||
int start_id = e.at("start").get<int>();
|
||||
int end_id = e.at("end").get<int>();
|
||||
|
||||
VEC_SPTR_Node start = app.gm.nodes | RANGE_FILTER([start_id](SPTR_Node n){return n->id == start_id;}) | std::ranges::to<VEC_SPTR_Node>();
|
||||
VEC_SPTR_Node end = app.gm.nodes | RANGE_FILTER([end_id](SPTR_Node n){return n->id == end_id;}) | std::ranges::to<VEC_SPTR_Node>();
|
||||
|
||||
if(!start.empty() && !end.empty()) app.gm.addConnection(start.front(), end.front());
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
for(int i = 0; i < 4; ++i){
|
||||
@@ -403,8 +421,8 @@ int main(){
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
std::ofstream file("state.json");
|
||||
file << json(app);
|
||||
//std::ofstream file("state.json");
|
||||
//file << json(app);
|
||||
|
||||
std::cout << std::setw(4) << json(app) << std::endl;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user